Browse Source

1、成绩录入班级搜索报错
2、课表发布后,通知督导处

dzx 11 months ago
parent
commit
e063b35e9b

+ 4 - 1
src/main/java/com/xjrsoft/module/schedule/controller/ScheduleController.java

@@ -88,8 +88,9 @@ public class ScheduleController {
     @ApiOperation(value="接收消息")
     @SaCheckPermission("schedule:detail")
     public RT<CourseReceiveMsg> receiveMsg(@RequestParam String schoolId, @RequestParam String eduYearSerialNo, @RequestParam String startDate, @RequestParam String endDate) throws Exception {
+        Date date = new Date();
         CourseReceiveMsg courseReceiveMsg = new CourseReceiveMsg();
-        courseReceiveMsg.setCreateDate(new Date());
+        courseReceiveMsg.setCreateDate(date);
         courseReceiveMsg.setSchoolId(schoolId);
         courseReceiveMsg.setEduYearSerialNo(eduYearSerialNo);
         courseReceiveMsg.setStartDate(startDate);
@@ -98,6 +99,8 @@ public class ScheduleController {
         courseReceiveMsg.setEnabledMark(EnabledMark.ENABLED.getCode());
         courseReceiveMsgService.save(courseReceiveMsg);
 
+        courseReceiveMsgService.noticeOverseer(eduYearSerialNo, date);
+
         return RT.ok(courseReceiveMsg);
     }
 

+ 6 - 1
src/main/java/com/xjrsoft/module/schedule/service/ICourseReceiveMsgService.java

@@ -3,6 +3,8 @@ package com.xjrsoft.module.schedule.service;
 import com.github.yulichang.base.MPJBaseService;
 import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
 
+import java.util.Date;
+
 /**
 * @title: 班级荣誉
 * @Author szs
@@ -13,5 +15,8 @@ import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
 public interface ICourseReceiveMsgService extends MPJBaseService<CourseReceiveMsg> {
 
 
-
+    /**
+     * 通知督导室
+     */
+    Boolean noticeOverseer(String eduYearSerialNo, Date sendDate);
 }

+ 84 - 0
src/main/java/com/xjrsoft/module/schedule/service/impl/CourseReceiveMsgServiceImpl.java

@@ -1,12 +1,32 @@
 package com.xjrsoft.module.schedule.service.impl;
 
+import cn.hutool.core.util.IdUtil;
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.github.yulichang.base.MPJBaseServiceImpl;
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.utils.VoToColumnUtil;
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
+import com.xjrsoft.module.organization.entity.Department;
+import com.xjrsoft.module.organization.entity.Role;
+import com.xjrsoft.module.organization.entity.User;
+import com.xjrsoft.module.organization.entity.UserRoleRelation;
+import com.xjrsoft.module.organization.service.IDepartmentService;
+import com.xjrsoft.module.organization.service.IUserService;
+import com.xjrsoft.module.organization.service.IWeChatService;
 import com.xjrsoft.module.schedule.entity.CourseReceiveMsg;
+import com.xjrsoft.module.schedule.entity.JianyueData;
 import com.xjrsoft.module.schedule.mapper.CourseReceiveMsgMapper;
 import com.xjrsoft.module.schedule.service.ICourseReceiveMsgService;
+import com.xjrsoft.module.schedule.service.IJianyueDataService;
 import lombok.AllArgsConstructor;
+import me.zhyd.oauth.log.Log;
 import org.springframework.stereotype.Service;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.List;
+
 /**
 * @title: 干部部门
 * @Author szs
@@ -16,4 +36,68 @@ import org.springframework.stereotype.Service;
 @Service
 @AllArgsConstructor
 public class CourseReceiveMsgServiceImpl extends MPJBaseServiceImpl<CourseReceiveMsgMapper, CourseReceiveMsg> implements ICourseReceiveMsgService {
+    private final IUserService userService;
+    private final IJianyueDataService jianyueDataService;
+    private final IDepartmentService departmentService;
+    private final IWeChatService weChatService;
+
+
+    @Override
+    public Boolean noticeOverseer(String eduYearSerialNo, Date sendDate) {
+        try {
+            JianyueData jianyueData = jianyueDataService.getOne(
+                    new QueryWrapper<JianyueData>().lambda()
+                            .eq(JianyueData::getSourceId, eduYearSerialNo)
+            );
+            String[] sourceId = jianyueData.getSourceId().split("_");
+            Department department = departmentService.getById(sourceId[0]);
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+
+            String wechatTemplate = "sHsmz7LRj7HLd7GSTS3r2jCLvK-4Wp19iGzEvYK8n_I";
+
+            String roleCode = "KEBIAOGX";
+            List<User> userList = userService.list(
+                    new MPJLambdaWrapper<User>()
+                            .select(User::getId)
+                            .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
+                            .innerJoin(UserRoleRelation.class, UserRoleRelation::getUserId, User::getId)
+                            .innerJoin(Role.class, Role::getId, UserRoleRelation::getRoleId)
+                            .eq(Role::getCode, roleCode)
+            );
+
+            for (User user : userList) {
+                WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+                weChatSendMessageDto.setTemplateId(wechatTemplate);
+                JSONObject paramJson = new JSONObject();
+
+                JSONObject thing8 = new JSONObject();
+                thing8.put("value", "课表更新");
+                paramJson.put("thing8", thing8);
+
+                JSONObject thing2 = new JSONObject();
+                thing2.put("value", department.getName());
+                paramJson.put("thing2", thing2);
+
+                JSONObject thing6 = new JSONObject();
+                thing6.put("value", "教务处");
+                paramJson.put("thing6", thing6);
+
+                JSONObject time3 = new JSONObject();
+                time3.put("value", sdf.format(sendDate));
+                paramJson.put("time3", time3);
+
+                weChatSendMessageDto.setContent(paramJson);
+                weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
+
+                String openId = user.getOpenId();
+                if(openId != null && !"".equals(openId)){
+                    weChatSendMessageDto.setUserId(openId);
+                    weChatService.sendTemplateMessage(weChatSendMessageDto);
+                }
+            }
+        }catch (Exception e){
+            Log.error(e.getMessage(), e);
+        }
+        return true;
+    }
 }

+ 1 - 1
src/main/resources/mapper/xycxedu/ExamSubjectScoreEnterMappper.xml

@@ -21,7 +21,7 @@
             and t3.name like concat('%', #{dto.examPlanName}, '%')
         </if>
         <if test="dto.className != null and dto.className != ''">
-            and t1.class_ids like concat('%', (select id from base_class where name like concat('%', #{dto.className}, '%')), '%')
+            AND (SELECT GROUP_CONCAT(NAME) FROM base_class WHERE t1.class_ids LIKE CONCAT('%', id, '%')) LIKE CONCAT('%', #{dto.className}, '%')
         </if>
         <if test="dto.courseSubjectName != null and dto.courseSubjectName != ''">
             and t4.name like concat('%', #{dto.courseSubjectName}, '%')