自动化立体仓库 - WMS系统
zhangc
2024-12-25 97c6071eaf01a3ce1a706cb0114dcb27d255aa3d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package com.zy.asrs.task;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.LocMastService;
import com.zy.common.utils.HttpHandler;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
 
import java.util.HashMap;
import java.util.List;
 
/**
 * 检测库位状态为F但无库存数据
 * 每分钟扫描一次
 */
@Component
public class CheckLocDetlExistScheduler {
 
    @Autowired
    private LocMastService locMastService;
    @Autowired
    private ConfigService configService;
 
    //每30分钟扫描一次
//    @Scheduled(cron = "0 30 * * * ? ")
    private void execute(){
        List<LocMast> locMasts = locMastService.selectLocDetlNotExist();
        if (locMasts.isEmpty()) {
            return;
        }
 
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code","dingdingReportUrl"));
        if (config == null) {
            return;
        }
 
        if (config.getStatus() == 0) {
            return;//通知禁用
        }
 
        StringBuffer buffer = new StringBuffer();
        buffer.append("【通知】三凯四向库-库存资料异常\n");//消息标题
 
        for (LocMast locMast : locMasts) {
            buffer.append(locMast.getLocNo()).append("\n");
        }
 
        try {
            HashMap<String, Object> param = new HashMap<>();
            HashMap<String, Object> data = new HashMap<>();
            data.put("content", buffer.toString());
            param.put("msgtype", "text");
            param.put("text", data);
            String response = new HttpHandler.Builder()
                    .setUri(config.getValue())
                    .setJson(JSON.toJSONString(param))
                    .setHttps(true)
                    .build()
                    .doPost();
            JSONObject jsonObject = JSON.parseObject(response);
            if (jsonObject.get("errmsg").equals("ok")) {
                return;//发送成功
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
 
}