|
|
@@ -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;
|
|
|
+ }
|
|
|
}
|