| | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | |
| | | /** |
| | | * 定时将任务(完成、取消)转成日志 |
| | |
| | | @Value("${wms.completeDevpTask}") |
| | | private String completeDevpTask; |
| | | |
| | | @Value("${wms.reportPalletizingCompleted}") |
| | | private String reportPalletizingCompleted; |
| | | |
| | | @Resource |
| | | private TaskWrkMapper taskWrkMapper; |
| | | |
| | |
| | | add(301);add(302);add(303);add(304);add(305);add(306);add(307);add(308); |
| | | }}; |
| | | |
| | | // 侧面码盘完成上报wms |
| | | @Scheduled(cron = "0/3 * * * * ? ") |
| | | public synchronized void reportPalletizingCompleted() { |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1); |
| | | if (devpThread != null) { |
| | | Map<Integer, StaProtocol> staProtocolMap = devpThread.getStation(); |
| | | int[] siteArray = new int[]{203, 207, 212}; |
| | | for (int site : siteArray) { |
| | | StaProtocol staProtocol = staProtocolMap.get(site); |
| | | if (staProtocol != null) { |
| | | short mpCompletedFlag = staProtocol.getMpCompletedFlag(); |
| | | if (mpCompletedFlag == 1) { |
| | | TaskWrk taskWrk = taskWrkMapper.selectByWrkNo(Integer.valueOf(staProtocol.getWorkNo())); |
| | | if (taskWrk != null) { |
| | | |
| | | // 请求体 |
| | | JSONObject request = new JSONObject(); |
| | | request.put("site", site); |
| | | |
| | | String response = ""; |
| | | boolean bool = false; |
| | | try { |
| | | response = new HttpHandler.Builder() |
| | | // .setHeaders(headParam) |
| | | .setUri(wmsUrl) |
| | | .setPath(reportPalletizingCompleted) |
| | | .setJson(JSON.toJSONString(request)) |
| | | .build() |
| | | .doPost(); |
| | | if (!Cools.isEmpty(response)) { |
| | | JSONObject jsonObject = JSON.parseObject(response); |
| | | if (Integer.parseInt(String.valueOf(jsonObject.get("code"))) == 200) { |
| | | bool = true; |
| | | // 推送队列 |
| | | boolean offer = MessageQueue.offer(SlaveType.Devp, 4, new Task(1, staProtocol)); |
| | | if (offer) { |
| | | // 更新数据库 |
| | | taskWrk.setMpCompletedReport(1); |
| | | taskWrkMapper.updateById(taskWrk); |
| | | } else { |
| | | log.error("侧面码盘完成上报wms推送队列失败,站点:{},任务号:{}", site, staProtocol.getWorkNo()); |
| | | } |
| | | } |
| | | } |
| | | } catch (Exception e) { |
| | | log.error("侧面码盘完成上报wms失败{},返回值={}", taskWrk, response); |
| | | } finally { |
| | | apiLogService.save("侧面码盘完成上报wms" |
| | | , wmsUrl + reportPalletizingCompleted |
| | | , null |
| | | , "127.0.0.1" |
| | | , JSON.toJSONString(request) |
| | | , response |
| | | , bool |
| | | ); |
| | | } |
| | | } else { |
| | | log.error("侧面码盘完成上报wms没有找到该任务,站点:{},任务号:{}", site, staProtocol.getWorkNo()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | // WMS分配入库库位异常上报 |
| | | @Scheduled(cron = "0/5 * * * * ? ") |
| | | @Transactional |