Commit 0fb2fcb5495ba25f7395d909640f9b2e2ded941c

Authored by 易文鹏
1 parent c225c241

feat:解除右侧库位禁用状态和对应4个库位标记。(取消任务、重复分配库位、分拣出库,整盘出库、空托盘出库、补充入库、完成移库任务)

src/main/java/com/huaheng/api/wcs/service/taskAssignService/TaskAssignServiceImpl.java
... ... @@ -7,6 +7,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
7 7 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
8 8 import com.huaheng.api.wcs.domain.TaskDetails;
9 9 import com.huaheng.api.wcs.domain.WcsTask;
  10 +import com.huaheng.api.wcs.service.warecellAllocation.LocationAllocationService;
10 11 import com.huaheng.common.constant.HttpConstant;
11 12 import com.huaheng.common.constant.QuantityConstant;
12 13 import com.huaheng.common.exception.service.ServiceException;
... ... @@ -48,7 +49,8 @@ import java.util.List;
48 49  
49 50 @Service
50 51 public class TaskAssignServiceImpl implements TaskAssignService {
51   -
  52 + @Resource
  53 + private LocationAllocationService locationAllocationService;
52 54 @Autowired
53 55 private AddressService addressService;
54 56 @Autowired
... ... @@ -142,22 +144,44 @@ public class TaskAssignServiceImpl implements TaskAssignService {
142 144  
143 145 // 出库动作
144 146 if (!direction) {
145   - int rowFlag = location.getRowFlag().intValue();
  147 + int rowFlag = location.getRowFlag();
146 148 //如果是外侧库位
147 149 if (rowFlag == QuantityConstant.ROW_OUT) {
148 150 Location insideLocation = locationService.getInsideNear(location);
149 151 String insideLocationCode = insideLocation.getCode();
150 152 if (StringUtils.isNotEmpty(insideLocation.getContainerCode())) {
151   - LambdaQueryWrapper<TaskHeader> lambdaWrapper = Wrappers.lambdaQuery();
152   - lambdaWrapper.eq(TaskHeader::getFromLocation, insideLocationCode);
153   - lambdaWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
154   - TaskHeader taskHeader2 = taskHeaderService.getOne(lambdaWrapper);
  153 + TaskHeader taskHeader2 = taskHeaderService.getOne(new LambdaQueryWrapper<TaskHeader>().eq(TaskHeader::getFromLocation, insideLocationCode).lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED));
155 154 if (taskHeader2 != null) {
156 155 preTaskNo = taskHeader2.getId();
157 156 } else {
158   - Location destinationLocation = locationService.getEmptyLocation(insideLocation);
159   - if (destinationLocation == null) {
160   - return AjaxResult.error("移库没有剩余库位");
  157 + Location destinationLocation = null;
  158 + if (insideLocation.getRoadway().equals("5")) {
  159 + //分配库位
  160 + //是否自建单据库位
  161 + int isSelfCreated = 0;
  162 + if (insideLocation.getSelfCreated()) {
  163 + isSelfCreated = 1;
  164 + }
  165 + boolean isFlammable = true;
  166 + if (insideLocation.getILayer() > 3) {
  167 + isFlammable = false;
  168 + }
  169 + String destinationLocationCode = locationAllocationService.allocation(insideLocation.getHigh(), insideLocation.getArea(), "5",
  170 + containerCode, insideLocation.getFrequencyLocation(), insideLocation.getOnlyEmptyContainer(), isSelfCreated, isFlammable);
  171 + if (StringUtils.isEmpty(destinationLocationCode)) {
  172 + return AjaxResult.error("移库没有剩余库位");
  173 + } else if (destinationLocationCode.length() > 10) {
  174 + return AjaxResult.error(destinationLocationCode);
  175 + }
  176 + //锁定库位
  177 + int updateCount2 = locationService.updateStatusNew(destinationLocationCode, warehouseCode, QuantityConstant.STATUS_LOCATION_LOCK, QuantityConstant.STATUS_LOCATION_EMPTY);
  178 + if (updateCount2 != 1) {
  179 + throw new ServiceException("库位已经锁定,不允许再分到这个库位");
  180 + }
  181 + destinationLocation = locationService.getLocationByCode(destinationLocationCode);
  182 + } else {
  183 + //获取一个最近的空闲库位(优先找外侧)
  184 + destinationLocation = locationService.getEmptyLocation(insideLocation);
161 185 }
162 186 AjaxResult ajaxResult = transferTaskService.createTransferTask(insideLocation.getCode(), destinationLocation.getCode(), warehouseCode);
163 187 if (ajaxResult.getCode() == 400) {
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/ReceiptTaskService.java
... ... @@ -334,6 +334,10 @@ public class ReceiptTaskService {
334 334 location.setContainerCode("");
335 335 location.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY);
336 336 locationService.updateById(location);
  337 +
  338 + //解除右侧库位禁用和对应4个库位标记
  339 + Container container = containerService.getContainerByCode(task.getContainerCode());
  340 + locationService.unbanRightLocationAndUnmark(container.getContainerType(), locationCode);
337 341 inventoryHeader.setLocationCode(task.getToLocation());
338 342 inventoryHeaderService.updateById(inventoryHeader);
339 343  
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/ShipmentTaskService.java
... ... @@ -129,11 +129,11 @@ public class ShipmentTaskService {
129 129 if (shipmentContainerDetails.isEmpty()) {
130 130 return AjaxResult.error("货箱" + shipmentContainerHeader.getContainerCode() + "没有子任务,操作中止");
131 131 }
  132 + LambdaQueryWrapper<Container> containerWrapper = Wrappers.lambdaQuery();
  133 + containerWrapper.eq(Container::getCode, shipmentContainerHeader.getContainerCode());
  134 + Container container = containerService.getOne(containerWrapper);
  135 +
132 136  
133   - LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery();
134   - containerLambdaQueryWrapper.eq(Container::getCode, shipmentContainerHeader.getContainerCode())
135   - .eq(Container::getWarehouseCode, ShiroUtils.getWarehouseCode());
136   - Container container = containerService.getOne(containerLambdaQueryWrapper);
137 137 if (StringUtils.isNull(container)) {
138 138 return AjaxResult.error("托盘不存在!");
139 139 }
... ... @@ -141,25 +141,15 @@ public class ShipmentTaskService {
141 141 return AjaxResult.error("托盘已经锁定!");
142 142 }
143 143 String locationCode = shipmentContainerHeader.getLocationCode();
144   -
145   - //防止重复点击生成重复的任务
146   - //List<TaskHeader> tasks = taskHeaderService.list(new LambdaQueryWrapper<TaskHeader>()
147   - // .eq(TaskHeader::getStatus, 1)
148   - // .eq(TaskHeader::getFromLocation, locationCode));
149   - //if (!tasks.isEmpty()) {
150 144 int count = containerHeaderService.count(new LambdaQueryWrapper<ShipmentContainerHeader>()
151 145 .eq(ShipmentContainerHeader::getStatus, 0)
152 146 .eq(ShipmentContainerHeader::getLocationCode, locationCode));
153 147 if (count == 0) {
154 148 return AjaxResult.error("没有新建状态的出库组盘,无法生成出库任务!");
155 149 }
156   - //}
  150 +
157 151 //检测库位
158   - LambdaQueryWrapper<Location> locationLambdaQueryWrapper = Wrappers.lambdaQuery();
159   - locationLambdaQueryWrapper.eq(Location::getCode, locationCode)
160   - .eq(Location::getWarehouseCode, ShiroUtils.getWarehouseCode())
161   - .eq(Location::getDeleted, false);
162   - Location location = locationService.getOne(locationLambdaQueryWrapper);
  152 + Location location = locationService.getLocationByCode(locationCode);
163 153 if (StringUtils.isNull(location)) {
164 154 return AjaxResult.error("库位禁用或不存在!");
165 155 }
... ... @@ -179,7 +169,7 @@ public class ShipmentTaskService {
179 169 //平库生成出库任务不锁定库位和容器
180 170 if (container.getFlat() == null || container.getFlat() != 1) {
181 171 container.setStatus(QuantityConstant.STATUS_CONTAINER_LOCK);
182   - containerService.update(container, containerLambdaQueryWrapper);
  172 + containerService.update(container, containerWrapper);
183 173 locationService.updateStatus(location.getCode(), QuantityConstant.STATUS_LOCATION_LOCK);
184 174 }
185 175 //创建任务头
... ... @@ -197,11 +187,8 @@ public class ShipmentTaskService {
197 187 //这里必须与库存的在库数量对比,后期可能存在一个配盘在执行任务,后一个配盘又在配这个的情况(这个时候不能整出)
198 188 //如果相等,则说明这个货箱包含了所有的数量,则可以整出,否则,创建拣选任务;
199 189 //查询所有库存
  190 + List<InventoryDetail> inventories = inventoryDetailService.list(new LambdaQueryWrapper<InventoryDetail>().eq(InventoryDetail::getLocationCode, locationCode));
200 191  
201   - LambdaQueryWrapper<InventoryDetail> inventoryDetailLambdaQueryWrapper = Wrappers.lambdaQuery();
202   - inventoryDetailLambdaQueryWrapper.eq(InventoryDetail::getLocationCode, locationCode)
203   - .eq(InventoryDetail::getWarehouseCode, ShiroUtils.getWarehouseCode());
204   - List<InventoryDetail> inventories = inventoryDetailService.list(inventoryDetailLambdaQueryWrapper);
205 192 BigDecimal inventoryTotal = new BigDecimal("0");
206 193 for (InventoryDetail item : inventories) {
207 194 inventoryTotal = inventoryTotal.add(item.getQty());
... ... @@ -319,7 +306,7 @@ public class ShipmentTaskService {
319 306 //获取任务明细
320 307 List<TaskDetail> taskDetails = taskDetailService.findByTaskId(task.getId());
321 308  
322   - if (task.getStatus().intValue() == QuantityConstant.TASK_STATUS_COMPLETED) {
  309 + if (task.getStatus() == QuantityConstant.TASK_STATUS_COMPLETED) {
323 310 throw new ServiceException("任务已完成");
324 311 }
325 312  
... ... @@ -336,23 +323,27 @@ public class ShipmentTaskService {
336 323 }
337 324 String warehouseCode = task.getWarehouseCode();
338 325 InventoryHeader inventoryHeader = null;
  326 + //分拣出库,解锁库位和标记
339 327 if (task.getTaskType().equals(QuantityConstant.TASK_TYPE_SORTINGSHIPMENT)) {
340   - LambdaQueryWrapper<InventoryHeader> lambdaQueryWrapper = Wrappers.lambdaQuery();
341   - lambdaQueryWrapper.eq(InventoryHeader::getWarehouseCode, warehouseCode)
  328 +
  329 + inventoryHeader = inventoryHeaderService.getOne(new LambdaQueryWrapper<InventoryHeader>()
342 330 .eq(InventoryHeader::getLocationCode, task.getFromLocation())
343   - .eq(InventoryHeader::getContainerCode, task.getContainerCode());
344   - inventoryHeader = inventoryHeaderService.getOne(lambdaQueryWrapper);
  331 + .eq(InventoryHeader::getContainerCode, task.getContainerCode()));
  332 +
345 333 if (inventoryHeader != null) {
346 334 String locationCode = inventoryHeader.getLocationCode();
347 335 Location location = locationService.getLocationByCode(locationCode, warehouseCode);
348 336 location.setStatus(QuantityConstant.STATUS_LOCATION_EMPTY);
349 337 locationService.updateById(location);
  338 +
  339 + Container container = containerService.getContainerByCode(task.getContainerCode());
  340 + //解除右侧库位禁用状态和对应4个库位标记
  341 + locationService.unbanRightLocationAndUnmark(container.getContainerType(), locationCode);
  342 +
350 343 inventoryHeader.setLocationCode(task.getToLocation());
351 344 inventoryHeaderService.updateById(inventoryHeader);
352   - LambdaQueryWrapper<InventoryDetail> lambdaQueryWrapper2 = Wrappers.lambdaQuery();
353   - lambdaQueryWrapper2.eq(InventoryDetail::getWarehouseCode, warehouseCode)
354   - .eq(InventoryDetail::getInventoryHeaderId, inventoryHeader.getId());
355   - List<InventoryDetail> inventoryDetails = inventoryDetailService.list(lambdaQueryWrapper2);
  345 +
  346 + List<InventoryDetail> inventoryDetails = inventoryDetailService.list(new LambdaQueryWrapper<InventoryDetail>().eq(InventoryDetail::getInventoryHeaderId, inventoryHeader.getId()));
356 347 if (inventoryDetails != null && !inventoryDetails.isEmpty()) {
357 348 for (InventoryDetail inventoryDetail : inventoryDetails) {
358 349 inventoryDetail.setLocationCode(task.getToLocation());
... ... @@ -571,16 +562,19 @@ public class ShipmentTaskService {
571 562 * @param containerCode 容器编码
572 563 * @param taskType 任务类型
573 564 */
574   - public void updateShipmentLocationContainer(String fromLocation, String toLocation,
575   - String containerCode, Integer taskType, String warehouseCode) {
  565 + public void updateShipmentLocationContainer(String fromLocation, String toLocation, String containerCode, Integer taskType, String warehouseCode) {
  566 + Container container = containerService.getContainerByCode(containerCode, warehouseCode);
  567 + if (StringUtils.isEmpty(containerCode)) {
  568 + throw new ServiceException("系统无" + container + "容器");
  569 + }
  570 +
576 571 //将库位状态改为空闲,如果是整出的对应的容器也清空
577 572 Location fromLocationRecord = locationService.getLocationByCode(fromLocation, warehouseCode);
578 573 if (StringUtils.isNull(fromLocationRecord)) {
579 574 throw new ServiceException("系统没有" + fromLocation + "库位");
580 575 }
581 576 /* 如果目标库位与源库位不一样时,需要更新两个库位*/
582   - if (StringUtils.isNotEmpty(toLocation)
583   - && !fromLocation.equals(toLocation)) {
  577 + if (StringUtils.isNotEmpty(toLocation) && !fromLocation.equals(toLocation)) {
584 578 Location toLocationRecord = locationService.getLocationByCode(toLocation, warehouseCode);
585 579 if (StringUtils.isNull(fromLocationRecord)) {
586 580 throw new ServiceException("系统没有" + toLocation + "库位");
... ... @@ -600,11 +594,8 @@ public class ShipmentTaskService {
600 594 fromLocationRecord.setContainerCode("");
601 595 }
602 596 locationService.updateById(fromLocationRecord);
603   -
604   - Container container = containerService.getContainerByCode(containerCode, warehouseCode);
605   - if (StringUtils.isEmpty(containerCode)) {
606   - throw new ServiceException("系统无" + container + "容器");
607   - }
  597 + //解除右侧库位禁用状态和对应4个库位标记
  598 + locationService.unbanRightLocationAndUnmark(container.getContainerType(), fromLocation);
608 599  
609 600 if (taskType.equals(QuantityConstant.TASK_TYPE_WHOLESHIPMENT)) {
610 601 if ("LS".equals(container.getContainerType())) {
... ... @@ -612,8 +603,7 @@ public class ShipmentTaskService {
612 603 throw new ServiceException("删除临时容器失败");
613 604 }
614 605 } else {
615   - containerService.updateLocationCodeAndStatus(containerCode, "",
616   - QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
  606 + containerService.updateLocationCodeAndStatus(containerCode, "", QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
617 607 }
618 608 } else {
619 609 //查询是否存在关联的库存,入如果没有就修改容器状态为empty
... ... @@ -622,11 +612,9 @@ public class ShipmentTaskService {
622 612 List<InventoryDetail> detailList = inventoryDetailService.list(inventoryDetaillambdaQueryWrapper);
623 613 //库存查询不到该容器就把容器状态改为可用
624 614 if (detailList.isEmpty()) {
625   - containerService.updateLocationCodeAndStatus(containerCode, toLocation,
626   - QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
  615 + containerService.updateLocationCodeAndStatus(containerCode, toLocation, QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
627 616 } else {
628   - containerService.updateLocationCodeAndStatus(containerCode, toLocation,
629   - QuantityConstant.STATUS_CONTAINER_SOME, warehouseCode);
  617 + containerService.updateLocationCodeAndStatus(containerCode, toLocation, QuantityConstant.STATUS_CONTAINER_SOME, warehouseCode);
630 618 }
631 619 }
632 620 }
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... ... @@ -279,19 +279,24 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
279 279 }
280 280  
281 281 private void cancelLocationAndContainerStatus(TaskHeader taskHeader) {
282   - if (taskHeader.getFromLocation() != null) {
  282 + Container container = containerService.getContainerByCode(taskHeader.getContainerCode());
  283 + if (StringUtils.isNotEmpty(taskHeader.getFromLocation())) {
283 284 //更新托盘、库位状态
284 285 locationService.updateStatus(taskHeader.getFromLocation(), QuantityConstant.STATUS_LOCATION_EMPTY);
  286 + //解除右侧库位禁用状态和对应4个库位标记
  287 + locationService.unbanRightLocationAndUnmark(container.getContainerType(), taskHeader.getFromLocation());
285 288 }
286   - if (taskHeader.getToLocation() != null) {
  289 + if (StringUtils.isNotEmpty(taskHeader.getToLocation())) {
287 290 //更新托盘、库位状态
288 291 locationService.updateStatus(taskHeader.getToLocation(), QuantityConstant.STATUS_LOCATION_EMPTY);
  292 + //解除右侧库位禁用状态和对应4个库位标记
  293 + locationService.unbanRightLocationAndUnmark(container.getContainerType(), taskHeader.getToLocation());
289 294 }
290 295  
291 296 InventoryHeader inventoryHeader = inventoryHeaderService.getOne(new LambdaQueryWrapper<InventoryHeader>()
292 297 .eq(InventoryHeader::getContainerCode, taskHeader.getContainerCode()));
293 298  
294   - Container container = containerService.getContainerByCode(taskHeader.getContainerCode());
  299 +
295 300 String lastStatus = container.getLastStatus();
296 301 container.setStatus(QuantityConstant.STATUS_CONTAINER_EMPTY);
297 302  
... ... @@ -432,21 +437,24 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
432 437 case QuantityConstant.TASK_TYPE_EMPTYSHIPMENT:
433 438 ajaxResult = workTaskService.completeEmptyOut(task);
434 439 break;
  440 + //盘点
435 441 case QuantityConstant.TASK_TYPE_CYCLECOUNT:
436 442 ajaxResult = cycleCountTaskService.completeCycleCountTask(task);
437 443 break;
  444 + //移库
438 445 case QuantityConstant.TASK_TYPE_TRANSFER:
439 446 ajaxResult = transferTaskService.completeTransferTask(task);
440 447 break;
  448 + //出库查看
441 449 case QuantityConstant.TASK_TYPE_VIEW:
442 450 ajaxResult = workTaskService.completeCheckOutTask(task);
443 451 break;
444   - case QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT:
445   - ajaxResult = workTaskService.completeManyEmptyIn(task);
446   - break;
447   - case QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT:
448   - ajaxResult = workTaskService.completeManyEmptyOut(task);
449   - break;
  452 + //case QuantityConstant.TASK_TYPE_MANY_EMPTYRECEIPT:
  453 + // ajaxResult = workTaskService.completeManyEmptyIn(task);
  454 + // break;
  455 + //case QuantityConstant.TASK_TYPE_MANY_EMPTYSHIPMENT:
  456 + // ajaxResult = workTaskService.completeManyEmptyOut(task);
  457 + // break;
450 458 default:
451 459 throw new ServiceException("不支持的任务类型");
452 460 }
... ... @@ -761,7 +769,7 @@ public class TaskHeaderServiceImpl extends ServiceImpl&lt;TaskHeaderMapper, TaskHea
761 769 if (locations.size() == 0) {
762 770 throw new ServiceException("没有空闲库位!");
763 771 }
764   - // TODO
  772 +
765 773 //随机取库位
766 774 Random rand = new Random();
767 775 Location location = locations.get(rand.nextInt(locations.size()));
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/TransferTaskService.java
... ... @@ -91,22 +91,18 @@ public class TransferTaskService {
91 91 if (StringUtils.isNotEmpty(desLocation.getContainerCode())) {
92 92 return AjaxResult.error("目标库位:" + desLocationCode + "存在托盘");
93 93 }
94   -
95 94 if (taskHeaderService.getUncompleteTaskInNear(desLocation) > 0) {
96 95 return AjaxResult.error("目标库位:" + desLocationCode + "旁边存在任务,请完成任务以后再分配");
97 96 }
98 97 if (!sourceLocation.getRoadway().equals(desLocation.getRoadway())) {
99 98 return AjaxResult.error("目标库位和源库位不在同一个巷道");
100 99 }
101   -
102 100 if (!sourceLocation.getHigh().equals(desLocation.getHigh())) {
103 101 return AjaxResult.error("目标库位和源库位高度不一样");
104 102 }
105   -
106 103 if (!sourceLocation.getLocationType().equals(desLocation.getLocationType())) {
107 104 return AjaxResult.error("目标库位和源库位库位类型不一样");
108 105 }
109   -
110 106 if (!sourceLocation.getArea().equals(desLocation.getArea())) {
111 107 return AjaxResult.error("目标库位和源库位不在同一个区域");
112 108 }
... ... @@ -117,25 +113,21 @@ public class TransferTaskService {
117 113 containerService.updateById(container);
118 114  
119 115 if (sourceLocation.getRowFlag() == QuantityConstant.ROW_OUT) {
120   - Location location1 = locationService.getNear(sourceLocation); //内侧库位
121   - String locationCode = location1.getCode();
122   - if (StringUtils.isNotEmpty(location1.getContainerCode())) {
123   - LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
124   - taskHeaderLambdaQueryWrapper.eq(TaskHeader::getFromLocation, locationCode)
  116 + Location medialLocation = locationService.getNear(sourceLocation); //内侧库位
  117 + String locationCode = medialLocation.getCode();
  118 + if (StringUtils.isNotEmpty(medialLocation.getContainerCode())) {
  119 + TaskHeader taskHeader = taskHeaderService.getOne(new LambdaQueryWrapper<TaskHeader>()
125 120 .eq(TaskHeader::getWarehouseCode, warehouseCode)
126   - .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
127   - TaskHeader taskHeader = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
  121 + .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED));
128 122 if (taskHeader != null) {
129 123 preTaskNo = taskHeader.getId();
130 124 } else {
131 125 return AjaxResult.error("源库位:" + sourceLocationCode + "旁边库位有托盘无法移库");
132 126 }
133 127 } else {
134   - LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery();
135   - taskHeaderLambdaQueryWrapper.eq(TaskHeader::getToLocation, locationCode)
136   - .eq(TaskHeader::getWarehouseCode, warehouseCode)
137   - .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED);
138   - TaskHeader taskHeader = taskHeaderService.getOne(taskHeaderLambdaQueryWrapper);
  128 + TaskHeader taskHeader = taskHeaderService.getOne(new LambdaQueryWrapper<TaskHeader>()
  129 + .eq(TaskHeader::getToLocation, locationCode)
  130 + .lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED));
139 131 if (taskHeader != null) {
140 132 return AjaxResult.error("源库位:" + sourceLocationCode + "旁边库位有任务无法移库");
141 133 }
... ... @@ -162,18 +154,13 @@ public class TransferTaskService {
162 154 }
163 155 locationService.updateStatus(sourceLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode);
164 156 // locationService.updateStatus(desLocationCode, QuantityConstant.STATUS_LOCATION_LOCK, warehouseCode);
165   - int updateCount = locationService.updateStatusNew(desLocationCode, warehouseCode,
166   - QuantityConstant.STATUS_LOCATION_LOCK, QuantityConstant.STATUS_LOCATION_EMPTY);
  157 + int updateCount = locationService.updateStatusNew(desLocationCode, warehouseCode, QuantityConstant.STATUS_LOCATION_LOCK, QuantityConstant.STATUS_LOCATION_EMPTY);
167 158 if (updateCount != 1) {
168 159 throw new ServiceException("库位已经锁定,不允许再分到这个库位");
169 160 }
170   - containerService.updateLocationCodeAndStatus(sourceLocation.getContainerCode(),
171   - sourceLocationCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode);
172   -
173   - LambdaUpdateWrapper<InventoryDetail> detailLambdaUpdateWrapper = Wrappers.lambdaUpdate();
174   - detailLambdaUpdateWrapper.eq(InventoryDetail::getWarehouseCode, warehouseCode);
175   - detailLambdaUpdateWrapper.eq(InventoryDetail::getLocationCode, sourceLocationCode);
176   - List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(detailLambdaUpdateWrapper);
  161 + containerService.updateLocationCodeAndStatus(sourceLocation.getContainerCode(), sourceLocationCode, QuantityConstant.STATUS_CONTAINER_LOCK, warehouseCode);
  162 + List<InventoryDetail> inventoryDetailList = inventoryDetailService.list(new LambdaQueryWrapper<InventoryDetail>()
  163 + .eq(InventoryDetail::getLocationCode, sourceLocationCode));
177 164 for (InventoryDetail inventoryDetail : inventoryDetailList) {
178 165 TaskDetail taskDetail = new TaskDetail();
179 166 taskDetail.setTaskId(taskHeader.getId());
... ... @@ -225,8 +212,7 @@ public class TransferTaskService {
225 212 String warehouseCode = taskHeader.getWarehouseCode();
226 213 InventoryDetail inventoryDetail = null;
227 214  
228   - Container container1 = containerService.getContainerByCode(
229   - taskHeader.getContainerCode(), warehouseCode);
  215 + Container container1 = containerService.getContainerByCode(taskHeader.getContainerCode(), warehouseCode);
230 216 container1.setMovementCount(container1.getMovementCount() + 1);
231 217 containerService.updateById(container1);
232 218  
... ... @@ -267,43 +253,39 @@ public class TransferTaskService {
267 253 inventoryTransaction.setZoneCode(inventoryDetail.getZoneCode());
268 254 inventoryTransactionService.save(inventoryTransaction);
269 255 }
270   - if (taskDetailList.size() != 0) {
  256 + if (!taskDetailList.isEmpty()) {
271 257 taskDetailService.saveOrUpdateBatch(taskDetailList);
272 258 }
273 259 if (!taskHeaderService.saveOrUpdate(taskHeader)) {
274 260 throw new ServiceException("任务单据状态更新失败!");
275 261 }
276 262 if (inventoryDetail != null) {
277   - containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(),
278   - taskHeader.getToLocation(), QuantityConstant.STATUS_CONTAINER_SOME, warehouseCode);
  263 + containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(), taskHeader.getToLocation(), QuantityConstant.STATUS_CONTAINER_SOME, warehouseCode);
279 264 } else {
280 265 Container container = containerService.getContainerByCode(taskHeader.getContainerCode());
281 266 if (container.getLastStatus().equalsIgnoreCase(QuantityConstant.STATUS_CONTAINER_MANY)) {
282 267 //恢复托盘组的状态
283   - containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(),
284   - taskHeader.getToLocation(), QuantityConstant.STATUS_CONTAINER_MANY, warehouseCode);
  268 + containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(), taskHeader.getToLocation(), QuantityConstant.STATUS_CONTAINER_MANY, warehouseCode);
285 269 container = containerService.getContainerByCode(taskHeader.getContainerCode());
286 270 container.setLastStatus(QuantityConstant.EMPTY_STRING);
287 271 containerService.updateById(container);
288 272 } else {
289   - containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(),
290   - taskHeader.getToLocation(), QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
  273 + containerService.updateLocationCodeAndStatus(taskHeader.getContainerCode(), taskHeader.getToLocation(), QuantityConstant.STATUS_CONTAINER_EMPTY, warehouseCode);
291 274 }
292 275 }
293   - locationService.updateContainerCodeAndStatus(taskHeader.getFromLocation(), "",
294   - QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);
295   - locationService.updateContainerCodeAndStatus(taskHeader.getToLocation(), taskHeader.getContainerCode(),
296   - QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);
  276 + locationService.updateContainerCodeAndStatus(taskHeader.getFromLocation(), "", QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);
  277 + //解除右侧库位禁用和对应4个库位标记
  278 + Container container = containerService.getContainerByCode(taskHeader.getContainerCode());
  279 + locationService.unbanRightLocationAndUnmark(container.getContainerType(), taskHeader.getFromLocation());
  280 +
  281 + locationService.updateContainerCodeAndStatus(taskHeader.getToLocation(), taskHeader.getContainerCode(), QuantityConstant.STATUS_LOCATION_EMPTY, warehouseCode);
297 282 inventoryHeadIdList = inventoryHeadIdList.stream().distinct().collect(Collectors.toList());
298 283 LambdaUpdateWrapper<InventoryHeader> headerUpdateWrapper = Wrappers.lambdaUpdate();
299   - headerUpdateWrapper.set(InventoryHeader::getLocationCode, taskHeader.getToLocation())
300   - .in(InventoryHeader::getId, inventoryHeadIdList);
  284 + headerUpdateWrapper.set(InventoryHeader::getLocationCode, taskHeader.getToLocation()).in(InventoryHeader::getId, inventoryHeadIdList);
301 285 LambdaUpdateWrapper<InventoryDetail> detailUpdateWrapper = Wrappers.lambdaUpdate();
302   - detailUpdateWrapper.set(InventoryDetail::getLocationCode, taskHeader.getToLocation())
303   - .in(InventoryDetail::getInventoryHeaderId, inventoryHeadIdList);
304   - if (inventoryHeadIdList.size() != 0) {
305   - if (!inventoryHeaderService.update(headerUpdateWrapper) ||
306   - !inventoryDetailService.update(detailUpdateWrapper)) {
  286 + detailUpdateWrapper.set(InventoryDetail::getLocationCode, taskHeader.getToLocation()).in(InventoryDetail::getInventoryHeaderId, inventoryHeadIdList);
  287 + if (!inventoryHeadIdList.isEmpty()) {
  288 + if (!inventoryHeaderService.update(headerUpdateWrapper) || !inventoryDetailService.update(detailUpdateWrapper)) {
307 289 throw new ServiceException("完成任务失败");
308 290 }
309 291 }
... ...
src/main/java/com/huaheng/pc/task/taskHeader/service/WorkTaskService.java
... ... @@ -673,10 +673,11 @@ public class WorkTaskService {
673 673 throw new ServiceException("容器状态更新失败!");
674 674 }
675 675  
676   -
  676 + Container container = containerService.getContainerByCode(taskHeader.getContainerCode());
677 677 //解锁库位
678   - locationService.updateContainerCodeAndStatus(taskHeader.getFromLocation(),
679   - "", QuantityConstant.STATUS_LOCATION_EMPTY, taskHeader.getWarehouseCode());
  678 + locationService.updateContainerCodeAndStatus(taskHeader.getFromLocation(), "", QuantityConstant.STATUS_LOCATION_EMPTY, taskHeader.getWarehouseCode());
  679 + //解除右侧库位禁用状态和对应4个库位标记
  680 + locationService.unbanRightLocationAndUnmark(container.getContainerType(), taskHeader.getFromLocation());
680 681 return AjaxResult.success();
681 682 }
682 683  
... ...