严智鑫
2024-08-05 00c4dfc5ac687c93e0b7abafc33abb693b38edd6
hangzhoumesParent/moduleService/CacheVerticalGlassModule/src/main/java/com/mes/job/PlcSlicecage.java
@@ -5,6 +5,7 @@
import com.mes.bigstorage.service.BigStorageCageDetailsService;
import com.mes.bigstorage.service.BigStorageCageService;
import com.mes.common.S7object;
import com.mes.common.utils.RedisUtil;
import com.mes.device.PlcParameterObject;
import com.mes.temperingglass.entity.TemperingGlassInfo;
import com.mes.temperingglass.service.TemperingGlassInfoService;
@@ -31,23 +32,24 @@
    private BigStorageCageDetailsService bigStorageCageDetailsService;
    @Resource
    private TemperingGlassInfoService temperingGlassInfoService;
    @Resource
    private RedisUtil redisUtil;
    private JSONObject jsonObject = new JSONObject();
    private JSONObject jsonObject1 = new JSONObject();
    public void queryDataSource1() throws InterruptedException {
        List<Double> carPostion=new ArrayList<>();
        carPostion.add(0.25);
        carPostion.add(0.5);
        jsonObject.append("carPostion",carPostion);
        //界面展示笼子信息
        jsonObject1.append("bigStorageCageInfos", bigStorageCageService.querybigStorageCageDetail());
        jsonObject.append("bigStorageCageInfos", bigStorageCageService.querybigStorageCageDetail());
        //进片任务数据
        List<BigStorageCageDetails> bigStorageCageDetailsFeedTask=bigStorageCageDetailsService.selectTask(1);
        List<BigStorageCageDetails> bigStorageCageDetailsFeedTask=bigStorageCageDetailsService.selectFeedTask();
        jsonObject.append("bigStorageCageDetailsFeedTask", bigStorageCageDetailsFeedTask);
        //出片任务数据
        List<BigStorageCageDetails> bigStorageCageDetailsOutTask=bigStorageCageDetailsService.selectTask(2);
        List<BigStorageCageDetails> bigStorageCageDetailsOutTask=bigStorageCageDetailsService.selectOutTask();
        jsonObject.append("bigStorageCageDetailsOutTask", bigStorageCageDetailsOutTask);
        //理片笼使用情况
@@ -56,6 +58,15 @@
        //理片笼表格信息
        jsonObject.append("bigStorageCageInfo", bigStorageCageService.querybigStorageCageDetailAll());
        //钢化开关
        boolean temperingSwitch=false;
        if(redisUtil.getCacheObject("temperingSwitch")==null){
            redisUtil.setCacheObject("temperingSwitch", false);
        }else{
            temperingSwitch=redisUtil.getCacheObject("temperingSwitch");
        }
        jsonObject.append("temperingSwitch", temperingSwitch);
    }
@@ -72,7 +83,6 @@
    @Scheduled(fixedDelay = 1000)
    public void plcStorageCageTask() throws InterruptedException {
        jsonObject = new JSONObject();
        jsonObject1 = new JSONObject();
        try {
            //查询使用数据源1查询数据
            queryDataSource1();
@@ -84,7 +94,6 @@
                for (WebSocketServer webserver : sendwServer) {
                    if (webserver != null) {
                        webserver.sendMessage(jsonObject.toString());
                        webserver.sendMessage(jsonObject1.toString());
                        List<String> messages = webserver.getMessages();
                        if (!messages.isEmpty()) {
                            // // 将最后一个消息转换为整数类型的列表
@@ -100,4 +109,25 @@
        }
    }
    @Scheduled(fixedDelay = 1000)
    public void temperingIsRun(){
        JSONObject jsonObject = new JSONObject();
        //进片任务数据
        List<BigStorageCageDetails> bigStorageCageDetailsFeedTask=bigStorageCageDetailsService.selectFeedTask();
        jsonObject.append("bigStorageCageDetailsFeedTask", bigStorageCageDetailsFeedTask);
        //出片任务数据
        List<BigStorageCageDetails> bigStorageCageDetailsOutTask=bigStorageCageDetailsService.selectOutTask();
        jsonObject.append("bigStorageCageDetailsOutTask", bigStorageCageDetailsOutTask);
        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("isRun");
        if (sendwServer != null) {
            for (WebSocketServer webserver : sendwServer) {
                if (webserver != null) {
                    webserver.sendMessage(jsonObject.toString());
                } else {
                    log.info("Home is closed");
                }
            }
        }
    }
}