huang
2025-08-29 d1bd20f33173a250015130bbe68fd47f37fd9160
JiuMuMesParent/moduleService/DeviceInteractionModule/src/main/java/com/mes/job/MachineTask.java
@@ -21,6 +21,7 @@
/**
 * 自动打标机
 *
 * @Author : yanzhxiin
 * @Date: 2024/8/20 11:19
 * @Description:
@@ -63,6 +64,7 @@
    //机械手
    @Scheduled(fixedDelay = 500)
    public void MarkingTasks() {
        try {
        machineListLoad =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"上片"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "loadTask");
@@ -84,10 +86,15 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("MarkingTasks:{}", exception.getMessage());
    }
    }
    //磨边机
    @Scheduled(fixedDelay = 500)
    public void edgingTasks() {
        try {
        machineListEdging =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"磨边"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "edgingTask");
@@ -100,11 +107,15 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("edgingTasks:{}", exception.getMessage());
        }
    }
    //翻片台
    @Scheduled(fixedDelay = 500)
    public void flipSliceTasks() {
        try {
        machineListFlipSlice =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"翻片"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "flipSlice");
@@ -117,11 +128,16 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("flipSliceTasks:{}", exception.getMessage());
        }
    }
    //打标机
    @Scheduled(fixedDelay = 500)
    public void markingTasks() {
        try {
        machineListMarking =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"自动打标机"));
        JSONObject jsonObject = new JSONObject();
@@ -135,11 +151,15 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("markingTasks:{}", exception.getMessage());
        }
    }
    //丝印机
    @Scheduled(fixedDelay = 500)
    public void silkScreenTasks() {
        try {
        machineListSilkScreen =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"自动丝印机"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "silkScreenTask");
@@ -152,10 +172,15 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("silkScreenTasks:{}", exception.getMessage());
    }
    }
    //点胶机
    //@Scheduled(fixedDelay = 500)
    @Scheduled(fixedDelay = 500)
    public void glueDispenserTasks() {
        try {
        machineListGlueDispenser =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"自动点胶机"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "glueDispenser");
@@ -168,10 +193,15 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("glueDispenserTasks:{}", exception.getMessage());
    }
    }
    //旋转台
    @Scheduled(fixedDelay = 500)
    public void rotateTasks() {
        try {
        machineListRotate =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"旋转台"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "rotate");
@@ -184,10 +214,15 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("rotateTasks:{}", exception.getMessage());
    }
    }
    //贴膜机
    @Scheduled(fixedDelay = 500)
    public void laminationTasks() {
        try {
        machineListLamination =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"自动贴膜机"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "lamination");
@@ -200,13 +235,16 @@
            jsonObject.append(machine.getId().toString(), jsonObjectItem);
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("laminationTasks:{}", exception.getMessage());
        }
    }
    //报工页面查询
    @Scheduled(fixedDelay = 1000)
    public void manualReporting() {
        try {
        machineListScanQrCode =machineMapper.selectList(new QueryWrapper<Machine>().lambda().eq(Machine::getName,"识别报工"));
        JSONObject jsonObject = new JSONObject();
        jsonObject.append("sessionMapName", "manualReporting");
@@ -227,19 +265,28 @@
        }
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("manualReporting:{}", exception.getMessage());
    }
    }
    //线下玻璃查询
    @Scheduled(fixedDelay = 1000)
    public void downLineTask() {
        try {
        JSONObject jsonObject = new JSONObject();
        List<Tasking> downLineTask=taskingService.findDownLineTask();
        jsonObject.append("sessionMapName", "downLineTask");
        jsonObject.append("downLineTask", downLineTask);
        this.webSocketServer(jsonObject);
        } catch (Exception exception) {
            log.info("downLineTask:{}", exception.getMessage());
        }
    }
    public void webSocketServer(JSONObject jsonObject) {
        try {
            log.info("发送数据:{}", jsonObject.getJSONArray("sessionMapName").get(0).toString());
            String sessionMapName=jsonObject.getJSONArray("sessionMapName").get(0).toString();
            webSocketServer.sendToWeb(sessionMapName, jsonObject.toString());
        } catch (Exception ex) {