From e046dba174365eb8934ee1e4206f09821145e876 Mon Sep 17 00:00:00 2001 From: skyouc Date: 星期四, 21 八月 2025 13:23:22 +0800 Subject: [PATCH] no message --- zy-asrs-wms/src/main/java/com/zy/asrs/wms/apis/wcs/schedule/ScheduleJobs.java | 348 ++++++++++++++++++++++++++++++++++++++++++++-------------- 1 files changed, 264 insertions(+), 84 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 35bf696..f0174de 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,17 +4,24 @@ 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.Constant; +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; import com.zy.asrs.wms.apis.wcs.entity.response.CommonReponse; -import com.zy.asrs.wms.asrs.entity.Task; +import com.zy.asrs.wms.asrs.entity.*; +import com.zy.asrs.wms.asrs.entity.dto.OrderOutMergeDto; +import com.zy.asrs.wms.asrs.entity.enums.LocStsType; import com.zy.asrs.wms.asrs.entity.enums.TaskStsType; -import com.zy.asrs.wms.asrs.service.TaskService; -import com.zy.asrs.wms.asrs.service.WorkService; +import com.zy.asrs.wms.asrs.service.*; +import com.zy.asrs.wms.asrs.service.impl.LocServiceImpl; +import com.zy.asrs.wms.utils.Utils; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.HttpEntity; @@ -22,18 +29,15 @@ import org.springframework.http.HttpMethod; import org.springframework.http.ResponseEntity; import org.springframework.jdbc.datasource.DataSourceTransactionManager; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.stereotype.Component; -import org.springframework.transaction.TransactionDefinition; -import org.springframework.transaction.TransactionStatus; import org.springframework.transaction.annotation.Transactional; -import org.springframework.transaction.support.DefaultTransactionDefinition; import org.springframework.util.LinkedMultiValueMap; import org.springframework.util.MultiValueMap; import org.springframework.web.client.RestTemplate; -import java.util.ArrayList; -import java.util.Comparator; -import java.util.List; +import javax.annotation.Resource; +import java.util.*; import java.util.stream.Collectors; @Slf4j @@ -42,107 +46,164 @@ @Autowired private DataSourceTransactionManager transactionManager; - @Autowired private TaskService taskService; - @Autowired private RestTemplate restTemplate; - @Autowired private WorkService workService; - + @Resource + private SystemProperties properties; + @Autowired + private LocServiceImpl locService; + @Autowired + private LocDetlService locDetlService; + @Autowired + private TaskDetlService taskDetlService; + @Autowired + private LocDetlFieldService locDetlFieldService; + @Autowired + private TaskDetlFieldService taskDetlFieldService; + @Autowired + private CacheSiteService cacheSiteService; + @Autowired + private OperationPortService operationPortService; /*** - * 閫氱煡ESS杈撻�佺嚎娴佸姩 + * 鍏ュ簱浠诲姟---閫氱煡ESS杈撻�佺嚎娴佸姩 */ - // @Scheduled(cron = "0/3 * * * * ? ") + @Scheduled(cron = "0/3 * * * * ? ") + @Transactional(rollbackFor = Exception.class) public void conveyorStart() { List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() - .eq(Task::getTaskSts, TaskStsType.WCS_CONTAINER_RECEIVE.id).eq(Task::getStatus, 0)); + .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)); + conveyorStarParam.setSlotCode(task.getOriginSite()) + .setContainerCode(task.getBarcode()) + .setDirection("100"); + // 鍘熷鎶ユ枃 + log.info("閫氱煡ESS杈撻�佺嚎娴佸姩璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", "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<>(params, headers); - // 璇锋眰 - ResponseEntity<String> exchange = restTemplate.exchange(Constant.ISSUE_TASK_OF_PUTAWAY, HttpMethod.POST, httpEntity, String.class); + headers.add("api-version", "v2.0"); + 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 { - CommonReponse commonReponse = JSON.toJavaObject(JSON.parseObject(exchange.getBody()), CommonReponse.class); + ObjectMapper objectMapper = new ObjectMapper(); + objectMapper.coercionConfigDefaults() + .setCoercion(CoercionInputShape.EmptyString, CoercionAction.AsEmpty); + CommonReponse commonReponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class); if (commonReponse.getCode() == 0) { - log.info(task.getTaskNo() + "涓嬪彂娴佸姩閫氱煡" + commonReponse.getMsg()); + taskService.update(new LambdaUpdateWrapper<Task>() + .eq(Task::getId, task.getId()) + .set(Task::getTaskSts, TaskStsType.WCS_CONVEYOR_START.id)); } else { throw new CoolException("涓嬪彂娴佸姩閫氱煡澶辫触锛侊紒"); } } } catch (Exception ex) { log.error(ex.getMessage()); - } finally { - //濡傛灉寮傚父淇敼绂佺敤鐘舵�� - taskService.update(new LambdaUpdateWrapper<Task>().set(Task::getStatus, 1).eq(Task::getId, task.getId())); } }); } - - /*** - * 姣忛殧3绉掞紝鑾峰彇搴撲腑鐘舵�佷负銆庝换鍔″畬鎴愩�忎笖鐘舵�併�巗ucess銆忕殑璁㈠崟 - * 骞跺皢浠诲姟鍙樹负鍘嗗彶妗� + /** + * 鐢熸垚鑷姩鐩樼偣浠诲姟 */ - // @Scheduled(cron = "0/3 * * * * ? ") - @Transactional - public void completeTaskSchedule() { - List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() - .eq(Task::getTaskType, 1) - .eq(Task::getTaskSts, TaskStsType.WCS_PUTAWAY_SUCESS) - .eq(Task::getExcudeStatus, "sucess")) - .stream().sorted(Comparator.comparing(Task::getTaskSts)) - .collect(Collectors.toList()); +// @Scheduled(cron = "0/50 * * * * ?") +// @Transactional(rollbackFor = Exception.class) + public void genCheckTask() { + Loc locs = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getLocStsId, LocStsType.F.val()).orderByAsc(Loc::getLocNo).last("limit 1")); + if (Objects.isNull(locs)) { + return; + } + List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>().select(Task::getId).eq(Task::getTaskType, 107L)); + if (!tasks.isEmpty() && tasks.size() >= 4) { + //榛樿鐢熸垚鍥涗釜鐩樼偣浠诲姟锛岃秴杩�4涓紝鍋滄鐢熸垚鐩樼偣浠诲姟; + return; + } + OperationPort operationPort = operationPortService.getOne(new LambdaQueryWrapper<OperationPort>().last("ORDER BY RAND() LIMIT 1;")); + if (operationPort == null || Objects.isNull(operationPort)) { + throw new CoolException("浣滀笟鍙d笉瀛樺湪"); + } + Task task = new Task(); + task.setTaskNo(workService.generateTaskNo(TaskStsType.GENERATE_OUT.id)); + task.setTaskSts(TaskStsType.GENERATE_OUT.id); + task.setTaskType(107L); //榛樿107鐩樼偣浠诲姟锛岀洏鐐逛换鍔℃病鏈夛紝鎸�103澶勭悊 + task.setIoPri(workService.generateIoPri(TaskStsType.GENERATE_OUT.id)); + task.setOriginLoc(locs.getLocNo()); + task.setTargetSite(operationPort.getFlag()); + task.setBarcode(locs.getBarcode()); - DefaultTransactionDefinition def = new DefaultTransactionDefinition(); - // TODO 鍗曚釜鎵ц澶辫触鍚庯紝 鍔犲叆澶辫触鍒楄〃锛屾坊鍔犲け璐ュ鐞嗗瓧娈碉紝閬垮厤閲嶅鏌ヨ璋冪敤 -// def.setName("SomeTxName"); - def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRED); - TransactionStatus status = transactionManager.getTransaction(def); - try { - tasks.forEach(task -> { - workService.completeTask(task.getId()); - }); - // execute your business logic here - //db operation - } catch (Exception ex) { - transactionManager.rollback(status); - throw ex; + if (!taskService.save(task)) { + throw new CoolException("浠诲姟鐢熸垚澶辫触锛侊紒"); } + List<LocDetl> locDetls = locDetlService.list(new LambdaQueryWrapper<LocDetl>().eq(LocDetl::getLocId, locs.getId())); + if (locDetls.isEmpty()) { + throw new CoolException("鏄庣粏涓嶅瓨鍦紒锛�"); + } + + for (LocDetl locDetl : locDetls) { + TaskDetl taskDetl = new TaskDetl(); + taskDetl.sync(locDetl); + taskDetl.setId(null); + taskDetl.setTaskId(task.getId()); + taskDetl.setTaskNo(task.getTaskNo()); + taskDetl.setAnfme(locDetl.getAnfme()); + taskDetl.setStock(locDetl.getAnfme()); + taskDetl.setWaveId(null); + taskDetl.setWaveNo(null); + taskDetl.setOrderId(null); + taskDetl.setOrderNo(null); + if (!taskDetlService.save(taskDetl)) { + throw new CoolException("淇濆瓨宸ヤ綔妗f槑缁嗗け璐�"); + } + + List<LocDetlField> locDetlFields = locDetlFieldService.list(new LambdaQueryWrapper<LocDetlField>().eq(LocDetlField::getDetlId, locDetl.getId())); + for (LocDetlField locDetlField : locDetlFields) { + TaskDetlField taskDetlField = new TaskDetlField(); + taskDetlField.sync(locDetlField); + taskDetlField.setId(null); + taskDetlField.setDetlId(taskDetl.getId()); + if (!taskDetlFieldService.save(taskDetlField)) { + throw new CoolException("鏄庣粏鎵╁睍鐢熸垚澶辫触"); + } + } + } + + if (!locService.update(new LambdaUpdateWrapper<Loc>().eq(Loc::getId, locs.getId()) + .set(Loc::getUpdateTime, new Date()) + .set(Loc::getLocStsId, LocStsType.R.val()))) { + throw new CoolException("搴撲綅鐘舵�佷慨鏀瑰け璐ワ紒锛�"); + } } - /*** - * 姣忛殧10绉掞紝鍒锋柊褰撳墠閫氱煡妗e垪琛紝涓嬪彂寰呭叆搴撹鍗曡嚦ESS + * 鍏ュ簱浠诲姟---涓嬪彂鍏ュ簱浠诲姟 + * 姣忛殧3绉掞紝鍒锋柊褰撳墠閫氱煡妗e垪琛紝涓嬪彂寰呭叆搴撹鍗曡嚦ESS * 鏌ヨ褰撳墠浠诲姟鍒楄〃锛� */ -// @Scheduled(cron = "0/3 * * * * ? ") + @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) - .eq(Task::getTaskSts, TaskStsType.GENERATE_IN)) +// .eq(Task::getTaskType, 1) + .eq(Task::getTaskSts, TaskStsType.GENERATE_IN.id)) .stream().sorted(Comparator.comparing(Task::getTaskSts)) .collect(Collectors.toList()); + if (tasks.size() == 0) { + return; + } // 鏁版嵁缁勮 PublishTasksParam tasksParam = new PublishTasksParam(); @@ -150,40 +211,42 @@ 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); + + param.setTaskDescribe(describe); params.add(param); tasksParam.setTasks(params); }); tasksParam.setTaskType("putaway"); - // TODO 澶氫换鍔″璁㈠崟锛岀粺涓�璋冨害锛屾槸鍚︿細鍑虹幇閮ㄥ垎鎴愬姛锛岄儴鍒嗗け璐ョ殑鎯呭喌 - //璋冪敤涓夋柟鎺ュ彛锛屽皢浠诲姟鎺ㄩ�佽嚦ESS骞冲彴 - MultiValueMap<String, Object> params = new LinkedMultiValueMap<>(); - // 璁剧疆璇锋眰鍙傛暟 - params.add("params", JSONObject.toJSONString(tasksParam)); - log.info("璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", Constant.ISSUE_TASK_OF_PUTAWAY, JSONObject.toJSONString(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); + headers.add("api-version", "v2.0"); + HttpEntity httpEntity = new HttpEntity<>(tasksParam, headers); // 璇锋眰 - ResponseEntity<String> exchange = restTemplate.exchange(Constant.ISSUE_TASK_OF_PUTAWAY, HttpMethod.POST, httpEntity, String.class); + 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); if (reponse.getCode() == 0) { - //璇锋眰鎴愬姛鍚庯紝缁熶竴淇敼鎵�鏈変换鍔℃。鐘舵�佷负鍏ュ簱鎵ц涓�� + // 璇锋眰鎴愬姛鍚庯紝缁熶竴淇敼鎵�鏈変换鍔℃。鐘舵�佷负鍏ュ簱鎵ц涓�� tasks.forEach(task -> { taskService.update(new LambdaUpdateWrapper<Task>() .set(Task::getTaskSts, TaskStsType.WCS_EXECUTE_IN.id) @@ -196,10 +259,127 @@ } } - /*** - * 姣忛殧10绉掓墽琛岋紝鍒锋柊褰撳墠浠诲姟鍒楄〃锛屼笅鍙戜换鍔″埌ESS - */ - public void flowNotify() { + /** + * //fixme 寮冪敤 + * 鍑哄簱浠诲姟---閫氱煡瀹瑰櫒娴佸姩 + * 姣忛殧3绉掞紝鑾峰彇褰撳墠鍑哄簱浠诲姟鍒楄〃鐘舵�佷负COMPLETE_OUT鐨勪换鍔★紝骞堕�氱煡ESS娴佸姩杈撻�佺嚎 + */ +// @Scheduled(cron = "0/5 * * * * ? ") + @Transactional(rollbackFor = Exception.class) + public void conveyorToNotify() { + List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() + .eq(Task::getTaskSts, TaskStsType.WCS_EXECUTE_OUT_CONVEYOR.id).eq(Task::getStatus, 1)); + + // 杩橀渶瑕佸啀淇敼 + tasks.forEach(task -> { +// try { +// ConveyorStarParam conveyorStarParam = new ConveyorStarParam(); +// conveyorStarParam.setSlotCode(task.getOriginLoc()) +// .setContainerCode(task.getBarcode()); +// if (task.getTaskType() == 101) { //浠诲姟绫诲瀷涓�101鍏ㄧ洏鍑哄簱锛岀洿鎺ュ彇涓嬪鍣紝浼�200 +// conveyorStarParam.setDirection("200"); +// } else if (task.getTaskType() == 103) { //濡傛灉涓轰换鍔$被鍨嬩负103锛岄渶璧板洖搴撴搷浣滐紝浼�100 +// conveyorStarParam.setDirection("100"); +// } +// //璋冪敤涓夋柟鎺ュ彛锛屽皢浠诲姟鎺ㄩ�佽嚦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) { + //娴佸姩閫氱煡涓嬪彂瀹屾垚鍚庯紝淇敼浠诲姟鐘舵�佷负杈撻�佺嚎娴佸姩涓�傘�� +// taskService.update(new LambdaUpdateWrapper<Task>() +// .eq(Task::getId, task.getId()) +// .set(Task::getTaskSts, TaskStsType.COMPLETE_OUT.id)); + +// 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) +// .set(Task::getUpdateTime, new Date()) +// .eq(Task::getId, task.getId())); +// } + }); + } + + + /** + * 鍑哄簱浠诲姟--- 姣忛殧3绉掞紝鑾峰彇褰撳墠鍑哄簱浠诲姟鍒楄〃鐘舵�佷负GENERATE_OUT鐨勪换鍔★紝涓嬪彂浠诲姟鑷矱SS + * //TODO 鍑哄簱浠诲姟鍒嗕袱绉嶏細 + * //TODO 1. 姝e父鍑哄簱鍚庯紝娓呴櫎浠诲姟锛� + * //TODO 2. 鍑哄簱鍚庤繕鏈夊簱瀛橈紝闇�瑕佹坊鍔犲鍣ㄥ洖搴撴搷浣� + */ + @Scheduled(cron = "0/3 * * * * ? ") + @Transactional(rollbackFor = Exception.class) + public void waveToTask() throws JsonProcessingException { + //鑾峰彇褰撳墠浠诲姟妗d腑锛屾墍鏈変负寰呭嚭搴撶姸鎬佺殑浠诲姟妗o紝鎸夋椂闂村崌搴忔帓鍒� + List<Task> tasks = taskService.list(new LambdaQueryWrapper<Task>() + .ge(Task::getTaskType, 101) //TODO 濡備綍纭鏄�101锛岃繕鏄�103 + .eq(Task::getTaskSts, TaskStsType.GENERATE_OUT.id)); + if (tasks.isEmpty()) { + return; + } +// tasks.stream().sorted(Comparator.comparing(Task::getTaskSts)) +// .collect(Collectors.toList()); + + // 鏁版嵁缁勮 + PublishTasksParam tasksParam = new PublishTasksParam(); + List<TaskParam> params = new ArrayList<>(); + //TODO 纭鏄惁闇�瑕佸崟浠诲姟澶氬鍣ㄧ爜鐨勯渶姹傦紝鐩墠绯荤粺閮芥槸鍗曞鍣ㄧ爜鐢熸垚鍗曚换鍔★紝澶氫换鍔℃槑缁嗭紙鐗╂枡娣疯锛� + tasks.forEach(task -> { + TaskParam param = new TaskParam(); + //璁剧疆瀹瑰櫒缂栫爜 + param.setTaskCode(task.getTaskNo()); + TaskDescribe describe = new TaskDescribe(); + //璁剧疆鐩爣搴撲綅锛岀珯鐐� + describe.setContainerCode(task.getBarcode()) + .setToLocationCode(task.getTargetLoc()) + .setToStationCode(task.getTargetSite()); + param.setTaskDescribe(describe); + params.add(param); + }); + tasksParam.setTasks(params); + tasksParam.setTaskType("carry"); + log.info("鍑哄簱浠诲姟涓嬪彂璇锋眰鍦板潃锛歿}锛岃姹傚弬鏁帮細{}", properties.getBaseHost() + properties.getEssReceiveTask(), JSONObject.toJSONString(tasksParam)); + HttpHeaders headers = new HttpHeaders(); + headers.add("Content-Type", "application/json"); + HttpEntity httpEntity = new HttpEntity<>(tasksParam, headers); + // 璇锋眰 + 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 { + ObjectMapper objectMapper = new ObjectMapper(); + CommonReponse reponse = objectMapper.readValue(exchange.getBody(), CommonReponse.class); + if (reponse.getCode() == 0) { + //璇锋眰鎴愬姛鍚庯紝缁熶竴淇敼鎵�鏈変换鍔℃。鐘舵�佷负鍏ュ簱鎵ц涓�� + tasks.forEach(task -> { + taskService.update(new LambdaUpdateWrapper<Task>() + .set(Task::getTaskSts, TaskStsType.WCS_EXECUTE_OUT.id) + .eq(Task::getId, task.getId())); + }); + } else { + // TODO 璇锋眰澶辫触闇�纭鏄惁瀛樺湪閮ㄥ垎鎴愬姛鐨勬儏鍐碉紝閮ㄥ垎鎴愬姛闇�瑕佸崟鐙埛鏂版垚鍔熺殑浠诲姟妗g姸鎬� + throw new CoolException(reponse.getMsg()); + } + } } } -- Gitblit v1.9.1