This commit is contained in:
zt
2025-09-20 20:07:50 +08:00
parent 5f8d494154
commit 325547f201
5 changed files with 106 additions and 22 deletions

View File

@ -20,6 +20,7 @@ import org.springframework.stereotype.Component;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@Slf4j @Slf4j
@ -69,7 +70,13 @@ public class AttendanceReminderJob {
Set<Long> list1 = list.stream().map(SubConstructionUser::getSysUserId).collect(Collectors.toSet()); Set<Long> list1 = list.stream().map(SubConstructionUser::getSysUserId).collect(Collectors.toSet());
for (Long userId : list1) { for (Long userId : list1) {
chatServerHandler.sendSystemMessageToUser(userId, message,"1"); CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(userId, message,"1");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", userId, message, e);
}
});
} }
} }
@ -101,7 +108,13 @@ public class AttendanceReminderJob {
Set<Long> list1 = list.stream().map(SubConstructionUser::getSysUserId).collect(Collectors.toSet()); Set<Long> list1 = list.stream().map(SubConstructionUser::getSysUserId).collect(Collectors.toSet());
for (Long userId : list1) { for (Long userId : list1) {
chatServerHandler.sendSystemMessageToUser(userId, message,"1"); CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(userId, message,"1");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", userId, message, e);
}
});
} }
} }

View File

@ -57,6 +57,7 @@ import java.io.OutputStream;
import java.time.*; import java.time.*;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -396,7 +397,14 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
// 上传人脸照 // 上传人脸照
SysOssVo upload = ossService.upload(file); SysOssVo upload = ossService.upload(file);
attendance.setFacePic(upload.getOssId().toString()); attendance.setFacePic(upload.getOssId().toString());
chatServerHandler.sendSystemMessageToUser(userId, "打卡成功", "1"); CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(userId, "打卡成功", "1");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", userId, "打卡成功", e);
}
});
boolean save = this.save(attendance); boolean save = this.save(attendance);
//插入工资 //插入工资
userSalaryDetailService.insertByAttendance(userId, attendance.getClockDate()); userSalaryDetailService.insertByAttendance(userId, attendance.getClockDate());
@ -444,7 +452,14 @@ public class BusAttendanceServiceImpl extends ServiceImpl<BusAttendanceMapper, B
// 上传人脸照 // 上传人脸照
SysOssVo upload = ossService.upload(file); SysOssVo upload = ossService.upload(file);
attendance.setFacePic(upload.getOssId().toString()); attendance.setFacePic(upload.getOssId().toString());
chatServerHandler.sendSystemMessageToUser(userId, "打卡成功", "1");
CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(userId, "打卡成功", "1");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", userId, "打卡成功", e);
}
});
boolean save = this.save(attendance); boolean save = this.save(attendance);
//插入工资 //插入工资
userSalaryDetailService.insertByAttendance(userId, attendance.getClockDate()); userSalaryDetailService.insertByAttendance(userId, attendance.getClockDate());

View File

