From be481eeb96c5ae1933510fa0543a7239f808c8ba Mon Sep 17 00:00:00 2001 From: pjb <123456> Date: 星期六, 08 三月 2025 17:06:45 +0800 Subject: [PATCH] ctu入库完成 --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java | 105 +++++++++++++++++++++++++++++----------------------- 1 files changed, 58 insertions(+), 47 deletions(-) diff --git a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java index 7ea4d15..665c558 100644 --- a/zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java +++ b/zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java @@ -4,8 +4,13 @@ import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.fasterxml.jackson.core.JsonProcessingException; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.cfg.CoercionAction; +import com.fasterxml.jackson.databind.cfg.CoercionInputShape; import com.zy.asrs.framework.exception.CoolException; import com.zy.asrs.wms.apis.wcs.entity.domain.SystemProperties; +import com.zy.asrs.wms.apis.wcs.entity.request.ConveyorStarParam; import com.zy.asrs.wms.apis.wcs.entity.request.PublishTasksParam; import com.zy.asrs.wms.apis.wcs.entity.request.TaskDescribe; import com.zy.asrs.wms.apis.wcs.entity.request.TaskParam; @@ -55,38 +60,39 @@ .eq(Task::getTaskSts, TaskStsType.WCS_CONTAINER_RECEIVE.id).eq(Task::getStatus, 1)); tasks.forEach(task -> { try { -// ConveyorStarParam conveyorStarParam = new ConveyorStarParam(); -// conveyorStarParam.setSlotCode(task.getOriginLoc()) -// .setContainerCode(task.getBarcode()); -// //璋冪敤涓夋柟鎺ュ彛锛屽皢浠诲姟鎺ㄩ�佽嚦ESS骞冲彴 -// MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); -// // 璁剧疆璇锋眰鍙傛暟 -// params.add("params", JSONObject.toJSONString(conveyorStarParam)); -// log.info("璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", Constant.CONVEYOR_START, JSONObject.toJSONString(conveyorStarParam)); -// HttpHeaders headers = new HttpHeaders(); -// headers.add("Content-Type", "application/json"); -// HttpEntity httpEntity = new HttpEntity<>(params, headers); -// // 璇锋眰 -// ResponseEntity<String> exchange = restTemplate.exchange(Constant.CONVEYOR_START, HttpMethod.POST, httpEntity, String.class); -// log.info("涓嬪彂娴佸姩閫氱煡 杩斿洖缁撴灉锛歿}", exchange); -// if (exchange.getBody() == null) { -// throw new CoolException("涓嬪彂娴佸姩閫氱煡澶辫触锛侊紒"); -// } else { -// CommonReponse commonReponse = JSON.toJavaObject(JSON.parseObject(exchange.getBody()), CommonReponse.class); -// if (commonReponse.getCode() == 0) { + ConveyorStarParam conveyorStarParam = new ConveyorStarParam(); + conveyorStarParam.setSlotCode(task.getOriginLoc()) + .setContainerCode(task.getBarcode()) + .setDirection("100"); + // 鍘熷鎶ユ枃 + log.info("璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", "http://192.168.2.200:9046/conveyor/moveContainer", JSONObject.toJSONString(conveyorStarParam)); + HttpHeaders headers = new HttpHeaders(); + headers.add("Content-Type", "application/json"); + HttpEntity httpEntity = new HttpEntity<>(conveyorStarParam, headers); + // 璋冪敤涓夋柟鎺ュ彛锛屽皢浠诲姟鎺ㄩ�佽嚦ESS骞冲彴 + ResponseEntity<String> exchange = restTemplate.exchange("http://192.168.2.200:9046/conveyor/moveContainer", HttpMethod.POST, httpEntity, String.class); + log.info("涓嬪彂娴佸姩閫氱煡 杩斿洖缁撴灉锛歿}", exchange); + if (exchange.getBody() == null) { + throw new CoolException("涓嬪彂娴佸姩閫氱煡澶辫触锛侊紒"); + } else { + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.coercionConfigDefaults() + .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); + CommonReponse commonReponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class); + if (commonReponse.getCode() == 0) { taskService.update(new LambdaUpdateWrapper<Task>() .eq(Task::getId, task.getId()) .set(Task::getTaskSts, TaskStsType.WCS_CONVEYOR_START.id)); -// log.info(task.getTaskNo() + "涓嬪彂娴佸姩閫氱煡" + commonReponse.getMsg()); -// } else { -// throw new CoolException("涓嬪彂娴佸姩閫氱煡澶辫触锛侊紒"); -// } -// } + log.info(task.getTaskNo() + "涓嬪彂娴佸姩閫氱煡" + commonReponse.getMsg()); + } else { + throw new CoolException("涓嬪彂娴佸姩閫氱煡澶辫触锛侊紒"); + } + } } catch (Exception ex) { log.error(ex.getMessage()); } finally { //濡傛灉寮傚父淇敼绂佺敤鐘舵�� -// taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getStatus, 0).eq(Task::getId, task.getId())); + taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getStatus, 0).eq(Task::getId, task.getId())); } }); @@ -100,7 +106,7 @@ */ @Scheduled(cron = "0/3 * * * * ? ") @Transactional(rollbackFor = Exception.class) - public void waitPakinSchedule() { + public void waitPakinSchedule() throws JsonProcessingException { //鑾峰彇褰撳墠浠诲姟妗d腑锛屾墍鏈変负寰呭叆搴撶姸鎬佺殑浠诲姟妗o紝鎸夋椂闂村崌搴忔帓鍒� List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() // .eq(Task::getTaskType, 1) @@ -117,16 +123,24 @@ tasks.forEach(task -> { List<TaskParam> params = new ArrayList<>(); TaskParam param = new TaskParam(); - //璁剧疆瀹瑰櫒缂栫爜 param.setTaskCode(task.getTaskNo()); - List<TaskDescribe> taskDescribes = new ArrayList<>(); + + // 澶勭悊搴撲綅鏄犲皠 + String[] parts = task.getTargetLoc().split("-"); + String formatLocNo = String.format("A-%03d-%03d-%02d", + Integer.parseInt(parts[0]), + Integer.parseInt(parts[1]), + Integer.parseInt(parts[2])); TaskDescribe describe = new TaskDescribe(); //璁剧疆鐩爣搴撲綅锛岀珯鐐� describe.setContainerCode(task.getBarcode()) - .setToLocationCode(task.getTargetLoc()) + .setToLocationCode(formatLocNo) .setToStationCode(task.getTargetSite()); - taskDescribes.add(describe); - param.setTaskDescribe(taskDescribes); +// .setFromLocationCode("") +// .setContainerFace("") +// .setContainerType("").setStorageTag(""); + + param.setTaskDescribe(describe); params.add(param); tasksParam.setTasks(params); }); @@ -134,20 +148,22 @@ tasksParam.setTaskType("putaway"); // TODO 澶氫换鍔″璁㈠崟锛岀粺涓�璋冨害锛屾槸鍚︿細鍑虹幇閮ㄥ垎鎴愬姛锛岄儴鍒嗗け璐ョ殑鎯呭喌 //璋冪敤涓夋柟鎺ュ彛锛屽皢浠诲姟鎺ㄩ�佽嚦ESS骞冲彴 - MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); +// MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); // 璁剧疆璇锋眰鍙傛暟 - params.add("params", JSONObject.toJSONString(tasksParam)); +// params.add("params", tasksParam); log.info("璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", "http://192.168.2.200:9046/task/create", JSONObject.toJSONString(tasksParam)); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json"); - HttpEntity httpEntity = new HttpEntity<>(params, headers); + HttpEntity httpEntity = new HttpEntity<>(tasksParam, headers); // 璇锋眰 ResponseEntity<String> exchange = restTemplate.exchange("http://192.168.2.200:9046/task/create", HttpMethod.POST, httpEntity, String.class); log.info("涓嬪彂浠诲姟 杩斿洖缁撴灉锛歿}", exchange); if (exchange.getBody() == null) { throw new CoolException("涓嬪彂浠诲姟澶辫触锛侊紒"); } else { - CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody()); + ObjectMapper objectMapper = new ObjectMapper(); + CommonReponse reponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class); +// CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody()); if (reponse.getCode() == 0) { // 璇锋眰鎴愬姛鍚庯紝缁熶竴淇敼鎵�鏈変换鍔℃。鐘舵�佷负鍏ュ簱鎵ц涓�� tasks.forEach(task -> { @@ -231,7 +247,7 @@ */ @Scheduled(cron = "0/3 * * * * ? ") @Transactional(rollbackFor = Exception.class) - public void waveToTask() { + public void waveToTask() throws JsonProcessingException { //鑾峰彇褰撳墠浠诲姟妗d腑锛屾墍鏈変负寰呭嚭搴撶姸鎬佺殑浠诲姟妗o紝鎸夋椂闂村崌搴忔帓鍒� List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() .ge(Task::getTaskType, 101) //TODO 濡備綍纭鏄�101锛岃繕鏄�103 @@ -250,36 +266,31 @@ TaskParam param = new TaskParam(); //璁剧疆瀹瑰櫒缂栫爜 param.setTaskCode(task.getTaskNo()); - List<TaskDescribe> taskDescribes = new ArrayList<>(); TaskDescribe describe = new TaskDescribe(); //璁剧疆鐩爣搴撲綅锛岀珯鐐� describe.setContainerCode(task.getBarcode()) .setToLocationCode(task.getTargetLoc()) .setToStationCode(task.getTargetSite()); - taskDescribes.add(describe); - param.setTaskDescribe(taskDescribes); + param.setTaskDescribe(describe); params.add(param); tasksParam.setTasks(params); }); tasksParam.setTaskType("carry"); // TODO 澶氫换鍔″璁㈠崟锛岀粺涓�璋冨害锛屾槸鍚︿細鍑虹幇閮ㄥ垎鎴愬姛锛岄儴鍒嗗け璐ョ殑鎯呭喌 - //璋冪敤涓夋柟鎺ュ彛锛屽皢浠诲姟鎺ㄩ�佽嚦ESS骞冲彴 - MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); SystemProperties properties = new SystemProperties(); - // 璁剧疆璇锋眰鍙傛暟 - params.add("params", JSONObject.toJSONString(tasksParam)); - log.info("璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", properties.getBaseHost() + properties.getIssueTaskOfEvent(), JSONObject.toJSONString(tasksParam)); + log.info("璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", properties.getBaseHost() + properties.getEssReceiveTask(), JSONObject.toJSONString(tasksParam)); HttpHeaders headers = new HttpHeaders(); headers.add("Content-Type", "application/json"); - HttpEntity httpEntity = new HttpEntity<>(params, headers); + HttpEntity httpEntity = new HttpEntity<>(tasksParam, headers); // 璇锋眰 - ResponseEntity<String> exchange = restTemplate.exchange(properties.getBaseHost() + properties.getIssueTaskOfEvent(), HttpMethod.POST, httpEntity, String.class); + ResponseEntity<String> exchange = restTemplate.exchange(properties.getBaseHost() + properties.getEssReceiveTask(), HttpMethod.POST, httpEntity, String.class); log.info("涓嬪彂浠诲姟 杩斿洖缁撴灉锛歿}", exchange); if (exchange.getBody() == null) { throw new CoolException("涓嬪彂浠诲姟澶辫触锛侊紒"); } else { - CommonReponse reponse = (CommonReponse) JSON.parse(exchange.getBody()); + ObjectMapper objectMapper = new ObjectMapper(); + CommonReponse reponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class); if (reponse.getCode() == 0) { //璇锋眰鎴愬姛鍚庯紝缁熶竴淇敼鎵�鏈変换鍔℃。鐘舵�佷负鍏ュ簱鎵ц涓�� tasks.forEach(task -> { -- Gitblit v1.9.1