| | |
| | | import com.baomidou.mybatisplus.mapper.EntityWrapper; |
| | | import com.core.common.Cools; |
| | | import com.zy.asrs.domain.param.CreateInTaskParam; |
| | | import com.zy.asrs.entity.BasCrnp; |
| | | import com.zy.asrs.entity.BasDevp; |
| | | import com.zy.asrs.entity.HttpRequestLog; |
| | | import com.zy.asrs.entity.WrkMast; |
| | | import com.zy.asrs.service.BasCrnpService; |
| | | import com.zy.asrs.service.BasDevpService; |
| | | import com.zy.asrs.service.HttpRequestLogService; |
| | | import com.zy.asrs.service.WrkMastService; |
| | | import com.zy.asrs.entity.*; |
| | | import com.zy.asrs.service.*; |
| | | import com.zy.asrs.utils.Utils; |
| | | import com.zy.common.model.StartupDto; |
| | | import com.zy.common.service.CommonService; |
| | |
| | | private ConfigService configService; |
| | | @Autowired |
| | | private HttpRequestLogService httpRequestLogService; |
| | | @Autowired |
| | | private LocMastService locMastService; |
| | | |
| | | //æ§è¡è¾éç«ç¹å
¥åºä»»å¡ |
| | | public synchronized void stationInExecute() { |
| | |
| | | continue; |
| | | } |
| | | |
| | | List<Integer> runBlockReassignLocStationList = new ArrayList<>(); |
| | | for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) { |
| | | runBlockReassignLocStationList.add(stationObjModel.getStationId()); |
| | | } |
| | | |
| | | List<StationProtocol> list = stationThread.getStatus(); |
| | | for (StationProtocol stationProtocol : list) { |
| | | if(stationProtocol.isAutoing() |
| | |
| | | && stationProtocol.getTaskNo() > 0 |
| | | && stationProtocol.isRunBlock() |
| | | ) { |
| | | //è¿è¡å µå¡ï¼éæ°ç³è¯·ä»»å¡ |
| | | WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo()); |
| | | if (wrkMast == null) { |
| | | News.info("è¾éç«ç¹å·={} è¿è¡é»å¡ï¼ä½æ æ³æ¾å°å¯¹åºä»»å¡ï¼å·¥ä½å·={}", stationProtocol.getStationId(), stationProtocol.getTaskNo()); |
| | |
| | | if (lock != null) { |
| | | continue; |
| | | } |
| | | |
| | | redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15); |
| | | |
| | | HashMap<String, Object> requestParam = new HashMap<>(); |
| | | String response = null; |
| | | try { |
| | | requestParam.put("taskNo", wrkMast.getWmsWrkNo()); |
| | | requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(basDevp.getDevpNo()))); |
| | | if (runBlockReassignLocStationList.contains(stationProtocol.getStationId())) { |
| | | //ç«ç¹å¤äºéæ°åé
åºä½åºå |
| | | //è¿è¡å µå¡ï¼éæ°ç³è¯·ä»»å¡ |
| | | |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(wmsSystemReassignInTaskUrl) |
| | | .setJson(JSON.toJSONString(requestParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | HashMap<String, Object> requestParam = new HashMap<>(); |
| | | String response = null; |
| | | try { |
| | | requestParam.put("taskNo", wrkMast.getWmsWrkNo()); |
| | | requestParam.put("row", Utils.getInTaskEnableRow(new ArrayList<>(basDevp.getDevpNo()))); |
| | | |
| | | String locNo = dto.getLocNo(); |
| | | //æ´æ°æ°æ® |
| | | wrkMast.setLocNo(locNo); |
| | | wrkMastService.updateById(wrkMast); |
| | | response = new HttpHandler.Builder() |
| | | .setUri(wmsUrl) |
| | | .setPath(wmsSystemReassignInTaskUrl) |
| | | .setJson(JSON.toJSONString(requestParam)) |
| | | .build() |
| | | .doPost(); |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (jsonObject.getInteger("code").equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locNo); |
| | | if (crnNo == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "æªå¹é
å°å åæº"); |
| | | continue; |
| | | String sourceLocNo = wrkMast.getLocNo(); |
| | | String locNo = dto.getLocNo(); |
| | | |
| | | LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo); |
| | | if (sourceLocMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "åºä½å·:{} æºåºä½ä¿¡æ¯ä¸åå¨", sourceLocNo); |
| | | continue; |
| | | } |
| | | |
| | | if (!sourceLocMast.getLocSts().equals("S")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "åºä½å·:{} æºåºä½ç¶æä¸å¤äºå
¥åºé¢çº¦", sourceLocNo); |
| | | continue; |
| | | } |
| | | |
| | | LocMast locMast = locMastService.queryByLoc(locNo); |
| | | if (locMast == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "åºä½å·:{} ç®æ åºä½ä¿¡æ¯ä¸åå¨", locNo); |
| | | continue; |
| | | } |
| | | |
| | | if (!locMast.getLocSts().equals("O")) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "åºä½å·:{} ç®æ åºä½ç¶æä¸å¤äºç©ºåºä½", locNo); |
| | | continue; |
| | | } |
| | | |
| | | Integer crnNo = commonService.findCrnNoByLocNo(locNo); |
| | | if (crnNo == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "æªå¹é
å°å åæº"); |
| | | continue; |
| | | } |
| | | |
| | | Integer targetStationId = commonService.findInStationId(crnNo, stationProtocol.getStationId()); |
| | | if (targetStationId == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "æç´¢å
¥åºç«ç¹å¤±è´¥"); |
| | | continue; |
| | | } |
| | | |
| | | StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0); |
| | | if(command == null){ |
| | | News.taskInfo(wrkMast.getWrkNo(), "è·åè¾é线å½ä»¤å¤±è´¥"); |
| | | continue; |
| | | } |
| | | |
| | | //æ´æ°æºåºä½ |
| | | sourceLocMast.setLocSts("O"); |
| | | sourceLocMast.setModiTime(new Date()); |
| | | locMastService.updateById(sourceLocMast); |
| | | |
| | | //æ´æ°ç®æ åºä½ |
| | | locMast.setLocSts("S"); |
| | | locMast.setModiTime(new Date()); |
| | | locMastService.updateById(locMast); |
| | | |
| | | //æ´æ°å·¥ä½æ¡£æ°æ® |
| | | wrkMast.setLocNo(locNo); |
| | | wrkMast.setCrnNo(crnNo); |
| | | wrkMast.setStaNo(targetStationId); |
| | | if (wrkMastService.updateById(wrkMast)) { |
| | | MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command)); |
| | | } |
| | | News.info("请æ±WMSæ¥å£æåï¼ï¼ï¼urlï¼{}ï¼requestï¼{}ï¼responseï¼{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response); |
| | | } else { |
| | | News.error("请æ±WMSæ¥å£å¤±è´¥ï¼ï¼ï¼urlï¼{}ï¼requestï¼{}ï¼responseï¼{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response); |
| | | } |
| | | |
| | | Integer targetStationId = commonService.findInStationId(crnNo, stationProtocol.getStationId()); |
| | | if (targetStationId == null) { |
| | | News.taskInfo(wrkMast.getWrkNo(), "æç´¢å
¥åºç«ç¹å¤±è´¥"); |
| | | continue; |
| | | } |
| | | |
| | | StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0); |
| | | if(command == null){ |
| | | News.taskInfo(wrkMast.getWrkNo(), "è·åè¾é线å½ä»¤å¤±è´¥"); |
| | | continue; |
| | | } |
| | | MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command)); |
| | | News.info("请æ±WMSæ¥å£æåï¼ï¼ï¼urlï¼{}ï¼requestï¼{}ï¼responseï¼{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response); |
| | | } else { |
| | | News.error("请æ±WMSæ¥å£å¤±è´¥ï¼ï¼ï¼urlï¼{}ï¼requestï¼{}ï¼responseï¼{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response); |
| | | } catch (Exception e) { |
| | | News.error("请æ±WMSæ¥å£å¼å¸¸ï¼ï¼ï¼urlï¼{}ï¼requestï¼{}ï¼ responseï¼{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response, e); |
| | | } finally { |
| | | HttpRequestLog httpRequestLog = new HttpRequestLog(); |
| | | httpRequestLog.setName(wmsUrl + wmsSystemReassignInTaskUrl); |
| | | httpRequestLog.setRequest(JSON.toJSONString(requestParam)); |
| | | httpRequestLog.setResponse(response); |
| | | httpRequestLog.setCreateTime(new Date()); |
| | | httpRequestLogService.insert(httpRequestLog); |
| | | } |
| | | } catch (Exception e) { |
| | | News.error("请æ±WMSæ¥å£å¼å¸¸ï¼ï¼ï¼urlï¼{}ï¼requestï¼{}ï¼ responseï¼{}", wmsUrl + wmsSystemReassignInTaskUrl, JSON.toJSONString(requestParam), response, e); |
| | | } finally { |
| | | HttpRequestLog httpRequestLog = new HttpRequestLog(); |
| | | httpRequestLog.setName(wmsUrl + wmsSystemReassignInTaskUrl); |
| | | httpRequestLog.setRequest(JSON.toJSONString(requestParam)); |
| | | httpRequestLog.setResponse(response); |
| | | httpRequestLog.setCreateTime(new Date()); |
| | | httpRequestLogService.insert(httpRequestLog); |
| | | }else { |
| | | //è¿è¡å µå¡ï¼éæ°è®¡ç®è·¯çº¿ |
| | | StationCommand command = stationThread.getMoveCommand(wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0); |
| | | if(command == null){ |
| | | News.taskInfo(wrkMast.getWrkNo(), "è·åè¾é线å½ä»¤å¤±è´¥"); |
| | | continue; |
| | | } |
| | | |
| | | MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command)); |
| | | News.info("è¾éç«ç¹å µå¡åéæ°è®¡ç®è·¯å¾å½ä»¤ä¸åæåï¼ç«ç¹å·={}ï¼å·¥ä½å·={}ï¼å½ä»¤æ°æ®={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command)); |
| | | } |
| | | } |
| | | } |