|
@@ -11,6 +11,8 @@ import com.jpsoft.smart.modules.common.utils.JwtUtil;
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
import com.jpsoft.smart.modules.common.utils.OSSUtil;
|
|
import com.jpsoft.smart.modules.common.utils.POIUtils;
|
|
import com.jpsoft.smart.modules.common.utils.POIUtils;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
import com.jpsoft.smart.modules.common.utils.WechatMessageUtil;
|
|
|
|
+import com.jpsoft.smart.modules.sys.entity.SysLog;
|
|
|
|
+import com.jpsoft.smart.modules.sys.service.SysLogService;
|
|
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
import com.sun.corba.se.spi.orbutil.threadpool.Work;
|
|
import io.jsonwebtoken.Jwts;
|
|
import io.jsonwebtoken.Jwts;
|
|
import io.jsonwebtoken.security.Keys;
|
|
import io.jsonwebtoken.security.Keys;
|
|
@@ -33,6 +35,7 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayInputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
import java.io.ByteArrayOutputStream;
|
|
|
|
+import java.net.SocketAddress;
|
|
import java.net.URLEncoder;
|
|
import java.net.URLEncoder;
|
|
import java.security.Key;
|
|
import java.security.Key;
|
|
import java.text.ParseException;
|
|
import java.text.ParseException;
|
|
@@ -87,6 +90,9 @@ public class UnmeasureTemperatureAlarmTask {
|
|
@Autowired
|
|
@Autowired
|
|
private HolidayInfoService holidayInfoService;
|
|
private HolidayInfoService holidayInfoService;
|
|
|
|
|
|
|
|
+ @Autowired
|
|
|
|
+ private SysLogService sysLogService;
|
|
|
|
+
|
|
public int batchUpdate(String companyId,Date startDate,Date endDate) throws Exception {
|
|
public int batchUpdate(String companyId,Date startDate,Date endDate) throws Exception {
|
|
DateTime dt1 = new DateTime(startDate);
|
|
DateTime dt1 = new DateTime(startDate);
|
|
DateTime dt2 = new DateTime(endDate);
|
|
DateTime dt2 = new DateTime(endDate);
|
|
@@ -185,11 +191,23 @@ public class UnmeasureTemperatureAlarmTask {
|
|
return affectCount;
|
|
return affectCount;
|
|
}
|
|
}
|
|
|
|
|
|
- //每5分钟执行一次
|
|
|
|
- @Scheduled(cron="0 0/5 * * * ?")
|
|
|
|
|
|
+ private void writeDbLog(String remark,String companyId){
|
|
|
|
+ SysLog sysLog = new SysLog();
|
|
|
|
+ sysLog.setPointcut("未测体温提醒");
|
|
|
|
+ sysLog.setUrl(companyId);
|
|
|
|
+ sysLog.setRemark(remark);
|
|
|
|
+ sysLog.setCreateTime(new Date());
|
|
|
|
+ sysLogService.insert(sysLog);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ //每5分钟执行一次 fixedDelay:表示上一次任务执行完成后多久再次执行,参数类型为long,单位ms
|
|
|
|
+ @Scheduled(cron="0 0/5 * * * *")
|
|
public void run() {
|
|
public void run() {
|
|
|
|
+ log.warn("测温提醒任务开始");
|
|
|
|
+
|
|
int intervalMinute = 5;
|
|
int intervalMinute = 5;
|
|
|
|
|
|
|
|
+ //查询所有的考勤时段
|
|
List<AlarmConfig> configList = alarmConfigService.list();
|
|
List<AlarmConfig> configList = alarmConfigService.list();
|
|
|
|
|
|
DateTime now = DateTime.now();
|
|
DateTime now = DateTime.now();
|
|
@@ -228,6 +246,11 @@ public class UnmeasureTemperatureAlarmTask {
|
|
//开始时间
|
|
//开始时间
|
|
if (weekdays.indexOf(String.valueOf(weekday)) != -1) {
|
|
if (weekdays.indexOf(String.valueOf(weekday)) != -1) {
|
|
if (now.compareTo(alarmTime)>=0 && now.compareTo(alarmTime.plusMinutes(intervalMinute))<0) {
|
|
if (now.compareTo(alarmTime)>=0 && now.compareTo(alarmTime.plusMinutes(intervalMinute))<0) {
|
|
|
|
+ writeDbLog(String.format("考勤测温提醒:考勤时间:{0},当前时间:{2}",
|
|
|
|
+ alarmTime.toString("yyyy-MM-dd HH:mm:ss"),
|
|
|
|
+ now.toString("yyyy-MM-dd HH:mm:ss")),
|
|
|
|
+ alarmConfig.getCompanyId());
|
|
|
|
+
|
|
//todo 通知个人
|
|
//todo 通知个人
|
|
if(alarmConfig.getNeedMeasureTemperature()){
|
|
if(alarmConfig.getNeedMeasureTemperature()){
|
|
noticePerson(alarmConfig,startTime,endTime);
|
|
noticePerson(alarmConfig,startTime,endTime);
|
|
@@ -244,15 +267,15 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //todo 记录考勤
|
|
|
|
- if (alarmConfig.getClassifier().equals(1)) {
|
|
|
|
- //上班时间前打卡算正常上班
|
|
|
|
|
|
+ //todo 记录考勤 (改在接收门禁数据中执行)
|
|
|
|
+// if (alarmConfig.getClassifier().equals(1)) {
|
|
|
|
+// //上班时间前打卡算正常上班
|
|
// recordAttendance(alarmConfig, startTime.toDate(), attendanceTime.toDate(), WorkAttendance.SUCCESS);
|
|
// recordAttendance(alarmConfig, startTime.toDate(), attendanceTime.toDate(), WorkAttendance.SUCCESS);
|
|
- }
|
|
|
|
- else{
|
|
|
|
- //下班时间前打卡算早退
|
|
|
|
|
|
+// }
|
|
|
|
+// else{
|
|
|
|
+// //下班时间前打卡算早退
|
|
// recordAttendance(alarmConfig, startTime.toDate(), attendanceTime.toDate(), WorkAttendance.LEAVE_EARLY);
|
|
// recordAttendance(alarmConfig, startTime.toDate(), attendanceTime.toDate(), WorkAttendance.LEAVE_EARLY);
|
|
- }
|
|
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
//todo 截止时间已到
|
|
//todo 截止时间已到
|
|
@@ -264,15 +287,15 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- //todo 记录考勤
|
|
|
|
- if (alarmConfig.getClassifier().equals(1)) {
|
|
|
|
- //上班时间后截止时间前打卡算迟到
|
|
|
|
|
|
+ //todo 记录考勤 (改在接收门禁数据中执行)
|
|
|
|
+// if (alarmConfig.getClassifier().equals(1)) {
|
|
|
|
+// //上班时间后截止时间前打卡算迟到
|
|
// recordAttendance(alarmConfig, attendanceTime.toDate(), endTime.toDate(),WorkAttendance.LATE);
|
|
// recordAttendance(alarmConfig, attendanceTime.toDate(), endTime.toDate(),WorkAttendance.LATE);
|
|
- }
|
|
|
|
- else{
|
|
|
|
- //下班时间后截止时间前打卡算正常下班
|
|
|
|
|
|
+// }
|
|
|
|
+// else{
|
|
|
|
+// //下班时间后截止时间前打卡算正常下班
|
|
// recordAttendance(alarmConfig, attendanceTime.toDate(), endTime.toDate(),WorkAttendance.SUCCESS);
|
|
// recordAttendance(alarmConfig, attendanceTime.toDate(), endTime.toDate(),WorkAttendance.SUCCESS);
|
|
- }
|
|
|
|
|
|
+// }
|
|
|
|
|
|
//未在开始截止时间内打卡算旷工
|
|
//未在开始截止时间内打卡算旷工
|
|
recordUnAttendance(alarmConfig,startTime.toDate(),attendanceTime.toDate(),endTime.toDate(),WorkAttendance.MISSING);
|
|
recordUnAttendance(alarmConfig,startTime.toDate(),attendanceTime.toDate(),endTime.toDate(),WorkAttendance.MISSING);
|
|
@@ -283,6 +306,8 @@ public class UnmeasureTemperatureAlarmTask {
|
|
log.error(ex.getMessage(),ex);
|
|
log.error(ex.getMessage(),ex);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ log.warn("测温提醒任务结束");
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -385,11 +410,18 @@ public class UnmeasureTemperatureAlarmTask {
|
|
//todo 查询该单位当前时间段是否有人员未测体温
|
|
//todo 查询该单位当前时间段是否有人员未测体温
|
|
List<PersonInfo> unmeasuredList = personDeviceLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
|
|
List<PersonInfo> unmeasuredList = personDeviceLogService.queryUnAttendanceList(companyCode,startTime.toDate(),endTime.toDate());
|
|
|
|
|
|
|
|
+ writeDbLog(String.format(
|
|
|
|
+ "查询考勤时段:{0}~{1},未考勤人员数量:{2}",
|
|
|
|
+ startTime.toString("yyyy-MM-dd HH:mm"),
|
|
|
|
+ endTime.toString("yyyy-MM-dd HH:mm"),
|
|
|
|
+ unmeasuredList.size()
|
|
|
|
+ ), alarmConfig.getCompanyId());
|
|
|
|
+
|
|
if (unmeasuredList.size()==0){
|
|
if (unmeasuredList.size()==0){
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
- //todo 给未测量人推送微信通知
|
|
|
|
|
|
+ //todo 给未测温人推送微信通知
|
|
for (PersonInfo personInfo : unmeasuredList) {
|
|
for (PersonInfo personInfo : unmeasuredList) {
|
|
if (personInfo.getWechatNoticeEnabled()!=null
|
|
if (personInfo.getWechatNoticeEnabled()!=null
|
|
&& personInfo.getWechatNoticeEnabled()
|
|
&& personInfo.getWechatNoticeEnabled()
|
|
@@ -402,7 +434,7 @@ public class UnmeasureTemperatureAlarmTask {
|
|
// else{
|
|
// else{
|
|
// message += ",请在" + attendanceTime.toString("HH:mm") + "至" + endTime.toString("HH:mm") + "时间内在单位(校园)内任意打卡点打卡及测温!";
|
|
// message += ",请在" + attendanceTime.toString("HH:mm") + "至" + endTime.toString("HH:mm") + "时间内在单位(校园)内任意打卡点打卡及测温!";
|
|
// }
|
|
// }
|
|
- message +=",请抓紧时间在单位(校园)内任意打卡点打卡和测温!";
|
|
|
|
|
|
+ message +=",请抓紧时间在单位内任意打卡点打卡和测温!";
|
|
|
|
|
|
JSONObject sendData = new JSONObject();
|
|
JSONObject sendData = new JSONObject();
|
|
|
|
|
|
@@ -432,6 +464,8 @@ public class UnmeasureTemperatureAlarmTask {
|
|
sendData.put("keyword3", keyword3);
|
|
sendData.put("keyword3", keyword3);
|
|
sendData.put("remark", remark);
|
|
sendData.put("remark", remark);
|
|
|
|
|
|
|
|
+ writeDbLog(String.format("向未测温人:{0}发送测温提醒通知",personInfo.getName()),alarmConfig.getCompanyId());
|
|
|
|
+
|
|
WechatMessageUtil.sendTemplate(sendData, wxConfig.getAppId(),wxConfig.getAppSecret(),remindTmplCode,personInfo.getOpenId(), null);
|
|
WechatMessageUtil.sendTemplate(sendData, wxConfig.getAppId(),wxConfig.getAppSecret(),remindTmplCode,personInfo.getOpenId(), null);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -459,6 +493,7 @@ public class UnmeasureTemperatureAlarmTask {
|
|
//todo 查询该单位的通知人
|
|
//todo 查询该单位的通知人
|
|
List<WarningPusher> pusherList = warningPusherService.findByCompanyId(companyInfo.getId());
|
|
List<WarningPusher> pusherList = warningPusherService.findByCompanyId(companyInfo.getId());
|
|
|
|
|
|
|
|
+
|
|
//todo 给单位相关人员推送通知
|
|
//todo 给单位相关人员推送通知
|
|
for (WarningPusher pusher: pusherList) {
|
|
for (WarningPusher pusher: pusherList) {
|
|
if (StringUtils.isNotEmpty(pusher.getOpenId())
|
|
if (StringUtils.isNotEmpty(pusher.getOpenId())
|
|
@@ -476,6 +511,8 @@ public class UnmeasureTemperatureAlarmTask {
|
|
}
|
|
}
|
|
|
|
|
|
try {
|
|
try {
|
|
|
|
+ writeDbLog(String.format("查询单位:{0},测温统计信息接收人:{1},personId={2}",companyInfo.getName(),pusher.getName(),personId),companyInfo.getId());
|
|
|
|
+
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
String token = JwtUtil.createToken(jwtSecret,String.valueOf(personId),sdf.parse("2030-01-01"));
|
|
String token = JwtUtil.createToken(jwtSecret,String.valueOf(personId),sdf.parse("2030-01-01"));
|