diff --git a/shkj-wms/src/main/java/com/shkj/wcs/controller/busin/WcsTaskController.java b/shkj-wms/src/main/java/com/shkj/wcs/controller/busin/WcsTaskController.java index adddfe9..bca9653 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/controller/busin/WcsTaskController.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/controller/busin/WcsTaskController.java @@ -49,77 +49,7 @@ public class WcsTaskController { @PostMapping("/toKjWcs/commonApi") @RepeatSubmit public WcsResponseVo commonApi(@RequestBody WcsCreateTaskDto bo) { - if (bo != null) { - List body = bo.getBody(); - if (!body.isEmpty()) { - for (WcsCreateTaskBody by : body) { - String taskId = by.getTaskId(); - String trayCode = by.getTrayCode(); - String taskType = by.getTaskType(); - String fromBinCode = by.getFromBinCode(); - String toBinCode = by.getToBinCode(); - String dataChange = by.getDataChange(); - String priority = by.getPriority(); - LambdaQueryWrapper lqwDataTask = new LambdaQueryWrapper() - .eq(BusinDataTask::getContainerCode, trayCode) - .in(BusinDataTask::getTaskStatus, TaskStatusEnum.wait_put.getValue(),TaskStatusEnum.wait_callback.getValue() ); - BusinDataTask one = iBusinDataTaskService.getOne(lqwDataTask); - if (dataChange.equals("1")) { - if (one != null) { - return WcsResponseVo.error(500, "该托盘" + trayCode + "存在未完成的任务"); - } - BusinDataTask businDataTask = new BusinDataTask(); - businDataTask.setTaskCode(taskId); - businDataTask.setTaskType(taskType); - businDataTask.setContainerCode(trayCode); - businDataTask.setFromSide(fromBinCode); - businDataTask.setToSide(toBinCode); - businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue()); - businDataTask.setCreateTime(DateUtils.getNowDate()); - if (!priority.isEmpty()){ - businDataTask.setPriority(priority); - } - boolean save = iBusinDataTaskService.save(businDataTask); - if (save) { - //调用下游接口下任务 - log.info("任务储存成功!"); - RcsCreateTaskDto rcsCreateTaskDto = new RcsCreateTaskDto(); - rcsCreateTaskDto.setTaskType(RCSTaskTypeEnum.PF_LMR_COMMON.getValue()); - rcsCreateTaskDto.setRobotTaskCode(businDataTask.getTaskCode()); - if(!businDataTask.getPriority().isEmpty()){ - rcsCreateTaskDto.setInitPriority(Integer.parseInt(businDataTask.getPriority())); - } - List rcsIdLists =new ArrayList<>(); - for (int i = 1;i<=2;i++){ - RcsIdList rcsIdList =new RcsIdList(); - if(i==1){ - rcsIdList.setType("ZONE"); - rcsIdList.setCode(businDataTask.getFromSide()); - rcsIdList.setOperation(RCSOperation.OT_COLLECT.getValue()); - } - rcsIdList.setType("ZONE"); - rcsIdList.setCode(businDataTask.getToSide()); - rcsIdList.setOperation(RCSOperation.OT_DELIVERY.getValue()); - rcsIdLists.add(rcsIdList); - } - - //Result result = rcsUtil.rcsCreateTask(rcsCreateTaskDto); - - } - } else if (dataChange.equals("2")) { - if (one == null) { - return WcsResponseVo.error(500, "未查询到该托盘" + trayCode + "存在未完成的任务"); - } - one.setTaskStatus("6"); - iBusinDataTaskService.updateById(one); - //推送给下游 - - } - } - } - - } - return WcsResponseVo.success(); + return iBusinDataTaskService.doTaskGeneratePickTask(bo); } @@ -168,7 +98,7 @@ public class WcsTaskController { @Log(title = "扫码处入库申请测试接口", businessType = BusinessType.UPDATE) @PostMapping("/toWzWcs/wcsIncomingTaskRequest") @RepeatSubmit - public WcsResponseVo wcsIncomingTaskRequest(@RequestBody WcsIncomingTaskRequestDto dto) { + public WcsResponseVo wcsIncomingTaskRequest(@RequestBody WcsIncomingTaskRequestBody dto) { //调用plc接口 暂时不用 WcsResponseVo vo = wcsUtil.wcsIncomingTaskRequest(dto); return vo; diff --git a/shkj-wms/src/main/java/com/shkj/wcs/service/IBusinDataTaskService.java b/shkj-wms/src/main/java/com/shkj/wcs/service/IBusinDataTaskService.java index 8970fb1..28bbf30 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/service/IBusinDataTaskService.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/service/IBusinDataTaskService.java @@ -2,6 +2,8 @@ package com.shkj.wcs.service; import com.baomidou.mybatisplus.extension.service.IService; import com.shkj.wcs.domain.BusinDataTask; +import com.shkj.wcs.third.workbinWcs.dto.WcsCreateTaskDto; +import com.shkj.wcs.vo.WcsResponseVo; /** * @author Comair @@ -9,6 +11,11 @@ import com.shkj.wcs.domain.BusinDataTask; */ public interface IBusinDataTaskService extends IService { + /** + * 下发任务 + */ + WcsResponseVo doTaskGeneratePickTask(WcsCreateTaskDto bo); + } diff --git a/shkj-wms/src/main/java/com/shkj/wcs/service/impl/BusinDataTaskServiceImpl.java b/shkj-wms/src/main/java/com/shkj/wcs/service/impl/BusinDataTaskServiceImpl.java index 2e60db5..aa7828e 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/service/impl/BusinDataTaskServiceImpl.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/service/impl/BusinDataTaskServiceImpl.java @@ -1,6 +1,8 @@ package com.shkj.wcs.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.shkj.common.utils.DateUtils; import com.shkj.wcs.bo.WcsPlcPropertyQueryBo; import com.shkj.wcs.domain.BusinDataTask; import com.shkj.wcs.domain.WcsPlcProperty; @@ -8,10 +10,20 @@ import com.shkj.wcs.mapper.BusinDataTaskMapper; import com.shkj.wcs.mapper.WcsPlcPropertyMapper; import com.shkj.wcs.service.IBusinDataTaskService; import com.shkj.wcs.service.IWcsPlcPropertyService; +import com.shkj.wcs.third.rcs.dto.RcsCreateTaskDto; +import com.shkj.wcs.third.rcs.dto.RcsIdList; +import com.shkj.wcs.third.rcs.enums.RCSOperation; +import com.shkj.wcs.third.rcs.enums.RCSTaskTypeEnum; +import com.shkj.wcs.third.workbinWcs.dto.WcsCreateTaskBody; +import com.shkj.wcs.third.workbinWcs.dto.WcsCreateTaskDto; +import com.shkj.wcs.vo.WcsResponseVo; +import com.shkj.wms.enums.TaskStatusEnum; +import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.stereotype.Service; +import java.util.ArrayList; import java.util.List; /** @@ -21,6 +33,83 @@ import java.util.List; * @date 2023-04-21 */ @Service +@Slf4j public class BusinDataTaskServiceImpl extends ServiceImpl implements IBusinDataTaskService { + @Override + public WcsResponseVo doTaskGeneratePickTask(WcsCreateTaskDto bo) { + log.info("中科下发任务请求数据:"+bo); + if (bo != null) { + List body = bo.getBody(); + if (!body.isEmpty()) { + for (WcsCreateTaskBody by : body) { + String taskId = by.getTaskId(); + String trayCode = by.getTrayCode(); + String taskType = by.getTaskType(); + String fromBinCode = by.getFromBinCode(); + String toBinCode = by.getToBinCode(); + String dataChange = by.getDataChange(); + String priority = by.getPriority(); + LambdaQueryWrapper lqwDataTask = new LambdaQueryWrapper() + .eq(BusinDataTask::getContainerCode, trayCode) + .in(BusinDataTask::getTaskStatus, TaskStatusEnum.wait_put.getValue(),TaskStatusEnum.wait_callback.getValue() ); + BusinDataTask one = this.getOne(lqwDataTask); + if (dataChange.equals("1")) { + if (one != null) { + return WcsResponseVo.error(500, "该托盘" + trayCode + "存在未完成的任务"); + } + BusinDataTask businDataTask = new BusinDataTask(); + businDataTask.setTaskCode(taskId); + businDataTask.setTaskType(taskType); + businDataTask.setContainerCode(trayCode); + businDataTask.setFromSide(fromBinCode); + businDataTask.setToSide(toBinCode); + businDataTask.setTaskStatus(TaskStatusEnum.wait_put.getValue()); + businDataTask.setCreateTime(DateUtils.getNowDate()); + if (!priority.isEmpty()){ + businDataTask.setPriority(priority); + } + boolean save = this.save(businDataTask); + if (save) { + //调用下游接口下任务 + log.info("任务储存成功!"); + RcsCreateTaskDto rcsCreateTaskDto = new RcsCreateTaskDto(); + rcsCreateTaskDto.setTaskType(RCSTaskTypeEnum.PF_LMR_COMMON.getValue()); + rcsCreateTaskDto.setRobotTaskCode(businDataTask.getTaskCode()); + if(!businDataTask.getPriority().isEmpty()){ + rcsCreateTaskDto.setInitPriority(Integer.parseInt(businDataTask.getPriority())); + } + List rcsIdLists =new ArrayList<>(); + for (int i = 1;i<=2;i++){ + RcsIdList rcsIdList =new RcsIdList(); + if(i==1){ + rcsIdList.setType("ZONE"); + rcsIdList.setCode(businDataTask.getFromSide()); + rcsIdList.setOperation(RCSOperation.OT_COLLECT.getValue()); + } + rcsIdList.setType("ZONE"); + rcsIdList.setCode(businDataTask.getToSide()); + rcsIdList.setOperation(RCSOperation.OT_DELIVERY.getValue()); + rcsIdLists.add(rcsIdList); + } + + //Result result = rcsUtil.rcsCreateTask(rcsCreateTaskDto); + + } + } else if (dataChange.equals("2")) { + if (one == null) { + return WcsResponseVo.error(500, "未查询到该托盘" + trayCode + "存在未完成的任务"); + } + one.setTaskStatus("6"); + this.updateById(one); + //推送给下游 + + } + return WcsResponseVo.success(); + } + } + + } + return WcsResponseVo.error(500,"请求失败请检查参数"); + } } diff --git a/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/WCSUtil.java b/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/WCSUtil.java index 0e09e66..0bfcfa3 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/WCSUtil.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/WCSUtil.java @@ -64,13 +64,18 @@ public class WCSUtil { * @return */ public WcsResponseVo queryTaskStatus(WCSQueryTaskStatusBody dto) { - Map headerMap = new HashMap<>(1); - headerMap.put("businessType", "trayCheck"); - String json = JSONObject.toJSONString(dto); + JSONObject jsonObject = new JSONObject(); + JSONObject header = new JSONObject(); + header.put("businessType","queryTaskStatus"); + jsonObject.put("header",header); + List queryTaskStatusBodyList = new ArrayList<>(); + queryTaskStatusBodyList.add(dto); + jsonObject.put("body",queryTaskStatusBodyList); + String json = JSONObject.toJSONString(jsonObject); + log.info("KJ向WZ请求是否存在生产区空托出库任务参数"+json); try { String res = HttpRequest.post(queryTaskStatusUrl) - .addHeaders(headerMap) .body(json) .execute().body(); log.info("KJ向WZ请求是否存在生产区空托出库任务返回:" + res); @@ -90,13 +95,18 @@ public class WCSUtil { * @return */ public WcsResponseVo wcsIncomingTrayCheck(WcsIncomingTrayCheckBody dto) { - Map headerMap = new HashMap<>(1); - headerMap.put("businessType", "trayCheck"); - String json = JSONObject.toJSONString(dto); + JSONObject jsonObject = new JSONObject(); + JSONObject header = new JSONObject(); + header.put("businessType","trayCheck"); + jsonObject.put("header",header); + List incomingTrayCheckBodies = new ArrayList<>(); + incomingTrayCheckBodies.add(dto); + jsonObject.put("body",incomingTrayCheckBodies); + String json = JSONObject.toJSONString(jsonObject); + log.info("KJ向WZ请求生产区入库托盘码校验参数"+json); try { String res = HttpRequest.post(wcsIncomingTrayCheckUrl) - .addHeaders(headerMap) .body(json) .execute().body(); log.info("KJ向WZ请求生产区入库托盘码校验返回:" + res); @@ -116,14 +126,19 @@ public class WCSUtil { * @param dto * @return */ - public WcsResponseVo wcsIncomingTaskRequest(WcsIncomingTaskRequestDto dto) { - Map headerMap = new HashMap<>(1); - headerMap.put("businessType", dto.getHeader().getBusinessType()); - String json = JSONObject.toJSONString(dto); + public WcsResponseVo wcsIncomingTaskRequest(WcsIncomingTaskRequestBody dto) { + JSONObject jsonObject = new JSONObject(); + JSONObject header = new JSONObject(); + header.put("businessType","stockIn"); + jsonObject.put("header",header); + List incomingTaskRequestBodies = new ArrayList<>(); + incomingTaskRequestBodies.add(dto); + jsonObject.put("body",incomingTaskRequestBodies); + String json = JSONObject.toJSONString(jsonObject); + log.info("KJ向WZ入库申请参数"+json); try { String res = HttpRequest.post(wcsIncomingTaskRequestUrl) - .addHeaders(headerMap) .body(json) .execute().body(); log.info("KJ向WZ入库申请返回:" + res); diff --git a/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/dto/WcsIncomingTaskRequestBody.java b/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/dto/WcsIncomingTaskRequestBody.java index c6fa61c..cb5c3d0 100644 --- a/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/dto/WcsIncomingTaskRequestBody.java +++ b/shkj-wms/src/main/java/com/shkj/wcs/third/workbinWcs/dto/WcsIncomingTaskRequestBody.java @@ -21,7 +21,6 @@ public class WcsIncomingTaskRequestBody implements Serializable { /** * 托盘码 */ - @NotBlank(message = "托盘码不得为空") private String trayCode;