Commit 9d8ae2357274abd88be1338352bf855bcdfe66de

Authored by 肖超群
1 parent bf74d4a1

完善生成任务 锁定容器和库位

huaheng-wms-core/src/main/java/org/jeecg/modules/wms/shipment/shipmentCombination/service/impl/ShipmentCombinationServiceImpl.java
... ... @@ -34,6 +34,7 @@ import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentDetailServ
34 34 import org.jeecg.modules.wms.shipment.shipmentHeader.service.IShipmentHeaderService;
35 35 import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail;
36 36 import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
  37 +import org.jeecg.modules.wms.task.taskHeader.entity.TaskLockEntity;
37 38 import org.jeecg.modules.wms.task.taskHeader.service.ITaskDetailService;
38 39 import org.jeecg.modules.wms.task.taskHeader.service.ITaskHeaderService;
39 40 import org.jeecg.utils.StringUtils;
... ... @@ -513,7 +514,8 @@ public class ShipmentCombinationServiceImpl implements IShipmentCombinationServi
513 514 if (!result.isSuccess()) {
514 515 return result;
515 516 }
516   - String zoneCode = location.getZoneCode();
  517 + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult();
  518 + String zoneCode = taskLockEntity.getZoneCode();
517 519 TaskHeader taskHeader = new TaskHeader();
518 520 taskHeader.setPreTaskNo(preTaskNo);
519 521 taskHeader.setTaskType(taskType);
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/stocktaking/cycleCountDetail/service/impl/CycleCountDetailServiceImpl.java
... ... @@ -27,6 +27,7 @@ import org.jeecg.modules.wms.stocktaking.cycleCountHeader.entity.CycleCountHeade
27 27 import org.jeecg.modules.wms.stocktaking.cycleCountHeader.service.impl.CycleCountHeaderServiceImpl;
28 28 import org.jeecg.modules.wms.task.taskHeader.entity.TaskDetail;
29 29 import org.jeecg.modules.wms.task.taskHeader.entity.TaskHeader;
  30 +import org.jeecg.modules.wms.task.taskHeader.entity.TaskLockEntity;
30 31 import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskDetailServiceImpl;
31 32 import org.jeecg.modules.wms.task.taskHeader.service.impl.TaskHeaderServiceImpl;
32 33 import org.jeecg.utils.StringUtils;
... ... @@ -198,6 +199,7 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
198 199 * @return
199 200 */
200 201 @Override
  202 + @Transactional
201 203 public Result createCycleCoutTaskByDetailId(Integer cycleCoutDetailId, String toPort, String warehouseCode) {
202 204 /* 任务主表中存在库位,在盘点明细中生成任务时,不同的容器生成不同的主任务 */
203 205 // 校验有没有相同容器正在执行任务.
... ... @@ -214,32 +216,27 @@ public class CycleCountDetailServiceImpl extends ServiceImpl<CycleCountDetailMap
214 216 if (childList.size() < 1) {
215 217 return Result.error("盘点明细没有子单");
216 218 }
217   - Location location = locationService.getLocationByCode(cycleCountDetail.getLocationCode(), warehouseCode);
218   - if (!location.getStatus().equals(QuantityConstant.STATUS_LOCATION_EMPTY)) {
219   - return Result.error(cycleCountDetail.getLocationCode() + "库位不在空闲状态,请先完成其他任务,操作失败!");
220   - }
221   - if (StringUtils.isEmpty(location.getContainerCode())) {
222   - return Result.error(cycleCountDetail.getLocationCode() + "库位中没有容器,操作失败!");
223   - }
224   -
225   - // 生成任务同时锁定库位
226   - boolean success = locationService.updateStatus(location.getCode(), QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode);
227   - if (!success) {
228   - throw new JeecgBootException("更新库位状态失败");
  219 + String containerCode = cycleCountDetail.getContainerCode();
  220 + String fromLocationCode = cycleCountDetail.getLocationCode();
  221 + String toLocationCode = QuantityConstant.EMPTY_STRING;
  222 + String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_TASK_LOCATION);
  223 + int taskLocationRule = Integer.parseInt(value);
  224 + if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION) {
  225 + toLocationCode = fromLocationCode;
229 226 }
230   - // 生成任务同时锁定容器
231   - success = containerServiceImpl.updateStatus(location.getContainerCode(), QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode);
232   - if (!success) {
233   - throw new JeecgBootException("更新容器状态失败");
  227 + Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_CYCLECOUNT, containerCode, fromLocationCode, toLocationCode,
  228 + warehouseCode);
  229 + if (!result.isSuccess()) {
  230 + return result;
234 231 }
  232 + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult();
  233 + String zoneCode = taskLockEntity.getZoneCode();
