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();
|
}
|
}
|
|
}
|