预警定时任务--当前,6个月,一年(发消息)

This commit is contained in:
zhn
2022-10-31 14:21:46 +08:00
parent e4553bd126
commit 74e32546dd
@@ -124,27 +124,33 @@ public class TimedTaskWarn implements Job {
//当前时间的前12个月
String beforeTimeSixTen = beforeTime(12,xin1Che1Xing2Shi2Shi1Ri4Qi1);
if(currentTime.equals(beforeTimeSix) || currentTime.equals(beforeTimeSixTen) || currentTime.equals(xin1Che1Xing2Shi2Shi1Ri4Qi1Str)){
//发送站内消息和飞书消息
String format = sdf.format(xin1Che1Xing2Shi2Shi1Ri4Qi1);
String content = "The implementation date of the " + category +" "+ serialNumber
+ " new model you subscribed to is "+format+",please pay attention to check";
String contentInfo = "The implementation date of the " + category +" "+ href
+ " new model you subscribed to is "+format+",please pay attention to check";
String msgTitle = content;
sendMessage(msgTitle, content,contentInfo,content, url, userIdList, thirdIdList);
}
// if(currentTime.equals(beforeTimeSix) || currentTime.equals(beforeTimeSixTen) || currentTime.equals(xin1Che1Xing2Shi2Shi1Ri4Qi1Str)){
// //发送站内消息和飞书消息
// String format = sdf.format(xin1Che1Xing2Shi2Shi1Ri4Qi1);
// String content = "The implementation date of the " + category +" "+ serialNumber
// + " new model you subscribed to is "+format+",please pay attention to check";
// String contentInfo = "The implementation date of the " + category +" "+ href
// + " new model you subscribed to is "+format+",please pay attention to check";
// String msgTitle = content;
// sendMessage(msgTitle, content,contentInfo,content, url, userIdList, thirdIdList);
// }
if(currentTime.equals(beforeTimeSixTen)){
//发送飞书消息(提前一年)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"1");
//站内消息
sendMessage(bussDocumentLibraryEO, userIdList,"1",sdf,href);
}
if(currentTime.equals(beforeTimeSix)){
//发送飞书消息(提前6个月)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"6");
//站内消息
sendMessage(bussDocumentLibraryEO, userIdList,"6",sdf,href);
}
if(currentTime.equals(xin1Che1Xing2Shi2Shi1Ri4Qi1Str)){
//发送飞书消息(当天)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"0");
//站内消息
sendMessage(bussDocumentLibraryEO, userIdList,"0",sdf,href);
}
}
@@ -165,19 +171,25 @@ public class TimedTaskWarn implements Job {
String contentInfo = "The implementation date of the " + category +" "+ href
+ " production vehicle you subscribed to is "+format+",please pay attention to check";
String msgTitle = content;
sendMessage(msgTitle, content,contentInfo,content, url, userIdList, thirdIdList);
// sendMessage(msgTitle, content,contentInfo,content, url, userIdList, thirdIdList);
}
if(currentTime.equals(beforeTimeSixTen)){
//发送飞书消息(提前一年)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"1");
//站内消息
sendMessage(bussDocumentLibraryEO, userIdList,"1",sdf,href);
}
if(currentTime.equals(beforeTimeSix)){
//发送飞书消息(提前6个月)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"6");
//站内消息
sendMessage(bussDocumentLibraryEO, userIdList,"6",sdf,href);
}
if(currentTime.equals(implementTimeStr)){
//发送飞书消息(当天)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"0");
//站内消息
sendMessage(bussDocumentLibraryEO, userIdList,"0",sdf,href);
}
}
}
@@ -224,25 +236,98 @@ public class TimedTaskWarn implements Job {
}
}
private void sendMessage(String title, String content,String contentInfo,String contentFeiShu, String url, List<String> userIdList, List<String> thirdIdList) {
//站内消息
// private void sendMessage(String title, String content,String contentInfo,String contentFeiShu, String url, List<String> userIdList, List<String> thirdIdList) {
// //站内消息
// //封装消息的实体类
// SysAnnouncement sysAnnouncement = bussDocumentLibraryEOService.getSysAnnouncement(userIdList,
// title,
// content,
// contentInfo,
// MessageTypeEnum.WARN.getValue(),
// MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
// null,null);
// sysAnnouncementService.saveAnnouncement(sysAnnouncement);
// bussDocumentLibraryEOService.sendWebsocket(StringUtils.join(userIdList, ","), content);
//
//// //飞书消息
//// try {
//// iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentFeiShu, MessageTypeEnum.WARN.getName(), url);
//// } catch (IOException e) {
//// e.printStackTrace();
//// }
// }
private void sendMessage(BussDocumentLibraryEO bussDocumentLibraryEO,
List<String> userIdList,
String flag,
SimpleDateFormat sdf,
String href) {
String number = bussDocumentLibraryEO.getSerialNumber();
String title = bussDocumentLibraryEO.getTitle();
String titleEn = bussDocumentLibraryEO.getTitleEn();
Date xin1Che1Xing2Shi2Shi1Ri4Qi1 = bussDocumentLibraryEO.getXin1Che1Xing2Shi2Shi1Ri4Qi1();
Date implementTime = bussDocumentLibraryEO.getImplementTime();
String newType = "";
String newVehicle = "";
if(ObjectUtils.isNotEmpty(xin1Che1Xing2Shi2Shi1Ri4Qi1)){
newType = sdf.format(xin1Che1Xing2Shi2Shi1Ri4Qi1);
}
if(ObjectUtils.isNotEmpty(implementTime)){
newVehicle = sdf.format(implementTime);
}
String contentCn = "";
String contentInfoCn = "";
String contentEn = "";
String contentInfoEn = "";
//"</br>"
contentCn = ",编号: "+number
+",标题: "+title
+",新车型实施日期: "+newType
+",在产车实施日期: "+newVehicle;
contentInfoCn = "编号: "+href+"</br>"
+"标题: "+title+"</br>"
+"新车型实施日期: "+newType+"</br>"
+"在产车实施日期: "+newVehicle;
contentEn = ",Regulation No: "+number
+",Title: "+titleEn
+",New Type Execution Date: "+newType
+",New Vehicle Execution Date: "+newVehicle;
contentInfoEn = "Regulation No: "+href+"</br>"
+"Title: "+titleEn+"</br>"
+"New Type Execution Date: "+newType+"</br>"
+"New Vehicle Execution Date: "+newVehicle;
if("1".equals(flag)){
contentCn = "您所订阅的法规将于1年后实施"+contentCn;
contentInfoCn = "您所订阅的法规将于1年后实施"+"</br>"+contentInfoCn;
contentEn = "The regulation you subscribed to will be implemented in one year"+contentEn;
contentInfoEn = "The regulation you subscribed to will be implemented in one year"+"</br>"+contentInfoEn;
}
if("6".equals(flag)){
contentCn = "您所订阅的法规将于6个月后实施"+contentCn;
contentInfoCn = "您所订阅的法规将于6个月后实施"+"</br>"+contentInfoCn;
contentEn = "The regulation you subscribed to will be implemented in six months"+contentEn;
contentInfoEn = "The regulation you subscribed to will be implemented in six months"+"</br>"+contentInfoEn;
}
if("0".equals(flag)){
contentCn = "您所订阅的法规已实施"+contentCn;
contentInfoCn = "您所订阅的法规已实施"+"</br>"+contentInfoCn;
contentEn = "The regulation you subscribed to is implemented"+contentEn;
contentInfoEn = "The regulation you subscribed to is implemented"+"</br>"+contentInfoEn;
}
//封装消息的实体类
SysAnnouncement sysAnnouncement = bussDocumentLibraryEOService.getSysAnnouncement(userIdList,
title,
content,
contentInfo,
contentEn,
contentInfoEn,
MessageTypeEnum.WARN.getValue(),
MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
null,null);
contentCn,contentInfoCn);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
bussDocumentLibraryEOService.sendWebsocket(StringUtils.join(userIdList, ","), content);
// //飞书消息
// try {
// iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentFeiShu, MessageTypeEnum.WARN.getName(), url);
// } catch (IOException e) {
// e.printStackTrace();
// }
bussDocumentLibraryEOService.sendWebsocket(StringUtils.join(userIdList, ","), contentInfoEn);
}
private String beforeTime (int month,Date date){