法规预警定时任务--飞书消息

This commit is contained in:
zhn
2022-10-28 09:53:33 +08:00
parent df5d6f7987
commit 19b4df8634
2 changed files with 97 additions and 12 deletions
@@ -512,9 +512,19 @@ public class FeishuServiceImpl implements IFeishuService {
contentSb.append("\"tag\": \"div\",");
contentSb.append("\"text\": {");
contentSb.append("\"content\": \"" + "编号: " + feishuMsgVo.getRegulationNo() + "\n")
.append("标题: "+feishuMsgVo.getDocumentTitleCn() + "\n")
.append("新车型实施日期: "+feishuMsgVo.getNewTypeExecutionDate()+ "\n")
.append("在产车实施日期: "+feishuMsgVo.getNewVehicleExecutionDate()+ "\",");
.append("标题: "+feishuMsgVo.getDocumentTitleCn() + "\n");
if (StringUtils.isNotBlank(feishuMsgVo.getNewTypeExecutionDate())) {
contentSb.append("新车型实施日期: " + feishuMsgVo.getNewTypeExecutionDate() + "\n");
} else {
contentSb.append("新车型实施日期: "+ "\n");
}
if (StringUtils.isNotBlank(feishuMsgVo.getNewVehicleExecutionDate())) {
contentSb.append("在产车实施日期: " + feishuMsgVo.getNewVehicleExecutionDate());
} else {
contentSb.append("在产车实施日期: ");
}
contentSb.append("\",");
contentSb.append("\"tag\": \"lark_md\"");
contentSb.append("}");
contentSb.append("},");
@@ -535,9 +545,18 @@ public class FeishuServiceImpl implements IFeishuService {
contentSb.append("\"tag\": \"div\",");
contentSb.append("\"text\": {");
contentSb.append("\"content\": \"" + "Regulation No: " + feishuMsgVo.getRegulationNo() + "\n")
.append("Title: " + feishuMsgVo.getDocumentTitleEn() + "\n")
.append("New Type Execution Date: " + feishuMsgVo.getNewTypeExecutionDate() + "\n")
.append("New Vehicle Execution Date: " + feishuMsgVo.getNewVehicleExecutionDate() + "\",");
.append("Title: " + feishuMsgVo.getDocumentTitleEn() + "\n");
if (StringUtils.isNotBlank(feishuMsgVo.getNewTypeExecutionDate())) {
contentSb.append("New Type Execution Date: " + feishuMsgVo.getNewTypeExecutionDate() + "\n");
} else {
contentSb.append("New Type Execution Date: "+ "\n");
}
if (StringUtils.isNotBlank(feishuMsgVo.getNewVehicleExecutionDate())) {
contentSb.append("New Vehicle Execution Date: " + feishuMsgVo.getNewVehicleExecutionDate());
} else {
contentSb.append("New Vehicle Execution Date: ");
}
contentSb.append("\",");
contentSb.append("\"tag\": \"lark_md\"");
contentSb.append("}");
contentSb.append("},");
@@ -4,6 +4,7 @@ import com.jero.common.constant.enums.MessageTypeEnum;
import com.jero.modules.document.entity.BussDocumentLibraryEO;
import com.jero.modules.document.service.impl.BussDocumentLibraryEOServiceImpl;
import com.jero.modules.feishu.service.IFeishuService;
import com.jero.modules.feishu.vo.FeishuMsgVo;
import com.jero.modules.subscribe.entity.OnlCgformSubscribe;
import com.jero.modules.subscribe.service.IOnlCgformSubscribeService;
import com.jero.modules.system.entity.SysAnnouncement;
@@ -133,6 +134,18 @@ public class TimedTaskWarn implements Job {
String msgTitle = content;
sendMessage(msgTitle, content,contentInfo,content, url, userIdList, thirdIdList);
}
if(currentTime.equals(beforeTimeSixTen)){
//发送飞书消息(提前一年)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"1");
}
if(currentTime.equals(beforeTimeSix)){
//发送飞书消息(提前6个月)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"6");
}
if(currentTime.equals(xin1Che1Xing2Shi2Shi1Ri4Qi1Str)){
//发送飞书消息(当天)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"0");
}
}
//在产车实施日期
@@ -154,10 +167,63 @@ public class TimedTaskWarn implements Job {
String msgTitle = content;
sendMessage(msgTitle, content,contentInfo,content, url, userIdList, thirdIdList);
}
if(currentTime.equals(beforeTimeSixTen)){
//发送飞书消息(提前一年)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"1");
}
if(currentTime.equals(beforeTimeSix)){
//发送飞书消息(提前6个月)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"6");
}
if(currentTime.equals(implementTimeStr)){
//发送飞书消息(当天)
sendFeishu(sdf, bussDocumentLibraryEO, url, thirdIdList,"0");
}
}
}
}
private void sendFeishu(SimpleDateFormat sdf,
BussDocumentLibraryEO bussDocumentLibraryEO,
String url,
List<String> thirdIdList,
String flag) {
FeishuMsgVo feishuMsgVo = new FeishuMsgVo();
feishuMsgVo.setTitle(MessageTypeEnum.WARN.getNameCn()+"/"+MessageTypeEnum.WARN.getName());
feishuMsgVo.setUrl(url);
String contentCn = "";
String contentEn = "";
if("1".equals(flag)){
contentCn = "您所订阅的法规将于1年后实施.";
contentEn = "The regulation you subscribed to will be implemented in one year.";
}
if("6".equals(flag)){
contentCn = "您所订阅的法规将于6个月后实施.";
contentEn = "The regulation you subscribed to will be implemented in six months.";
}
if("0".equals(flag)){
contentCn = "您所订阅的法规已实施.";
contentEn = "The regulation you subscribed to is implemented.";
}
feishuMsgVo.setContent(contentCn);
feishuMsgVo.setContentEn(contentEn);
feishuMsgVo.setRegulationNo(bussDocumentLibraryEO.getSerialNumber());
feishuMsgVo.setDocumentTitleCn(bussDocumentLibraryEO.getTitle());
feishuMsgVo.setDocumentTitleEn(bussDocumentLibraryEO.getTitleEn());
if(ObjectUtils.isNotEmpty(bussDocumentLibraryEO.getXin1Che1Xing2Shi2Shi1Ri4Qi1())){
feishuMsgVo.setNewTypeExecutionDate(sdf.format(bussDocumentLibraryEO.getXin1Che1Xing2Shi2Shi1Ri4Qi1()));
}
if(ObjectUtils.isNotEmpty(bussDocumentLibraryEO.getImplementTime())){
feishuMsgVo.setNewVehicleExecutionDate(sdf.format(bussDocumentLibraryEO.getImplementTime()));
}
try {
iFeishuService.sendCardMsgWarn(thirdIdList.toArray(new String[]{}),feishuMsgVo);
} catch (IOException e) {
e.printStackTrace();
}
}
private void sendMessage(String title, String content,String contentInfo,String contentFeiShu, String url, List<String> userIdList, List<String> thirdIdList) {
//站内消息
//封装消息的实体类
@@ -165,12 +231,12 @@ public class TimedTaskWarn implements Job {
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();
}
// //飞书消息
// try {
// iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentFeiShu, MessageTypeEnum.WARN.getName(), url);
// } catch (IOException e) {
// e.printStackTrace();
// }
}
private String beforeTime (int month,Date date){