浏览代码

修改传阅发消息

snihwxf 2 月之前
父节点
当前提交
1d411057d7
共有 1 个文件被更改,包括 21 次插入8 次删除
  1. 21 8
      src/main/java/com/xjrsoft/module/workflow/service/impl/WorkflowExecuteServiceImpl.java

+ 21 - 8
src/main/java/com/xjrsoft/module/workflow/service/impl/WorkflowExecuteServiceImpl.java

@@ -8,6 +8,7 @@ import cn.hutool.core.collection.ListUtil;
 import cn.hutool.core.convert.Convert;
 import cn.hutool.core.date.DateUtil;
 import cn.hutool.core.map.MapUtil;
+import cn.hutool.core.util.IdUtil;
 import cn.hutool.core.util.ObjectUtil;
 import cn.hutool.core.util.StrUtil;
 import cn.hutool.db.Session;
@@ -48,9 +49,11 @@ import com.xjrsoft.module.magicapi.service.IMagicApiService;
 import com.xjrsoft.module.magicapi.vo.MagicApiInfoVo;
 import com.xjrsoft.module.oa.entity.OfficialDocumentReceived;
 import com.xjrsoft.module.oa.mapper.OfficialDocumentReceivedMapper;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
 import com.xjrsoft.module.organization.entity.User;
 import com.xjrsoft.module.organization.entity.UserRoleRelation;
 import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.organization.service.IWeChatService;
 import com.xjrsoft.module.system.entity.DictionaryDetail;
 import com.xjrsoft.module.system.entity.File;
 import com.xjrsoft.module.system.entity.Stamp;
@@ -5522,7 +5525,8 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
             }
         }
         if (!appendUserTaskCirculated.isEmpty()) {
-            WeChatUtil weChatUtil = SpringUtil.getBean(WeChatUtil.class);
+//            WeChatUtil weChatUtil = SpringUtil.getBean(WeChatUtil.class);
+            IWeChatService weChatUtil = SpringUtil.getBean(IWeChatService.class);
             CommonPropertiesConfig cpConfig = SpringUtil.getBean(CommonPropertiesConfig.class);
             Map<Long, User> userMap = userService.listByIds(appendUserTaskCirculated).stream().filter(x -> StrUtil.isNotEmpty(x.getOpenId())).collect(Collectors.toMap(User::getId, x -> x));
             for (Long userId : appendUserTaskCirculated) {
@@ -5552,13 +5556,22 @@ public class WorkflowExecuteServiceImpl implements IWorkflowExecuteService {
                         put("value", LocalDateTimeUtil.format(LocalDateTime.now(), LocalDateTimeUtil.LOCAL_DATE_TIME_FORMAT));
                     }});
 
-                    JSONObject object = new JSONObject();
-                    object.put("touser", appendUser.getOpenId());
-                    object.put("template_id", "sHsmz7LRj7HLd7GSTS3r2jCLvK-4Wp19iGzEvYK8n_I");
-                    object.put("url", StrUtil.format("{}/xjrsoft/pages/workflow/approval?taskId={}&processId={}&type=todo", cpConfig.getDomainApp(), task.getId(), task.getProcessInstanceId()));
-                    object.put("client_msg_id", task.getId());
-                    object.put("data", data);
-                    weChatUtil.sendTemplateMessage(object);
+//                    JSONObject object = new JSONObject();
+//                    object.put("touser", appendUser.getOpenId());
+//                    object.put("template_id", "sHsmz7LRj7HLd7GSTS3r2jCLvK-4Wp19iGzEvYK8n_I");
+//                    object.put("url", StrUtil.format("{}/xjrsoft/pages/workflow/approval?taskId={}&processId={}&type=todo", cpConfig.getDomainApp(), task.getId(), task.getProcessInstanceId()));
+//                    object.put("client_msg_id", task.getId());
+//                    object.put("data", data);
+//                    weChatUtil.sendTemplateMessage(object);
+
+                    WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+                    weChatSendMessageDto.setUserId(appendUser.getOpenId());
+                    weChatSendMessageDto.setTemplateId("sHsmz7LRj7HLd7GSTS3r2jCLvK-4Wp19iGzEvYK8n_I");
+                    weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextIdStr());
+                    weChatSendMessageDto.setUrl(StrUtil.format("{}/xjrsoft/pages/workflow/approval?taskId={}&processId={}&type=todo", cpConfig.getDomainApp(), task.getId(), task.getProcessInstanceId()));
+                    weChatSendMessageDto.setContent(data);
+                    weChatUtil.sendTemplateMessage(weChatSendMessageDto);
+
                 }catch (Exception e){
                     Log.error(e.getMessage(), e);
                 }