|
@@ -276,117 +276,117 @@ public class BizTakeStockPeriodController extends BaseController
|
|
|
}
|
|
|
//盘点入库信息表
|
|
|
//拿到所有部分入库的入库单信息
|
|
|
- List<BizTaksStockInboundOrderDetail> taskStockList = bizInboundOrderDetailService.getTaskStockList();
|
|
|
- if(taskStockList.size()>0) {
|
|
|
-
|
|
|
- //获取所有批次的id
|
|
|
- List<Long> lotIds = taskStockList.stream().map(BizTaksStockInboundOrderDetail::getLotId).distinct().collect(Collectors.toList());
|
|
|
- //根据批次id查询到对应批次的零存或领取信息
|
|
|
- List<BizStorageRetrieval> storageRetrievalList = bizStorageRetrievalService.query().in("lot_id", lotIds).or().in("retrieval_lot_id", lotIds).list();
|
|
|
- //根据批次id查询到对应批次已经上架的入库单信息
|
|
|
- List<BizInboundOrderDetail> inboundOrderDetailList = bizInboundOrderDetailService.query().in("lot_id", lotIds).eq("is_inbound", 1).list();
|
|
|
- //根据批次id查询到对应批次的盘点批次信息
|
|
|
- List<BizTaksStockLot> filteredList = list.stream().filter(item -> lotIds.contains(item.getLotId())).collect(Collectors.toList());
|
|
|
-
|
|
|
- // 创建映射,计算每个批次的零存数量
|
|
|
- Map<Long, Long> storageNumByLotId = storageRetrievalList.stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- BizStorageRetrieval::getLotId,
|
|
|
- Collectors.summingLong(BizStorageRetrieval::getStorageNum)
|
|
|
- ));
|
|
|
-
|
|
|
- // 创建映射,计算每个批次的领取数量
|
|
|
- Map<Long, Long> storageNumByRetrievalLotId = storageRetrievalList.stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- BizStorageRetrieval::getRetrievalLotId,
|
|
|
- Collectors.summingLong(BizStorageRetrieval::getStorageNum)
|
|
|
- ));
|
|
|
-
|
|
|
- // 创建映射,计算每个批次的入库数量
|
|
|
- Map<Long, Long> inboundNumByLotId = inboundOrderDetailList.stream()
|
|
|
- .collect(Collectors.groupingBy(
|
|
|
- BizInboundOrderDetail::getLotId,
|
|
|
- Collectors.summingLong(BizInboundOrderDetail::getInboundNum)
|
|
|
- ));
|
|
|
-
|
|
|
- // 已经全部上架的批次id
|
|
|
- List<Long> endIds=new ArrayList<>();
|
|
|
- for (BizTaksStockLot item : filteredList) {
|
|
|
- //拿到当前批次的盘点数量
|
|
|
- long resultNum = item.getProdNum();
|
|
|
- // 减去零存数量
|
|
|
- resultNum -= storageNumByLotId.getOrDefault(item.getLotId(), 0L);
|
|
|
-
|
|
|
- // 加上领取数量
|
|
|
- resultNum += storageNumByRetrievalLotId.getOrDefault(item.getLotId(), 0L);
|
|
|
-
|
|
|
- // 减去入库数量
|
|
|
- resultNum -= inboundNumByLotId.getOrDefault(item.getLotId(), 0L);
|
|
|
-
|
|
|
- // 判断当前批次的盘点数量是否为0
|
|
|
- // 如果为0,则表示该批次已经全部入库
|
|
|
- if (resultNum == 0) {
|
|
|
- endIds.add(item.getId());
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- // 将已将全部上架的批次从taskStockList与lotIds中移除
|
|
|
- taskStockList.removeIf(item -> endIds.contains(item.getId()));
|
|
|
- lotIds.removeAll(endIds);
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //拿到所有批次的信息
|
|
|
- List<BizLot> lotList = bizLotService.query().in("id", lotIds).list();
|
|
|
- //拿到所有合格证id
|
|
|
- List<Long> certificateLotIds = taskStockList.stream().map(BizTaksStockInboundOrderDetail::getCertificateLotId).distinct().collect(Collectors.toList());
|
|
|
- //拿到所有合格证信息
|
|
|
- List<BizCertificateLot> certificateLotList = bizCertificateLotService.query().in("id", certificateLotIds).list();
|
|
|
- for (BizTaksStockInboundOrderDetail item : taskStockList) {
|
|
|
- item.setTakeStockPeriodId(bizTakeStockPeriod.getId());
|
|
|
- item.setStockYear(bizTakeStockPeriod.getStockYear());
|
|
|
- item.setStockMonth(bizTakeStockPeriod.getStockMonth());
|
|
|
- //投入数是当前批次所有的入库数量
|
|
|
- List<BizTaksStockInboundOrderDetail> collect = taskStockList.stream().filter(task -> task.getLotCode().equals(item.getLotCode())).collect(Collectors.toList());
|
|
|
- item.setProdNum(collect.stream().mapToLong(BizTaksStockInboundOrderDetail::getInboundNum).sum());
|
|
|
- BizLot bizLot = lotList.stream().filter(lot -> lot.getId().equals(item.getLotId())).findFirst().orElse(null);
|
|
|
- item.setIsWaste(bizLot.getIsWaste());
|
|
|
- item.setIsAmend(bizLot.getIsAmend());
|
|
|
- item.setIsWasteRecycling(bizLot.getIsWasteRecycling());
|
|
|
- item.setIsSuperaddition(bizLot.getIsSuperaddition());
|
|
|
-
|
|
|
- item.setFromId(bizLot.getFromId());
|
|
|
- BizCertificateLot bizCertificateLot = certificateLotList.stream().filter(certificateLot -> certificateLot.getId().equals(item.getCertificateLotId())).findFirst().orElse(null);
|
|
|
- item.setBarcode(bizCertificateLot.getBarcode());
|
|
|
- }
|
|
|
- bizTaksStockInboundOrderDetailService.saveBatch(taskStockList);
|
|
|
- }
|
|
|
- //盘点合格证信息表
|
|
|
- List<BizTaksStockCertificateLot> certificateList = bizCertificateLotService.getTaskStockList();
|
|
|
- if(certificateList.size()>0){
|
|
|
- List<Long> companyIds = certificateList.stream().map(BizTaksStockCertificateLot::getCompanyId).distinct().collect(Collectors.toList());
|
|
|
- List<BizCompany> companyList = bizCompanyService.query().in("id", companyIds).list();
|
|
|
- List<Long> lotIds = certificateList.stream().map(BizTaksStockCertificateLot::getLotId).distinct().collect(Collectors.toList());
|
|
|
- List<BizLot> lotList = bizLotService.query().in("id", lotIds).list();
|
|
|
- for (BizTaksStockCertificateLot item : certificateList){
|
|
|
- item.setTakeStockPeriodId(bizTakeStockPeriod.getId());
|
|
|
- item.setStockYear(bizTakeStockPeriod.getStockYear());
|
|
|
- item.setStockMonth(bizTakeStockPeriod.getStockMonth());
|
|
|
- //投入数是当前批次所有的入库数量
|
|
|
- List<BizTaksStockCertificateLot> collect = certificateList.stream().filter(task -> task.getLotCode().equals(item.getLotCode())).collect(Collectors.toList());
|
|
|
- item.setProdNum(collect.stream().mapToLong(BizTaksStockCertificateLot::getTempProdNum).sum());
|
|
|
- BizCompany bizCompany = companyList.stream().filter(company -> company.getId().equals(item.getCompanyId())).findFirst().orElse(null);
|
|
|
- item.setCompanyName(bizCompany.getCompanyName());
|
|
|
- item.setCompanyCode(bizCompany.getCompanyCode());
|
|
|
- BizLot bizLot = lotList.stream().filter(lot -> lot.getId().equals(item.getLotId())).findFirst().orElse(null);
|
|
|
- item.setIsWaste(bizLot.getIsWaste());
|
|
|
- item.setIsAmend(bizLot.getIsAmend());
|
|
|
- item.setIsWasteRecycling(bizLot.getIsWasteRecycling());
|
|
|
- item.setIsSuperaddition(bizLot.getIsSuperaddition());
|
|
|
- item.setFromId(bizLot.getFromId());
|
|
|
- }
|
|
|
- bizTaksStockCertificateLotService.saveBatch(certificateList);
|
|
|
- }
|
|
|
+// List<BizTaksStockInboundOrderDetail> taskStockList = bizInboundOrderDetailService.getTaskStockList();
|
|
|
+// if(taskStockList.size()>0) {
|
|
|
+//
|
|
|
+// //获取所有批次的id
|
|
|
+// List<Long> lotIds = taskStockList.stream().map(BizTaksStockInboundOrderDetail::getLotId).distinct().collect(Collectors.toList());
|
|
|
+// //根据批次id查询到对应批次的零存或领取信息
|
|
|
+// List<BizStorageRetrieval> storageRetrievalList = bizStorageRetrievalService.query().in("lot_id", lotIds).or().in("retrieval_lot_id", lotIds).list();
|
|
|
+// //根据批次id查询到对应批次已经上架的入库单信息
|
|
|
+// List<BizInboundOrderDetail> inboundOrderDetailList = bizInboundOrderDetailService.query().in("lot_id", lotIds).eq("is_inbound", 1).list();
|
|
|
+// //根据批次id查询到对应批次的盘点批次信息
|
|
|
+// List<BizTaksStockLot> filteredList = list.stream().filter(item -> lotIds.contains(item.getLotId())).collect(Collectors.toList());
|
|
|
+//
|
|
|
+// // 创建映射,计算每个批次的零存数量
|
|
|
+// Map<Long, Long> storageNumByLotId = storageRetrievalList.stream()
|
|
|
+// .collect(Collectors.groupingBy(
|
|
|
+// BizStorageRetrieval::getLotId,
|
|
|
+// Collectors.summingLong(BizStorageRetrieval::getStorageNum)
|
|
|
+// ));
|
|
|
+//
|
|
|
+// // 创建映射,计算每个批次的领取数量
|
|
|
+// Map<Long, Long> storageNumByRetrievalLotId = storageRetrievalList.stream()
|
|
|
+// .collect(Collectors.groupingBy(
|
|
|
+// BizStorageRetrieval::getRetrievalLotId,
|
|
|
+// Collectors.summingLong(BizStorageRetrieval::getStorageNum)
|
|
|
+// ));
|
|
|
+//
|
|
|
+// // 创建映射,计算每个批次的入库数量
|
|
|
+// Map<Long, Long> inboundNumByLotId = inboundOrderDetailList.stream()
|
|
|
+// .collect(Collectors.groupingBy(
|
|
|
+// BizInboundOrderDetail::getLotId,
|
|
|
+// Collectors.summingLong(BizInboundOrderDetail::getInboundNum)
|
|
|
+// ));
|
|
|
+//
|
|
|
+// // 已经全部上架的批次id
|
|
|
+// List<Long> endIds=new ArrayList<>();
|
|
|
+// for (BizTaksStockLot item : filteredList) {
|
|
|
+// //拿到当前批次的盘点数量
|
|
|
+// long resultNum = item.getProdNum();
|
|
|
+// // 减去零存数量
|
|
|
+// resultNum -= storageNumByLotId.getOrDefault(item.getLotId(), 0L);
|
|
|
+//
|
|
|
+// // 加上领取数量
|
|
|
+// resultNum += storageNumByRetrievalLotId.getOrDefault(item.getLotId(), 0L);
|
|
|
+//
|
|
|
+// // 减去入库数量
|
|
|
+// resultNum -= inboundNumByLotId.getOrDefault(item.getLotId(), 0L);
|
|
|
+//
|
|
|
+// // 判断当前批次的盘点数量是否为0
|
|
|
+// // 如果为0,则表示该批次已经全部入库
|
|
|
+// if (resultNum == 0) {
|
|
|
+// endIds.add(item.getId());
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// // 将已将全部上架的批次从taskStockList与lotIds中移除
|
|
|
+// taskStockList.removeIf(item -> endIds.contains(item.getId()));
|
|
|
+// lotIds.removeAll(endIds);
|
|
|
+//
|
|
|
+//
|
|
|
+//
|
|
|
+// //拿到所有批次的信息
|
|
|
+// List<BizLot> lotList = bizLotService.query().in("id", lotIds).list();
|
|
|
+// //拿到所有合格证id
|
|
|
+// List<Long> certificateLotIds = taskStockList.stream().map(BizTaksStockInboundOrderDetail::getCertificateLotId).distinct().collect(Collectors.toList());
|
|
|
+// //拿到所有合格证信息
|
|
|
+// List<BizCertificateLot> certificateLotList = bizCertificateLotService.query().in("id", certificateLotIds).list();
|
|
|
+// for (BizTaksStockInboundOrderDetail item : taskStockList) {
|
|
|
+// item.setTakeStockPeriodId(bizTakeStockPeriod.getId());
|
|
|
+// item.setStockYear(bizTakeStockPeriod.getStockYear());
|
|
|
+// item.setStockMonth(bizTakeStockPeriod.getStockMonth());
|
|
|
+// //投入数是当前批次所有的入库数量
|
|
|
+// List<BizTaksStockInboundOrderDetail> collect = taskStockList.stream().filter(task -> task.getLotCode().equals(item.getLotCode())).collect(Collectors.toList());
|
|
|
+// item.setProdNum(collect.stream().mapToLong(BizTaksStockInboundOrderDetail::getInboundNum).sum());
|
|
|
+// BizLot bizLot = lotList.stream().filter(lot -> lot.getId().equals(item.getLotId())).findFirst().orElse(null);
|
|
|
+// item.setIsWaste(bizLot.getIsWaste());
|
|
|
+// item.setIsAmend(bizLot.getIsAmend());
|
|
|
+// item.setIsWasteRecycling(bizLot.getIsWasteRecycling());
|
|
|
+// item.setIsSuperaddition(bizLot.getIsSuperaddition());
|
|
|
+//
|
|
|
+// item.setFromId(bizLot.getFromId());
|
|
|
+// BizCertificateLot bizCertificateLot = certificateLotList.stream().filter(certificateLot -> certificateLot.getId().equals(item.getCertificateLotId())).findFirst().orElse(null);
|
|
|
+// item.setBarcode(bizCertificateLot.getBarcode());
|
|
|
+// }
|
|
|
+// bizTaksStockInboundOrderDetailService.saveBatch(taskStockList);
|
|
|
+// }
|
|
|
+// //盘点合格证信息表
|
|
|
+// List<BizTaksStockCertificateLot> certificateList = bizCertificateLotService.getTaskStockList();
|
|
|
+// if(certificateList.size()>0){
|
|
|
+// List<Long> companyIds = certificateList.stream().map(BizTaksStockCertificateLot::getCompanyId).distinct().collect(Collectors.toList());
|
|
|
+// List<BizCompany> companyList = bizCompanyService.query().in("id", companyIds).list();
|
|
|
+// List<Long> lotIds = certificateList.stream().map(BizTaksStockCertificateLot::getLotId).distinct().collect(Collectors.toList());
|
|
|
+// List<BizLot> lotList = bizLotService.query().in("id", lotIds).list();
|
|
|
+// for (BizTaksStockCertificateLot item : certificateList){
|
|
|
+// item.setTakeStockPeriodId(bizTakeStockPeriod.getId());
|
|
|
+// item.setStockYear(bizTakeStockPeriod.getStockYear());
|
|
|
+// item.setStockMonth(bizTakeStockPeriod.getStockMonth());
|
|
|
+// //投入数是当前批次所有的入库数量
|
|
|
+// List<BizTaksStockCertificateLot> collect = certificateList.stream().filter(task -> task.getLotCode().equals(item.getLotCode())).collect(Collectors.toList());
|
|
|
+// item.setProdNum(collect.stream().mapToLong(BizTaksStockCertificateLot::getTempProdNum).sum());
|
|
|
+// BizCompany bizCompany = companyList.stream().filter(company -> company.getId().equals(item.getCompanyId())).findFirst().orElse(null);
|
|
|
+// item.setCompanyName(bizCompany.getCompanyName());
|
|
|
+// item.setCompanyCode(bizCompany.getCompanyCode());
|
|
|
+// BizLot bizLot = lotList.stream().filter(lot -> lot.getId().equals(item.getLotId())).findFirst().orElse(null);
|
|
|
+// item.setIsWaste(bizLot.getIsWaste());
|
|
|
+// item.setIsAmend(bizLot.getIsAmend());
|
|
|
+// item.setIsWasteRecycling(bizLot.getIsWasteRecycling());
|
|
|
+// item.setIsSuperaddition(bizLot.getIsSuperaddition());
|
|
|
+// item.setFromId(bizLot.getFromId());
|
|
|
+// }
|
|
|
+// bizTaksStockCertificateLotService.saveBatch(certificateList);
|
|
|
+// }
|
|
|
}else{
|
|
|
//缩小连接池
|
|
|
bizTakeStockPeriodService.updateDruidPoolSize(200);
|