lisai17@sina.com 2020-11-16 11:24:16 +08:00
parent 193b38cc4e
commit 258d6d7882
1 changed files with 35 additions and 8 deletions

View File

@ -1,30 +1,57 @@
package com.cowr.service.ssjygl.jobs; package com.cowr.service.ssjygl.jobs;
import com.cowr.service.ssjygl.main.Config; import com.cowr.service.ssjygl.main.Config;
import com.cowr.service.ssjygl.main.SvrCacheData;
import com.jfinal.kit.HttpKit; import com.jfinal.kit.HttpKit;
import com.jfinal.kit.StrKit; import com.jfinal.kit.StrKit;
import com.jfinal.log.Log; import com.jfinal.log.Log;
import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.Db;
import com.jfinal.plugin.activerecord.Record;
import org.quartz.Job; import org.quartz.Job;
import org.quartz.JobExecutionContext; import org.quartz.JobExecutionContext;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
public class CheckExceptionDataJob implements Job { public class CheckExceptionDataJob implements Job {
private static Log log = Log.getLog(CheckExceptionDataJob.class); private static Log log = Log.getLog(CheckExceptionDataJob.class);
public void execute() { public void execute() {
int cnt = Db.queryInt("select count(t.sn) cnt from order_temp t\n" + String content = "";
List<String> onlineids = new ArrayList<>();
long nowst = System.currentTimeMillis();
for (Map.Entry<Integer, Record> entry : SvrCacheData.SUP_HEARTBEAT.entrySet()) {
Record c = entry.getValue();
long st = c.getLong("tm");
// 五分钟以内的才进行判断超过5分钟的就认为是离线了
// 离线的砂站会产生正常的未同步数据
if (nowst - st < 5 * 60 * 1000) {
onlineids.add(entry.getKey().toString());
}
}
int cnt = 0;
if (!onlineids.isEmpty()) {
cnt = Db.queryInt("select count(t.sn) cnt from order_temp t\n" +
" left join transport p on t.sn = p.order_sn\n" + " left join transport p on t.sn = p.order_sn\n" +
" where t.state = 5 \n" + " where t.state = 5 \n" +
" and t.supermarket_id in(" + StrKit.join(onlineids, ",") + ") \n" +
" and p.id is null"); " and p.id is null");
int sync = Db.queryInt("select count(t.id) cnt from sync_task t\n" + } else {
" where t.state = 0"); content += "没有找到在线砂站信息。";
String content = ""; log.error("没有找到在线砂站信息。");
}
int sync = Db.queryInt("select count(t.id) cnt from sync_task t where t.state = 0");
if (cnt > 0) { if (cnt > 0) {
content += "浠水砂石系统有 " + cnt + " 条异常数据。"; content += "浠水砂石系统有 " + cnt + " 条订单异常数据。";
} }
if (sync > 0) { if (sync > 0) {