法规预警推送
This commit is contained in:
+9
@@ -58,6 +58,15 @@ public interface IFeishuService {
|
|||||||
*/
|
*/
|
||||||
String sendCardMsgTerritory(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException;
|
String sendCardMsgTerritory(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 预警推送(飞书消息)
|
||||||
|
* @param userIds
|
||||||
|
* @param feishuMsgVo
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
String sendCardMsgWarn(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 虚拟清单(飞书消息)
|
* 虚拟清单(飞书消息)
|
||||||
* @param userIds
|
* @param userIds
|
||||||
|
|||||||
+108
@@ -453,6 +453,114 @@ public class FeishuServiceImpl implements IFeishuService {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
contentSb.append("\"header\": {");
|
||||||
|
contentSb.append("\"template\": \"green\",");
|
||||||
|
contentSb.append("\"title\": {");
|
||||||
|
contentSb.append("\"content\": \" " + feishuMsgVo.getTitle() + " \",");
|
||||||
|
contentSb.append("\"tag\": \"plain_text\"");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("}");
|
||||||
|
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(contentSb.toString());
|
||||||
|
|
||||||
|
// 设置请求参数
|
||||||
|
JSONObject paramsMap = new JSONObject();
|
||||||
|
paramsMap.put("user_ids", userIds);
|
||||||
|
paramsMap.put("msg_type", "interactive");
|
||||||
|
paramsMap.put("card", jsonObject);
|
||||||
|
|
||||||
|
// 发送请求给飞书
|
||||||
|
String response = HttpRequestUtil.getResponseOfPOST(batchSendMessageUrl, headerMap, paramsMap.toJSONString());
|
||||||
|
// 获取返回结果
|
||||||
|
JSONObject tokenJson = JSONObject.parseObject(response);
|
||||||
|
if(!tokenJson.get("code").toString().equals("0")) {
|
||||||
|
log.error("请求出现异常:" + tokenJson.get("msg") + " " + tokenJson);
|
||||||
|
}
|
||||||
|
return tokenJson.get("msg").toString();
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 预警推送(飞书消息)
|
||||||
|
* @param userIds
|
||||||
|
* @param feishuMsgVo
|
||||||
|
* @return
|
||||||
|
* @throws IOException
|
||||||
|
*/
|
||||||
|
public String sendCardMsgWarn(String[] userIds, FeishuMsgVo feishuMsgVo) throws IOException {
|
||||||
|
String token = getTenantAccessToken();
|
||||||
|
// 设置请求头
|
||||||
|
Map<String, String> headerMap = new HashMap<>();
|
||||||
|
headerMap.put("Authorization", "Bearer " + token);
|
||||||
|
headerMap.put("Content-Type", "application/json; charset=utf-8");
|
||||||
|
|
||||||
|
// 示例
|
||||||
|
StringBuilder contentSb = new StringBuilder();
|
||||||
|
contentSb.append("{");
|
||||||
|
contentSb.append("\"elements\": [");
|
||||||
|
// 内容中文
|
||||||
|
if (StrUtil.isNotEmpty(feishuMsgVo.getContent())){
|
||||||
|
contentSb.append("{");
|
||||||
|
contentSb.append("\"tag\": \"div\",");
|
||||||
|
contentSb.append("\"text\": {");
|
||||||
|
contentSb.append("\"content\": \"" + feishuMsgVo.getContent() + "\"\n,");
|
||||||
|
contentSb.append("\"tag\": \"lark_md\"");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("},");
|
||||||
|
};
|
||||||
|
// 编号,标题,新车型实施日期,在产车实施日期
|
||||||
|
contentSb.append("{");
|
||||||
|
contentSb.append("\"tag\": \"div\",");
|
||||||
|
contentSb.append("\"text\": {");
|
||||||
|
contentSb.append("\"content\": \"" + "编号: " + feishuMsgVo.getRegulationNo() + "\n")
|
||||||
|
.append("标题: "+feishuMsgVo.getDocumentTitleCn() + "\n")
|
||||||
|
.append("新车型实施日期: "+feishuMsgVo.getNewTypeExecutionDate()+ "\n")
|
||||||
|
.append("在产车实施日期: "+feishuMsgVo.getNewVehicleExecutionDate()+ "\",");
|
||||||
|
contentSb.append("\"tag\": \"lark_md\"");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("},");
|
||||||
|
contentSb.append("{\"tag\": \"hr\"},");
|
||||||
|
|
||||||
|
//内容英文
|
||||||
|
if (StrUtil.isNotEmpty(feishuMsgVo.getContentEn())){
|
||||||
|
contentSb.append("{");
|
||||||
|
contentSb.append("\"tag\": \"div\",");
|
||||||
|
contentSb.append("\"text\": {");
|
||||||
|
contentSb.append("\"content\": \"" + feishuMsgVo.getContentEn() + "\"\n,");
|
||||||
|
contentSb.append("\"tag\": \"lark_md\"");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("},");
|
||||||
|
};
|
||||||
|
// 编号,标题,新车型实施日期,在产车实施日期
|
||||||
|
contentSb.append("{");
|
||||||
|
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() + "\",");
|
||||||
|
contentSb.append("\"tag\": \"lark_md\"");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("},");
|
||||||
|
|
||||||
|
|
||||||
|
contentSb.append("{");
|
||||||
|
contentSb.append("\"actions\": [");
|
||||||
|
contentSb.append("{");
|
||||||
|
contentSb.append("\"tag\": \"button\",");
|
||||||
|
contentSb.append("\"text\": {");
|
||||||
|
contentSb.append("\"content\": \"view\",");
|
||||||
|
contentSb.append("\"tag\": \"plain_text\"");
|
||||||
|
contentSb.append("},");
|
||||||
|
contentSb.append("\"type\": \"primary\",");
|
||||||
|
contentSb.append("\"url\": \" "+ feishuMsgVo.getUrl() +" \"");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("],");
|
||||||
|
contentSb.append("\"tag\": \"action\"");
|
||||||
|
contentSb.append("}");
|
||||||
|
contentSb.append("],");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
contentSb.append("\"header\": {");
|
contentSb.append("\"header\": {");
|
||||||
contentSb.append("\"template\": \"green\",");
|
contentSb.append("\"template\": \"green\",");
|
||||||
contentSb.append("\"title\": {");
|
contentSb.append("\"title\": {");
|
||||||
|
|||||||
+4
-4
@@ -28,13 +28,13 @@ public class FeishuMsgVo {
|
|||||||
|
|
||||||
private String assignee; //评估人 适用范围:责任人提交通知发起人(设计符合性,pre-homo符合性,验证符合性)
|
private String assignee; //评估人 适用范围:责任人提交通知发起人(设计符合性,pre-homo符合性,验证符合性)
|
||||||
|
|
||||||
private String RegulationNo; //编号
|
private String documentTitleCn; //文档标题中文
|
||||||
|
|
||||||
private String documentTitle; //文档标题
|
private String documentTitleEn; //文档标题英文
|
||||||
|
|
||||||
private String NewTypeExecutionDate; //新车型实施日期
|
private String newTypeExecutionDate; //新车型实施日期
|
||||||
|
|
||||||
private String NewVehicleExecutionDate; //在产车实施日期
|
private String newVehicleExecutionDate; //在产车实施日期
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+39
-15
@@ -426,12 +426,17 @@ public class LawsWarnService {
|
|||||||
bussDocumentLibraryEOService.sendWebsocket(StringUtils.join(thirdIdList, ","), contentInfo);
|
bussDocumentLibraryEOService.sendWebsocket(StringUtils.join(thirdIdList, ","), contentInfo);
|
||||||
//飞书
|
//飞书
|
||||||
try {
|
try {
|
||||||
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
||||||
for (String s : urlList) {
|
for (String s : urlList) {
|
||||||
|
FeishuMsgVo feishuMsgVo = new FeishuMsgVo();
|
||||||
String encode = UriEncoder.encode(s);
|
String encode = UriEncoder.encode(s);
|
||||||
List<String> list = new ArrayList<>();
|
List<String> list = new ArrayList<>();
|
||||||
mapList.stream().forEach(e->{
|
mapList.stream().forEach(e->{
|
||||||
if(s.contains((String)e.get("id"))){
|
if(s.contains((String)e.get("id"))){
|
||||||
String serialNumber = StringUtils.valueOf(e.get("serial_number"));
|
String serialNumber = StringUtils.valueOf(e.get("serial_number"));
|
||||||
|
//封装飞书消息实体类
|
||||||
|
setFeishuMsgVo(sysUser, sdf, feishuMsgVo, encode, e, serialNumber);
|
||||||
|
|
||||||
String timeContent = "";
|
String timeContent = "";
|
||||||
if("1".equals(flag)){
|
if("1".equals(flag)){
|
||||||
String value = StringUtils.valueOf(e.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"));
|
String value = StringUtils.valueOf(e.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"));
|
||||||
@@ -453,24 +458,11 @@ public class LawsWarnService {
|
|||||||
list.add(serialNumber + timeContent);
|
list.add(serialNumber + timeContent);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
String contentTemp = sysUser.getUsername() + " has pushed " + StringUtils.join(list, ",") + ", Please be reminded to check it out.";
|
iFeishuService.sendCardMsgWarn(thirdIdList.toArray(new String[]{}), feishuMsgVo);
|
||||||
|
|
||||||
//XXX向您分享了法规预警信息。
|
|
||||||
//XXX shared Regulation Early Warning infomation with you.
|
|
||||||
String contentInfoFei = sysUser.getUsername() +" shared Regulation Early Warning infomation with you..";
|
|
||||||
String contentInfoFeiCn = sysUser.getUsername() +"向您分享了法规预警信息";
|
|
||||||
FeishuMsgVo feishuMsgVo = new FeishuMsgVo();
|
|
||||||
feishuMsgVo.setTitle(MessageTypeEnum.READ.getNameCn()+"/"+MessageTypeEnum.READ.getName());
|
|
||||||
feishuMsgVo.setUrl(encode);
|
|
||||||
feishuMsgVo.setContentEn(contentInfoFei);
|
|
||||||
feishuMsgVo.setContent(contentInfoFeiCn);
|
|
||||||
// feishuMsgVo.setRegulationNo();
|
|
||||||
// feishuMsgVo.setDocumentTitle();
|
|
||||||
// feishuMsgVo.setNewTypeExecutionDate();
|
|
||||||
// feishuMsgVo.setNewVehicleExecutionDate();
|
|
||||||
|
|
||||||
|
// String contentTemp = sysUser.getUsername() + " has pushed " + StringUtils.join(list, ",") + ", Please be reminded to check it out.";
|
||||||
// iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentTemp, MessageTypeEnum.PUSH.getName(), encode);
|
// iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentTemp, MessageTypeEnum.PUSH.getName(), encode);
|
||||||
iFeishuService.batchSendMessage(thirdIdList.toArray(new String[]{}), contentTemp, MessageTypeEnum.PUSH.getName(), encode);
|
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@@ -478,6 +470,38 @@ public class LawsWarnService {
|
|||||||
bussDocumentLibraryEOService.sendWebsocket(documentIds, contentInfo);
|
bussDocumentLibraryEOService.sendWebsocket(documentIds, contentInfo);
|
||||||
return "推送成功";
|
return "推送成功";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setFeishuMsgVo(LoginUser sysUser, SimpleDateFormat sdf, FeishuMsgVo feishuMsgVo, String encode, Map<String, Object> e, String serialNumber) {
|
||||||
|
String documentTitleCn = ""; //文档标题
|
||||||
|
String documentTitleEn = ""; //文档标题
|
||||||
|
String newTypeExecutionDate = ""; //新车型实施日期
|
||||||
|
String newVehicleExecutionDate = ""; //在产车实施日期
|
||||||
|
if(ObjectUtils.isNotEmpty(e.get("title"))){
|
||||||
|
documentTitleCn = String.valueOf(e.get("title"));
|
||||||
|
}
|
||||||
|
if(ObjectUtils.isNotEmpty(e.get("title_en"))){
|
||||||
|
documentTitleEn = String.valueOf(e.get("title_en"));
|
||||||
|
}
|
||||||
|
if(ObjectUtils.isNotEmpty(e.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"))){
|
||||||
|
newTypeExecutionDate = sdf.format(e.get("xin1_che1_xing2_shi2_shi1_ri4_qi1"));
|
||||||
|
}
|
||||||
|
if(ObjectUtils.isNotEmpty(e.get("implement_time"))){
|
||||||
|
newVehicleExecutionDate = sdf.format(e.get("implement_time"));
|
||||||
|
}
|
||||||
|
String contentInfoFei = sysUser.getUsername() +" shared Regulation Early Warning infomation with you.";
|
||||||
|
String contentInfoFeiCn = sysUser.getUsername() +"向您分享了法规预警信息.";
|
||||||
|
|
||||||
|
|
||||||
|
feishuMsgVo.setTitle(MessageTypeEnum.WARN.getNameCn()+"/"+MessageTypeEnum.WARN.getName());
|
||||||
|
feishuMsgVo.setUrl(encode);
|
||||||
|
feishuMsgVo.setContentEn(contentInfoFei);
|
||||||
|
feishuMsgVo.setContent(contentInfoFeiCn);
|
||||||
|
feishuMsgVo.setRegulationNo(serialNumber);
|
||||||
|
feishuMsgVo.setNewTypeExecutionDate(newTypeExecutionDate);
|
||||||
|
feishuMsgVo.setNewVehicleExecutionDate(newVehicleExecutionDate);
|
||||||
|
feishuMsgVo.setDocumentTitleCn(documentTitleCn);
|
||||||
|
feishuMsgVo.setDocumentTitleEn(documentTitleEn);
|
||||||
|
}
|
||||||
// public String warnPullMessage(String departIds, String userIds, String documentIds,String flag) {
|
// public String warnPullMessage(String departIds, String userIds, String documentIds,String flag) {
|
||||||
// Set<String> allDepartIds = new HashSet<>();
|
// Set<String> allDepartIds = new HashSet<>();
|
||||||
// //查询当前部门下所有部门
|
// //查询当前部门下所有部门
|
||||||
|
|||||||
Reference in New Issue
Block a user