| 
					
				 | 
			
			
				@@ -76,12 +76,8 @@ public class OyeResultServiceImpl implements IOyeResultService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @param mapValue 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      * @return 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				      */ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public synchronized String insertInboundResult(Map<String, Object> mapValue) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<Map<String,Object>> mapList = (List<Map<String,Object>>) mapValue.get("mapList"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<OyeInboundResult> OyeInboundResults = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<OyeRealtimeInventory> oyeRealtimeInventoriesInsert = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<OyeRealtimeInventory> oyeRealtimeInventoriesUpdate = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         System.out.println("===========" + new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         JSONObject jsonObject = new JSONObject(mapValue); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         System.out.println(jsonObject); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -91,84 +87,88 @@ public class OyeResultServiceImpl implements IOyeResultService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (oyeInboundResultMapper.selectSaleMaterialID(DataChange.dataToBigDecimal(map.get("saleMaterialId"))) != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new Exception("该分录已入库,无法继续入库"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //判断该分录是否有净重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             if (DataChange.dataToBigDecimal(map.get("netWeight")) == null || DataChange.dataToBigDecimal(map.get("netWeight")).intValue() == 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 throw new Exception("该分录无净重,不允许入库"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //判断该分录是否有净重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //根据分录ID查询理重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal materialNumber = DataChange.dataToBigDecimal(map.get("materialNumber")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal theoryWeightSaleMaterial = oyeRealtimeInventoryMapper.getTheoryWeight(DataChange.dataToBigDecimal(map.get("saleMaterialId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal singleWeight = theoryWeightSaleMaterial.divide(materialNumber,4,BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //根据分录理重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            OyeInboundResult oyeInboundResult = new OyeInboundResult(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal theoryWeight = DataChange.dataToBigDecimal(map.get("theoryWeight")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal meter = DataChange.dataToBigDecimal(map.get("meter")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setResultId(oyeInboundResultMapper.getResultId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setSaleArea(map.get("saleArea").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setConsigneeId(DataChange.dataToBigDecimal(map.get("consigneeId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setCapacityId(DataChange.dataToBigDecimal(map.get("capacityId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setOrderId(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setSaleMaterialId(DataChange.dataToBigDecimal(map.get("saleMaterialId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setCapacityNumbher(map.get("capacityNumber") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setInboundArea(map.get("inboundArea").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setInboundWarehouse(map.get("inboundWarehouse").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setSaleNo(map.get("saleNo") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (meter != null || meter.intValue() !=0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                oyeInboundResult.setMeter(meter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setMaterialId(materialId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setTheoryWeight(theoryWeight); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setSingleWeight(singleWeight); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setNetWeight(DataChange.dataToBigDecimal(map.get("netWeight"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setMaterialNumber(materialNumber); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setInsertUsername(map.get("userName") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResult.setInsertTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            map.put("singleWeight",singleWeight); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //根据区域,客户,物资,单重,米数,仓库,库区查询实时库存在不在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            BigDecimal inventoryId = oyeRealtimeInventoryMapper.getInventoryId(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (inventoryId == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //新增实时库存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                map.put("flag",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                OyeRealtimeInventory oyeRealtimeInventory = insertRealTimeInventory(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                oyeRealtimeInventoriesInsert.add(oyeRealtimeInventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                oyeInboundResult.setInventoryId(oyeRealtimeInventory.getInventoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                map.put("inventoryId",inventoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                map.put("flag",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                OyeRealtimeInventory oyeRealtimeInventory = updateRealTimeInventory(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                oyeInboundResult.setInventoryId(oyeRealtimeInventory.getInventoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                oyeRealtimeInventoriesUpdate.add(oyeRealtimeInventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (!map.get("place").equals(map.get("inboundWarehouse"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //如果收货地址与place,则需要修改收货地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                BigDecimal newPlaceId = oyeInboundResultMapper.getPlaceId(map.get("inboundWarehouse").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                //修改收货地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Map<String, Object> addressMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                addressMap.put("newPlaceId",newPlaceId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                addressMap.put("placeId",DataChange.dataToBigDecimal(map.get("placeId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                addressMap.put("saleMaterialId",DataChange.dataToBigDecimal(map.get("saleMaterialId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                oyeInboundResultMapper.updateAddressPlace(addressMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            //判断该运单有没有签收实绩 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            String receiptAddress = oyeInboundResultMapper.selectReceiptResultId(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if(receiptAddress != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                oyeInboundResultMapper.updateOOOrderStatus(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeInboundResultMapper.updateOrderStatus(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            // 修改运单状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            OyeInboundResults.add(oyeInboundResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        oyeInboundResultMapper.batchInsert(OyeInboundResults); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (oyeRealtimeInventoriesInsert.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeRealtimeInventoryMapper.batchInsert(oyeRealtimeInventoriesInsert); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (oyeRealtimeInventoriesUpdate.size() > 0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            oyeRealtimeInventoryMapper.batchUpdate(oyeRealtimeInventoriesUpdate); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for (Map<String,Object> map : mapList) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            insertInboundResultReal(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return "入库成功"; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public synchronized int insertInboundResultReal(Map<String,Object> map) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        int i = 0; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //根据分录ID查询理重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal materialNumber = DataChange.dataToBigDecimal(map.get("materialNumber")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal theoryWeightSaleMaterial = oyeRealtimeInventoryMapper.getTheoryWeight(DataChange.dataToBigDecimal(map.get("saleMaterialId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal singleWeight = theoryWeightSaleMaterial.divide(materialNumber,4,BigDecimal.ROUND_HALF_UP); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //根据分录理重 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OyeInboundResult oyeInboundResult = new OyeInboundResult(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal theoryWeight = DataChange.dataToBigDecimal(map.get("theoryWeight")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal meter = DataChange.dataToBigDecimal(map.get("meter")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setResultId(oyeInboundResultMapper.getResultId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setSaleArea(map.get("saleArea").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setConsigneeId(DataChange.dataToBigDecimal(map.get("consigneeId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setCapacityId(DataChange.dataToBigDecimal(map.get("capacityId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setOrderId(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setSaleMaterialId(DataChange.dataToBigDecimal(map.get("saleMaterialId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setCapacityNumbher(map.get("capacityNumber") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setInboundArea(map.get("inboundArea").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setInboundWarehouse(map.get("inboundWarehouse").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setSaleNo(map.get("saleNo") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (meter != null || meter.intValue() !=0) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            oyeInboundResult.setMeter(meter); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setMaterialId(materialId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setTheoryWeight(theoryWeight); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setSingleWeight(singleWeight); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setNetWeight(DataChange.dataToBigDecimal(map.get("netWeight"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setMaterialNumber(materialNumber); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setInsertUsername(map.get("userName") + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResult.setInsertTime(new Date()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        map.put("singleWeight",singleWeight); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //根据区域,客户,物资,单重,米数,仓库,库区查询实时库存在不在 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        BigDecimal inventoryId = oyeRealtimeInventoryMapper.getInventoryId(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (inventoryId == null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //新增实时库存 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("flag",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            OyeRealtimeInventory oyeRealtimeInventory = insertRealTimeInventory(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            oyeInboundResult.setInventoryId(oyeRealtimeInventory.getInventoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("inventoryId",oyeRealtimeInventory.getInventoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            oyeRealtimeInventoryMapper.insertSelective(oyeRealtimeInventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }else{ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("inventoryId",inventoryId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            map.put("flag",1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            OyeRealtimeInventory oyeRealtimeInventory = updateRealTimeInventory(map); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            oyeInboundResult.setInventoryId(oyeRealtimeInventory.getInventoryId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            oyeRealtimeInventoryMapper.updateByPrimaryKeySelective(oyeRealtimeInventory); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!map.get("place").equals(map.get("inboundWarehouse"))) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //如果收货地址与place,则需要修改收货地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            BigDecimal newPlaceId = oyeInboundResultMapper.getPlaceId(map.get("inboundWarehouse").toString()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            //修改收货地址 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            Map<String, Object> addressMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addressMap.put("newPlaceId",newPlaceId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addressMap.put("placeId",DataChange.dataToBigDecimal(map.get("placeId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            addressMap.put("saleMaterialId",DataChange.dataToBigDecimal(map.get("saleMaterialId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            oyeInboundResultMapper.updateAddressPlace(addressMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //判断该运单有没有签收实绩 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String receiptAddress = oyeInboundResultMapper.selectReceiptResultId(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if(receiptAddress != null) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            oyeInboundResultMapper.updateOOOrderStatus(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // 修改运单状态 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResultMapper.updateOrderStatus(DataChange.dataToBigDecimal(map.get("orderId"))); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        //新增入库实绩 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        oyeInboundResultMapper.insertSelective(oyeInboundResult); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return i; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Transactional(rollbackFor = Exception.class) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public synchronized String insertOutboundResult(Map<String,Object> mapValue) throws Exception { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         List<OyeOutboundResult> oyeOutboundResults = new ArrayList<>(); 
			 |