From c1ef2d1fc4c0dae2bc8452924dcd77a0ff3a1ef5 Mon Sep 17 00:00:00 2001 From: cpT <1@123> Date: 星期四, 19 六月 2025 15:02:52 +0800 Subject: [PATCH] #改造 --- src/main/java/com/zy/asrs/task/TaskLogScheduler.java | 70 ++++++++++++++++++++++++---------- 1 files changed, 49 insertions(+), 21 deletions(-) diff --git a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java index 8463ff2..2b65667 100644 --- a/src/main/java/com/zy/asrs/task/TaskLogScheduler.java +++ b/src/main/java/com/zy/asrs/task/TaskLogScheduler.java @@ -3,6 +3,7 @@ import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.mapper.EntityWrapper; +import com.core.common.Cools; import com.core.exception.CoolException; import com.zy.asrs.domain.enums.TaskStatusType; import com.zy.asrs.entity.*; @@ -19,6 +20,7 @@ import org.springframework.stereotype.Component; import java.io.IOException; +import java.time.LocalDateTime; import java.util.Date; import java.util.HashMap; import java.util.List; @@ -49,32 +51,58 @@ @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); - } - if (!taskWrkService.deleteById(taskWrk)) { - throw new CoolException("浠诲姟妗e垹闄ゅけ璐�" + taskWrkLog); - } - } 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("浠诲姟妗e垹闄ゅけ璐�"+taskWrkLog); - } - } + List<TaskWrk> taskWrkList = taskWrkService.selectToBeHistoryData(); + for (TaskWrk taskWrk : taskWrkList) { + JSONObject jsonObject = null; + String response = null; + boolean success = false; + HashMap<String, Object> map = new HashMap<>(); + try { + map.put("taskNo",taskWrk.getTaskNo()); + map.put("taskStatus",taskWrk.getStatusWms()); + map.put("ioType",taskWrk.getIoTypeWms()); + map.put("barCode",taskWrk.getBarcode()); + map.put("reportTime", LocalDateTime.now()); + map.put("weight",taskWrk.getScWeight().doubleValue()); + response = new HttpHandler.Builder() + .setUri(wmsUrl) + .setPath(taskStatusFeedbackPath) + .setJson(JSON.toJSONString(map)) + .build() + .doPost(); + jsonObject = JSON.parseObject(response); + if (!Cools.isEmpty(jsonObject.getInteger("code")) && jsonObject.getInteger("code").equals(200)) { + if (taskWrkService.saveToHistory(taskWrk.getTaskNo()) == 0) { + log.error("浠诲姟妗h浆浠诲姟鍘嗗彶妗eけ璐�" + taskWrk); + return ; + } + success = true; + //鍒犻櫎浠诲姟 + taskWrkService.delete(new EntityWrapper<TaskWrk>().eq("task_no", taskWrk.getTaskNo())); + } else { + log.error("wms鍏ュ簱鍑哄簱瀹屾垚涓婃姤澶辫触" + taskWrk); + } + } catch (Exception e) { + log.error("wms閫氳澶辫触," + e.getMessage()); + } finally { + apiLogService.save("wms鍏ュ簱鍑哄簱瀹屾垚涓婃姤" + , wmsUrl + taskStatusFeedbackPath + , null + , "127.0.0.1" + , JSON.toJSONString(map) + , response + , success + ); + } } + + } } -- Gitblit v1.9.1