Browse Source

微信通知修改

master
DX 1 month ago
parent
commit
5ad5ddad74
  1. 4
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java
  2. 25
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java
  3. 13
      yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/util/StringUtil.java

4
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java

@ -14,6 +14,7 @@ import cn.iocoder.yudao.module.system.dal.mysql.enterprise.EnterpriseMapper;
import cn.iocoder.yudao.module.system.dal.mysql.enterpriseinspections.EnterpriseInspectionsMapper;
import cn.iocoder.yudao.module.system.dal.mysql.taskinfo.TaskInfoMapper;
import cn.iocoder.yudao.module.system.service.taskinfo.TaskInfoService;
import cn.iocoder.yudao.module.system.util.StringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import lombok.extern.slf4j.Slf4j;
import org.redisson.executor.TasksService;
@ -59,11 +60,10 @@ public class TaskSendStartMessageJob implements JobHandler {
Map<String, String> message = new HashMap<>();
message.put("thing2", beforeTaskInfo.getTitle());
message.put("time3", DateUtil.format(beforeTaskInfo.getStartDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY));
message.put("thing4", beforeTaskInfo.getDescription());
message.put("thing4", StringUtil.truncateString(beforeTaskInfo.getDescription(), 15));
message.put("time5", DateUtil.format(beforeTaskInfo.getEndDate().atStartOfDay(), DateUtils.FORMAT_YEAR_MONTH_DAY));
reqDTO.setMessages(message);
socialClientApi.sendWxaSubscribeMessage(reqDTO);
}
catch (Exception e){
log.error("任务发送通知错误:",e.toString());

25
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java

@ -28,6 +28,7 @@ import cn.iocoder.yudao.module.system.service.auth.AdminAuthService;
import cn.iocoder.yudao.module.system.service.dept.DeptService;
import cn.iocoder.yudao.module.system.service.taglibrary.TagLibraryService;
import cn.iocoder.yudao.module.system.service.user.AdminUserService;
import cn.iocoder.yudao.module.system.util.StringUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
@ -340,7 +341,7 @@ public class TaskInfoServiceImpl implements TaskInfoService {
Map<String, String> message = new HashMap<>();
message.put("thing2", taskInfoDO.getTitle());
message.put("time3", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY));
message.put("thing4", taskInfoDO.getDescription());
message.put("thing4", StringUtil.truncateString(taskInfoDO.getDescription(), 15));
message.put("time5", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY));
reqDTO.setMessages(message);
socialClientApi.sendWxaSubscribeMessage(reqDTO);
@ -351,17 +352,17 @@ public class TaskInfoServiceImpl implements TaskInfoService {
}
//站内信发送通知
NotifySendSingleToUserReqDTO notifyMessage = new NotifySendSingleToUserReqDTO();
notifyMessage.setUserId(Long.valueOf(enterpriseInspectionsDO.getUserId()));
notifyMessage.setTemplateCode("task_messages");
Map<String, Object> templateParams = new HashMap<>();
templateParams.put("title", taskInfoDO.getTitle());
templateParams.put("startTime", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY));
templateParams.put("endTime", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY) );
templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId());
notifyMessage.setTemplateParams(templateParams);
notifyMessageSendApi.sendSingleMessageToMember(notifyMessage);
// NotifySendSingleToUserReqDTO notifyMessage = new NotifySendSingleToUserReqDTO();
// notifyMessage.setUserId(Long.valueOf(enterpriseInspectionsDO.getUserId()));
// notifyMessage.setTemplateCode("task_messages");
// Map<String, Object> templateParams = new HashMap<>();
// templateParams.put("title", taskInfoDO.getTitle());
// templateParams.put("startTime", DateUtil.format(taskInfoDO.getStartDate(), DateUtils.FORMAT_YEAR_MONTH_DAY));
// templateParams.put("endTime", DateUtil.format(taskInfoDO.getEndDate(), DateUtils.FORMAT_YEAR_MONTH_DAY) );
// templateParams.put("url", "sub/task/detail?taskId="+ enterpriseInspectionsDO.getTaskId());
// notifyMessage.setTemplateParams(templateParams);
// notifyMessageSendApi.sendSingleMessageToMember(notifyMessage);
enterpriseInspectionsDO.setStatus(2);
list.add(enterpriseInspectionsDO);

13
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/util/StringUtil.java

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.system.util;
public class StringUtil {
/*
字符串截取, 超过长度用...
*/
public static String truncateString(String text, int maxLength) {
if (text.length() > maxLength) {
return text.substring(0, maxLength) + "...";
}
return text;
}
}
Loading…
Cancel
Save