Commit 14ae71cea6ff5d8994dfbe028c49d1c0bab07948
1 parent
e12f6d18
优化入库、出库组盘推荐容器,有任务的、已经组盘了的容器不推荐。
Showing
13 changed files
with
250 additions
and
92 deletions
src/main/java/com/huaheng/mobile/shipment/MobileShipmentController.java
... | ... | @@ -21,6 +21,8 @@ import com.huaheng.pc.config.material.service.MaterialService; |
21 | 21 | import com.huaheng.pc.config.receiptType.domain.ReceiptType; |
22 | 22 | import com.huaheng.pc.config.shipmentType.domain.ShipmentType; |
23 | 23 | import com.huaheng.pc.config.shipmentType.service.ShipmentTypeService; |
24 | +import com.huaheng.pc.config.station.domain.Station; | |
25 | +import com.huaheng.pc.config.station.service.StationService; | |
24 | 26 | import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail; |
25 | 27 | import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService; |
26 | 28 | import com.huaheng.pc.inventory.inventoryHeader.service.InventoryHeaderService; |
... | ... | @@ -75,6 +77,8 @@ public class MobileShipmentController extends BaseController { |
75 | 77 | private ShipmentHeaderMapper shipmentHeaderMapper; |
76 | 78 | @Resource |
77 | 79 | private MaterialService materialService; |
80 | + @Resource | |
81 | + private StationService stationService; | |
78 | 82 | |
79 | 83 | /** |
80 | 84 | * 自动组盘 |
... | ... | @@ -83,9 +87,11 @@ public class MobileShipmentController extends BaseController { |
83 | 87 | */ |
84 | 88 | @PostMapping("/autoCombination") |
85 | 89 | @ResponseBody |
86 | - public AjaxResult autoCombination(@RequestBody Map<String, String> param){ | |
87 | - String shipmentCode = param.get("shipmentCode"); | |
88 | - AjaxResult ajaxResult = shipmentContainerHeaderService.autoCombination(shipmentCode); | |
90 | + public AjaxResult autoCombination(@RequestBody List<ShipmentDetail> shipmentDetailList) { | |
91 | + if(shipmentDetailList == null || shipmentDetailList.size() <= 0) { | |
92 | + return AjaxResult.error("组盘信息为空"); | |
93 | + } | |
94 | + AjaxResult ajaxResult = shipmentContainerHeaderService.autoCombination(shipmentDetailList); | |
89 | 95 | return ajaxResult; |
90 | 96 | } |
91 | 97 | |
... | ... | @@ -194,6 +200,27 @@ public class MobileShipmentController extends BaseController { |
194 | 200 | return AjaxResult.success(taskIds); |
195 | 201 | } |
196 | 202 | |
203 | + /** | |
204 | + * 根据出库单号生成出库任务 | |
205 | + */ | |
206 | + @PostMapping("/outPort") | |
207 | + @ResponseBody | |
208 | + @Transactional(rollbackFor = Exception.class) | |
209 | + public AjaxResult outPort(@RequestBody Map<String, String> param) { | |
210 | + int type = Integer.parseInt(param.get("type")); | |
211 | + String area = param.get("area"); | |
212 | + LambdaQueryWrapper<Station> queryWrapper = Wrappers.lambdaQuery(); | |
213 | + if(type == QuantityConstant.STATION_PICK_AND_OUT) { | |
214 | + queryWrapper.in(Station::getType, | |
215 | + QuantityConstant.STATION_OUT, QuantityConstant.STATION_PICK); | |
216 | + } else { | |
217 | + queryWrapper.eq(Station::getType, type); | |
218 | + } | |
219 | + queryWrapper.eq(Station::getArea, area); | |
220 | + List<Station> stationList = stationService.list(queryWrapper); | |
221 | + return AjaxResult.success(stationList); | |
222 | + } | |
223 | + | |
197 | 224 | @PostMapping("/findShipment") |
198 | 225 | @ApiOperation("移动端查询出库单") |
199 | 226 | @Log(title = "移动端查询出库单", action = BusinessType.OTHER) |
... | ... |
src/main/java/com/huaheng/pc/config/address/domain/Address.java
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderService.java
... | ... | @@ -59,4 +59,8 @@ public interface ReceiptContainerHeaderService extends IService<ReceiptContainer |
59 | 59 | * @return |
60 | 60 | */ |
61 | 61 | AjaxResult cancelReceipt(Integer id); |
62 | + | |
63 | + int getUnCompleteCombineNumber(String containerCode); | |
64 | + | |
65 | + List<ReceiptContainerHeader> getUnCompleteCombineList(); | |
62 | 66 | } |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptContainerHeader/service/ReceiptContainerHeaderServiceImpl.java
... | ... | @@ -32,6 +32,8 @@ import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail; |
32 | 32 | import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService; |
33 | 33 | import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader; |
34 | 34 | import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService; |
35 | +import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader; | |
36 | +import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService; | |
35 | 37 | import com.huaheng.pc.task.taskHeader.domain.TaskHeader; |
36 | 38 | import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; |
37 | 39 | import org.springframework.stereotype.Service; |
... | ... | @@ -68,6 +70,8 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
68 | 70 | private ConfigValueMapper configValueMapper; |
69 | 71 | @Resource |
70 | 72 | private ConfigService configService; |
73 | + @Resource | |
74 | + private ShipmentContainerHeaderService shipmentContainerHeaderService; | |
71 | 75 | /** |
72 | 76 | * 保存入库组盘 |
73 | 77 | * @param receiptCode 入库单编码 |
... | ... | @@ -110,6 +114,10 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
110 | 114 | // locationService.updateStatus(locationCode, QuantityConstant.STATUS_LOCK); |
111 | 115 | // } |
112 | 116 | |
117 | + int unCompleteCombineNumber = shipmentContainerHeaderService.getUnCompleteCombineNumber(containerCode); | |
118 | + if(unCompleteCombineNumber > 0) { | |
119 | + throw new ServiceException("该托盘已经用于出库组盘"); | |
120 | + } | |
113 | 121 | /* 新建保存组盘头表记录*/ |
114 | 122 | //根据容器编码查询组盘表头记录 |
115 | 123 | LambdaQueryWrapper<ReceiptContainerHeader> lambda = Wrappers.lambdaQuery(); |
... | ... | @@ -619,4 +627,26 @@ public class ReceiptContainerHeaderServiceImpl extends ServiceImpl<ReceiptContai |
619 | 627 | } |
620 | 628 | return AjaxResult.success("成功"); |
621 | 629 | } |
630 | + | |
631 | + @Override | |
632 | + public int getUnCompleteCombineNumber(String containerCode) { | |
633 | + LambdaQueryWrapper<ReceiptContainerHeader> receiptContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
634 | + receiptContainerHeaderLambdaQueryWrapper.eq(ReceiptContainerHeader::getContainerCode, containerCode) | |
635 | + .lt(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_FINISHED); | |
636 | + int number = 0; | |
637 | + List<ReceiptContainerHeader> receiptContainerHeaderList = list(receiptContainerHeaderLambdaQueryWrapper); | |
638 | + if(receiptContainerHeaderList != null && receiptContainerHeaderList.size() > 0) { | |
639 | + number = receiptContainerHeaderList.size(); | |
640 | + } | |
641 | + return number; | |
642 | + } | |
643 | + | |
644 | + @Override | |
645 | + public List<ReceiptContainerHeader> getUnCompleteCombineList() { | |
646 | + LambdaQueryWrapper<ReceiptContainerHeader> receiptContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
647 | + receiptContainerHeaderLambdaQueryWrapper | |
648 | + .lt(ReceiptContainerHeader::getStatus, QuantityConstant.RECEIPT_CONTAINER_FINISHED); | |
649 | + List<ReceiptContainerHeader> receiptContainerHeaderList = list(receiptContainerHeaderLambdaQueryWrapper); | |
650 | + return receiptContainerHeaderList; | |
651 | + } | |
622 | 652 | } |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiptHeader/controller/ReceiptHeaderController.java
... | ... | @@ -77,7 +77,6 @@ public class ReceiptHeaderController extends BaseController { |
77 | 77 | PageDomain pageDomain = TableSupport.buildPageRequest(); |
78 | 78 | Integer pageNum = pageDomain.getPageNum(); |
79 | 79 | Integer pageSize = pageDomain.getPageSize(); |
80 | - String warehouCode = ShiroUtils.getWarehouseCode(); | |
81 | 80 | lambdaQueryWrapper.ge(StringUtils.isNotEmpty(createdBegin), ReceiptHeader::getCreated, createdBegin) |
82 | 81 | .le(StringUtils.isNotEmpty(createdEnd), ReceiptHeader::getCreated, createdEnd) |
83 | 82 | .in(StringUtils.isNotEmpty(receiptHeader.getCompanyCode()),ReceiptHeader::getCompanyCode, receiptHeader.getCompanyCode()) |
... | ... | @@ -88,7 +87,7 @@ public class ReceiptHeaderController extends BaseController { |
88 | 87 | .eq(StringUtils.isNotEmpty(receiptHeader.getCode()), ReceiptHeader::getCode, receiptHeader.getCode()) |
89 | 88 | .eq(StringUtils.isNotEmpty(receiptHeader.getReferCode()), ReceiptHeader::getReferCode, receiptHeader.getReferCode()) |
90 | 89 | .le(StringUtils.isNotNull(receiptHeader.getFirstStatus()), |
91 | - ReceiptHeader::getFirstStatus, receiptHeader.getFirstStatus()) | |
90 | + ReceiptHeader::getFirstStatus, receiptHeader.getFirstStatus()) | |
92 | 91 | .ge(StringUtils.isNotNull(receiptHeader.getLastStatus()), |
93 | 92 | ReceiptHeader::getLastStatus, receiptHeader.getLastStatus()) |
94 | 93 | .orderByDesc(ReceiptHeader::getCreated); |
... | ... |
src/main/java/com/huaheng/pc/receipt/receiving/controller/ReceivingController.java
... | ... | @@ -15,12 +15,17 @@ import com.huaheng.pc.config.container.service.ContainerService; |
15 | 15 | import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail; |
16 | 16 | import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService; |
17 | 17 | import com.huaheng.pc.receipt.receiptContainerDetail.service.ReceiptContainerDetailService; |
18 | +import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; | |
18 | 19 | import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService; |
19 | 20 | import com.huaheng.pc.receipt.receiptDetail.domain.ReceiptDetail; |
20 | 21 | import com.huaheng.pc.receipt.receiptDetail.service.ReceiptDetailService; |
21 | 22 | import com.huaheng.pc.receipt.receiptHeader.domain.ReceiptHeader; |
22 | 23 | import com.huaheng.pc.receipt.receiptHeader.service.ReceiptHeaderService; |
23 | 24 | import com.huaheng.pc.receipt.receiving.service.ReceivingService; |
25 | +import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader; | |
26 | +import com.huaheng.pc.shipment.shipmentContainerHeader.service.ShipmentContainerHeaderService; | |
27 | +import com.huaheng.pc.task.taskHeader.domain.TaskHeader; | |
28 | +import com.huaheng.pc.task.taskHeader.service.TaskHeaderService; | |
24 | 29 | import io.swagger.annotations.ApiOperation; |
25 | 30 | import io.swagger.annotations.ApiParam; |
26 | 31 | import org.apache.shiro.authz.annotation.RequiresPermissions; |
... | ... | @@ -33,6 +38,7 @@ import org.springframework.web.bind.annotation.ResponseBody; |
33 | 38 | |
34 | 39 | import javax.annotation.Resource; |
35 | 40 | import java.math.BigDecimal; |
41 | +import java.util.ArrayList; | |
36 | 42 | import java.util.List; |
37 | 43 | import java.util.Map; |
38 | 44 | |
... | ... | @@ -63,6 +69,10 @@ public class ReceivingController extends BaseController { |
63 | 69 | private ContainerService containerService; |
64 | 70 | @Resource |
65 | 71 | private InventoryDetailService inventoryDetailService; |
72 | + @Resource | |
73 | + private TaskHeaderService taskHeaderService; | |
74 | + @Resource | |
75 | + private ShipmentContainerHeaderService shipmentContainerHeaderService; | |
66 | 76 | |
67 | 77 | @RequiresPermissions("receipt:receiving:view") |
68 | 78 | @GetMapping() |
... | ... | @@ -140,13 +150,13 @@ public class ReceivingController extends BaseController { |
140 | 150 | @PostMapping("/getInventoryInfo") |
141 | 151 | @RequiresPermissions("receipt:receiving:add") |
142 | 152 | @Log(title = "入库-入库单", operating ="获取库存信息", action = BusinessType.OTHER) |
143 | - public AjaxResult getInventoryInfo(String code,Integer id) { | |
153 | + public AjaxResult getInventoryInfo(String code,Integer id) throws Exception { | |
144 | 154 | //找到主单的账套和仓库 |
145 | 155 | LambdaQueryWrapper<ReceiptHeader> lambdaQueryWrapper= Wrappers.lambdaQuery(); |
146 | 156 | lambdaQueryWrapper.eq(ReceiptHeader::getCode,code) |
147 | 157 | .eq(ReceiptHeader::getWarehouseCode, ShiroUtils.getWarehouseCode()); |
148 | 158 | ReceiptHeader receiptHeader=receiptHeaderService.getOne(lambdaQueryWrapper); |
149 | - if(receiptHeader==null){ | |
159 | + if(receiptHeader == null) { | |
150 | 160 | throw new ServiceException("找不到主单"); |
151 | 161 | } |
152 | 162 | |
... | ... | @@ -156,10 +166,30 @@ public class ReceivingController extends BaseController { |
156 | 166 | .eq(ReceiptDetail::getWarehouseCode, ShiroUtils.getWarehouseCode()) |
157 | 167 | .eq(ReceiptDetail::getId,id); |
158 | 168 | ReceiptDetail receiptDetail=receiptDetailService.getOne(lambdaQuery); |
159 | - if(receiptDetail==null){ | |
169 | + if(receiptDetail == null) { | |
160 | 170 | throw new ServiceException("找不到子单"); |
161 | 171 | } |
162 | 172 | |
173 | + List<TaskHeader> unCompleteTaskList = taskHeaderService.getUnCompleteTaskList(); | |
174 | + List<ShipmentContainerHeader> shipmentContainerHeaderList = | |
175 | + shipmentContainerHeaderService.getUnCompleteCombineList(); | |
176 | + List<String> containerList = new ArrayList<>(); | |
177 | + if(unCompleteTaskList != null && unCompleteTaskList.size() > 0) { | |
178 | + for(TaskHeader taskHeader : unCompleteTaskList) { | |
179 | + String containerCode = taskHeader.getContainerCode(); | |
180 | + containerList.add(containerCode); | |
181 | + } | |
182 | + } | |
183 | + | |
184 | + if(shipmentContainerHeaderList != null && shipmentContainerHeaderList.size() > 0) { | |
185 | + for(ShipmentContainerHeader shipmentContainerHeader : shipmentContainerHeaderList) { | |
186 | + String containerCode = shipmentContainerHeader.getContainerCode(); | |
187 | + if(!containerList.contains(containerCode)) { | |
188 | + containerList.add(containerCode); | |
189 | + } | |
190 | + } | |
191 | + } | |
192 | + | |
163 | 193 | //本物料库存 |
164 | 194 | LambdaQueryWrapper<InventoryDetail> inventoryDetailLambda = Wrappers.lambdaQuery(); |
165 | 195 | inventoryDetailLambda.eq(InventoryDetail::getWarehouseCode,ShiroUtils.getWarehouseCode()) |
... | ... | @@ -168,17 +198,38 @@ public class ReceivingController extends BaseController { |
168 | 198 | .eq((StringUtils.isNotEmpty(receiptDetail.getProjectNo())),InventoryDetail::getProjectNo, |
169 | 199 | receiptDetail.getProjectNo()); |
170 | 200 | List<InventoryDetail> inventoryList = inventoryDetailService.list(inventoryDetailLambda); |
201 | + List<InventoryDetail> removeInventoryList = new ArrayList<>(); | |
171 | 202 | |
172 | 203 | //空容器 |
173 | 204 | LambdaQueryWrapper<Container> container=Wrappers.lambdaQuery(); |
174 | 205 | container.eq(Container::getWarehouseCode,ShiroUtils.getWarehouseCode()) |
175 | 206 | .eq(Container::getCompanyCode,receiptHeader.getCompanyCode()) |
176 | 207 | .eq(Container::getStatus, QuantityConstant.STATUS_CONTAINER_EMPTY); |
177 | - List<Container> containerList=containerService.list(container); | |
208 | + List<Container> emptyContainerList=containerService.list(container); | |
209 | + List<Container> removeEmptyContainerList = new ArrayList<>(); | |
210 | + | |
211 | + for(String containerCode : containerList) { | |
212 | + if(inventoryList != null && inventoryList.size() > 0) { | |
213 | + for (InventoryDetail inventoryDetail : inventoryList) { | |
214 | + if (inventoryDetail.getContainerCode().equals(containerCode)) { | |
215 | + removeInventoryList.add(inventoryDetail); | |
216 | + } | |
217 | + } | |
218 | + } | |
219 | + if(emptyContainerList != null && emptyContainerList.size() > 0) { | |
220 | + for (Container container1 : emptyContainerList) { | |
221 | + if (container1.getCode().equals(containerCode)) { | |
222 | + removeEmptyContainerList.add(container1); | |
223 | + } | |
224 | + } | |
225 | + } | |
226 | + } | |
227 | + inventoryList.removeAll(removeInventoryList); | |
228 | + emptyContainerList.removeAll(removeEmptyContainerList); | |
178 | 229 | |
179 | 230 | Map map=new ModelMap(); |
180 | 231 | map.put("inventoryList",inventoryList); |
181 | - map.put("containerList",containerList); | |
232 | + map.put("containerList",emptyContainerList); | |
182 | 233 | return AjaxResult.success(map); |
183 | 234 | } |
184 | 235 | } |
... | ... |
src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderService.java
... | ... | @@ -38,4 +38,9 @@ public interface ShipmentContainerHeaderService extends IService<ShipmentContain |
38 | 38 | boolean cancelShipment(Integer combineHeaderId); |
39 | 39 | |
40 | 40 | AjaxResult getShipmentInfoByCode(String code); |
41 | + | |
42 | + // 获得没有组盘完成的数量 | |
43 | + int getUnCompleteCombineNumber(String containerCode); | |
44 | + | |
45 | + List<ShipmentContainerHeader> getUnCompleteCombineList(); | |
41 | 46 | } |
... | ... |
src/main/java/com/huaheng/pc/shipment/shipmentContainerHeader/service/ShipmentContainerHeaderServiceImpl.java
... | ... | @@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
4 | 4 | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
5 | 5 | import com.huaheng.common.constant.QuantityConstant; |
6 | 6 | import com.huaheng.common.exception.service.ServiceException; |
7 | +import com.huaheng.common.utils.StringUtils; | |
7 | 8 | import com.huaheng.common.utils.security.ShiroUtils; |
8 | 9 | import com.huaheng.framework.web.domain.AjaxResult; |
9 | 10 | import com.huaheng.framework.web.domain.RetCode; |
... | ... | @@ -17,6 +18,8 @@ import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceServic |
17 | 18 | import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail; |
18 | 19 | import com.huaheng.pc.inventory.inventoryDetail.service.InventoryDetailService; |
19 | 20 | import com.huaheng.pc.receipt.receiptContainerDetail.domain.ReceiptContainerDetail; |
21 | +import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; | |
22 | +import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService; | |
20 | 23 | import com.huaheng.pc.shipment.shipmentContainerDetail.domain.ShipmentContainerDetail; |
21 | 24 | import com.huaheng.pc.shipment.shipmentContainerDetail.service.ShipmentContainerDetailService; |
22 | 25 | import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentCombinationModel; |
... | ... | @@ -79,6 +82,8 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
79 | 82 | private ContainerService containerService; |
80 | 83 | @Resource |
81 | 84 | private ShipmentTaskService shipmentTaskService; |
85 | + @Autowired | |
86 | + private ReceiptContainerHeaderService receiptContainerHeaderService; | |
82 | 87 | |
83 | 88 | |
84 | 89 | @Override |
... | ... | @@ -111,13 +116,18 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
111 | 116 | throw new ServiceException("出库数量必须大于0"); |
112 | 117 | } |
113 | 118 | ShipmentDetail shipmentDetail = shipmentDetailService.getById(shipmentCombinationModel.getShipmentDetailId()); |
114 | - if(shipmentDetail==null){ | |
119 | + if(shipmentDetail == null){ | |
115 | 120 | throw new ServiceException("出库明细未找到"); |
116 | 121 | } |
117 | 122 | InventoryDetail inventoryDetail = inventoryDetailService.getById((shipmentCombinationModel.getInventoryDetailId())); |
118 | - if(inventoryDetail==null){ | |
123 | + if(inventoryDetail == null){ | |
119 | 124 | throw new ServiceException("库存未找到"); |
120 | 125 | } |
126 | + String containerCode = inventoryDetail.getContainerCode(); | |
127 | + int unCompleteCombineNumber = receiptContainerHeaderService.getUnCompleteCombineNumber(containerCode); | |
128 | + if(unCompleteCombineNumber > 0) { | |
129 | + throw new ServiceException("托盘:" + containerCode + " 已经用于入库组盘"); | |
130 | + } | |
121 | 131 | //校验数量是否超出 |
122 | 132 | if((shipmentDetail.getShipQty().subtract(shipmentDetail.getRequestQty())).compareTo(shipmentCombinationModel.getShipQty())<0){ |
123 | 133 | throw new ServiceException("录入数量超出明细待出数量"); |
... | ... | @@ -501,36 +511,50 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
501 | 511 | @Override |
502 | 512 | public AjaxResult autoCombination(List<ShipmentDetail> shipmentDetailList){ |
503 | 513 | int num = 0; |
504 | - List<Integer> list=new ArrayList<>(); | |
514 | + List<Integer> list = new ArrayList<>(); | |
505 | 515 | for (ShipmentDetail item : shipmentDetailList) { |
506 | 516 | //获取需要出库数量 |
507 | 517 | BigDecimal shipmentQty = item.getShipQty().subtract(item.getRequestQty()); |
518 | + String userDef1 = item.getUserDef1(); | |
519 | + if (StringUtils.isNotEmpty(userDef1)) { | |
520 | + shipmentQty = new BigDecimal(userDef1); | |
521 | + } | |
508 | 522 | //判断是否还有需要出库的物料,如果没有就跳过该物料 |
509 | 523 | if (shipmentQty.compareTo(BigDecimal.ZERO) <= 0) { |
510 | 524 | continue; |
511 | 525 | } |
512 | - // 根据 仓库编码、货主编码、物料编码,物料状态,项目号来查找可以出库的物料 | |
513 | -// ShippingSearch search = new ShippingSearch(); | |
514 | -// search.setWarehouseCode(ShiroUtils.getWarehouseCode()); | |
515 | -// search.setCompanyCode(item.getCompanyCode()); | |
516 | -// search.setMaterialCode(item.getMaterialCode()); | |
517 | -// search.setInventorySts(item.getInventorySts()); //物料状态 | |
518 | 526 | |
519 | 527 | List<InventoryDetail> inventoryList = shippingCombinationService.getInventorys(item); |
520 | 528 | //去除已锁的库存 |
521 | - ArrayList<InventoryDetail> lockList = new ArrayList<>(); | |
522 | - LambdaQueryWrapper<Container> queryWrapper; | |
529 | + ArrayList<InventoryDetail> removeInventoryList = new ArrayList<>(); | |
530 | + List<TaskHeader> taskHeaderList = taskHeaderService.getUnCompleteTaskList(); | |
531 | + List<ReceiptContainerHeader> receiptContainerHeaderList = | |
532 | + receiptContainerHeaderService.getUnCompleteCombineList(); | |
523 | 533 | boolean lock = false; |
524 | 534 | for (InventoryDetail inventoryDetail : inventoryList) { |
525 | - queryWrapper = Wrappers.lambdaQuery(); | |
526 | - queryWrapper.eq(Container::getCode,inventoryDetail.getContainerCode()); | |
527 | - Container container = containerService.getOne(queryWrapper); | |
528 | - if (QuantityConstant.STATUS_CONTAINER_LOCK.equals(container.getStatus())){ | |
529 | - lockList.add(inventoryDetail); | |
535 | + LambdaQueryWrapper<Container> containerLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
536 | + containerLambdaQueryWrapper.eq(Container::getCode, inventoryDetail.getContainerCode()); | |
537 | + Container container = containerService.getOne(containerLambdaQueryWrapper); | |
538 | + if (QuantityConstant.STATUS_CONTAINER_LOCK.equals(container.getStatus())) { | |
539 | + removeInventoryList.add(inventoryDetail); | |
530 | 540 | lock = true; |
531 | 541 | } |
542 | + if(taskHeaderList != null) { | |
543 | + for(TaskHeader taskHeader : taskHeaderList) { | |
544 | + if(taskHeader.getContainerCode().equals(container.getCode())) { | |
545 | + removeInventoryList.add(inventoryDetail); | |
546 | + } | |
547 | + } | |
548 | + } | |
549 | + if(receiptContainerHeaderList != null) { | |
550 | + for(ReceiptContainerHeader receiptContainerHeader : receiptContainerHeaderList) { | |
551 | + if(receiptContainerHeader.getContainerCode().equals(container.getCode())) { | |
552 | + removeInventoryList.add(inventoryDetail); | |
553 | + } | |
554 | + } | |
555 | + } | |
532 | 556 | } |
533 | - inventoryList.removeAll(lockList); | |
557 | + inventoryList.removeAll(removeInventoryList); | |
534 | 558 | if (inventoryList.size()<1 && lock){ |
535 | 559 | return AjaxResult.success("明细id为"+item.getId()+"的物料所在托盘全部处于锁定状态,请完成或取消任务后再进行组盘"); |
536 | 560 | } |
... | ... | @@ -561,18 +585,17 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
561 | 585 | //如果库存数 >= 待出库数,组盘数就是待出库数并且结束组盘,否则组盘数就是库存数 |
562 | 586 | if (inventoryQty.compareTo(shipmentQty) > -1) { |
563 | 587 | shipmentCombination.setShipQty(shipmentQty); |
564 | - ShipmentContainerHeader shipmentContainerHeader=this.combination(shipmentCombination); | |
565 | - list.add(shipmentContainerHeader.getId()); | |
566 | 588 | } else { |
567 | 589 | shipmentCombination.setShipQty(inventoryQty); |
568 | - ShipmentContainerHeader shipmentContainerHeader=this.combination(shipmentCombination); | |
569 | - list.add(shipmentContainerHeader.getId()); | |
570 | 590 | } |
591 | + ShipmentContainerHeader shipmentContainerHeader=this.combination(shipmentCombination); | |
592 | + list.add(shipmentContainerHeader.getId()); | |
571 | 593 | shipmentQty = shipmentQty.subtract(shipmentCombination.getShipQty()); |
572 | 594 | } |
573 | 595 | } |
574 | 596 | } |
575 | - if(num==shipmentDetailList.size()){ | |
597 | + | |
598 | + if(num == shipmentDetailList.size()){ | |
576 | 599 | throw new ServiceException("单据物料的库存分配规则在此库区没有库存,无法出库"); |
577 | 600 | } |
578 | 601 | return AjaxResult.success("成功",list); |
... | ... | @@ -645,4 +668,27 @@ public class ShipmentContainerHeaderServiceImpl extends ServiceImpl<ShipmentCont |
645 | 668 | return AjaxResult.success(shipmentContainerDetails); |
646 | 669 | } |
647 | 670 | |
671 | + @Override | |
672 | + public int getUnCompleteCombineNumber(String containerCode) { | |
673 | + LambdaQueryWrapper<ShipmentContainerHeader> shipmentContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
674 | + shipmentContainerHeaderLambdaQueryWrapper.eq(ShipmentContainerHeader::getContainerCode, containerCode) | |
675 | + .lt(ShipmentContainerHeader::getStatus, QuantityConstant.SHIPMENT_CONTAINER_FINISHED); | |
676 | + int number = 0; | |
677 | + List<ShipmentContainerHeader> shipmentContainerHeaderList = list(shipmentContainerHeaderLambdaQueryWrapper); | |
678 | + if(shipmentContainerHeaderList != null && shipmentContainerHeaderList.size() > 0) { | |
679 | + number = shipmentContainerHeaderList.size(); | |
680 | + } | |
681 | + return number; | |
682 | + } | |
683 | + | |
684 | + @Override | |
685 | + public List<ShipmentContainerHeader> getUnCompleteCombineList() { | |
686 | + LambdaQueryWrapper<ShipmentContainerHeader> shipmentContainerHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
687 | + shipmentContainerHeaderLambdaQueryWrapper.lt(ShipmentContainerHeader::getStatus, | |
688 | + QuantityConstant.SHIPMENT_CONTAINER_FINISHED); | |
689 | + List<ShipmentContainerHeader> shipmentContainerHeaderList = | |
690 | + list(shipmentContainerHeaderLambdaQueryWrapper); | |
691 | + return shipmentContainerHeaderList; | |
692 | + } | |
693 | + | |
648 | 694 | } |
... | ... |
src/main/java/com/huaheng/pc/shipment/shippingCombination/controller/ShippingCombinationController.java
... | ... | @@ -16,6 +16,7 @@ import com.huaheng.mobile.shipment.Shipment; |
16 | 16 | import com.huaheng.pc.config.shipmentPreference.service.ShipmentPreferenceService; |
17 | 17 | import com.huaheng.pc.inventory.inventoryDetail.domain.InventoryDetail; |
18 | 18 | import com.huaheng.pc.receipt.receiptContainerHeader.domain.ReceiptContainerHeader; |
19 | +import com.huaheng.pc.receipt.receiptContainerHeader.service.ReceiptContainerHeaderService; | |
19 | 20 | import com.huaheng.pc.shipment.shipmentContainerDetail.service.ShipmentContainerDetailService; |
20 | 21 | import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentCombinationModel; |
21 | 22 | import com.huaheng.pc.shipment.shipmentContainerHeader.domain.ShipmentContainerHeader; |
... | ... | @@ -62,7 +63,10 @@ public class ShippingCombinationController extends BaseController { |
62 | 63 | @Autowired |
63 | 64 | TaskHeaderService taskHeaderService; |
64 | 65 | @Resource |
65 | - private ShipmentTaskService shipmentTaskService; | |
66 | + ShipmentTaskService shipmentTaskService; | |
67 | + @Resource | |
68 | + ReceiptContainerHeaderService receiptContainerHeaderService; | |
69 | + | |
66 | 70 | |
67 | 71 | |
68 | 72 | /** |
... | ... | @@ -98,37 +102,6 @@ public class ShippingCombinationController extends BaseController { |
98 | 102 | } |
99 | 103 | |
100 | 104 | |
101 | -// /** | |
102 | -// * 获取能出库的库存列表 | |
103 | -// * @param code,id | |
104 | -// * @return | |
105 | -// */ | |
106 | -// @PostMapping("/getInventory") | |
107 | -// @ResponseBody | |
108 | -// public TableDataInfo getInventory(String code, Integer id){ | |
109 | -// //找到主单的账套 | |
110 | -// LambdaQueryWrapper<ShipmentHeader> lambdaQueryWrapper = Wrappers.lambdaQuery(); | |
111 | -// lambdaQueryWrapper.eq(ShipmentHeader::getCode,code) | |
112 | -// .eq(ShipmentHeader::getWarehouseCode,ShiroUtils.getWarehouseCode()); | |
113 | -// ShipmentHeader shipmentHeader=shipmentHeaderService.getOne(lambdaQueryWrapper); | |
114 | -// if(shipmentHeader==null){ | |
115 | -// throw new ServiceException("找不到主单"); | |
116 | -// } | |
117 | -// //找到子单物料 | |
118 | -// ShipmentDetail shipmentDetail=new ShipmentDetail(); | |
119 | -// shipmentDetail=shipmentDetailService.getById(id); | |
120 | -// if(shipmentDetail==null){ | |
121 | -// throw new ServiceException("找不到子单"); | |
122 | -// } | |
123 | -// LambdaQueryWrapper<InventoryDetail> lam = Wrappers.lambdaQuery(); | |
124 | -// lam.eq(InventoryDetail::getWarehouseCode,shipmentHeader.getWarehouseCode()) | |
125 | -// .eq(InventoryDetail::getCompanyCode,shipmentHeader.getCompanyCode()) | |
126 | -// .eq(InventoryDetail::getMaterialCode,shipmentDetail.getMaterialCode()); | |
127 | -// | |
128 | -// List<InventoryDetail> list= inventoryDetailService.list(lam); | |
129 | -// return getDataTable(list); | |
130 | -// } | |
131 | - | |
132 | 105 | |
133 | 106 | /** |
134 | 107 | * 获取能出库的库存列表 |
... | ... | @@ -143,11 +116,11 @@ public class ShippingCombinationController extends BaseController { |
143 | 116 | lambdaQueryWrapper.eq(ShipmentHeader::getCode,code) |
144 | 117 | .eq(ShipmentHeader::getWarehouseCode,ShiroUtils.getWarehouseCode()); |
145 | 118 | ShipmentHeader shipmentHeader=shipmentHeaderService.getOne(lambdaQueryWrapper); |
146 | - if(shipmentHeader==null){ | |
119 | + if(shipmentHeader == null){ | |
147 | 120 | throw new ServiceException("找不到主单"); |
148 | 121 | } |
149 | 122 | //找到子单 |
150 | - ShipmentDetail shipmentDetail=new ShipmentDetail(); | |
123 | + ShipmentDetail shipmentDetail = new ShipmentDetail(); | |
151 | 124 | shipmentDetail=shipmentDetailService.getById(id); |
152 | 125 | if(shipmentDetail==null){ |
153 | 126 | throw new ServiceException("找不到子单"); |
... | ... | @@ -166,6 +139,21 @@ public class ShippingCombinationController extends BaseController { |
166 | 139 | removeList.add(item); |
167 | 140 | } |
168 | 141 | } |
142 | + List<ReceiptContainerHeader> unCompleteCombineList = | |
143 | + receiptContainerHeaderService.getUnCompleteCombineList(); | |
144 | + if(unCompleteCombineList != null && unCompleteCombineList.size() > 0) { | |
145 | + for(ReceiptContainerHeader receiptContainerHeader : unCompleteCombineList) { | |
146 | + String containerCode = receiptContainerHeader.getContainerCode(); | |
147 | + for(InventoryDetail item : list) { | |
148 | + if(containerCode.equals(item.getContainerCode())) { | |
149 | + if(!removeList.contains(item)) { | |
150 | + removeList.add(item); | |
151 | + } | |
152 | + break; | |
153 | + } | |
154 | + } | |
155 | + } | |
156 | + } | |
169 | 157 | list.removeAll(removeList); |
170 | 158 | //查找分配规则 |
171 | 159 | return getDataTable(list); |
... | ... |
src/main/java/com/huaheng/pc/shipment/shippingCombination/service/ShippingCombinationService.java
... | ... | @@ -61,8 +61,8 @@ public class ShippingCombinationService { |
61 | 61 | LambdaQueryWrapper<ShipmentPreference> slam=Wrappers.lambdaQuery(); |
62 | 62 | slam.eq(ShipmentPreference::getCode,configValue.getIdentifier()) |
63 | 63 | .eq(ShipmentPreference::getWarehouseCode,configValue.getWarehouseCode()); |
64 | - ShipmentPreference shipmentPreference=shipmentPreferenceService.getOne(slam); | |
65 | - if(shipmentPreference==null){ | |
64 | + ShipmentPreference shipmentPreference = shipmentPreferenceService.getOne(slam); | |
65 | + if(shipmentPreference == null){ | |
66 | 66 | throw new ServiceException("仓库的出库配置中出库首选项不存在"); |
67 | 67 | } |
68 | 68 | |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/ShipmentTaskService.java
... | ... | @@ -245,7 +245,6 @@ public class ShipmentTaskService { |
245 | 245 | //获取任务明细 |
246 | 246 | List<TaskDetail> taskDetails = taskDetailService.findByTaskId(task.getId()); |
247 | 247 | |
248 | - List<Integer> shipmentHeadIds = new ArrayList<>(); | |
249 | 248 | if (task.getStatus().equals(QuantityConstant.TASK_STATUS_COMPLETED)) { |
250 | 249 | throw new ServiceException("任务已完成"); |
251 | 250 | } |
... | ... | @@ -288,10 +287,6 @@ public class ShipmentTaskService { |
288 | 287 | if (taskDetail.getStatus() < QuantityConstant.TASK_STATUS_RUNNING) { |
289 | 288 | //获取出库子货箱 |
290 | 289 | ShipmentContainerDetail shipmentContainerDetail = shipmentContainerDetailService.getById(taskDetail.getAllocationId()); |
291 | - //取出子单据 | |
292 | - ShipmentDetail shipmentDetail = shipmentDetailService.getById(taskDetail.getBillDetailId()); | |
293 | - //暂存id,为更新单据状态准备 | |
294 | - shipmentHeadIds.add(shipmentDetail.getShipmentId()); | |
295 | 290 | //获取对应库存记录 |
296 | 291 | InventoryDetail inventoryDetail = inventoryDetailService.getById(taskDetail.getToInventoryId()); |
297 | 292 | if (inventoryDetail == null) { |
... | ... | @@ -333,23 +328,27 @@ public class ShipmentTaskService { |
333 | 328 | //记录库存交易记录 |
334 | 329 | InventoryTransaction inventoryTransaction = new InventoryTransaction(); |
335 | 330 | inventoryTransaction.setWarehouseCode(task.getWarehouseCode()); |
336 | - inventoryTransaction.setCompanyCode(shipmentDetail.getCompanyCode()); | |
331 | + inventoryTransaction.setCompanyCode(inventoryDetail.getCompanyCode()); | |
337 | 332 | inventoryTransaction.setLocationCode(inventoryDetail.getLocationCode()); |
338 | 333 | inventoryTransaction.setContainerCode(inventoryDetail.getContainerCode()); |
339 | 334 | inventoryTransaction.setTransactionType(QuantityConstant.INVENTORY_TRANSACTION_SHIPMENT); |
340 | - inventoryTransaction.setMaterialCode(shipmentDetail.getMaterialCode()); | |
341 | - inventoryTransaction.setMaterialName(shipmentDetail.getMaterialName()); | |
342 | - inventoryTransaction.setMaterialSpec(shipmentDetail.getMaterialSpec()); | |
343 | - inventoryTransaction.setMaterialUnit(shipmentDetail.getMaterialUnit()); | |
335 | + inventoryTransaction.setMaterialCode(inventoryDetail.getMaterialCode()); | |
336 | + inventoryTransaction.setMaterialName(inventoryDetail.getMaterialName()); | |
337 | + inventoryTransaction.setMaterialSpec(inventoryDetail.getMaterialSpec()); | |
338 | + inventoryTransaction.setMaterialUnit(inventoryDetail.getMaterialUnit()); | |
344 | 339 | inventoryTransaction.setBillCode(taskDetail.getBillCode()); |
345 | - inventoryTransaction.setBillDetailId(shipmentDetail.getId()); | |
346 | - inventoryTransaction.setBatch(shipmentDetail.getBatch()); | |
347 | - inventoryTransaction.setLot(shipmentDetail.getLot()); | |
348 | - inventoryTransaction.setProjectNo(shipmentDetail.getProjectNo()); | |
340 | + //取出子单据 | |
341 | + ShipmentDetail shipmentDetail = shipmentDetailService.getById(taskDetail.getBillDetailId()); | |
342 | + if(shipmentDetail != null) { | |
343 | + inventoryTransaction.setBillDetailId(shipmentDetail.getId()); | |
344 | + } | |
345 | + inventoryTransaction.setBatch(inventoryDetail.getBatch()); | |
346 | + inventoryTransaction.setLot(inventoryDetail.getLot()); | |
347 | + inventoryTransaction.setProjectNo(inventoryDetail.getProjectNo()); | |
349 | 348 | inventoryTransaction.setQcCheck(inventoryDetail.getQcCheck()); |
350 | 349 | inventoryTransaction.setSupplierCode(inventoryDetail.getSupplierCode()); |
351 | - inventoryTransaction.setManufactureDate(shipmentDetail.getManufactureDate()); | |
352 | - inventoryTransaction.setExpirationDate(shipmentDetail.getExpirationDate()); | |
350 | + inventoryTransaction.setManufactureDate(inventoryDetail.getManufactureDate()); | |
351 | + inventoryTransaction.setExpirationDate(inventoryDetail.getExpirationDate()); | |
353 | 352 | inventoryTransaction.setInventorySts(inventoryDetail.getInventorySts()); |
354 | 353 | //这里取反,更符合出库的语义,同时方便对记录进行统计 |
355 | 354 | inventoryTransaction.setTaskQty(taskDetail.getQty()); |
... | ... | @@ -376,14 +375,13 @@ public class ShipmentTaskService { |
376 | 375 | HashSet<Integer> ids = new HashSet<>(); |
377 | 376 | for (TaskDetail taskDetail : taskDetailList) { |
378 | 377 | ShipmentDetail shipmentDetail = shipmentDetailService.getById(taskDetail.getBillDetailId()); |
379 | - if (StringUtils.isNull(shipmentDetail)) { | |
380 | - throw new ServiceException("查找出库单明细失败"); | |
381 | - } | |
382 | - if (shipmentDetail.getShipQty().compareTo(shipmentDetail.getRequestQty()) == 0) { | |
383 | - shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_COMPLETED); | |
384 | - shipmentDetailService.updateById(shipmentDetail); | |
378 | + if (StringUtils.isNotNull(shipmentDetail)) { | |
379 | + if (shipmentDetail.getShipQty().compareTo(shipmentDetail.getRequestQty()) == 0) { | |
380 | + shipmentDetail.setStatus(QuantityConstant.SHIPMENT_HEADER_COMPLETED); | |
381 | + shipmentDetailService.updateById(shipmentDetail); | |
382 | + } | |
383 | + ids.add(shipmentDetail.getShipmentId()); | |
385 | 384 | } |
386 | - ids.add(shipmentDetail.getShipmentId()); | |
387 | 385 | } |
388 | 386 | |
389 | 387 | /*更新出库单状态*/ |
... | ... |
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderService.java
src/main/java/com/huaheng/pc/task/taskHeader/service/TaskHeaderServiceImpl.java
... | ... | @@ -800,6 +800,14 @@ public class TaskHeaderServiceImpl extends ServiceImpl<TaskHeaderMapper, TaskHea |
800 | 800 | } |
801 | 801 | |
802 | 802 | @Override |
803 | + public List<TaskHeader> getUnCompleteTaskList() { | |
804 | + LambdaQueryWrapper<TaskHeader> taskHeaderLambdaQueryWrapper = Wrappers.lambdaQuery(); | |
805 | + taskHeaderLambdaQueryWrapper.lt(TaskHeader::getStatus, QuantityConstant.TASK_STATUS_COMPLETED); | |
806 | + List<TaskHeader> taskHeaderList = taskHeaderService.list(taskHeaderLambdaQueryWrapper); | |
807 | + return taskHeaderList; | |
808 | + } | |
809 | + | |
810 | + @Override | |
803 | 811 | public int prioritymax(String ids) { |
804 | 812 | String[] idArray = Convert.toStrArray(ids); |
805 | 813 | LambdaQueryWrapper<TaskHeader> wrapper = Wrappers.lambdaQuery(); |
... | ... |