|
@ -0,0 +1,83 @@
|
|
|
package com.yihu.jw.care.job.order;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.yihu.jw.im.util.ImUtil;
|
|
|
import org.quartz.DisallowConcurrentExecution;
|
|
|
import org.quartz.Job;
|
|
|
import org.quartz.JobExecutionContext;
|
|
|
import org.quartz.JobExecutionException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
|
|
|
/**
|
|
|
* Created by Bing on 2021/10/14.
|
|
|
*/
|
|
|
@DisallowConcurrentExecution//解决执行频率和间隔时间的问题。到了执行时间点前一任务还在执行中,不会执行下一次任务,直至该次任务完成
|
|
|
public class EmeWarnOrderJob implements Job {
|
|
|
private static Logger logger = LoggerFactory.getLogger(EmeWarnOrderJob.class);
|
|
|
|
|
|
@Autowired
|
|
|
private JdbcTemplate jdbcTemplate;
|
|
|
@Autowired
|
|
|
private ImUtil imUtil;
|
|
|
|
|
|
@Override
|
|
|
public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
logger.info("EME_WARNING_OVERTIME_NOT_RESPONSE start");
|
|
|
try {
|
|
|
|
|
|
//救助工单<=1小时&&<1未处理
|
|
|
String sql = " select o.id,o.session_id sessionId,o.patient,o.patient_name patientName,o.create_time,20 as type from " +
|
|
|
"base_emergency_assistance_order o where status=1 and (TIMESTAMPDIFF(HOUR,o.create_time,now()) >=1 " +
|
|
|
"and TIMESTAMPDIFF(HOUR,o.create_time,now()) <24) and not EXISTS ( " +
|
|
|
" select 1 from base_emergency_warn_log log where log.order_id = o.id) ";
|
|
|
|
|
|
List<Map<String,Object>> list = jdbcTemplate.queryForList(sql);
|
|
|
|
|
|
//安防<=1小时&&<1天未处理
|
|
|
sql = " select o.id,o.patient,o.patient_name patientName,o.serve_desc serverDesc,ct.id consult,22 as type from base_security_monitoring_order o " +
|
|
|
" INNER JOIN wlyy_consult ct on o.id = ct.relation_code where o.status=1 and (TIMESTAMPDIFF(HOUR,o.create_time,now()) >=1 " +
|
|
|
" AND TIMESTAMPDIFF(HOUR,o.create_time,now()) <24) and not EXISTS ( " +
|
|
|
" select 1 from base_emergency_warn_log log where log.order_id = o.id); ";
|
|
|
list.addAll(jdbcTemplate.queryForList(sql));
|
|
|
|
|
|
for (Map<String,Object> map:list){
|
|
|
Integer type = Integer.parseInt(map.get("type").toString()) ;
|
|
|
JSONObject message = null;
|
|
|
if (20==type){
|
|
|
message = new JSONObject();
|
|
|
message.put("session_id",map.get("sessionId"));
|
|
|
message.put("sender_name",map.get("patientName"));
|
|
|
message.put("content_notice",map.get("patientName")+" 发起紧急救助!");
|
|
|
message.put("sender_code",map.get("patient"));
|
|
|
message.put("OrderType",20);
|
|
|
message.put("OrderStatus","new");
|
|
|
message.put("order_id",map.get("id"));
|
|
|
message.put("content_type",40);
|
|
|
}else {
|
|
|
message = new JSONObject();
|
|
|
String sessionId = map.get("patient")+"_"+ map.get("consult") + "_22";
|
|
|
message.put("session_id",sessionId);
|
|
|
message.put("sender_name",map.get("patientName"));
|
|
|
message.put("content_notice",map.get("patientName")+" "+map.get("serverDesc")+"!");
|
|
|
message.put("sender_code",map.get("patient"));
|
|
|
message.put("OrderType",22);
|
|
|
message.put("OrderStatus","new");
|
|
|
message.put("order_id",map.get("id"));
|
|
|
message.put("content_type",40);
|
|
|
}
|
|
|
if (null!=message){
|
|
|
imUtil.sendPcManageMessageToPc("cloudCare_pcManage",message.toString());
|
|
|
}
|
|
|
}
|
|
|
}catch (Exception e){
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
logger.info("EME_WARNING_OVERTIME_NOT_RESPONSE end");
|
|
|
}
|
|
|
}
|