소스 검색

班级考核发起后通知班主

dzx 2 달 전
부모
커밋
35e4ea0bd2

+ 30 - 0
src/main/java/com/xjrsoft/common/enums/AssessmentTypeEnum.java

@@ -0,0 +1,30 @@
+package com.xjrsoft.common.enums;
+
+/**
+ * @author dzx
+ * @date 2024年9月25日
+ * 考核对象(class:班级 personal:个人)
+ */
+public enum AssessmentTypeEnum {
+
+
+    CLASS("class", "班级考核"),
+
+    PERSONAL("personal", "个人考核");
+
+    final String code;
+    final String value;
+
+    public String getCode() {
+        return this.code;
+    }
+
+    public String getValue() {
+        return this.value;
+    }
+
+    AssessmentTypeEnum(final String code, final String message) {
+        this.code = code;
+        this.value = message;
+    }
+}

+ 5 - 2
src/main/java/com/xjrsoft/module/liteflow/node/StudentAssessmentInspectionNode.java

@@ -14,7 +14,7 @@ import java.util.Map;
 @Component("student_assessment_inspection_node")
 public class StudentAssessmentInspectionNode extends NodeComponent {
     @Autowired
-    private IBaseStudentAssessmentInspectionService baseStudentAssessmentInspectionService;
+    private IBaseStudentAssessmentInspectionService inspectionService;
 
     @Override
     public void process() throws Exception {
@@ -24,7 +24,10 @@ public class StudentAssessmentInspectionNode extends NodeComponent {
         Long formId = Convert.toLong(value);
         if (formId != null) {
             // 数据处理
-            baseStudentAssessmentInspectionService.dataHandle(formId);
+            inspectionService.dataHandle(formId);
+
+            //通知班主
+            inspectionService.noticeTeacher(formId);
         }
     }
 }

+ 7 - 0
src/main/java/com/xjrsoft/module/student/service/IBaseStudentAssessmentInspectionService.java

@@ -61,4 +61,11 @@ public interface IBaseStudentAssessmentInspectionService extends MPJBaseService<
     IPage<CalssQuantitativeAssessmentPageVo> getCalssQuantitativeAssessmentPage(Page<CalssQuantitativeAssessmentPageDto> page, CalssQuantitativeAssessmentPageDto dto);
 
     Boolean dataHandle(Long id);
+
+    /**
+     * 通知班主任
+     * @param id
+     * @return
+     */
+    Boolean noticeTeacher(Long id);
 }

+ 93 - 2
src/main/java/com/xjrsoft/module/student/service/impl/BaseStudentAssessmentInspectionServiceImpl.java

@@ -1,10 +1,12 @@
 package com.xjrsoft.module.student.service.impl;
 
 import cn.dev33.satoken.stp.StpUtil;
+import cn.hutool.core.util.IdUtil;
 import com.alibaba.excel.EasyExcel;
 import com.alibaba.excel.ExcelWriter;
 import com.alibaba.excel.support.ExcelTypeEnum;
 import com.alibaba.excel.write.metadata.WriteSheet;
+import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
@@ -13,12 +15,17 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.github.yulichang.base.MPJBaseServiceImpl;
 import com.github.yulichang.toolkit.MPJWrappers;
 import com.github.yulichang.wrapper.MPJLambdaWrapper;
+import com.xjrsoft.common.enums.AssessmentTypeEnum;
 import com.xjrsoft.common.enums.ScoreTypeEnum;
 import com.xjrsoft.common.model.result.RT;
 import com.xjrsoft.common.utils.VoToColumnUtil;
 import com.xjrsoft.common.utils.excel.ExcelMergeUtil;
 import com.xjrsoft.module.base.entity.BaseClass;
 import com.xjrsoft.module.base.mapper.BaseClassMapper;
+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 com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionMobilePageDto;
 import com.xjrsoft.module.student.dto.BaseStudentAssessmentInspectionPageDto;
 import com.xjrsoft.module.student.dto.CalssQuantitativeAssessmentPageDto;
@@ -28,11 +35,13 @@ import com.xjrsoft.module.student.entity.BaseClassMajorSet;
 import com.xjrsoft.module.student.entity.BaseStudentAssessmentCategory;
 import com.xjrsoft.module.student.entity.BaseStudentAssessmentClassRelation;
 import com.xjrsoft.module.student.entity.BaseStudentAssessmentInspection;
+import com.xjrsoft.module.student.entity.BaseStudentAssessmentProject;
 import com.xjrsoft.module.student.entity.BaseStudentAssessmentStudentRelation;
 import com.xjrsoft.module.student.entity.BaseStudentSchoolRoll;
 import com.xjrsoft.module.student.mapper.BaseStudentAssessmentCategoryMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentAssessmentClassRelationMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentAssessmentInspectionMapper;
+import com.xjrsoft.module.student.mapper.BaseStudentAssessmentProjectMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentAssessmentStudentRelationMapper;
 import com.xjrsoft.module.student.mapper.BaseStudentSchoolRollMapper;
 import com.xjrsoft.module.student.service.IBaseStudentAssessmentInspectionService;
