Просмотр исходного кода

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

dw 1 месяц назад
Родитель
Сommit
f9e6db6ae3

+ 6
- 0
src/main/java/com/th/demo/mapping/ware/DistributionMapper.java Просмотреть файл

24
 
24
 
25
     //    取消出库修改cancle_flag字段
25
     //    取消出库修改cancle_flag字段
26
     int updateCancleFlag(@Param("distributionId") String distributionId, @Param("outId") String outId);
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 Просмотреть файл

19
 import com.th.demo.tools.JSONTools;
19
 import com.th.demo.tools.JSONTools;
20
 import com.th.demo.tools.Tools;
20
 import com.th.demo.tools.Tools;
21
 import org.springframework.beans.factory.annotation.Autowired;
21
 import org.springframework.beans.factory.annotation.Autowired;
22
+import org.springframework.scheduling.annotation.Scheduled;
22
 import org.springframework.stereotype.Service;
23
 import org.springframework.stereotype.Service;
23
 import org.springframework.transaction.annotation.Transactional;
24
 import org.springframework.transaction.annotation.Transactional;
24
 
25
 
54
 
55
 
55
     String result = Type.FAIL;
56
     String result = Type.FAIL;
56
     int num = 0;
57
     int num = 0;
58
+    //    定时任务执行统计
59
+    int count = 0;
57
 
60
 
58
     @Override
61
     @Override
59
     public String out(String json, String userId, String belongId) {
62
     public String out(String json, String userId, String belongId) {
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 Просмотреть файл

269
     order by t.add_time desc
269
     order by t.add_time desc
270
   </select>
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
 </mapper>
292
 </mapper>

Загрузка…
Отмена
Сохранить