Commit bf74d4a12912b309b4efe199d174a3e6b45304f7
1 parent
4a0ebc6b
把生成任务的锁定容器和库位,集中到一起
Showing
10 changed files
with
356 additions
and
243 deletions
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/controller/WcsController.java
... | ... | @@ -5,22 +5,14 @@ import javax.servlet.http.HttpServletRequest; |
5 | 5 | |
6 | 6 | import org.jeecg.common.api.vo.Result; |
7 | 7 | import org.jeecg.common.aspect.annotation.AutoLog; |
8 | -import org.jeecg.modules.wms.api.wcs.entity.ArriveEntity; | |
9 | -import org.jeecg.modules.wms.api.wcs.entity.ManyEmptyDomain; | |
10 | -import org.jeecg.modules.wms.api.wcs.entity.ManyEmptyOutDomain; | |
11 | -import org.jeecg.modules.wms.api.wcs.entity.MaterialInfoEntity; | |
12 | -import org.jeecg.modules.wms.api.wcs.entity.TaskEntity; | |
13 | -import org.jeecg.modules.wms.api.wcs.entity.WarecellDomain; | |
8 | +import org.jeecg.modules.wms.api.wcs.entity.*; | |
14 | 9 | import org.jeecg.modules.wms.api.wcs.service.WcsService; |
15 | 10 | import org.jeecg.modules.wms.framework.controller.HuahengBaseController; |
16 | 11 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; |
17 | 12 | import org.jeecg.utils.StringUtils; |
13 | +import org.jeecg.utils.interceptor.AccessLimit; | |
18 | 14 | import org.jeecg.utils.support.ApiLogger; |
19 | -import org.springframework.web.bind.annotation.PostMapping; | |
20 | -import org.springframework.web.bind.annotation.RequestBody; | |
21 | -import org.springframework.web.bind.annotation.RequestMapping; | |
22 | -import org.springframework.web.bind.annotation.ResponseBody; | |
23 | -import org.springframework.web.bind.annotation.RestController; | |
15 | +import org.springframework.web.bind.annotation.*; | |
24 | 16 | |
25 | 17 | import io.swagger.annotations.Api; |
26 | 18 | import io.swagger.annotations.ApiOperation; |
... | ... | @@ -46,6 +38,7 @@ public class WcsController extends HuahengBaseController { |
46 | 38 | @ResponseBody |
47 | 39 | @ApiOperation("仓位分配") |
48 | 40 | @ApiLogger(apiName = "仓位分配", from = "WCS") |
41 | + @AccessLimit(seconds = 5, maxCount = 5) | |
49 | 42 | public Result warecellAllocation(@RequestBody WarecellDomain warecellDomain, HttpServletRequest req) { |
50 | 43 | String warehouseCode = warecellDomain.getWarehouseCode(); |
51 | 44 | String taskNo = warecellDomain.getTaskNo(); |
... | ... | @@ -82,6 +75,7 @@ public class WcsController extends HuahengBaseController { |
82 | 75 | @ResponseBody |
83 | 76 | @ApiOperation("申请空托盘组入库") |
84 | 77 | @ApiLogger(apiName = "申请空托盘组入库", from = "WCS") |
78 | + @AccessLimit(seconds = 5, maxCount = 5) | |
85 | 79 | public Result manyEmptyIn(@RequestBody ManyEmptyDomain manyEmptyDomain) { |
86 | 80 | String containerCode = manyEmptyDomain.getContainerCode(); |
87 | 81 | String warehouseCode = manyEmptyDomain.getWarehouseCode(); |
... | ... | @@ -117,6 +111,7 @@ public class WcsController extends HuahengBaseController { |
117 | 111 | @ResponseBody |
118 | 112 | @ApiOperation("申请空托盘组出库") |
119 | 113 | @ApiLogger(apiName = "申请空托盘组出库", from = "WCS") |
114 | + @AccessLimit(seconds = 5, maxCount = 5) | |
120 | 115 | public Result manyEmptyOut(@RequestBody ManyEmptyOutDomain manyEmptyOutDomain) { |
121 | 116 | String toPortCode = manyEmptyOutDomain.getPort(); |
122 | 117 | String warehouseCode = manyEmptyOutDomain.getWarehouseCode(); |
... | ... | @@ -150,6 +145,7 @@ public class WcsController extends HuahengBaseController { |
150 | 145 | @ResponseBody |
151 | 146 | @ApiOperation("WCS任务完成") |
152 | 147 | @ApiLogger(apiName = "WCS任务完成", from = "WCS") |
148 | + @AccessLimit(seconds = 5, maxCount = 5) | |
153 | 149 | public Result completeTaskByWMS(@RequestBody TaskEntity taskEntity) { |
154 | 150 | String taskNo = taskEntity.getTaskNo(); |
155 | 151 | String lockKey = taskNo; |
... | ... | @@ -185,6 +181,7 @@ public class WcsController extends HuahengBaseController { |
185 | 181 | @ResponseBody |
186 | 182 | @ApiOperation("到达拣选台") |
187 | 183 | @ApiLogger(apiName = "到达拣选台", from = "WCS") |
184 | + @AccessLimit(seconds = 5, maxCount = 5) | |
188 | 185 | public Result arrivedNotice(@RequestBody ArriveEntity arriveEntity) { |
189 | 186 | String taskNo = arriveEntity.getTaskNo(); |
190 | 187 | String port = arriveEntity.getPort(); |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/entity/WcsTask.java
1 | 1 | package org.jeecg.modules.wms.api.wcs.entity; |
2 | 2 | |
3 | +import org.jeecg.utils.constant.QuantityConstant; | |
4 | + | |
3 | 5 | import io.swagger.annotations.ApiModelProperty; |
4 | 6 | import lombok.Data; |
5 | 7 | |
... | ... | @@ -92,6 +94,11 @@ public class WcsTask { |
92 | 94 | private String zoneCode; |
93 | 95 | |
94 | 96 | /** |
97 | + * 平台 | |
98 | + */ | |
99 | + @ApiModelProperty(value = "平台") | |
100 | + private String platform = QuantityConstant.PLATFORM_WMS; | |
101 | + /** | |
95 | 102 | * 备注 |
96 | 103 | */ |
97 | 104 | @ApiModelProperty(value = "备注") |
... | ... | @@ -114,4 +121,5 @@ public class WcsTask { |
114 | 121 | */ |
115 | 122 | @ApiModelProperty(value = "顺序数量") |
116 | 123 | private int sequenceNumber; |
124 | + | |
117 | 125 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/api/wcs/service/WcsServiceImpl.java
... | ... | @@ -39,7 +39,6 @@ import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; |
39 | 39 | import org.jeecg.utils.OkHttpUtils; |
40 | 40 | import org.jeecg.utils.StringUtils; |
41 | 41 | import org.jeecg.utils.constant.QuantityConstant; |
42 | -import org.jeecg.utils.support.ApiLogger; | |
43 | 42 | import org.springframework.stereotype.Service; |
44 | 43 | import org.springframework.transaction.annotation.Transactional; |
45 | 44 | |
... | ... | @@ -262,7 +261,6 @@ public class WcsServiceImpl implements WcsService { |
262 | 261 | |
263 | 262 | @Override |
264 | 263 | @Transactional(rollbackFor = Exception.class) |
265 | - @ApiLogger(apiName = "任务下发", from = "WCS") | |
266 | 264 | @OperationLog(bizId = "#taskHeader.getId()", bizType = "'任务追踪'", tag = "'任务下发'", extra = "''", |
267 | 265 | msg = "'任务类型:' + #taskHeader.getTaskType() + ',起始库位:' + #taskHeader.getFromLocationCode() + ',目标库位:' + #taskHeader.getToLocationCode() + ',容器编码:' + #taskHeader.getContainerCode()", |
268 | 266 | recordReturnValue = true) |
... | ... | @@ -471,7 +469,6 @@ public class WcsServiceImpl implements WcsService { |
471 | 469 | wcsTask.setTaskType(800); |
472 | 470 | break; |
473 | 471 | case QuantityConstant.TASK_TYPE_OVER_STATION: |
474 | - case QuantityConstant.TASK_TYPE_MANY_OVER_STATION: | |
475 | 472 | wcsTask.setTaskType(1000); |
476 | 473 | break; |
477 | 474 | default: |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/IReceiptContainerHeaderService.java
... | ... | @@ -30,7 +30,7 @@ public interface IReceiptContainerHeaderService extends IService<ReceiptContaine |
30 | 30 | |
31 | 31 | ReceiptContainerHeader getUnCompleteReceiptContainerByCode(String containerCode, String warehouseCode); |
32 | 32 | |
33 | - public Result<TaskHeader> createReceiptTask(ReceiptContainerHeader receiptContainerHeader, String warehouseCode); | |
33 | + Result<TaskHeader> createReceiptTask(ReceiptContainerHeader receiptContainerHeader, String warehouseCode); | |
34 | 34 | |
35 | 35 | boolean updateStatusById(int status, int id); |
36 | 36 | |
... | ... | @@ -65,4 +65,9 @@ public interface IReceiptContainerHeaderService extends IService<ReceiptContaine |
65 | 65 | * 更新去向toPort |
66 | 66 | */ |
67 | 67 | boolean updateToPortById(String toPort, int id); |
68 | + | |
69 | + /** | |
70 | + * 更新去向toPort和状态status | |
71 | + */ | |
72 | + boolean updateToPortAndStatus(String toPort, int status, int id); | |
68 | 73 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/receipt/receiptContainerHeader/service/impl/ReceiptContainerHeaderServiceImpl.java
... | ... | @@ -11,9 +11,7 @@ import javax.annotation.Resource; |
11 | 11 | |
12 | 12 | import org.jeecg.common.api.vo.Result; |
13 | 13 | import org.jeecg.common.exception.JeecgBootException; |
14 | -import org.jeecg.modules.wms.config.container.entity.Container; | |
15 | 14 | import org.jeecg.modules.wms.config.container.service.IContainerService; |
16 | -import org.jeecg.modules.wms.config.location.entity.Location; | |
17 | 15 | import org.jeecg.modules.wms.config.location.service.ILocationService; |
18 | 16 | import org.jeecg.modules.wms.config.parameterConfiguration.service.IParameterConfigurationService; |
19 | 17 | import org.jeecg.modules.wms.inventory.inventoryHeader.service.IInventoryHeaderService; |
... | ... | @@ -28,6 +26,7 @@ import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptDetailService |
28 | 26 | import org.jeecg.modules.wms.receipt.receiptHeader.service.IReceiptHeaderService; |
29 | 27 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; |
30 | 28 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
29 | +import org.jeecg.modules.wms.task.taskHeader.entity.TaskLockEntity; | |
31 | 30 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService; |
32 | 31 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService; |
33 | 32 | import org.jeecg.utils.StringUtils; |
... | ... | @@ -115,63 +114,40 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
115 | 114 | public Result<TaskHeader> createReceiptTask(ReceiptContainerHeader receiptContainerHeader, String warehouseCode) { |
116 | 115 | log.info("开始创建入库任务"); |
117 | 116 | if (!receiptContainerHeader.getWarehouseCode().equals(warehouseCode)) { |
118 | - return Result.error("id:" + receiptContainerHeader.getId() + "的入库组盘不能在" + warehouseCode + "仓库操作"); | |
117 | + return Result.error("创建入库任务, id:" + receiptContainerHeader.getId() + "的入库组盘不能在" + warehouseCode + "仓库操作"); | |
119 | 118 | } |
120 | 119 | String containerCode = receiptContainerHeader.getContainerCode(); |
121 | - Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
122 | - if (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) { | |
123 | - return Result.error("托盘已经锁定,不能生成任务"); | |
124 | - } | |
120 | + String fromLocationCode = receiptContainerHeader.getFromLocationCode(); | |
121 | + String toLocationCode = receiptContainerHeader.getToLocationCode(); | |
122 | + int taskType = receiptContainerHeader.getTaskType(); | |
123 | + boolean success = false; | |
125 | 124 | List<ReceiptContainerDetail> receiptContainerDetailList = |
126 | 125 | receiptContainerDetailService.getReceiptContainerDetailListByHeaderId(receiptContainerHeader.getId()); |
127 | 126 | if (receiptContainerDetailList.size() == 0) { |
128 | - return Result.error("id:" + receiptContainerHeader.getId() + "的入库组盘,没有组盘明细,请先组盘!"); | |
129 | - } | |
130 | - boolean success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
131 | - if (!success) { | |
132 | - throw new JeecgBootException("更新容器状态失败"); | |
133 | - } | |
134 | - String fromLocationCode = receiptContainerHeader.getFromLocationCode(); | |
135 | - String toLocaitonCode = receiptContainerHeader.getToLocationCode(); | |
136 | - if (StringUtils.isNotEmpty(fromLocationCode)) { | |
137 | - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
138 | - if (!success) { | |
139 | - throw new JeecgBootException("更新起始库位状态失败"); | |
140 | - } | |
141 | - } | |
142 | - String zoneCode = null; | |
143 | - if (StringUtils.isNotEmpty(toLocaitonCode)) { | |
144 | - if (!toLocaitonCode.equals(fromLocationCode)) { | |
145 | - success = locationService.updateStatus(toLocaitonCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
146 | - if (!success) { | |
147 | - throw new JeecgBootException("更新目标库位状态失败"); | |
148 | - } | |
149 | - } | |
150 | - Location toLocation = locationService.getLocationByCode(toLocaitonCode, warehouseCode); | |
151 | - if (!toLocation.getWarehouseCode().equals(warehouseCode)) { | |
152 | - throw new JeecgBootException("库位对应的仓库不匹配"); | |
153 | - } | |
154 | - zoneCode = toLocation.getZoneCode(); | |
155 | - // 旁边库位有任务 | |
156 | - if (taskHeaderService.haveUncompleteTaskInNear(toLocation)) { | |
157 | - throw new JeecgBootException("旁边库位任务数大于0"); | |
158 | - } | |
127 | + return Result.error("创建入库任务, id:" + receiptContainerHeader.getId() + "的入库组盘,没有组盘明细,请先组盘!"); | |
159 | 128 | } |
160 | 129 | int receiptContainerStatus = receiptContainerHeader.getStatus(); |
161 | 130 | if (receiptContainerStatus != QuantityConstant.RECEIPT_CONTAINER_BUILD) { |
162 | - throw new JeecgBootException("入库组盘状态不是创建状态"); | |
131 | + return Result.error("创建入库任务, 入库组盘状态不是创建状态"); | |
163 | 132 | } |
164 | 133 | String containerFillStatus = QuantityConstant.STATUS_CONTAINER_FILL_SOME; |
165 | 134 | if (!StringUtils.isEmpty(receiptContainerHeader.getContainerFillStatus())) { |
166 | 135 | containerFillStatus = receiptContainerHeader.getContainerFillStatus(); |
167 | 136 | } |
137 | + // 锁定容器和库位 | |
138 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(taskType, containerCode, fromLocationCode, toLocationCode, warehouseCode); | |
139 | + if (!result.isSuccess()) { | |
140 | + return result; | |
141 | + } | |
142 | + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult(); | |
143 | + String zoneCode = taskLockEntity.getZoneCode(); | |
168 | 144 | TaskHeader taskHeader = new TaskHeader(); |
169 | 145 | taskHeader.setContainerCode(containerCode); |
170 | 146 | taskHeader.setContainerFillStatus(containerFillStatus); |
171 | 147 | taskHeader.setTaskType(receiptContainerHeader.getTaskType()); |
172 | 148 | taskHeader.setInnernalTaskType(QuantityConstant.TASK_INTENERTYPE_RECEIPT); |
173 | 149 | taskHeader.setFromLocationCode(fromLocationCode); |
174 | - taskHeader.setToLocationCode(toLocaitonCode); | |
150 | + taskHeader.setToLocationCode(toLocationCode); | |
175 | 151 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); |
176 | 152 | taskHeader.setCompanyCode(receiptContainerHeader.getCompanyCode()); |
177 | 153 | taskHeader.setReceiptContainerHeaderId(receiptContainerHeader.getId()); |
... | ... | @@ -180,7 +156,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
180 | 156 | taskHeader.setToPortCode(receiptContainerHeader.getToPort()); |
181 | 157 | success = taskHeaderService.save(taskHeader); |
182 | 158 | if (!success) { |
183 | - throw new JeecgBootException("任务生成失败"); | |
159 | + throw new JeecgBootException("创建入库任务, 任务生成失败"); | |
184 | 160 | } |
185 | 161 | int taskHeaderId = taskHeader.getId(); |
186 | 162 | List<TaskDetail> taskDetailList = new ArrayList<>(); |
... | ... | @@ -206,7 +182,7 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
206 | 182 | taskDetailList.add(taskDetail); |
207 | 183 | ReceiptDetail receiptDetail = receiptDetailService.getById(receiptContainerDetail.getReceiptDetailId()); |
208 | 184 | if (receiptDetail == null) { |
209 | - throw new JeecgBootException("根据id:" + receiptContainerDetail.getReceiptDetailId() + ",没有找到入库单详情"); | |
185 | + throw new JeecgBootException("创建入库任务, 根据id:" + receiptContainerDetail.getReceiptDetailId() + ",没有找到入库单详情"); | |
210 | 186 | } |
211 | 187 | Integer receiptId = receiptDetail.getReceiptId(); |
212 | 188 | receiptDetail = new ReceiptDetail(); |
... | ... | @@ -215,33 +191,33 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
215 | 191 | receiptDetail.setStatus(QuantityConstant.RECEIPT_HEADER_WAIT_SHELF); |
216 | 192 | receiptDetailList.add(receiptDetail); |
217 | 193 | } |
194 | + if (taskDetailList.size() == 0) { | |
195 | + throw new JeecgBootException("创建入库任务, 任务详情为空"); | |
196 | + } | |
218 | 197 | success = taskDetailService.saveBatch(taskDetailList); |
219 | 198 | if (!success) { |
220 | - throw new JeecgBootException("任务详情生成失败"); | |
199 | + throw new JeecgBootException("创建入库任务, 任务详情生成失败"); | |
221 | 200 | } |
222 | 201 | if (receiptContainerHeader.getTaskType() == QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT) { |
223 | 202 | success = inventoryHeaderService.updateInventoryContainerStatusByContainerCode(containerCode, warehouseCode); |
224 | 203 | if (!success) { |
225 | - throw new JeecgBootException("生成任务时, 更新库存头失败"); | |
204 | + throw new JeecgBootException("创建入库任务, 更新库存头失败"); | |
226 | 205 | } |
227 | 206 | } |
228 | - ReceiptContainerHeader receiptContainerHeader1 = new ReceiptContainerHeader(); | |
229 | - receiptContainerHeader1.setId(receiptContainerHeader.getId()); | |
230 | - receiptContainerHeader1.setToPort(receiptContainerHeader.getToPort()); | |
231 | - receiptContainerHeader1.setStatus(QuantityConstant.RECEIPT_CONTAINER_TASK); | |
232 | - success = this.updateById(receiptContainerHeader1); | |
207 | + success = receiptContainerHeaderService.updateToPortAndStatus(receiptContainerHeader.getToPort(), QuantityConstant.RECEIPT_CONTAINER_TASK, | |
208 | + receiptContainerHeader.getId()); | |
233 | 209 | if (!success) { |
234 | - throw new JeecgBootException("生成任务时,更新入库组盘头失败"); | |
210 | + throw new JeecgBootException("创建入库任务,更新入库组盘头失败"); | |
235 | 211 | } |
236 | 212 | success = receiptDetailService.updateBatchById(receiptDetailList); |
237 | 213 | if (!success) { |
238 | - throw new JeecgBootException("更新入库单明细失败"); | |
214 | + throw new JeecgBootException("创建入库任务,更新入库单明细失败"); | |
239 | 215 | } |
240 | 216 | List<Integer> receiptIdList = receiptDetailList.stream().map(ReceiptDetail::getReceiptId).distinct().collect(Collectors.toList()); |
241 | 217 | for (Integer receiptId : receiptIdList) { |
242 | 218 | success = receiptHeaderService.updateReceiptHeaderStatus(receiptId); |
243 | 219 | if (!success) { |
244 | - throw new JeecgBootException("更新入库单明细失败"); | |
220 | + throw new JeecgBootException("创建入库任务, 更新入库单明细失败"); | |
245 | 221 | } |
246 | 222 | } |
247 | 223 | LogRecordContext.putVariable("taskHeader", taskHeader);// 操作日志收集 |
... | ... | @@ -447,4 +423,14 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
447 | 423 | return success; |
448 | 424 | } |
449 | 425 | |
426 | + @Override | |
427 | + public boolean updateToPortAndStatus(String toPort, int status, int id) { | |
428 | + ReceiptContainerHeader receiptContainerHeader = new ReceiptContainerHeader(); | |
429 | + receiptContainerHeader.setToPort(toPort); | |
430 | + receiptContainerHeader.setStatus(status); | |
431 | + receiptContainerHeader.setId(id); | |
432 | + boolean success = updateById(receiptContainerHeader); | |
433 | + return success; | |
434 | + } | |
435 | + | |
450 | 436 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
... | ... | @@ -470,6 +470,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi |
470 | 470 | if (StringUtils.isEmpty(fromLocationCode)) { |
471 | 471 | return Result.error("生成出库任务时, 出库组盘头没有起始库位号"); |
472 | 472 | } |
473 | + // 出库时,外侧库位的任务,如果对应的内侧有任务,那么内侧任务执行完成以后,再执行出库任务。 | |
473 | 474 | Location location = locationService.getLocationByCode(fromLocationCode, warehouseCode); |
474 | 475 | if (location == null) { |
475 | 476 | return Result.error("生成出库任务时, 库位号" + fromLocationCode + "没有找到库位"); |
... | ... | @@ -484,21 +485,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi |
484 | 485 | } |
485 | 486 | } |
486 | 487 | } |
487 | - Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
488 | - if (container == null) { | |
489 | - return Result.error("生成出库任务时, 托盘不存在" + containerCode); | |
490 | - } | |
491 | - if (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) { | |
492 | - return Result.error("生成出库任务时, 托盘已经锁定" + containerCode); | |
493 | - } | |
494 | - boolean success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
495 | - if (!success) { | |
496 | - throw new JeecgBootException("生成出库任务时, 更新容器失败" + containerCode); | |
497 | - } | |
498 | - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
499 | - if (!success) { | |
500 | - throw new JeecgBootException("生成出库任务时, 更新库位失败" + fromLocationCode); | |
501 | - } | |
488 | + // 根据出库数量,判断任务类型 | |
502 | 489 | List<InventoryDetail> inventoryDetailList = inventoryDetailService.getInventoryDetailListByContainerCode(containerCode, warehouseCode); |
503 | 490 | BigDecimal inventoryTotal = BigDecimal.ZERO; |
504 | 491 | for (InventoryDetail inventoryDetail : inventoryDetailList) { |
... | ... | @@ -521,6 +508,11 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi |
521 | 508 | if (shipmentTaskRule == QuantityConstant.RULE_TASK_PICK_SHIPMENT) { |
522 | 509 | taskType = QuantityConstant.TASK_TYPE_SORTINGSHIPMENT; |
523 | 510 | } |
511 | + // 锁定容器、库位 | |
512 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(taskType, containerCode, fromLocationCode, toLocationCode, warehouseCode); | |
513 | + if (!result.isSuccess()) { | |
514 | + return result; | |
515 | + } | |
524 | 516 | String zoneCode = location.getZoneCode(); |
525 | 517 | TaskHeader taskHeader = new TaskHeader(); |
526 | 518 | taskHeader.setPreTaskNo(preTaskNo); |
... | ... | @@ -539,7 +531,7 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi |
539 | 531 | taskHeader.setToLocationCode(toLocationCode); |
540 | 532 | } |
541 | 533 | taskHeader.setShipmentContainerHeaderId(shipmentContainerHeader.getId()); |
542 | - success = taskHeaderService.save(taskHeader); | |
534 | + boolean success = taskHeaderService.save(taskHeader); | |
543 | 535 | if (!success) { |
544 | 536 | throw new JeecgBootException("生成出库任务时, 创建任务失败"); |
545 | 537 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/entity/TaskLockEntity.java
0 → 100644
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/ITaskHeaderService.java
... | ... | @@ -318,4 +318,35 @@ public interface ITaskHeaderService extends IService<TaskHeader> { |
318 | 318 | * @return |
319 | 319 | */ |
320 | 320 | boolean combineInventoryDetail(TaskHeader taskHeader); |
321 | + | |
322 | + /** | |
323 | + * 根据任务区分,在生产任务的时候,锁定容器和库位 | |
324 | + * @param | |
325 | + */ | |
326 | + Result createTaskLockContainerAndLocation(int taskType, String containerCode, String fromLocationCode, String toLocationCode, String warehouseCode); | |
327 | + | |
328 | + /** | |
329 | + * 入库任务,在生产任务的时候,锁定容器和库位 | |
330 | + * @param | |
331 | + */ | |
332 | + Result createReceiptTaskLockContainerAndLocation(String containerCode, String toLocationCode, String warehouseCode); | |
333 | + | |
334 | + /** | |
335 | + * 出库任务,在生产任务的时候,锁定容器和库位 | |
336 | + * @param | |
337 | + */ | |
338 | + Result createShipmentTaskLockContainerAndLocation(String containerCode, String warehouseCode); | |
339 | + | |
340 | + /** | |
341 | + * 分拣任务,在生产任务的时候,锁定容器和库位 | |
342 | + * @param | |
343 | + */ | |
344 | + Result createSortTaskLockContainerAndLocation(String containerCode, String fromLocationCode, String toLocationCode, String warehouseCode); | |
345 | + | |
346 | + /** | |
347 | + * 跨站任务,在生产任务的时候,锁定容器和库位 | |
348 | + * @param | |
349 | + */ | |
350 | + Result createOverStationTaskLockContainer(String containerCode, String warehouseCode); | |
351 | + | |
321 | 352 | } |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... | ... | @@ -53,6 +53,7 @@ import org.jeecg.modules.wms.stocktaking.cycleCountDetail.service.impl.CycleCoun |
53 | 53 | import org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.impl.CycleCountHeaderServiceImpl; |
54 | 54 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail; |
55 | 55 | import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader; |
56 | +import org.jeecg.modules.wms.task.taskHeader.entity.TaskLockEntity; | |
56 | 57 | import org.jeecg.modules.wms.task.taskHeader.mapper.TaskDetailMapper; |
57 | 58 | import org.jeecg.modules.wms.task.taskHeader.mapper.TaskHeaderMapper; |
58 | 59 | import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService; |
... | ... | @@ -183,6 +184,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
183 | 184 | @Transactional(rollbackFor = Exception.class) |
184 | 185 | public Result<TaskHeader> createTransferTask(String fromLocationCode, String toLocationCode, String warehouseCode) { |
185 | 186 | log.info("开始创建移库任务,起始库位" + fromLocationCode + ",目标库位" + toLocationCode); |
187 | + int preTaskNo = 0; | |
186 | 188 | if (StringUtils.isEmpty(fromLocationCode)) { |
187 | 189 | return Result.error("创建移库任务时,起始库位为空"); |
188 | 190 | } |
... | ... | @@ -190,18 +192,14 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
190 | 192 | return Result.error("创建移库任务时,目标库位为空"); |
191 | 193 | } |
192 | 194 | Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); |
193 | - Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); | |
194 | - Integer preTaskNo = 0; | |
195 | - // 1. 判断起点库位和终点库位是否满足移库条件 | |
196 | 195 | if (fromLocation == null) { |
197 | 196 | return Result.error("创建移库任务时,起始库位:" + fromLocationCode + "未找到"); |
198 | 197 | } |
199 | - if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(fromLocation.getStatus())) { | |
200 | - return Result.error("创建移库任务时,起始库位:" + fromLocationCode + "状态非空闲"); | |
201 | - } | |
202 | - if (StringUtils.isEmpty(fromLocation.getContainerCode())) { | |
203 | - return Result.error("创建移库任务时,起始库位:" + fromLocationCode + "不存在托盘"); | |
198 | + Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); | |
199 | + if (fromLocation == null) { | |
200 | + return Result.error("创建移库任务时,起始库位:" + fromLocationCode + "未找到"); | |
204 | 201 | } |
202 | + String containerCode = fromLocation.getContainerCode(); | |
205 | 203 | // 这里增加组盘校验,如果此托盘存在未完成的组盘数据,则不能移库 |
206 | 204 | // 校验入库组盘 |
207 | 205 | if (receiptContainerHeaderService.havaUnCompleteCombineByLocationCode(fromLocationCode, warehouseCode)) { |
... | ... | @@ -212,15 +210,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
212 | 210 | return Result.error("创建移库任务时,起始库位:" + fromLocationCode + "存在出库组盘,不能移库"); |
213 | 211 | } |
214 | 212 | |
215 | - if (toLocation == null) { | |
216 | - return Result.error("创建移库任务时,目标库位:" + toLocationCode + "未找到"); | |
217 | - } | |
218 | - if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(toLocation.getStatus())) { | |
219 | - return Result.error("创建移库任务时,目标库位:" + toLocationCode + "状态非空闲"); | |
220 | - } | |
221 | - if (StringUtils.isNotEmpty(toLocation.getContainerCode())) { | |
222 | - return Result.error("创建移库任务时,目标库位:" + toLocationCode + "存在托盘"); | |
223 | - } | |
224 | 213 | // 校验入库组盘 |
225 | 214 | if (receiptContainerHeaderService.havaUnCompleteCombineByLocationCode(toLocationCode, warehouseCode)) { |
226 | 215 | return Result.error("创建移库任务时,目标库位:" + toLocationCode + "存在入库组盘,不能移库"); |
... | ... | @@ -232,7 +221,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
232 | 221 | if (taskHeaderService.haveUncompleteTaskInNear(toLocation)) { |
233 | 222 | return Result.error("创建移库任务时,目标库位:" + toLocationCode + "旁边存在任务,请完成任务以后再分配"); |
234 | 223 | } |
235 | - | |
236 | 224 | if (!fromLocation.getRoadWay().equals(toLocation.getRoadWay())) { |
237 | 225 | return Result.error("创建移库任务时,目标库位和源库位不在同一个巷道"); |
238 | 226 | } |
... | ... | @@ -266,6 +254,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
266 | 254 | } |
267 | 255 | } |
268 | 256 | |
257 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_TRANSFER, containerCode, fromLocationCode, toLocationCode, | |
258 | + warehouseCode); | |
259 | + if (!result.isSuccess()) { | |
260 | + return result; | |
261 | + } | |
269 | 262 | // 4. 判断源库位旁边有托盘但是没有任务,那么不允许移库 |
270 | 263 | TaskHeader taskHeader = new TaskHeader(); |
271 | 264 | taskHeader.setWarehouseCode(warehouseCode); |
... | ... | @@ -281,21 +274,9 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
281 | 274 | if (!success) { |
282 | 275 | throw new JeecgBootException("创建移库任务时,创建任务失败"); |
283 | 276 | } |
284 | - | |
285 | - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
286 | - if (!success) { | |
287 | - throw new JeecgBootException("创建移库任务时, 起始库位" + fromLocationCode + "更新失败"); | |
288 | - } | |
289 | - success = locationService.updateStatus(toLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
290 | - if (!success) { | |
291 | - throw new JeecgBootException("创建移库任务时, 终点库位" + toLocationCode + "更新失败"); | |
292 | - } | |
293 | - success = containerService.updateStatus(fromLocation.getContainerCode(), QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
294 | 277 | log.info("完成创建移库任务,起始库位" + fromLocationCode + ",目的库位" + toLocationCode); |
295 | - if (!success) { | |
296 | - throw new JeecgBootException("创建移库任务时,容器" + fromLocation.getContainerCode() + "更新失败"); | |
297 | - } | |
298 | 278 | return Result.OK("创建移库任务成功", taskHeader); |
279 | + | |
299 | 280 | } |
300 | 281 | |
301 | 282 | @Override |
... | ... | @@ -315,10 +296,13 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
315 | 296 | if (container == null) { |
316 | 297 | return Result.error("创建出库查看任务时,容器为空"); |
317 | 298 | } |
318 | - if (container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_LOCK)) { | |
319 | - return Result.error("创建出库查看任务时,容器是锁定状态"); | |
320 | - } | |
321 | 299 | String fromLocationCode = container.getLocationCode(); |
300 | + String toLocationCode = QuantityConstant.EMPTY_STRING; | |
301 | + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_TASK_LOCATION); | |
302 | + int taskLocationRule = Integer.parseInt(value); | |
303 | + if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION) { | |
304 | + toLocationCode = fromLocationCode; | |
305 | + } | |
322 | 306 | if (StringUtils.isEmpty(fromLocationCode)) { |
323 | 307 | return Result.error("创建出库查看任务时,容器不在库位上"); |
324 | 308 | } |
... | ... | @@ -331,6 +315,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
331 | 315 | if (port == null) { |
332 | 316 | return Result.error("创建出库查看任务时,没有找到出库口:" + toPortCode); |
333 | 317 | } |
318 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_CHECK_OUT, containerCode, fromLocationCode, toLocationCode, | |
319 | + warehouseCode); | |
320 | + if (!result.isSuccess()) { | |
321 | + return result; | |
322 | + } | |
334 | 323 | boolean success = false; |
335 | 324 | LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery(); |
336 | 325 | inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getContainerCode, containerCode).eq(InventoryDetail::getWarehouseCode, warehouseCode) |
... | ... | @@ -350,14 +339,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
350 | 339 | throw new JeecgBootException("创建出库查看任务时,更新库存详情失败"); |
351 | 340 | } |
352 | 341 | } |
353 | - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
354 | - if (!success) { | |
355 | - throw new JeecgBootException("创建出库查看任务时,更新库位状态失败"); | |
356 | - } | |
357 | - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
358 | - if (!success) { | |
359 | - throw new JeecgBootException("创建出库查看任务时,更新容器状态失败"); | |
360 | - } | |
361 | 342 | TaskHeader taskHeader = new TaskHeader(); |
362 | 343 | taskHeader.setWarehouseCode(warehouseCode); |
363 | 344 | taskHeader.setTaskType(QuantityConstant.TASK_TYPE_CHECK_OUT); |
... | ... | @@ -366,11 +347,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
366 | 347 | taskHeader.setZoneCode(zoneCode); |
367 | 348 | taskHeader.setFromLocationCode(fromLocationCode); |
368 | 349 | taskHeader.setToPortCode(toPortCode); |
369 | - String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_TASK_LOCATION); | |
370 | - int taskLocationRule = Integer.parseInt(value); | |
371 | - if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION) { | |
372 | - taskHeader.setToLocationCode(fromLocationCode); | |
373 | - } | |
350 | + taskHeader.setToLocationCode(toLocationCode); | |
374 | 351 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); |
375 | 352 | success = taskHeaderService.save(taskHeader); |
376 | 353 | log.info("完成创建出库查看任务,容器编码" + containerCode + "目标站台号" + toPortCode); |
... | ... | @@ -396,16 +373,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
396 | 373 | if (StringUtils.isEmpty(warehouseCode)) { |
397 | 374 | return Result.error("创建跨站任务时,仓库编码为空"); |
398 | 375 | } |
399 | - Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
400 | - if (container == null) { | |
401 | - return Result.error("创建跨站任务时,容器为空"); | |
402 | - } | |
403 | - if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
404 | - return Result.error("创建跨站任务时, 容器状态不为空闲状态"); | |
405 | - } | |
406 | - if (!container.getFillStatus().equals(QuantityConstant.STATUS_CONTAINER_FILL_EMPTY)) { | |
407 | - return Result.error("创建跨站任务时,容器状态不为空托盘"); | |
408 | - } | |
409 | 376 | Port fromPort = portService.getPortByCode(fromPortCode, warehouseCode); |
410 | 377 | if (fromPort == null) { |
411 | 378 | return Result.error("创建跨站任务时,起始站台为空"); |
... | ... | @@ -414,7 +381,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
414 | 381 | if (toPort == null) { |
415 | 382 | return Result.error("创建跨站任务时,目标站台为空"); |
416 | 383 | } |
417 | - | |
384 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_OVER_STATION, containerCode, QuantityConstant.EMPTY_STRING, | |
385 | + QuantityConstant.EMPTY_STRING, warehouseCode); | |
386 | + if (!result.isSuccess()) { | |
387 | + return result; | |
388 | + } | |
418 | 389 | TaskHeader taskHeader = new TaskHeader(); |
419 | 390 | taskHeader.setWarehouseCode(warehouseCode); |
420 | 391 | taskHeader.setContainerCode(containerCode); |
... | ... | @@ -427,11 +398,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
427 | 398 | if (!success) { |
428 | 399 | return Result.error("创建跨站任务时, 创建任务失败"); |
429 | 400 | } |
430 | - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
431 | 401 | log.info("完成创建跨站任务,容器号" + containerCode + ",起始站台号" + fromPortCode + ",目标站台号" + toPortCode); |
432 | - if (!success) { | |
433 | - return Result.error("创建跨站任务时, 更新容器状态失败"); | |
434 | - } | |
435 | 402 | return Result.ok("创建跨站任务成功"); |
436 | 403 | } |
437 | 404 | |
... | ... | @@ -511,35 +478,13 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
511 | 478 | } |
512 | 479 | log.info("开始创建空托盘组入库任务,容器编码" + containerCode + ",库位编码" + toLocationCode); |
513 | 480 | String zoneCode = null; |
514 | - Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
515 | - if (container == null) { | |
516 | - return Result.error("创建空托盘组入库任务时,没有找到容器"); | |
517 | - } | |
518 | - if (StringUtils.isNotEmpty(container.getLocationCode())) { | |
519 | - return Result.error("创建空托盘组入库任务时, 容器已在库位" + container.getLocationCode() + "上"); | |
520 | - } | |
521 | - if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
522 | - return Result.error("创建空托盘组入库任务时,容器状态不为空闲状态"); | |
523 | - } | |
524 | - if (!container.getFillStatus().equals(QuantityConstant.STATUS_CONTAINER_FILL_EMPTY)) { | |
525 | - return Result.error("创建空托盘组入库任务时,容器状态不为空托盘"); | |
526 | - } | |
527 | - boolean success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
528 | - if (!success) { | |
529 | - throw new JeecgBootException("创建空托盘组入库任务时, 更新容器状态失败"); | |
481 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT, containerCode, | |
482 | + QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode); | |
483 | + if (!result.isSuccess()) { | |
484 | + return result; | |
530 | 485 | } |
531 | 486 | if (StringUtils.isNotEmpty(toLocationCode)) { |
532 | 487 | Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); |
533 | - if (toLocation == null) { | |
534 | - return Result.error("创建空托盘组入库任务时,没有找到目标库位"); | |
535 | - } | |
536 | - if (!toLocation.getStatus().equals(QuantityConstant.STATUS_LOCATION_EMPTY)) { | |
537 | - return Result.error("创建空托盘组入库任务时,目标库位状态不是空闲"); | |
538 | - } | |
539 | - success = locationService.updateStatus(toLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
540 | - if (!success) { | |
541 | - throw new JeecgBootException("创建空托盘组入库任务时, 更新库位状态失败"); | |
542 | - } | |
543 | 488 | zoneCode = toLocation.getZoneCode(); |
544 | 489 | } |
545 | 490 | TaskHeader taskHeader = new TaskHeader(); |
... | ... | @@ -550,7 +495,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
550 | 495 | taskHeader.setToLocationCode(toLocationCode); |
551 | 496 | taskHeader.setZoneCode(zoneCode); |
552 | 497 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); |
553 | - success = taskHeaderService.save(taskHeader); | |
498 | + boolean success = taskHeaderService.save(taskHeader); | |
554 | 499 | log.info("完成创建空托盘组入库任务,容器编码" + containerCode + ",库位编码" + toLocationCode); |
555 | 500 | if (!success) { |
556 | 501 | throw new JeecgBootException("创建空托盘组入库任务时, 创建任务失败"); |
... | ... | @@ -571,20 +516,13 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
571 | 516 | if (StringUtils.isEmpty(warehouseCode)) { |
572 | 517 | return Result.error("创建空托盘组出库任务时,仓库编码为空"); |
573 | 518 | } |
574 | - Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
575 | - if (container == null) { | |
576 | - return Result.error("创建空托盘组出库任务时, 没有找到容器:" + containerCode); | |
577 | - } | |
578 | - if (!QuantityConstant.STATUS_CONTAINER_EMPTY.equals(container.getStatus())) { | |
579 | - return Result.error("创建空托盘组出库任务时, 容器状态不为空闲状态"); | |
580 | - } | |
581 | - if (!QuantityConstant.STATUS_CONTAINER_FILL_MANY.equals(container.getFillStatus())) { | |
582 | - return Result.error("创建空托盘组出库任务时, 容器填充状态不为空托盘组状态"); | |
519 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT, containerCode, | |
520 | + QuantityConstant.EMPTY_STRING, QuantityConstant.EMPTY_STRING, warehouseCode); | |
521 | + if (!result.isSuccess()) { | |
522 | + return result; | |
583 | 523 | } |
524 | + Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
584 | 525 | String fromLocationCode = container.getLocationCode(); |
585 | - if (StringUtils.isEmpty(fromLocationCode)) { | |
586 | - return Result.error("创建空托盘组出库任务时, 该容器不在库位上"); | |
587 | - } | |
588 | 526 | Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); |
589 | 527 | if (fromLocation == null) { |
590 | 528 | return Result.error("创建空托盘组出库任务时, 没有找到库位:" + fromLocationCode); |
... | ... | @@ -593,14 +531,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
593 | 531 | if (StringUtils.isEmpty(zoneCode)) { |
594 | 532 | return Result.error("创建空托盘组出库任务时, 库区为空"); |
595 | 533 | } |
596 | - boolean success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
597 | - if (!success) { | |
598 | - throw new JeecgBootException("创建空托盘组出库任务时, 更新容器状态失败"); | |
599 | - } | |
600 | - success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
601 | - if (!success) { | |
602 | - throw new JeecgBootException("创建空托盘组出库任务时, 更新库位状态失败"); | |
603 | - } | |
604 | 534 | TaskHeader taskHeader = new TaskHeader(); |
605 | 535 | taskHeader.setWarehouseCode(warehouseCode); |
606 | 536 | taskHeader.setZoneCode(zoneCode); |
... | ... | @@ -610,7 +540,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
610 | 540 | taskHeader.setFromLocationCode(fromLocationCode); |
611 | 541 | taskHeader.setToPortCode(toPortCode); |
612 | 542 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); |
613 | - success = taskHeaderService.save(taskHeader); | |
543 | + boolean success = taskHeaderService.save(taskHeader); | |
614 | 544 | log.info("完成创建空托盘组出库任务,容器编码" + containerCode + ",去向位置编码" + toPortCode); |
615 | 545 | if (!success) { |
616 | 546 | throw new JeecgBootException("创建空托盘组出库任务时,生成任务失败"); |
... | ... | @@ -982,36 +912,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
982 | 912 | if (StringUtils.isEmpty(warehouseCode)) { |
983 | 913 | return Result.error("创建空托盘入库时, 仓库编码为空"); |
984 | 914 | } |
985 | - Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
986 | - if (container == null) { | |
987 | - return Result.error("创建空托盘入库时, 没有找到托盘" + containerCode); | |
988 | - } | |
989 | - if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
990 | - return Result.error("创建空托盘入库时, 托盘状态并非空托盘状态"); | |
991 | - } | |
992 | - if (StringUtils.isNotEmpty(container.getLocationCode())) { | |
993 | - return Result.error("创建空托盘入库时, 容器已在库位" + container.getLocationCode() + "上"); | |
994 | - } | |
995 | 915 | |
996 | - if (StringUtils.isNotEmpty(toLocationCode)) { | |
997 | - Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); | |
998 | - if (toLocation == null) { | |
999 | - return Result.error("创建空托盘入库时," + toLocationCode + "目标库位不存在"); | |
1000 | - } | |
1001 | - if (StringUtils.isNotEmpty(toLocation.getContainerCode())) { | |
1002 | - return Result.error("创建空托盘入库时," + toLocationCode + "上已存在容器" + toLocation.getContainerCode()); | |
1003 | - } | |
1004 | - if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(toLocation.getStatus())) { | |
1005 | - return Result.error("创建空托盘入库时, 目标库位非空闲"); | |
1006 | - } | |
1007 | - boolean success = locationService.updateStatus(toLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
1008 | - if (!success) { | |
1009 | - throw new JeecgBootException("创建空托盘入库时,更新库位状态失败"); | |
1010 | - } | |
1011 | - } | |
1012 | - boolean success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
1013 | - if (!success) { | |
1014 | - throw new JeecgBootException("创建空托盘入库时,更新容器状态失败"); | |
916 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_EMPTYRECEIPT, containerCode, QuantityConstant.EMPTY_STRING, | |
917 | + toLocationCode, warehouseCode); | |
918 | + if (!result.isSuccess()) { | |
919 | + return result; | |
1015 | 920 | } |
1016 | 921 | TaskHeader taskHeader = new TaskHeader(); |
1017 | 922 | taskHeader.setWarehouseCode(warehouseCode); |
... | ... | @@ -1020,7 +925,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1020 | 925 | taskHeader.setInnernalTaskType(QuantityConstant.TASK_INTENERTYPE_RECEIPT); |
1021 | 926 | taskHeader.setToLocationCode(toLocationCode); |
1022 | 927 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); |
1023 | - success = taskHeaderService.save(taskHeader); | |
928 | + boolean success = taskHeaderService.save(taskHeader); | |
1024 | 929 | log.info("完成创建空托入库任务"); |
1025 | 930 | if (!success) { |
1026 | 931 | throw new JeecgBootException("创建空托盘入库时,保存任务失败"); |
... | ... | @@ -1049,15 +954,11 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1049 | 954 | return Result.error("创建空托盘出库时, 仓库编码为空"); |
1050 | 955 | } |
1051 | 956 | Container container = containerService.getContainerByCode(containerCode, warehouseCode); |
1052 | - if (container == null) { | |
1053 | - return Result.error("创建空托盘出库时, 没有找到托盘" + containerCode); | |
1054 | - } | |
1055 | - if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
1056 | - return Result.error("创建空托盘出库时, 托盘状态并非空托盘状态"); | |
1057 | - } | |
1058 | 957 | String fromLocationCode = container.getLocationCode(); |
1059 | - if (StringUtils.isEmpty(fromLocationCode)) { | |
1060 | - return Result.error("创建空托盘出库时, 容器不在库位上"); | |
958 | + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_EMPTYSHIPMENT, containerCode, QuantityConstant.EMPTY_STRING, | |
959 | + QuantityConstant.EMPTY_STRING, warehouseCode); | |
960 | + if (!result.isSuccess()) { | |
961 | + return result; | |
1061 | 962 | } |
1062 | 963 | Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); |
1063 | 964 | if (fromLocation == null) { |
... | ... | @@ -1071,14 +972,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1071 | 972 | if (port == null) { |
1072 | 973 | return Result.error("创建空托盘出库时, 没有找到出库口" + toPortCode); |
1073 | 974 | } |
1074 | - boolean success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
1075 | - if (!success) { | |
1076 | - throw new JeecgBootException("创建空托盘出库时,更新库位状态失败"); | |
1077 | - } | |
1078 | - success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
1079 | - if (!success) { | |
1080 | - throw new JeecgBootException("创建空托盘出库时,更新容器状态失败"); | |
1081 | - } | |
1082 | 975 | TaskHeader taskHeader = new TaskHeader(); |
1083 | 976 | taskHeader.setWarehouseCode(warehouseCode); |
1084 | 977 | taskHeader.setZoneCode(zoneCode); |
... | ... | @@ -1088,7 +981,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1088 | 981 | taskHeader.setFromLocationCode(fromLocationCode); |
1089 | 982 | taskHeader.setStatus(QuantityConstant.TASK_STATUS_BUILD); |
1090 | 983 | taskHeader.setToPortCode(toPortCode); |
1091 | - success = taskHeaderService.save(taskHeader); | |
984 | + boolean success = taskHeaderService.save(taskHeader); | |
1092 | 985 | log.info("完成创建空托出库任务" + containerCode); |
1093 | 986 | if (!success) { |
1094 | 987 | throw new JeecgBootException("创建空托盘出库时,保存任务失败"); |
... | ... | @@ -1238,7 +1131,6 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1238 | 1131 | if (!success) { |
1239 | 1132 | throw new JeecgBootException("完成入库任务时,更新入库组盘头表状态失败"); |
1240 | 1133 | } |
1241 | - | |
1242 | 1134 | success = inventoryDetailService.saveBatch(inventoryDetailList); |
1243 | 1135 | if (!success) { |
1244 | 1136 | throw new JeecgBootException("完成入库任务时,保存库存详情失败"); |
... | ... | @@ -1578,6 +1470,204 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
1578 | 1470 | } |
1579 | 1471 | |
1580 | 1472 | /** |
1473 | + * 锁定容器和库位分4种情况,入库任务、出库任务、分拣任务、换站任务 | |
1474 | + * @param | |
1475 | + */ | |
1476 | + @Override | |
1477 | + @Transactional(rollbackFor = Exception.class) | |
1478 | + public Result createTaskLockContainerAndLocation(int taskType, String containerCode, String fromLocationCode, String toLocationCode, String warehouseCode) { | |
1479 | + Result result = null; | |
1480 | + switch (taskType) { | |
1481 | + case QuantityConstant.TASK_TYPE_WHOLERECEIPT: | |
1482 | + case QuantityConstant.TASK_TYPE_EMPTYRECEIPT: | |
1483 | + case QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT: | |
1484 | + result = taskHeaderService.createReceiptTaskLockContainerAndLocation(containerCode, toLocationCode, warehouseCode); | |
1485 | + break; | |
1486 | + case QuantityConstant.TASK_TYPE_WHOLESHIPMENT: | |
1487 | + case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT: | |
1488 | + case QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT: | |
1489 | + result = taskHeaderService.createShipmentTaskLockContainerAndLocation(containerCode, warehouseCode); | |
1490 | + break; | |
1491 | + case QuantityConstant.TASK_TYPE_SUPPLEMENTRECEIPT: | |
1492 | + case QuantityConstant.TASK_TYPE_SORTINGSHIPMENT: | |
1493 | + case QuantityConstant.TASK_TYPE_CYCLECOUNT: | |
1494 | + case QuantityConstant.TASK_TYPE_TRANSFER: | |
1495 | + case QuantityConstant.TASK_TYPE_CHECK_OUT: | |
1496 | + result = taskHeaderService.createSortTaskLockContainerAndLocation(containerCode, fromLocationCode, toLocationCode, warehouseCode); | |
1497 | + break; | |
1498 | + case QuantityConstant.TASK_TYPE_OVER_STATION: | |
1499 | + result = taskHeaderService.createOverStationTaskLockContainer(containerCode, warehouseCode); | |
1500 | + break; | |
1501 | + } | |
1502 | + return result; | |
1503 | + } | |
1504 | + | |
1505 | + @Override | |
1506 | + @Transactional(rollbackFor = Exception.class) | |
1507 | + public Result createReceiptTaskLockContainerAndLocation(String containerCode, String toLocationCode, String warehouseCode) { | |
1508 | + boolean success = false; | |
1509 | + TaskLockEntity taskLockEntity = new TaskLockEntity(); | |
1510 | + String zoneCode = null; | |
1511 | + Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
1512 | + if (container == null) { | |
1513 | + return Result.error("创建入库任务时, 没有找到托盘" + containerCode); | |
1514 | + } | |
1515 | + if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
1516 | + return Result.error("创建入库任务时, 托盘状态并非空闲状态"); | |
1517 | + } | |
1518 | + if (StringUtils.isNotEmpty(container.getLocationCode())) { | |
1519 | + return Result.error("创建入库任务时, 容器已在库位" + container.getLocationCode() + "上"); | |
1520 | + } | |
1521 | + if (StringUtils.isNotEmpty(toLocationCode)) { | |
1522 | + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_ALLOCATION); | |
1523 | + if (StringUtils.isEmpty(value)) { | |
1524 | + return Result.error("创建入库任务时, 未绑定定位规则"); | |
1525 | + } | |
1526 | + int allocationRule = Integer.parseInt(value); | |
1527 | + if (allocationRule == QuantityConstant.DOUBLE_FORK) { | |
1528 | + return Result.error("创建入库任务时, 双伸位库位不能手动指定库位"); | |
1529 | + } | |
1530 | + Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); | |
1531 | + if (toLocation == null) { | |
1532 | + return Result.error("创建入库任务时," + toLocationCode + "目标库位不存在"); | |
1533 | + } | |
1534 | + if (StringUtils.isNotEmpty(toLocation.getContainerCode())) { | |
1535 | + return Result.error("创建入库任务时," + toLocationCode + "上已存在容器" + toLocation.getContainerCode()); | |
1536 | + } | |
1537 | + if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(toLocation.getStatus())) { | |
1538 | + return Result.error("创建入库任务时, 目标库位非空闲"); | |
1539 | + } | |
1540 | + zoneCode = toLocation.getZoneCode(); | |
1541 | + } | |
1542 | + taskLockEntity.setZoneCode(zoneCode); | |
1543 | + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
1544 | + if (!success) { | |
1545 | + throw new JeecgBootException("创建入库任务时,更新容器状态失败"); | |
1546 | + } | |
1547 | + if (StringUtils.isNotEmpty(toLocationCode)) { | |
1548 | + success = locationService.updateStatus(toLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
1549 | + if (!success) { | |
1550 | + throw new JeecgBootException("创建入库任务时,更新库位状态失败"); | |
1551 | + } | |
1552 | + } | |
1553 | + return Result.OK("创建入库任务成功", taskLockEntity); | |
1554 | + } | |
1555 | + | |
1556 | + @Override | |
1557 | + @Transactional(rollbackFor = Exception.class) | |
1558 | + public Result createShipmentTaskLockContainerAndLocation(String containerCode, String warehouseCode) { | |
1559 | + boolean success = false; | |
1560 | + TaskLockEntity taskLockEntity = new TaskLockEntity(); | |
1561 | + String zoneCode = null; | |
1562 | + Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
1563 | + if (container == null) { | |
1564 | + return Result.error("创建出库任务时, 没有找到托盘" + containerCode); | |
1565 | + } | |
1566 | + if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
1567 | + return Result.error("创建出库任务时, 托盘状态并非空闲状态"); | |
1568 | + } | |
1569 | + if (StringUtils.isEmpty(container.getLocationCode())) { | |
1570 | + return Result.error("创建出库任务时, 容器不在库位" + container.getLocationCode() + "上"); | |
1571 | + } | |
1572 | + String fromLocationCode = container.getLocationCode(); | |
1573 | + Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); | |
1574 | + if (fromLocation == null) { | |
1575 | + return Result.error("创建出库任务时, 起始库位为空"); | |
1576 | + } | |
1577 | + if (StringUtils.isEmpty(fromLocation.getContainerCode())) { | |
1578 | + return Result.error("创建出库任务时," + fromLocationCode + "上已存在容器" + fromLocation.getContainerCode()); | |
1579 | + } | |
1580 | + if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(fromLocation.getStatus())) { | |
1581 | + return Result.error("创建出库任务时, 起始库位非空闲"); | |
1582 | + } | |
1583 | + zoneCode = fromLocation.getZoneCode(); | |
1584 | + taskLockEntity.setZoneCode(zoneCode); | |
1585 | + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
1586 | + if (!success) { | |
1587 | + throw new JeecgBootException("创建出库任务时,更新容器状态失败"); | |
1588 | + } | |
1589 | + success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
1590 | + if (!success) { | |
1591 | + throw new JeecgBootException("创建出库任务时,更新库位状态失败"); | |
1592 | + } | |
1593 | + return Result.OK("创建出库任务成功", taskLockEntity); | |
1594 | + } | |
1595 | + | |
1596 | + @Override | |
1597 | + @Transactional(rollbackFor = Exception.class) | |
1598 | + public Result createSortTaskLockContainerAndLocation(String containerCode, String fromLocationCode, String toLocationCode, String warehouseCode) { | |
1599 | + boolean success = false; | |
1600 | + TaskLockEntity taskLockEntity = new TaskLockEntity(); | |
1601 | + String zoneCode = null; | |
1602 | + Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
1603 | + if (container == null) { | |
1604 | + return Result.error("创建分拣任务时, 没有找到托盘" + containerCode); | |
1605 | + } | |
1606 | + if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
1607 | + return Result.error("创建分拣任务时, 托盘状态并非空闲状态"); | |
1608 | + } | |
1609 | + if (StringUtils.isEmpty(container.getLocationCode())) { | |
1610 | + return Result.error("创建分拣任务时, 容器不在库位" + container.getLocationCode() + "上"); | |
1611 | + } | |
1612 | + Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode); | |
1613 | + if (fromLocation == null) { | |
1614 | + return Result.error("创建分拣任务时, 起始库位为空"); | |
1615 | + } | |
1616 | + if (StringUtils.isEmpty(fromLocation.getContainerCode())) { | |
1617 | + return Result.error("创建分拣任务时," + fromLocationCode + "上已存在容器" + fromLocation.getContainerCode()); | |
1618 | + } | |
1619 | + if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(fromLocation.getStatus())) { | |
1620 | + return Result.error("创建分拣任务时, 起始库位非空闲"); | |
1621 | + } | |
1622 | + zoneCode = fromLocation.getZoneCode(); | |
1623 | + taskLockEntity.setZoneCode(zoneCode); | |
1624 | + if (StringUtils.isNotEmpty(toLocationCode)) { | |
1625 | + Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode); | |
1626 | + if (toLocation == null) { | |
1627 | + return Result.error("创建分拣任务时," + toLocationCode + "目标库位不存在"); | |
1628 | + } | |
1629 | + if (StringUtils.isNotEmpty(toLocation.getContainerCode())) { | |
1630 | + return Result.error("创建分拣任务时," + toLocationCode + "上已存在容器" + toLocation.getContainerCode()); | |
1631 | + } | |
1632 | + if (!QuantityConstant.STATUS_LOCATION_EMPTY.equals(toLocation.getStatus())) { | |
1633 | + return Result.error("创建分拣任务时, 目标库位非空闲"); | |
1634 | + } | |
1635 | + } | |
1636 | + success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
1637 | + if (!success) { | |
1638 | + throw new JeecgBootException("创建分拣任务时,更新容器状态失败"); | |
1639 | + } | |
1640 | + success = locationService.updateStatus(fromLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
1641 | + if (!success) { | |
1642 | + throw new JeecgBootException("创建分拣任务时,更新库位状态失败"); | |
1643 | + } | |
1644 | + if (StringUtils.isNotEmpty(toLocationCode)) { | |
1645 | + success = locationService.updateStatus(toLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode); | |
1646 | + if (!success) { | |
1647 | + throw new JeecgBootException("创建分拣任务时,更新库位状态失败"); | |
1648 | + } | |
1649 | + } | |
1650 | + return Result.OK("创建分拣任务成功", taskLockEntity); | |
1651 | + } | |
1652 | + | |
1653 | + @Override | |
1654 | + @Transactional(rollbackFor = Exception.class) | |
1655 | + public Result createOverStationTaskLockContainer(String containerCode, String warehouseCode) { | |
1656 | + Container container = containerService.getContainerByCode(containerCode, warehouseCode); | |
1657 | + if (container == null) { | |
1658 | + return Result.error("创建跨站任务时,容器为空"); | |
1659 | + } | |
1660 | + if (!container.getStatus().equals(QuantityConstant.STATUS_CONTAINER_EMPTY)) { | |
1661 | + return Result.error("创建跨站任务时, 容器状态不为空闲状态"); | |
1662 | + } | |
1663 | + boolean success = containerService.updateStatus(containerCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode); | |
1664 | + if (!success) { | |
1665 | + throw new JeecgBootException("创建跨站任务时,更新容器状态失败"); | |
1666 | + } | |
1667 | + return Result.ok("创建跨站任务成功"); | |
1668 | + } | |
1669 | + | |
1670 | + /** | |
1581 | 1671 | * 完成空托盘入库任务 |
1582 | 1672 | * @param taskHeader 任务 |
1583 | 1673 | * @return Result 完成入库任务结果 |
... | ... |
huaheng-wms-core/src/main/java/org/jeecg/utils/constant/QuantityConstant.java