Commit 2b401af48475bebbe57daa7e78d59aabf60b572e
1 parent
4e33ccc8
优化代码
Showing
8 changed files
with
103 additions
and
55 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/erp/controller/ErpController.java
... | ... | @@ -4,19 +4,11 @@ import javax.annotation.Resource; |
4 | 4 | import javax.servlet.http.HttpServletRequest; |
5 | 5 | |
6 | 6 | import org.jeecg.common.api.vo.Result; |
7 | -import org.jeecg.modules.wms.api.erp.entity.ErpCancel; | |
8 | -import org.jeecg.modules.wms.api.erp.entity.ErpMaterial; | |
9 | -import org.jeecg.modules.wms.api.erp.entity.ErpReceipt; | |
10 | -import org.jeecg.modules.wms.api.erp.entity.ErpShipment; | |
11 | -import org.jeecg.modules.wms.api.erp.entity.InventoryQueryParam; | |
7 | +import org.jeecg.modules.wms.api.erp.entity.*; | |
12 | 8 | import org.jeecg.modules.wms.api.erp.service.IErpService; |
13 | 9 | import org.jeecg.modules.wms.framework.controller.HuahengBaseController; |
14 | 10 | import org.jeecg.utils.support.ApiLogger; |
15 | -import org.springframework.web.bind.annotation.PostMapping; | |
16 | -import org.springframework.web.bind.annotation.RequestBody; | |
17 | -import org.springframework.web.bind.annotation.RequestMapping; | |
18 | -import org.springframework.web.bind.annotation.ResponseBody; | |
19 | -import org.springframework.web.bind.annotation.RestController; | |
11 | +import org.springframework.web.bind.annotation.*; | |
20 | 12 | |
21 | 13 | import io.swagger.annotations.Api; |
22 | 14 | import io.swagger.annotations.ApiOperation; |
... | ... | @@ -32,6 +24,14 @@ public class ErpController extends HuahengBaseController { |
32 | 24 | @Resource |
33 | 25 | private IErpService erpService; |
34 | 26 | |
27 | + @PostMapping("/addMaterial") | |
28 | + @ResponseBody | |
29 | + @ApiOperation("增加物料") | |
30 | + @ApiLogger(apiName = "增加物料", from = "ERP") | |
31 | + public Result addMaterial(@RequestBody ErpMaterial erpMaterial) { | |
32 | + return erpService.addMaterial(erpMaterial); | |
33 | + } | |
34 | + | |
35 | 35 | @PostMapping("/receipt") |
36 | 36 | @ResponseBody |
37 | 37 | @ApiOperation("入库单下发") |
... | ... | @@ -77,12 +77,4 @@ public class ErpController extends HuahengBaseController { |
77 | 77 | return result; |
78 | 78 | } |
79 | 79 | |
80 | - @PostMapping("/addMaterial") | |
81 | - @ResponseBody | |
82 | - @ApiOperation("增加物料") | |
83 | - @ApiLogger(apiName = "增加物料", from = "ERP") | |
84 | - public Result addMaterial(@RequestBody ErpMaterial erpMaterial) { | |
85 | - return erpService.addMaterial(erpMaterial); | |
86 | - } | |
87 | - | |
88 | 80 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/mobile/entity/CallBoxBean.java
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
... | ... | @@ -171,7 +171,13 @@ public class WcsController extends HuahengBaseController { |
171 | 171 | @ApiOperation("设置物料信息") |
172 | 172 | @ApiLogger(apiName = "WCS设置物料信息", from = "WCS") |
173 | 173 | public Result setMaterialInfo(@RequestBody MaterialInfoEntity materialInfoEntity) { |
174 | - Result result = wcsService.setMaterialInfo(materialInfoEntity); | |
174 | + Result result = handleMultiProcess("setMaterialInfo", new MultiProcessListener() { | |
175 | + @Override | |
176 | + public Result<?> doProcess() { | |
177 | + Result result = wcsService.setMaterialInfo(materialInfoEntity); | |
178 | + return result; | |
179 | + } | |
180 | + }); | |
175 | 181 | return result; |
176 | 182 | } |
177 | 183 | |
... | ... | @@ -184,7 +190,13 @@ public class WcsController extends HuahengBaseController { |
184 | 190 | public Result arrivedNotice(@RequestBody ArriveEntity arriveEntity) { |
185 | 191 | String taskNo = arriveEntity.getTaskNo(); |
186 | 192 | String port = arriveEntity.getPort(); |
187 | - Result result = wcsService.arrivedNotice(taskNo, port); | |
193 | + Result result = handleMultiProcess("arrivedNotice", new MultiProcessListener() { | |
194 | + @Override | |
195 | + public Result<?> doProcess() { | |
196 | + Result result = wcsService.arrivedNotice(taskNo, port); | |
197 | + return result; | |
198 | + } | |
199 | + }); | |
188 | 200 | return result; |
189 | 201 | } |
190 | 202 | |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java
... | ... | @@ -2,6 +2,7 @@ package org.jeecg.modules.wms.api.wcs.service; |
2 | 2 | |
3 | 3 | import java.net.SocketException; |
4 | 4 | import java.util.ArrayList; |
5 | +import java.util.Date; | |
5 | 6 | import java.util.List; |
6 | 7 | import java.util.stream.Collectors; |
7 | 8 | |
... | ... | @@ -257,6 +258,7 @@ public class WcsServiceImpl implements WcsService { |
257 | 258 | taskHeader.setZoneCode(location.getZoneCode()); |
258 | 259 | taskHeader.setRoadWay(location.getRoadWay()); |
259 | 260 | taskHeader.setPreTaskNo(preTaskNo); |
261 | + taskHeader.setAllocationTime(new Date()); | |
260 | 262 | taskHeader.setWeight(Integer.parseInt(warecellDomain.getWeight())); |
261 | 263 | taskHeader.setToLocationCode(locationCode); |
262 | 264 | if (!taskHeaderService.updateById(taskHeader)) { |
... | ... | @@ -703,6 +705,10 @@ public class WcsServiceImpl implements WcsService { |
703 | 705 | if (status == QuantityConstant.TASK_STATUS_COMPLETED) { |
704 | 706 | return Result.error("任务已经完成taskNo:" + taskNo); |
705 | 707 | } |
708 | + int taskId = taskHeader.getId(); | |
709 | + taskHeader = new TaskHeader(); | |
710 | + taskHeader.setId(taskId); | |
711 | + taskHeader.setArrivalTime(new Date()); | |
706 | 712 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_ARRIVED_STATION); |
707 | 713 | taskHeader.setToPortCode(port); |
708 | 714 | boolean result = taskHeaderService.updateById(taskHeader); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/IInventoryDetailService.java
... | ... | @@ -50,4 +50,5 @@ public interface IInventoryDetailService extends IService<InventoryDetail> { |
50 | 50 | |
51 | 51 | boolean updateQtyAndTaskQtyAndLocationCode(BigDecimal qty, BigDecimal taskQty, String locationCode, int id); |
52 | 52 | |
53 | + boolean updateBatchLocationCodeById(List<InventoryDetail> inventoryDetailList); | |
53 | 54 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/inventory/inventoryHeader/service/impl/InventoryDetailServiceImpl.java
... | ... | @@ -2,6 +2,7 @@ package org.jeecg.modules.wms.inventory.inventoryHeader.service.impl; |
2 | 2 | |
3 | 3 | import java.math.BigDecimal; |
4 | 4 | import java.math.RoundingMode; |
5 | +import java.util.ArrayList; | |
5 | 6 | import java.util.List; |
6 | 7 | import java.util.Map; |
7 | 8 | import java.util.function.Function; |
... | ... | @@ -131,6 +132,19 @@ public class InventoryDetailServiceImpl extends ServiceImpl<InventoryDetailMappe |
131 | 132 | return success; |
132 | 133 | } |
133 | 134 | |
135 | + @Override | |
136 | + public boolean updateBatchLocationCodeById(List<InventoryDetail> inventoryDetailList) { | |
137 | + List<InventoryDetail> inventoryDetailList1 = new ArrayList<>(); | |
138 | + for (InventoryDetail inventoryDetail : inventoryDetailList) { | |
139 | + InventoryDetail inventoryDetail1 = new InventoryDetail(); | |
140 | + inventoryDetail1.setId(inventoryDetail.getId()); | |
141 | + inventoryDetail1.setLocationCode(inventoryDetail.getLocationCode()); | |
142 | + inventoryDetailList1.add(inventoryDetail1); | |
143 | + } | |
144 | + boolean success = this.updateBatchById(inventoryDetailList1); | |
145 | + return success; | |
146 | + } | |
147 | + | |
134 | 148 | /** |
135 | 149 | * 计算库存明细托盘填充度 |
136 | 150 | * @author TanYibin |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskHeader.java
... | ... | @@ -168,4 +168,16 @@ public class TaskHeader implements Serializable { |
168 | 168 | /** 更新日期 */ |
169 | 169 | @ApiModelProperty(value = "更新日期") |
170 | 170 | private Date updateTime; |
171 | + /** 执行时间(下发任务时间) */ | |
172 | + @ApiModelProperty(value = "执行时间") | |
173 | + private Date executeTime; | |
174 | + /** 分配时间 */ | |
175 | + @ApiModelProperty(value = "分配时间") | |
176 | + private Date allocationTime; | |
177 | + /** 到达时间(到达拣选台时间) */ | |
178 | + @ApiModelProperty(value = "到达时间") | |
179 | + private Date arrivalTime; | |
180 | + /** 完成时间(完成任务时间) */ | |
181 | + @ApiModelProperty(value = "完成时间") | |
182 | + private Date completeTime; | |
171 | 183 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... | ... | @@ -62,6 +62,7 @@ import org.jeecg.utils.StringUtils; |
62 | 62 | import org.jeecg.utils.constant.QuantityConstant; |
63 | 63 | import org.springframework.beans.factory.annotation.Autowired; |
64 | 64 | import org.springframework.stereotype.Service; |
65 | +import org.springframework.transaction.annotation.Propagation; | |
65 | 66 | import org.springframework.transaction.annotation.Transactional; |
66 | 67 | |
67 | 68 | import com.alibaba.fastjson.JSON; |
... | ... | @@ -867,7 +868,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
867 | 868 | } |
868 | 869 | |
869 | 870 | @Override |
870 | - @Transactional(rollbackFor = Exception.class) | |
871 | + @Transactional(rollbackFor = Exception.class, propagation = Propagation.REQUIRES_NEW) | |
871 | 872 | public Result sendTaskToWcs(Integer taskId) { |
872 | 873 | TaskHeader taskHeader = taskHeaderService.getById(taskId); |
873 | 874 | if (taskHeader == null) { |
... | ... | @@ -1010,9 +1011,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1010 | 1011 | if (taskHeader.getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) { |
1011 | 1012 | return Result.ok("入库任务(" + taskHeader.getId() + ")已经是完成的!"); |
1012 | 1013 | } |
1013 | - if (taskDetailList.isEmpty()) { | |
1014 | - throw new JeecgBootException("完成入库任务时, 入库任务明细为空"); | |
1015 | - } | |
1014 | +// if (taskDetailList.isEmpty()) { | |
1015 | +// throw new JeecgBootException("完成入库任务时, 入库任务明细为空"); | |
1016 | +// } | |
1016 | 1017 | Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); |
1017 | 1018 | if (toLocation == null) { |
1018 | 1019 | throw new JeecgBootException("完成入库任务时,没有找到目的库位"); |
... | ... | @@ -1117,17 +1118,33 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1117 | 1118 | inventoryTransaction.setQty(receiptQty); |
1118 | 1119 | inventoryTransactionList.add(inventoryTransaction); |
1119 | 1120 | } |
1120 | - success = receiptContainerHeaderService.updateStatusById(QuantityConstant.RECEIPT_CONTAINER_FINISHED, taskHeader.getReceiptContainerHeaderId()); | |
1121 | - if (!success) { | |
1122 | - throw new JeecgBootException("完成入库任务时,更新入库组盘头表状态失败"); | |
1123 | - } | |
1124 | - success = inventoryDetailService.saveBatch(inventoryDetailList); | |
1125 | - if (!success) { | |
1126 | - throw new JeecgBootException("完成入库任务时,保存库存详情失败"); | |
1127 | - } | |
1128 | - success = inventoryTransactionService.saveBatch(inventoryTransactionList); | |
1129 | - if (!success) { | |
1130 | - throw new JeecgBootException("完成入库任务时,保存库存交易失败"); | |
1121 | + | |
1122 | + if (!taskDetailList.isEmpty()) { | |
1123 | + success = receiptContainerHeaderService.updateStatusById(QuantityConstant.RECEIPT_CONTAINER_FINISHED, taskHeader.getReceiptContainerHeaderId()); | |
1124 | + if (!success) { | |
1125 | + throw new JeecgBootException("完成入库任务时,更新入库组盘头表状态失败"); | |
1126 | + } | |
1127 | + success = inventoryDetailService.saveBatch(inventoryDetailList); | |
1128 | + if (!success) { | |
1129 | + throw new JeecgBootException("完成入库任务时,保存库存详情失败"); | |
1130 | + } | |
1131 | + success = inventoryTransactionService.saveBatch(inventoryTransactionList); | |
1132 | + if (!success) { | |
1133 | + throw new JeecgBootException("完成入库任务时,保存库存交易失败"); | |
1134 | + } | |
1135 | + if (!taskHeaderService.combineInventoryDetail(taskHeader)) { | |
1136 | + throw new JeecgBootException("合并入库库存失败"); | |
1137 | + } | |
1138 | + if (!receiptDetailService.updateBatchById(receiptDetaiList)) { | |
1139 | + throw new JeecgBootException("完成入库任务时,更新入库单详情失败"); | |
1140 | + } | |
1141 | + List<Integer> receiptIdList = receiptDetaiList.stream().map(ReceiptDetail::getReceiptId).distinct().collect(Collectors.toList()); | |
1142 | + for (Integer receiptId : receiptIdList) { | |
1143 | + success = receiptHeaderService.updateReceiptHeaderStatus(receiptId); | |
1144 | + if (!success) { | |
1145 | + throw new JeecgBootException("完成入库任务时,更新入库单头失败"); | |
1146 | + } | |
1147 | + } | |
1131 | 1148 | } |
1132 | 1149 | |
1133 | 1150 | Result result = taskHeaderService.completeTaskUnLockContainerAndLocation(taskHeader.getContainerFillStatus(), taskType, containerCode, fromLocationCode, |
... | ... | @@ -1135,25 +1152,12 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1135 | 1152 | if (!result.isSuccess()) { |
1136 | 1153 | throw new JeecgBootException(result.getMessage()); |
1137 | 1154 | } |
1138 | - if (!taskHeaderService.combineInventoryDetail(taskHeader)) { | |
1139 | - throw new JeecgBootException("合并入库库存失败"); | |
1140 | - } | |
1141 | - if (!receiptDetailService.updateBatchById(receiptDetaiList)) { | |
1142 | - throw new JeecgBootException("完成入库任务时,更新入库单详情失败"); | |
1143 | - } | |
1144 | - List<Integer> receiptIdList = receiptDetaiList.stream().map(ReceiptDetail::getReceiptId).distinct().collect(Collectors.toList()); | |
1145 | - for (Integer receiptId : receiptIdList) { | |
1146 | - success = receiptHeaderService.updateReceiptHeaderStatus(receiptId); | |
1147 | - if (!success) { | |
1148 | - throw new JeecgBootException("完成入库任务时,更新入库单头失败"); | |
1149 | - } | |
1150 | - } | |
1151 | 1155 | if (!inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode)) { |
1152 | 1156 | throw new JeecgBootException("完成入库任务时,更新托盘状态失败"); |
1153 | 1157 | } |
1154 | 1158 | success = taskHeaderService.updateStatusById(QuantityConstant.TASK_STATUS_COMPLETED, taskHeader.getId()); |
1155 | 1159 | if (!success) { |
1156 | - throw new JeecgBootException("完成出库任务,保存任务头失败"); | |
1160 | + throw new JeecgBootException("完成入库任务时,保存任务头失败"); | |
1157 | 1161 | } |
1158 | 1162 | receiptDetaiList = receiptDetaiList.stream().filter(t -> t.getStatus().equals(QuantityConstant.RECEIPT_HEADER_COMPLETED)).collect(Collectors.toList()); |
1159 | 1163 | LogRecordContext.putVariable("taskHeader", taskHeader); |
... | ... | @@ -1194,9 +1198,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1194 | 1198 | if (taskHeader.getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) { |
1195 | 1199 | return Result.ok("完成出库任务,(" + taskHeader.getId() + ")任务已经是完成的!"); |
1196 | 1200 | } |
1197 | - if (taskDetailList.isEmpty()) { | |
1198 | - return Result.error("完成出库任务,任务明细为空"); | |
1199 | - } | |
1201 | +// if (taskDetailList.isEmpty()) { | |
1202 | +// return Result.error("完成出库任务,任务明细为空"); | |
1203 | +// } | |
1200 | 1204 | if (StringUtils.isEmpty(fromLocationCode)) { |
1201 | 1205 | return Result.error("完成出库任务" + taskHeader.getId() + "没有起始库位,执行中止"); |
1202 | 1206 | } |
... | ... | @@ -2143,14 +2147,13 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
2143 | 2147 | .eq(InventoryHeader::getLocationCode, fromLocationCode); |
2144 | 2148 | InventoryHeader inventoryHeader = inventoryHeaderService.getOne(inventoryHeaderLambdaUpdateWrapper); |
2145 | 2149 | if (inventoryHeader != null) { |
2146 | - inventoryHeader.setLocationCode(toLocationCode); | |
2147 | - success = inventoryHeaderService.updateById(inventoryHeader); | |
2150 | + success = inventoryHeaderService.updateLocationCodeById(toLocationCode, inventoryHeader.getId()); | |
2148 | 2151 | if (!success) { |
2149 | 2152 | throw new JeecgBootException("完成移库任务时, 更新库存头失败"); |
2150 | 2153 | } |
2151 | 2154 | } |
2152 | 2155 | if (inventoryDetailList.size() != 0) { |
2153 | - success = inventoryDetailService.updateBatchById(inventoryDetailList); | |
2156 | + success = inventoryDetailService.updateBatchLocationCodeById(inventoryDetailList); | |
2154 | 2157 | if (!success) { |
2155 | 2158 | throw new JeecgBootException("完成移库任务时, 更新库存详情失败"); |
2156 | 2159 | } |
... | ... | @@ -2431,6 +2434,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
2431 | 2434 | TaskHeader taskHeader = new TaskHeader(); |
2432 | 2435 | taskHeader.setId(id); |
2433 | 2436 | taskHeader.setStatus(status); |
2437 | + if (status == QuantityConstant.TASK_STATUS_COMPLETED) { | |
2438 | + taskHeader.setCompleteTime(new Date()); | |
2439 | + } else if (status == QuantityConstant.TASK_STATUS_RELEASE) { | |
2440 | + taskHeader.setExecuteTime(new Date()); | |
2441 | + } | |
2434 | 2442 | boolean success = taskHeaderService.updateById(taskHeader); |
2435 | 2443 | return success; |
2436 | 2444 | } |
... | ... |