Commit e30e904b45f8d870389703ba63d952dcf40c9b73
1 parent
2c80bc2c
修改出库,将锁定库位提前到组盘。修改的有出组盘,取消组盘,生成任务,取消任务
Showing
3 changed files
with
81 additions
and
80 deletions
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderServiceImpl.java
... | ... | @@ -120,9 +120,6 @@ public class ReceiptContainerHeaderServiceImpl implements IReceiptContainerHeade |
120 | 120 | if (receiptContainerHeader.getStatus() > 0) { |
121 | 121 | return AjaxResult.error("配盘单已经下发,不能删除!"); |
122 | 122 | } |
123 | - //修改库位状态 | |
124 | - locationService.updateStatus(receiptContainerHeader.getLocationCode(), "empty"); | |
125 | - | |
126 | 123 | ReceiptContainerDetail receiptContainerDetail = new ReceiptContainerDetail(); |
127 | 124 | receiptContainerDetail.setHeaderId(id); |
128 | 125 | List<ReceiptContainerDetail> list = receiptContainerDetailService.selectListEntityByEqual(receiptContainerDetail); |
... | ... | @@ -132,9 +129,7 @@ public class ReceiptContainerHeaderServiceImpl implements IReceiptContainerHeade |
132 | 129 | //将已收货数量为0的入库单据明细状态改为0 |
133 | 130 | receiptContainerDetailMapper.updateReceiptDetailStatus(item.getReceiptDetailId()); |
134 | 131 | //删除配盘明细 |
135 | - ReceiptContainerDetail condition = new ReceiptContainerDetail(); | |
136 | - condition.setHeaderId(id); | |
137 | - receiptContainerDetailService.deleteByCondition(condition); | |
132 | + receiptContainerDetailService.deleteById(item.getId()); | |
138 | 133 | } |
139 | 134 | //删除配盘主表 |
140 | 135 | this.deleteById(id); |
... | ... |
src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
... | ... | @@ -139,21 +139,25 @@ public class ShipmentContainerHeaderServiceImpl implements IShipmentContainerHea |
139 | 139 | } |
140 | 140 | List<Integer> containerHeaderIds = new ArrayList<>(); |
141 | 141 | for (ShipmentCombinationModel shipmentCombinationModel:shipmentCombinationModels) { |
142 | - | |
143 | - //明细单 | |
144 | - ShipmentDetail shipmentDetail = shipmentDetailService.selectEntityById(shipmentCombinationModel.getShipmentDetailId()); | |
145 | - //查询库存 | |
142 | + //获取库存 | |
146 | 143 | Inventory inventory = inventoryService.selectEntityById(shipmentCombinationModel.getInventoryId()); |
147 | - //库位 | |
144 | + //获取库位 | |
148 | 145 | Location locationCondition = new Location(); |
149 | 146 | locationCondition.setWarehouseCode(inventory.getWarehouseCode()); |
150 | 147 | locationCondition.setCode(inventory.getLocationCode()); |
151 | 148 | Location location = locationService.selectFirstEntity(locationCondition); |
152 | - | |
149 | + //检查货物是否足够操作 | |
153 | 150 | if(inventory.getQty().subtract(inventory.getTaskQty()).compareTo(shipmentCombinationModel.getQty()) < 0 |
154 | 151 | || shipmentCombinationModel.getQty().compareTo(BigDecimal.ZERO) == 0) { |
155 | 152 | return AjaxResult.error("容器"+location.getContainerCode()+"已经完成出库,没有相应货物"); |
156 | 153 | } |
154 | + //更新库存分配数 | |
155 | + inventory.setTaskQty(inventory.getTaskQty().add(shipmentCombinationModel.getQty())); | |
156 | + inventoryService.updateByModel(inventory); | |
157 | + //更新单据明细的已出库数量 | |
158 | + ShipmentDetail shipmentDetail = shipmentDetailService.selectEntityById(shipmentCombinationModel.getShipmentDetailId()); | |
159 | + shipmentDetail.setQtyCompleted(shipmentDetail.getQtyCompleted().add(shipmentCombinationModel.getQty())); | |
160 | + shipmentDetailService.updateByModel(shipmentDetail); | |
157 | 161 | |
158 | 162 | //在组盘表中查找任务状态小于20的容器,如果状态为0就合并出库明细,状态大于0就提示不能组盘。如果找不到就新增一条组盘表头 |
159 | 163 | ShipmentContainerHeader ShipmentCondition = new ShipmentContainerHeader(); |
... | ... | @@ -204,11 +208,6 @@ public class ShipmentContainerHeaderServiceImpl implements IShipmentContainerHea |
204 | 208 | shipmentContainerDetail.setHeaderId(shipmentContainerHeader.getId()); |
205 | 209 | shipmentContainerDetailService.insert(shipmentContainerDetail); |
206 | 210 | } |
207 | - //更新库存分配数、明细单据已发数 | |
208 | - inventory.setTaskQty(inventory.getTaskQty().add(shipmentCombinationModel.getQty())); | |
209 | - inventoryService.updateByModel(inventory); | |
210 | - shipmentDetail.setQtyCompleted(shipmentDetail.getQtyCompleted().add(shipmentCombinationModel.getQty())); | |
211 | - shipmentDetailService.updateByModel(shipmentDetail); | |
212 | 211 | //更新单据状态 |
213 | 212 | shipmentHeaderService.updateShipmentStatus(shipmentDetail.getShipmentId()); |
214 | 213 | //锁定库位 |
... | ... | @@ -581,8 +580,21 @@ public class ShipmentContainerHeaderServiceImpl implements IShipmentContainerHea |
581 | 580 | if(!shipmentDetail.getMaterialCode().equals(inventory.getMaterialCode())){ |
582 | 581 | return AjaxResult.error("配盘物料不一致"); |
583 | 582 | } |
584 | - | |
585 | - | |
583 | + //库位 | |
584 | + Location locationCondition = new Location(); | |
585 | + locationCondition.setWarehouseCode(inventory.getWarehouseCode()); | |
586 | + locationCondition.setCode(inventory.getLocationCode()); | |
587 | + Location location = locationService.selectFirstEntity(locationCondition); | |
588 | + if (location.getStatus().equals("lock")) { | |
589 | + //在组盘表中查找任务状态小于20的容器,如果状态为0就合并出库明细,状态大于0就提示不能组盘。如果找不到就新增一条组盘表头 | |
590 | + ShipmentContainerHeader ShipmentCondition = new ShipmentContainerHeader(); | |
591 | + ShipmentCondition.setShipmentContainerCode(location.getContainerCode()); | |
592 | + ShipmentCondition.setWarehouseId(ShiroUtils.getWarehouseId()); | |
593 | + ShipmentContainerHeader shipmentContainerHeader = shipmentContainerHeaderMapper.selectUnCompletedShipmentContainer(ShipmentCondition); | |
594 | + if (shipmentContainerHeader == null) { | |
595 | + return AjaxResult.error("库位已经锁定不能使用"); | |
596 | + } | |
597 | + } | |
586 | 598 | return AjaxResult.success(""); |
587 | 599 | } |
588 | 600 | |
... | ... | @@ -677,14 +689,12 @@ public class ShipmentContainerHeaderServiceImpl implements IShipmentContainerHea |
677 | 689 | if(shipmentContainerHeader.getStatus()>9){ |
678 | 690 | return AjaxResult.error("容器"+shipmentContainerHeader.getShipmentContainerCode()+"非新建状态,不允许取消明细"); |
679 | 691 | } |
680 | - //库存 | |
681 | - Inventory inventory = inventoryService.selectEntityById(shipmentContainerDetail.getInventoryId()); | |
682 | - //单据明细 | |
683 | - ShipmentDetail shipmentDetail = shipmentDetailService.selectEntityById(shipmentContainerDetail.getShipmentDetailId()); | |
684 | 692 | //恢复占用库存 |
693 | + Inventory inventory = inventoryService.selectEntityById(shipmentContainerDetail.getInventoryId()); | |
685 | 694 | inventory.setTaskQty(inventory.getTaskQty().subtract(shipmentContainerDetail.getQty())); |
686 | 695 | inventoryService.updateByModel(inventory); |
687 | 696 | //恢复单据发货数量 |
697 | + ShipmentDetail shipmentDetail = shipmentDetailService.selectEntityById(shipmentContainerDetail.getShipmentDetailId()); | |
688 | 698 | shipmentDetail.setQtyCompleted(shipmentDetail.getQtyCompleted().subtract(shipmentContainerDetail.getQty())); |
689 | 699 | shipmentDetailService.updateByModel(shipmentDetail); |
690 | 700 | //删除这个配盘明细 |
... | ... | @@ -692,9 +702,10 @@ public class ShipmentContainerHeaderServiceImpl implements IShipmentContainerHea |
692 | 702 | //查询头表下还有没有明细,如果没有,则删了这个头表 |
693 | 703 | ShipmentContainerDetail condition = new ShipmentContainerDetail(); |
694 | 704 | condition.setHeaderId(shipmentContainerDetail.getHeaderId()); |
695 | - List<ShipmentContainerDetail> shipmentContainerDetailsList= shipmentContainerDetailService.selectListEntityByEqual(condition); | |
696 | - if(shipmentContainerDetailsList==null||shipmentContainerDetailsList.size() == 0){ | |
705 | + List<Map<String, Object>> list= shipmentContainerDetailService.selectListMapByEqual("id", condition); | |
706 | + if(list==null||list.size() == 0){ | |
697 | 707 | this.deleteById(shipmentContainerHeader.getId()); |
708 | + locationService.updateStatus(shipmentContainerHeader.getLocationCode(),"empty"); | |
698 | 709 | } |
699 | 710 | //更新单据状态 |
700 | 711 | shipmentHeaderService.updateShipmentStatus(shipmentDetail.getShipmentId()); |
... | ... |
src/main/java/com/huaheng/pc/task/task/service/TaskServiceImpl.java
... | ... | @@ -656,7 +656,6 @@ public class TaskServiceImpl implements ITaskService { |
656 | 656 | taskDetail.setStatus((short)40); |
657 | 657 | taskDetail.setLastUpdatedBy(ShiroUtils.getLoginName()); |
658 | 658 | taskDetailService.updateByModel(taskDetail); |
659 | - | |
660 | 659 | //修改入库单明细的状态 |
661 | 660 | receiptHeaderService.updateDetailStatus(DataUtils.getInteger(map.get("receiptDetailId")), (short)800); |
662 | 661 | } |
... | ... | @@ -672,7 +671,7 @@ public class TaskServiceImpl implements ITaskService { |
672 | 671 | task.setLastStatus((short)40); |
673 | 672 | task.setLastUpdatedBy(ShiroUtils.getLoginName()); |
674 | 673 | this.updateByModel(task); |
675 | - //修改库位状态 | |
674 | + //修改库位状态和对应的容器 | |
676 | 675 | Location locationRecord = new Location(); |
677 | 676 | locationRecord.setStatus("empty"); |
678 | 677 | locationRecord.setContainerCode(task.getContainerCode()); |
... | ... | @@ -680,7 +679,7 @@ public class TaskServiceImpl implements ITaskService { |
680 | 679 | locationCondition.setCode(task.getDestinationLocation()); |
681 | 680 | locationCondition.setWarehouseId(ShiroUtils.getWarehouseId()); |
682 | 681 | locationService.updateByCondition(locationRecord, locationCondition); |
683 | - //修改容器状态 | |
682 | + //修改容器状态和对应的库位 | |
684 | 683 | Container containerRecord = new Container(); |
685 | 684 | containerRecord.setLocationCode(LocationCode); |
686 | 685 | containerRecord.setStatus("some"); |
... | ... | @@ -688,7 +687,7 @@ public class TaskServiceImpl implements ITaskService { |
688 | 687 | containerCondition.setCode(task.getContainerCode()); |
689 | 688 | containerCondition.setWarehouseId(ShiroUtils.getWarehouseId()); |
690 | 689 | containerService.updateByCondition(containerRecord, containerCondition); |
691 | - //修改组盘表 | |
690 | + //修改组盘表状态为40 | |
692 | 691 | ReceiptContainerHeader receiptContainerHeader = new ReceiptContainerHeader(); |
693 | 692 | receiptContainerHeader.setId(task.getAllocationHeadId()); |
694 | 693 | receiptContainerHeader.setStatus((short)40); |
... | ... | @@ -705,9 +704,7 @@ public class TaskServiceImpl implements ITaskService { |
705 | 704 | task.setFirstStatus((short)40); |
706 | 705 | task.setLastStatus((short)40); |
707 | 706 | taskService.updateByModel(task); |
708 | - | |
709 | 707 | locationService.updateStatus(task.getSourceLocation(), "empty"); |
710 | - | |
711 | 708 | return AjaxResult.success("完成出库查看任务"); |
712 | 709 | } |
713 | 710 | |
... | ... | @@ -1064,8 +1061,6 @@ public class TaskServiceImpl implements ITaskService { |
1064 | 1061 | // //更新货位状态 |
1065 | 1062 | // locationService.updateLocationStatus(location.getCode()); |
1066 | 1063 | //更新货位状态 |
1067 | -// locationService.updateLocationStatus(location.getCode()); | |
1068 | - //更新货箱状态 | |
1069 | 1064 | ShipmentContainerHeader record = new ShipmentContainerHeader(); |
1070 | 1065 | record.setId(shipmentContainerHeaderId); |
1071 | 1066 | record.setStatus((short)10); |
... | ... | @@ -1097,38 +1092,38 @@ public class TaskServiceImpl implements ITaskService { |
1097 | 1092 | return AjaxResult.error("货箱" + shipmentContainerHeader.getShipmentContainerCode() + "没有子任务,操作中止"); |
1098 | 1093 | } |
1099 | 1094 | |
1100 | - //货位 | |
1101 | - Location locationCondition = new Location(); | |
1102 | - locationCondition.setWarehouseCode(shipmentContainerHeader.getWarehouseCode()); | |
1103 | - locationCondition.setContainerCode(shipmentContainerHeader.getShipmentContainerCode()); | |
1104 | - Location location = locationService.selectFirstEntity(locationCondition); | |
1105 | - if(!location.getStatus().equals("empty")){ | |
1106 | - return AjaxResult.error("托盘对应货位"+location.getCode()+"非空闲,无法生成任务,操作中止"); | |
1107 | - } | |
1108 | - | |
1109 | - //托盘 | |
1110 | - Container containerCondition = new Container(); | |
1111 | - containerCondition.setCode(shipmentContainerHeader.getShipmentContainerCode()); | |
1112 | - containerCondition.setWarehouseId(shipmentContainerHeader.getWarehouseId()); | |
1113 | - Container container = containerService.selectFirstEntity(containerCondition); | |
1114 | - //如果已经有任务表头,那么先取消掉已有任务表头,再把所有任务详情组成一个任务表头。 | |
1115 | - Task taskCondition = new Task(); | |
1116 | - taskCondition.setContainerCode(container.getCode()); | |
1117 | - List<Task> tasks = taskService.selectListEntityByEqual(taskCondition); | |
1118 | - List<TaskDetail> taskDetailList = null; | |
1119 | - if(tasks != null) { | |
1120 | - taskDetailList = new ArrayList<>(); | |
1121 | - for(Task task : tasks) { | |
1122 | - if (task.getFirstStatus() < 10) { | |
1123 | - TaskDetail taskDetailCondition = new TaskDetail(); | |
1124 | - taskDetailCondition.setTaskId(task.getId()); | |
1125 | - taskDetailList.addAll(taskDetailService.selectListEntityByEqual(taskDetailCondition)); | |
1126 | - taskService.deleteById(task.getId()); | |
1127 | - } else if(task.getFirstStatus() < 40 && task.getFirstStatus()> 9) { | |
1128 | - return AjaxResult.error("货箱" + task.getContainerCode() + "正在执行任务"); | |
1129 | - } | |
1130 | - } | |
1131 | - } | |
1095 | +// //货位 | |
1096 | +// Location locationCondition = new Location(); | |
1097 | +// locationCondition.setWarehouseCode(shipmentContainerHeader.getWarehouseCode()); | |
1098 | +// locationCondition.setContainerCode(shipmentContainerHeader.getShipmentContainerCode()); | |
1099 | +// Location location = locationService.selectFirstEntity(locationCondition); | |
1100 | +// if(!location.getStatus().equals("empty")){ | |
1101 | +// return AjaxResult.error("托盘对应货位"+location.getCode()+"非空闲,无法生成任务,操作中止"); | |
1102 | +// } | |
1103 | +// | |
1104 | +// //托盘 | |
1105 | +// Container containerCondition = new Container(); | |
1106 | +// containerCondition.setCode(shipmentContainerHeader.getShipmentContainerCode()); | |
1107 | +// containerCondition.setWarehouseId(shipmentContainerHeader.getWarehouseId()); | |
1108 | +// Container container = containerService.selectFirstEntity(containerCondition); | |
1109 | +// //如果已经有任务表头,那么先取消掉已有任务表头,再把所有任务详情组成一个任务表头。 | |
1110 | +// Task taskCondition = new Task(); | |
1111 | +// taskCondition.setContainerCode(container.getCode()); | |
1112 | +// List<Task> tasks = taskService.selectListEntityByEqual(taskCondition); | |
1113 | +// List<TaskDetail> taskDetailList = null; | |
1114 | +// if(tasks != null) { | |
1115 | +// taskDetailList = new ArrayList<>(); | |
1116 | +// for(Task task : tasks) { | |
1117 | +// if (task.getFirstStatus() < 10) { | |
1118 | +// TaskDetail taskDetailCondition = new TaskDetail(); | |
1119 | +// taskDetailCondition.setTaskId(task.getId()); | |
1120 | +// taskDetailList.addAll(taskDetailService.selectListEntityByEqual(taskDetailCondition)); | |
1121 | +// taskService.deleteById(task.getId()); | |
1122 | +// } else if(task.getFirstStatus() < 40 && task.getFirstStatus()> 9) { | |
1123 | +// return AjaxResult.error("货箱" + task.getContainerCode() + "正在执行任务"); | |
1124 | +// } | |
1125 | +// } | |
1126 | +// } | |
1132 | 1127 | |
1133 | 1128 | //创建任务头 |
1134 | 1129 | Task task = new Task(); |
... | ... | @@ -1145,7 +1140,7 @@ public class TaskServiceImpl implements ITaskService { |
1145 | 1140 | // 如果相等,则说明这个货箱包含了所有的数量,则可以整出,否则,创建拣选任务; |
1146 | 1141 | //查询所有库存 |
1147 | 1142 | Inventory inventoryCondition = new Inventory(); |
1148 | - inventoryCondition.setLocationCode(location.getCode()); | |
1143 | + inventoryCondition.setLocationCode(shipmentContainerHeader.getLocationCode()); | |
1149 | 1144 | inventoryCondition.setWarehouseId(ShiroUtils.getWarehouseId()); |
1150 | 1145 | List<Inventory> inventories = inventoryService.selectListEntityByEqual( inventoryCondition); |
1151 | 1146 | BigDecimal inventoryTotal=new BigDecimal("0"); |
... | ... | @@ -1167,9 +1162,9 @@ public class TaskServiceImpl implements ITaskService { |
1167 | 1162 | } |
1168 | 1163 | task.setStation(0);//站台暂时设置为0 |
1169 | 1164 | // |
1170 | - task.setContainerId(container.getId()); | |
1171 | - task.setContainerCode(container.getCode()); | |
1172 | - task.setSourceLocation(location.getCode()); | |
1165 | +// task.setContainerId(container.getId()); | |
1166 | + task.setContainerCode(shipmentContainerHeader.getShipmentContainerCode()); | |
1167 | + task.setSourceLocation(shipmentContainerHeader.getLocationCode()); | |
1173 | 1168 | task.setDestinationLocation(null); |
1174 | 1169 | task.setFirstStatus((short)1); |
1175 | 1170 | task.setLastStatus((short)1); |
... | ... | @@ -1179,15 +1174,15 @@ public class TaskServiceImpl implements ITaskService { |
1179 | 1174 | task.setLastUpdatedBy(ShiroUtils.getLoginName()); |
1180 | 1175 | task.setLastUpdated(null); |
1181 | 1176 | this.insert(task); |
1182 | - if(taskDetailList != null) { | |
1183 | - for (TaskDetail record : taskDetailList) { | |
1184 | - Task taskCondition2 = new Task(); | |
1185 | - taskCondition2.setContainerCode(container.getCode()); | |
1186 | - Task task2 = taskService.selectFirstEntity(taskCondition2); | |
1187 | - record.setTaskId(task2.getId()); | |
1188 | - taskDetailService.updateByModel(record); | |
1189 | - } | |
1190 | - } | |
1177 | +// if(taskDetailList != null) { | |
1178 | +// for (TaskDetail record : taskDetailList) { | |
1179 | +// Task taskCondition2 = new Task(); | |
1180 | +// taskCondition2.setContainerCode(container.getCode()); | |
1181 | +// Task task2 = taskService.selectFirstEntity(taskCondition2); | |
1182 | +// record.setTaskId(task2.getId()); | |
1183 | +// taskDetailService.updateByModel(record); | |
1184 | +// } | |
1185 | +// } | |
1191 | 1186 | //遍历子货箱创建子任务 |
1192 | 1187 | for(ShipmentContainerDetail shipmentContainerDetail : shipmentContainerDetails){ |
1193 | 1188 | TaskDetail taskDetail = new TaskDetail(); |
... | ... | @@ -1195,8 +1190,8 @@ public class TaskServiceImpl implements ITaskService { |
1195 | 1190 | taskDetail.setWarehouseCode(task.getWarehouseCode()); |
1196 | 1191 | taskDetail.setWarehouseId(task.getWarehouseId()); |
1197 | 1192 | taskDetail.setAllocationId(shipmentContainerDetail.getId()); |
1198 | - taskDetail.setContainerCode(container.getCode()); | |
1199 | - taskDetail.setSourceLocation(location.getCode()); | |
1193 | + taskDetail.setContainerCode(task.getContainerCode()); | |
1194 | + taskDetail.setSourceLocation(task.getSourceLocation()); | |
1200 | 1195 | taskDetail.setDestinationLocation(null); |
1201 | 1196 | taskDetail.setStatus((short)1); |
1202 | 1197 | taskDetail.setEndTime(null); |
... | ... |