2023-02-16 15:28:15 +08:00
|
|
|
|
package com.zhgd.xmgl.task;
|
|
|
|
|
|
|
2024-03-11 20:22:27 +08:00
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import cn.hutool.core.date.DateTime;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
2024-05-23 17:55:42 +08:00
|
|
|
|
import cn.hutool.core.util.StrUtil;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
2024-05-22 21:57:53 +08:00
|
|
|
|
import com.zhgd.jeecg.common.mybatis.EntityMap;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.entity.Notice;
|
2024-03-11 20:22:27 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.entity.SystemUser;
|
2024-03-25 15:13:09 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.mapper.SystemLogoConfigMapper;
|
2024-03-11 20:22:27 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.mapper.SystemUserMapper;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.basicdata.service.INoticeService;
|
2024-05-22 21:57:53 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.dangerous.entity.HiddenDangerInspectRecord;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.dangerous.service.IHiddenDangerInspectRecordService;
|
2024-04-13 17:35:21 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.project.entity.Project;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.project.entity.ProjectExternalSystemService;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.project.mapper.ProjectExternalSystemServiceMapper;
|
2024-03-11 20:22:27 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.project.mapper.ProjectMapper;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.project.service.IProjectUfaceConfigService;
|
2024-05-22 21:57:53 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.quality.entity.QualityInspectionRecord;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.entity.WorkerAttendance;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.entity.WorkerBlacklist;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.entity.WorkerInfo;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.entity.WorkerMonthAttendanceStatistics;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.mapper.WorkerBlacklistMapper;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.worker.mapper.WorkerCertificateMapper;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.mapper.WorkerInfoMapper;
|
2024-04-13 17:35:21 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.service.IWorkerAttendancePresenceService;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.service.IWorkerAttendanceService;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.service.IWorkerCertificateService;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.worker.service.IWorkerMonthAttendanceStatisticsService;
|
2024-05-09 18:49:41 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.xz.entity.XzCertificateExpireAlarmRecord;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.xz.entity.XzWorkerSafeWatchAlarm;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.entity.XzWorkerSafeWatchConfig;
|
2024-05-22 21:57:53 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.xz.entity.XzWorkerSafeWatchManager;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityInspectTaskItemRecord;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityInspectTaskRecord;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.security.entity.XzSecurityQualityInspectionRecord;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.security.mapper.XzSecurityInspectTaskItemRecordMapper;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.security.mapper.XzSecurityInspectTaskRecordMapper;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.security.service.IXzSecurityQualityInspectionRecordService;
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.xz.service.IXzWorkerSafeWatchAlarmService;
|
|
|
|
|
|
import com.zhgd.xmgl.modules.xz.service.IXzWorkerSafeWatchConfigService;
|
2024-05-22 21:57:53 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.xz.service.IXzWorkerSafeWatchManagerService;
|
2024-05-09 18:49:41 +08:00
|
|
|
|
import com.zhgd.xmgl.modules.xz.service.impl.XzCertificateExpireAlarmRecordServiceImpl;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import com.zhgd.xmgl.util.ElecardUtil;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import net.javacrumbs.shedlock.core.SchedulerLock;
|
2024-05-22 21:57:53 +08:00
|
|
|
|
import org.apache.commons.collections.MapUtils;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.scheduling.annotation.Scheduled;
|
|
|
|
|
|
import org.springframework.stereotype.Component;
|
2024-03-25 15:13:09 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
|
2024-05-22 01:36:11 +08:00
|
|
|
|
import java.util.*;
|
2024-03-11 20:22:27 +08:00
|
|
|
|
import java.util.stream.Collectors;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @program: wisdomSite
|
|
|
|
|
|
* @description: 劳务人员定时任务
|
|
|
|
|
|
* @author: Mr.Peng
|
|
|
|
|
|
* @create: 2021-09-10 17:31
|
|
|
|
|
|
**/
|
2024-01-16 18:36:09 +08:00
|
|
|
|
@Slf4j
|
2023-02-16 15:28:15 +08:00
|
|
|
|
@Component
|
2024-01-16 18:36:09 +08:00
|
|
|
|
@RestController
|
2024-03-25 15:13:09 +08:00
|
|
|
|
@RequestMapping("xmgl/task")
|
2023-02-16 15:28:15 +08:00
|
|
|
|
public class WorkerTask {
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private ProjectExternalSystemServiceMapper projectExternalSystemServiceMapper;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WorkerInfoMapper workerInfoMapper;
|
2024-03-11 20:22:27 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private ProjectMapper projectMapper;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private SystemUserMapper systemUserMapper;
|
2024-03-25 15:13:09 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private SystemLogoConfigMapper systemLogoConfigMapper;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
|
2024-04-13 17:35:21 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IWorkerAttendancePresenceService workerAttendancePresenceService;
|
|
|
|
|
|
|
2023-02-16 15:28:15 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private INoticeService noticeService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IProjectUfaceConfigService projectUfaceConfigService;
|
2024-01-16 18:36:09 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IWorkerCertificateService workerCertificateService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WorkerCertificateMapper workerCertificateMapper;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private WorkerBlacklistMapper workerBlacklistMapper;
|
2023-02-16 15:28:15 +08:00
|
|
|
|
|
2024-04-13 17:35:21 +08:00
|
|
|
|
@Autowired
|
2024-05-09 18:49:41 +08:00
|
|
|
|
private XzCertificateExpireAlarmRecordServiceImpl xzCertificateExpireAlarmRecordService;
|
2024-04-13 17:35:21 +08:00
|
|
|
|
|
2024-05-22 01:36:11 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IXzWorkerSafeWatchConfigService xzWorkerSafeWatchConfigService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IWorkerMonthAttendanceStatisticsService workerMonthAttendanceStatisticsService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IWorkerAttendanceService workerAttendanceService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IXzWorkerSafeWatchAlarmService xzWorkerSafeWatchAlarmService;
|
|
|
|
|
|
|
2024-05-22 21:57:53 +08:00
|
|
|
|
@Autowired
|
|
|
|
|
|
private IXzWorkerSafeWatchManagerService xzWorkerSafeWatchManagerService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private XzSecurityInspectTaskRecordMapper xzSecurityInspectTaskRecordMapper;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private XzSecurityInspectTaskItemRecordMapper xzSecurityInspectTaskItemRecordMapper;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IHiddenDangerInspectRecordService hiddenDangerInspectRecordService;
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
private IXzSecurityQualityInspectionRecordService qualityInspectionRecordService;
|
|
|
|
|
|
|
2023-02-16 15:28:15 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 定时修改用户码状态
|
|
|
|
|
|
*/
|
2024-01-16 18:36:09 +08:00
|
|
|
|
@SchedulerLock(name = "updateWorkerCode", lockAtMostFor = 1000 * 60 * 60, lockAtLeastFor = 1000 * 60 * 5)
|
2023-02-16 15:28:15 +08:00
|
|
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
2024-01-16 18:36:09 +08:00
|
|
|
|
public void updateWorkerCode() {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
log.info("------------------------------健康码同步开始-----------------------------------------");
|
2024-01-16 18:36:09 +08:00
|
|
|
|
try {
|
|
|
|
|
|
List<ProjectExternalSystemService> list = projectExternalSystemServiceMapper.getChangtongCodeSystemList();
|
2024-04-27 17:51:47 +08:00
|
|
|
|
Date now = new Date();
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
|
|
for (ProjectExternalSystemService projectExternalSystemService : list) {
|
2024-04-27 17:51:47 +08:00
|
|
|
|
getWorkerCodeState(projectExternalSystemService, now);
|
2023-02-16 15:28:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-11 20:22:27 +08:00
|
|
|
|
} catch (Exception e) {
|
2024-04-14 21:05:01 +08:00
|
|
|
|
log.error("error:", e);
|
2023-02-16 15:28:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
log.info("------------------------------健康码同步结束-----------------------------------------");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-27 17:51:47 +08:00
|
|
|
|
public void getWorkerCodeState(ProjectExternalSystemService projectExternalSystemService, Date now) {
|
2024-03-11 20:22:27 +08:00
|
|
|
|
try {
|
|
|
|
|
|
List<WorkerInfo> list = workerInfoMapper.selectAllWorkerInfoList(projectExternalSystemService.getProjectSn());
|
|
|
|
|
|
if (list != null && list.size() > 0) {
|
|
|
|
|
|
String token = ElecardUtil.getToken(projectExternalSystemService.getSystemUrl(), projectExternalSystemService.getAppId(), projectExternalSystemService.getAppSecert(),
|
|
|
|
|
|
projectExternalSystemService.getPublicKey(), projectExternalSystemService.getPrivateKey());
|
|
|
|
|
|
if (StringUtils.isNotEmpty(token)) {
|
|
|
|
|
|
int redNum = 0;
|
|
|
|
|
|
int orangeNum = 0;
|
|
|
|
|
|
StringBuilder redWorkerName = new StringBuilder();
|
|
|
|
|
|
StringBuilder orangeWorkerName = new StringBuilder();
|
|
|
|
|
|
for (WorkerInfo workerInfo : list) {
|
|
|
|
|
|
log.info("---------------" + workerInfo.getWorkerName());
|
|
|
|
|
|
String enterStatus = ElecardUtil.getCardInfo(projectExternalSystemService.getSystemUrl(), projectExternalSystemService.getAppId(), projectExternalSystemService.getAppSecert(),
|
|
|
|
|
|
projectExternalSystemService.getPublicKey(), projectExternalSystemService.getPrivateKey(), token, workerInfo.getIdCard());
|
2023-02-16 15:28:15 +08:00
|
|
|
|
//0 :绿色, 1:黄色 ,2:红色
|
|
|
|
|
|
//红黄码需设备取消授权不允许通行
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (StringUtils.isNotEmpty(enterStatus)) {
|
|
|
|
|
|
if ("2".equals(enterStatus)) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
redNum++;
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (redWorkerName.length() > 0) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
redWorkerName.append("、");
|
|
|
|
|
|
}
|
|
|
|
|
|
redWorkerName.append(workerInfo.getWorkerName());
|
|
|
|
|
|
//码状态,0无码,1红,2黄,3绿
|
|
|
|
|
|
workerInfo.setCodeState(1);
|
|
|
|
|
|
workerInfo.setUfaceDevId("0");
|
|
|
|
|
|
projectUfaceConfigService.deleteWorkerInfo(workerInfo);
|
2024-03-11 20:22:27 +08:00
|
|
|
|
} else if ("1".equals(enterStatus)) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
orangeNum++;
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (orangeWorkerName.length() > 0) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
orangeWorkerName.append("、");
|
|
|
|
|
|
}
|
|
|
|
|
|
orangeWorkerName.append(workerInfo.getWorkerName());
|
|
|
|
|
|
workerInfo.setCodeState(2);
|
|
|
|
|
|
workerInfo.setUfaceDevId("0");
|
|
|
|
|
|
projectUfaceConfigService.deleteWorkerInfo(workerInfo);
|
2024-03-11 20:22:27 +08:00
|
|
|
|
} else {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
workerInfo.setCodeState(3);
|
|
|
|
|
|
}
|
|
|
|
|
|
workerInfoMapper.updateById(workerInfo);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (redNum > 0 || orangeNum > 0) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
//String title="今日昌通码核验黄码"+orangeNum+"人,红码"+redNum+"人";
|
2024-03-11 20:22:27 +08:00
|
|
|
|
StringBuilder title = new StringBuilder();
|
2023-02-16 15:28:15 +08:00
|
|
|
|
title.append("今日昌通码核验黄码").append(orangeNum).append("人,");
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (orangeWorkerName.length() > 0) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
title.append("分别为:").append(orangeWorkerName.toString()).append(",");
|
|
|
|
|
|
}
|
|
|
|
|
|
title.append("红码").append(redNum).append("人");
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (redWorkerName.length() > 0) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
title.append("分别为:").append(redWorkerName.toString()).append("。");
|
|
|
|
|
|
}
|
2024-03-11 20:22:27 +08:00
|
|
|
|
StringBuilder title2 = new StringBuilder();
|
|
|
|
|
|
if (orangeWorkerName.length() > 0) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
title2.append("黄码人员:").append(orangeWorkerName.toString()).append(",");
|
|
|
|
|
|
}
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (redWorkerName.length() > 0) {
|
2023-02-16 15:28:15 +08:00
|
|
|
|
title2.append("红码人员:").append(redWorkerName.toString()).append("。");
|
|
|
|
|
|
}
|
|
|
|
|
|
title2.append("已销权");
|
2024-01-16 18:36:09 +08:00
|
|
|
|
noticeService.sendProjectNoicte(projectExternalSystemService.getProjectSn(), "红黄码核验", title.toString(), "17");
|
|
|
|
|
|
noticeService.sendProjectNoicte(projectExternalSystemService.getProjectSn(), "红黄码销权", title2.toString(), "17");
|
2023-02-16 15:28:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-01-16 18:36:09 +08:00
|
|
|
|
} catch (Exception e) {
|
2024-04-14 21:05:01 +08:00
|
|
|
|
log.error("error:", e);
|
2023-02-16 15:28:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-01-16 18:36:09 +08:00
|
|
|
|
/**
|
2024-03-27 14:59:35 +08:00
|
|
|
|
* 劳务人员,截止日期到期的话(包括人员的合同信息、资格证书、保险信息),就自动填充原因,就是证件到期到黑名单中
|
2024-01-16 18:36:09 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@SchedulerLock(name = "addWorkerBlacklist", lockAtMostFor = 1000 * 60 * 60, lockAtLeastFor = 1000 * 60 * 5)
|
|
|
|
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
2024-03-25 15:13:09 +08:00
|
|
|
|
@RequestMapping("/addWorkerBlacklist")
|
2024-01-16 18:36:09 +08:00
|
|
|
|
public void addWorkerBlacklist() {
|
2024-03-27 14:59:35 +08:00
|
|
|
|
log.info("任务开始,劳务人员,截止日期到期的话(包括人员的合同信息、资格证书、保险信息),到黑名单");
|
|
|
|
|
|
//证书过期
|
|
|
|
|
|
List<WorkerInfo> list = workerCertificateMapper.selectExpiredCertificateNotInBlackWorkerList();
|
|
|
|
|
|
addWorkerBlacklist(list, "证件已到期", 1);
|
|
|
|
|
|
|
|
|
|
|
|
//合同过期
|
|
|
|
|
|
List<WorkerInfo> list1 = workerCertificateMapper.selectExpiredContractNotInBlackWorkerList();
|
|
|
|
|
|
addWorkerBlacklist(list1, "合同已到期", 2);
|
|
|
|
|
|
|
|
|
|
|
|
//保险过期
|
|
|
|
|
|
List<WorkerInfo> list2 = workerCertificateMapper.selectExpiredInsuranceNotInBlackWorkerList();
|
|
|
|
|
|
addWorkerBlacklist(list2, "保险已到期", 3);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void addWorkerBlacklist(List<WorkerInfo> list, String addReason, int type) {
|
2024-01-16 18:36:09 +08:00
|
|
|
|
for (WorkerInfo workerInfo : list) {
|
|
|
|
|
|
WorkerBlacklist black = new WorkerBlacklist();
|
|
|
|
|
|
black.setProjectSn(workerInfo.getProjectSn());
|
|
|
|
|
|
black.setWorkerId(workerInfo.getId());
|
|
|
|
|
|
black.setWorkerName(workerInfo.getWorkerName());
|
|
|
|
|
|
black.setIdCard(workerInfo.getIdCard());
|
2024-03-27 14:59:35 +08:00
|
|
|
|
black.setAddReason(addReason);
|
|
|
|
|
|
black.setReason(addReason);
|
2024-01-16 18:36:09 +08:00
|
|
|
|
black.setAddTime(DateUtil.now());
|
|
|
|
|
|
black.setCreateTime(new Date());
|
2024-03-27 14:59:35 +08:00
|
|
|
|
black.setType(type);
|
2024-01-16 18:36:09 +08:00
|
|
|
|
workerBlacklistMapper.insert(black);
|
2023-02-16 15:28:15 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-03-11 20:22:27 +08:00
|
|
|
|
|
|
|
|
|
|
/**
|
2024-03-25 15:13:09 +08:00
|
|
|
|
* 对人员的资质证书到期进行预警,预警后发送消息提示项目管理员账号
|
|
|
|
|
|
* 系统设置:开启后将会在对企业下的各个项目开启人员证书到期预警提示,提前预警时间可以自行设置,监测内容包括人员的合同信息、资格证书、保险信息。
|
2024-03-11 20:22:27 +08:00
|
|
|
|
*/
|
|
|
|
|
|
@SchedulerLock(name = "alarmWorkerBlack", lockAtMostFor = 1000 * 60 * 60, lockAtLeastFor = 1000 * 60 * 5)
|
|
|
|
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
2024-03-25 15:13:09 +08:00
|
|
|
|
@RequestMapping("/alarmWorkerBlack")
|
2024-03-11 20:22:27 +08:00
|
|
|
|
public void alarmWorkerBlack() {
|
2024-03-27 14:59:35 +08:00
|
|
|
|
log.info("任务开始,对人员的合同信息、资格证书、保险信息到期进行预警,预警后发送消息提示项目管理员账号");
|
|
|
|
|
|
//资格证书预警
|
|
|
|
|
|
List<WorkerInfo> list1 = workerCertificateMapper.getAlarmWorkerCertificateWithHeadquarter();
|
|
|
|
|
|
List<WorkerInfo> list2 = workerCertificateMapper.getAlarmWorkerCertificateNotHeadquarter();
|
2024-05-09 18:49:41 +08:00
|
|
|
|
addNotice(CollUtil.addAll(list1, list2), "人员的资质证书即将到期", "20");
|
2024-03-27 14:59:35 +08:00
|
|
|
|
|
|
|
|
|
|
//合同信息预警
|
|
|
|
|
|
List<WorkerInfo> list3 = workerCertificateMapper.getAlarmWorkerContractWithHeadquarter();
|
|
|
|
|
|
List<WorkerInfo> list4 = workerCertificateMapper.getAlarmWorkerContractNotHeadquarter();
|
2024-05-09 18:49:41 +08:00
|
|
|
|
addNotice(CollUtil.addAll(list3, list4), "人员的合同信息即将到期", "21");
|
2024-03-27 14:59:35 +08:00
|
|
|
|
|
|
|
|
|
|
//保险信息预警
|
|
|
|
|
|
List<WorkerInfo> list5 = workerCertificateMapper.getAlarmWorkerInsuranceWithHeadquarter();
|
|
|
|
|
|
List<WorkerInfo> list6 = workerCertificateMapper.getAlarmWorkerInsuranceNotHeadquarter();
|
2024-05-09 18:49:41 +08:00
|
|
|
|
addNotice(CollUtil.addAll(list5, list6), "人员的保险信息即将到期", "22");
|
2024-03-27 14:59:35 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-22 01:36:11 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 对人员未履职情况进行监测,及时反馈预警
|
|
|
|
|
|
*/
|
2024-05-22 21:57:53 +08:00
|
|
|
|
@Scheduled(cron = "0 0/1 * * * ?")
|
2024-05-22 01:36:11 +08:00
|
|
|
|
@RequestMapping("/workerSafeWatchAlarm")
|
|
|
|
|
|
public void workerSafeWatchAlarm() {
|
|
|
|
|
|
log.info("开始执行对人员未履职情况进行监测");
|
2024-05-22 21:57:53 +08:00
|
|
|
|
String [] typeName = {"人员日常考勤", "每个项目自检任务", "一个月内缺勤超过", "一个月内迟到超过"};
|
2024-05-22 01:36:11 +08:00
|
|
|
|
List<Project> projects = projectMapper.selectList(Wrappers.<Project>lambdaQuery().eq(Project::getStatus, 2));
|
|
|
|
|
|
int day = DateUtil.dayOfMonth(new Date());
|
|
|
|
|
|
for (Project project : projects) {
|
|
|
|
|
|
if (project.getEnableWorkerSafeWatch() != null && project.getEnableWorkerSafeWatch() == 1) {
|
|
|
|
|
|
if (StringUtils.isNotBlank(project.getWorkerSafeWatchTime()) &&
|
2024-05-22 21:57:53 +08:00
|
|
|
|
DateUtil.format(new Date(), "HH:mm").equals(
|
|
|
|
|
|
DateUtil.format(DateUtil.parseTime(project.getWorkerSafeWatchTime()), "HH:mm"))) {
|
2024-05-22 01:36:11 +08:00
|
|
|
|
List<XzWorkerSafeWatchConfig> list = xzWorkerSafeWatchConfigService.list(Wrappers.<XzWorkerSafeWatchConfig>lambdaQuery()
|
|
|
|
|
|
.eq(XzWorkerSafeWatchConfig::getProjectSn, project.getProjectSn()));
|
|
|
|
|
|
List<XzWorkerSafeWatchAlarm> alarmList = new ArrayList<>();
|
|
|
|
|
|
List<Notice> noticeList = new ArrayList<>();
|
|
|
|
|
|
for (XzWorkerSafeWatchConfig xzWorkerSafeWatchConfig : list) {
|
|
|
|
|
|
String type = xzWorkerSafeWatchConfig.getType();
|
2024-05-22 21:57:53 +08:00
|
|
|
|
int dayNum = xzWorkerSafeWatchConfig.getDayNum();
|
2024-05-22 01:36:11 +08:00
|
|
|
|
Set<String> personSn = new HashSet<>();
|
|
|
|
|
|
//计算日常考勤规则
|
2024-05-22 21:57:53 +08:00
|
|
|
|
if (type.equals("1")) {
|
2024-05-23 22:31:10 +08:00
|
|
|
|
dayNum = dayNum + 1;
|
|
|
|
|
|
DateTime dateTime = DateUtil.beginOfDay(DateUtil.offsetDay(new Date(), -dayNum));
|
2024-05-22 01:36:11 +08:00
|
|
|
|
Set<String> personSet = workerAttendanceService.list(Wrappers.<WorkerAttendance>lambdaQuery().between(WorkerAttendance::getCreateTime
|
|
|
|
|
|
, dateTime, new Date())).stream().map(w -> w.getPersonSn()).collect(Collectors.toSet());
|
2024-05-22 21:57:53 +08:00
|
|
|
|
Set<String> workerSet = workerInfoMapper.selectList(Wrappers.<WorkerInfo>lambdaQuery().eq(WorkerInfo::getInserviceType, 1)).stream().map(w -> w.getPersonSn()).collect(Collectors.toSet());
|
2024-05-22 01:36:11 +08:00
|
|
|
|
workerSet.removeAll(personSet);
|
2024-05-22 21:57:53 +08:00
|
|
|
|
personSn.addAll(workerSet);
|
2024-05-22 01:36:11 +08:00
|
|
|
|
}
|
2024-05-22 21:57:53 +08:00
|
|
|
|
if (type.equals("2")) {
|
2024-05-23 22:31:10 +08:00
|
|
|
|
dayNum = dayNum + 1;
|
2024-05-22 21:57:53 +08:00
|
|
|
|
List<XzSecurityInspectTaskRecord> xzSecurityInspectTaskRecords = xzSecurityInspectTaskRecordMapper.selectList(Wrappers.<XzSecurityInspectTaskRecord>lambdaQuery()
|
|
|
|
|
|
.eq(XzSecurityInspectTaskRecord::getSn, project.getProjectSn())
|
|
|
|
|
|
.le(XzSecurityInspectTaskRecord::getEndTime, DateUtil.offsetDay(new Date(), -dayNum)));
|
|
|
|
|
|
if (xzSecurityInspectTaskRecords.size() > 0) {
|
|
|
|
|
|
List<XzSecurityInspectTaskItemRecord> itemList = xzSecurityInspectTaskItemRecordMapper.selectList(Wrappers.<XzSecurityInspectTaskItemRecord>lambdaQuery()
|
|
|
|
|
|
.in(XzSecurityInspectTaskItemRecord::getTaskId, xzSecurityInspectTaskRecords.stream().map(s -> s.getId()).collect(Collectors.toList())));
|
|
|
|
|
|
if (itemList != null && itemList.size() > 0) {
|
|
|
|
|
|
for (XzSecurityInspectTaskItemRecord data : itemList) {
|
|
|
|
|
|
XzSecurityInspectTaskRecord xzSecurityInspectTaskRecord = xzSecurityInspectTaskRecords.stream().filter(s -> s.getId().toString().equals(data.getTaskId().toString())).collect(Collectors.toList()).get(0);
|
|
|
|
|
|
SystemUser systemUser = systemUserMapper.selectById(xzSecurityInspectTaskRecord.getInspectUser());
|
|
|
|
|
|
WorkerInfo workerInfo = workerInfoMapper.selectById(systemUser.getWorkerId());
|
|
|
|
|
|
int count = 0;
|
|
|
|
|
|
if (xzSecurityInspectTaskRecord.getType() == 1) {
|
|
|
|
|
|
count = hiddenDangerInspectRecordService.count(Wrappers.<HiddenDangerInspectRecord>lambdaQuery()
|
|
|
|
|
|
.eq(HiddenDangerInspectRecord::getInspectHiddenDangerItemRecordId, data.getId()));
|
|
|
|
|
|
} else {
|
|
|
|
|
|
count = qualityInspectionRecordService.count(Wrappers.<XzSecurityQualityInspectionRecord>lambdaQuery()
|
|
|
|
|
|
.eq(XzSecurityQualityInspectionRecord::getItemId, data.getId()));
|
|
|
|
|
|
}
|
|
|
|
|
|
if (count == 0) {
|
|
|
|
|
|
personSn.add(workerInfo.getPersonSn());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-22 01:36:11 +08:00
|
|
|
|
}
|
2024-05-22 21:57:53 +08:00
|
|
|
|
if (type.equals("3")) {
|
2024-05-22 01:36:11 +08:00
|
|
|
|
List<WorkerMonthAttendanceStatistics> list1 = workerMonthAttendanceStatisticsService.list(Wrappers.<WorkerMonthAttendanceStatistics>
|
|
|
|
|
|
lambdaQuery().eq(WorkerMonthAttendanceStatistics::getProjectSn, project.getProjectSn())
|
|
|
|
|
|
.eq(WorkerMonthAttendanceStatistics::getQueryTime, DateUtil.format(new Date(), "yyyy-MM")));
|
|
|
|
|
|
Integer number = 0;
|
|
|
|
|
|
for (WorkerMonthAttendanceStatistics workerMonthAttendanceStatistics : list1) {
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(JSON.toJSONString(workerMonthAttendanceStatistics));
|
|
|
|
|
|
Iterator<String> iterator = obj.keySet().iterator();
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
|
|
String value = obj.getString(iterator.next());
|
|
|
|
|
|
if (value.equals("0")) {
|
|
|
|
|
|
number ++ ;
|
|
|
|
|
|
}
|
2024-05-23 18:30:51 +08:00
|
|
|
|
if (number > dayNum) {
|
2024-05-22 01:36:11 +08:00
|
|
|
|
personSn.add(workerMonthAttendanceStatistics.getPersonSn());
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-22 21:57:53 +08:00
|
|
|
|
if (type.equals("4")) {
|
2024-05-22 01:36:11 +08:00
|
|
|
|
List<WorkerMonthAttendanceStatistics> list1 = workerMonthAttendanceStatisticsService.list(Wrappers.<WorkerMonthAttendanceStatistics>
|
|
|
|
|
|
lambdaQuery().eq(WorkerMonthAttendanceStatistics::getProjectSn, project.getProjectSn())
|
|
|
|
|
|
.eq(WorkerMonthAttendanceStatistics::getQueryTime, DateUtil.format(new Date(), "yyyy-MM")));
|
|
|
|
|
|
Integer number = 0;
|
|
|
|
|
|
for (WorkerMonthAttendanceStatistics workerMonthAttendanceStatistics : list1) {
|
|
|
|
|
|
JSONObject obj = JSONObject.parseObject(JSON.toJSONString(workerMonthAttendanceStatistics));
|
|
|
|
|
|
Iterator<String> iterator = obj.keySet().iterator();
|
|
|
|
|
|
while (iterator.hasNext()) {
|
|
|
|
|
|
String value = obj.getString(iterator.next());
|
|
|
|
|
|
if (value.equals("2")) {
|
|
|
|
|
|
number ++ ;
|
|
|
|
|
|
}
|
2024-05-23 18:30:51 +08:00
|
|
|
|
if (number > dayNum) {
|
2024-05-22 01:36:11 +08:00
|
|
|
|
personSn.add(workerMonthAttendanceStatistics.getPersonSn());
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-22 21:57:53 +08:00
|
|
|
|
if (personSn.size() > 0) {
|
|
|
|
|
|
Map<String, Object> requestParam = new HashMap<>();
|
|
|
|
|
|
requestParam.put("personSns", personSn);
|
2024-05-23 17:55:42 +08:00
|
|
|
|
requestParam.put("inserviceType", 1);
|
2024-05-22 21:57:53 +08:00
|
|
|
|
List<WorkerInfo> workerInfoList = workerInfoMapper.selectWorkerInfoList(new Page<>(-1, -1), requestParam);
|
|
|
|
|
|
for (WorkerInfo workerInfo : workerInfoList) {
|
2024-05-23 17:55:42 +08:00
|
|
|
|
if (workerInfo.getEnterpriseId() == null) {
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
2024-05-22 21:57:53 +08:00
|
|
|
|
XzWorkerSafeWatchAlarm xzWorkerSafeWatchAlarm = new XzWorkerSafeWatchAlarm();
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setWorkerId(workerInfo.getId());
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setWorkerName(workerInfo.getWorkerName());
|
|
|
|
|
|
String deptName = workerInfo.getDepartmentName() == null ? "" : workerInfo.getDepartmentName();
|
|
|
|
|
|
String teamName = workerInfo.getTeamName() == null ? "" : workerInfo.getTeamName();
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setDeptName(deptName + teamName);
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setEnterpriseName(workerInfo.getEnterpriseName());
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setAlarmTime(new Date());
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setType(type);
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setProjectSn(project.getProjectSn());
|
|
|
|
|
|
xzWorkerSafeWatchAlarm.setDayNum(dayNum);
|
2024-05-23 17:55:42 +08:00
|
|
|
|
xzWorkerSafeWatchAlarm.setEnterpriseId(workerInfo.getEnterpriseId());
|
2024-05-22 21:57:53 +08:00
|
|
|
|
alarmList.add(xzWorkerSafeWatchAlarm);
|
2024-05-22 01:36:11 +08:00
|
|
|
|
|
2024-05-22 21:57:53 +08:00
|
|
|
|
Long id = xzWorkerSafeWatchConfig.getId();
|
|
|
|
|
|
|
|
|
|
|
|
List<String> userIds = Arrays.asList(xzWorkerSafeWatchManagerService.list(Wrappers.<XzWorkerSafeWatchManager>lambdaQuery()
|
|
|
|
|
|
.eq(XzWorkerSafeWatchManager::getWatchConfigId, id))
|
|
|
|
|
|
.stream().map(l -> l.getUserId()).collect(Collectors.joining(",")).split(","));
|
|
|
|
|
|
for (String userId : userIds) {
|
2024-05-23 17:55:42 +08:00
|
|
|
|
if (StringUtils.isNotBlank(userId)) {
|
|
|
|
|
|
Notice notice = new Notice();
|
|
|
|
|
|
notice.setType("35");
|
|
|
|
|
|
notice.setMsg(StrUtil.format("事件:{},人员名称:{},身份证号:{}",
|
|
|
|
|
|
typeName[Integer.parseInt(type) - 1] + dayNum + "天未履职", workerInfo.getWorkerName(), workerInfo.getIdCard()));
|
|
|
|
|
|
notice.setTitle("人员安全履职预警提醒");
|
|
|
|
|
|
notice.setIsRead(0);
|
|
|
|
|
|
notice.setAccountId(Long.valueOf(userId));
|
|
|
|
|
|
notice.setSendTime(DateUtil.formatDateTime(new Date()));
|
|
|
|
|
|
noticeList.add(notice);
|
|
|
|
|
|
}
|
2024-05-22 21:57:53 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-05-22 01:36:11 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
xzWorkerSafeWatchAlarmService.saveBatch(alarmList);
|
|
|
|
|
|
noticeService.saveBatch(noticeList);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
2024-03-27 14:59:35 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 添加通知
|
|
|
|
|
|
*
|
|
|
|
|
|
* @param list
|
|
|
|
|
|
* @param title 标题
|
|
|
|
|
|
* @param type
|
|
|
|
|
|
*/
|
2024-05-09 18:49:41 +08:00
|
|
|
|
private void addNotice(Collection<WorkerInfo> list, String title, String type) {
|
2024-03-11 20:22:27 +08:00
|
|
|
|
Map<String, List<WorkerInfo>> projectMap = list.stream().collect(Collectors.groupingBy(WorkerInfo::getProjectSn));
|
|
|
|
|
|
if (CollUtil.isNotEmpty(projectMap)) {
|
|
|
|
|
|
for (Map.Entry<String, List<WorkerInfo>> entry : projectMap.entrySet()) {
|
|
|
|
|
|
List<SystemUser> systemUserList = systemUserMapper.selectList(new LambdaQueryWrapper<SystemUser>()
|
|
|
|
|
|
.eq(SystemUser::getSn, entry.getKey()));
|
|
|
|
|
|
List<WorkerInfo> workerInfoList = entry.getValue();
|
|
|
|
|
|
if (CollUtil.isNotEmpty(workerInfoList)) {
|
|
|
|
|
|
for (WorkerInfo workerInfo : workerInfoList) {
|
2024-05-09 18:49:41 +08:00
|
|
|
|
String certificateTypeName = workerInfo.getCertificateTypeName();
|
|
|
|
|
|
XzCertificateExpireAlarmRecord xzCertificateExpireAlarmRecord = new XzCertificateExpireAlarmRecord();
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setPersonTypeName(getPersonTypeName(workerInfo.getPersonType()));
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setEnterpriseName(workerInfo.getEnterpriseName());
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setTeamDepartmentName(StringUtils.isNotBlank(workerInfo.getDepartmentName()) ? workerInfo.getDepartmentName() : workerInfo.getTeamName());
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setWorkerName(workerInfo.getWorkerName());
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setCertificateTypeName(certificateTypeName);
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setCertificateEndDate(DateUtil.parseDate(workerInfo.getEffectTime()));
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setAlarmPromptTime(new Date());
|
|
|
|
|
|
xzCertificateExpireAlarmRecord.setProjectSn(workerInfo.getProjectSn());
|
|
|
|
|
|
xzCertificateExpireAlarmRecordService.add(xzCertificateExpireAlarmRecord);
|
2024-03-11 20:22:27 +08:00
|
|
|
|
if (CollUtil.isNotEmpty(systemUserList)) {
|
|
|
|
|
|
for (SystemUser systemUser : systemUserList) {
|
2024-05-09 18:49:41 +08:00
|
|
|
|
noticeService.addUserNotice(systemUser.getUserId(), workerInfo.getWorkerName() + "的" + certificateTypeName + "即将到期,请尽快更新!", title, type);
|
2024-03-11 20:22:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-05-09 18:49:41 +08:00
|
|
|
|
private String getPersonTypeName(Integer personType) {
|
|
|
|
|
|
if (personType == 1) {
|
|
|
|
|
|
return "劳务人员";
|
|
|
|
|
|
} else if (personType == 2) {
|
|
|
|
|
|
return "管理人员";
|
|
|
|
|
|
} else if (personType == 3) {
|
|
|
|
|
|
return "临时人员";
|
|
|
|
|
|
}
|
|
|
|
|
|
return null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2024-04-13 17:35:21 +08:00
|
|
|
|
/**
|
|
|
|
|
|
* 劳务在场零点清空功能
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Scheduled(cron = "0 10 0 * * ?")
|
|
|
|
|
|
@SchedulerLock(name = "updateWorkerAttendanceZero", lockAtMostFor = 1000 * 60 * 30, lockAtLeastFor = 1000 * 60 * 3)
|
|
|
|
|
|
@RequestMapping("updateWorkerAttendanceZero")
|
|
|
|
|
|
public void updateWorkerAttendanceZero() {
|
|
|
|
|
|
List<Project> projects = projectMapper.selectList(new LambdaQueryWrapper<Project>()
|
|
|
|
|
|
.eq(Project::getEnableWorkerAttendanceZero, 1));
|
|
|
|
|
|
for (Project project : projects) {
|
|
|
|
|
|
String projectSn = project.getProjectSn();
|
|
|
|
|
|
workerAttendancePresenceService.addNowAllWorkerAttendancePresence(projectSn);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-02-16 15:28:15 +08:00
|
|
|
|
}
|