| | |
| | |
|
| | | 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.DownGlassTask;
|
| | | import com.mes.downglassinfo.entity.request.DownGlassInfoRequest;
|
| | | import com.mes.downglassinfo.service.DownGlassInfoService;
|
| | | import com.mes.downglassinfo.service.DownGlassTaskService;
|
| | | import com.mes.downstorage.service.DownStorageCageService;
|
| | | import com.mes.downworkstation.entity.DownWorkstation;
|
| | | import com.mes.downworkstation.service.DownWorkstationService;
|
| | | import com.mes.tools.DateUtil;
|
| | | 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;
|
| | |
| | | private DownStorageCageService downStorageCageService;
|
| | | @Autowired
|
| | | private DownGlassInfoService downGlassInfoService;
|
| | | @Autowired
|
| | | private DownGlassTaskService downGlassTaskService;
|
| | |
|
| | |
|
| | | @Autowired
|
| | | private RedisUtil redisUtil;
|
| | |
|
| | | @Scheduled(fixedDelay = 2000)
|
| | | public void sendDownWorkstations() {
|
| | |
| | |
|
| | | @Scheduled(fixedDelay = 2000)
|
| | | public void sendDownGlassInfo() {
|
| | | DownGlassInfoRequest request = redisUtil.getCacheObject("downGlassRequest");
|
| | | if (null == request) {
|
| | | request = new DownGlassInfoRequest();
|
| | | }
|
| | | if (request.getBeginDate() == null) {
|
| | | request.setBeginDate(DateUtil.getBeginDate());
|
| | | request.setEndDate(DateUtil.getEndDate());
|
| | | }
|
| | | log.info("发送当前正在执行工程已落架的玻璃信息");
|
| | | LambdaQueryWrapper<DownGlassInfo> wrapper = new LambdaQueryWrapper<DownGlassInfo>()
|
| | | .between(null != request.getBeginDate(), DownGlassInfo::getGmtCreate, 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());
|
| | | List<DownGlassInfo> downGlassInfos = downGlassInfoService.list(new LambdaQueryWrapper<DownGlassInfo>()
|
| | | .inSql(DownGlassInfo::getEngineerId, "select engineer_id from engineering where state = 1"));
|
| | | Map<Integer, List<DownGlassInfo>> listMap = downGlassInfos.stream().collect(Collectors.groupingBy(DownGlassInfo::getWorkStationId));
|
| | | JSONObject jsonObject4 = new JSONObject();
|
| | | jsonObject4.append("downGlassInfos", downGlassInfos);
|
| | | jsonObject4.append("engineerIdList", engineerIdList);
|
| | |
|
| | | //钢化开关
|
| | | boolean autoPrint = false;
|
| | | if (redisUtil.getCacheObject("autoPrint") == null) {
|
| | | redisUtil.setCacheObject("autoPrint", false);
|
| | | } else {
|
| | | autoPrint = redisUtil.getCacheObject("autoPrint");
|
| | | }
|
| | | jsonObject4.append("autoPrint", autoPrint);
|
| | |
|
| | | ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("unloadglass");
|
| | | List<Map<String, Object>> list = downStorageCageService.selectDownStorageCages();
|
| | | jsonObject4.append("params", listMap);
|
| | | ArrayList<WebSocketServer> sendwServer4 = WebSocketServer.sessionMap.get("sendDownGlass");
|
| | | if (sendwServer4 != null) {
|
| | | for (WebSocketServer webserver : sendwServer4) {
|
| | | if (webserver != null && webserver.session.isOpen()) {
|
| | | webserver.sendMessage(jsonObject4.toString());
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | @Scheduled(fixedDelay = 1000)
|
| | | public void isRun() {
|
| | | JSONObject jsonObject = new JSONObject();
|
| | | //正在进行的任务
|
| | | List<DownWorkstation> downWorkstation = downWorkstationService.getoneDownWorkstations(1, 6);
|
| | | jsonObject.append("downWorkstation", downWorkstation);
|
| | | List<DownGlassTask> downGlassTask = downGlassTaskService.selectOutTaskCache();
|
| | | jsonObject.append("downGlassTask", downGlassTask);
|
| | | ArrayList<WebSocketServer> sendwServer = WebSocketServer.sessionMap.get("unLoadGlassIsRun");
|
| | | if (sendwServer != null) {
|
| | | for (WebSocketServer webserver : sendwServer) {
|
| | | if (webserver != null) {
|
| | | webserver.sendMessage(jsonObject.toString());
|
| | | } else {
|
| | | log.info("unLoadGlassIsRun is closed");
|
| | | }
|
| | | }
|
| | | }
|