|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${wms.url}") | 
|---|
|  |  |  | private String wmsUrl; | 
|---|
|  |  |  | @Value("${wms.movePath}") | 
|---|
|  |  |  | private String movePath; | 
|---|
|  |  |  | @Value("${wms.taskStatusFeedbackPath}") | 
|---|
|  |  |  | private String taskStatusFeedbackPath; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Scheduled(cron = "0/3 * * * * ? ") | 
|---|
|  |  |  | public void execute() throws IOException { | 
|---|
|  |  |  | for (TaskWrk taskWrk : taskWrkService.selectToBeHistoryData()) { | 
|---|
|  |  |  | if (taskWrk.getStatus().equals(TaskStatusType.OVER.id)||taskWrk.getStatus()==7) {//完成 | 
|---|
|  |  |  | //区分入出库 | 
|---|
|  |  |  | TaskWrkLog taskWrkLog = new TaskWrkLog(taskWrk); | 
|---|
|  |  |  | if (!wrkLogService.insert(taskWrkLog)) { | 
|---|
|  |  |  | throw new CoolException("转历史档失败" + taskWrkLog); | 
|---|
|  |  |  | JSONObject jsonObject = null; | 
|---|
|  |  |  | String response = null; | 
|---|
|  |  |  | boolean success = false; | 
|---|
|  |  |  | HashMap<String, Object> map = new HashMap<>(); | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | map.put("taskNo", taskWrk.getTaskNo()); | 
|---|
|  |  |  | map.put("status",5); | 
|---|
|  |  |  | map.put("ioType", taskWrk.getIoType()); | 
|---|
|  |  |  | map.put("barcode", taskWrk.getBarcode()); | 
|---|
|  |  |  | map.put("reportTime", new Date()); | 
|---|
|  |  |  | response = new HttpHandler.Builder() | 
|---|
|  |  |  | .setUri(wmsUrl) | 
|---|
|  |  |  | .setPath(taskStatusFeedbackPath) | 
|---|
|  |  |  | .setJson(JSON.toJSONString(map)) | 
|---|
|  |  |  | .build() | 
|---|
|  |  |  | .doPost(); | 
|---|
|  |  |  | jsonObject = JSON.parseObject(response); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | if (jsonObject.getInteger("code").equals(200)) { | 
|---|
|  |  |  | if (taskWrkService.saveToHistory(taskWrk.getTaskNo()) == 0) { | 
|---|
|  |  |  | log.error("任务档转任务历史档失败" + taskWrk); | 
|---|
|  |  |  | return ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if (!taskWrkService.deleteById(taskWrk)) { | 
|---|
|  |  |  | throw new CoolException("任务档删除失败" + taskWrkLog); | 
|---|
|  |  |  | success = true; | 
|---|
|  |  |  | //删除任务 | 
|---|
|  |  |  | taskWrkService.delete(new EntityWrapper<TaskWrk>().eq("task_no", taskWrk.getTaskNo())); | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | log.error("wms入库出库完成上报失败" + taskWrk); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } else if (taskWrk.getStatus().equals(TaskStatusType.CANCEL.id)) { | 
|---|
|  |  |  | TaskWrkLog taskWrkLog=new TaskWrkLog(taskWrk); | 
|---|
|  |  |  | if(!wrkLogService.insert(taskWrkLog)){ | 
|---|
|  |  |  | throw new CoolException("转历史档失败"+taskWrkLog); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(!taskWrkService.deleteById(taskWrk)){ | 
|---|
|  |  |  | throw new CoolException("任务档删除失败"+taskWrkLog); | 
|---|
|  |  |  | } catch (Exception e) { | 
|---|
|  |  |  | log.error("wms通讯失败," + e.getMessage()); | 
|---|
|  |  |  | } finally { | 
|---|
|  |  |  | apiLogService.save("wms入库出库完成上报" | 
|---|
|  |  |  | , wmsUrl + taskStatusFeedbackPath | 
|---|
|  |  |  | , null | 
|---|
|  |  |  | , "127.0.0.1" | 
|---|
|  |  |  | , JSON.toJSONString(map) | 
|---|
|  |  |  | , response | 
|---|
|  |  |  | , success | 
|---|
|  |  |  | ); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|