|
@@ -1,27 +1,35 @@
|
|
|
package com.xjrsoft.module.student.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
import com.google.gson.JsonArray;
|
|
|
import com.google.gson.JsonElement;
|
|
|
import com.google.gson.JsonObject;
|
|
|
import com.google.gson.JsonParser;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
import com.xjrsoft.module.attendance.dto.AttendanceStatisticDto;
|
|
|
import com.xjrsoft.module.hikvision.entity.HikvisionData;
|
|
|
import com.xjrsoft.module.hikvision.mapper.HikvisionDataMapper;
|
|
|
import com.xjrsoft.module.hikvision.util.ApiUtil;
|
|
|
+import com.xjrsoft.module.organization.dto.WeChatSendMessageDto;
|
|
|
+import com.xjrsoft.module.organization.entity.User;
|
|
|
+import com.xjrsoft.module.organization.entity.UserStudent;
|
|
|
+import com.xjrsoft.module.organization.service.IUserService;
|
|
|
+import com.xjrsoft.module.organization.service.IWeChatService;
|
|
|
import com.xjrsoft.module.outint.vo.IdCountVo;
|
|
|
-import com.xjrsoft.module.student.dto.BaseStudentUserPageDto;
|
|
|
import com.xjrsoft.module.student.dto.StudentLeavePageDto;
|
|
|
import com.xjrsoft.module.student.entity.StudentLeave;
|
|
|
import com.xjrsoft.module.student.mapper.StudentLeaveMapper;
|
|
|
import com.xjrsoft.module.student.service.IStudentLeaveService;
|
|
|
-import com.xjrsoft.module.student.vo.BaseStudentUserPageVo;
|
|
|
import com.xjrsoft.module.student.vo.StudentLeavePageVo;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
import java.util.HashMap;
|
|
@@ -39,6 +47,8 @@ import java.util.Map;
|
|
|
public class StudentLeaveServiceImpl extends MPJBaseServiceImpl<StudentLeaveMapper, StudentLeave> implements IStudentLeaveService {
|
|
|
|
|
|
private final HikvisionDataMapper hikvisionDataMapper;
|
|
|
+ private final IUserService userService;
|
|
|
+ private final IWeChatService weChatService;
|
|
|
|
|
|
@Override
|
|
|
public Boolean hikvisionLeave(Long id) {
|
|
@@ -115,6 +125,61 @@ public class StudentLeaveServiceImpl extends MPJBaseServiceImpl<StudentLeaveMapp
|
|
|
return baseMapper.getLeavePage(page, dto);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 流程通过后通知学生家长
|
|
|
+ * @param id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public Boolean noticeParents(Long id) {
|
|
|
+ StudentLeave studentLeave = this.getById(id);
|
|
|
+ List<User> list = userService.list(
|
|
|
+ new MPJLambdaWrapper<User>()
|
|
|
+ .select(User::getId)
|
|
|
+ .select(User.class, x -> VoToColumnUtil.fieldsToColumns(User.class).contains(x.getProperty()))
|
|
|
+ .innerJoin(UserStudent.class, UserStudent::getUserId, User::getId)
|
|
|
+ .eq(UserStudent::getStudentId, studentLeave.getStudentUserId())
|
|
|
+ .isNotNull(User::getOpenId)
|
|
|
+ );
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
|
|
|
+ String endDate = studentLeave.getEndDate().format(formatter);
|
|
|
+ String startDate = studentLeave.getStartDate().format(formatter);
|
|
|
+
|
|
|
+ User student = userService.getById(studentLeave.getStudentUserId());
|
|
|
+ String wechatTemplate = "sHsmz7LRj7HLd7GSTS3r2jCLvK-4Wp19iGzEvYK8n_I";
|
|
|
+ for (User user : list) {
|
|
|
+ WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
|
|
|
+ weChatSendMessageDto.setUserId(user.getOpenId());
|
|
|
+ weChatSendMessageDto.setTemplateId(wechatTemplate);
|
|
|
+ weChatSendMessageDto.setMsgId(IdUtil.getSnowflakeNextId() + "");
|
|
|
+
|
|
|
+ JSONObject data = new JSONObject();
|
|
|
+ // 任务名称
|
|
|
+ data.put("thing8", new JSONObject() {{
|
|
|
+ put("value", "学生请假");
|
|
|
+ }});
|
|
|
+ // 事项名称
|
|
|
+ data.put("thing2", new JSONObject() {{
|
|
|
+ put("value", "请假时间:" + startDate + "~" + endDate);
|
|
|
+ }});
|
|
|
+ // 申请人
|
|
|
+ data.put("thing6", new JSONObject() {{
|
|
|
+ put("value", student.getName());
|
|
|
+ }});
|
|
|
+ // 时间
|
|
|
+ data.put("time3", new JSONObject() {{
|
|
|
+ put("value", sdf.format(studentLeave.getCreateDate()));
|
|
|
+ }});
|
|
|
+ weChatSendMessageDto.setContent(data);
|
|
|
+ weChatService.sendTemplateMessage(weChatSendMessageDto);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
JsonArray selectResource(ApiUtil apiUtil){
|
|
|
String apiPath = "/api/irds/v2/resource/resourcesByParams";
|
|
|
JsonObject jsonObject = new JsonObject();
|