| 
					
				 | 
			
			
				@@ -504,97 +504,21 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	List<FabricOMOrder> setFabricOMOrderOutDetail(List<FabricOMOrder> fabricOMOrderList, String code){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		List<FabricMoOrderCK> fabricMoOrderCKList = fabricLossMapper.getOmOutDetailList(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 获取委外订单行id,入库物料编号+颜色,处理费用,入库数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<Map<String,Object>> rowInfoList = fabricLossMapper.getOmRowInfoList(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 获取委外订单行id,出库物料信息,出库数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<FabricMoOrderCK> rowOutList = fabricLossMapper.getOmRowOutList(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 获取委外订单出库物料的入库物料信息:包含采购入库、委外入库、其他入库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<Map<String,Object>> rowInList = fabricLossMapper.getOmRowInList(code); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-		for (FabricOMOrder fabricOMOrder : fabricOMOrderList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			List<FabricMoOrderCK> findList = fabricMoOrderCKList.stream().filter(e-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					e.getCInvCodeIn().equals(fabricOMOrder.getCInvCode()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					oConvertUtils.getString(e.getCColorIn()).equals(fabricOMOrder.getCColor())).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<FabricMoOrderCK> fabricMoOrderCKList = getFabricMoOrderCKList(rowInfoList, rowOutList, rowInList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			// 设置成本,循环查找上一级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			if (findList.size() == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			FabricMoOrderCK preItem = findList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			double preMoney = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			boolean abnormal = false; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			while (true){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				FabricMoOrderCK tempItem = preItem; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				List<FabricMoOrderCK> preList = fabricMoOrderCKList.stream().filter(e-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						e.getCInvCodeIn().equals(tempItem.getCInvCodeOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						oConvertUtils.getString(e.getCColorIn()).equals(tempItem.getCColorOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						oConvertUtils.getString(e.getCBatchIn()).equals(tempItem.getCBatchOut())).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (preList.size() == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				// 有两行单价不一样的,报异常。委外取加工单价,采购取采购单价 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				double price = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				for (FabricMoOrderCK ckItem : preList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					double tmpPrice = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if ("委外加工".equals(ckItem.getCBusType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						tmpPrice = ckItem.getIProcessPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					}else if ("普通采购".equals(ckItem.getCBusType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						tmpPrice = ckItem.getIPurchusePrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if (price == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						price = tmpPrice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						if (price != tmpPrice){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							abnormal = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							preMoney = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-							break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (price == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					abnormal = true; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (abnormal){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				preMoney += preItem.getIQuantityIn()*price; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				preItem = preList.get(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			// 设置出库数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			//double shouldOutSum = fabricOMOrder.getIQuantityOut(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			for (FabricMoOrderCK ckItem : findList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				//double curInSum = ckItem.getIQuantityIn(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				double curOut = ckItem.getIQuantityOut(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//				if (shouldOutSum>curInSum){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//					curOut = curInSum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//				}else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//					curOut = shouldOutSum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				BigDecimal bdVal = new BigDecimal(curOut); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				ckItem.setIQuantity(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				double tmpPrice = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				double tmpMoney = preMoney; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				if (!abnormal){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if ("委外加工".equals(ckItem.getCBusType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						tmpPrice = ckItem.getIProcessPrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					}else if ("普通采购".equals(ckItem.getCBusType())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						tmpPrice = ckItem.getIPurchusePrice(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					tmpMoney += ckItem.getIQuantityIn()*tmpPrice; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					if (ckItem.getIQuantity()>0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						bdVal = new BigDecimal(tmpMoney); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						ckItem.setIMoney(bdVal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						bdVal = new BigDecimal(tmpMoney / ckItem.getIQuantity()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-						ckItem.setIPrice(bdVal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for (FabricOMOrder fabricOMOrder : fabricOMOrderList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 根据入库物料过滤 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List<FabricMoOrderCK> findOutList = fabricMoOrderCKList.stream().filter(e-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					e.getCInvCodeColorIn().equals(fabricOMOrder.getCInvCode()+fabricOMOrder.getCColor())).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//				shouldOutSum-=curOut; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//				if (shouldOutSum<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//					break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-//				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-			fabricOMOrder.setFabricMoOrderCKList(findList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			fabricOMOrder.setFabricMoOrderCKList(findOutList); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return fabricOMOrderList; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -743,4 +667,129 @@ public class FabricLossServiceImpl extends ServiceImpl<FabricLossMapper, FabricL 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 		return fabricPoOrderLyys; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	/** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 * 计算委外订单成本 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 * @param rowInfoList - 委外订单行信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 * @param rowOutList - 材料出库信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 * @param rowInList - 材料入库信息 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	 */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	List<FabricMoOrderCK> getFabricMoOrderCKList(List<Map<String,Object>> rowInfoList, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	                                             List<FabricMoOrderCK> rowOutList, 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	                                             List<Map<String,Object>> rowInList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 从最底层的物料向上逐级设置材料入库成本 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		do { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 可设置金额材料出库委外订单行id 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List<FabricMoOrderCK> findOutCanSetList = rowOutList.stream().filter(out->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return rowInList.stream().filter(in-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					oConvertUtils.getDouble(in.get("iPurchuseMoney").toString(),0)>0 && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							in.get("cInvCode").toString().equals(out.getCInvCodeOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							in.get("cColor").toString().equals(out.getCColorOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							in.get("cBatch").toString().equals(out.getCBatchOut())).count()>0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			}).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 可设置金额的入库单 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List<Map<String,Object>> findInCanSetList = rowInList.stream().filter(in->{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				return oConvertUtils.getDouble(in.get("iPurchuseMoney").toString(),0) == 0 && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						findOutCanSetList.stream().filter(out-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							oConvertUtils.getInt(in.get("MODetailsID")).equals(out.getMODetailsID())).count()>0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			}).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (findInCanSetList.size() == 0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 设置入库单金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for (Map<String,Object> item : findInCanSetList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				// 本次入库加工费 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Optional<Map<String,Object>> findRowInfoOpt = rowInfoList.stream().filter(info-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						oConvertUtils.getInt(info.get("MODetailsID")).equals(oConvertUtils.getInt(item.get("MODetailsID"))) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				).findFirst(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if (!findRowInfoOpt.isPresent()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Map<String,Object> findRowInfo = findRowInfoOpt.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				// 本次加工费用 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double iProcessFee = oConvertUtils.getDouble(findRowInfo.get("iProcessFee").toString(),0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				// 本次入库总数量 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double iQuantityIn = oConvertUtils.getDouble(findRowInfo.get("iQuantityIn").toString(),0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				// 出库材料费 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double iOutFee = 0.0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				List<FabricMoOrderCK> findOutList = rowOutList.stream().filter(out->out.getMODetailsID().equals(oConvertUtils.getInt(item.get("MODetailsID")))).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				for (FabricMoOrderCK itemOut : findOutList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					Double outSum = itemOut.getIQuantityOut(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					// 获取出库的入库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					List<Map<String,Object>> findInByOutList = rowInList.stream().filter(in-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						in.get("cInvCode").toString().equals(itemOut.getCInvCodeOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						in.get("cColor").toString().equals(itemOut.getCColorOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						in.get("cBatch").toString().equals(itemOut.getCBatchOut())).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					for (Map<String,Object> itemIn :findInByOutList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						Double inSum = oConvertUtils.getDouble(itemIn.get("iQuantity").toString(),0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						Double iPurchuseMoney = oConvertUtils.getDouble(itemIn.get("iPurchuseMoney").toString(),0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						Double curSum = outSum>inSum?inSum:outSum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						outSum -= curSum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						iOutFee += curSum*iPurchuseMoney/inSum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						if (outSum<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+						} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				// 单价 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double iPrice = (iOutFee+iProcessFee)/iQuantityIn; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				// 设置采购金额 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				item.put("iPurchuseMoney", iPrice*oConvertUtils.getDouble(item.get("iQuantity").toString(),0)); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} while(true); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		List<FabricMoOrderCK> ret = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		// 设置出库数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		for (FabricMoOrderCK itemOut : rowOutList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Double outSum = itemOut.getIQuantityOut(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 委外订单行 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			Optional<Map<String,Object>> findRowInfoOpt = rowInfoList.stream().filter(info-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					oConvertUtils.getInt(info.get("MODetailsID")).equals(itemOut.getMODetailsID()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			).findFirst(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			if (!findRowInfoOpt.isPresent()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				continue; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			// 获取出库的入库 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			List<Map<String,Object>> findInByOutList = rowInList.stream().filter(in-> 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					in.get("cInvCode").toString().equals(itemOut.getCInvCodeOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							in.get("cColor").toString().equals(itemOut.getCColorOut()) && 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+							in.get("cBatch").toString().equals(itemOut.getCBatchOut())).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			for (Map<String,Object> itemIn :findInByOutList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double inSum = oConvertUtils.getDouble(itemIn.get("iQuantity").toString(),0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double iPurchuseMoney = oConvertUtils.getDouble(itemIn.get("iPurchuseMoney").toString(),0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				Double curSum = outSum>inSum?inSum:outSum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				outSum -= curSum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				FabricMoOrderCK retItem = new FabricMoOrderCK(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				ret.add(retItem); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCBusType(itemIn.get("cBusType").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCCode(itemIn.get("cCode").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCVenName(itemIn.get("cVenName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCVenAbbName(itemIn.get("cVenAbbName").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCInvCodeColorIn(findRowInfoOpt.get().get("cInvCodeColorIn").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCInvCodeOut(itemOut.getCInvCodeOut()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCInvNameOut(itemOut.getCInvNameOut()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCColorOut(itemOut.getCColorOut()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setCBatchOut(itemOut.getCBatchOut()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setMODetailsID(itemOut.getMODetailsID()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				BigDecimal bdVal = new BigDecimal(curSum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setIQuantity(bdVal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setIQuantityOut(itemOut.getIQuantityOut()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setIQuantityIn(inSum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				bdVal = new BigDecimal(iPurchuseMoney/inSum*curSum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setIMoney(bdVal.setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				bdVal = new BigDecimal(iPurchuseMoney/inSum); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				retItem.setIPrice(bdVal.setScale(4, BigDecimal.ROUND_HALF_UP).doubleValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				if (outSum<=0){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+					break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+				} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+			} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+		return ret; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+	} 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |