From b3176719f4e73bd5ea67ac6b6835d74fd607e102 Mon Sep 17 00:00:00 2001
From: yaozc2021 <yaozc@yhzhg.cn>
Date: Mon, 21 Apr 2025 03:00:11 +0000
Subject: [PATCH] Merge branch 'wcd-2411-update' of http://192.168.1.110:5678/r/pms-upgrade into wcd
---
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java | 18 ++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskUserServiceImpl.java | 89 +++++----
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java | 39 ++--
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java | 122 ++++++------
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java | 63 ++++++
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java | 4
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/impl/MeetingRoomReservationServiceImpl.java | 130 ++++++-------
eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ContractMethod.java | 44 ++--
8 files changed, 289 insertions(+), 220 deletions(-)
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/impl/MeetingRoomReservationServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/impl/MeetingRoomReservationServiceImpl.java
index 108bfe5..86ce4fa 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/impl/MeetingRoomReservationServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/conferenceRoom/service/impl/MeetingRoomReservationServiceImpl.java
@@ -1,50 +1,40 @@
/*
-* Copyright 2019-2020 Zheng Jie
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package me.zhengjie.modules.conferenceRoom.service.impl;
import me.zhengjie.exception.BadRequestException;
-import me.zhengjie.modules.assetManagement.domain.AssetManagement;
-import me.zhengjie.modules.assetManagement.domain.AssetUseManagement;
-import me.zhengjie.modules.attendance.domain.AttendanceGoOut;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoom;
import me.zhengjie.modules.conferenceRoom.domain.MeetingRoomReservation;
import me.zhengjie.modules.conferenceRoom.repository.MeetingRoomRepository;
-import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomDto;
import me.zhengjie.modules.constant.Constant;
-import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
-import me.zhengjie.modules.system.domain.CustomerResources;
+import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.UserRepository;
-import me.zhengjie.utils.ValidationUtil;
-import me.zhengjie.utils.FileUtil;
+import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.conferenceRoom.repository.MeetingRoomReservationRepository;
import me.zhengjie.modules.conferenceRoom.service.MeetingRoomReservationService;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationDto;
import me.zhengjie.modules.conferenceRoom.service.dto.MeetingRoomReservationQueryCriteria;
import me.zhengjie.modules.conferenceRoom.service.mapstruct.MeetingRoomReservationMapper;
-import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
-import me.zhengjie.utils.PageUtil;
-import me.zhengjie.utils.QueryHelp;
-import me.zhengjie.utils.SecurityUtils;
import java.text.SimpleDateFormat;
import java.util.*;
@@ -53,11 +43,11 @@
import java.util.function.Function;
/**
-* @website https://eladmin.vip
-* @description 服务实现
-* @author wcd
-* @date 2023-02-09
-**/
+ * @author wcd
+ * @website https://eladmin.vip
+ * @description 服务实现
+ * @date 2023-02-09
+ **/
@Service
@RequiredArgsConstructor
public class MeetingRoomReservationServiceImpl implements MeetingRoomReservationService {
@@ -65,14 +55,14 @@
private final MeetingRoomReservationRepository meetingRoomReservationRepository;
private final MeetingRoomReservationMapper meetingRoomReservationMapper;
private final MeetingRoomRepository meetingRoomRepository;
- private final OpaiDingTalkService opaiDingTalkService;
+ private final WeComServiceImpl weComService;
private final UserRepository userRepository;
@Override
- public Map<String,Object> queryAll(MeetingRoomReservationQueryCriteria criteria, Pageable pageable){
- Page<MeetingRoomReservation> page = meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+ public Map<String, Object> queryAll(MeetingRoomReservationQueryCriteria criteria, Pageable pageable) {
+ Page<MeetingRoomReservation> page = meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
//将实体转换为Dto(重写)
- Function<MeetingRoomReservation, MeetingRoomReservationDto> func = new Function<MeetingRoomReservation, MeetingRoomReservationDto>(){
+ Function<MeetingRoomReservation, MeetingRoomReservationDto> func = new Function<MeetingRoomReservation, MeetingRoomReservationDto>() {
@Override
public MeetingRoomReservationDto apply(MeetingRoomReservation meetingRoomReservation) {
// 将实体类转换成DTO
@@ -87,15 +77,15 @@
}
@Override
- public List<MeetingRoomReservationDto> queryAll(MeetingRoomReservationQueryCriteria criteria){
- return meetingRoomReservationMapper.toDto(meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+ public List<MeetingRoomReservationDto> queryAll(MeetingRoomReservationQueryCriteria criteria) {
+ return meetingRoomReservationMapper.toDto(meetingRoomReservationRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public MeetingRoomReservationDto findById(Long id) {
MeetingRoomReservation meetingRoomReservation = meetingRoomReservationRepository.findById(id).orElseGet(MeetingRoomReservation::new);
- ValidationUtil.isNull(meetingRoomReservation.getId(),"MeetingRoomReservation","id",id);
+ ValidationUtil.isNull(meetingRoomReservation.getId(), "MeetingRoomReservation", "id", id);
return meetingRoomReservationMapper.toDto(meetingRoomReservation);
}
@@ -106,15 +96,15 @@
String startTime = df.format(resources.getStartTime());
String endTime = df.format(resources.getEndTime());
//验证约时间是否冲突
- List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTime(startTime,endTime,resources.getMeetingId());
- if(meetingRoomReservations.size() > 0){
+ List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTime(startTime, endTime, resources.getMeetingId());
+ if (meetingRoomReservations.size() > 0) {
MeetingRoomReservation errorMeetingRoomReservation = meetingRoomReservations.get(0);
SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
throw new BadRequestException("预约时间冲突," + errorFormat.format(errorMeetingRoomReservation.getStartTime()) + "至" + errorFormat.format(errorMeetingRoomReservation.getEndTime())
+ "已经存在会议室预约,请调整时间");
- }else{
- //调用钉钉公共方法
- setDingding(resources);
+ } else {
+ // 发送通知
+ sendNotice(resources);
}
return meetingRoomReservationMapper.toDto(meetingRoomReservationRepository.save(resources));
}
@@ -123,7 +113,7 @@
@Transactional(rollbackFor = Exception.class)
public void update(MeetingRoomReservation resources) throws Exception {
MeetingRoomReservation meetingRoomReservation = meetingRoomReservationRepository.findById(resources.getId()).orElseGet(MeetingRoomReservation::new);
- ValidationUtil.isNull( meetingRoomReservation.getId(),"MeetingRoomReservation","id",resources.getId());
+ ValidationUtil.isNull(meetingRoomReservation.getId(), "MeetingRoomReservation", "id", resources.getId());
meetingRoomReservation.copy(resources);
SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String startTime = df.format(resources.getStartTime());
@@ -132,48 +122,52 @@
Set<Long> ids = new HashSet<>();
ids.add(meetingRoomReservation.getId());
//验证时间是否冲突
- List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTimeEdit(startTime,endTime, resources.getMeetingId(), ids);
- if(meetingRoomReservations.size() > 0){
+ List<MeetingRoomReservation> meetingRoomReservations = meetingRoomReservationRepository.checkReservationTimeEdit(startTime, endTime, resources.getMeetingId(), ids);
+ if (meetingRoomReservations.size() > 0) {
MeetingRoomReservation errorMeetingRoomReservation = meetingRoomReservations.get(0);
SimpleDateFormat errorFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
throw new BadRequestException("预约时间冲突," + errorFormat.format(errorMeetingRoomReservation.getStartTime()) + "至" + errorFormat.format(errorMeetingRoomReservation.getEndTime())
+ "已经存在会议室预约,请调整时间");
- }else{
- setDingding(resources);
+ } else {
+ // 发送通知
+ sendNotice(resources);
}
meetingRoomReservationRepository.save(meetingRoomReservation);
}
/**
- * 发送钉钉公共方法
+ * 向其他应用发送通知公共方法
+ *
* @param resources
- * @return
- * @throws Exception
*/
- public void setDingding(MeetingRoomReservation resources) throws Exception {
- // 获取存储用户钉钉号
- List<String> dingDingList = new ArrayList<>();
+ public void sendNotice(MeetingRoomReservation resources) {
+ // 获取存储用户企微ID
+ List<String> weComList = new ArrayList<>();
// 查询用户
List<User> userList = userRepository.findAll();
- for(User user : userList){
+ for (User user : userList) {
Role role = user.getRoles().iterator().next();
- // 获取项目组长级以上的用户的钉钉id
- if(Long.valueOf(role.getLevel()) <= Constant.ROLE_LEVEL_LEADER){
- if(ObjectUtils.isNotEmpty(user.getDingding())){
- dingDingList.add(user.getDingding());
+ // 获取项目组长级以上的用户的企微ID
+ if (Long.valueOf(role.getLevel()) <= Constant.ROLE_LEVEL_LEADER) {
+ if (StringUtils.isNotBlank(user.getWeComId())) {
+ weComList.add(user.getWeComId());
}
}
}
// 查询会议室
MeetingRoom meetingRoom = meetingRoomRepository.findById(resources.getMeetingId()).orElseGet(MeetingRoom::new);
- // 发送内容至钉钉
- opaiDingTalkService.sendNotice(dingDingList, "会议室预约提示", "### 会议室预约提示 \n >" +
- " \n 会议主题:" + resources.getMeetingTheme() +
- " \n 预订者:" + SecurityUtils.getCurrentUsername() +
- " \n 会议室:" + meetingRoom.getConferenceRoomName() +
- " \n 开始时间: " + resources.getStartTime().toString().substring(0,19) +
- " \n 结束时间: " + resources.getEndTime().toString().substring(0,19) +
- " \n 会议室预约有变更,请登录PMS系统查看。", "card");
+ // 发送内容至企微
+ weComService.sendNotice(weComList, "会议室预约提示", String.format("<div class=\"normal\">会议主题:%s</div>" +
+ "<div class=\"normal\">预订者:%s</div>" +
+ "<div class=\"normal\">会议室:%s</div>" +
+ "<div class=\"normal\">开始时间:%s</div>" +
+ "<div class=\"normal\">结束时间:%s</div>" +
+ "<div class=\"highlight\">会议室预约有变更,请登录PMS系统查看。</div>",
+ resources.getMeetingTheme(),
+ SecurityUtils.getCurrentUsername(),
+ meetingRoom.getConferenceRoomName(),
+ resources.getStartTime().toString().substring(0, 19),
+ resources.getEndTime().toString().substring(0, 19)), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
}
@Override
@@ -189,7 +183,7 @@
for (MeetingRoomReservationDto meetingRoomReservation : all) {
// 查询会议室
MeetingRoom meetingRoom = meetingRoomRepository.findById(meetingRoomReservation.getMeetingId()).orElseGet(MeetingRoom::new);
- Map<String,Object> map = new LinkedHashMap<>();
+ Map<String, Object> map = new LinkedHashMap<>();
map.put("会议室", meetingRoom.getConferenceRoomName());
map.put("会议主题", meetingRoomReservation.getMeetingTheme());
map.put("开始时间", meetingRoomReservation.getStartTime());
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
index 181b04b..6fdc0e7 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/constant/Constant.java
@@ -381,4 +381,22 @@
// 申请审核站点
public static final String APPROVAL_SITE_TYPE = "approval_site_type";
+
+ // 企微消息类型:文本
+ public static final String WECOM_MESSAGE_TYPE_TEXT = "text";
+ // 企微消息类型:图片
+ public static final String WECOM_MESSAGE_TYPE_IMAGE = "image";
+ // 企微消息类型:语言
+ public static final String WECOM_MESSAGE_TYPE_VOICE = "voice";
+ // 企微消息类型:视频
+ public static final String WECOM_MESSAGE_TYPE_VIDEO = "video";
+ // 企微消息类型:文件
+ public static final String WECOM_MESSAGE_TYPE_FILE = "file";
+ // 企微消息类型:文本卡片
+ public static final String WECOM_MESSAGE_TYPE_TEXTCARD = "textcard";
+
+ // 企微消息:跳转链接
+ public static final String WECOM_MESSAGE_URL = "http://pms-upgrade.yhzhg.cn/";
+ // 企微消息:按钮文字(最多4个字,超出自动截断)
+ public static final String WECOM_MESSAGE_BTNTXT = "前往查看";
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
index 63e2e7c..04f5fcb 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/service/impl/WeComServiceImpl.java
@@ -4,6 +4,7 @@
import lombok.RequiredArgsConstructor;
import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpService;
+import me.chanjar.weixin.cp.bean.message.WxCpMessage;
import me.chanjar.weixin.cp.bean.oa.WxCpCheckinData;
import me.zhengjie.modules.attendance.domain.*;
import me.zhengjie.modules.attendance.repository.*;
@@ -262,10 +263,10 @@
*/
@Transactional(rollbackFor = Exception.class)
public void getWeComAttendanceListOfNight(String attendDate, List attUser) throws Exception {
- // 获取企业微信Token
- wxCpService.getAccessToken();
-
try {
+ // 获取企业微信Token
+ wxCpService.getAccessToken();
+
// 获取参数日期类
Calendar calAttendDate = Calendar.getInstance();
// 日期格式化
@@ -375,6 +376,7 @@
/**
* 中午12点30或凌晨02:30执行定时任务
+ *
* @throws Exception
*/
public void getWeComAttendanceListOfNoonOrNight(String attendDate, List attUser) throws Exception {
@@ -421,7 +423,6 @@
}
return attendance;
}
-
/**
* 请假优先于出差优先于外出
@@ -822,4 +823,58 @@
}
return null;
}
+
+ /**
+ * 发送企微应用消息
+ *
+ * @param userWeComIdList 接收消息用户企微ID
+ * @param content 消息内容
+ * @param type 消息类型
+ */
+ public void sendNotice(List<String> userWeComIdList, String title, String content, String type) {
+ if (userWeComIdList.size() > 0) {
+ try {
+ // 获取企业微信Token
+ wxCpService.getAccessToken();
+
+ // 编辑消息
+ WxCpMessage wxCpMessage = new WxCpMessage();
+ wxCpMessage.setToUser(userWeComIdList.stream().collect(Collectors.joining("|")));
+ if (type.equals(Constant.WECOM_MESSAGE_TYPE_TEXT)) {
+ wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXT);
+ wxCpMessage.setContent(content);
+ } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_IMAGE)) {
+ wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_IMAGE);
+ wxCpMessage.setMediaId(content);
+ } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_VOICE)) {
+ wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_VOICE);
+ wxCpMessage.setMediaId(content);
+ } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_VIDEO)) {
+ wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_VIDEO);
+ wxCpMessage.setMediaId(content);
+ wxCpMessage.setTitle(title);
+ } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_FILE)) {
+ wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_FILE);
+ wxCpMessage.setMediaId(content);
+ } else if (type.equals(Constant.WECOM_MESSAGE_TYPE_TEXTCARD)) {
+ wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
+ wxCpMessage.setTitle(title);
+ wxCpMessage.setDescription(content);
+ wxCpMessage.setUrl(Constant.WECOM_MESSAGE_URL);
+ wxCpMessage.setBtnTxt(Constant.WECOM_MESSAGE_BTNTXT);
+ } else {
+ wxCpMessage.setMsgType(Constant.WECOM_MESSAGE_TYPE_TEXT);
+ wxCpMessage.setContent(content);
+ }
+ wxCpMessage.setSafe("0");
+ wxCpMessage.setEnableDuplicateCheck(false);
+ wxCpMessage.setDuplicateCheckInterval(600);
+
+ // 发送消息
+ wxCpService.getMessageService().send(wxCpMessage);
+ } catch (WxErrorException wxErrorException) {
+ wxErrorException.printStackTrace();
+ }
+ }
+ }
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ContractMethod.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ContractMethod.java
index c5ff0d8..42154ee 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ContractMethod.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ContractMethod.java
@@ -1,10 +1,9 @@
package me.zhengjie.modules.quartz.task;
-import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.constant.Constant;
-import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.Role;
import me.zhengjie.modules.system.domain.SysConfigProportion;
import me.zhengjie.modules.system.domain.SysUserContract;
@@ -12,21 +11,18 @@
import me.zhengjie.modules.system.repository.SysConfigProportionRepository;
import me.zhengjie.modules.system.repository.SysUserContractRepository;
import me.zhengjie.modules.system.repository.UserRepository;
-import org.springframework.scheduling.annotation.Async;
+import me.zhengjie.utils.StringUtils;
import org.springframework.stereotype.Service;
-import org.springframework.util.ObjectUtils;
-import java.sql.Timestamp;
-import java.text.SimpleDateFormat;
import java.time.*;
import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
-import java.util.Calendar;
import java.util.Date;
import java.util.List;
/**
* 合同是否到期提醒
+ *
* @author 魏传栋
* @date 2023-01-10
*/
@@ -38,23 +34,23 @@
private final SysConfigProportionRepository sysConfigProportionRepository;
private final SysUserContractRepository sysUserContractRepository;
private final UserRepository userRepository;
- private final OpaiDingTalkService opaiDingTalkService;
+ private final WeComServiceImpl weComService;
// 合同到期提醒
public void contractRemind() throws Exception {
// 今天日期
Date today = new Date();
- // 钉钉Id
- List<String> dingDingList = new ArrayList<>();
+ // 用户企微ID
+ List<String> weComList = new ArrayList<>();
// 查询用户
List<User> userList = userRepository.findAll();
- for(User user : userList){
+ for (User user : userList) {
// 获取用户角色
Role role = user.getRoles().iterator().next();
// 高级别
- if(Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_SUPER) || Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_GENERAL)){
- if(ObjectUtil.isNotEmpty(user.getDingding())){
- dingDingList.add(user.getDingding());
+ if (Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_SUPER) || Long.valueOf(role.getLevel()).equals(Constant.ROLE_LEVEL_GENERAL)) {
+ if (StringUtils.isNotBlank(user.getWeComId())) {
+ weComList.add(user.getWeComId());
}
}
}
@@ -63,9 +59,9 @@
// 查询合同
List<SysUserContract> sysUserContractList = sysUserContractRepository.findAll();
- for(SysUserContract sysUserContract : sysUserContractList){
+ for (SysUserContract sysUserContract : sysUserContractList) {
// 当合同结束时间大于今天
- if(sysUserContract.getContractEndTime().compareTo(today) > 0){
+ if (sysUserContract.getContractEndTime().compareTo(today) > 0) {
// 查询合同即将到期的员工
User user1 = userRepository.findById(sysUserContract.getUserId()).orElseGet(User::new);
// date转LocalDateTime
@@ -73,18 +69,20 @@
ZoneId zoneId = ZoneId.systemDefault();
LocalDateTime todayLocalDateTime = instant.atZone(zoneId).toLocalDateTime();
// 今天到合同结束时间的差值
- Long chronoUnit = ChronoUnit.DAYS.between(todayLocalDateTime.toLocalDate(), sysUserContract.getContractEndTime().toLocalDateTime().toLocalDate());
+ Long chronoUnit = ChronoUnit.DAYS.between(todayLocalDateTime.toLocalDate(), sysUserContract.getContractEndTime().toLocalDateTime().toLocalDate());
Integer count = 0;
for (Integer i = 0; i <= chronoUnit; i++) {
count++;
}
// 相差天数等于配置表的数值时给高级别用户发钉钉信息
- if(Double.valueOf(count).equals(sysConfigProportion.getProportion())){
- opaiDingTalkService.sendNotice(dingDingList, "合同将到期提醒", "### 合同将到期提示 \n >" +
- " \n 所属员工:" + user1.getNickName() +
- " \n 合同名称: " + sysUserContract.getContractName() +
- " \n 合同到期时间: " + sysUserContract.getContractEndTime().toString().substring(0,10) +
- " \n 所属员工合同即将到期,请登录PMS系统查看。", "card");
+ if (Double.valueOf(count).equals(sysConfigProportion.getProportion())) {
+ weComService.sendNotice(weComList, "合同将到期提醒", String.format("<div class=\"normal\">所属员工:%s</div>" +
+ "<div class=\"normal\">合同名称:%s</div>" +
+ "<div class=\"normal\">合同到期时间:%s</div>" +
+ "<div class=\"highlight\">所属员工合同即将到期,请登录PMS系统查看。</div>",
+ user1.getNickName(),
+ sysUserContract.getContractName(),
+ sysUserContract.getContractEndTime().toString().substring(0, 10)), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
}
}
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java
index ac20ed4..120f28d 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/quartz/task/ResourceReminderMethod.java
@@ -1,26 +1,23 @@
package me.zhengjie.modules.quartz.task;
-import cn.hutool.core.util.ObjectUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.constant.Constant;
-import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.*;
import me.zhengjie.modules.system.repository.*;
+import me.zhengjie.utils.StringUtils;
import org.springframework.stereotype.Service;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
-import java.time.Instant;
-import java.time.LocalDateTime;
-import java.time.ZoneId;
-import java.time.temporal.ChronoUnit;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
/**
* 客户资源管理提醒(延时)
+ *
* @author 魏传栋
* @date 2023-01-10
*/
@@ -30,12 +27,13 @@
public class ResourceReminderMethod {
private final UserRepository userRepository;
- private final OpaiDingTalkService opaiDingTalkService;
+ private final WeComServiceImpl weComService;
private final CustomerResourcesRepository customerResourcesRepository;
private final CustomerResourcesUserRepository customerResourcesUserRepository;
/**
* 客户资源管理提醒
+ *
* @throws Exception
*/
public void resourceReminder() throws Exception {
@@ -44,23 +42,26 @@
String nowTime = sdf.format(new Date());
// 查询客户资源管理表
List<CustomerResources> customerResourcesList = customerResourcesRepository.findAll();
- for(CustomerResources customerResources : customerResourcesList){
+ for (CustomerResources customerResources : customerResourcesList) {
// 表中的提醒时间与当前的时间一致,发送钉钉消息
- if(customerResources.getOpeningTime() != null && customerResources.getOpeningTime().compareTo(Timestamp.valueOf(nowTime)) == 0){
- // 钉钉List
- List<String> dingDingList = new ArrayList<>();
+ if (customerResources.getOpeningTime() != null && customerResources.getOpeningTime().compareTo(Timestamp.valueOf(nowTime)) == 0) {
+ // 企微ID
+ List<String> weComList = new ArrayList<>();
// 查询中间表
List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(customerResources.getId());
- for(int i = 0; i < customerResourcesUserList.size(); i++){
+ for (CustomerResourcesUser customerResourcesUser : customerResourcesUserList) {
// 查询用户
- User user = userRepository.findById(customerResourcesUserList.get(i).getUserId()).orElseGet(User::new);
- dingDingList.add(user.getDingding());
+ User user = userRepository.findById(customerResourcesUser.getUserId()).orElseGet(User::new);
+ if (StringUtils.isNotBlank(user.getWeComId())) {
+ weComList.add(user.getWeComId());
+ }
}
- // 发送信息至被提醒人钉钉
- opaiDingTalkService.sendNotice(dingDingList, "客户资源管理提示", "### 客户资源管理提示 \n >" +
- " \n 标题:" + customerResources.getTitle() +
- " \n 分类: " + customerResources.getClassification() +
- " \n 新增客户资源,请登录PMS系统查看。", "card");
+ // 发送信息至被提醒人企微
+ weComService.sendNotice(weComList, "客户资源管理提示", String.format("<div class=\"normal\">标题:%s</div>" +
+ "<div class=\"normal\">分类:%s</div>" +
+ "<div class=\"highlight\">新增客户资源,请登录PMS系统查看。</div>",
+ customerResources.getTitle(),
+ customerResources.getClassification()), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
}
}
}
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
index fc054f4..6987186 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/system/service/impl/CustomerResourcesServiceImpl.java
@@ -1,31 +1,30 @@
/*
-* Copyright 2019-2020 Zheng Jie
-*
-* Licensed under the Apache License, Version 2.0 (the "License");
-* you may not use this file except in compliance with the License.
-* You may obtain a copy of the License at
-*
-* http://www.apache.org/licenses/LICENSE-2.0
-*
-* Unless required by applicable law or agreed to in writing, software
-* distributed under the License is distributed on an "AS IS" BASIS,
-* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-* See the License for the specific language governing permissions and
-* limitations under the License.
-*/
+ * Copyright 2019-2020 Zheng Jie
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package me.zhengjie.modules.system.service.impl;
import me.zhengjie.modules.business.service.BusinessPlanService;
import me.zhengjie.modules.business.service.dto.BusinessPlanDto;
import me.zhengjie.modules.constant.Constant;
-import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.domain.CustomerResources;
import me.zhengjie.modules.system.domain.CustomerResourcesUser;
import me.zhengjie.modules.system.domain.User;
import me.zhengjie.modules.system.repository.CustomerResourcesUserRepository;
import me.zhengjie.modules.system.repository.UserRepository;
-import me.zhengjie.utils.ValidationUtil;
-import me.zhengjie.utils.FileUtil;
+import me.zhengjie.utils.*;
import lombok.RequiredArgsConstructor;
import me.zhengjie.modules.system.repository.CustomerResourcesRepository;
import me.zhengjie.modules.system.service.CustomerResourcesService;
@@ -37,8 +36,6 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
-import me.zhengjie.utils.PageUtil;
-import me.zhengjie.utils.QueryHelp;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
@@ -48,11 +45,11 @@
import javax.servlet.http.HttpServletResponse;
/**
-* @website https://eladmin.vip
-* @description 服务实现
-* @author wcd
-* @date 2023-02-02
-**/
+ * @author wcd
+ * @website https://eladmin.vip
+ * @description 服务实现
+ * @date 2023-02-02
+ **/
@Service
@Transactional
@RequiredArgsConstructor
@@ -61,15 +58,15 @@
private final CustomerResourcesRepository customerResourcesRepository;
private final CustomerResourcesMapper customerResourcesMapper;
private final UserRepository userRepository;
- private final OpaiDingTalkService opaiDingTalkService;
+ private final WeComServiceImpl weComService;
private final CustomerResourcesUserRepository customerResourcesUserRepository;
private final BusinessPlanService businessPlanService;
@Override
- public Map<String,Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable){
- Page<CustomerResources> page = customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder),pageable);
+ public Map<String, Object> queryAll(CustomerResourcesQueryCriteria criteria, Pageable pageable) {
+ Page<CustomerResources> page = customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
// 将实体类转换为DTO(重写)
- Function<CustomerResources, CustomerResourcesDto> func = new Function<CustomerResources, CustomerResourcesDto>(){
+ Function<CustomerResources, CustomerResourcesDto> func = new Function<CustomerResources, CustomerResourcesDto>() {
@Override
public CustomerResourcesDto apply(CustomerResources t) {
// 将实体类转换成DTO
@@ -87,15 +84,15 @@
}
@Override
- public List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria){
- return customerResourcesMapper.toDto(customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root,criteria,criteriaBuilder)));
+ public List<CustomerResourcesDto> queryAll(CustomerResourcesQueryCriteria criteria) {
+ return customerResourcesMapper.toDto(customerResourcesRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder)));
}
@Override
@Transactional
public CustomerResourcesDto findById(Long id) {
CustomerResources customerResources = customerResourcesRepository.findById(id).orElseGet(CustomerResources::new);
- ValidationUtil.isNull(customerResources.getId(),"CustomerResources","id",id);
+ ValidationUtil.isNull(customerResources.getId(), "CustomerResources", "id", id);
return customerResourcesMapper.toDto(customerResources);
}
@@ -103,15 +100,15 @@
@Transactional(rollbackFor = Exception.class)
public void create(CustomerResources resources) throws Exception {
// 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息
- if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){
- // 调用
- resources = setDingding(resources);
+ if (ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)) {
+ // 发送通知
+ resources = sendNotice(resources);
}
// 保存
customerResourcesRepository.save(resources);
// 中间表添加数据
- if(resources.getRemindPeople().size() != 0){
- for(int i = 0; i < resources.getRemindPeople().size(); i++){
+ if (resources.getRemindPeople().size() != 0) {
+ for (int i = 0; i < resources.getRemindPeople().size(); i++) {
// 中间表添加数据
CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser();
customerResourcesUser.setCustomerResourcesId(resources.getId());
@@ -125,24 +122,24 @@
@Transactional(rollbackFor = Exception.class)
public void update(CustomerResources resources) throws Exception {
CustomerResources customerResources = customerResourcesRepository.findById(resources.getId()).orElseGet(CustomerResources::new);
- ValidationUtil.isNull( customerResources.getId(),"CustomerResources","id",resources.getId());
+ ValidationUtil.isNull(customerResources.getId(), "CustomerResources", "id", resources.getId());
customerResources.copy(resources);
// 提醒时间为空,状态为提醒说明是立即提醒,发送钉钉消息
- if(ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)){
- // 调用
- customerResources = setDingding(customerResources);
- }else if(resources.getRemind().equals(Constant.RESOURCES_TYPE_NOREMIND)){
+ if (ObjectUtils.isEmpty(resources.getOpeningTime()) && resources.getRemind().equals(Constant.RESOURCES_TYPE_REMIND)) {
+ // 发送通知
+ customerResources = sendNotice(customerResources);
+ } else if (resources.getRemind().equals(Constant.RESOURCES_TYPE_NOREMIND)) {
customerResources.setOpeningTime(null);
}
customerResourcesRepository.save(customerResources);
// 删除中间表数据
List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(customerResources.getId());
- for(int i = 0; i < customerResourcesUserList.size(); i++){
+ for (int i = 0; i < customerResourcesUserList.size(); i++) {
customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId());
}
// 中间表添加数据
- if(resources.getRemindPeople().size() != 0){
- for(int i = 0; i < resources.getRemindPeople().size(); i++){
+ if (resources.getRemindPeople().size() != 0) {
+ for (int i = 0; i < resources.getRemindPeople().size(); i++) {
// 中间表添加数据
CustomerResourcesUser customerResourcesUser = new CustomerResourcesUser();
customerResourcesUser.setCustomerResourcesId(resources.getId());
@@ -153,32 +150,32 @@
}
/**
- * 发送钉钉(公共)
+ * 向其他应用发送通知公共方法
+ *
* @param resources
- * @return
- * @throws Exception
*/
- public CustomerResources setDingding(CustomerResources resources) throws Exception {
+ public CustomerResources sendNotice(CustomerResources resources) {
// 获取当前时间
SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String time = sf.format(new Date());
resources.setOpeningTime(Timestamp.valueOf(time));
- // 获取存储用户钉钉号
- List<String> dingDingList = new ArrayList<>();
- if(resources.getRemindPeople().size() != 0){
- for(Long userId : resources.getRemindPeople()){
+ // 获取存储用户企微ID
+ List<String> weComList = new ArrayList<>();
+ if (resources.getRemindPeople().size() != 0) {
+ for (Long userId : resources.getRemindPeople()) {
// 查询用户
User user = userRepository.findById(userId).orElseGet(User::new);
- if(ObjectUtils.isNotEmpty(user.getDingding())){
- dingDingList.add(user.getDingding());
+ if (StringUtils.isNotBlank(user.getWeComId())) {
+ weComList.add(user.getWeComId());
}
}
}
- // 发送内容至钉钉
- opaiDingTalkService.sendNotice(dingDingList, "客户资源管理提示", "### 客户资源管理提示 \n >" +
- " \n 标题:" + resources.getTitle() +
- " \n 分类: " + resources.getClassification() +
- " \n 客户资源有变动,请登录PMS系统查看。", "card");
+ // 发送内容至企微
+ weComService.sendNotice(weComList, "客户资源管理提示", String.format("<div class=\"normal\">标题:%s</div>" +
+ "<div class=\"normal\">分类:%s</div>" +
+ "<div class=\"highlight\">客户资源有变动,请登录PMS系统查看。</div>",
+ resources.getTitle(),
+ resources.getClassification()), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
return resources;
}
@@ -187,7 +184,7 @@
for (Long id : ids) {
// 查询中间表
List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(id);
- for(int i = 0; i < customerResourcesUserList.size(); i++){
+ for (int i = 0; i < customerResourcesUserList.size(); i++) {
customerResourcesUserRepository.deleteByCustomerResourcesId(customerResourcesUserList.get(i).getCustomerResourcesId());
}
customerResourcesRepository.deleteById(id);
@@ -198,7 +195,7 @@
public void download(List<CustomerResourcesDto> all, HttpServletResponse response) throws IOException {
List<Map<String, Object>> list = new ArrayList<>();
for (CustomerResourcesDto customerResources : all) {
- Map<String,Object> map = new LinkedHashMap<>();
+ Map<String, Object> map = new LinkedHashMap<>();
map.put("标题", customerResources.getTitle());
map.put("分类", customerResources.getClassification());
map.put("记录时间", customerResources.getRecordTime());
@@ -216,6 +213,7 @@
/**
* 查询被提醒人
+ *
* @param resources
* @return
*/
@@ -225,7 +223,7 @@
List<CustomerResourcesUser> customerResourcesUserList = customerResourcesUserRepository.findByCustomerResourcesId(resources.getId());
// 用户信息
List<User> userList = new ArrayList<>();
- for(int i = 0; i < customerResourcesUserList.size(); i++){
+ for (int i = 0; i < customerResourcesUserList.size(); i++) {
// 查询用户表
User user = userRepository.findById(customerResourcesUserList.get(i).getUserId()).orElseGet(User::new);
userList.add(user);
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskUserServiceImpl.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskUserServiceImpl.java
index ef89085..aef237b 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskUserServiceImpl.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/task/service/impl/TaskUserServiceImpl.java
@@ -20,7 +20,6 @@
import java.math.RoundingMode;
import java.net.URLEncoder;
import java.text.DecimalFormat;
-import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.*;
import java.time.temporal.ChronoUnit;
@@ -30,21 +29,16 @@
import javax.servlet.http.HttpServletResponse;
-import cn.hutool.core.bean.BeanUtil;
-import cn.hutool.core.bean.copier.CopyOptions;
import me.zhengjie.exception.BadRequestException;
import me.zhengjie.modules.project.domain.Project;
import me.zhengjie.modules.project.repository.ProjectRepository;
-import me.zhengjie.modules.quartz.service.OpaiDingTalkService;
+import me.zhengjie.modules.quartz.service.impl.WeComServiceImpl;
import me.zhengjie.modules.system.repository.DictDetailRepository;
-import me.zhengjie.modules.system.repository.SysUserLevelWageRepository;
import me.zhengjie.modules.task.domain.*;
-import me.zhengjie.modules.task.repository.TaskRepository;
import me.zhengjie.modules.task.service.dto.*;
import me.zhengjie.modules.treatment.domain.UserLevelWage;
import me.zhengjie.modules.treatment.repository.UserLevelWageRepository;
-import me.zhengjie.utils.FileUtil;
-import me.zhengjie.utils.SecurityUtils;
+import me.zhengjie.utils.*;
import org.bson.types.ObjectId;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.cache.annotation.CacheEvict;
@@ -66,11 +60,7 @@
import me.zhengjie.modules.system.repository.UserRepository;
import me.zhengjie.modules.system.service.UserService;
import me.zhengjie.modules.system.service.dto.UserDto;
-import me.zhengjie.modules.task.repository.TaskUserRepository;
import me.zhengjie.modules.task.service.TaskUserService;
-import me.zhengjie.modules.task.service.mapstruct.TaskUserMapper;
-import me.zhengjie.utils.PageUtil;
-import me.zhengjie.utils.ValidationUtil;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddressList;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
@@ -91,7 +81,7 @@
private final UserService userService;
private final MongoTemplate mongoTemplate;
private final UserLevelWageRepository userLevelWageRepository;
- private final OpaiDingTalkService opaiDingTalkService;
+ private final WeComServiceImpl weComService;
private final ProjectRepository projectRepository;
private final DictDetailRepository dictDetailRepository;
@@ -463,17 +453,22 @@
// }
mongoTemplate.save(taskUserMongo);
if (taskGenerate.getUserIds() != null) {
- //发送钉钉给审批人
- List<String> sendList = new ArrayList<>();
- //查询所属用户信息
+ // 发送给审批人企微
+ List<String> weComList = new ArrayList<>();
+ // 查询所属用户信息
User user = userRepository.findById(taskGenerate.getUserIds()).orElseGet(User::new);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- sendList.add(user.getDingding());
- opaiDingTalkService.sendNotice(sendList, "任务变更提醒", "### 任务创建提示 \n" +
- " \n 项目:" + project.getName() +
- " \n 任务:" + taskMongos.get(0).getName() + " > " + taskUserMongo.getName() +
- " \n 任务区间:" + sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate()) +
- " \n 任务创建成功,请登录PMS系统查看。", "card");
+ if (StringUtils.isNotBlank(user.getWeComId())) {
+ weComList.add(user.getWeComId());
+ weComService.sendNotice(weComList, "任务变更提醒", String.format("<div class=\"gray\">任务创建提示</div>" +
+ "<div class=\"normal\">项目:%s</div>" +
+ "<div class=\"normal\">任务:%s</div>" +
+ "<div class=\"normal\">任务区间:%s</div>" +
+ "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
+ project.getName(),
+ taskMongos.get(0).getName() + " > " + taskUserMongo.getName(),
+ sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
+ }
}
}
}
@@ -966,7 +961,7 @@
// taskUserMongoDto.setPerformanceHours(Double.valueOf(format));
// taskUserMongo.setPerformanceHours(Double.valueOf(format));
// } else {
- taskUserMongoDto.setPerformanceHours(taskUserMongo.getTaskHours());
+ taskUserMongoDto.setPerformanceHours(taskUserMongo.getTaskHours());
// }
// mongoTemplate.save(taskUserMongo);
@@ -1156,18 +1151,23 @@
mongoTemplate.save(resources);
if (resources.getUserId() != null) {
- //发送钉钉给审批人
- List<String> sendList = new ArrayList<>();
- //查询所属用户信息
+ // 发送给审批人企微
+ List<String> weComList = new ArrayList<>();
+ // 查询所属用户信息
User user = userRepository.findById(resources.getUserId()).orElseGet(User::new);
Project project = projectRepository.findById(resources.getTask().getProjectId()).orElseGet(Project::new);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- sendList.add(user.getDingding());
- opaiDingTalkService.sendNotice(sendList, "任务变更提醒", "### 任务创建提示 \n" +
- " \n 项目:" + project.getName() +
- " \n 任务:" + resources.getTask().getName() + " > " + resources.getName() +
- " \n 任务区间:" + sdf.format(resources.getTaskStartDate()) + "~" + sdf.format(resources.getTaskEndDate()) +
- " \n 任务创建成功,请登录PMS系统查看。", "card");
+ if (StringUtils.isNotBlank(user.getWeComId())) {
+ weComList.add(user.getWeComId());
+ weComService.sendNotice(weComList, "任务变更提醒", String.format("<div class=\"gray\">任务创建提示</div>" +
+ "<div class=\"normal\">项目:%s</div>" +
+ "<div class=\"normal\">任务:%s</div>" +
+ "<div class=\"normal\">任务区间:%s</div>" +
+ "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
+ project.getName(),
+ resources.getTask().getName() + " > " + resources.getName(),
+ sdf.format(resources.getTaskStartDate()) + "~" + sdf.format(resources.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
+ }
}
}
@@ -1241,18 +1241,23 @@
// " \n 当前任务有新的变更,请登录PMS系统查看。", "card");
if (resources.getUserId() != null) {
- //发送钉钉给审批人
- List<String> sendList = new ArrayList<>();
- //查询所属用户信息
+ // 发送给审批人企微
+ List<String> weComList = new ArrayList<>();
+ // 查询所属用户信息
User user = userRepository.findById(resources.getUserId()).orElseGet(User::new);
Project project = projectRepository.findById(resources.getProjectId()).orElseGet(Project::new);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- sendList.add(user.getDingding());
- opaiDingTalkService.sendNotice(sendList, "任务变更提醒", "### 任务创建提示 \n" +
- " \n 项目:" + project.getName() +
- " \n 任务:" + taskUserMongo.getTask().getName() + " > " + taskUserMongo.getName() +
- " \n 任务区间:" + sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate()) +
- " \n 任务创建成功,请登录PMS系统查看。", "card");
+ if (StringUtils.isNotBlank(user.getWeComId())) {
+ weComList.add(user.getWeComId());
+ weComService.sendNotice(weComList, "任务变更提醒", String.format("<div class=\"gray\">任务创建提示</div>" +
+ "<div class=\"normal\">项目:%s</div>" +
+ "<div class=\"normal\">任务:%s</div>" +
+ "<div class=\"normal\">任务区间:%s</div>" +
+ "<div class=\"highlight\">任务创建成功,请登录PMS系统查看。</div>",
+ project.getName(),
+ taskUserMongo.getTask().getName() + " > " + taskUserMongo.getName(),
+ sdf.format(taskUserMongo.getTaskStartDate()) + "~" + sdf.format(taskUserMongo.getTaskEndDate())), Constant.WECOM_MESSAGE_TYPE_TEXTCARD);
+ }
}
}
@@ -1291,7 +1296,7 @@
String projectName = projectRepository.findById(taskMongo.getProjectId()).orElseGet(Project::new).getName();
String userNickName = taskUser.getUserNickName();
String taskStatus = taskUser.getTaskStatus() != null ? dictDetailRepository.findByDictNameAndValue(Constant.TASK_STATUS, taskUser.getTaskStatus()).getLabel() : "";
- Map<String,Object> map = new LinkedHashMap<>();
+ Map<String, Object> map = new LinkedHashMap<>();
map.put("项目名称", projectName);
map.put("任务名称", taskName);
map.put("任务分配", taskUserName);
diff --git a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
index e67bd40..1603193 100644
--- a/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
+++ b/eladmin-master/eladmin-system/src/main/java/me/zhengjie/modules/temp/Temp.java
@@ -49,7 +49,7 @@
return new ResponseEntity<>("", HttpStatus.OK);
}
- @AnonymousGetMapping(value = "/wechat/approval/back")
+ @AnonymousGetMapping(value = "/wechat/approval/backUrl")
@Log("企业微信验证回调URL")
@ApiOperation("企业微信验证回调URL")
public void approvalBack(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
@@ -57,7 +57,7 @@
wechatSendHistoryService.approvalBack(msgSignature, timestamp, nonce, echostr, response);
}
- @AnonymousPostMapping(value = "/wechat/approval/back")
+ @AnonymousPostMapping(value = "/wechat/approval/backUrl")
@Log("处理企业微信审批回调事件")
@ApiOperation("处理企业微信审批回调事件")
public ResponseEntity<Object> handleApprovalCallback(@RequestParam(value = "msg_signature") String msgSignature, @RequestParam(value = "timestamp") String timestamp,
--
Gitblit v1.9.3