Commit 0e71c0b9912a1e5c600d48ae6a3a1f52cec9cbe1

Authored by 谭毅彬
1 parent 4433fd16

接口异常错误返回信息优化

Signed-off-by: TanYibin <5491541@qq.com>
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
1 1 package org.jeecg.modules.wms.api.wcs.controller;
2 2  
  3 +import java.net.SocketException;
  4 +
3 5 import javax.annotation.Resource;
4 6 import javax.servlet.http.HttpServletRequest;
5 7  
... ... @@ -59,8 +61,7 @@ public class WcsController extends HuahengBaseController {
59 61 Result result = handleMultiProcess("warecellAllocation", lockKey, new MultiProcessListener() {
60 62 @Override
61 63 public Result<?> doProcess() {
62   - Result result = wcsService.warecellAllocation(warecellDomain);
63   - return result;
  64 + return wcsService.warecellAllocation(warecellDomain);
64 65 }
65 66 });
66 67 return result;
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/LocationAllocationServiceImpl.java
... ... @@ -107,8 +107,6 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
107 107 searchNumber = Integer.parseInt(value);
108 108 }
109 109 String lastString = "ORDER BY layer asc, id asc limit " + searchNumber;
110   - StopWatch stopWatch = new StopWatch();
111   - stopWatch.start("aaa");
112 110 List<Integer> removeRoadWays = new ArrayList<>();
113 111 // 寻找可用巷道,空闲的空库位低于设定值,那么这个巷道就不能用来分配库位
114 112 for (Integer roadWay : roadWays) {
... ... @@ -122,9 +120,6 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
122 120 removeRoadWays.add(roadWay);
123 121 }
124 122 }
125   - stopWatch.stop();
126   - System.out.println("waste aa:" + stopWatch.getLastTaskTimeMillis());
127   - stopWatch.start("bbb");
128 123 roadWays.removeAll(removeRoadWays);
129 124 if (roadWays == null || roadWays.size() == 0) {
130 125 throw new JeecgBootException("分配库位时, 巷道为空");
... ... @@ -147,8 +142,6 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
147 142 }
148 143 }
149 144 locationList.removeAll(removeLocaationList);
150   - stopWatch.stop();
151   - System.out.println("waste bb:" + stopWatch.getLastTaskTimeMillis());
152 145 if (locationList.size() == 0) {
153 146 locationLambda = Wrappers.lambdaQuery();
154 147 locationLambda.eq(Location::getZoneCode, zoneCode).eq(Location::getWarehouseCode, warehouseCode).eq(Location::getRoadWay, roadWay)
... ... @@ -170,8 +163,7 @@ public class LocationAllocationServiceImpl implements LocationAllocationService
170 163 return null;
171 164 }
172 165 Location location = locationList.stream().findFirst().orElse(null);
173   - String locationCode = location.getCode();
174   - return locationCode;
  166 + return location.getCode();
