liyg vor 2 Jahren
Ursprung
Commit
089492eb74

+ 9 - 0
src/main/java/com/steerinfo/dil/mapper/TmstruckLoadResultMapper.java

@@ -6,6 +6,7 @@ import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Select;
 
+import javax.management.ObjectName;
 import java.math.BigDecimal;
 import java.util.Date;
 import java.util.List;
@@ -120,6 +121,14 @@ public interface TmstruckLoadResultMapper extends IBaseMapper<TmstruckLoadResult
     //查找当前订单共有几次出
     List<Integer> allOutFactoryNum(BigDecimal orderId);
 
+    //查找当前订单共有几次出
+    List<Integer> allOutFactoryJudge(BigDecimal orderId);
+
+    //查询是否存在未装货出厂实绩
+    int countJudgeLeave(Map<String, Object> map);
+    //更新成装货路段顺序号
+    int updateLoadSeq(Map<String, Object> map);
+
     //修改装货路段顺序号
     int updateSqe(@Param("orderId")BigDecimal orderId);
 

+ 27 - 0
src/main/java/com/steerinfo/dil/service/impl/TmstruckLoadResultServiceImpl.java

@@ -314,6 +314,11 @@ public class TmstruckLoadResultServiceImpl implements ITmstruckLoadResultService
         }
         ////更新路段顺序号
         //utilsService.updateOrderLineSequence(map);
+        //判断是否存在未装货出厂的出厂实绩
+        if(tmstruckLoadResultMapper.countJudgeLeave(mesMap)>0){
+            //回滚出厂信息
+            rollbackJudge(mesMap);
+        }
         //判断是否为未装货
         if (map.get("insertUpdateRemark")!=null) {
             String insertUpdateRemark = (String) map.get("insertUpdateRemark");
@@ -405,6 +410,28 @@ public class TmstruckLoadResultServiceImpl implements ITmstruckLoadResultService
         return tmstruckLoadResultMapper.updateSqe(orderId);
     }
 
+    /**
+     * 回退未装货
+     * @Author TXF
+     * @Date 2022/2/13 12:59
+     * @param map
+     * @return
+     **/
+    public int rollbackJudge(Map<String, Object> map) {
+        BigDecimal orderId =DataChange.dataToBigDecimal(map.get("orderId"));
+        //查找当前订单所有未装货出厂
+        List<Integer> resultIdList = tmstruckLoadResultMapper.allOutFactoryJudge(orderId);
+        for(Integer resultId: resultIdList){
+            //清空出厂信息
+            TmstruckLeaveFactoryResult tmstruckLeaveFactoryResult = tmstruckLeaveFactoryResultMapper.selectByPrimaryKey(new BigDecimal(resultId));
+            tmstruckLeaveFactoryResult.setResultOutMode(null);
+            tmstruckLeaveFactoryResult.setResultOutGateTime(null);
+            tmstruckLeaveFactoryResultMapper.updateByPrimaryKey(tmstruckLeaveFactoryResult);
+        }
+        //更新订单路段顺序号为装货路段顺序号
+        return tmstruckLoadResultMapper.updateLoadSeq(map);
+    }
+
     /**
      * 添加装车标准时长ID
      * @param orderNumber

+ 33 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstruckLoadResultMapper.xml

@@ -1726,6 +1726,32 @@
     order by TLFR.SEGMENT_SQE
   </select>
 
+  <select id="allOutFactoryJudge" resultType="int" parameterType="java.math.BigDecimal">
+    select TLFR.RESULT_ID
+    from OMSTRUCK_ORDER OO
+           left join TMSTRUCK_TOTAL_RESULT TTR on TTR.ORDER_ID = OO.ORDER_ID
+           left join TMSTRUCK_LEAVE_FACTORY_RESULT TLFR on TTR.RESULT_TOTAL_ID = TLFR.RESULT_TOTAL_ID
+    where OO.ORDER_ID = #{orderId}
+    and TLFR.RESULT_OUT_GATE_TIME is not null
+    and TLFR.RESULT_OUT_MODE = '未装货出厂'
+    order by TLFR.SEGMENT_SQE
+  </select>
+
+  <update id="updateLoadSeq">
+    UPDATE OMSTRUCK_ORDER
+    SET ORDER_LINE_SEQUENCE =
+          (
+            SELECT
+              TLR.SEGMENT_SQE
+            FROM TMSTRUCK_LOAD_RESULT TLR
+                   LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR ON TLR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
+            WHERE	TTR.ORDER_ID = #{orderId}
+            ORDER BY SEGMENT_SQE
+              FETCH NEXT 1 ROWS ONLY
+          )
+    WHERE ORDER_ID = #{orderId}
+  </update>
+
   <update id="updateSqe" parameterType="java.util.Map">
     update OMSTRUCK_ORDER OO
     set OO.ORDER_LINE_SEQUENCE =
@@ -1778,5 +1804,12 @@
     select TLR.RESULT_LOAD_END_TIME "loadEndTime" from TMSTRUCK_LOAD_RESULT TLR
     WHERE TLR.RESULT_TOTAL_ID = #{resultTotalId}
   </select>
+  <select id="countJudgeLeave" resultType="java.lang.Integer">
+    SELECT
+      COUNT(TLFR.RESULT_ID)
+    FROM TMSTRUCK_LEAVE_FACTORY_RESULT TLFR
+           LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR ON TLFR.RESULT_TOTAL_ID = TTR.RESULT_TOTAL_ID
+    WHERE	TLFR.RESULT_OUT_MODE = '未装货出厂' AND TTR.ORDER_ID = #{orderId}
+  </select>
 
 </mapper>