Index: ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceOptimizeManagerImpl.java =================================================================== diff -u -r30397 -r30412 --- ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceOptimizeManagerImpl.java (.../InvoiceOptimizeManagerImpl.java) (revision 30397) +++ ssts-invoice/src/main/java/com/forgon/disinfectsystem/invoicemanager/service/InvoiceOptimizeManagerImpl.java (.../InvoiceOptimizeManagerImpl.java) (revision 30412) @@ -886,8 +886,9 @@ //3.申请项与一次性物品标识的关联map(第一层map的key为申请项,value为一次性物品标识数量map(key为一次性物品标识对象,value为数量)) final Map> allTousseItemToIdentificationAmountMap = new HashMap<>(); + Map> tousseItemToIdentificationAmountMapForBatch = null; if(MapUtils.isNotEmpty(batchToIdentificationAmountMap)){ - Map> tousseItemToIdentificationAmountMapForBatch = + tousseItemToIdentificationAmountMapForBatch = findTousseItemAndMatchIdentificationAmountMapFromBatch(batchToIdentificationAmountMap, barcodeToSendAmountMap, invoicePlanId, departCoding, applyDate, invoiceGroupByConfig, invoiceOrigin, tousseDeliverOccasion, hideUnprintedDisposableGoodsInvoicePlan); @@ -899,7 +900,7 @@ //4.申请项与一次性物品标识的关联map(第一层map的key为申请项,value为一次性物品标识数量map(key为一次性物品标识对象,value为数量)) if(MapUtils.isNotEmpty(disposableGoodsToIdentificationAmountMap)){ Map> tousseItemToIdentificationAmountMapForDisposableGoods = - findTousseItemAndMatchIdentificationAmountMapFromDisposableGoods(disposableGoodsToIdentificationAmountMap, + findTousseItemAndMatchIdentificationAmountMapFromDisposableGoods(disposableGoodsToIdentificationAmountMap, tousseItemToIdentificationAmountMapForBatch, barcodeToSendAmountMap, invoicePlanId, departCoding, applyDate, invoiceGroupByConfig, invoiceOrigin, tousseDeliverOccasion, hideUnprintedDisposableGoodsInvoicePlan); if(MapUtils.isNotEmpty(tousseItemToIdentificationAmountMapForDisposableGoods)){ @@ -918,6 +919,16 @@ disposableGoodsIdentificationToAmountMap.put(key,MathTools.add(disposableGoodsIdentificationToAmountMap.get(key), amount).intValue()); }); } + //申请项剩余的待发货数量(下面的判断基本上不会进来了,先注释掉) + /*final int restWaitSendoutAmount = MathTools.sub(tousseItem.getAmount(),tousseItem.getSendOutAmount()).intValue(); + //两个map合并后的标识对应的数量和 + int summaryAmount = disposableGoodsIdentificationToAmountMap.values().stream().reduce((amount1,amount2) -> { + return MathTools.add(amount1, amount2).intValue(); + }).orElse(0); + if(summaryAmount > restWaitSendoutAmount){ + //throw new SystemException(String.format("【%s】的待发货数量为%s,扫描的数量为%s超过了待发货,请减小扫描数量!",tousseItem.getTousseName(),restWaitSendoutAmount,summaryAmount)); + throw new SystemException(String.format("【%s】的扫描的数量超过待发货数量,请调小扫描数量!",tousseItem.getTousseName())); + }*/ entry.setValue(disposableGoodsIdentificationToAmountMap); }); //遍历申请项已匹配的标识及发货数量map,如果有申请项不在allTousseItemToIdentificationAmountMap中时,将该申请项的键值对entry设值到allTousseItemToIdentificationAmountMap中 @@ -4139,6 +4150,7 @@ /** * 17.根据要发货的物品(一次性物品定义)查询待发货物品的申请项及匹配 * @param disposableGoodsToIdentificationAmountMap 一次性物品定义对应"标识对应发货数量map"的map + * @param tousseItemToIdentificationAmountMapForBatch 申请项根据批次条码已经匹配关联了的标识对象及数量的map,根据一次性物品固定条码匹配时需要扣减掉申请项按批次条码的已匹配数量 * @param barcodeToSendAmountMap 要发货的一次性物品条码(即一次性物品固定条码)对应发货数量map * @param invoicePlanId 申请单id,如果有传此值则不用科室编码进行过滤,否则用科室编码过滤 * @param departCoding 科室编码 @@ -4150,6 +4162,7 @@ */ private Map> findTousseItemAndMatchIdentificationAmountMapFromDisposableGoods( Map> disposableGoodsToIdentificationAmountMap, + Map> tousseItemToIdentificationAmountMapForBatch, Map barcodeToSendAmountMap, Long invoicePlanId,String departCoding,String applyDate,String invoiceGroupByConfig, String invoiceOrigin,String tousseDeliverOccasion,boolean hideUnprintedDisposableGoodsInvoicePlan @@ -4159,9 +4172,11 @@ if(CollectionUtils.isNotEmpty(disposableGoodsSet)){ List barcodeList = new ArrayList(); Map idToDisposableGoodsMap = new HashMap(); + Map fixBarcodeToDisposableGoodsMap = new HashMap(); disposableGoodsSet.stream().forEach(dg -> { barcodeList.add(dg.getBarcode()); idToDisposableGoodsMap.put(dg.getId(), dg); + fixBarcodeToDisposableGoodsMap.put(dg.getBarcode(), dg); }); Map> tousseItemMatchIdentiToAmountMapMap = new LinkedHashMap>(); @@ -4201,6 +4216,15 @@ for(TousseItem tousseItem : tousseItemList){ //需要发货的数量 int needSendAmount = MathTools.sub(tousseItem.getAmount(), tousseItem.getSendOutAmount()).intValue(); + if(tousseItemToIdentificationAmountMapForBatch != null){ + Map identificationAmountMapForBatch = tousseItemToIdentificationAmountMapForBatch.get(tousseItem); + if(MapUtils.isNotEmpty(identificationAmountMapForBatch)){ + int summaryAmount = identificationAmountMapForBatch.values().stream().reduce((amount1,amount2) -> { + return MathTools.add(amount1, amount2).intValue(); + }).orElse(0); + needSendAmount = MathTools.sub(needSendAmount, summaryAmount).intValue(); + } + } if(needSendAmount <= 0){ continue; } @@ -4266,6 +4290,30 @@ StringUtils.join(values,";"))); }); logger.debug("*******************findTousseItemAndMatchIdentificationAmountMapFromDisposableGoods tousseItemMatchIdentiToAmountMapMap end"); + //按物品的进行固定条码的匹配数量汇总,检查各物品的发货数量是否超过了对应所匹配的数量,如有超过则进行提示 + Map fixbarcodeToMatchedSummaryAmountMap = new HashMap<>(); + tousseItemMatchIdentiToAmountMapMap.entrySet().forEach(entry -> { + TousseItem key = entry.getKey(); + Long disposableGoodsId = key.getDisposableGoodsId(); + DisposableGoods dg = idToDisposableGoodsMap.get(disposableGoodsId); + String fixbarcode = dg.getBarcode(); + //该申请项已匹配的数量 + Map value = entry.getValue(); + int matchedAmount = value.values().stream().reduce((amount1, amount2) -> { + return MathTools.add(amount1, amount2).intValue(); + }).orElse(0); + fixbarcodeToMatchedSummaryAmountMap.put(fixbarcode,MathTools.add(fixbarcodeToMatchedSummaryAmountMap.get(fixbarcode), matchedAmount).intValue()); + }); + fixbarcodeToMatchedSummaryAmountMap.entrySet().forEach(entry -> { + String fixbarcode = entry.getKey(); + //该申请项的一次性物品固定条码对应的发货数量 + Integer sendAmount = barcodeToSendAmountMap.get(fixbarcode); + //该申请项已匹配的数量 + int matchedAmount = fixbarcodeToMatchedSummaryAmountMap.get(fixbarcode); + if(sendAmount > matchedAmount){ + throw new SystemException(String.format("【%s】的扫描的数量超过待发货数量,请调小扫描数量!",fixBarcodeToDisposableGoodsMap.get(fixbarcode).getShowName())); + } + }); return tousseItemMatchIdentiToAmountMapMap; } return null;