瀏覽代碼

新增24h补扫出厂关单

liyg 2 年之前
父節點
當前提交
329d88b313

+ 8 - 0
src/main/java/com/steerinfo/dil/mapper/TmstruckLeaveFactoryResultMapper.java

@@ -1,6 +1,7 @@
 package com.steerinfo.dil.mapper;
 
 import com.steerinfo.dil.model.TmstruckLeaveFactoryResult;
+import com.steerinfo.dil.model.TmstruckWeightResult;
 import com.steerinfo.framework.mapper.IBaseMapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Select;
@@ -150,4 +151,11 @@ public interface TmstruckLeaveFactoryResultMapper extends IBaseMapper<TmstruckLe
 
     int getPrintNumber(BigDecimal orderId);
 
+    //查询所有出了净重的计量实绩
+    List<Map<String,Object>> getWeightResultNetted(Map<String,Object> map);
+
+    //出厂
+    int updateLeaveTime(Map<String,Object> map);
+    //关单
+    int updateLeaveOrder(Map<String,Object> map);
 }

+ 23 - 0
src/main/java/com/steerinfo/dil/service/impl/TmstruckLeaveFactoryResultServiceImpl.java

@@ -8,11 +8,13 @@ import com.steerinfo.dil.mapper.TmstruckLeaveFactoryResultMapper;
 import com.steerinfo.dil.mapper.TmstruckLoadResultMapper;
 import com.steerinfo.dil.mapper.UtilsMapper;
 import com.steerinfo.dil.model.TmstruckLeaveFactoryResult;
+import com.steerinfo.dil.model.TmstruckWeightResult;
 import com.steerinfo.dil.service.ITmstruckLeaveFactoryResultService;
 import com.steerinfo.dil.util.DataChange;
 import com.steerinfo.dil.util.HTTPRequestUtils;
 import com.steerinfo.dil.util.getRequestUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.scheduling.annotation.Scheduled;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -673,4 +675,25 @@ public class TmstruckLeaveFactoryResultServiceImpl implements ITmstruckLeaveFact
         }
         return 0;
     }
+
+    /**
+     * 非钢材,出净重24h后自动出厂,并关单
+     */
+    @Scheduled(fixedRate = 1000*60*60*3)
+    public void autoLeaveFactory(){
+        Date date=new Date();
+        Calendar calendar=Calendar.getInstance();
+        calendar.setTime(date);
+        calendar.add(Calendar.DAY_OF_MONTH,-1);
+        date=calendar.getTime();
+        Map<String,Object> map = new HashMap<>();
+        map.put("nowDate",date);
+        List<Map<String,Object>> list = tmstruckLeaveFactoryResultMapper.getWeightResultNetted(map);
+        for(Map<String,Object> item:list){
+            //更新出厂
+            tmstruckLeaveFactoryResultMapper.updateLeaveTime(item);
+            //关闭订单
+            tmstruckLeaveFactoryResultMapper.updateLeaveOrder(item);
+        }
+    }
 }

+ 26 - 0
src/main/resources/com/steerinfo/dil/mapper/TmstruckLeaveFactoryResultMapper.xml

@@ -1506,4 +1506,30 @@
         SELECT OO.PRINTNUMBER FROM OMSTRUCK_ORDER OO
         WHERE OO.ORDER_ID = #{orderId}
     </select>
+    <select id="getWeightResultNetted" resultType="java.util.Map">
+        SELECT
+            TWR.WEIGHT_TASK_RESULT_ID "resultId",
+            TWR.RESULT_TOTAL_ID "resultTotalId",
+            TWR.RESULT_GROSS_WEIGHT_TIME "resultGrossWeightTime",
+            TWR.RESULT_TARE_WEIGHT_TIME "resultTareWeightTime",
+            OO.ORDER_ID "orderId"
+        FROM TMSTRUCK_WEIGHT_RESULT TWR
+                 LEFT JOIN TMSTRUCK_TOTAL_RESULT TTR ON TTR .RESULT_TOTAL_ID = TWR .RESULT_TOTAL_ID
+                 LEFT JOIN OMSTRUCK_ORDER OO ON OO .ORDER_ID = TTR .ORDER_ID
+        WHERE OO .ORDER_STATUS = 5 AND OO .ORDER_TYPE != 1 AND TWR .RESULT_NET_WEIGHT IS NOT NULL
+        AND #{nowDate} > TWR .RESULT_GROSS_WEIGHT_TIME
+        AND #{nowDate} > TWR .RESULT_TARE_WEIGHT_TIME
+    </select>
+    <update id="updateLeaveTime">
+        UPDATE TMSTRUCK_LEAVE_FACTORY_RESULT
+        SET TMSTRUCK_LEAVE_FACTORY_RESULT.RESULT_OUT_GATE_TIME = SYSDATE,
+            TMSTRUCK_LEAVE_FACTORY_RESULT.RESULT_OUT_MODE = '24h自动补扫出厂'
+        WHERE
+            TMSTRUCK_LEAVE_FACTORY_RESULT.RESULT_TOTAL_ID = #{resultTotalId}
+    </update>
+    <update id="updateLeaveOrder">
+        UPDATE OMSTRUCK_ORDER
+        SET ORDER_STATUS = 2
+        WHERE ORDER_ID = #{orderId}
+    </update>
 </mapper>