175 167 }
176 168  
177 169 /**
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsService.java
1 1 package org.jeecg.modules.wms.api.wcs.service;
2 2  
  3 +import java.net.SocketException;
  4 +
3 5 import org.jeecg.common.api.vo.Result;
4 6 import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity;
5 7 import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain;
... ... @@ -11,7 +13,8 @@ import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
11 13 */
12 14 public interface WcsService {
13 15  
14   - /** 仓位分配 */
  16 + /** 仓位分配
  17 + * @throws SocketException */
15 18 Result warecellAllocation(WarecellDomain warecellDomain);
16 19  
17 20 /**
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java
1 1 package org.jeecg.modules.wms.api.wcs.service;
2 2  
  3 +import java.net.SocketException;
3 4 import java.util.ArrayList;
4 5 import java.util.List;
5 6 import java.util.stream.Collectors;
... ... @@ -59,43 +60,57 @@ public class WcsServiceImpl implements WcsService {
59 60  
60 61 @Resource
61 62 private IZoneService zoneService;
  63 +
62 64 @Resource
63 65 private ITaskHeaderService taskHeaderService;
  66 +
64 67 @Resource
65 68 private ITaskDetailService taskDetailService;
  69 +
66 70 @Resource
67 71 private IContainerService containerService;
  72 +
68 73 @Resource
69 74 private ILocationTypeService locationTypeService;
  75 +
70 76 @Resource
71 77 private ILocationHighService locationHighService;
  78 +
72 79 @Resource
73 80 private IParameterConfigurationService parameterConfigurationService;
  81 +
74 82 @Resource
75 83 private IReceiptContainerDetailService receiptContainerDetailService;
  84 +
76 85 @Resource
77 86 private IMaterialService materialService;
  87 +
78 88 @Resource
79 89 private IReceiptContainerHeaderService receiptContainerHeaderService;
  90 +
80 91 @Resource
81 92 private LocationAllocationService locationAllocationService;
  93 +
82 94 @Resource
83 95 private ILocationService locationService;
  96 +
84 97 @Resource
85 98 private IAddressService addressService;
  99 +
86 100 @Resource
87 101 private IContainerTypeService containerTypeService;
88 102  
89 103 /**
90 104 * 库位分配
  105 + * @throws SocketException
91 106 */
92 107 @Override
93 108 @Transactional(rollbackFor = Exception.class)
94 109 @OperationLog(bizId = "''", bizType = "'入库单追踪'", tag = "'详情分配库位'", extra = "#extraJsonString",
95   - msg = "'任务ID:' + #warecellDomain.getTaskNo() + ',库位编码:' + #locationCode", condition = "#receiptContainerDetailList.size() > 0", recordReturnValue = true)
96   - @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'分配库位'", extra = "''",
  110 + msg = "'任务ID:' + #warecellDomain.getTaskNo() + ',库位编码:' + #locationCode", condition = "null != #success && #success", recordReturnValue = true)
  111 + @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'分配库位'",
97 112 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode()",
98   - recordReturnValue = true)
  113 + condition = "null != #success && #success", recordReturnValue = true)
99 114 public Result warecellAllocation(WarecellDomain warecellDomain) {
100 115 log.info("开始分配库位");
101 116 String warehouseCode = warecellDomain.getWarehouseCode();
... ... @@ -247,14 +262,15 @@ public class WcsServiceImpl implements WcsService {
247 262 if (!taskHeaderService.updateById(taskHeader)) {
248 263 throw new JeecgBootException("更新任务头表目标库位失败");
249 264 }
250   -
  265 +
251 266 WcsTask wcsTask = new WcsTask();
252 267 wcsTask.setToLocationCode(locationCode);
253 268 wcsTask.setPreTaskNo(String.valueOf(preTaskNo));
254   - LogRecordContext.putVariable("locationCode", locationCode);// 操作日志收集
255   - LogRecordContext.putVariable("receiptContainerDetailList", receiptContainerDetailList);// 操作日志收集
256   - LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(receiptContainerDetailList));// 操作日志收集
257   - LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集
  269 + // 操作日志收集
  270 + LogRecordContext.putVariable("locationCode", locationCode);
  271 + LogRecordContext.putVariable("extraJsonString", JSON.toJSONString(receiptContainerDetailList));
  272 + LogRecordContext.putVariable("taskHeader", taskHeader);
  273 + LogRecordContext.putVariable("success", true);
258 274 log.info("完成分配库位,任务号:" + taskNo + ", 库位号:" + locationCode);
259 275 return Result.OK(wcsTask);
260 276 }
... ... @@ -263,7 +279,7 @@ public class WcsServiceImpl implements WcsService {
263 279 @Transactional(rollbackFor = Exception.class)
264 280 @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'任务下发'", extra = "''",
265 281 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode()",
266   - recordReturnValue = true)
  282 + condition = "null != #success && #success", recordReturnValue = true)
