|
|
@@ -14,6 +14,10 @@ import org.quartz.JobExecutionException;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
+import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
@@ -47,6 +51,8 @@ public class IncidentTicketJob implements Job {
|
|
|
}
|
|
|
LoginUser loginUser = sysBaseAPI.getUserByName("admin");
|
|
|
|
|
|
+ SimpleDateFormat inputFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.S");
|
|
|
+
|
|
|
for(Map<String,Object> m:mapList){
|
|
|
|
|
|
if(m.get("order_status")==null||m.get("order_status")=="" ||
|
|
|
@@ -56,7 +62,18 @@ public class IncidentTicketJob implements Job {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
+ String inputDate = m.get("create_time").toString();//
|
|
|
+ // 解析输入日期
|
|
|
+ Date date = inputFormat.parse(inputDate);
|
|
|
+ // 转换为LocalDateTime处理
|
|
|
+ LocalDateTime dateTime = LocalDateTime.ofInstant(date.toInstant(), ZoneId.systemDefault());
|
|
|
+ // 减去8小时
|
|
|
+ LocalDateTime newTime = dateTime.minusHours(8);
|
|
|
+ Date create_time = Date.from(newTime.atZone(ZoneId.systemDefault()).toInstant());
|
|
|
+
|
|
|
String order_status = m.get("order_status").toString();//订单状态 //1未处理 2已通知 3通知已反馈 4已推送 5已提交 6已完结
|
|
|
+ String order_statusText = m.get("order_status").toString();//订单状态 //1未处理 2已通知 3通知已反馈 4已推送 5已提交 6已完结
|
|
|
+ String order_type = m.get("order_type")==null || m.get("order_type") == "" ? "" : m.get("order_type").toString();//事故类型 //扣款 应补 公司承担
|
|
|
if(order_status.equals("未处理")){
|
|
|
order_status = "1";
|
|
|
}else if(order_status.equals("已通知")){
|
|
|
@@ -75,38 +92,187 @@ public class IncidentTicketJob implements Job {
|
|
|
|
|
|
String user_id = m.get("user_id").toString();//用户
|
|
|
int minute = (int) m.get("minute");//提醒时间(分钟)
|
|
|
- int frequency = (int) m.get("frequency");//提醒次数
|
|
|
+ int frequency = 1;// (int) m.get("frequency");//提醒次数
|
|
|
+ minute = minute*1440; //客户要求改成天
|
|
|
+
|
|
|
+ //首次提醒
|
|
|
+ List<String> ticketList = incidentTicketService.selectTicketList(frequency,order_status,minute,order_type,create_time);
|
|
|
+
|
|
|
+ if(ticketList.size() > 0){
|
|
|
+
|
|
|
+ String result = String.join(",", ticketList);
|
|
|
+
|
|
|
+ for(String userId:user_id.split(",")){
|
|
|
+
|
|
|
+ String msgContent = "<h3>您有"+ticketList.size()+"条("+order_statusText+")的事故单需要处理,请查看</h3><br> <h4><br>"+result+"</h4>";
|
|
|
+
|
|
|
+ sysBaseAPI.sendSysAnnouncement(loginUser,"admin",userId,"事故处理单提醒",
|
|
|
+ msgContent,
|
|
|
+ CommonConstant.MSG_CATEGORY_2,new HashMap<>());
|
|
|
|
|
|
- List<String> ticketList = incidentTicketService.selectTicketList(frequency,order_status,minute);
|
|
|
+ incidentTicketService.setMsgLog(order_status,userId,null,minute,frequency,msgContent,order_statusText,result);
|
|
|
|
|
|
- if(ticketList.size() == 0){
|
|
|
+ }
|
|
|
+
|
|
|
+ incidentTicketService.updateIncidentInfo(ticketList,order_type);
|
|
|
+ }
|
|
|
+
|
|
|
+ //次提醒
|
|
|
+ if(m.get("user_id2")==null||m.get("user_id2")=="" ||
|
|
|
+ m.get("minute2")==null||m.get("minute2")=="" ||
|
|
|
+ m.get("frequency2")==null||m.get("frequency2")==""){
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- String result = String.join(",", ticketList);
|
|
|
+ user_id = m.get("user_id2").toString();//用户
|
|
|
+ minute = (int) m.get("minute2");//提醒时间(分钟)
|
|
|
+ frequency = 2;// (int) m.get("frequency");//提醒次数
|
|
|
+ minute = minute*1440; //客户要求改成天
|
|
|
|
|
|
- for(String userId:user_id.split(",")){
|
|
|
+ List<String> ticketList2 = incidentTicketService.selectTicketList(frequency,order_status,minute,order_type,create_time);
|
|
|
|
|
|
- String msgContent = "<h3>您有"+ticketList.size()+"条("+order_status+")的事故单需要处理,请查看</h3><br> <h4><br>"+result+"</h4>";
|
|
|
+ if(ticketList2.size() > 0){
|
|
|
|
|
|
- sysBaseAPI.sendSysAnnouncement(loginUser,"admin",userId,"事故处理单提醒",
|
|
|
- msgContent,
|
|
|
- CommonConstant.MSG_CATEGORY_2,new HashMap<>());
|
|
|
+ String result = String.join(",", ticketList2);
|
|
|
|
|
|
- incidentTicketService.setMsgLog(order_status,userId,null,minute,frequency,msgContent);
|
|
|
+ for(String userId:user_id.split(",")){
|
|
|
|
|
|
- }
|
|
|
+ String msgContent = "<h3>您有"+ticketList2.size()+"条("+order_statusText+")的事故单需要处理,请查看</h3><br> <h4><br>"+result+"</h4>";
|
|
|
|
|
|
- incidentTicketService.updateIncidentInfo(ticketList);
|
|
|
+ sysBaseAPI.sendSysAnnouncement(loginUser,"admin",userId,"事故处理单提醒",
|
|
|
+ msgContent,
|
|
|
+ CommonConstant.MSG_CATEGORY_2,new HashMap<>());
|
|
|
+
|
|
|
+ incidentTicketService.setMsgLog(order_status,userId,null,minute,frequency,msgContent,order_type,result);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ incidentTicketService.updateIncidentInfo(ticketList2,order_type);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
- incidentTicketService.setMsgLog(null,null,null,99,99,"消息发送失败:"+e.getMessage());
|
|
|
- System.out.println("消息发送失败:"+e.getMessage());
|
|
|
- e.printStackTrace();
|
|
|
+ incidentTicketService.setMsgLog(null,null,null,0,0,"消息发送失败:"+e.getMessage(),null,null);
|
|
|
+// System.out.println("消息发送失败:"+e.getMessage());
|
|
|
+// e.printStackTrace();
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
|
|
|
+//
|
|
|
+// try {
|
|
|
+//
|
|
|
+// //获取质量配置表
|
|
|
+// //遍历配置表
|
|
|
+// //查询 包含配置内数据 质量事故单:状态,发送次数<配置次数,上次发送时间(初始时间)与 当前时间 相差分钟数 > 配置分钟
|
|
|
+// //根据配置人员 发送消息
|
|
|
+// //更新发送时间,更新发送次数
|
|
|
+// //记录日志
|
|
|
+// //结束
|
|
|
+//
|
|
|
+// List<Map<String,Object>> mapList = incidentTicketService.selectConfigList();
|
|
|
+// if(mapList.size() == 0){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// LoginUser loginUser = sysBaseAPI.getUserByName("admin");
|
|
|
+//
|
|
|
+// for(Map<String,Object> m:mapList){
|
|
|
+//
|
|
|
+// if(m.get("order_status")==null||m.get("order_status")=="" ||
|
|
|
+// m.get("user_id")==null||m.get("user_id")=="" ||
|
|
|
+// m.get("minute")==null||m.get("minute")=="" ||
|
|
|
+// m.get("frequency")==null||m.get("frequency")==""){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// String order_status = m.get("order_status").toString();//订单状态 //1未处理 2已通知 3通知已反馈 4已推送 5已提交 6已完结
|
|
|
+// String order_statusText = m.get("order_status").toString();//订单状态 //1未处理 2已通知 3通知已反馈 4已推送 5已提交 6已完结
|
|
|
+// String order_type = m.get("order_type")==null || m.get("order_type") == "" ? "" : m.get("order_type").toString();//事故类型 //扣款 应补 公司承担
|
|
|
+// if(order_status.equals("未处理")){
|
|
|
+// order_status = "1";
|
|
|
+// }else if(order_status.equals("已通知")){
|
|
|
+// order_status = "2";
|
|
|
+// }else if(order_status.equals("通知已反馈")){
|
|
|
+// order_status = "3";
|
|
|
+// }else if(order_status.equals("已推送")){
|
|
|
+// order_status = "4";
|
|
|
+// }else if(order_status.equals("已提交")){
|
|
|
+// order_status = "5";
|
|
|
+// }else if(order_status.equals("已完结")){
|
|
|
+// order_status = "6";
|
|
|
+// }else{
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// String user_id = m.get("user_id").toString();//用户
|
|
|
+// int minute = (int) m.get("minute");//提醒时间(分钟)
|
|
|
+// int frequency = 1;// (int) m.get("frequency");//提醒次数
|
|
|
+//
|
|
|
+// //首次提醒
|
|
|
+// List<String> ticketList = incidentTicketService.selectTicketList(frequency,order_status,minute,order_type);
|
|
|
+//
|
|
|
+// if(ticketList.size() > 0){
|
|
|
+//
|
|
|
+// String result = String.join(",", ticketList);
|
|
|
+//
|
|
|
+// for(String userId:user_id.split(",")){
|
|
|
+//
|
|
|
+// String msgContent = "<h3>您有"+ticketList.size()+"条("+order_statusText+")的事故单需要处理,请查看</h3><br> <h4><br>"+result+"</h4>";
|
|
|
+//
|
|
|
+// sysBaseAPI.sendSysAnnouncement(loginUser,"admin",userId,"事故处理单提醒",
|
|
|
+// msgContent,
|
|
|
+// CommonConstant.MSG_CATEGORY_2,new HashMap<>());
|
|
|
+//
|
|
|
+// incidentTicketService.setMsgLog(order_status,userId,null,minute,frequency,msgContent,order_statusText,result);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// incidentTicketService.updateIncidentInfo(ticketList,order_type);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //次提醒
|
|
|
+// if(m.get("user_id2")==null||m.get("user_id2")=="" ||
|
|
|
+// m.get("minute2")==null||m.get("minute2")=="" ||
|
|
|
+// m.get("frequency2")==null||m.get("frequency2")==""){
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// user_id = m.get("user_id2").toString();//用户
|
|
|
+// minute = (int) m.get("minute2");//提醒时间(分钟)
|
|
|
+// frequency = 2;// (int) m.get("frequency");//提醒次数
|
|
|
+//
|
|
|
+// List<String> ticketList2 = incidentTicketService.selectTicketList(frequency,order_status,minute,order_type);
|
|
|
+//
|
|
|
+// if(ticketList2.size() > 0){
|
|
|
+//
|
|
|
+// String result = String.join(",", ticketList2);
|
|
|
+//
|
|
|
+// for(String userId:user_id.split(",")){
|
|
|
+//
|
|
|
+// String msgContent = "<h3>您有"+ticketList2.size()+"条("+order_statusText+")的事故单需要处理,请查看</h3><br> <h4><br>"+result+"</h4>";
|
|
|
+//
|
|
|
+// sysBaseAPI.sendSysAnnouncement(loginUser,"admin",userId,"事故处理单提醒",
|
|
|
+// msgContent,
|
|
|
+// CommonConstant.MSG_CATEGORY_2,new HashMap<>());
|
|
|
+//
|
|
|
+// incidentTicketService.setMsgLog(order_status,userId,null,minute,frequency,msgContent,order_type,result);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// incidentTicketService.updateIncidentInfo(ticketList2,order_type);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// }catch (Exception e){
|
|
|
+// incidentTicketService.setMsgLog(null,null,null,0,0,"消息发送失败:"+e.getMessage(),null,null);
|
|
|
+//// System.out.println("消息发送失败:"+e.getMessage());
|
|
|
+//// e.printStackTrace();
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
|
|
|
}
|