|
@@ -681,75 +681,80 @@ public class BaseStudentAssessmentInspectionServiceImpl extends MPJBaseServiceIm
|
|
|
|
|
|
@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());
|
|
|
- }});
|
|
|
+ try {
|
|
|
+ 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.getPersonalStudentUserIds().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) + "...";
|
|
|
+ }
|
|
|
|
|
|
- BaseStudentAssessmentProject project = projectMapper.selectById(inspection.getBaseStudentAssessmentProjectId());
|
|
|
- thing4 = project.getName();
|
|
|
+ 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());
|
|
|
+ }});
|
|
|
|
|
|
- }else if(AssessmentTypeEnum.PERSONAL.getCode().equals(inspection.getAssessmentType())){
|
|
|
- data.put("const3", new JSONObject() {{
|
|
|
- put("value", AssessmentTypeEnum.PERSONAL.getValue());
|
|
|
+ //考核时间
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日");
|
|
|
+ data.put("time2", new JSONObject() {{
|
|
|
+ put("value", sdf.format(inspection.getAssessmentDate()));
|
|
|
}});
|
|
|
- String[] studentUsers = inspection.getPersonalStudentUserIds().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();
|
|
|
+ weChatSendMessageDto.setContent(data);
|
|
|
+ weChatService.sendTemplateMessage(weChatSendMessageDto);
|
|
|
+ return true;
|
|
|
+ }catch (Exception e){
|
|
|
+ Log.error(e.getMessage(), e);
|
|
|
+ return false;
|
|
|
}
|
|
|
- //得分
|
|
|
- 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;
|
|
|
}
|
|
|
|
|
|
@Override
|