235 234 // 每个明细单生成一张主任务,子单就是任务明细。
236 235 TaskHeader task = new TaskHeader();
237 236 task.setWarehouseCode(warehouseCode);
238 237 task.setCompanyCode(cycleCountDetail.getCompanyCode());
239 238 task.setShipmentContainerHeaderId(cycleCountDetail.getId());// 明细ID写入主任务
240   - if (location != null) {
241   - task.setZoneCode(location.getZoneCode());
242   - }
  239 + task.setZoneCode(zoneCode);
243 240 task.setInnernalTaskType(QuantityConstant.TASK_INTENERTYPE_CYCLECOUNT);
244 241 task.setTaskType(QuantityConstant.TASK_TYPE_CYCLECOUNT);
245 242 task.setContainerCode(cycleCountDetail.getContainerCode());
... ... @@ -250,15 +247,9 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
250 247 task.setShipmentContainerHeaderId(cycleCoutDetailId);
251 248 task.setSequence(1);
252 249 task.setShipmentOrder(System.currentTimeMillis());
253   -
254   - String value = parameterConfigurationService.getValueByCode(QuantityConstant.RULE_TASK_LOCATION);
255   - int taskLocationRule = Integer.parseInt(value);
256   - if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION) {
257   - task.setToLocationCode(cycleCountDetail.getLocationCode());
258   - }
  250 + task.setToLocationCode(toLocationCode);
259 251 if (taskHeaderService.save(task)) {
260 252 // 锁定库位状态
261   - locationService.updateStatus(location.getContainerCode(), QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode);
262 253 cycleCountDetail.setTaskHeaderId(task.getId()); // 盘点明细修改状态task数据源
263 254 } else {
264 255 throw new JeecgBootException("盘点任务主表生成失败!");
... ... @@ -308,15 +299,11 @@ public class CycleCountDetailServiceImpl extends ServiceImpl&lt;CycleCountDetailMap
308 299 cycleCountHeader.setStatusCyc(QuantityConstant.CYCLECOUNT_STATUS_BUILDTASK);
309 300 cycleCountHeaderService.updateById(cycleCountHeader);
310 301  
311   -// LambdaQueryWrapper<InventoryDetail> lambdaQueryWrapper = Wrappers.lambdaQuery();
312   -// lambdaQueryWrapper.eq(InventoryDetail::getContainerCode,task.getContainerCode());
313   -// List<InventoryDetail> inventoryDetails = inventoryDetailService.list(lambdaQueryWrapper);
314   -
315   - Result<Integer> result = new Result<Integer>();
316   - result.setCode(200);
317   - result.setMessage("盘点任务生成成功");
318   - result.setResult(cycleCountHeader.getId());
319   - return result;
  302 +// Result<Integer> result = new Result<Integer>();
  303 +// result.setCode(200);
  304 +// result.setMessage("盘点任务生成成功");
  305 +// result.setResult(cycleCountHeader.getId());
  306 + return Result.OK("盘点任务生成成功", cycleCountHeader.getId());
320 307 }
321 308  
322 309 @Override
... ...
huaheng-wms-core/src/main/java/org/jeecg/modules/wms/task/taskHeader/service/impl/TaskHeaderServiceImpl.java
... ... @@ -259,12 +259,14 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
259 259 if (!result.isSuccess()) {
260 260 return result;
261 261 }
  262 + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult();
  263 + String zoneCode = taskLockEntity.getZoneCode();
262 264 // 4. 判断源库位旁边有托盘但是没有任务,那么不允许移库
263 265 TaskHeader taskHeader = new TaskHeader();
264 266 taskHeader.setWarehouseCode(warehouseCode);
265 267 taskHeader.setTaskType(QuantityConstant.TASK_TYPE_TRANSFER);
266 268 taskHeader.setInnernalTaskType(QuantityConstant.TASK_INTENERTYPE_TRANSFER_POSITION);
267   - taskHeader.setZoneCode(fromLocation.getZoneCode());
  269 + taskHeader.setZoneCode(zoneCode);
