|
@@ -5,11 +5,14 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.extra.mail.MailAccount;
|
|
|
import cn.hutool.extra.mail.MailUtil;
|
|
|
import cn.hutool.extra.spring.SpringUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.xjrsoft.common.constant.GlobalConstant;
|
|
|
import com.xjrsoft.common.enums.MessageType;
|
|
|
import com.xjrsoft.common.enums.YesOrNoEnum;
|
|
|
import com.xjrsoft.common.sms.SmsSender;
|
|
|
+import com.xjrsoft.common.utils.LocalDateTimeUtil;
|
|
|
import com.xjrsoft.common.utils.RedisUtil;
|
|
|
+import com.xjrsoft.common.utils.WeChatUtil;
|
|
|
import com.xjrsoft.module.oa.entity.Message;
|
|
|
import com.xjrsoft.module.oa.service.IMessageService;
|
|
|
import com.xjrsoft.module.organization.entity.User;
|
|
@@ -59,6 +62,65 @@ public class SendMessageUtil {
|
|
|
messageService.save(message);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 发送工作流审批微信消息
|
|
|
+ */
|
|
|
+ public static void sendWorkflowApproveWx(NoticePolicyParam param, String name) {
|
|
|
+ IUserService userService = SpringUtil.getBean(IUserService.class);
|
|
|
+ RedisUtil redisUtil = SpringUtil.getBean(RedisUtil.class);
|
|
|
+
|
|
|
+ WeChatUtil weChatUtil = SpringUtil.getBean(WeChatUtil.class);
|
|
|
+
|
|
|
+ //获取用户相关信息
|
|
|
+ List<User> userList = redisUtil.get(GlobalConstant.USER_CACHE_KEY, new TypeReference<List<User>>() {
|
|
|
+ });
|
|
|
+ //如果缓存中不存在用户信息,就直接去数据库查询,并保存到缓存中去
|
|
|
+ if (userList.size() == 0) {
|
|
|
+ userList = userService.list();
|
|
|
+ redisUtil.set(GlobalConstant.USER_CACHE_KEY, userList);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (param.getNoticeUserIds().size() > 0) {
|
|
|
+ for (Long userId : param.getNoticeUserIds()) {
|
|
|
+ User user = userList.stream().filter(u -> userId.equals(u.getId())).findFirst().orElse(new User());
|
|
|
+ String openId = user.getOpenId();
|
|
|
+
|
|
|
+ if (StrUtil.isEmpty(openId)) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ // 任务名称
|
|
|
+ data.put("thing8", new JSONObject() {{
|
|
|
+ put("value", param.getSchemaName());
|
|
|
+ }});
|
|
|
+ // 事项名称
|
|
|
+ data.put("thing2", new JSONObject() {{
|
|
|
+ put("value", name);
|
|
|
+ }});
|
|
|
+ // 申请人
|
|
|
+ data.put("thing6", new JSONObject() {{
|
|
|
+ put("value", param.getStartUserName());
|
|
|
+ }});
|
|
|
+ // 时间
|
|
|
+ data.put("time3", new JSONObject() {{
|
|
|
+ put("value", LocalDateTimeUtil.format(LocalDateTime.now(), LocalDateTimeUtil.LOCAL_DATE_TIME_FORMAT));
|
|
|
+ }});
|
|
|
+
|
|
|
+ JSONObject object = new JSONObject();
|
|
|
+ object.put("touser", openId);
|
|
|
+ object.put("template_id", "sHsmz7LRj7HLd7GSTS3r2jCLvK-4Wp19iGzEvYK8n_I");
|
|
|
+ object.put("miniprogram", new JSONObject() {{
|
|
|
+ put("appid", weChatUtil.getAppletAppKey());
|
|
|
+ put("pagepath", StrUtil.format("/xjrsoft/pages/workflow/approval?taskId={}&processId={}&type=todo", param.getTaskId(), param.getProcessId()));
|
|
|
+ }});
|
|
|
+ object.put("client_msg_id", param.getTaskId());
|
|
|
+ object.put("data", data);
|
|
|
+ weChatUtil.sendTemplateMessage(object);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 添加工作流审批消息
|
|
|
*/
|