| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				 | 
				
					@ -101,108 +101,110 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        List<String> requestIdList = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        List<DetailsOfCentralized> updateList = new ArrayList<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //更新采购申请信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        centralizedRequestList.forEach(centralizedRequest -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            requestIdList.add(centralizedRequest.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            centralizedRequest.setStatus(ReagentStatusConstants.CENTRALIZED_PURCHASING_TO_PLAN.getStatus()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            centralizedRequest.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        requestService.updateBatchById(centralizedRequestList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        List<DetailsOfCentralized> detailsOfCentralizeds = detailsOfCentralizedService.list(Wrappers.<DetailsOfCentralized>lambdaQuery().in(DetailsOfCentralized::getCentralizedRequestId, requestIdList)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        boolean flag = true;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        Map<String, List<DetailsOfCentralized>> map = detailsOfCentralizeds.stream().collect(Collectors.groupingBy(item -> item.getReagentConsumableId())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        map.forEach((key, value) -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //证明有重复购买的物品,需要合并
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            if (value.size() > 1) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                fillData(procurementContent, value.get(0)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setQuantityPurchased(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setNumberOfApplications(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                value.forEach(detailsOfCentralized -> { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    updateList.add(detailsOfCentralized); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    procurementContent.setQuantityPurchased(procurementContent.getQuantityPurchased() + detailsOfCentralized.getQuantityPurchased()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setNumberOfApplications(procurementContent.getQuantityPurchased()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                list.add(procurementContent);//将计划明细添加至集合
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                DetailsOfCentralized detailsOfCentralized = value.get(0); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                fillData(procurementContent, detailsOfCentralized); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setQuantityPurchased(procurementContent.getNumberOfApplications()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                list.add(procurementContent);//将计划明细添加至集合
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                updateList.add(detailsOfCentralized); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        for (DetailsOfCentralized detailsOfCentralized1 : detailsOfCentralizedAllList) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            PurchasingPlanDTO purchasingPlanDTO = new PurchasingPlanDTO();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            BeanUtils.copyProperties(detailsOfCentralized1, purchasingPlanDTO);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            purchasingPlanDTO.setDetailsOfCentralizedId(detailsOfCentralized1.getId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //将列入计划的集中采购申请状态变为3
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            CentralizedRequest centralizedRequest = requestService.getById(detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId()).getCentralizedRequestId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            centralizedRequest.setStatus(3);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        centralizedRequestList.forEach(centralizedRequest -> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            requestIdList.add(centralizedRequest.getId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            centralizedRequest.setStatus(ReagentStatusConstants.CENTRALIZED_PURCHASING_TO_PLAN.getStatus());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            centralizedRequest.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            requestService.updateById(centralizedRequest);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            DetailsOfCentralized detailsOfCentralized = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId());//集中采购申请明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            ReagentConsumables reagentConsumables = reagentConsumablesService.getById(detailsOfCentralized.getReagentConsumableId());//试剂耗材信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            flag = true;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //合并相同的采购内容,若存在相同的采购物品,则无需创建计划明细,将采购申请明细与该计划明细关联即可
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            if (list.size() != 0) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                for (int i = 0; i < list.size(); i++) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    if (list.get(i).getReagentConsumableId().equals(purchasingPlanDTO.getReagentConsumableId())) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        list.get(i).setUnitPrice(reagentConsumables.getUnitPrice());//获取单价
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        //Set采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        list.get(i).setQuantityPurchased(list.get(i).getQuantityPurchased() + purchasingPlanDTO.getNumberOfApplications());//合并之前的数量加上被合并对象的数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        list.get(i).setSubtotal(list.get(i).getQuantityPurchased() * list.get(i).getUnitPrice());//计算小计
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        //添加采购申请明细的采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        detailsOfCentralized.setProcurementContentId(list.get(i).getProcurementContentId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        detailsOfCentralizedService.updateById(detailsOfCentralized);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        //被合并后,改变flag,进入下一个循环
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                        flag = false;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                //无需合并的采购计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                if (flag) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    BeanUtils.copyProperties(purchasingPlanDTO, procurementContent);//拷贝
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    procurementContent.setQuantityPurchased(purchasingPlanDTO.getNumberOfApplications());//赋值采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());//赋值采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    procurementContent.setUnitPrice(reagentConsumables.getUnitPrice());//单价
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased());//小计
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId());//采购申请明细关联采购计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    detailsOfCentralizedService.updateById(detailsOfCentralized);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    list.add(procurementContent);//将计划明细添加至集合
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            } else {//对于首次循环,List一定为空,故执行下列语句,且只会执行一次
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                ProcurementContent procurementContent = new ProcurementContent();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                BeanUtils.copyProperties(purchasingPlanDTO, procurementContent);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                DetailsOfCentralized byId = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                byId.setQuantityPurchased(byId.getNumberOfApplications());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        });
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        requestService.updateBatchById(centralizedRequestList);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        List<DetailsOfCentralized> detailsOfCentralizeds = detailsOfCentralizedService.list(Wrappers.<DetailsOfCentralized>lambdaQuery().in(DetailsOfCentralized::getCentralizedRequestId, idList)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        boolean flag = true;
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        Map<String, List<DetailsOfCentralized>> map = detailsOfCentralizeds.stream().collect(Collectors.groupingBy(item -> item.getReagentConsumableId()));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        map.forEach((key, value) -> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            //证明有重复购买的物品,需要合并
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            if (value.size() > 1) {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                fillData(procurementContent, value.get(0));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setQuantityPurchased(0);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setNumberOfApplications(0);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                value.forEach(detailsOfCentralized -> {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    updateList.add(detailsOfCentralized);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                    procurementContent.setQuantityPurchased(procurementContent.getQuantityPurchased() + detailsOfCentralized.getQuantityPurchased());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                });
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setNumberOfApplications(procurementContent.getQuantityPurchased());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                list.add(procurementContent);//将计划明细添加至集合
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            } else {
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                DetailsOfCentralized detailsOfCentralized = value.get(0);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                fillData(procurementContent, detailsOfCentralized);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setQuantityPurchased(procurementContent.getNumberOfApplications());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setUnitPrice(reagentConsumables.getUnitPrice());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setSubtotal(procurementContent.getQuantityPurchased() * procurementContent.getUnitPrice());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                byId.setProcurementContentId(procurementContent.getProcurementContentId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                detailsOfCentralizedService.updateById(byId);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                list.add(procurementContent);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                list.add(procurementContent);//将计划明细添加至集合
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//                updateList.add(detailsOfCentralized);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//            }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        }
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					//        });
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        boolean flag = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        for (DetailsOfCentralized detailsOfCentralized1 : detailsOfCentralizeds) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            PurchasingPlanDTO purchasingPlanDTO = new PurchasingPlanDTO(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            BeanUtils.copyProperties(detailsOfCentralized1, purchasingPlanDTO); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            purchasingPlanDTO.setDetailsOfCentralizedId(detailsOfCentralized1.getId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //将列入计划的集中采购申请状态变为3
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            CentralizedRequest centralizedRequest = requestService.getById(detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId()).getCentralizedRequestId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            centralizedRequest.setStatus(3); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            centralizedRequest.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            requestService.updateById(centralizedRequest); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            DetailsOfCentralized detailsOfCentralized = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId());//集中采购申请明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            ReagentConsumables reagentConsumables = reagentConsumablesService.getById(detailsOfCentralized.getReagentConsumableId());//试剂耗材信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            flag = true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //合并相同的采购内容,若存在相同的采购物品,则无需创建计划明细,将采购申请明细与该计划明细关联即可
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            if (list.size() != 0) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                for (int i = 0; i < list.size(); i++) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    if (list.get(i).getReagentConsumableId().equals(purchasingPlanDTO.getReagentConsumableId())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        list.get(i).setUnitPrice(reagentConsumables.getUnitPrice());//获取单价
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        //Set采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        list.get(i).setQuantityPurchased(list.get(i).getQuantityPurchased() + purchasingPlanDTO.getNumberOfApplications());//合并之前的数量加上被合并对象的数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        list.get(i).setSubtotal(list.get(i).getQuantityPurchased() * list.get(i).getUnitPrice());//计算小计
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        //添加采购申请明细的采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        detailsOfCentralized.setProcurementContentId(list.get(i).getProcurementContentId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        detailsOfCentralizedService.updateById(detailsOfCentralized); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        //被合并后,改变flag,进入下一个循环
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                        flag = false; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                //无需合并的采购计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                if (flag) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    ProcurementContent procurementContent = new ProcurementContent();//新建计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    BeanUtils.copyProperties(purchasingPlanDTO, procurementContent);//拷贝
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId());//关联计划ID
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    procurementContent.setQuantityPurchased(purchasingPlanDTO.getNumberOfApplications());//赋值采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    detailsOfCentralized.setQuantityPurchased(detailsOfCentralized.getNumberOfApplications());//赋值采购数量
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    procurementContent.setUnitPrice(reagentConsumables.getUnitPrice());//单价
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    procurementContent.setSubtotal(procurementContent.getUnitPrice() * procurementContent.getQuantityPurchased());//小计
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    detailsOfCentralized.setProcurementContentId(procurementContent.getProcurementContentId());//采购申请明细关联采购计划明细
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    detailsOfCentralizedService.updateById(detailsOfCentralized); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                    list.add(procurementContent);//将计划明细添加至集合
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            } else {//对于首次循环,List一定为空,故执行下列语句,且只会执行一次
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                ProcurementContent procurementContent = new ProcurementContent(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                BeanUtils.copyProperties(purchasingPlanDTO, procurementContent); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                DetailsOfCentralized byId = detailsOfCentralizedService.getById(purchasingPlanDTO.getDetailsOfCentralizedId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                byId.setQuantityPurchased(byId.getNumberOfApplications()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setProcurementContentId(IdWorker.get32UUID().toUpperCase()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setPurchasingPlanId(purchasingPlan.getPurchasingPlanId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setQuantityPurchased(procurementContent.getNumberOfApplications()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setUnitPrice(reagentConsumables.getUnitPrice()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                procurementContent.setSubtotal(procurementContent.getQuantityPurchased() * procurementContent.getUnitPrice()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                byId.setProcurementContentId(procurementContent.getProcurementContentId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                detailsOfCentralizedService.updateById(byId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                list.add(procurementContent); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        if (this.save(purchasingPlan) & procurementContentService.saveBatch(list) && detailsOfCentralizedService.updateBatchById(updateList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            calculatedAmount(purchasingPlan, list);//计算经费预算
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				 | 
				
					@ -329,7 +331,7 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        procurementContentService.updateById(procurementContent); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        detailsOfCentralizedService.updateById(detailsOfCentralized); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        //计算修改后的经费
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        calculatedAmount(purchasingPlan, procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        return procurementContent; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					    } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				 | 
				
					@ -355,7 +357,7 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        if (procurementContentService.updateById(procurementContent) && detailsOfCentralizedService.updateById(detailsOfCentralized)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            //计算经费
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            calculatedAmount(purchasingPlan, procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            return procurementContent; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } else throw new RuntimeException(String.format("修改失败")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					    } | 
				
			
			
		
	
	
		
			
				
					| 
						
						
						
							
								
							
						
					 | 
				
				 | 
				 | 
				
					@ -381,7 +383,7 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                this.removeById(purchasingPlan); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					                return true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            calculatedAmount(purchasingPlan, procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            return true; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } else { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            return null; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				 | 
				
					@ -473,7 +475,7 @@ public class PurchasingPlanServiceImpl extends ServiceImpl<PurchasingPlanMapper, | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        purchasingPlan.setStatus(1); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        purchasingPlan.setCommitTime(LocalDateTime.now());//
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        if (this.updateById(purchasingPlan)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            calculatedAmount(purchasingPlan,procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            calculatedAmount(purchasingPlan, procurementContentService.list(Wrappers.<ProcurementContent>lambdaQuery().eq(ProcurementContent::getPurchasingPlanId, purchasingPlan.getPurchasingPlanId()))); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					            return purchasingPlan; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					        } else throw new RuntimeException(String.format("提交失败")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				 | 
				
					
 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				 | 
				
					
  |