luobang пре 1 година
родитељ
комит
9ba7a9d9e2

+ 2 - 0
src/main/java/com/steerinfo/dil/mapper/TmstruckWeightBatchMapper.java

@@ -20,4 +20,6 @@ public interface TmstruckWeightBatchMapper extends IBaseMapper<TmstruckWeightBat
 
     int updateOmMes(Map<String, Object> weightMap);
 
+    int updateAmsFluToNull(BigDecimal weightBatchId);
+
 }

+ 3 - 0
src/main/java/com/steerinfo/dil/mapper/TmstruckWeightResultMapper.java

@@ -181,4 +181,7 @@ public interface TmstruckWeightResultMapper extends IBaseMapper<TmstruckWeightRe
     int updateQuitSaleMaterialId(Map<String, Object> map);
 
     int updateMakeDate(BigDecimal saleMaterialId);
+
+    int updateWeightResultToNull(BigDecimal weightBatchId);
+
 }

+ 54 - 44
src/main/java/com/steerinfo/dil/service/impl/TmstruckWeightResultServiceImpl.java

@@ -384,9 +384,10 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
                 }
                 codeMap.put("materialId",materialId);
                 tmstruckWeightResult.setMaterialId(materialId);
+                tmstruckWeightResult.setMaterialNum(DataChange.dataToBigDecimal(codeMap.get("goodNum")));
             }
             if(resultNetWeight  != null && !"".equals(resultNetWeight) && codeMap.get("saleMaterialId") != null) {
-                tmstruckWeightResult.setMaterialNum(DataChange.dataToBigDecimal(codeMap.get("goodNum")));
+
                 tmstruckWeightResult.setSaleMaterialId(DataChange.dataToBigDecimal(codeMap.get("saleMaterialId")));
                 tmstruckWeightResult.setSaleMaterialId(saleMaterialId);
             }
