ZengTao
2025-03-17 a7c479daff0e44988f174f8c93fb41f30fdc48e1
hangzhoumesParent/moduleService/hollowGlassModule/src/main/java/com/mes/job/PushMessageToIndex.java
@@ -11,9 +11,12 @@
import com.mes.common.config.Const;
import com.mes.hollow.entity.HollowBigStorageCageDetails;
import com.mes.hollow.entity.HollowGlassOutRelationInfo;
import com.mes.hollow.entity.dto.FlowCardGlassInfoDTO;
import com.mes.hollow.entity.vo.HollowBigStorageDetailsQueryVO;
import com.mes.hollow.service.HollowBigStorageCageDetailsService;
import com.mes.hollow.service.HollowBigStorageCageService;
import com.mes.hollow.service.HollowGlassOutRelationInfoService;
import com.mes.hollow.service.HollowGlassRelationInfoService;
import com.mes.hollowqueue.entity.HollowGlassQueueInfo;
import com.mes.hollowqueue.service.HollowGlassQueueInfoService;
import com.mes.tools.WebSocketServer;
@@ -48,6 +51,8 @@
    HollowBigStorageCageDetailsService hollowBigStorageCageDetailsService;
    @Resource
    BigStorageCageTaskService bigStorageCageTaskService;
    @Resource
    HollowGlassRelationInfoService hollowGlassRelationInfoService;
    @Autowired(required = false)
    MiloService miloService;
@@ -59,16 +64,15 @@
    public void hollowGlassTask() {
        List<HollowGlassOutRelationInfo> taskList = hollowGlassOutRelationInfoService.list(new LambdaQueryWrapper<HollowGlassOutRelationInfo>()
                .in(HollowGlassOutRelationInfo::getState, Const.HOLLOW_FLOW_CARD_START));
        if (CollectionUtil.isEmpty(taskList)) {
            return;
        }
        JSONObject jsonObject = new JSONObject();
        List<Long> taskIdList = taskList.stream().map(HollowGlassOutRelationInfo::getId).collect(Collectors.toList());
        List<HollowGlassQueueInfo> list = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>().in(HollowGlassQueueInfo::getRelationId, taskIdList));
        Map<Integer, List<HollowGlassQueueInfo>> listMap = list.stream().collect(Collectors.groupingBy(HollowGlassQueueInfo::getCell));
        jsonObject.append("930", listMap.get(930));
        jsonObject.append("931", listMap.get(931));
        jsonObject.append("932", listMap.get(932));
        if (CollectionUtil.isNotEmpty(taskList)) {
            List<Long> taskIdList = taskList.stream().map(HollowGlassOutRelationInfo::getId).collect(Collectors.toList());
            List<HollowGlassQueueInfo> list = hollowGlassQueueInfoService.list(new LambdaQueryWrapper<HollowGlassQueueInfo>().in(HollowGlassQueueInfo::getRelationId, taskIdList));
            Map<Integer, List<HollowGlassQueueInfo>> listMap = list.stream().collect(Collectors.groupingBy(HollowGlassQueueInfo::getCell));
            jsonObject.append("930", listMap.get(930));
            jsonObject.append("931", listMap.get(931));
            jsonObject.append("932", listMap.get(932));
        }
        try {
            //930空闲信号
            ReadWriteEntity freeOneRequestEntity = miloService.readFromOpcUa("CMJ1.CMJ1.isFree");
@@ -138,8 +142,8 @@
                    BigStorageTaskVO task = new BigStorageTaskVO();
                    task.setGlassId(requestWord.getValue() + "");
                    int isExistCount = hollowBigStorageCageDetailsService.count(new LambdaQueryWrapper<HollowBigStorageCageDetails>().in(HollowBigStorageCageDetails::getGlassId, task.getGlassId())
                            .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL_ZERO));
                    if (isExistCount > 0 && "0".equals(targetSlotWord.getValue() + "")) {
                            .in(HollowBigStorageCageDetails::getState, Const.GLASS_STATE_IN_ALL));
                    if (isExistCount > 0) {
                        task.setIsSame(1);
                    } else {
                        task.setIsSame(0);
@@ -197,6 +201,33 @@
        //理片笼使用情况
        List<Map<String, Object>> bigStorageCageUsage = hollowBigStorageCageService.selectBigStorageCageUsage();
        jsonObject.append("bigStorageCageUsage", bigStorageCageUsage);
        //理片笼使用情况汇总
        HollowBigStorageDetailsQueryVO hollowBigStorageDetailsQueryVO = new HollowBigStorageDetailsQueryVO();
        List<FlowCardGlassInfoDTO> bigStorageCageUsageSummary = hollowGlassRelationInfoService.queryHollowAllFlowCardSummary(hollowBigStorageDetailsQueryVO);
        jsonObject.append("bigStorageCageUsageSummary", bigStorageCageUsageSummary);
    }
    @Scheduled(fixedDelay = 1000)
    public void largenScreen() {
        JSONObject jsonObject = new JSONObject();
        //理片笼使用情况
        List<Map<String, Object>> hollowBigStorageCageUsage = hollowBigStorageCageService.selectBigStorageCageUsage();
        jsonObject.append("hollowBigStorageCageUsage", hollowBigStorageCageUsage);
        ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("largenScreen");
        if (sendwServer != null) {
            for (WebSocketServer webserver : sendwServer) {
                if (webserver != null) {
                    webserver.sendMessage(jsonObject.toString());
                    List<String> messages = webserver.getMessages();
                    if (!messages.isEmpty()) {
                        // // 将最后一个消息转换为整数类型的列表
                        webserver.clearMessages();
                    }
                } else {
                    log.info("largenScreen is closed");
                }
            }
        }
    }
}