diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java index f7c0f9f..46c0b0c 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/job/TaskSendStartMessageJob.java +++ b/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 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()); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java index 7c1079c..aede359 100644 --- a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/taskinfo/TaskInfoServiceImpl.java +++ b/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 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 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 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); diff --git a/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/util/StringUtil.java b/yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/util/StringUtil.java new file mode 100644 index 0000000..0793c24 --- /dev/null +++ b/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; + } +}