268 270 taskHeader.setContainerCode(fromLocation.getContainerCode());
269 271 taskHeader.setFromLocationCode(fromLocationCode);
270 272 taskHeader.setToLocationCode(toLocationCode);
... ... @@ -303,23 +305,17 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
303 305 if (taskLocationRule == QuantityConstant.RULE_TASK_SET_LOCATION) {
304 306 toLocationCode = fromLocationCode;
305 307 }
306   - if (StringUtils.isEmpty(fromLocationCode)) {
307   - return Result.error("创建出库查看任务时,容器不在库位上");
308   - }
309   - Location location = locationService.getLocationByCode(fromLocationCode, warehouseCode);
310   - if (location == null) {
311   - return Result.error("创建出库查看任务时,没有找到库位:" + fromLocationCode);
312   - }
313   - String zoneCode = location.getZoneCode();
314   - Port port = portService.getPortByCode(toPortCode, zoneCode, warehouseCode);
315   - if (port == null) {
316   - return Result.error("创建出库查看任务时,没有找到出库口:" + toPortCode);
317   - }
318 308 Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_CHECK_OUT, containerCode, fromLocationCode, toLocationCode,
319 309 warehouseCode);
320 310 if (!result.isSuccess()) {
321 311 return result;
322 312 }
  313 + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult();
  314 + String zoneCode = taskLockEntity.getZoneCode();
  315 + Port port = portService.getPortByCode(toPortCode, zoneCode, warehouseCode);
  316 + if (port == null) {
  317 + throw new JeecgBootException("创建出库查看任务时,没有找到出库口:" + toPortCode);
  318 + }
323 319 boolean success = false;
324 320 LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
325 321 inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getContainerCode, containerCode).eq(InventoryDetail::getWarehouseCode, warehouseCode)
... ... @@ -477,16 +473,13 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
477 473 return Result.error("创建空托盘组入库任务时,仓库编码为空");
478 474 }
479 475 log.info("开始创建空托盘组入库任务,容器编码" + containerCode + ",库位编码" + toLocationCode);
480   - String zoneCode = null;
481 476 Result result = taskHeaderService.createTaskLockContainerAndLocation(QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT, containerCode,
482 477 QuantityConstant.EMPTY_STRING, toLocationCode, warehouseCode);
483 478 if (!result.isSuccess()) {
484 479 return result;
485 480 }
486   - if (StringUtils.isNotEmpty(toLocationCode)) {
487   - Location toLocation = locationService.getLocationByCode(toLocationCode, warehouseCode);
488   - zoneCode = toLocation.getZoneCode();
489   - }
  481 + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult();
  482 + String zoneCode = taskLockEntity.getZoneCode();
490 483 TaskHeader taskHeader = new TaskHeader();
491 484 taskHeader.setWarehouseCode(warehouseCode);
492 485 taskHeader.setContainerCode(containerCode);
... ... @@ -521,16 +514,10 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
521 514 if (!result.isSuccess()) {
522 515 return result;
523 516 }
  517 + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult();
  518 + String zoneCode = taskLockEntity.getZoneCode();
524 519 Container container = containerService.getContainerByCode(containerCode, warehouseCode);
525 520 String fromLocationCode = container.getLocationCode();
526   - Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode);
527   - if (fromLocation == null) {
528   - return Result.error("创建空托盘组出库任务时, 没有找到库位:" + fromLocationCode);
529   - }
530   - String zoneCode = fromLocation.getZoneCode();
531   - if (StringUtils.isEmpty(zoneCode)) {
532   - return Result.error("创建空托盘组出库任务时, 库区为空");
533   - }
534 521 TaskHeader taskHeader = new TaskHeader();
535 522 taskHeader.setWarehouseCode(warehouseCode);
536 523 taskHeader.setZoneCode(zoneCode);
... ... @@ -960,14 +947,8 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
960 947 if (!result.isSuccess()) {
961 948 return result;
962 949 }
963   - Location fromLocation = locationService.getLocationByCode(fromLocationCode, warehouseCode);
964   - if (fromLocation == null) {
965   - return Result.error("创建空托盘出库时, 起始库位为空");
966   - }
967   - String zoneCode = fromLocation.getZoneCode();
968   - if (StringUtils.isEmpty(zoneCode)) {
969   - return Result.error("创建空托盘出库时, 起始库位的库区为空");
970   - }
  950 + TaskLockEntity taskLockEntity = (TaskLockEntity)result.getResult();
  951 + String zoneCode = taskLockEntity.getZoneCode();
971 952 Port port = portService.getPortByCode(toPortCode, zoneCode, warehouseCode);
972 953 if (port == null) {
973 954 return Result.error("创建空托盘出库时, 没有找到出库口" + toPortCode);
... ...