Browse Source

1.新增定时任务,每日零点自动排查已出库的库存出库状态未更新的库存,自动更新出库状态

dw 1 month ago
parent
commit
f9e6db6ae3

+ 6
- 0
src/main/java/com/th/demo/mapping/ware/DistributionMapper.java View File

@@ -24,4 +24,10 @@ public interface DistributionMapper {
24 24
 
25 25
     //    取消出库修改cancle_flag字段
26 26
     int updateCancleFlag(@Param("distributionId") String distributionId, @Param("outId") String outId);
27
+
28
+    //    查询未出库状态,出库单存在的数据
29
+    List<String> selectWaitOutIds();
30
+
31
+    //    根据主表id修改出库状态
32
+    int updateOutStatus(@Param("storeId") String storeId);
27 33
 }

+ 21
- 0
src/main/java/com/th/demo/service/impl/ware/OutServiceImpl.java View File

@@ -19,6 +19,7 @@ import com.th.demo.service.ware.OutService;
19 19
 import com.th.demo.tools.JSONTools;
20 20
 import com.th.demo.tools.Tools;
21 21
 import org.springframework.beans.factory.annotation.Autowired;
22
+import org.springframework.scheduling.annotation.Scheduled;
22 23
 import org.springframework.stereotype.Service;
23 24
 import org.springframework.transaction.annotation.Transactional;
24 25
 
@@ -54,6 +55,8 @@ public class OutServiceImpl implements OutService {
54 55
 
55 56
     String result = Type.FAIL;
56 57
     int num = 0;
58
+    //    定时任务执行统计
59
+    int count = 0;
57 60
 
58 61
     @Override
59 62
     public String out(String json, String userId, String belongId) {
@@ -357,4 +360,22 @@ public class OutServiceImpl implements OutService {
357 360
     }
358 361
 
359 362
 
363
+    /**
364
+     * 库存状态检测方法(定时)
365
+     */
366
+    @Scheduled(cron = "0 * * * * *")
367
+    public void checkStock() {
368
+        count += 1;
369
+//      查询未出库状态,出库单存在的数据
370
+//        List<String> list = distributionMapper.selectWaitOutIds();
371
+//        if(!list.isEmpty()){
372
+//            for (String storeId : list) {
373
+////                根据id修改主表出库状态
374
+//                distributionMapper.updateOutStatus(storeId);
375
+//            }
376
+//        }
377
+        System.out.println("执行定时任务_______"+count);
378
+
379
+    }
380
+
360 381
 }

+ 20
- 0
src/main/resource/mapper/ware/DistributionMapper.xml View File

@@ -269,4 +269,24 @@ where substring(t.distribution_no,3,8) = DATE_FORMAT(NOW(), '%Y%m%d')) temp))
269 269
     order by t.add_time desc
270 270
   </select>
271 271
 
272
+    <select id="selectWaitOutIds" parameterType="java.lang.String">
273
+        SELECT
274
+            b.id
275
+        FROM
276
+            t_ware_distribution_detail a
277
+                LEFT JOIN t_ware_store b ON a.store_id = b.id
278
+                LEFT JOIN t_ware_distribution c ON c.id = a.distribution_id
279
+        WHERE
280
+--             未出库
281
+            b.out_flag = '0'
282
+          AND b.cancel_flag = '0'
283
+          AND a.cancel_flag = '0'
284
+--           出库单已存在
285
+          AND c.out_flag = '1'
286
+    </select>
287
+    <update id="updateOutStatus" parameterType="java.lang.String">
288
+        update t_ware_store
289
+        set out_flag = '1'
290
+        where id = #{storeId}
291
+    </update>
272 292
 </mapper>

Loading…
Cancel
Save