267 283 public Result wcsTaskAssign(TaskHeader taskHeader) {
268 284 if (taskHeader == null) {
269 285 return Result.error("wms任务为空");
... ... @@ -415,6 +431,7 @@ public class WcsServiceImpl implements WcsService {
415 431 }
416 432 }
417 433 LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集
  434 + LogRecordContext.putVariable("success", true);
418 435 return Result.ok("下发任务成功");
419 436 }
420 437  
... ... @@ -500,7 +517,7 @@ public class WcsServiceImpl implements WcsService {
500 517 @Transactional(rollbackFor = Exception.class)
501 518 @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'空出处理'", extra = "''",
502 519 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode() + ',目标出入口:' + #taskHeader.getToPortCode()",
503   - recordReturnValue = true)
  520 + condition = "null != #success && #success", recordReturnValue = true)
504 521 public Result emptyOutHandle(String taskNo) {
505 522 if (StringUtils.isEmpty(taskNo)) {
506 523 return Result.error("任务号为空");
... ... @@ -525,7 +542,9 @@ public class WcsServiceImpl implements WcsService {
525 542 if (!success) {
526 543 return Result.error("修改任务失败,空出处理失败");
527 544 }
528   - LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集
  545 + // 操作日志收集
  546 + LogRecordContext.putVariable("taskHeader", taskHeader);
  547 + LogRecordContext.putVariable("success", true);
529 548 return Result.ok("空出处理成功");
530 549 }
531 550  
... ... @@ -533,7 +552,7 @@ public class WcsServiceImpl implements WcsService {
533 552 @Transactional(rollbackFor = Exception.class)
534 553 @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'重入处理'", extra = "''",
535 554 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode() + ',目标出入口:' + #taskHeader.getToPortCode()",
536   - recordReturnValue = true)
  555 + condition = "null != #success && #success", recordReturnValue = true)
537 556 public Result reentryHandle(String taskNo) {
538 557 // 1、判断非空字段
539 558 if (StringUtils.isEmpty(taskNo)) {
... ... @@ -630,7 +649,9 @@ public class WcsServiceImpl implements WcsService {
630 649 TaskReentryEntity taskReentryEntity = new TaskReentryEntity();
631 650 taskReentryEntity.setTaskNo(Integer.parseInt(taskNo));
632 651 taskReentryEntity.setRedirectionLocationCode(locationCode);
633   - LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集
  652 + // 操作日志收集
  653 + LogRecordContext.putVariable("taskHeader", taskHeader);
  654 + LogRecordContext.putVariable("success", true);
634 655 return Result.ok(taskReentryEntity);
635 656 }
636 657  
... ... @@ -638,7 +659,7 @@ public class WcsServiceImpl implements WcsService {
638 659 @Transactional(rollbackFor = Exception.class)
639 660 @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'取货错处理'", extra = "''",
640 661 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode() + ',目标出入口:' + #taskHeader.getToPortCode()",
641   - recordReturnValue = true)
  662 + condition = "null != #success && #success", recordReturnValue = true)
642 663 public Result pickupErrorHandle(String taskNo) {
643 664 // 1、判断非空字段
644 665 if (StringUtils.isEmpty(taskNo)) {
... ... @@ -662,6 +683,7 @@ public class WcsServiceImpl implements WcsService {
662 683 return Result.error("取货错处理失败,更新任务失败");
663 684 }
664 685 LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集
  686 + LogRecordContext.putVariable("success", true);
665 687 return Result.ok("取货错处理成功");
666 688 }
667 689  
... ... @@ -669,7 +691,7 @@ public class WcsServiceImpl implements WcsService {
669 691 @Transactional(rollbackFor = Exception.class)
670 692 @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'到达站台'", extra = "''",
671 693 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode() + ',目标出入口:' + #taskHeader.getToPortCode()",
672   - recordReturnValue = true)
  694 + condition = "null != #success && #success", recordReturnValue = true)
673 695 public Result arrivedNotice(String taskNo, String port) {
674 696 TaskHeader taskHeader = taskHeaderService.getById(taskNo);
675 697 if (taskHeader == null) {
... ... @@ -685,7 +707,9 @@ public class WcsServiceImpl implements WcsService {
685 707 if (!result) {
686 708 return Result.error("更新到达站台失败");
687 709 }
688   - LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集
  710 + // 操作日志收集
  711 + LogRecordContext.putVariable("taskHeader", taskHeader);
  712 + LogRecordContext.putVariable("success", true);
689 713 return Result.ok("更新到达站台成功");
690 714 }
691 715  
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/framework/controller/HuahengBaseController.java
... ... @@ -5,6 +5,7 @@ import java.util.concurrent.TimeUnit;
5 5 import javax.annotation.Nonnull;
6 6  
7 7 import org.jeecg.common.api.vo.Result;
  8 +import org.jeecg.common.exception.JeecgBootException;
8 9 import org.jeecg.utils.support.RedissonDistributedLocker;
9 10 import org.springframework.beans.factory.annotation.Autowired;
10 11  
... ... @@ -73,7 +74,7 @@ public class HuahengBaseController {
73 74 result = multiProcessListener.doProcess();
74 75 } catch (Exception e) {
75 76 log.error("[{}] 执行分布式事务失败 lockKey = {},errorMessage = {}", taskName, fullLockKey, ExceptionUtil.getMessage(e), e);
76   - throw ExceptionUtil.convertFromOrSuppressedThrowable(e, RuntimeException.class);
  77 + return Result.error(ExceptionUtil.getMessage(e));
77 78 } finally {
78 79 redissonDistributedLocker.unlock(fullLockKey);
79 80 final long finishTime = SystemClock.now();
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... ... @@ -196,8 +196,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
196 196 return Result.error("创建移库任务时,起始库位:" + fromLocationCode + "未找到");
197 197 }
198 198 Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode);
199   - if (fromLocation == null) {
200   - return Result.error("创建移库任务时,起始库位:" + fromLocationCode + "未找到");
  199 + if (toLocation == null) {
  200 + return Result.error("创建移库任务时,目标库位:" + toLocation + "未找到");
201 201 }
202 202 String containerCode = fromLocation.getContainerCode();
203 203 // 这里增加组盘校验,如果此托盘存在未完成的组盘数据,则不能移库
... ... @@ -979,11 +979,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
979 979 @Transactional(rollbackFor = Exception.class)
980 980 @OperationLog(bizId = "''", bizType = "'任务追踪'", tag = "'入库任务完成'", extra = "#extraJsonString1",
981 981 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode()",
982   - condition = "#taskDetailList.size() > 0", recordReturnValue = true)
  982 + condition = "null != #success && #success", recordReturnValue = true)
983 983 @OperationLog(bizId = "''", bizType = "'入库单追踪'", tag = "'入库任务完成'", extra = "#extraJsonString1",
984 984 msg = "'任务ID:' + #taskHeader.getId() + ',库位编码:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode()",
985   - condition = "#taskDetailList.size() > 0", recordReturnValue = true)
986   - @OperationLog(bizId = "''", bizType = "'入库单追踪'", tag = "'详情入库完成'", extra = "#extraJsonString2", msg = "''", condition = "#receiptDetaiList.size() > 0",
  985 + condition = "null != #success && #success", recordReturnValue = true)
  986 + @OperationLog(bizId = "''", bizType = "'入库单追踪'", tag = "'详情入库完成'", extra = "#extraJsonString2", msg = "''", condition = "null != #success && #success",
987 987 recordReturnValue = true)
988 988 public Result completeReceiptTask(TaskHeader taskHeader) {
989 989 if (taskHeader == null) {
... ... @@ -1161,11 +1161,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1161 1161 }
1162 1162 receiptDetaiList = receiptDetaiList.stream().filter(t -> t.getStatus().equals(QuantityConstant.RECEIPT_HEADER_COMPLETED)).collect(Collectors.toList());
1163 1163 LogRecordContext.putVariable("taskHeader", taskHeader);
1164   - LogRecordContext.putVariable("taskDetailList", taskDetailList);
1165 1164 LogRecordContext.putVariable("extraJsonString1", JSON.toJSONString(taskDetailList));
1166   - LogRecordContext.putVariable("receiptDetaiList", receiptDetaiList);
1167 1165 LogRecordContext.putVariable("extraJsonString2", JSON.toJSONString(receiptDetaiList));
1168   - log.info("完成入库任务, 任务号" + taskHeader.getId());
  1166 + LogRecordContext.putVariable("success", true);// 操作日志收集
  1167 + log.info("完成入库任务, 任务号:" + taskHeader.getId());
1169 1168 return Result.ok("完成入库任务");
1170 1169 }
1171 1170  
... ... @@ -1178,11 +1177,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1178 1177 @Transactional(rollbackFor = Exception.class)
1179 1178 @OperationLog(bizId = "''", bizType = "'任务追踪'", tag = "'出库任务完成'", extra = "#extraJsonString1",
1180 1179 msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode()",
1181   - condition = "#taskDetailList.size() > 0", recordReturnValue = true)
  1180 + condition = "null != #success && #success", recordReturnValue = true)
1182 1181 @OperationLog(bizId = "''", bizType = "'出库单追踪'", tag = "'出库任务完成'", extra = "#extraJsonString1",
1183 1182 msg = "'任务ID:' + #taskHeader.getId() + ',库位编码:' + #taskHeader.getFromLocationCode() + ',容器编码:' + #taskHeader.getContainerCode() + ',目标出入口:' + #taskHeader.getToPortCode()",
1184   - recordReturnValue = true)
1185   - @OperationLog(bizId = "''", bizType = "'出库单追踪'", tag = "'详情出库完成'", extra = "#extraJsonString2", msg = "''", condition = "#shipmentDetailList.size() > 0",
  1183 + condition = "null != #success && #success", recordReturnValue = true)
  1184 + @OperationLog(bizId = "''", bizType = "'出库单追踪'", tag = "'详情出库完成'", extra = "#extraJsonString2", msg = "''", condition = "null != #success && #success",
1186 1185 recordReturnValue = true)
1187 1186 public Result completeShipmentTask(TaskHeader taskHeader) {
1188 1187 if (taskHeader == null) {
... ... @@ -1193,7 +1192,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1193 1192 String fromLocationCode = taskHeader.getFromLocationCode();
1194 1193 String toLocationCode = taskHeader.getToLocationCode();
1195 1194 String containerCode = taskHeader.getContainerCode();
1196   - String zoneCode = taskHeader.getZoneCode();
1197 1195 int taskType = taskHeader.getTaskType();
1198 1196 List<TaskDetail> taskDetailList = taskDetailService.getTaskDetailListByTaskId(taskHeader.getId());
1199 1197 boolean success = false;
... ... @@ -1383,10 +1381,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
1383 1381 // 操作记录添加
1384 1382 shipmentDetailList = shipmentDetailList.stream().filter(t -> t.getStatus().equals(QuantityConstant.SHIPMENT_HEADER_COMPLETED)).collect(Collectors.toList());
1385 1383 LogRecordContext.putVariable("taskHeader", taskHeader);
1386   - LogRecordContext.putVariable("taskDetailList", taskDetailList); // 操作记录添加
1387 1384 LogRecordContext.putVariable("extraJsonString1", JSON.toJSONString(taskDetailList));
1388   - LogRecordContext.putVariable("shipmentDetailList", shipmentDetailList);
1389 1385 LogRecordContext.putVariable("extraJsonString2", JSON.toJSONString(shipmentDetailList));
  1386 + LogRecordContext.putVariable("success", true);
1390 1387 log.info("完成出库任务,任务号:" + taskHeader.getId());
1391 1388 return Result.ok("完成出库任务");
1392 1389 }
... ...