|  |  | @ -168,58 +168,61 @@ public class PurPlanController { | 
			
		
	
		
		
			
				
					
					|  |  |  |         purApplyEntity.setAuditUser(userId + ""); |  |  |  |         purApplyEntity.setAuditUser(userId + ""); | 
			
		
	
		
		
			
				
					
					|  |  |  |         purApplyEntity.setStatus(postPurPlanRequest.getEditStatus()); |  |  |  |         purApplyEntity.setStatus(postPurPlanRequest.getEditStatus()); | 
			
		
	
		
		
			
				
					
					|  |  |  |         purPlanService.update(purApplyEntity); |  |  |  |         purPlanService.update(purApplyEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |         String billNo=""; | 
			
				
				
			
		
	
		
		
	
		
		
			
				
					
					|  |  |  |         List<PurPlanDetailEntity> purPlanDetailEntities = purPlanDetailService.findByOrderId(purApplyEntity.getId() + ""); |  |  |  |         List<PurPlanDetailEntity> purPlanDetailEntities = purPlanDetailService.findByOrderId(purApplyEntity.getId() + ""); | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         //对计划单里面的供应商进行分组
 | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  |         Map<String, List<PurPlanDetailEntity>> map = purPlanDetailEntities.stream().collect(Collectors.groupingBy(PurPlanDetailEntity::getSupId)); | 
			
		
	
		
		
			
				
					
					|  |  |  |  |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |         if (postPurPlanRequest.getEditStatus() == ConstantStatus.APPLY_AUDIT_ED) { |  |  |  |         if (postPurPlanRequest.getEditStatus() == ConstantStatus.APPLY_AUDIT_ED) { | 
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  | 
 | 
			
		
	
		
		
			
				
					
					|  |  |  |             if (CollUtil.isNotEmpty(purPlanDetailEntities) && postPurPlanRequest.isAutoPurchase()==true |  |  |  |             if (CollUtil.isNotEmpty(purPlanDetailEntities) && postPurPlanRequest.isAutoPurchase()==true | 
			
		
	
		
		
			
				
					
					|  |  |  |                     && StrUtil.isNotEmpty(postPurPlanRequest.getTargetSubInv())  && StrUtil.isNotEmpty(postPurPlanRequest.getTargetBillAction()) ) { |  |  |  |                     && StrUtil.isNotEmpty(postPurPlanRequest.getTargetSubInv())  && StrUtil.isNotEmpty(postPurPlanRequest.getTargetBillAction()) ) { | 
			
		
	
		
		
			
				
					
					|  |  |  |                 //生产单据表信息
 |  |  |  | 
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 IoOrderEntity ioOrderEntity=new IoOrderEntity(); |  |  |  |                 for (Map.Entry<String, List<PurPlanDetailEntity>> m:map.entrySet()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setBillNo(gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER ,"yyyyMMdd"))); |  |  |  |                     //生产单据表信息
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setCorpOrderId(CustomUtil.getDate()); |  |  |  |                     IoOrderEntity ioOrderEntity=new IoOrderEntity(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setMainAction(ConstantType.TYPE_PUT); |  |  |  |                     ioOrderEntity.setBillNo(gennerOrderUtils.createScOrderNo(new OrderNoTypeBean(Constant.SCAN_ORDER ,"yyyyMMdd"))); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setAction(postPurPlanRequest.getTargetBillAction()); |  |  |  |                     ioOrderEntity.setCorpOrderId(CustomUtil.getDate()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setFromCorp("1111"); |  |  |  |                     ioOrderEntity.setMainAction(ConstantType.TYPE_PUT); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setFromType(ConstantStatus.FROM_PLAN); |  |  |  |                     ioOrderEntity.setAction(postPurPlanRequest.getTargetBillAction()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setStatus(1); |  |  |  |                     ioOrderEntity.setFromCorp(m.getKey()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setDealStatus(1); |  |  |  |                     ioOrderEntity.setFromType(ConstantStatus.FROM_PLAN); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setCreateTime(new Date()); |  |  |  |                     ioOrderEntity.setStatus(1); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setCreateUser(postPurPlanRequest.getPurPlanEntity().getAuditUser()); |  |  |  |                     ioOrderEntity.setDealStatus(1); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setUpdateTime(new Date()); |  |  |  |                     ioOrderEntity.setOrderType(1); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setUpdateUser(postPurPlanRequest.getPurPlanEntity().getAuditUser()); |  |  |  |                     ioOrderEntity.setCreateTime(new Date()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setCustomerId("110"); |  |  |  |                     ioOrderEntity.setCreateUser(postPurPlanRequest.getPurPlanEntity().getAuditUser()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setDeptCode(postPurPlanRequest.getTargetDeptCode()); |  |  |  |                     ioOrderEntity.setUpdateTime(new Date()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderEntity.setInvCode(postPurPlanRequest.getTargetSubInv()); |  |  |  |                     ioOrderEntity.setUpdateUser(postPurPlanRequest.getPurPlanEntity().getAuditUser()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 ioOrderService.insertOrder(ioOrderEntity); |  |  |  |                     ioOrderEntity.setCustomerId("110"); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 //插入业务单表
 |  |  |  |                     ioOrderEntity.setDeptCode(postPurPlanRequest.getTargetDeptCode()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 //查询详情表
 |  |  |  |                     ioOrderEntity.setInvCode(postPurPlanRequest.getTargetSubInv()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 List<PurPlanDetailEntity> purPlanDetailEntityList=purPlanDetailService.findByOrderId(postPurPlanRequest.getPurPlanEntity().getId()+""); |  |  |  |                     ioOrderService.insertOrder(ioOrderEntity); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                for (PurPlanDetailEntity obj:purPlanDetailEntityList){ |  |  |  |                     billNo+=ioOrderEntity.getBillNo()+","; | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                    //插入业务单表
 | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    BasicProductsEntity basicProductsEntity=purPlanDetailService.selectIoOrderDetailBiz(obj.getId()); |  |  |  |                     for (PurPlanDetailEntity obj:m.getValue()) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                         BasicProductsEntity basicProductsEntity = purPlanDetailService.selectIoOrderDetailBiz(obj.getId()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    IoOrderDetailBizEntity ioOrderDetailBizEntity=new IoOrderDetailBizEntity(); |  |  |  |                         IoOrderDetailBizEntity ioOrderDetailBizEntity = new IoOrderDetailBizEntity(); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setOrderIdFk(ioOrderEntity.getId()+""); |  |  |  |                         ioOrderDetailBizEntity.setOrderIdFk(ioOrderEntity.getBillNo()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setBindRlFk(Long.valueOf(obj.getProductId())); |  |  |  |                         ioOrderDetailBizEntity.setBindRlFk(Long.valueOf(obj.getProductId())); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setCount(obj.getCount()); |  |  |  |                         ioOrderDetailBizEntity.setCount(obj.getCount()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid()); |  |  |  |                         ioOrderDetailBizEntity.setUuidFk(basicProductsEntity.getUuid()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode()); |  |  |  |                         ioOrderDetailBizEntity.setNameCode(basicProductsEntity.getNameCode()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc()); |  |  |  |                         ioOrderDetailBizEntity.setCoName(basicProductsEntity.getCpmctymc()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh()); |  |  |  |                         ioOrderDetailBizEntity.setCertCode(basicProductsEntity.getZczbhhzbapzbh()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setYlqxzcrbarmc(basicProductsEntity.getYlqxzcrbarmc()); |  |  |  |                         ioOrderDetailBizEntity.setYlqxzcrbarmc(basicProductsEntity.getYlqxzcrbarmc()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setManufacturer(basicProductsEntity.getManufactory()); |  |  |  |                         ioOrderDetailBizEntity.setManufacturer(basicProductsEntity.getManufactory()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setMeasname(basicProductsEntity.getMeasname()); |  |  |  |                         ioOrderDetailBizEntity.setMeasname(basicProductsEntity.getMeasname()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setSpec(basicProductsEntity.getGgxh()); |  |  |  |                         ioOrderDetailBizEntity.setSpec(basicProductsEntity.getGgxh()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    if(basicProductsEntity.getPrice()!=null) { |  |  |  |                         if (basicProductsEntity.getPrice() != null) { | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                        ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice())); |  |  |  |                             ioOrderDetailBizEntity.setPrice(BigDecimal.valueOf(basicProductsEntity.getPrice())); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    } |  |  |  |                         } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizEntity.setSupId(obj.getSupId()); |  |  |  |                         ioOrderDetailBizEntity.setSupId(obj.getSupId()); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                    ioOrderDetailBizService.insert(ioOrderDetailBizEntity); |  |  |  |                         ioOrderDetailBizService.insert(ioOrderDetailBizEntity); | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                } |  |  |  |                     } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  | 
 |  |  |  |                 } | 
			
				
				
			
		
	
		
		
			
				
					
					|  |  |  |                 purApplyEntity.setStockOrderNo(ioOrderEntity.getBillNo()); |  |  |  |                 purApplyEntity.setStockOrderNo(billNo.substring(0,billNo.length()-1)); | 
			
				
				
			
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
	
		
		
			
				
					
					|  |  |  |                 purPlanService.update(purApplyEntity); |  |  |  |                 purPlanService.update(purApplyEntity); | 
			
		
	
		
		
			
				
					
					|  |  |  |             } |  |  |  |             } | 
			
		
	
		
		
			
				
					
					|  |  |  |         } |  |  |  |         } | 
			
		
	
	
		
		
			
				
					|  |  | 
 |