Commit da91f3c8d0dce3c14e363a901a71bd4b20bb4f37

Authored by 肖超群
1 parent cb3833e5

1. 增加重入、空出处理

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; @@ -8,6 +8,7 @@ import org.jeecg.modules.wms.api.acs.service.IAcsService;
8 import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; 8 import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger;
9 import org.jeecg.modules.wms.framework.controller.HuahengBaseController; 9 import org.jeecg.modules.wms.framework.controller.HuahengBaseController;
10 import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService; 10 import org.jeecg.modules.wms.task.agvTask.service.IAgvTaskService;
  11 +import org.jeecg.utils.StringUtils;
11 import org.jeecg.utils.constant.QuantityConstant; 12 import org.jeecg.utils.constant.QuantityConstant;
12 import org.springframework.transaction.annotation.Transactional; 13 import org.springframework.transaction.annotation.Transactional;
13 import org.springframework.web.bind.annotation.*; 14 import org.springframework.web.bind.annotation.*;
@@ -36,16 +37,16 @@ public class AcsController extends HuahengBaseController { @@ -36,16 +37,16 @@ public class AcsController extends HuahengBaseController {
36 String carNo = acsStatus.getCarNo(); 37 String carNo = acsStatus.getCarNo();
37 int status = acsStatus.getStatus(); 38 int status = acsStatus.getStatus();
38 String updateBy = acsStatus.getUpdateBy(); 39 String updateBy = acsStatus.getUpdateBy();
39 - if (taskNo == null) { 40 + if (StringUtils.isEmpty(taskNo)) {
40 return Result.error("更新AGV状态,任务号为空"); 41 return Result.error("更新AGV状态,任务号为空");
41 } 42 }
42 - if (carNo == null) { 43 + if (StringUtils.isEmpty(carNo)) {
43 return Result.error("更新AGV状态,车辆编号为空"); 44 return Result.error("更新AGV状态,车辆编号为空");
44 } 45 }
45 if (status == 0) { 46 if (status == 0) {
46 return Result.error("更新AGV状态,状态信息为空"); 47 return Result.error("更新AGV状态,状态信息为空");
47 } 48 }
48 - if (updateBy == null) { 49 + if (StringUtils.isEmpty(updateBy)) {
49 return Result.error("更新AGV状态,更新者信息为空"); 50 return Result.error("更新AGV状态,更新者信息为空");
50 } 51 }
51 if (status == QuantityConstant.TASK_STATUS_COMPLETED) { 52 if (status == QuantityConstant.TASK_STATUS_COMPLETED) {
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
1 package org.jeecg.modules.wms.api.wcs.controller; 1 package org.jeecg.modules.wms.api.wcs.controller;
2 2
  3 +import java.util.Map;
  4 +
3 import javax.annotation.Resource; 5 import javax.annotation.Resource;
4 import javax.servlet.http.HttpServletRequest; 6 import javax.servlet.http.HttpServletRequest;
5 7
@@ -12,9 +14,11 @@ import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; @@ -12,9 +14,11 @@ import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain;
12 import org.jeecg.modules.wms.api.wcs.service.WcsService; 14 import org.jeecg.modules.wms.api.wcs.service.WcsService;
13 import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger; 15 import org.jeecg.modules.wms.framework.aspectj.lang.annotation.ApiLogger;
14 import org.jeecg.modules.wms.framework.controller.HuahengBaseController; 16 import org.jeecg.modules.wms.framework.controller.HuahengBaseController;
  17 +import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
15 import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; 18 import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService;
16 import org.jeecg.utils.HuahengJwtUtil; 19 import org.jeecg.utils.HuahengJwtUtil;
17 import org.jeecg.utils.StringUtils; 20 import org.jeecg.utils.StringUtils;
  21 +import org.jeecg.utils.constant.QuantityConstant;
18 import org.springframework.web.bind.annotation.*; 22 import org.springframework.web.bind.annotation.*;
19 23
20 import io.swagger.annotations.ApiOperation; 24 import io.swagger.annotations.ApiOperation;
@@ -144,4 +148,57 @@ public class WcsController extends HuahengBaseController { @@ -144,4 +148,57 @@ public class WcsController extends HuahengBaseController {
144 Result result = wcsService.setMaterialInfo(materialInfoEntity); 148 Result result = wcsService.setMaterialInfo(materialInfoEntity);
145 return result; 149 return result;
146 } 150 }
  151 +
  152 + @AutoLog(value = "到达拣选台")
  153 + @PostMapping("/arrivedNotice")
  154 + @ApiOperation("到达拣选台")
  155 + @ResponseBody
  156 + @ApiLogger(apiName = "到达拣选台", from = "WCS")
  157 + public Result arrivedNotice(@RequestBody Map<String, String> map, HttpServletRequest req) {
  158 + String taskNo = map.get("taskNo");
  159 + String port = map.get("port");
  160 + String msg = map.get("msg");
  161 + String state = map.get("state");
  162 + TaskHeader taskHeader = taskHeaderService.getById(taskNo);
  163 + if (taskHeader == null) {
  164 + return Result.error("没有找到任务taskNo:" + taskNo);
  165 + }
  166 + String warehouseCode = HuahengJwtUtil.getWarehouseCodeByToken(req);
  167 + if (!taskHeader.getWarehouseCode().equals(warehouseCode)) {
  168 + return Result.error("任务仓库编码不匹配");
  169 + }
  170 + int status = taskHeader.getStatus();
  171 + if (status == QuantityConstant.TASK_STATUS_COMPLETED) {
  172 + return Result.error("任务已经完成taskNo:" + taskNo);
  173 + }
  174 + taskHeader.setStatus(QuantityConstant.TASK_STATUS_ARRIVED_STATION);
  175 + taskHeader.setToPortCode(port);
  176 + boolean result = taskHeaderService.updateById(taskHeader);
  177 + if (!result) {
  178 + return Result.error("更新到达站台失败");
  179 + }
  180 + return Result.ok("更新到达站台成功");
  181 + }
  182 +
  183 + @AutoLog(value = "空出处理")
  184 + @PostMapping("/emptyOutHandle")
  185 + @ApiOperation("空出处理")
  186 + @ResponseBody
  187 + @ApiLogger(apiName = "空出处理", from = "WCS")
  188 + public Result emptyOutHandle(@RequestBody Map<String, String> map) {
  189 + String taskNo = map.get("taskNo");
  190 + Result result = wcsService.emptyOutHandle(taskNo);
  191 + return result;
  192 + }
  193 +
  194 + @AutoLog(value = "重入处理")
  195 + @PostMapping("/reentryHandle")
  196 + @ApiOperation("重入处理")
  197 + @ResponseBody
  198 + @ApiLogger(apiName = "重入处理", from = "WCS")
  199 + public Result reentryHandle(@RequestBody Map<String, String> map) {
  200 + String taskNo = map.get("taskNo");
  201 + Result result = wcsService.reentryHandle(taskNo);
  202 + return result;
  203 + }
147 } 204 }
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/entity/TaskReentryEntity.java 0 → 100644
  1 +package org.jeecg.modules.wms.api.wcs.entity;
  2 +
  3 +import lombok.Data;
  4 +
  5 +@Data
  6 +public class TaskReentryEntity {
  7 +
  8 + private Integer taskNo;
  9 + private String redirectionLocationCode;
  10 +}
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsService.java
@@ -14,10 +14,25 @@ public interface WcsService { @@ -14,10 +14,25 @@ public interface WcsService {
14 /** 仓位分配 */ 14 /** 仓位分配 */
15 Result warecellAllocation(WarecellDomain warecellDomain); 15 Result warecellAllocation(WarecellDomain warecellDomain);
16 16
  17 + /**
  18 + * 下发任务给WCS
  19 + */
17 Result wcsTaskAssign(TaskHeader taskHeader); 20 Result wcsTaskAssign(TaskHeader taskHeader);
18 21
19 WcsTask switchTaskTypeToWcs(WcsTask wcsTask); 22 WcsTask switchTaskTypeToWcs(WcsTask wcsTask);
20 - /** 23 +
  24 + /**
21 * 设置物料信息,包括长、宽、高、重量 25 * 设置物料信息,包括长、宽、高、重量
22 */ 26 */
23 - Result setMaterialInfo(MaterialInfoEntity materialInfoEntity);} 27 + Result setMaterialInfo(MaterialInfoEntity materialInfoEntity);
  28 +
  29 + /**
  30 + * 空出处理
  31 + */
  32 + Result emptyOutHandle(String taskNo);
  33 +
  34 + /**
  35 + * 重入处理
  36 + */
  37 + Result reentryHandle(String taskNo);
  38 +}
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java
@@ -8,12 +8,13 @@ import javax.annotation.Resource; @@ -8,12 +8,13 @@ import javax.annotation.Resource;
8 8
9 import org.jeecg.common.api.vo.Result; 9 import org.jeecg.common.api.vo.Result;
10 import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity; 10 import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity;
  11 +import org.jeecg.modules.wms.api.wcs.entity.TaskReentryEntity;
11 import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; 12 import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain;
12 import org.jeecg.modules.wms.api.wcs.entity.WcsTask; 13 import org.jeecg.modules.wms.api.wcs.entity.WcsTask;
13 import org.jeecg.modules.wms.config.address.service.IAddressService; 14 import org.jeecg.modules.wms.config.address.service.IAddressService;
14 import org.jeecg.modules.wms.config.container.entity.Container; 15 import org.jeecg.modules.wms.config.container.entity.Container;
15 import org.jeecg.modules.wms.config.container.service.IContainerService; 16 import org.jeecg.modules.wms.config.container.service.IContainerService;
16 -import org.jeecg.modules.wms.config.containerType.service.impl.ContainerTypeServiceImpl; 17 +import org.jeecg.modules.wms.config.containerType.service.IContainerTypeService;
17 import org.jeecg.modules.wms.config.location.entity.Location; 18 import org.jeecg.modules.wms.config.location.entity.Location;
18 import org.jeecg.modules.wms.config.location.service.ILocationService; 19 import org.jeecg.modules.wms.config.location.service.ILocationService;
19 import org.jeecg.modules.wms.config.locationHigh.entity.LocationHigh; 20 import org.jeecg.modules.wms.config.locationHigh.entity.LocationHigh;
@@ -78,8 +79,11 @@ public class WcsServiceImpl implements WcsService { @@ -78,8 +79,11 @@ public class WcsServiceImpl implements WcsService {
78 @Resource 79 @Resource
79 private IAddressService addressService; 80 private IAddressService addressService;
80 @Resource 81 @Resource
81 - private ContainerTypeServiceImpl containerTypeServiceImpl; 82 + private IContainerTypeService containerTypeService;
82 83
  84 + /**
  85 + * 库位分配
  86 + */
83 @Override 87 @Override
84 @Transactional(rollbackFor = Exception.class) 88 @Transactional(rollbackFor = Exception.class)
85 public Result warecellAllocation(WarecellDomain warecellDomain) { 89 public Result warecellAllocation(WarecellDomain warecellDomain) {
@@ -439,4 +443,131 @@ public class WcsServiceImpl implements WcsService { @@ -439,4 +443,131 @@ public class WcsServiceImpl implements WcsService {
439 } 443 }
440 return Result.ok("设置物料信息成功"); 444 return Result.ok("设置物料信息成功");
441 } 445 }
  446 +
  447 + @Override
  448 + @Transactional(rollbackFor = Exception.class)
  449 + public Result emptyOutHandle(String taskNo) {
  450 + if (StringUtils.isEmpty(taskNo)) {
  451 + return Result.error("任务号为空");
  452 + }
  453 +
  454 + TaskHeader taskHeader = taskHeaderService.getById(taskNo);
  455 + if (taskHeader == null) {
  456 + return Result.error("任务号错误,没有找到该任务");
  457 + }
  458 +
  459 + if (taskHeader.getStatus() == QuantityConstant.TASK_STATUS_COMPLETED) {
  460 + return Result.error("任务已完成");
  461 + }
  462 +
  463 + taskHeader.setIsEmptyOut(QuantityConstant.EMPTY_OUT);
  464 + taskHeader.setExceptionName("空出处理");
  465 + taskHeader.setExceptionState(1);
  466 + boolean success = taskHeaderService.updateById(taskHeader);
  467 + if (!success) {
  468 + return Result.error("修改任务失败,空出处理失败");
  469 + }
  470 + return Result.ok("空出处理成功");
  471 + }
  472 +
  473 + @Override
  474 + public Result reentryHandle(String taskNo) {
  475 + // 1、判断非空字段
  476 + if (StringUtils.isEmpty(taskNo)) {
  477 + return Result.error("重入处理失败, 任务号为空");
  478 + }
  479 + // 2、根据任务号查找任务
  480 + TaskHeader taskHeader = taskHeaderService.getById(taskNo);
  481 + if (taskHeader == null) {
  482 + return Result.error("重入处理失败,任务号错误没有找到该任务");
  483 + }
  484 + String warehouseCode = taskHeader.getWarehouseCode();
  485 + int status = taskHeader.getStatus();
  486 + if (status == QuantityConstant.TASK_STATUS_COMPLETED) {
  487 + return Result.error("重入处理失败, 任务已完成");
  488 + }
  489 + String toLocationCode = taskHeader.getToLocationCode();
  490 + if (StringUtils.isEmpty(toLocationCode)) {
  491 + return Result.error("重入处理失败, 目的库位号为空");
  492 + }
  493 + // 3、找到目标库位
  494 + Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode);
  495 + if (toLocation == null) {
  496 + return Result.error("重入处理失败, 没有找到目标库位");
  497 + }
  498 +
  499 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_ALLOCATION);
  500 + if (StringUtils.isEmpty(value)) {
  501 + return Result.error("重入处理失败,未绑定定位规则");
  502 + }
  503 + int allocationRule = Integer.parseInt(value);
  504 + List<String> locationTypeCodeList = new ArrayList<>();
  505 + String locationTypeCode = toLocation.getLocationTypeCode();
  506 + if (StringUtils.isNotEmpty(locationTypeCode)) {
  507 + locationTypeCodeList.add(locationTypeCode);
  508 + }
  509 + int high = toLocation.getHigh();
  510 + String zoneCode = toLocation.getZoneCode();
  511 + Integer roadWay = toLocation.getRoadWay();
  512 + List<Integer> roadWays = new ArrayList<>();
  513 + roadWays.add(roadWay);
  514 + String containerCode = taskHeader.getContainerCode();
  515 + List<TaskDetail> taskDetailList = taskDetailService.getTaskDetailListByTaskId(taskHeader.getId());
  516 + String materialAreaCode = null;
  517 + if (taskDetailList != null && taskDetailList.size() > 0) {
  518 + String materialCode = taskDetailList.get(0).getMaterialCode();
  519 + Material material = materialService.getMaterialByCode(materialCode);
  520 + materialAreaCode = material.getMaterialareaCode();
  521 + }
  522 + // 4. WMS重新分配库位号
  523 + String locationCode =
  524 + locationAllocationService.allocation(allocationRule, locationTypeCodeList, high, zoneCode, roadWays, warehouseCode, containerCode, materialAreaCode);
  525 + if (StringUtils.isEmpty(locationCode)) {
  526 + return Result.error("重入处理失败, 没有库位可分配");
  527 + }
  528 + // 5. 任务类型为整盘入库、补充入库,更新入库组盘的库位号
  529 + int taskType = taskHeader.getTaskType();
  530 + if (taskType == QuantityConstant.TASK_TYPE_WHOLERECEIPT || taskType == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) {
  531 + ReceiptContainerHeader receiptContainerHeader = receiptContainerHeaderService.getById(taskHeader.getReceiptContainerHeaderId());
  532 + if (receiptContainerHeader == null) {
  533 + return Result.error("重入处理失败, 没有找到入库组盘头");
  534 + }
  535 + receiptContainerHeader.setToLocationCode(locationCode);
  536 + boolean success = receiptContainerHeaderService.updateById(receiptContainerHeader);
  537 + if (!success) {
  538 + throw new ServiceException("重入处理失败, 更新入库组盼头失败");
  539 + }
  540 + }
  541 + // 6. 锁定WMS分配的库位
  542 + boolean success = locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode);
  543 + if (!success) {
  544 + throw new ServiceException("重入处理失败, 更新库位状态失败");
  545 + }
  546 + String originLocationCode = taskHeader.getOriginLocationCode();
  547 + String taskLocationCode = taskHeader.getToLocationCode();
  548 + // 7. 把原来的目标库位记录到初始库位上
  549 + if (StringUtils.isEmpty(originLocationCode)) {
  550 + originLocationCode = taskLocationCode;
  551 + } else {
  552 + originLocationCode = originLocationCode + "," + taskLocationCode;
  553 + }
  554 +
  555 + taskHeader.setToLocationCode(locationCode);
  556 + taskHeader.setExceptionName("重入处理");
  557 + taskHeader.setIsDoubleIn(QuantityConstant.DOUBLE_IN);
  558 + taskHeader.setExceptionState(1);
  559 + taskHeader.setOriginLocationCode(originLocationCode);
  560 + // 8. 更新任务信息
  561 + success = taskHeaderService.updateById(taskHeader);
  562 + if (!success) {
  563 + throw new ServiceException("重入处理失败, 更新任务信息失败");
  564 + }
  565 +
  566 + // 9. 封装返回的数据格式,包括任务号和重新分配的库位号
  567 + TaskReentryEntity taskReentryEntity = new TaskReentryEntity();
  568 + taskReentryEntity.setTaskNo(Integer.parseInt(taskNo));
  569 + taskReentryEntity.setRedirectionLocationCode(toLocationCode);
  570 + return Result.ok(taskReentryEntity);
  571 + }
  572 +
442 } 573 }
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&lt;ContainerMapper, Container @@ -86,8 +86,8 @@ public class ContainerServiceImpl extends ServiceImpl&lt;ContainerMapper, Container
86 boolean success = false; 86 boolean success = false;
87 if (StringUtils.isNotEmpty(locationCode)) { 87 if (StringUtils.isNotEmpty(locationCode)) {
88 success = havaLocationCodeByContainer(locationCode, warehouseCode); 88 success = havaLocationCodeByContainer(locationCode, warehouseCode);
89 - if (!success) {  
90 - throw new ServiceException("取消任务时, 库位表已经存在这个容器号,不能再写入"); 89 + if (success) {
  90 + throw new ServiceException("库位表已经存在这个容器号,不能再写入");
91 } 91 }
92 } 92 }
93 container.setStatus(status); 93 container.setStatus(status);
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java
@@ -79,7 +79,7 @@ public class TaskHeader implements Serializable { @@ -79,7 +79,7 @@ public class TaskHeader implements Serializable {
79 @Excel(name = "是否空出", width = 15, dicCode = "is_or_not") 79 @Excel(name = "是否空出", width = 15, dicCode = "is_or_not")
80 @Dict(dicCode = "is_or_not") 80 @Dict(dicCode = "is_or_not")
81 @ApiModelProperty(value = "是否空出") 81 @ApiModelProperty(value = "是否空出")
82 - private String isEmptyOut; 82 + private Integer isEmptyOut;
83 /** 是否重入 */ 83 /** 是否重入 */
84 @Excel(name = "是否重入", width = 15, dicCode = "is_or_not") 84 @Excel(name = "是否重入", width = 15, dicCode = "is_or_not")
85 @Dict(dicCode = "is_or_not") 85 @Dict(dicCode = "is_or_not")
@@ -126,6 +126,10 @@ public class TaskHeader implements Serializable { @@ -126,6 +126,10 @@ public class TaskHeader implements Serializable {
126 private Integer sequence; 126 private Integer sequence;
127 @ApiModelProperty(value = "顺序数量") 127 @ApiModelProperty(value = "顺序数量")
128 private Integer sequenceNumber; 128 private Integer sequenceNumber;
  129 + @ApiModelProperty(value = "异常原因")
  130 + private String exceptionName;
  131 + @ApiModelProperty(value = "异常状态")
  132 + private Integer exceptionState;
129 /** 备用字段1 */ 133 /** 备用字段1 */
130 @Excel(name = "备用字段1", width = 15) 134 @Excel(name = "备用字段1", width = 15)
131 @ApiModelProperty(value = "备用字段1") 135 @ApiModelProperty(value = "备用字段1")
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&lt;TaskHeaderMapper, TaskHea @@ -1815,8 +1815,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1815 } 1815 }
1816 if (StringUtils.isNotEmpty(fromLocationCode)) { 1816 if (StringUtils.isNotEmpty(fromLocationCode)) {
1817 success = containerService.havaLocationCodeByContainer(fromLocationCode, warehouseCode); 1817 success = containerService.havaLocationCodeByContainer(fromLocationCode, warehouseCode);
1818 - if (!success) {  
1819 - throw new ServiceException("取消任务时, 库位表已经存在这个容器号,不能再写入"); 1818 + if (success) {
  1819 + throw new ServiceException("库位表已经存在这个容器号,不能再写入");
1820 } 1820 }
1821 } 1821 }
1822 container.setLastStatus(QuantityConstant.EMPTY_STRING); 1822 container.setLastStatus(QuantityConstant.EMPTY_STRING);