zhoushihao
2024-08-06 3fd8fc38a8c0ee454b842f0ef189fd507b8d9468
hangzhoumesParent/moduleService/UnLoadGlassModule/src/main/java/com/mes/job/Downpush.java
@@ -2,13 +2,18 @@
import cn.hutool.json.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.mes.common.config.Const;
import com.mes.common.utils.RedisUtil;
import com.mes.downglassinfo.entity.DownGlassInfo;
import com.mes.downglassinfo.entity.request.DownGlassInfoRequest;
import com.mes.downglassinfo.service.DownGlassInfoService;
import com.mes.downstorage.service.DownStorageCageService;
import com.mes.downworkstation.entity.DownWorkstation;
import com.mes.downworkstation.service.DownWorkstationService;
import com.mes.tools.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
@@ -28,6 +33,9 @@
    private DownStorageCageService downStorageCageService;
    @Autowired
    private DownGlassInfoService downGlassInfoService;
    @Autowired
    private RedisUtil redisUtil;
    @Scheduled(fixedDelay = 2000)
    public void sendDownWorkstations() {
@@ -101,13 +109,26 @@
    @Scheduled(fixedDelay = 2000)
    public void sendDownGlassInfo() {
        DownGlassInfoRequest request = redisUtil.getCacheObject("downGlassRequest");
        if (null == request) {
            request = new DownGlassInfoRequest();
        }
        log.info("发送当前正在执行工程已落架的玻璃信息");
        List<DownGlassInfo> downGlassInfos = downGlassInfoService.list(new LambdaQueryWrapper<DownGlassInfo>()
                .inSql(DownGlassInfo::getEngineerId, "select engineer_id from engineering where state = 1"));
        LambdaQueryWrapper<DownGlassInfo> wrapper = new LambdaQueryWrapper<DownGlassInfo>()
                .between(null != request.getBeginDate(), DownGlassInfo::getEngineerId, request.getBeginDate(), request.getEndDate())
                .eq(StringUtils.isNotBlank(request.getEngineerId()), DownGlassInfo::getEngineerId, request.getEngineerId());
        if (null == request.getWorkStationId() || 0 == request.getWorkStationId()) {
            wrapper.in(DownGlassInfo::getWorkStationId, Const.WORK_STATION_ALL);
        } else {
            wrapper.eq(DownGlassInfo::getWorkStationId, request.getWorkStationId());
        }
        List<DownGlassInfo> downGlassInfos = downGlassInfoService.list(wrapper);
        Map<Integer, List<DownGlassInfo>> listMap = downGlassInfos.stream().collect(Collectors.groupingBy(DownGlassInfo::getWorkStationId));
        List<Object> engineerIdListTemp = downGlassInfoService.listObjs(new QueryWrapper<DownGlassInfo>().select("distinct engineer_id"));
        List<String> engineerIdList = engineerIdListTemp.stream().map(String::valueOf).collect(Collectors.toList());
        JSONObject jsonObject4 = new JSONObject();
        List<Map<String, Object>> list = downStorageCageService.selectDownStorageCages();
        jsonObject4.append("params", listMap);
        jsonObject4.append("downGlassInfos", listMap);
        jsonObject4.append("engineerIdList", engineerIdList);
        ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("sendDownGlass");
        if (sendwServer4 != null) {
            for (WebSocketServer webserver : sendwServer4) {