| 
					
				 | 
			
			
				@@ -98,7 +98,7 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// 成本发票 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			setCostInvoiceList(ret, editData); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// 计算单件成本 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			Double costInTotal = ret.getFabricCostInvoiceList().stream().mapToDouble(FabricCostInvoice::getIMoney).sum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Double costInTotal = ret.getFabricCostInvoiceList().stream().filter(e->e.getIMoney() != null).mapToDouble(FabricCostInvoice::getIMoney).sum(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			BigDecimal dVal = new BigDecimal(costInTotal); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			ret.setActualMoney(dVal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			BigDecimal bdPriceReal = new BigDecimal(0); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1158,8 +1158,9 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				assemVouchsInvIdList.add(orgIn); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		int deep = 0;// 查询深度 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 获取物业原始入库单信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		while (assemVouchsInvIdList.stream().filter(e->"转换入库".equalsIgnoreCase(e.getCBusType())).count()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		while (assemVouchsInvIdList.stream().filter(e->"转换入库".equalsIgnoreCase(e.getCBusType())).count()>0 && deep < 10){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// 获取转换入库物料id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			List<String> invIdList = assemVouchsInvIdList.stream().filter(e->"转换入库".equalsIgnoreCase(e.getCBusType())).map(FabricAssemVouchsOrgIn::getCInvIdAfter).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			// 获取转换前入入库内容 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1181,6 +1182,8 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			deep++; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 设置采购入库单价 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		List<Integer> autoIdList = assemVouchsInvIdList.stream().filter(e-> 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1522,6 +1525,28 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 转入数量有负数的,从正数扣除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<FabricPoOrderIn> nList = allInList.stream().filter(e->e.getIQuantity()<0).collect(Collectors.toList());// 负数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		allInList = allInList.stream().filter(e->e.getIQuantity()>=0).collect(Collectors.toList());// 正数 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		if (nList.size()>0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for (FabricPoOrderIn nItem : nList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double nQuantity = DoubleOperation.mul(nItem.getIQuantity(),-1.0, 4); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				for (FabricPoOrderIn item : allInList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					if (item.getInvId().equalsIgnoreCase(nItem.getInvId())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						Double quantity = item.getIQuantity(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						Double subQuantity = Math.min(nQuantity, quantity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						nQuantity = DoubleOperation.sub(nQuantity, subQuantity); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						item.setIQuantity(DoubleOperation.sub(quantity, subQuantity)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if (nQuantity <= 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				nItem.setIQuantity(DoubleOperation.mul(nItem.getIQuantity(),-1.0, 4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		nList = nList.stream().filter(e->e.getIQuantity()<0).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		allInList.addAll(nList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 所有出库-委外出库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		List<FabricMoOrderCK> allOutList = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for (FabricOMOrder omOrder : allOmOrderList){ 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -1561,11 +1586,11 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				List<FabricMoOrderCK> findList = otherOutList.stream().filter(e -> e.getInvOutId().equalsIgnoreCase(item.getInvId())).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				findList.forEach(e -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 					e.setCSourceInvId(item.getCSourceInvId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					e.setIQuantityOut(DoubleOperation.mul(e.getIQuantityOut(), item.getIRate(), 2)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					e.setIQuantityOut(DoubleOperation.mul(e.getIQuantityOut(), item.getIRate(), 4)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 				}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		// 转入成本有负数的,从正数扣除 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		// 入 - 出 : 出大于0 的,是转入;入大于0 的是转出 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		for (FabricPoOrderIn itemIn : allInList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 			Double inLeft = itemIn.getIQuantity(); 
			 |