@ -47,6 +47,9 @@ import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
@ -81,7 +84,6 @@ public class BusReissueCardServiceImpl extends ServiceImpl<BusReissueCardMapper,
private ISubUserSalaryDetailService userSalaryDetailService; private ISubUserSalaryDetailService userSalaryDetailService;
@Resource @Resource
private ChatServerHandler chatServerHandler; private ChatServerHandler chatServerHandler;
/** /**
* 查询施工人员补卡申请 * 查询施工人员补卡申请
* *
@ -374,7 +376,14 @@ public class BusReissueCardServiceImpl extends ServiceImpl<BusReissueCardMapper,
.eq(BusAttendance::getId, bean.getAttendanceId()) .eq(BusAttendance::getId, bean.getAttendanceId())
.set(BusAttendance::getHandle, "1")); .set(BusAttendance::getHandle, "1"));
//发送通知 //发送通知
chatServerHandler.sendSystemMessageToUser(bean.getGangerId(),"["+bean.getUserName()+ "]"+"提交了新的补卡申请","1"); //发送通知 - 异步执行
CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(bean.getGangerId(),"["+bean.getUserName()+ "]"+"提交了新的补卡申请","1");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", bean.getGangerId(), "提交了新的补卡申请", e);
}
});
return bean.getId(); return bean.getId();
} }
@ -398,13 +407,27 @@ public class BusReissueCardServiceImpl extends ServiceImpl<BusReissueCardMapper,
if(BusAttendanceClockStatusEnum.UNCLOCK.getValue().equals(clockStatus)){ if(BusAttendanceClockStatusEnum.UNCLOCK.getValue().equals(clockStatus)){
userSalaryDetailService.insertByAttendance(byId.getUserId(),byId.getClockDate()); userSalaryDetailService.insertByAttendance(byId.getUserId(),byId.getClockDate());
} }
chatServerHandler.sendSystemMessageToUser(bean.getUserId(),"补卡申请已通过","1"); CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(bean.getUserId(),"补卡申请已通过","1");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", bean.getUserId(), "补卡申请已通过", e);
}
});
} }
if("3".equals(bean.getGangerOpinion())){ if("3".equals(bean.getGangerOpinion())){
BusAttendance byId = attendanceService.getById(attendanceId); BusAttendance byId = attendanceService.getById(attendanceId);
byId.setHandle("0"); byId.setHandle("0");
attendanceService.updateById(byId); attendanceService.updateById(byId);
chatServerHandler.sendSystemMessageToUser(bean.getUserId(),"补卡申请未通过","1"); CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(bean.getUserId(),"补卡申请未通过","1");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", bean.getUserId(), "补卡申请未通过", e);
}
});
} }
return b; return b;
} }

View File

@ -59,6 +59,7 @@ import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@ -204,11 +205,19 @@ public class QltQualityInspectionServiceImpl extends ServiceImpl<QltQualityInspe
throw new ServiceException("新增检查工单信息失败,数据库异常", HttpStatus.ERROR); throw new ServiceException("新增检查工单信息失败,数据库异常", HttpStatus.ERROR);
} }
if (req.getCorrectorId() != null) { if (req.getCorrectorId() != null) {
String title = "您有新的质量巡检工单,请及时查看!"; CompletableFuture.runAsync(() -> {
if (req.getIsReply().equals("1")) { try {
title = "您有新的质量巡检工单需要整改,请及时处理!"; String title = req.getIsReply().equals("1")
} ? "您有新的质量巡检工单需要整改,请及时处理!"
chatServerHandler.sendSystemMessageToUser(req.getCorrectorId(), title, "3"); : "您有新的质量巡检工单,请及时查看!";
chatServerHandler.sendSystemMessageToUser(req.getCorrectorId(), title, "3");
} catch (Exception e) {
String title = req.getIsReply().equals("1")
? "您有新的质量巡检工单需要整改,请及时处理!"
: "您有新的质量巡检工单,请及时查看!";
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", req.getCorrectorId(), title, e);
}
});
} }
// 返回新写入的数据 // 返回新写入的数据
return qualityInspection.getId(); return qualityInspection.getId();
@ -233,8 +242,15 @@ public class QltQualityInspectionServiceImpl extends ServiceImpl<QltQualityInspe
throw new ServiceException("修改检查工单信息失败,数据不存在", HttpStatus.NOT_FOUND); throw new ServiceException("修改检查工单信息失败,数据不存在", HttpStatus.NOT_FOUND);
} }
if ("2".equals(req.getInspectionStatus()) && oldQualityInspection.getCreateBy() != null && oldQualityInspection.getIsReply().equals("1")) { if ("2".equals(req.getInspectionStatus()) && oldQualityInspection.getCreateBy() != null && oldQualityInspection.getIsReply().equals("1")) {
chatServerHandler.sendSystemMessageToUser(oldQualityInspection.getCreateBy(), String title = "质量巡检工单【" + oldQualityInspection.getInspectionHeadline() + "】已整改,请及时复查!";
"质量巡检工单【" + oldQualityInspection.getInspectionHeadline() + "】已整改,请及时复查!", "3"); CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(oldQualityInspection.getCreateBy(), title, "3");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", oldQualityInspection.getCreateBy(), title, e);
}
});
} }
if("2".equals(req.getVerificationType())){ if("2".equals(req.getVerificationType())){
handleFail(oldQualityInspection); handleFail(oldQualityInspection);

View File

@ -60,6 +60,7 @@ import java.nio.file.Files;
import java.nio.file.Path; import java.nio.file.Path;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.*; import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.zip.ZipOutputStream; import java.util.zip.ZipOutputStream;
@ -230,11 +231,19 @@ public class HseSafetyInspectionServiceImpl extends ServiceImpl<HseSafetyInspect
// 向整改人发送消息 // 向整改人发送消息
Long correctorId = req.getCorrectorId(); Long correctorId = req.getCorrectorId();
if (correctorId != null) { if (correctorId != null) {
String title = "您有新的安全巡检工单,请及时查看!"; CompletableFuture.runAsync(() -> {
if (req.getIsReply().equals("1")) { try {
title = "您有新的安全巡检工单需要整改,请及时处理!"; String title = req.getIsReply().equals("1")
} ? "您有新的安全巡检工单需要整改,请及时处理!"
chatServerHandler.sendSystemMessageToUser(correctorId, title, "2"); : "您有新的安全巡检工单,请及时查看!";
chatServerHandler.sendSystemMessageToUser(correctorId, title, "2");
} catch (Exception e) {
String title = req.getIsReply().equals("1")
? "您有新的安全巡检工单需要整改,请及时处理!"
: "您有新的安全巡检工单,请及时查看!";
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", correctorId, title, e);
}
});
} }
// 返回新写入的数据 // 返回新写入的数据
return safetyInspection.getId(); return safetyInspection.getId();
@ -481,8 +490,16 @@ public class HseSafetyInspectionServiceImpl extends ServiceImpl<HseSafetyInspect
HseSafetyInspection updateInspection = new HseSafetyInspection(); HseSafetyInspection updateInspection = new HseSafetyInspection();
BeanUtils.copyProperties(req, updateInspection); BeanUtils.copyProperties(req, updateInspection);
if (safetyInspection.getCreateBy() != null && safetyInspection.getIsReply().equals("1")) { if (safetyInspection.getCreateBy() != null && safetyInspection.getIsReply().equals("1")) {
chatServerHandler.sendSystemMessageToUser(safetyInspection.getCreateBy(), String title = "安全巡检工单【" + safetyInspection.getCheckProject() + "】已整改,请及时复查!";
"安全巡检工单【" + safetyInspection.getCheckProject() + "】已整改,请及时复查!", "2"); CompletableFuture.runAsync(() -> {
try {
chatServerHandler.sendSystemMessageToUser(safetyInspection.getCreateBy(), title, "2");
} catch (Exception e) {
log.error("异步发送系统消息失败用户ID: {}, 消息: {}", safetyInspection.getCreateBy(), title, e);
}
});
} }
// 填充默认值 // 填充默认值
updateInspection.setId(id); updateInspection.setId(id);