|
|
@@ -24,6 +24,7 @@ import com.platform.dao.dto.check.CheckPlanDTO;
|
|
|
import com.platform.dao.dto.check.CheckProjectPlanRelationDTO;
|
|
|
import com.platform.dao.dto.check.CheckStandardDTO;
|
|
|
import com.platform.dao.dto.sb.SbInfoDTO;
|
|
|
+import com.platform.dao.dto.upms.SysUserDTO;
|
|
|
import com.platform.dao.entity.check.*;
|
|
|
import com.platform.dao.entity.sb.SbInfo;
|
|
|
import com.platform.dao.entity.upms.SysConfig;
|
|
|
@@ -34,7 +35,9 @@ import com.platform.dao.mapper.repair.RepairApplicationFormMapper;
|
|
|
import com.platform.dao.mapper.sb.SbInfoMapper;
|
|
|
import com.platform.dao.mapper.sb.SbPositionMapper;
|
|
|
import com.platform.dao.mapper.upms.SysFileMapper;
|
|
|
+import com.platform.dao.mapper.upms.SysUserMapper;
|
|
|
import com.platform.dao.util.CustomExcelImportUtil;
|
|
|
+import com.platform.dao.util.MessageTemplateUtil;
|
|
|
import com.platform.dao.vo.SysUserDeptVO;
|
|
|
import com.platform.dao.vo.SysUserVO;
|
|
|
import com.platform.dao.vo.query.check.*;
|
|
|
@@ -49,6 +52,7 @@ import com.platform.dao.vo.tuicalendar.TuiCalendar;
|
|
|
import com.platform.dao.vo.tuicalendar.TuiCalendarUtil;
|
|
|
import com.platform.service.base.impl.BaseServiceImpl;
|
|
|
import com.platform.service.check.CheckJobService;
|
|
|
+import com.platform.service.mail.MailService;
|
|
|
import com.platform.service.sb.SbInfoService;
|
|
|
import com.platform.service.upms.SysConfigService;
|
|
|
import com.platform.service.upms.SysUserDeptService;
|
|
|
@@ -120,6 +124,10 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
private CheckRequirementMapper requirementMapper;
|
|
|
@Autowired
|
|
|
private RepairApplicationFormMapper repairApplicationFormMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysUserMapper sysUserMapper;
|
|
|
+ @Autowired
|
|
|
+ private MailService mailService;
|
|
|
|
|
|
@Value("${upload.root-dir}")
|
|
|
private String UPLOAD_ROOT_FOLDER;
|
|
|
@@ -2736,6 +2744,77 @@ public class CheckJobServiceImpl extends BaseServiceImpl<CheckJobMapper, CheckJo
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ public void sendTeamUnfinishedNotice() {
|
|
|
+ // 查询执行方式为班组且未完成的保养任务
|
|
|
+ List<CheckJobVO> jobs = checkJobMapper.selectUnfinishedTeamJobs();
|
|
|
+ if (CollectionUtils.isEmpty(jobs)) {
|
|
|
+ log.info("班组未完成保养提醒:无未完成的班组保养任务,跳过");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 按班组(check_dept_id)分组
|
|
|
+ Map<String, List<CheckJobVO>> deptJobMap = jobs.stream()
|
|
|
+ .filter(job -> StringUtils.isNotBlank(job.getCheckDeptId()))
|
|
|
+ .collect(Collectors.groupingBy(CheckJobVO::getCheckDeptId, LinkedHashMap::new, Collectors.toList()));
|
|
|
+ String date = DateUtils.dateToString(LocalDate.now(), DateUtils.PATTERN_YMD);
|
|
|
+ for (Map.Entry<String, List<CheckJobVO>> entry : deptJobMap.entrySet()) {
|
|
|
+ String deptId = entry.getKey();
|
|
|
+ List<CheckJobVO> deptJobs = entry.getValue();
|
|
|
+ // 查询该班组下的班长
|
|
|
+ SysUserDTO query = new SysUserDTO();
|
|
|
+ query.setDeptIds(Collections.singletonList(deptId));
|
|
|
+ query.setRoleCode(SysRoleCodeEnum.BAN_ZHANG.name());
|
|
|
+ List<SysUserVO> leaders = sysUserMapper.selectDeptRoleUser(query);
|
|
|
+ if (CollectionUtils.isEmpty(leaders)) {
|
|
|
+ log.warn("班组 {} 未配置班长,跳过未完成保养提醒", deptId);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ // 按设备去重(同一设备可能存在多个未完成任务),保留设备名称与编号
|
|
|
+ String deptName = deptJobs.get(0).getCheckDeptName();
|
|
|
+ Map<String, Map<String, Object>> deviceMap = new LinkedHashMap<>();
|
|
|
+ for (CheckJobVO job : deptJobs) {
|
|
|
+ String key = StringUtils.isNotBlank(job.getSbId()) ? job.getSbId()
|
|
|
+ : (job.getSbName() + "_" + job.getSbNo());
|
|
|
+ if (deviceMap.containsKey(key)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Map<String, Object> device = new HashMap<>();
|
|
|
+ device.put("sbName", StringUtils.isBlank(job.getSbName()) ? "未知设备" : job.getSbName());
|
|
|
+ device.put("sbNo", StringUtils.isBlank(job.getSbNo()) ? "无" : job.getSbNo());
|
|
|
+ device.put("statusName", getCheckJobStatusName(job.getStatus()));
|
|
|
+ deviceMap.put(key, device);
|
|
|
+ }
|
|
|
+ List<Map<String, Object>> devices = new ArrayList<>(deviceMap.values());
|
|
|
+ String content = MessageTemplateUtil.getTeamUnfinishedEmailContent(deptName, date, devices);
|
|
|
+ for (SysUserVO leader : leaders) {
|
|
|
+ if (StringUtils.isNotBlank(leader.getEmail())) {
|
|
|
+ mailService.sendHtmlMail(leader.getEmail(), "设备保养任务未完成提醒", content);
|
|
|
+ } else {
|
|
|
+ log.warn("班长 {} 未配置邮箱,无法发送未完成保养提醒", leader.getRealName());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 保养任务状态文字描述
|
|
|
+ */
|
|
|
+ private String getCheckJobStatusName(Integer status) {
|
|
|
+ if (status == null) {
|
|
|
+ return "未完成";
|
|
|
+ }
|
|
|
+ if (CheckJobStatusEnum.NOT_EXECUTE.getValue().equals(status)) {
|
|
|
+ return "未执行";
|
|
|
+ }
|
|
|
+ if (CheckJobStatusEnum.EXECUTING.getValue().equals(status)) {
|
|
|
+ return "执行中";
|
|
|
+ }
|
|
|
+ if (Integer.valueOf(4).equals(status)) {
|
|
|
+ return "已逾期";
|
|
|
+ }
|
|
|
+ return "未完成";
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void generateJobsForSb(String sbId) {
|
|
|
if (StringUtils.isBlank(sbId)) {
|