Browse Source

新增库存重量划拨功能

shxiaoc 9 months ago
parent
commit
7bde980c40

+ 13 - 0
src/main/java/com/steerinfo/dil/controller/OyeResultController.java

@@ -213,6 +213,19 @@ public class OyeResultController extends BaseRESTfulController {
         }
         }
     }
     }
 
 
+    @ApiOperation("划分实时库存重量")
+    @PostMapping("updateInsertRealTimeWeight")
+    public RESTfulResult updateInsertRealTimeWeight(@RequestBody Map<String,Object> map) {
+        String result = null ;
+        try {
+            result = oyeResultService.updateInsertRealTimeWeight(map);
+            return success(result);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return failed(e.getMessage());
+        }
+    }
+
     @ApiOperation("定制报表数据,收发存")
     @ApiOperation("定制报表数据,收发存")
     @PostMapping("receiveSendReport")
     @PostMapping("receiveSendReport")
     public RESTfulResult receiveSendReport(@RequestBody Map<String,Object> map) {
     public RESTfulResult receiveSendReport(@RequestBody Map<String,Object> map) {

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

@@ -420,6 +420,117 @@ public class OyeResultServiceImpl implements IOyeResultService {
         return "操作成功";
         return "操作成功";
     }
     }
 
 
+    /**
+     * 划拨实时库存重量
+     * @param map
+     * @return
+     * @throws Exception
+     */
+    @Transactional(rollbackFor = Exception.class)
+    public synchronized String updateInsertRealTimeWeight(Map<String, Object> map) throws Exception{
+        System.out.println("===========" + new Date());
+        JSONObject jsonObject = new JSONObject(map);
+        System.out.println(jsonObject);
+        System.out.println("===========" + new Date());
+        // 划分实时库存数据
+        // 针对原先的库存,需要进行出库;针对划分后的库存需要进行入库;先出后入;
+        // 创建出库需要的数据;
+        BigDecimal newInventoryId = DataChange.dataToBigDecimal(map.get("newInventoryId"));
+        OyeOutboundResult oyeOutboundResult = new OyeOutboundResult();
+        oyeOutboundResult.setId(oyeOutboundResultMapper.getResultId());
+        BigDecimal materialId = DataChange.dataToBigDecimal(map.get("materialId"));
+        BigDecimal singleWeight = DataChange.dataToBigDecimal(map.get("singleWeight"));
+        BigDecimal meter = DataChange.dataToBigDecimal(map.get("meter"));
+        map.put("materialNumber", map.get("materialNumberEdit"));
+        map.put("theoryWeight", map.get("theoryWeightEdit"));
+        map.put("netWeight", map.get("netWeightEdit"));
+        //划拨件数
+        BigDecimal materialNumber = DataChange.dataToBigDecimal(map.get("materialNumber"));
+        //划拨理重
+        BigDecimal theoryWeight = DataChange.dataToBigDecimal(map.get("theoryWeight"));
+        //划拨净重
+        BigDecimal netWeight = DataChange.dataToBigDecimal(map.get("netWeight"));
+        //重量划拨,允许件数为0
+        /*if(materialNumber == null || materialNumber.intValue() == 0) {
+            throw new Exception("物资件数错误");
+        }*/
+        materialNumber = materialNumber == null || materialNumber.intValue() < 0 ? new BigDecimal(0) : materialNumber;
+        oyeOutboundResult.setInboundArea(map.get("inboundArea").toString());
+        oyeOutboundResult.setConsigneeId(DataChange.dataToBigDecimal(map.get("oldConsigneeId")));
+        oyeOutboundResult.setSaleArea(map.get("oldSaleArea").toString());
+        oyeOutboundResult.setInboundWarehouse(map.get("oldInboundWarehouse").toString());
+        //更新制单日期
+        oyeOutboundResult.setMaterialId(materialId);
+        oyeOutboundResult.setMeter(meter);
+        oyeOutboundResult.setSingleWeight(singleWeight);
+        oyeOutboundResult.setTheoryWeight(theoryWeight);
+        oyeOutboundResult.setNetWeight(netWeight);
+        oyeOutboundResult.setMaterialNumber(materialNumber);
+        oyeOutboundResult.setInsertUsername(map.get("userName") + "");
+        oyeOutboundResult.setInsertTime(new Date());
+        oyeOutboundResult.setInventoryId(DataChange.dataToBigDecimal(map.get("inventoryId")));
+        oyeOutboundResult.setAlternateFields2("库存重量划拨");
+        oyeOutboundResult.setCapacityNumbher("库存重量划拨");
+        Map<String, Object> outBoundMap = new HashMap<>();
+        outBoundMap.put("inventoryId",map.get("inventoryId"));
+        outBoundMap.put("materialNumber",oyeOutboundResult.getMaterialNumber());
+        outBoundMap.put("netWeight",oyeOutboundResult.getNetWeight());
+        outBoundMap.put("theoryWeight",oyeOutboundResult.getTheoryWeight());
+        outBoundMap.put("flag",2);
+        OyeRealtimeInventory oyeRealtimeInventoryOut = updateRealTimeInventory(outBoundMap);
+        // 创建入库需要的数据
+        OyeInboundResult oyeInboundResult = new OyeInboundResult();
+        oyeInboundResult.setResultId(oyeInboundResultMapper.getResultId());
+        oyeInboundResult.setInboundArea(map.get("inboundArea").toString());
+        oyeInboundResult.setConsigneeId(DataChange.dataToBigDecimal(map.get("consigneeId")));
+        oyeInboundResult.setSaleArea(map.get("saleArea").toString());
+        oyeInboundResult.setInboundWarehouse(map.get("inboundWarehouse").toString());
+        oyeInboundResult.setMeter(meter);
+        oyeInboundResult.setMaterialId(materialId);
+        oyeInboundResult.setSingleWeight(singleWeight);
+        oyeInboundResult.setTheoryWeight(theoryWeight);
+        oyeInboundResult.setNetWeight(netWeight);
+        oyeInboundResult.setMaterialNumber(materialNumber);
+        oyeInboundResult.setInsertUsername(map.get("userName") + "");
+        oyeInboundResult.setInsertTime(new Date());
+        oyeInboundResult.setAlternateFields2("库存重量划拨");
+        oyeInboundResult.setCapacityNumbher("库存重量划拨");
+        map.put("singleWeight",singleWeight);
+        OyeRealtimeInventory oyeRealtimeInventoryInsert = null;
+        OyeRealtimeInventory oyeRealtimeInventoryUpdate = null;
+        //根据区域,客户,物资,单重,米数,仓库,库区查询实时库存在不在
+        BigDecimal inventoryId = null ;
+        if(newInventoryId == null || newInventoryId.intValue() == 0) {
+            inventoryId = oyeRealtimeInventoryMapper.getInventoryId(map);
+        }else{
+            inventoryId = newInventoryId;
+        }
+        if (inventoryId != null && inventoryId.compareTo(DataChange.dataToBigDecimal(map.get("inventoryId"))) == 0) {
+            throw new Exception("库存ID一致无法划分");
+        }
+        if (inventoryId == null) {
+            //新增实时库存
+            map.put("flag",1);
+            oyeRealtimeInventoryInsert = insertRealTimeInventory(map);
+            oyeInboundResult.setInventoryId(oyeRealtimeInventoryInsert.getInventoryId());
+        }else{
+            map.put("inventoryId",inventoryId);
+            map.put("flag",1);
+            oyeRealtimeInventoryUpdate = updateRealTimeInventory(map);
+            oyeInboundResult.setInventoryId(oyeRealtimeInventoryUpdate.getInventoryId());
+        }
+        if (oyeRealtimeInventoryInsert != null) {
+            oyeRealtimeInventoryMapper.insertSelective(oyeRealtimeInventoryInsert);
+        }
+        if (oyeRealtimeInventoryUpdate != null) {
+            oyeRealtimeInventoryMapper.updateByPrimaryKeySelective(oyeRealtimeInventoryUpdate);
+        }
+        oyeInboundResultMapper.insertSelective(oyeInboundResult);
+        oyeRealtimeInventoryMapper.updateByPrimaryKeySelective(oyeRealtimeInventoryOut);
+        oyeOutboundResultMapper.insertSelective(oyeOutboundResult);
+        return "操作成功";
+    }
+
 
 
 
 
     @Transactional(rollbackFor = Exception.class)
     @Transactional(rollbackFor = Exception.class)

+ 1 - 1
src/main/resources/com/steerinfo/dil/mapper/OyeInboundResultMapper.xml

@@ -863,7 +863,7 @@
            LEFT JOIN TMSTRUCK_WEIGHT_BATCH TWB ON TWB.WEIGHT_BATCH_ID = ASM.WEIGHT_BATCH_ID
            LEFT JOIN TMSTRUCK_WEIGHT_BATCH TWB ON TWB.WEIGHT_BATCH_ID = ASM.WEIGHT_BATCH_ID
            <where>
            <where>
            <if test="1 == 1">
            <if test="1 == 1">
-             and  OIR.SALE_MATERIAL_ID IS NOT NULL
+             and  (OIR.SALE_MATERIAL_ID IS NOT NULL or OIR.ALTERNATE_FIELDS2 = '库存重量划拨')
            </if>
            </if>
            <if test="startDate != null">
            <if test="startDate != null">
               and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= OIR.INSERT_TIME
               and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= OIR.INSERT_TIME

+ 1 - 1
src/main/resources/com/steerinfo/dil/mapper/OyeOutboundResultMapper.xml

@@ -833,7 +833,7 @@
     LEFT JOIN OMSTRUCK_ORDER OO on OOR.ORDER_ID = OO.ORDER_ID
     LEFT JOIN OMSTRUCK_ORDER OO on OOR.ORDER_ID = OO.ORDER_ID
     <where>
     <where>
         <if test="1 == 1">
         <if test="1 == 1">
-          and  OOR.SALE_MATERIAL_ID IS NOT NULL
+          and  (OOR.SALE_MATERIAL_ID IS NOT NULL or OOR.ALTERNATE_FIELDS2 = '库存重量划拨')
         </if>
         </if>
       <if test="startDate != null">
       <if test="startDate != null">
         and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= OOR.INSERT_TIME
         and to_date(#{startDate}, 'yyyy-mm-dd hh24:mi:ss') &lt;= OOR.INSERT_TIME