diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/controller/AcsController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/controller/AcsController.java index c7ed874..96c9b3e 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/controller/AcsController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/acs/controller/AcsController.java @@ -8,6 +8,7 @@ import org.jeecg.modules.wms.api.acs.service.IAcsService; import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; import org.jeecg.modules.wms.framework.controller.HuahengBaseController; import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService; +import org.jeecg.utils.StringUtils; import org.jeecg.utils.constant.QuantityConstant; import org.springframework.transaction.annotation.Transactional; import org.springframework.web.bind.annotation.*; @@ -36,16 +37,16 @@ public class AcsController extends HuahengBaseController { String carNo = acsStatus.getCarNo(); int status = acsStatus.getStatus(); String updateBy = acsStatus.getUpdateBy(); - if (taskNo == null) { + if (StringUtils.isEmpty(taskNo)) { return Result.error("更新AGV状态,任务号为空"); } - if (carNo == null) { + if (StringUtils.isEmpty(carNo)) { return Result.error("更新AGV状态,车辆编号为空"); } if (status == 0) { return Result.error("更新AGV状态,状态信息为空"); } - if (updateBy == null) { + if (StringUtils.isEmpty(updateBy)) { return Result.error("更新AGV状态,更新者信息为空"); } if (status == QuantityConstant.TASK_STATUS_COMPLETED) { diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java index 0972a5a..b61a5ca 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java @@ -1,5 +1,7 @@ package org.jeecg.modules.wms.api.wcs.controller; +import java.util.Map; + import javax.annotation.Resource; import javax.servlet.http.HttpServletRequest; @@ -12,9 +14,11 @@ import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; import org.jeecg.modules.wms.api.wcs.service.WcsService; import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; import org.jeecg.modules.wms.framework.controller.HuahengBaseController; +import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; import org.jeecg.utils.HuahengJwtUtil; import org.jeecg.utils.StringUtils; +import org.jeecg.utils.constant.QuantityConstant; import org.springframework.web.bind.annotation.*; import io.swagger.annotations.ApiOperation; @@ -144,4 +148,57 @@ public class WcsController extends HuahengBaseController { Result result = wcsService.setMaterialInfo(materialInfoEntity); return result; } + + @AutoLog(value = "到达拣选台") + @PostMapping("/arrivedNotice") + @ApiOperation("到达拣选台") + @ResponseBody + @ApiLogger(apiName = "到达拣选台", from = "WCS") + public Result arrivedNotice(@RequestBody Map<String, String> map, HttpServletRequest req) { + String taskNo = map.get("taskNo"); + String port = map.get("port"); + String msg = map.get("msg"); + String state = map.get("state"); + TaskHeader taskHeader = taskHeaderService.getById(taskNo); + if (taskHeader == null) { + return Result.error("没有找到任务taskNo:" + taskNo); + } + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req); + if (!taskHeader.getWarehouseCode().equals(warehouseCode)) { + return Result.error("任务仓库编码不匹配"); + } + int status = taskHeader.getStatus(); + if (status == QuantityConstant.TASK_STATUS_COMPLETED) { + return Result.error("任务已经完成taskNo:" + taskNo); + } + taskHeader.setStatus(QuantityConstant.TASK_STATUS_ARRIVED_STATION); + taskHeader.setToPortCode(port); + boolean result = taskHeaderService.updateById(taskHeader); + if (!result) { + return Result.error("更新到达站台失败"); + } + return Result.ok("更新到达站台成功"); + } + + @AutoLog(value = "空出处理") + @PostMapping("/emptyOutHandle") + @ApiOperation("空出处理") + @ResponseBody + @ApiLogger(apiName = "空出处理", from = "WCS") + public Result emptyOutHandle(@RequestBody Map<String, String> map) { + String taskNo = map.get("taskNo"); + Result result = wcsService.emptyOutHandle(taskNo); + return result; + } + + @AutoLog(value = "重入处理") + @PostMapping("/reentryHandle") + @ApiOperation("重入处理") + @ResponseBody + @ApiLogger(apiName = "重入处理", from = "WCS") + public Result reentryHandle(@RequestBody Map<String, String> map) { + String taskNo = map.get("taskNo"); + Result result = wcsService.reentryHandle(taskNo); + return result; + } } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/entity/TaskReentryEntity.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/entity/TaskReentryEntity.java new file mode 100644 index 0000000..685cf09 --- /dev/null +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/entity/TaskReentryEntity.java @@ -0,0 +1,10 @@ +package org.jeecg.modules.wms.api.wcs.entity; + +import lombok.Data; + +@Data +public class TaskReentryEntity { + + private Integer taskNo; + private String redirectionLocationCode; +} diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsService.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsService.java index 43dfe8c..bda94b2 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsService.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsService.java @@ -14,10 +14,25 @@ public interface WcsService { /** 仓位分配 */ Result warecellAllocation(WarecellDomain warecellDomain); + /** + * 下发任务给WCS + */ Result wcsTaskAssign(TaskHeader taskHeader); WcsTask switchTaskTypeToWcs(WcsTask wcsTask); - /** + + /** * 设置物料信息,包括长、宽、高、重量 */ - Result setMaterialInfo(MaterialInfoEntity materialInfoEntity);} + Result setMaterialInfo(MaterialInfoEntity materialInfoEntity); + + /** + * 空出处理 + */ + Result emptyOutHandle(String taskNo); + + /** + * 重入处理 + */ + Result reentryHandle(String taskNo); +} diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java index cad2e9c..7cd3f8d 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java @@ -8,12 +8,13 @@ import javax.annotation.Resource; import org.jeecg.common.api.vo.Result; import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity; +import org.jeecg.modules.wms.api.wcs.entity.TaskReentryEntity; import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; import org.jeecg.modules.wms.api.wcs.entity.WcsTask; import org.jeecg.modules.wms.config.address.service.IAddressService; import org.jeecg.modules.wms.config.container.entity.Container; import org.jeecg.modules.wms.config.container.service.IContainerService; -import org.jeecg.modules.wms.config.containerType.service.impl.ContainerTypeServiceImpl; +import org.jeecg.modules.wms.config.containerType.service.IContainerTypeService; import org.jeecg.modules.wms.config.location.entity.Location; import org.jeecg.modules.wms.config.location.service.ILocationService; import org.jeecg.modules.wms.config.locationHigh.entity.LocationHigh; @@ -78,8 +79,11 @@ public class WcsServiceImpl implements WcsService { @Resource private IAddressService addressService; @Resource - private ContainerTypeServiceImpl containerTypeServiceImpl; + private IContainerTypeService containerTypeService; + /** + * 库位分配 + */ @Override @Transactional(rollbackFor = Exception.class) public Result warecellAllocation(WarecellDomain warecellDomain) { @@ -439,4 +443,131 @@ public class WcsServiceImpl implements WcsService { } return Result.ok("设置物料信息成功"); } + + @Override + @Transactional(rollbackFor = Exception.class) + public Result emptyOutHandle(String taskNo) { + if (StringUtils.isEmpty(taskNo)) { + return Result.error("任务号为空"); + } + + TaskHeader taskHeader = taskHeaderService.getById(taskNo); + if (taskHeader == null) { + return Result.error("任务号错误,没有找到该任务"); + } + + if (taskHeader.getStatus() == QuantityConstant.TASK_STATUS_COMPLETED) { + return Result.error("任务已完成"); + } + + taskHeader.setIsEmptyOut(QuantityConstant.EMPTY_OUT); + taskHeader.setExceptionName("空出处理"); + taskHeader.setExceptionState(1); + boolean success = taskHeaderService.updateById(taskHeader); + if (!success) { + return Result.error("修改任务失败,空出处理失败"); + } + return Result.ok("空出处理成功"); + } + + @Override + public Result reentryHandle(String taskNo) { + // 1、判断非空字段 + if (StringUtils.isEmpty(taskNo)) { + return Result.error("重入处理失败, 任务号为空"); + } + // 2、根据任务号查找任务 + TaskHeader taskHeader = taskHeaderService.getById(taskNo); + if (taskHeader == null) { + return Result.error("重入处理失败,任务号错误没有找到该任务"); + } + String warehouseCode = taskHeader.getWarehouseCode(); + int status = taskHeader.getStatus(); + if (status == QuantityConstant.TASK_STATUS_COMPLETED) { + return Result.error("重入处理失败, 任务已完成"); + } + String toLocationCode = taskHeader.getToLocationCode(); + if (StringUtils.isEmpty(toLocationCode)) { + return Result.error("重入处理失败, 目的库位号为空"); + } + // 3、找到目标库位 + Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); + if (toLocation == null) { + return Result.error("重入处理失败, 没有找到目标库位"); + } + + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_ALLOCATION); + if (StringUtils.isEmpty(value)) { + return Result.error("重入处理失败,未绑定定位规则"); + } + int allocationRule = Integer.parseInt(value); + List<String> locationTypeCodeList = new ArrayList<>(); + String locationTypeCode = toLocation.getLocationTypeCode(); + if (StringUtils.isNotEmpty(locationTypeCode)) { + locationTypeCodeList.add(locationTypeCode); + } + int high = toLocation.getHigh(); + String zoneCode = toLocation.getZoneCode(); + Integer roadWay = toLocation.getRoadWay(); + List<Integer> roadWays = new ArrayList<>(); + roadWays.add(roadWay); + String containerCode = taskHeader.getContainerCode(); + List<TaskDetail> taskDetailList = taskDetailService.getTaskDetailListByTaskId(taskHeader.getId()); + String materialAreaCode = null; + if (taskDetailList != null && taskDetailList.size() > 0) { + String materialCode = taskDetailList.get(0).getMaterialCode(); + Material material = materialService.getMaterialByCode(materialCode); + materialAreaCode = material.getMaterialareaCode(); + } + // 4. WMS重新分配库位号 + String locationCode = + locationAllocationService.allocation(allocationRule, locationTypeCodeList, high, zoneCode, roadWays, warehouseCode, containerCode, materialAreaCode); + if (StringUtils.isEmpty(locationCode)) { + return Result.error("重入处理失败, 没有库位可分配"); + } + // 5. 任务类型为整盘入库、补充入库,更新入库组盘的库位号 + int taskType = taskHeader.getTaskType(); + if (taskType == QuantityConstant.TASK_TYPE_WHOLERECEIPT || taskType == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) { + ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(taskHeader.getReceiptContainerHeaderId()); + if (receiptContainerHeader == null) { + return Result.error("重入处理失败, 没有找到入库组盘头"); + } + receiptContainerHeader.setToLocationCode(locationCode); + boolean success = receiptContainerHeaderService.updateById(receiptContainerHeader); + if (!success) { + throw new ServiceException("重入处理失败, 更新入库组盼头失败"); + } + } + // 6. 锁定WMS分配的库位 + boolean success = locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); + if (!success) { + throw new ServiceException("重入处理失败, 更新库位状态失败"); + } + String originLocationCode = taskHeader.getOriginLocationCode(); + String taskLocationCode = taskHeader.getToLocationCode(); + // 7. 把原来的目标库位记录到初始库位上 + if (StringUtils.isEmpty(originLocationCode)) { + originLocationCode = taskLocationCode; + } else { + originLocationCode = originLocationCode + "," + taskLocationCode; + } + + taskHeader.setToLocationCode(locationCode); + taskHeader.setExceptionName("重入处理"); + taskHeader.setIsDoubleIn(QuantityConstant.DOUBLE_IN); + taskHeader.setExceptionState(1); + taskHeader.setOriginLocationCode(originLocationCode); + // 8. 更新任务信息 + success = taskHeaderService.updateById(taskHeader); + if (!success) { + throw new ServiceException("重入处理失败, 更新任务信息失败"); + } + + // 9. 封装返回的数据格式,包括任务号和重新分配的库位号 + TaskReentryEntity taskReentryEntity = new TaskReentryEntity(); + taskReentryEntity.setTaskNo(Integer.parseInt(taskNo)); + taskReentryEntity.setRedirectionLocationCode(toLocationCode); + return Result.ok(taskReentryEntity); + } + } diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java index 03068fa..d4cbb72 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/config/container/service/impl/ContainerServiceImpl.java @@ -86,8 +86,8 @@ public class ContainerServiceImpl extends ServiceImpl<ContainerMapper, Container boolean success = false; if (StringUtils.isNotEmpty(locationCode)) { success = havaLocationCodeByContainer(locationCode, warehouseCode); - if (!success) { - throw new ServiceException("取消任务时, 库位表已经存在这个容器号,不能再写入"); + if (success) { + throw new ServiceException("库位表已经存在这个容器号,不能再写入"); } } container.setStatus(status); diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java index a06d05b..249e8fb 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java @@ -79,7 +79,7 @@ public class TaskHeader implements Serializable { @Excel(name = "是否空出", width = 15, dicCode = "is_or_not") @Dict(dicCode = "is_or_not") @ApiModelProperty(value = "是否空出") - private String isEmptyOut; + private Integer isEmptyOut; /** 是否重入 */ @Excel(name = "是否重入", width = 15, dicCode = "is_or_not") @Dict(dicCode = "is_or_not") @@ -126,6 +126,10 @@ public class TaskHeader implements Serializable { private Integer sequence; @ApiModelProperty(value = "顺序数量") private Integer sequenceNumber; + @ApiModelProperty(value = "异常原因") + private String exceptionName; + @ApiModelProperty(value = "异常状态") + private Integer exceptionState; /** 备用字段1 */ @Excel(name = "备用字段1", width = 15) @ApiModelProperty(value = "备用字段1") diff --git a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java index e6244b7..eff1a1d 100644 --- a/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java +++ b/huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java @@ -1815,8 +1815,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea } if (StringUtils.isNotEmpty(fromLocationCode)) { success = containerService.havaLocationCodeByContainer(fromLocationCode, warehouseCode); - if (!success) { - throw new ServiceException("取消任务时, 库位表已经存在这个容器号,不能再写入"); + if (success) { + throw new ServiceException("库位表已经存在这个容器号,不能再写入"); } } container.setLastStatus(QuantityConstant.EMPTY_STRING);