Merge remote-tracking branch 'origin/feature_dev_20221025_message' into feature_dev_20221025_message

This commit is contained in:
CD
2022-10-31 15:37:20 +08:00
5 changed files with 254 additions and 63 deletions
@@ -5265,15 +5265,20 @@ public class BussDocumentLibraryEOServiceImpl extends ServiceImpl<BussDocumentLi
// String contentInfo = sysUser.getUsername() + " pushed " + StringUtils.join(hrefList, ",") + " to you. Please be reminded to check it out.";
// String title = StringUtils.join(serialNumberList, ",") + " has been pushed to you, please check";
String contentEnNo = sysUser.getUsername() + " shared " + StringUtils.join(serialNumberList, ",") + " with you, please be reminded to check it out.";
String contentInfoEnYes = sysUser.getUsername() + " shared " + StringUtils.join(hrefList, ",") + " with you, please be reminded to check it out.";
String contentInfoCnNo = sysUser.getUsername() + "向您分享了" + StringUtils.join(serialNumberList, ",") + "请查看.";
String contentInfoCnYes = sysUser.getUsername() + "向您分享了" + StringUtils.join(hrefList, ",") + "请查看.";
//封装消息的实体类
SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList,
title,
content,
contentInfo,
contentEnNo,
contentInfoEnYes,
MessageTypeEnum.PUSH.getValue(),
MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
null,
null);
contentInfoCnNo,
contentInfoCnYes);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
sendWebsocket(StringUtils.join(thirdIdList, ","), contentInfo);
//飞书
@@ -42,6 +42,7 @@ import com.jero.modules.system.service.ISysUserService;
import com.jero.modules.system.service.impl.SysCategoryServiceImpl;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -409,31 +410,83 @@ public class DummyInventoryBaseEOServiceImpl extends ServiceImpl<DummyInventoryB
//发消息
int count = 1;
List<String> hrefListAdd = new ArrayList<>();
if(serialNumberAddList.size() != 0){
List<String> hrefList = new ArrayList<>();
for (DummyInventoryInfoEO dummyInventoryInfoEO : collectAdd) {
String href = "<a href='/docManage/library/detail?id=" + dummyInventoryInfoEO.getBussDocumentLibraryId() +
"&title=" + dummyInventoryInfoEO.getTitle() +
"&serial_number=" + dummyInventoryInfoEO.getSerialNumber() + "'" + " target='_blank'>" + dummyInventoryInfoEO.getSerialNumber() + "</a>";
hrefList.add(href);
hrefListAdd.add(href);
}
contentLog += count+". New regulations: " + StringUtils.join(hrefList,",") + "</br>";
contentLog += count+". New regulations: " + StringUtils.join(hrefListAdd,",") + "</br>";
contentLogFeishu += count+". New regulations: " + StringUtils.join(serialNumberAddList,",") + " ";
count++;
}
List<String> hrefListDelete = new ArrayList<>();
if(serialNumberDeleteList.size() != 0){
List<String> hrefList = new ArrayList<>();
for (DummyInventoryInfoEO dummyInventoryInfoEO : collectDelete) {
String href = "<a href='/docManage/library/detail?id=" + dummyInventoryInfoEO.getBussDocumentLibraryId() +
"&title=" + dummyInventoryInfoEO.getTitle() +
"&serial_number=" + dummyInventoryInfoEO.getSerialNumber() + "'" + " target='_blank'>" + dummyInventoryInfoEO.getSerialNumber() + "</a>";
hrefList.add(href);
hrefListDelete.add(href);
}
contentLog += count + ". Remove regulations: " + StringUtils.join(hrefList,",") + "</br>";
contentLog += count + ". Remove regulations: " + StringUtils.join(hrefListDelete,",") + "</br>";
contentLogFeishu += count + ". Remove regulations: " + StringUtils.join(serialNumberDeleteList,",") + " ";
}
if(serialNumberAddList.size() != 0 || serialNumberDeleteList.size() != 0){
int countNo = 1;
StringBuilder sbContentNo = new StringBuilder();
if(ObjectUtils.isNotEmpty(serialNumberAddList)){
sbContentNo.append(countNo+". New regulations: "+StringUtils.join(serialNumberAddList,",")+", ");
countNo ++;
}
if(ObjectUtils.isNotEmpty(serialNumberDeleteList)){
sbContentNo.append(countNo+". Remove regulations: "+StringUtils.join(serialNumberDeleteList,","));
}
int countYes = 1;
StringBuilder sbContentYes = new StringBuilder();
if(ObjectUtils.isNotEmpty(serialNumberAddList)){
sbContentYes.append(countYes+". New regulations: "+StringUtils.join(hrefListAdd,",")+"</br>");
countYes ++;
}
if(ObjectUtils.isNotEmpty(serialNumberDeleteList)){
sbContentYes.append(countYes+". Remove regulations: "+StringUtils.join(hrefListDelete,","));
}
//消息英文--不带标签
String contentNo = "The "+ baseEO.getName()+" virtual list you subscribed to has been updated as follows" + sbContentNo;
//消息英文--带标签
String contentYes = "The "+ baseEO.getName()+" virtual list you subscribed to has been updated as follows"+ "</br>" + sbContentYes;;
int countInfoNo = 1;
StringBuilder sbContentINfoNo = new StringBuilder();
if(ObjectUtils.isNotEmpty(serialNumberAddList)){
sbContentINfoNo.append(countInfoNo+". 新增文档: "+StringUtils.join(serialNumberAddList,",")+", ");
countInfoNo ++;
}
if(ObjectUtils.isNotEmpty(serialNumberDeleteList)){
sbContentINfoNo.append(countInfoNo+". 删除文档: "+StringUtils.join(serialNumberDeleteList,","));
}
int countInfoYes = 1;
StringBuilder sbContentInfoYes = new StringBuilder();
if(ObjectUtils.isNotEmpty(serialNumberAddList)){
sbContentInfoYes.append(countInfoYes+". 新增文档: "+StringUtils.join(hrefListAdd,",")+"</br>");
countInfoYes ++;
}
if(ObjectUtils.isNotEmpty(serialNumberDeleteList)){
sbContentInfoYes.append(countInfoYes+". 删除文档: "+StringUtils.join(hrefListDelete,","));
}
//消息中文--不带标签
String contentInfoNo = "您所订阅的"+baseEO.getName()+"虚拟清单已更新,更新内容如下:"+sbContentINfoNo;
//消息中文--带标签
String contentInfoYes = "您所订阅的"+baseEO.getName()+"虚拟清单已更新,更新内容如下:"+"</br>"+sbContentInfoYes;
List<String> userNameList = dummyReadEOService.queryReadUserInfo(dummyInventoryBaseEO.getId());
List<String> thirdIdList = new ArrayList<>();
if(userNameList.size() != 0){
@@ -444,12 +497,12 @@ public class DummyInventoryBaseEOServiceImpl extends ServiceImpl<DummyInventoryB
String title = "The "+ baseEO.getName()+" virtual list you subscribed to has been updated.";
SysAnnouncement sysAnnouncement = bussDocumentLibraryEOService.getSysAnnouncement(userIdList,
title,
title,
contentLog,
contentNo,
contentYes,
MessageTypeEnum.READ.getValue(),
MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
null,
null);
contentInfoNo,
contentInfoYes);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
bussDocumentLibraryEOService.sendWebsocket(dummyInventoryBaseEO.getId(), title);
}
@@ -499,13 +552,16 @@ public class DummyInventoryBaseEOServiceImpl extends ServiceImpl<DummyInventoryB
String title = "The "+ baseEO.getName()+" virtual list you subscribed to has been withdrawn.";
//Please note that the XX virtual list you subscribed to has been withdrawn.
String contentLog = "Please note that the "+ baseEO.getName()+" virtual list you subscribed to has been withdrawn.";
String contentCn = "您订阅的虚拟清单"+ baseEO.getName()+"已被撤回.";
String contentInfoEn = "Please note that the "+ baseEO.getName()+" virtual list you subscribed to has been withdrawn.";
SysAnnouncement sysAnnouncement = bussDocumentLibraryEOService.getSysAnnouncement(userIdList,
title,
title,
contentLog,
contentInfoEn,
contentInfoEn,
MessageTypeEnum.READ.getValue(),
MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
null,null);
contentCn,contentCn);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
bussDocumentLibraryEOService.sendWebsocket(dummyInventoryBaseEO.getId(), title);
}
@@ -881,8 +881,24 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl<ProblemKnowle
+ "'>" + " View details" + "</a>";
String contentInfo = msgContentEN + " " + href;
String ContentENNo = currentUser.getUsername()+" shared " + problemKnowledgeBaseTitle + " with you.Please be reminded to check it out.";
String ContentInfoENYes = currentUser.getUsername()+" shared " + problemKnowledgeBaseTitle + " with you.Please be reminded to check it out."+ " " + href;
String contentCnNo = currentUser.getUsername()+"向您分享了"+problemKnowledgeBaseTitle+",请查看.";
String contentInfoCnYes = currentUser.getUsername()+"向您分享了"+problemKnowledgeBaseTitle+",请查看"+ " " + href;
//封装消息的实体类
SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList, msgTitle, msgContentEN, contentInfo,MessageTypeEnum.PUSH.getValue(),MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName());
SysAnnouncement sysAnnouncement = getSysAnnouncement(userIdList,
msgTitle,
ContentENNo,
ContentInfoENYes,
MessageTypeEnum.PUSH.getValue(),
MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
contentCnNo,
contentInfoCnYes);
this.sysAnnouncementService.saveAnnouncement(sysAnnouncement);
this.sendWebsocket(StringUtils.join(thirdIdList, ","), contentInfo);
//飞书
@@ -922,7 +938,9 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl<ProblemKnowle
String content,
String contentInfo,
String messageType,
String initiator) {
String initiator,
String contentCn,
String contentInfoCn) {
SysAnnouncement sysAnnouncement = new SysAnnouncement();
sysAnnouncement.setInitiator(initiator);
sysAnnouncement.setDelFlag("0");
@@ -934,6 +952,8 @@ public class ProblemKnowledgeBaseEOServiceImpl extends ServiceImpl<ProblemKnowle
sysAnnouncement.setMsgContent(content);
sysAnnouncement.setMsgContentInfo(contentInfo);
sysAnnouncement.setUserIds(StringUtils.join(userIdList, ","));
sysAnnouncement.setMsgContentCn(contentCn);
sysAnnouncement.setMsgContentInfoCn(contentInfoCn);
return sysAnnouncement;
}
}
@@ -373,7 +373,7 @@ public class LawsWarnService {
thirdIdList.addAll(thirdId);
}
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
//查询文档
List<Map<String, Object>> mapList = bussDocumentLibraryEOMapper.selectMapsAll(documentIds);
List<String> serialNumberList = new ArrayList<>();
@@ -409,27 +409,52 @@ public class LawsWarnService {
"&serial_number=" + map.get("serial_number") + "'" + " target='_blank'>" + map.get("serial_number") + "</a>";
urlList.add(url);
hrefList.add(href+timeContent);
//推送多条时, 每条单独发消息
//编号, 标题, 新车型实施日期, 在产车实施日期
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
String serialNumber = StringUtils.valueOf(map.get("serial_number"));
String titleCn = StringUtils.valueOf(map.get("title"));
String titleEn = StringUtils.valueOf(map.get("title_en"));
String newType = "";
if(ObjectUtils.isNotEmpty(map.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"))){
newType = sdf.format(map.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"));
}
String newVehicle = "";
if(ObjectUtils.isNotEmpty(map.get("implement_time"))){
newVehicle = sdf.format(map.get("implement_time"));
}
//消息-英文
String contentNo = sysUser.getUsername() +" shared Regulation Early Warning infomation with you, "
+"Regulation No: "+serialNumber+",Title: "+titleEn+",New Type Execution Date: "+newType+",New Vehicle Execution Date: "+newVehicle;
String contentInfoYes = sysUser.getUsername() +" shared Regulation Early Warning infomation with you, "+"</br>"
+"Regulation No: "+href+"</br>"
+"Title: "+titleEn+"</br>"
+"New Type Execution Date: "+newType+"</br>"
+"New Vehicle Execution Date: "+newVehicle;
//消息中文
String contentCnNo = sysUser.getUsername() +"向您分享了法规预警信息, "+"编号: "+serialNumber+",标题: "+titleCn+",新车型实施日期: "+newType+",在产车实施日期: "+newVehicle;
String contentInfoCnYes = sysUser.getUsername() +"向您分享了法规预警信息,"+"</br>"
+"编号: "+href+"</br>"
+"标题: "+titleCn+"</br>"
+"新车型实施日期: "+newType+"</br>"
+"在产车实施日期: "+newVehicle;
//封装消息的实体类
SysAnnouncement sysAnnouncement = bussDocumentLibraryEOService.getSysAnnouncement(userIdList,
null,
contentNo,
contentInfoYes,
MessageTypeEnum.PUSH.getValue(),
MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
contentCnNo,contentInfoCnYes);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
bussDocumentLibraryEOService.sendWebsocket(StringUtils.join(thirdIdList, ","), contentInfoCnYes);
}
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
String content = StringUtils.join(serialNumberList, ",") + " has been shared with you, please check.";
//消息详情模板
// XXX has pushed GB 7258 to you as the implementation date of vehicle production is XXXX-XX-XX
// GB 7258 to you as the implementation date of vehicle production is XXXX-XX-XX Please be reminded to check it out.
String contentInfo = sysUser.getUsername() + " has pushed " + StringUtils.join(hrefList, ",") + ", Please be reminded to check it out.";
String title = content;
//封装消息的实体类
SysAnnouncement sysAnnouncement = bussDocumentLibraryEOService.getSysAnnouncement(userIdList,
title,
content,
contentInfo,
MessageTypeEnum.PUSH.getValue(),
MessageTypeEnum.SYSTEMATIC_NOTIFICATION.getName(),
null,null);
sysAnnouncementService.saveAnnouncement(sysAnnouncement);
bussDocumentLibraryEOService.sendWebsocket(StringUtils.join(thirdIdList, ","), contentInfo);
//飞书
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
@@ -473,7 +498,7 @@ public class LawsWarnService {
} catch (IOException e) {
e.printStackTrace();
}
bussDocumentLibraryEOService.sendWebsocket(documentIds, contentInfo);
bussDocumentLibraryEOService.sendWebsocket(documentIds, documentIds);
return "推送成功";
}
@@ -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){