|
@@ -1,12 +1,26 @@
|
|
|
package com.xjrsoft.module.room.service.impl;
|
|
|
|
|
|
+import cn.hutool.core.util.IdUtil;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.github.yulichang.base.MPJBaseServiceImpl;
|
|
|
+import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
|
+import com.xjrsoft.module.base.entity.BaseClass;
|
|
|
+import com.xjrsoft.module.base.service.IBaseClassService;
|
|
|
+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.room.entity.WfRoomStayOvernight;
|
|
|
import com.xjrsoft.module.room.mapper.WfRoomStayOvernightMapper;
|
|
|
import com.xjrsoft.module.room.service.IWfRoomStayOvernightService;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.List;
|
|
|
+
|
|
|
/**
|
|
|
* @title: 留校住宿申请
|
|
|
* @Author szs
|
|
@@ -16,4 +30,49 @@ import org.springframework.stereotype.Service;
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
public class WfRoomStayOvernightServiceImpl extends MPJBaseServiceImpl<WfRoomStayOvernightMapper, WfRoomStayOvernight> implements IWfRoomStayOvernightService {
|
|
|
+ private final IUserService userService;
|
|
|
+
|
|
|
+ private final IBaseClassService classService;
|
|
|
+
|
|
|
+ private final IWeChatService weChatService;
|
|
|
+ @Override
|
|
|
+ public Boolean noticeParents(Long id) {
|
|
|
+ WfRoomStayOvernight applicant = 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, applicant.getApplicantUserId())
|
|
|
+ .isNotNull(User::getOpenId)
|
|
|
+ );
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyy年MM月dd日");
|
|
|
+
|
|
|
+ User student = userService.getById(applicant.getApplicantUserId());
|
|
|
+ BaseClass aClass = classService.getById(applicant.getClassName());
|
|
|
+ String wechatTemplate = "pbggflZY985uimp9XQ0pe3-GftuPyF7fG5jCo97_jJU";
|
|
|
+ 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("thing1", new JSONObject() {{
|
|
|
+ put("value", student.getName());
|
|
|
+ }});
|
|
|
+ // 时间
|
|
|
+ data.put("time3", new JSONObject() {{
|
|
|
+ put("value", sdf.format(applicant.getStartTime()));
|
|
|
+ }});
|
|
|
+ //班级
|
|
|
+ data.put("thing2", new JSONObject() {{
|
|
|
+ put("value", aClass.getName());
|
|
|
+ }});
|
|
|
+ weChatSendMessageDto.setContent(data);
|
|
|
+ weChatService.sendTemplateMessage(weChatSendMessageDto);
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
}
|