@@ -865,65 +866,74 @@ public class TmstruckWeightResultServiceImpl implements ITmstruckWeightResultSer
         //联动删除
         for (Map<String, Object> map : mapList) {
             String orderNumber = (String) map.get("orderNumber");
+            BigDecimal weightBatchId = DataChange.dataToBigDecimal(map.get("weightBatchId"));
             //判断该运输订单号是否是钢材的
             Map<String,Object> orderMes = tmstruckWeightResultMapper.getOOType(orderNumber);
             if(orderMes == null) {
                 return "failed";
             }
             //新增日志表
-            saleLogUtil.logOrder(DataChange.dataToBigDecimal(orderMes.get("orderId")),"计量联动删除","计量系统",SaleLogUtil.DELETE);
+            saleLogUtil.logOrder(DataChange.dataToBigDecimal(orderMes.get("orderId")),"计量联动删除" + weightBatchId,"计量系统" + map.get("userName"),SaleLogUtil.DELETE);
             BigDecimal resultTotalId = DataChange.dataToBigDecimal(orderMes.get("resultTotalId"));
             BigDecimal orderId = DataChange.dataToBigDecimal(orderMes.get("orderId"));
             Integer orderType = DataChange.dataToBigDecimal(orderMes.get("orderType")).intValue();
             if(orderType == 1 || orderType == 4) {
-                //删皮,此时没有物资名称,只有运输订单号
-                if(map.get("good") == null || "".equals(map.get("good"))){
-                    //清空皮重信息,且将进厂时间清空,且将路段顺序号置为0
-                    tmstruckWeightResultMapper.updateWeightTare(resultTotalId);
-                    tmstruckWeightResultMapper.updateEnfactoryResult(resultTotalId);
-                    tmstruckWeightResultMapper.updateOrderLineSqe(orderId);
-                    tmstruckWeightResultMapper.updateTotalStatus(resultTotalId);
-                }
-                //如果传输了物资,则判断该物资是第几拼
-                if(map.get("good") != null && !"".equals(map.get("good"))){
-                    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-                    //查询物资
-                    map.put("good",map.get("goodspa") + "" + map.get("good"));
-                    BigDecimal materialId = tmstruckWeightResultMapper.getMaterialId(map);
-                    if(materialId == null) {
-                        return "没有找到该物资,返回failed";
-                    }
-                    //查询该物资id及对应的净重还有毛重时间是哪一拼
-                    String resultGrossWeightTime = (String) map.get("resultCrossWeightTime");
-                    Date resultGrossWeightTime1 = sdf.parse(resultGrossWeightTime);
-                    Map<String, Object> weightMap = new HashMap<>();
-                    weightMap.put("resultTotalId",orderMes.get("resultTotalId"));
-                    weightMap.put("materialId",materialId);
-                    weightMap.put("resultGrossWeightTime",resultGrossWeightTime);
-                    weightMap.put("saleMaterialId",map.get("saleMaterialId"));
-                    Map<String,Object> map1 = tmstruckWeightResultMapper.selectWeightMes(weightMap);
-                    tmstruckWeightResultMapper.updateMakeDate(DataChange.dataToBigDecimal(weightMap.get("saleMaterialId")));
-                    //根据查询信息判断是哪一拼
-                    Integer spellNum = (DataChange.dataToBigDecimal(map1.get("grossSqe")).intValue() + DataChange.dataToBigDecimal(map1.get("tareSqe")).intValue()) / 6;
-                    if(spellNum == 1){
-                        //如果是第一拼
-                        tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(map1.get("weightTaskResultId")));
-                        //删除下二拼的皮重
-                        tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId);
+                if(weightBatchId == null) {
+                    //删皮,此时没有物资名称,只有运输订单号
+                    if(map.get("good") == null || "".equals(map.get("good"))){
+                        //清空皮重信息,且将进厂时间清空,且将路段顺序号置为0
+                        tmstruckWeightResultMapper.updateWeightTare(resultTotalId);
                         tmstruckWeightResultMapper.updateEnfactoryResult(resultTotalId);
                         tmstruckWeightResultMapper.updateOrderLineSqe(orderId);
                         tmstruckWeightResultMapper.updateTotalStatus(resultTotalId);
-                    }else{
-                        tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(map1.get("weightTaskResultId")));
-                        tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId);
-                        //查询有净重的实绩的最大路段顺序号
-                        BigDecimal orderLineSqe = tmstruckWeightResultMapper.selectOrderLineSqe(resultTotalId);
-                        if(orderLineSqe != null) {
-                            tmstruckWeightResultMapper.updateOrderLineSqeBySqe(orderId,orderLineSqe.intValue());
+                    }
+                    //如果传输了物资,则判断该物资是第几拼
+                    if(map.get("good") != null && !"".equals(map.get("good"))){
+                        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+                        //查询物资
+                        map.put("good",map.get("goodspa") + "" + map.get("good"));
+                        BigDecimal materialId = tmstruckWeightResultMapper.getMaterialId(map);
+                        if(materialId == null) {
+                            return "没有找到该物资,返回failed";
                         }
+                        //查询该物资id及对应的净重还有毛重时间是哪一拼
+                        String resultGrossWeightTime = (String) map.get("resultCrossWeightTime");
+                        Date resultGrossWeightTime1 = sdf.parse(resultGrossWeightTime);
+                        Map<String, Object> weightMap = new HashMap<>();
+                        weightMap.put("resultTotalId",orderMes.get("resultTotalId"));
+                        weightMap.put("materialId",materialId);
+                        weightMap.put("resultGrossWeightTime",resultGrossWeightTime);
+                        weightMap.put("saleMaterialId",map.get("saleMaterialId"));
+                        Map<String,Object> map1 = tmstruckWeightResultMapper.selectWeightMes(weightMap);
+                        tmstruckWeightResultMapper.updateMakeDate(DataChange.dataToBigDecimal(weightMap.get("saleMaterialId")));
+                        //根据查询信息判断是哪一拼
+                        Integer spellNum = (DataChange.dataToBigDecimal(map1.get("grossSqe")).intValue() + DataChange.dataToBigDecimal(map1.get("tareSqe")).intValue()) / 6;
+                        if(spellNum == 1){
+                            //如果是第一拼
+                            tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(map1.get("weightTaskResultId")));
+                            //删除下二拼的皮重
+                            tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId);
+                            tmstruckWeightResultMapper.updateEnfactoryResult(resultTotalId);
+                            tmstruckWeightResultMapper.updateOrderLineSqe(orderId);
+                            tmstruckWeightResultMapper.updateTotalStatus(resultTotalId);
+                        }else{
+                            tmstruckWeightResultMapper.updateWeightResult(DataChange.dataToBigDecimal(map1.get("weightTaskResultId")));
+                            tmstruckWeightResultMapper.updateWeightTareNoGross(resultTotalId);
+                            //查询有净重的实绩的最大路段顺序号
+                            BigDecimal orderLineSqe = tmstruckWeightResultMapper.selectOrderLineSqe(resultTotalId);
+                            if(orderLineSqe != null) {
+                                tmstruckWeightResultMapper.updateOrderLineSqeBySqe(orderId,orderLineSqe.intValue());
+                            }
+                        }
+                }
+                }else{
+                    //存在计量批次id,首先把计量批次ID,更新分录表里面的计量分录id为null,然后把实绩表也清空。
+                    tmstruckWeightResultMapper.updateWeightResultToNull(weightBatchId);
+                    tmstruckWeightBatchMapper.updateAmsFluToNull(weightBatchId);
 
-                    }
                 }
