|
@@ -6,18 +6,22 @@ import com.jpsoft.smart.modules.base.service.AlarmConfigService;
|
|
import com.jpsoft.smart.modules.base.service.CompanyInfoService;
|
|
import com.jpsoft.smart.modules.base.service.CompanyInfoService;
|
|
import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
|
|
import com.jpsoft.smart.modules.base.service.PersonDeviceFilterLogService;
|
|
import com.jpsoft.smart.modules.base.service.WarningPusherService;
|
|
import com.jpsoft.smart.modules.base.service.WarningPusherService;
|
|
|
|
+import com.jpsoft.smart.modules.business.entity.WorkAttendance;
|
|
|
|
+import com.jpsoft.smart.modules.business.service.WorkAttendanceService;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
-import com.jpsoft.smart.modules.common.utils.WeixinUtil;
|
|
|
|
|
|
+import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.joda.time.DateTime;
|
|
import org.joda.time.DateTime;
|
|
-import org.joda.time.Minutes;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
import java.text.SimpleDateFormat;
|
|
|
|
+import java.util.Date;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.UUID;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
@Slf4j
|
|
@Slf4j
|
|
@@ -34,6 +38,9 @@ public class UnmeasureTemperatureAlarmTask {
|
|
@Autowired
|
|
@Autowired
|
|
private CompanyInfoService companyInfoService;
|
|
private CompanyInfoService companyInfoService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private WorkAttendanceService workAttendanceService;
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private WxConfig wxConfig;
|
|
private WxConfig wxConfig;
|
|
|
|
|
|
@@ -62,20 +69,49 @@ public class UnmeasureTemperatureAlarmTask {
|
|
try {
|
|
try {
|
|
String weekdays = alarmConfig.getWeekdays();
|
|
String weekdays = alarmConfig.getWeekdays();
|
|
DateTime startTime = new DateTime(sdf.parse(date + " " + alarmConfig.getStartTime()));
|
|
DateTime startTime = new DateTime(sdf.parse(date + " " + alarmConfig.getStartTime()));
|
|
- DateTime endTime = new DateTime(sdf.parse(date + " " + alarmConfig.getAttendanceTime()));
|
|
|
|
|
|
+ DateTime attendanceTime = new DateTime(sdf.parse(date + " " + alarmConfig.getAttendanceTime()));
|
|
|
|
+ DateTime endTime = new DateTime(sdf.parse(date + " " + alarmConfig.getEndTime()));
|
|
|
|
|
|
- DateTime alarmTime = endTime.plusMinutes(-10);
|
|
|
|
|
|
+ DateTime alarmTime = attendanceTime.plusMinutes(-10);
|
|
|
|
|
|
//开始时间
|
|
//开始时间
|
|
if (weekdays.indexOf(String.valueOf(weekday)) != -1) {
|
|
if (weekdays.indexOf(String.valueOf(weekday)) != -1) {
|
|
|
|
+ //todo 考勤时间提前10分钟通知人员
|
|
if (now.compareTo(alarmTime)>=0 && now.compareTo(alarmTime.plusMinutes(intervalMinute))<0) {
|
|
if (now.compareTo(alarmTime)>=0 && now.compareTo(alarmTime.plusMinutes(intervalMinute))<0) {
|
|
//todo 通知个人
|
|
//todo 通知个人
|
|
- noticePerson(alarmConfig,startTime,endTime);
|
|
|
|
|
|
+ noticePerson(alarmConfig,startTime,attendanceTime);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ //todo 考勤时间已到
|
|
|
|
+ if (now.compareTo(attendanceTime)>=0 && now.compareTo(attendanceTime.plusMinutes(intervalMinute))<0) {
|
|
|
|
+ //todo 未测量人通知管理人员
|
|
|
|
+ noticeManager(alarmConfig,startTime,attendanceTime);
|
|
|
|
+
|
|
|
|
+ //todo 记录考勤
|
|
|
|
+ if (alarmConfig.getClassifier().equals(1)) {
|
|
|
|
+ //上班时间前打卡算正常上班
|
|
|
|
+ recordAttendance(alarmConfig, startTime.toDate(), attendanceTime.toDate(), WorkAttendance.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ //下班时间前打卡算早退
|
|
|
|
+ recordAttendance(alarmConfig, startTime.toDate(), attendanceTime.toDate(), WorkAttendance.LEAVE_EARLY);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //todo 截止时间已到
|
|
if (now.compareTo(endTime)>=0 && now.compareTo(endTime.plusMinutes(intervalMinute))<0) {
|
|
if (now.compareTo(endTime)>=0 && now.compareTo(endTime.plusMinutes(intervalMinute))<0) {
|
|
- //todo 通知管理人员
|
|
|
|
- noticeManager(alarmConfig,startTime,endTime);
|
|
|
|
|
|
+ //todo 记录考勤
|
|
|
|
+ if (alarmConfig.getClassifier().equals(1)) {
|
|
|
|
+ //上班时间后截止时间前打卡算迟到
|
|
|
|
+ recordAttendance(alarmConfig, attendanceTime.toDate(), endTime.toDate(),WorkAttendance.LATE);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ //下班时间后截止时间前打卡算正常下班
|
|
|
|
+ recordAttendance(alarmConfig, attendanceTime.toDate(), endTime.toDate(),WorkAttendance.SUCCESS);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //未到开始截止时间内打开算旷工
|
|
|
|
+ recordUnAttendance(alarmConfig,startTime.toDate(),endTime.toDate(),WorkAttendance.MISSING);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -85,7 +121,68 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void noticePerson(AlarmConfig alarmConfig, DateTime startTime, DateTime endTime) {
|
|
|
|
|
|
+ /**
|
|
|
|
+ * 记录未考勤人员
|
|
|
|
+ * @param alarmConfig
|
|
|
|
+ * @param startDate
|
|
|
|
+ * @param endDate
|
|
|
|
+ * @param result
|
|
|
|
+ */
|
|
|
|
+ private void recordUnAttendance(AlarmConfig alarmConfig, Date startDate, Date endDate, String result) {
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(alarmConfig.getCompanyId());
|
|
|
|
+
|
|
|
|
+ String companyCode = companyInfo.getCode();
|
|
|
|
+
|
|
|
|
+ if (alarmConfig.getSubordinate()!=null && alarmConfig.getSubordinate()){
|
|
|
|
+ companyCode += "%";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //todo 查询该单位当前时间段未考勤人员列表
|
|
|
|
+ List<PersonInfo> attendanceList = personDeviceFilterLogService.queryUnAttendanceList(companyCode,startDate,endDate);
|
|
|
|
+
|
|
|
|
+ for (PersonInfo personInfo: attendanceList) {
|
|
|
|
+ WorkAttendance workAttendance = new WorkAttendance();
|
|
|
|
+ workAttendance.setId(UUID.randomUUID().toString());
|
|
|
|
+ workAttendance.setPersonId(personInfo.getId());
|
|
|
|
+ workAttendance.setAlarmConfigId(alarmConfig.getId());
|
|
|
|
+ workAttendance.setCreateTime(new Date());
|
|
|
|
+ workAttendance.setResult(result);
|
|
|
|
+
|
|
|
|
+ workAttendanceService.insert(workAttendance);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 记录考勤
|
|
|
|
+ * @param alarmConfig
|
|
|
|
+ */
|
|
|
|
+ @Async
|
|
|
|
+ public void recordAttendance(AlarmConfig alarmConfig,Date startDate,Date endDate,String result) {
|
|
|
|
+ CompanyInfo companyInfo = companyInfoService.get(alarmConfig.getCompanyId());
|
|
|
|
+
|
|
|
|
+ String companyCode = companyInfo.getCode();
|
|
|
|
+
|
|
|
|
+ if (alarmConfig.getSubordinate()!=null && alarmConfig.getSubordinate()){
|
|
|
|
+ companyCode += "%";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //todo 查询该单位当前时间段考勤人员列表
|
|
|
|
+ List<PersonInfo> unAttendanceList = personDeviceFilterLogService.queryAttendanceList(companyCode,startDate,endDate);
|
|
|
|
+
|
|
|
|
+ for (PersonInfo personInfo: unAttendanceList) {
|
|
|
|
+ WorkAttendance workAttendance = new WorkAttendance();
|
|
|
|
+ workAttendance.setId(UUID.randomUUID().toString());
|
|
|
|
+ workAttendance.setPersonId(personInfo.getId());
|
|
|
|
+ workAttendance.setAlarmConfigId(alarmConfig.getId());
|
|
|
|
+ workAttendance.setCreateTime(new Date());
|
|
|
|
+ workAttendance.setResult(result);
|
|
|
|
+
|
|
|
|
+ workAttendanceService.insert(workAttendance);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Async
|
|
|
|
+ public void noticePerson(AlarmConfig alarmConfig, DateTime startTime, DateTime endTime) {
|
|
CompanyInfo companyInfo = companyInfoService.get(alarmConfig.getCompanyId());
|
|
CompanyInfo companyInfo = companyInfoService.get(alarmConfig.getCompanyId());
|
|
|
|
|
|
String companyCode = companyInfo.getCode();
|
|
String companyCode = companyInfo.getCode();
|
|
@@ -95,7 +192,7 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
|
|
|
|
//todo 查询该单位当前时间段是否有人员未测体温
|
|
//todo 查询该单位当前时间段是否有人员未测体温
|
|
- List<PersonInfo> unmeasuredList = personDeviceFilterLogService.queryUnmeasuredList(companyCode,startTime.toDate(),endTime.toDate());
|
|
|
|
|
|
+ List<PersonInfo> unmeasuredList = personDeviceFilterLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
|
|
|
|
|
|
if (unmeasuredList.size()==0){
|
|
if (unmeasuredList.size()==0){
|
|
return;
|
|
return;
|
|
@@ -114,7 +211,8 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private void noticeManager(AlarmConfig alarmConfig, DateTime startTime, DateTime endTime) {
|
|
|
|
|
|
+ @Async
|
|
|
|
+ public void noticeManager(AlarmConfig alarmConfig, DateTime startTime, DateTime endTime) {
|
|
CompanyInfo companyInfo = companyInfoService.get(alarmConfig.getCompanyId());
|
|
CompanyInfo companyInfo = companyInfoService.get(alarmConfig.getCompanyId());
|
|
|
|
|
|
String companyCode = companyInfo.getCode();
|
|
String companyCode = companyInfo.getCode();
|
|
@@ -124,7 +222,7 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
|
|
|
|
//todo 查询该单位当前时间段是否有人员未测体温
|
|
//todo 查询该单位当前时间段是否有人员未测体温
|
|
- List<PersonInfo> unmeasuredList = personDeviceFilterLogService.queryUnmeasuredList(companyCode,startTime.toDate(),endTime.toDate());
|
|
|
|
|
|
+ List<PersonInfo> unmeasuredList = personDeviceFilterLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
|
|
|
|
|
|
if (unmeasuredList.size()==0){
|
|
if (unmeasuredList.size()==0){
|
|
return;
|
|
return;
|
|
@@ -149,7 +247,8 @@ public class UnmeasureTemperatureAlarmTask {
|
|
|
|
|
|
//todo 给单位相关人员推送通知
|
|
//todo 给单位相关人员推送通知
|
|
for (WarningPusher pusher: pusherList) {
|
|
for (WarningPusher pusher: pusherList) {
|
|
- if (StringUtils.isNotEmpty(pusher.getOpenId())) {
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(pusher.getOpenId())
|
|
|
|
+ && pusher.getMissingNoticeEnabled()!=null && pusher.getMissingNoticeEnabled()) {
|
|
String message = "尊敬的用户:" + pusher.getName()
|
|
String message = "尊敬的用户:" + pusher.getName()
|
|
+ ",当天时段" + startTime.toString("HH:mm") + "至" + endTime.toString("HH:mm")
|
|
+ ",当天时段" + startTime.toString("HH:mm") + "至" + endTime.toString("HH:mm")
|
|
+ ",有" + total + "人未测量体温。名单如下:" + sb.toString();
|
|
+ ",有" + total + "人未测量体温。名单如下:" + sb.toString();
|
|
@@ -161,4 +260,15 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+ Boolean result = null;
|
|
|
|
+
|
|
|
|
+ if (result){
|
|
|
|
+ System.out.println("yes");
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ System.out.println("no");
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|