Kaynağa Gözat

食堂评价,发布时通知答题人

dzx 2 ay önce
ebeveyn
işleme
e5a86796de

+ 46 - 1
src/main/java/com/xjrsoft/module/evaluate/service/impl/EvaluateManageServiceImpl.java

@@ -2,10 +2,14 @@ package com.xjrsoft.module.evaluate.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
 import cn.hutool.core.bean.BeanUtil;
+import cn.hutool.core.util.IdUtil;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.enums.DeleteMark;
 import com.xjrsoft.common.enums.EvaluateTypeEnum;
 import com.xjrsoft.common.exception.MyException;
 import com.xjrsoft.module.evaluate.dto.DrillEvaluateClassListDto;
@@ -33,6 +37,10 @@ import com.xjrsoft.module.evaluate.vo.EvaluateManageScoreVo;
 import com.xjrsoft.module.evaluate.vo.EvaluateWriteVo;
 import com.xjrsoft.module.evaluate.vo.MobileIndexPageVo;
 import com.xjrsoft.module.evaluate.vo.MobileResultPageVo;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.organization.service.IWeChatService;
 import lombok.AllArgsConstructor;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
@@ -42,6 +50,8 @@ import javax.script.ScriptEngineManager;
 import javax.script.ScriptException;
 import java.text.DecimalFormat;
 import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.format.DateTimeFormatter;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
@@ -64,7 +74,8 @@ public class EvaluateManageServiceImpl extends MPJBaseServiceImpl<EvaluateManage
     private final EvaluateExecuterMapper evaluateExecuterMapper;
     private final EvaluateItemMapper evaluateItemMapper;
     private final EvaluateManageItemMapper evaluateManageItemMapper;
-
+    private final IUserService userService;
+    private final IWeChatService weChatService;
 
     @Override
     @Transactional(rollbackFor = Exception.class)
@@ -138,6 +149,40 @@ public class EvaluateManageServiceImpl extends MPJBaseServiceImpl<EvaluateManage
         evaluateManage.setModifyUserId(StpUtil.getLoginIdAsLong());
 
         evaluateManageMapper.updateById(evaluateManage);
+        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
+        String time17 = LocalDateTime.now().format(formatter);
+        // 查询参加答题的用户进行微信消息通知
+        List<User> list = userService.list(
+                new MPJLambdaWrapper<User>()
+                        .innerJoin(EvaluateExecuter.class, EvaluateExecuter::getEvaluateObjectId, User::getId)
+                        .eq(EvaluateExecuter::getEvaluateManageId, evaluateManage.getId())
+                        .eq(EvaluateExecuter::getDeleteMark, DeleteMark.NODELETE.getCode())
+                        .ne(User::getOpenId, "")
+                        .isNotNull(User::getOpenId)
+        );
+        User releaseUser = userService.getById(StpUtil.getLoginIdAsLong());
+        for (User user : list) {
+            WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+            weChatSendMessageDto.setUserId(user.getOpenId());
+            weChatSendMessageDto.setTemplateId("qmpXORPM1Cocqn503Qa4On6BJhR92UZ00eod2-6IcGo");
+            weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
+            JSONObject paramJson = new JSONObject();
+
+            JSONObject thing23 = new JSONObject();
+            thing23.put("value", evaluateManage.getName());
+            paramJson.put("thing23", thing23);
+
+            JSONObject thing29 = new JSONObject();
+            thing29.put("value", releaseUser.getName());
+            paramJson.put("thing29", thing29);
+
+            JSONObject time17Json = new JSONObject();
+            time17Json.put("value", time17);
+            paramJson.put("time17", time17Json);
+
+            weChatSendMessageDto.setContent(paramJson);
+            weChatService.sendTemplateMessage(weChatSendMessageDto);
+        }
         return true;
     }