+
+
             }else{
                 tmstruckWeightResultMapper.linkageDeleteTransportOrder(orderNumber);
             }

+ 6 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstruckWeightBatchMapper.xml

@@ -292,4 +292,10 @@
     WHERE OOM.SALE_MATERIAL_ID = (SELECT ASM.SALE_MATERIAL_ID FROM AMS_SALE_MATERIAL ASM
     WHERE ASM.EAS_PRIMARY_ID = #{FLID})
   </update>
+    <update id="updateAmsFluToNull">
+      UPDATE AMS_SALE_MATERIAL ASM
+      SET ASM.WEIGHT_BATCH_ID = NULL,
+          ASM.SALE_MAKE_DATE = NULL
+      WHERE ASM.WEIGHT_BATCH_ID = #{weightBatchId}
+    </update>
 </mapper>

+ 14 - 3
src/main/resources/com/steerinfo/dil/mapper/TmstruckWeightResultMapper.xml

@@ -1546,9 +1546,20 @@
         UPDATE AMS_SALE_MATERIAL ASM
         SET ASM.SALE_MAKE_DATE = NULL
         WHERE
-
      ASM.SALE_MATERIAL_ID = #{saleMaterialId}
-
-
+    </update>
+    <update id="updateWeightResultToNull">
+        UPDATE TMSTRUCK_WEIGHT_RESULT TWR
+        SET TWR.RESULT_NET_WEIGHT = NULL,
+            TWR.RESULT_GROSS_WEIGHT_TIME = NULL,
+            TWR.RESULT_GROSS_WEIGHT = NULL,
+            TWR.RESULT_TARE_WEIGHT = NULL,
+            TWR.RESULT_TARE_WEIGHT_TIME = NULL,
+            TWR.INSERT_UPDATE_REMARK = '计量联动删除',
+            TWR.RESULT_POUND_NO = NULL,
+            TWR.MATERIAL_ID = NULL,
+            TWR.SALE_MATERIAL_ID = NULL
+        WHERE TWR.SALE_MATERIAL_ID IN (select asm.SALE_MATERIAL_ID from AMS_SALE_MATERIAL ASM
+            where asm.WEIGHT_BATCH_ID = #{weightBatchId})
     </update>
 </mapper>