|
@@ -5,6 +5,7 @@ import cn.hutool.extra.spring.SpringUtil;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
|
|
|
+import com.xjrsoft.common.utils.VoToColumnUtil;
|
|
import com.xjrsoft.common.utils.WeChatUtil;
|
|
import com.xjrsoft.common.utils.WeChatUtil;
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
import com.xjrsoft.config.CommonPropertiesConfig;
|
|
import com.xjrsoft.module.attendance.entity.AttendanceMessageSet;
|
|
import com.xjrsoft.module.attendance.entity.AttendanceMessageSet;
|
|
@@ -23,8 +24,11 @@ import com.xjrsoft.module.outint.entity.TeacherOutInRecord;
|
|
import com.xjrsoft.module.outint.service.IStudentOutInRecordService;
|
|
import com.xjrsoft.module.outint.service.IStudentOutInRecordService;
|
|
import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
|
|
import com.xjrsoft.module.outint.service.ITeacherOutInRecordService;
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
import com.xjrsoft.module.student.entity.BaseStudent;
|
|
|
|
+import com.xjrsoft.module.system.entity.WechatMessageLog;
|
|
|
|
+import com.xjrsoft.module.system.service.IWechatMessageLogService;
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
import com.xjrsoft.module.teacher.entity.BaseTeacher;
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
import com.xjrsoft.module.teacher.entity.XjrUser;
|
|
|
|
+import com.yomahub.liteflow.util.JsonUtil;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
@@ -43,7 +47,7 @@ import java.util.Map;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
/**
|
|
- * 考勤消息通知
|
|
|
|
|
|
+ * 考勤消息通知,给领导推送每个时段的考勤情况
|
|
* @author dzx
|
|
* @author dzx
|
|
* @date 2024年6月7日
|
|
* @date 2024年6月7日
|
|
*/
|
|
*/
|
|
@@ -77,6 +81,9 @@ public class AttendanceMessageTask {
|
|
@Autowired
|
|
@Autowired
|
|
private WeChatUtil weChatUtil;
|
|
private WeChatUtil weChatUtil;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private IWechatMessageLogService wechatMessageLogService;
|
|
|
|
+
|
|
@Scheduled(cron = "0 */15 * * * ?")
|
|
@Scheduled(cron = "0 */15 * * * ?")
|
|
public void RefreshConnectionPool() {
|
|
public void RefreshConnectionPool() {
|
|
String active = SpringUtil.getActiveProfile();
|
|
String active = SpringUtil.getActiveProfile();
|
|
@@ -84,12 +91,16 @@ public class AttendanceMessageTask {
|
|
log.info("非正式环境,无法执行数据推送");
|
|
log.info("非正式环境,无法执行数据推送");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ doExecute();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void doExecute(){
|
|
LocalDateTime now = LocalDateTime.now();
|
|
LocalDateTime now = LocalDateTime.now();
|
|
HolidayDate holidayDate = holidayDateService.getOne(
|
|
HolidayDate holidayDate = holidayDateService.getOne(
|
|
- new QueryWrapper<HolidayDate>().lambda()
|
|
|
|
- .eq(HolidayDate::getDate, now.toLocalDate())
|
|
|
|
|
|
+ new QueryWrapper<HolidayDate>().lambda()
|
|
|
|
+ .eq(HolidayDate::getDate, now.toLocalDate())
|
|
);
|
|
);
|
|
- if(holidayDate.getWay() != null && holidayDate.getWay() != 0){
|
|
|
|
|
|
+ if(holidayDate != null && holidayDate.getWay() != null && holidayDate.getWay() != 0){
|
|
log.info("非工作日,不需要提醒");
|
|
log.info("非工作日,不需要提醒");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -97,9 +108,23 @@ public class AttendanceMessageTask {
|
|
List<AttendanceRuleDetails> ruleDetails = ruleCategoryService.getTodayRules();
|
|
List<AttendanceRuleDetails> ruleDetails = ruleCategoryService.getTodayRules();
|
|
//获取最近的时间
|
|
//获取最近的时间
|
|
LocalDateTime recentlyTime = getRecentlyTime(ruleDetails, now);
|
|
LocalDateTime recentlyTime = getRecentlyTime(ruleDetails, now);
|
|
|
|
+ String wechatTemplate = weChatUtil.getAttendanceMessageTemplate();
|
|
|
|
+ WechatMessageLog log = wechatMessageLogService.getOne(
|
|
|
|
+ new QueryWrapper<WechatMessageLog>().lambda()
|
|
|
|
+ .select(WechatMessageLog.class, x -> VoToColumnUtil.fieldsToColumns(WechatMessageLog.class).contains(x.getProperty()))
|
|
|
|
+ .eq(WechatMessageLog::getSendTime, recentlyTime)
|
|
|
|
+ .eq(WechatMessageLog::getTemplateId, wechatTemplate)
|
|
|
|
+ );
|
|
|
|
+ if(log != null){//已经推送过,不再进行推送
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ WechatMessageLog messageLog = new WechatMessageLog();
|
|
|
|
+ messageLog.setTemplateId(wechatTemplate);
|
|
|
|
+ messageLog.setSendTime(recentlyTime);
|
|
|
|
|
|
List<AttendanceMessageSet> list = messageSetService.list(
|
|
List<AttendanceMessageSet> list = messageSetService.list(
|
|
- new QueryWrapper<AttendanceMessageSet>().lambda()
|
|
|
|
|
|
+ new QueryWrapper<AttendanceMessageSet>().lambda()
|
|
);
|
|
);
|
|
//判断是上午还是下午
|
|
//判断是上午还是下午
|
|
Integer timePeriod = null;
|
|
Integer timePeriod = null;
|
|
@@ -118,6 +143,8 @@ public class AttendanceMessageTask {
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
String format = recentlyTime.format(formatter);
|
|
String format = recentlyTime.format(formatter);
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
for (AttendanceMessageSet messageSet : list) {
|
|
for (AttendanceMessageSet messageSet : list) {
|
|
if(!messageSet.getTimePeriod().contains(timePeriod + "")){
|
|
if(!messageSet.getTimePeriod().contains(timePeriod + "")){
|
|
continue;
|
|
continue;
|
|
@@ -125,6 +152,8 @@ public class AttendanceMessageTask {
|
|
//查询需要通知的人
|
|
//查询需要通知的人
|
|
List<XjrUser> userList = userService.list(
|
|
List<XjrUser> userList = userService.list(
|
|
new MPJLambdaWrapper<XjrUser>()
|
|
new MPJLambdaWrapper<XjrUser>()
|
|
|
|
+ .select(XjrUser::getId)
|
|
|
|
+ .select(XjrUser.class, x -> VoToColumnUtil.fieldsToColumns(XjrUser.class).contains(x.getProperty()))
|
|
.leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
|
|
.leftJoin(UserRoleRelation.class, UserRoleRelation::getUserId, XjrUser::getId)
|
|
.leftJoin(AttendanceMessageUserRelation.class, AttendanceMessageUserRelation::getUserId, XjrUser::getId)
|
|
.leftJoin(AttendanceMessageUserRelation.class, AttendanceMessageUserRelation::getUserId, XjrUser::getId)
|
|
.eq(UserRoleRelation::getRoleId, messageSet.getRoleType())
|
|
.eq(UserRoleRelation::getRoleId, messageSet.getRoleType())
|
|
@@ -137,14 +166,14 @@ public class AttendanceMessageTask {
|
|
if(messageSet.getRoleType() != null && messageSet.getRoleType() == 2){
|
|
if(messageSet.getRoleType() != null && messageSet.getRoleType() == 2){
|
|
//教师总人数
|
|
//教师总人数
|
|
long teacherCout = userService.count(
|
|
long teacherCout = userService.count(
|
|
- new MPJLambdaWrapper<XjrUser>()
|
|
|
|
- .leftJoin(BaseTeacher.class, BaseTeacher::getUserId, XjrUser::getId)
|
|
|
|
|
|
+ new MPJLambdaWrapper<XjrUser>()
|
|
|
|
+ .leftJoin(BaseTeacher.class, BaseTeacher::getUserId, XjrUser::getId)
|
|
);
|
|
);
|
|
//查询进入记录,就是实际到校的人数
|
|
//查询进入记录,就是实际到校的人数
|
|
long outInRecords = teachertOutInRecordService.count(
|
|
long outInRecords = teachertOutInRecordService.count(
|
|
- new MPJLambdaWrapper<TeacherOutInRecord>()
|
|
|
|
- .le(TeacherOutInRecord::getRecordTime, recentlyTime)
|
|
|
|
- .eq(TeacherOutInRecord::getStatus, 1)
|
|
|
|
|
|
+ new MPJLambdaWrapper<TeacherOutInRecord>()
|
|
|
|
+ .le(TeacherOutInRecord::getRecordTime, recentlyTime)
|
|
|
|
+ .eq(TeacherOutInRecord::getStatus, 1)
|
|
);
|
|
);
|
|
|
|
|
|
//计算出勤率
|
|
//计算出勤率
|
|
@@ -154,14 +183,28 @@ public class AttendanceMessageTask {
|
|
}
|
|
}
|
|
|
|
|
|
WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
|
|
WeChatSendMessageDto weChatSendMessageDto = new WeChatSendMessageDto();
|
|
- weChatSendMessageDto.setTemplateId(weChatUtil.getAttendanceMessageTemplate());
|
|
|
|
|
|
+ weChatSendMessageDto.setTemplateId(wechatTemplate);
|
|
JSONObject paramJson = new JSONObject();
|
|
JSONObject paramJson = new JSONObject();
|
|
|
|
|
|
- paramJson.put("thing6", "教职工");
|
|
|
|
- paramJson.put("time11", format);
|
|
|
|
- paramJson.put("const23", timePeriodStr);
|
|
|
|
- paramJson.put("character_string18", teacherCout - outInRecords);
|
|
|
|
- paramJson.put("const3", divide.doubleValue());
|
|
|
|
|
|
+ JSONObject thing6 = new JSONObject();
|
|
|
|
+ thing6.put("value", "教职工");
|
|
|
|
+ paramJson.put("thing6", thing6);
|
|
|
|
+
|
|
|
|
+ JSONObject time11 = new JSONObject();
|
|
|
|
+ time11.put("value", format);
|
|
|
|
+ paramJson.put("time11", time11);
|
|
|
|
+
|
|
|
|
+ JSONObject const23 = new JSONObject();
|
|
|
|
+ const23.put("value", timePeriodStr);
|
|
|
|
+ paramJson.put("const23", const23);
|
|
|
|
+
|
|
|
|
+ JSONObject character_string18 = new JSONObject();
|
|
|
|
+ character_string18.put("value", teacherCout - outInRecords);
|
|
|
|
+ paramJson.put("character_string18", character_string18);
|
|
|
|
+
|
|
|
|
+ JSONObject const3 = new JSONObject();
|
|
|
|
+ const3.put("value", "出勤率 " + (divide.doubleValue() * 100) + "%");
|
|
|
|
+ paramJson.put("const3", const3);
|
|
|
|
|
|
weChatSendMessageDto.setContent(paramJson);
|
|
weChatSendMessageDto.setContent(paramJson);
|
|
weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/teacher/index", commonPropertiesConfig.getDomainApp()));
|
|
weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/teacher/index", commonPropertiesConfig.getDomainApp()));
|
|
@@ -174,14 +217,14 @@ public class AttendanceMessageTask {
|
|
}else if(messageSet.getRoleType() != null && messageSet.getRoleType() == 3){
|
|
}else if(messageSet.getRoleType() != null && messageSet.getRoleType() == 3){
|
|
//教师总人数
|
|
//教师总人数
|
|
long teacherCout = userService.count(
|
|
long teacherCout = userService.count(
|
|
- new MPJLambdaWrapper<XjrUser>()
|
|
|
|
- .leftJoin(BaseStudent.class, BaseStudent::getUserId, XjrUser::getId)
|
|
|
|
|
|
+ new MPJLambdaWrapper<XjrUser>()
|
|
|
|
+ .leftJoin(BaseStudent.class, BaseStudent::getUserId, XjrUser::getId)
|
|
);
|
|
);
|
|
//查询进入记录,就是实际到校的人数
|
|
//查询进入记录,就是实际到校的人数
|
|
long outInRecords = studentOutInRecordService.count(
|
|
long outInRecords = studentOutInRecordService.count(
|
|
- new MPJLambdaWrapper<StudentOutInRecord>()
|
|
|
|
- .le(StudentOutInRecord::getRecordTime, recentlyTime)
|
|
|
|
- .eq(StudentOutInRecord::getStatus, 1)
|
|
|
|
|
|
+ new MPJLambdaWrapper<StudentOutInRecord>()
|
|
|
|
+ .le(StudentOutInRecord::getRecordTime, recentlyTime)
|
|
|
|
+ .eq(StudentOutInRecord::getStatus, 1)
|
|
);
|
|
);
|
|
|
|
|
|
//计算出勤率
|
|
//计算出勤率
|
|
@@ -195,11 +238,25 @@ public class AttendanceMessageTask {
|
|
weChatSendMessageDto.setTemplateId(weChatUtil.getAttendanceMessageTemplate());
|
|
weChatSendMessageDto.setTemplateId(weChatUtil.getAttendanceMessageTemplate());
|
|
JSONObject paramJson = new JSONObject();
|
|
JSONObject paramJson = new JSONObject();
|
|
|
|
|
|
- paramJson.put("thing6", "学生");
|
|
|
|
- paramJson.put("time11", format);
|
|
|
|
- paramJson.put("const23", timePeriodStr);
|
|
|
|
- paramJson.put("character_string18", teacherCout - outInRecords);
|
|
|
|
- paramJson.put("const3", divide.doubleValue());
|
|
|
|
|
|
+ JSONObject thing6 = new JSONObject();
|
|
|
|
+ thing6.put("value", "教职工");
|
|
|
|
+ paramJson.put("thing6", thing6);
|
|
|
|
+
|
|
|
|
+ JSONObject time11 = new JSONObject();
|
|
|
|
+ time11.put("value", format);
|
|
|
|
+ paramJson.put("time11", time11);
|
|
|
|
+
|
|
|
|
+ JSONObject const23 = new JSONObject();
|
|
|
|
+ const23.put("value", timePeriodStr);
|
|
|
|
+ paramJson.put("const23", const23);
|
|
|
|
+
|
|
|
|
+ JSONObject character_string18 = new JSONObject();
|
|
|
|
+ character_string18.put("value", teacherCout - outInRecords);
|
|
|
|
+ paramJson.put("character_string18", character_string18);
|
|
|
|
+
|
|
|
|
+ JSONObject const3 = new JSONObject();
|
|
|
|
+ const3.put("value", "出勤率 " + (divide.doubleValue() * 100) + "%");
|
|
|
|
+ paramJson.put("const3", const3);
|
|
|
|
|
|
weChatSendMessageDto.setContent(paramJson);
|
|
weChatSendMessageDto.setContent(paramJson);
|
|
weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/class/index", commonPropertiesConfig.getDomainApp()));
|
|
weChatSendMessageDto.setUrl(StrUtil.format("{}pages/attendance/class/index", commonPropertiesConfig.getDomainApp()));
|
|
@@ -211,13 +268,13 @@ public class AttendanceMessageTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ wechatMessageLogService.save(messageLog);
|
|
}
|
|
}
|
|
|
|
|
|
LocalDateTime getRecentlyTime(List<AttendanceRuleDetails> ruleDetails, LocalDateTime now){
|
|
LocalDateTime getRecentlyTime(List<AttendanceRuleDetails> ruleDetails, LocalDateTime now){
|
|
List<LocalDateTime> result = new ArrayList<>();
|
|
List<LocalDateTime> result = new ArrayList<>();
|
|
for (AttendanceRuleDetails ruleDetail : ruleDetails) {
|
|
for (AttendanceRuleDetails ruleDetail : ruleDetails) {
|
|
- if(ruleDetail.getIsAllowInOutSchool() != null && ruleDetail.getIsAllowInOutSchool() != 1
|
|
|
|
|
|
+ if(ruleDetail.getIsAllowInOutSchool() != null && ruleDetail.getIsAllowInOutSchool() == 1
|
|
&& ruleDetail.getIsAttendance() != null && ruleDetail.getIsAttendance() == 1){
|
|
&& ruleDetail.getIsAttendance() != null && ruleDetail.getIsAttendance() == 1){
|
|
if(ruleDetail.getAmStartTime() != null){
|
|
if(ruleDetail.getAmStartTime() != null){
|
|
LocalDateTime amStartTime = now.with(ruleDetail.getAmStartTime());
|
|
LocalDateTime amStartTime = now.with(ruleDetail.getAmStartTime());
|