Jelajahi Sumber

重新出库逻辑修改

xiaosonghong 6 hari lalu
induk
melakukan
23bb147dd5

+ 76 - 0
src/main/java/com/steerinfo/dil/service/impl/OyeResultServiceImpl.java

@@ -260,6 +260,81 @@ public class OyeResultServiceImpl implements IOyeResultService {
         return "出库成功";
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    public String reAddOutBound(Map<String,Object> map) throws Exception {
+        //判断该拼是否出库
+        if (oyeOutboundResultMapper.selectSaleMaterialID(DataChange.dataToBigDecimal(map.get("saleMaterialId"))) != null) {
+            throw new Exception("该分录已出库,无法继续出库");
+        }
+        //根据实时库存ID获取单重
+        BigDecimal inventoryId = DataChange.dataToBigDecimal(map.get("inventoryId"));
+        if(inventoryId == null || inventoryId.intValue() == 0) {
+            throw new Exception("库存ID不存在");
+        }
+        BigDecimal materialNumber = DataChange.dataToBigDecimal(map.get("materialNumber"));
+        BigDecimal singleWeight = oyeRealtimeInventoryMapper.getSingleWeight(inventoryId);
+        BigDecimal theoryWeightSaleMaterial = singleWeight.multiply(materialNumber);
+        OyeOutboundResult oyeOutboundResult = new OyeOutboundResult();
+        BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId"));
+        BigDecimal theoryWeight = DataChange.dataToBigDecimal(map.get("theoryWeight"));
+        BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
+        if(materialNumber == null || materialNumber.intValue() == 0) {
+            throw new Exception("物资件数错误");
+        }
+        if(netWeight == null || netWeight.doubleValue() <= 0) {
+            return "";
+        }
+        //查询比例
+        BigDecimal compareValue = DataChange.dataToBigDecimal(oyeRealtimeInventoryMapper.selectCompareValue());
+        BigDecimal theoryAdd = theoryWeightSaleMaterial.multiply(compareValue.add(new BigDecimal(1)));
+        BigDecimal theorySub = theoryWeightSaleMaterial.multiply(new BigDecimal(1).subtract(compareValue));
+        if (netWeight.compareTo(theoryAdd) > 0 || netWeight.compareTo(theorySub) < 0) {
+            throw new Exception("净重不在理重的" + compareValue + "范围内");
+        }
+        //BigDecimal singleWeight = theoryWeight.divide(materialNumber);
+        BigDecimal meter = DataChange.dataToBigDecimal(map.get("meter"));
+        oyeOutboundResult.setResultId(oyeOutboundResultMapper.getResultId());
+        oyeOutboundResult.setSaleArea(map.get("saleArea").toString());
+        oyeOutboundResult.setConsigneeId(DataChange.dataToBigDecimal(map.get("consigneeId")));
+        oyeOutboundResult.setCapacityNumbher(map.get("capacityNumber") + "");
+        oyeOutboundResult.setCapacityId(DataChange.dataToBigDecimal(map.get("capacityId")));
+        oyeOutboundResult.setOrderId(DataChange.dataToBigDecimal(map.get("orderId")));
+        oyeOutboundResult.setCapacityNumbher(map.get("capacityNumber") + "");
+        oyeOutboundResult.setInboundArea(map.get("inboundArea").toString());
+        oyeOutboundResult.setInboundWarehouse(map.get("inboundWarehouse").toString());
+        oyeOutboundResult.setSaleMaterialId(DataChange.dataToBigDecimal(map.get("saleMaterialId")));
+        //更新制单日期
+        oyeOutboundResult.setMeter(meter);
+        oyeOutboundResult.setMaterialId(materialId);
+        oyeOutboundResult.setTheoryWeight(theoryWeight);
+        oyeOutboundResult.setSingleWeight(singleWeight);
+        oyeOutboundResult.setNetWeight(netWeight);
+        oyeOutboundResult.setMaterialNumber(materialNumber);
+        oyeOutboundResult.setInsertUsername(map.get("userName") + "");
+        oyeOutboundResult.setInsertTime(new Date());
+        map.put("singleWeight",singleWeight);
+        //根据区域,客户,物资,单重,米数,仓库,库区查询实时库存在不在
+        oyeOutboundResult.setInventoryId(inventoryId);
+        map.put("inventoryId",inventoryId);
+        map.put("flag",2);
+        OyeRealtimeInventory oyeRealtimeInventory = updateRealTimeInventory(map);
+        //更新库存信息BUG修改
+        //oyeRealtimeInventories.add(oyeRealtimeInventory);
+        oyeRealtimeInventoryMapper.updateByPrimaryKey(oyeRealtimeInventory);
+        TmstruckWeightBatch  tmstruckWeightBatch  = generateWeightBatch(map);
+        Map<String, Object> updateMap = new HashMap<>();
+        updateMap.put("weightBatchId",tmstruckWeightBatch.getWeightBatchId());
+        updateMap.put("materialNumber",materialNumber);
+        updateMap.put("saleMaterialId",DataChange.dataToBigDecimal(map.get("saleMaterialId")));
+        updateMap.put("materialWeight",theoryWeight);
+        oyeOutboundResultMapper.updateSaleMakeDate(updateMap);
+        oyeOutboundResultMapper.updateOrderStatus(DataChange.dataToBigDecimal(map.get("orderId")));
+        oyeOutboundResultMapper.insert(oyeOutboundResult);
+        //oyeRealtimeInventoryMapper.batchUpdate(oyeRealtimeInventories);
+        tmstruckWeightBatchMapper.insert(tmstruckWeightBatch);
+        return "出库成功";
+    }
+
     /**
      * 新增实时库存
      */
@@ -753,6 +828,7 @@ public class OyeResultServiceImpl implements IOyeResultService {
             BigDecimal weightBatchId = DataChange.dataToBigDecimal(map.get("weightBatchId"));
             //判断有没有实绩ID
             if(resultId == null || resultId.intValue() == 0) {
+                reAddOutBound(map);
                 continue;
             }
             //获取前端传输过来的件数、理重、净重