车辆三检发消息

This commit is contained in:
2026-05-21 14:48:29 +08:00
parent cd8a4fd5c8
commit 30f0decedb
2 changed files with 99 additions and 1 deletions

View File

@@ -4,10 +4,13 @@ import com.hotwj.platform.config.vehicleThreeInspect.domain.HotVehicleThreeInspe
import com.hotwj.platform.config.vehicleThreeInspect.mapper.HotVehicleThreeInspectMapper;
import com.hotwj.platform.flow.callback.IFlowCallback;
import com.hotwj.platform.flow.service.ISysFlowService;
import com.hotwj.platform.noticeManagerment.systemNotification.domain.bo.HotSystemNotificationGroupBo;
import com.hotwj.platform.noticeManagerment.systemNotification.service.IHotSystemNotificationService;
import com.hotwj.platform.securityManagement.hiddenDanger.domain.HotHiddenDanger;
import com.hotwj.platform.securityManagement.hiddenDanger.domain.bo.HotHiddenDangerBo;
import com.hotwj.platform.securityManagement.hiddenDanger.mapper.HotHiddenDangerMapper;
import lombok.extern.slf4j.Slf4j;
import org.dromara.common.core.utils.StringUtils;
import org.dromara.common.core.utils.MapstructUtils;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
@@ -26,13 +29,16 @@ public class VehicleThreeInspectCallback implements IFlowCallback {
private final HotVehicleThreeInspectMapper inspectMapper;
private final HotHiddenDangerMapper hiddenDangerMapper;
private final ISysFlowService flowService;
private final IHotSystemNotificationService notificationService;
public VehicleThreeInspectCallback(HotVehicleThreeInspectMapper inspectMapper,
HotHiddenDangerMapper hiddenDangerMapper,
@Lazy ISysFlowService flowService) {
@Lazy ISysFlowService flowService,
IHotSystemNotificationService notificationService) {
this.inspectMapper = inspectMapper;
this.hiddenDangerMapper = hiddenDangerMapper;
this.flowService = flowService;
this.notificationService = notificationService;
}
@Override
@@ -56,6 +62,11 @@ public class VehicleThreeInspectCallback implements IFlowCallback {
createHiddenDangerFlow(inspect);
}
inspectMapper.updateById(inspect);
try {
sendDriverAuditNotification(inspect, success);
} catch (Exception e) {
log.warn("发送车辆三检审核结果通知失败 inspectId={} driverId={}", inspect.getId(), inspect.getDriverId(), e);
}
}
}
@@ -103,4 +114,47 @@ public class VehicleThreeInspectCallback implements IFlowCallback {
hiddenDangerMapper.updateById(danger);
}
}
private void sendDriverAuditNotification(HotVehicleThreeInspect inspect, boolean success) {
if (inspect == null || StringUtils.isBlank(inspect.getDriverId())) {
return;
}
HotSystemNotificationGroupBo bos = new HotSystemNotificationGroupBo();
bos.setLevel("普通");
bos.setContent(buildDriverAuditNotificationContent(inspect, success));
bos.setSourceType("车辆管理");
bos.setSenderType("SYSTEM");
bos.setReceiverType("驾驶员");
bos.setReceiverIds(java.util.Collections.singletonList(inspect.getDriverId()));
bos.setIsDeleted(0L);
notificationService.insertByBo(bos);
}
private String buildDriverAuditNotificationContent(HotVehicleThreeInspect inspect, boolean success) {
String phaseName = getPhaseName(inspect.getInspectPhase());
if (success) {
return "您的车辆三检【" + phaseName + "】已审核通过,请及时查看。";
}
String auditResult = StringUtils.trimToEmpty(inspect.getAuditResult());
if (StringUtils.isNotBlank(auditResult)) {
return "您的车辆三检【" + phaseName + "】未通过,审核意见:" + auditResult;
}
return "您的车辆三检【" + phaseName + "】未通过,请及时查看审核意见。";
}
private String getPhaseName(Long phase) {
if (phase == null) {
return "未知阶段";
}
if (phase == 1L) {
return "出车前检查";
}
if (phase == 2L) {
return "行车中检查";
}
if (phase == 3L) {
return "收车后检查";
}
return "未知阶段";
}
}

View File

@@ -11,6 +11,8 @@ import com.hotwj.platform.config.vehicleThreeInspect.mapper.HotVehicleThreeInspe
import com.hotwj.platform.config.vehicleThreeInspect.service.IHotVehicleThreeInspectService;
import com.hotwj.platform.flow.service.ISysFlowService;
import com.hotwj.platform.integration.ocr.SignatureVerifyService;
import com.hotwj.platform.noticeManagerment.systemNotification.domain.bo.HotSystemNotificationGroupBo;
import com.hotwj.platform.noticeManagerment.systemNotification.service.IHotSystemNotificationService;
import com.hotwj.platform.resourceManagement.vehicleManagement.domain.vo.HotVehicleVo;
import com.hotwj.platform.resourceManagement.vehicleManagement.mapper.HotVehicleMapper;
import com.hotwj.platform.securityManagement.hiddenDanger.mapper.HotHiddenDangerMapper;
@@ -44,6 +46,7 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
private final HotVehicleMapper hotVehicleMapper;
private final HotHiddenDangerMapper hotHiddenDangerMapper;
private final ISysFlowService flowService;
private final IHotSystemNotificationService notificationService;
private final SignatureVerifyService signatureVerifyService;
/**
@@ -252,6 +255,11 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
add.setInstanceId(instanceId);
add.setFlowStatus("SUBMITTED");
baseMapper.updateById(add);
try {
sendSubmitNotification(add, approverId);
} catch (Exception e) {
log.warn("发送车辆三检提交通知失败 inspectId={} approverId={}", add.getId(), approverId, e);
}
}
return flag;
}
@@ -280,6 +288,42 @@ public class HotVehicleThreeInspectServiceImpl implements IHotVehicleThreeInspec
return Long.parseLong(first);
}
private void sendSubmitNotification(HotVehicleThreeInspect inspect, String approverId) {
if (inspect == null || StringUtils.isBlank(approverId)) {
return;
}
HotSystemNotificationGroupBo bos = new HotSystemNotificationGroupBo();
bos.setLevel("普通");
bos.setContent(buildSubmitNotificationContent(inspect));
bos.setSourceType("车辆管理");
bos.setSenderType("SYSTEM");
bos.setReceiverType("管理员");
bos.setReceiverIds(java.util.Collections.singletonList(approverId));
bos.setIsDeleted(0L);
notificationService.insertByBo(bos);
}
private String buildSubmitNotificationContent(HotVehicleThreeInspect inspect) {
String driverName = StringUtils.blankToDefault(StringUtils.trim(inspect.getDriverName()), "驾驶员");
return driverName + "提交了车辆三检【" + getPhaseName(inspect.getInspectPhase()) + "】记录,请及时审核。";
}
private String getPhaseName(Long phase) {
if (phase == null) {
return "未知阶段";
}
if (phase == 1L) {
return "出车前检查";
}
if (phase == 2L) {
return "行车中检查";
}
if (phase == 3L) {
return "收车后检查";
}
return "未知阶段";
}
/**
* 修改车辆三检
*