@@ -54,6 +63,7 @@ import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
 import java.io.ByteArrayOutputStream;
+import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.time.temporal.TemporalAdjusters;
 import java.util.ArrayList;
@@ -62,6 +72,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
 
+import static javax.swing.UIManager.put;
+
 /**
  * @title: 学生班级巡查考核
  * @Author dzx
@@ -74,7 +86,9 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
 
     private final BaseStudentAssessmentInspectionMapper assessmentInspectionMapper;
 
-    private final BaseStudentAssessmentCategoryMapper baseStudentAssessmentCategoryMapper;
+    private final BaseStudentAssessmentCategoryMapper categoryMapper;
+
+    private final BaseStudentAssessmentProjectMapper projectMapper;
 
     private final BaseStudentAssessmentStudentRelationMapper assessmentStudentRelationMapper;
 
@@ -86,6 +100,10 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
 
     private final IFileService fileService;
 
+    private final IUserService userService;
+
+    private final IWeChatService weChatService;
+
     @Override
     public Page<BaseStudentAssessmentInspectionPageVo> getPage(Page<BaseStudentAssessmentInspectionPageDto> page, BaseStudentAssessmentInspectionPageDto dto) {
         Page<BaseStudentAssessmentInspectionPageVo> result = assessmentInspectionMapper.getPage(page, dto);
@@ -195,7 +213,7 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
         LambdaQueryWrapper<BaseStudentAssessmentCategory> baseStudentAssessmentCategoryLambdaQueryWrapper = new LambdaQueryWrapper<>();
         baseStudentAssessmentCategoryLambdaQueryWrapper
                 .in(BaseStudentAssessmentCategory::getId, baseStudentAssessmentCategoryIdList);
-        List<BaseStudentAssessmentCategory> baseStudentAssessmentCategorieList = baseStudentAssessmentCategoryMapper.selectList(baseStudentAssessmentCategoryLambdaQueryWrapper);
+        List<BaseStudentAssessmentCategory> baseStudentAssessmentCategorieList = categoryMapper.selectList(baseStudentAssessmentCategoryLambdaQueryWrapper);
 
         //导出子表
         if(baseStudentAssessmentCategorieList.size() > 0){
@@ -524,4 +542,77 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
         }
         return true;
     }
+
+    @Override
+    public Boolean noticeTeacher(Long id) {
+        BaseStudentAssessmentInspection inspection = this.getById(id);
+        String classIds = inspection.getClassIds();
+        BaseClass baseClass = baseClassMapper.selectById(classIds);
+        User user = userService.getById(baseClass.getTeacherId());
+        String wechatTemplate = "Xb21V8au0Ur9puQs4hIDJTl8LP6GTgVOHQtOeie1Oco";
+
+        WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
+        weChatSendMessageDto.setUserId(user.getOpenId());
+        weChatSendMessageDto.setTemplateId(wechatTemplate);
+        weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
+
+        JSONObject data = new JSONObject();
+        String thing4 = "";
+        String thing1 = "无";
+        if(AssessmentTypeEnum.CLASS.getCode().equals(inspection.getAssessmentType())){
+            data.put("const3", new JSONObject() {{
+                put("value", AssessmentTypeEnum.CLASS.getValue());
+            }});
+
+            BaseStudentAssessmentProject project = projectMapper.selectById(inspection.getBaseStudentAssessmentProjectId());
+            thing4 = project.getName();
+
+        }else if(AssessmentTypeEnum.PERSONAL.getCode().equals(inspection.getAssessmentType())){
+            data.put("const3", new JSONObject() {{
+                put("value", AssessmentTypeEnum.PERSONAL.getValue());
+            }});
+            String[] studentUsers = inspection.getStudentUserIds().split(",");
+            List<String> studentIds = new ArrayList<>();
+            for (String studentUser : studentUsers) {
+                studentIds.add(studentUser.trim());
+            }
+            List<User> userList = userService.listByIds(studentIds);
+            for (int i = 0; i < userList.size(); i ++){
+                if(i > 0){
+                    thing1 += ",";
+                }
+                thing1 += userList.get(i).getName();
+            }
+            if(thing1.length() > 20){
+                thing1 = thing1.substring(0, 16) + "...";
+            }
+
+            BaseStudentAssessmentCategory category = categoryMapper.selectById(inspection.getBaseStudentAssessmentCategoryId());
+            thing4 = category.getName();
+        }
+        //得分
+        JSONObject thing4Json = new JSONObject();
+        thing4Json.put("value", thing4);
+        data.put("thing4", thing4Json);
+
+        //学生
+        JSONObject thing1Json = new JSONObject();
+        thing1Json.put("value", thing1);
+        data.put("thing1", thing1Json);
+
+        //得分
+        data.put("character_string5", new JSONObject() {{
+            put("value", inspection.getScore());
+        }});
+
+        //考核时间
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
+        data.put("time2", new JSONObject() {{
+            put("value", sdf.format(inspection.getAssessmentDate()));
+        }});
+
+        weChatSendMessageDto.setContent(data);
+        weChatService.sendTemplateMessage(weChatSendMessageDto);
+        return true;
+    }
 }