Commit 244fe6b2 by 杨卫

feat:拍卖后台检测保存自测提交

1 parent 130e6067
......@@ -5,6 +5,7 @@ import com.glsx.usedcar.enums.inspect.InspectionWorkOrderAuditStatusEnum;
import com.glsx.usedcar.enums.inspect.InspectionWorkOrderStatusEnum;
import com.glsx.usedcar.module.inspect.delegate.InspectionSaveDelegate;
import com.glsx.usedcar.module.inspect.dto.InspectionResultDTO;
import com.glsx.usedcar.module.inspect.dto.InspectionScoreDTO;
import com.glsx.usedcar.module.inspect.entity.InspectionRecord;
import com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder;
import com.glsx.usedcar.module.inspect.service.InspectionEditLogService;
......@@ -42,7 +43,7 @@ public class AdminSaveDelegate implements InspectionSaveDelegate {
private final Set<Long> operationNodeIds = new HashSet<>();
/** 旧评分记录快照,用于保存后的评分 diff 对比 */
private InspectionRecord oldRecord;
private InspectionScoreDTO oldScore;
/** 工单对象,用于 afterSave 写入工单操作日志 */
private InspectionWorkOrder workOrder;
......@@ -132,23 +133,27 @@ public class AdminSaveDelegate implements InspectionSaveDelegate {
@Override
public void beforeScoreSave(Long taskId) {
// 快照旧评分数据,用于保存后 diff 对比
this.oldRecord = inspectionRecordService.findRecordByTaskId(taskId);
InspectionRecord record = inspectionRecordService.findRecordByTaskId(taskId);
this.oldScore = InspectionScoreDTO.fromEntity(record);
log.info("【PC端】快照旧评分数据完成,taskId={}", taskId);
}
@Override
public void afterScoreSave(InspectionRecord record, Long taskId, InspectionWorkOrder workOrder) {
public void afterScoreSave(InspectionScoreDTO oldScore, InspectionScoreDTO newScore,
Long taskId, InspectionWorkOrder workOrder) {
// 使用传入的 newScore,如果没有则使用保存的 oldScore(首次保存时)
InspectionScoreDTO finalOldScore = this.oldScore != null ? this.oldScore : oldScore;
inspectionEditLogService.saveScoreEditLog(
record.getId(),
workOrder.getId(),
taskId,
workOrder,
oldRecord,
record,
finalOldScore,
newScore,
getPlatType(),
getOperatorId(),
getOperatorName()
);
log.info("【PC端】评分修改日志记录完成,recordId={}", record.getId());
log.info("【PC端】评分修改日志记录完成,taskId={}", taskId);
}
@Override
......
......@@ -209,6 +209,14 @@ public class InspectionWorkOrderController {
}
}
/**
* 分页查询工单操作日志
* @author yangwei
* @since 2026/4/14 16:24
* @param workOrderId 工单id
* @param pagination 分页参数
* @return com.glsx.usedcar.resp.BaseResp<org.springframework.data.domain.Page<com.glsx.usedcar.module.inspect.vo.WorkOrderOpLogRespVO>>
*/
@Operation(summary = "查询工单操作日志", description = "分页查询检测工单操作日志,操作类型为11(修改检测项信息)和12(修改检测评分)时会关联查询具体修改内容")
@PostMapping("/opLog/{workOrderId}/page")
public BaseResp<Page<WorkOrderOpLogRespVO>> queryWorkOrderOpLogPage(
......
package com.glsx.usedcar.module.inspect.delegate;
import com.glsx.usedcar.enums.inspect.InspectionPlatTypeEnum;
import com.glsx.usedcar.module.inspect.dto.InspectionScoreDTO;
import com.glsx.usedcar.module.inspect.entity.InspectionRecord;
import com.glsx.usedcar.module.inspect.entity.InspectionWorkOrder;
import com.glsx.usedcar.module.inspect.vo.CompleteInspectionRespVO;
......@@ -20,7 +21,7 @@ import java.util.Set;
*/
public interface InspectionSaveDelegate {
default void operationNodeIds(Set<Long> nodeIds){};
default void operationNodeIds(Set<Long> nodeIds) {}
/**
......@@ -82,11 +83,13 @@ public interface InspectionSaveDelegate {
/**
* 评分保存后钩子:可用于写评分修改日志(默认空实现)
*
* @param record 保存后的检测记录
* @param oldScore 保存前的评分数据(DTO)
* @param newScore 保存后的评分数据(DTO)
* @param taskId 检测工单 ID
* @param workOrder 检测工单
*/
default void afterScoreSave(InspectionRecord record, Long taskId, InspectionWorkOrder workOrder) {}
default void afterScoreSave(InspectionScoreDTO oldScore, InspectionScoreDTO newScore,
Long taskId, InspectionWorkOrder workOrder) {}
/**
* 保存评分后的完成检查与处理
......
package com.glsx.usedcar.module.inspect.dto;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 检测评分 DTO(用于评分日志快照)
*
* @author yangwei
* @since 2026/4/13
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InspectionScoreDTO implements Serializable {
@Serial
private static final long serialVersionUID = 7281943562814735110L;
/** 外观评分 */
private BigDecimal exteriorScore;
/** 外观评分依据 */
private String exteriorComment;
/** 骨架评级(A/B/C/D) */
private String skeletonLevel;
/** 骨架评级依据 */
private String skeletonComment;
/** 内饰评级(A/B/C/D) */
private String interiorLevel;
/** 内饰评级依据 */
private String interiorComment;
/** 综合评分 */
private BigDecimal overallScore;
/** 综合评价 */
private String overallComment;
/**
* 从 InspectionRecord 实体构建 DTO
*/
public static InspectionScoreDTO fromEntity(com.glsx.usedcar.module.inspect.entity.InspectionRecord record) {
if (record == null) {
return null;
}
return InspectionScoreDTO.builder()
.exteriorScore(record.getExteriorScore())
.exteriorComment(record.getExteriorComment())
.skeletonLevel(record.getSkeletonLevel())
.skeletonComment(record.getSkeletonComment())
.interiorLevel(record.getInteriorLevel())
.interiorComment(record.getInteriorComment())
.overallScore(record.getOverallScore())
.overallComment(record.getOverallComment())
.build();
}
}
......@@ -15,6 +15,7 @@ import com.glsx.usedcar.module.inspect.dao.InspectionOpLogRepository;
import com.glsx.usedcar.module.inspect.dao.InspectionResultRepository;
import com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderOpLogRepository;
import com.glsx.usedcar.module.inspect.dto.InspectionResultDTO;
import com.glsx.usedcar.module.inspect.dto.InspectionScoreDTO;
import com.glsx.usedcar.module.inspect.entity.*;
import com.glsx.usedcar.module.inspect.vo.InspectionNodeVO;
import com.glsx.usedcar.module.inspect.vo.InspectionResultSnapshotVO;
......@@ -28,6 +29,9 @@ import org.springframework.data.domain.Pageable;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.function.Function;
......@@ -190,6 +194,7 @@ public class InspectionEditLogService {
item.setTriModuleName(StrUtil.nullToEmpty(triModuleName));
item.setFieldLabel(StrUtil.nullToEmpty(fieldLabel));
item.setFieldKey(nodeId.toString());
item.setInteractionType(nodeVO.getInteractionType());
item.setBeforeValue(beforeValue);
item.setAfterValue(afterValue);
item.setSortSeq(sortSeq++);
......@@ -399,8 +404,8 @@ public class InspectionEditLogService {
* @param recordId 检测记录ID
* @param taskId 工单ID
* @param workOrder 工单对象
* @param oldRecord 保存前的检测记录(包含旧评分)
* @param newRecord 保存后的检测记录(包含新评分)
* @param oldScore 保存前的评分数据(DTO)
* @param newScore 保存后的评分数据(DTO)
* @param platType 平台类型
* @param operatorId 操作人ID
* @param operatorName 操作人姓名
......@@ -409,8 +414,8 @@ public class InspectionEditLogService {
public void saveScoreEditLog(Long recordId,
Long taskId,
InspectionWorkOrder workOrder,
InspectionRecord oldRecord,
InspectionRecord newRecord,
InspectionScoreDTO oldScore,
InspectionScoreDTO newScore,
InspectionPlatTypeEnum platType,
Long operatorId,
String operatorName) {
......@@ -419,44 +424,68 @@ public class InspectionEditLogService {
int sortSeq = 0;
// 外观评分
addScoreItemIfChanged(items, InspectConstants.SCORE_EXTERIOR, LambdaUtil.getFieldName(InspectionRecord::getExteriorScore),
oldRecord != null ? oldRecord.getExteriorScore() : null,
newRecord.getExteriorScore(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_EXTERIOR,
LambdaUtil.getFieldName(InspectionRecord::getExteriorScore),
oldScore != null ? oldScore.getExteriorScore() : null,
newScore != null ? newScore.getExteriorScore() : null,
sortSeq++);
// 外观评分依据
addScoreItemIfChanged(items, InspectConstants.SCORE_EXTERIOR_BASE, LambdaUtil.getFieldName(InspectionRecord::getExteriorComment),
oldRecord != null ? oldRecord.getExteriorComment() : null,
newRecord.getExteriorComment(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_EXTERIOR_BASE,
LambdaUtil.getFieldName(InspectionRecord::getExteriorComment),
oldScore != null ? oldScore.getExteriorComment() : null,
newScore != null ? newScore.getExteriorComment() : null,
sortSeq++);
// 骨架评级
addScoreItemIfChanged(items, InspectConstants.SCORE_SKELETON, LambdaUtil.getFieldName(InspectionRecord::getSkeletonLevel),
oldRecord != null ? oldRecord.getSkeletonLevel() : null,
newRecord.getSkeletonLevel(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_SKELETON,
LambdaUtil.getFieldName(InspectionRecord::getSkeletonLevel),
oldScore != null ? oldScore.getSkeletonLevel() : null,
newScore != null ? newScore.getSkeletonLevel() : null,
sortSeq++);
// 骨架评级依据
addScoreItemIfChanged(items, InspectConstants.SCORE_SKELETON_BASE, LambdaUtil.getFieldName(InspectionRecord::getSkeletonComment),
oldRecord != null ? oldRecord.getSkeletonComment() : null,
newRecord.getSkeletonComment(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_SKELETON_BASE,
LambdaUtil.getFieldName(InspectionRecord::getSkeletonComment),
oldScore != null ? oldScore.getSkeletonComment() : null,
newScore != null ? newScore.getSkeletonComment() : null,
sortSeq++);
// 内饰评级
addScoreItemIfChanged(items, InspectConstants.SCORE_INTERIOR, LambdaUtil.getFieldName(InspectionRecord::getInteriorLevel),
oldRecord != null ? oldRecord.getInteriorLevel() : null,
newRecord.getInteriorLevel(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_INTERIOR,
LambdaUtil.getFieldName(InspectionRecord::getInteriorLevel),
oldScore != null ? oldScore.getInteriorLevel() : null,
newScore != null ? newScore.getInteriorLevel() : null,
sortSeq++);
// 内饰评级依据
addScoreItemIfChanged(items, InspectConstants.SCORE_INTERIOR_BASE, LambdaUtil.getFieldName(InspectionRecord::getInteriorComment),
oldRecord != null ? oldRecord.getInteriorComment() : null,
newRecord.getInteriorComment(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_INTERIOR_BASE,
LambdaUtil.getFieldName(InspectionRecord::getInteriorComment),
oldScore != null ? oldScore.getInteriorComment() : null,
newScore != null ? newScore.getInteriorComment() : null,
sortSeq++);
// 综合评分
addScoreItemIfChanged(items, InspectConstants.SCORE_OVERALL, LambdaUtil.getFieldName(InspectionRecord::getOverallScore),
oldRecord != null ? oldRecord.getOverallScore() : null,
newRecord.getOverallScore(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_OVERALL,
LambdaUtil.getFieldName(InspectionRecord::getOverallScore),
oldScore != null ? oldScore.getOverallScore() : null,
newScore != null ? newScore.getOverallScore() : null,
sortSeq++);
// 综合评价
addScoreItemIfChanged(items, InspectConstants.SCORE_OVERALL_BASE, LambdaUtil.getFieldName(InspectionRecord::getOverallComment),
oldRecord != null ? oldRecord.getOverallComment() : null,
newRecord.getOverallComment(),
addScoreItemIfChanged(
items,
InspectConstants.SCORE_OVERALL_BASE,
LambdaUtil.getFieldName(InspectionRecord::getOverallComment),
oldScore != null ? oldScore.getOverallComment() : null,
newScore != null ? newScore.getOverallComment() : null,
sortSeq++);
// 2. 无变更则跳过
......@@ -503,15 +532,25 @@ public class InspectionEditLogService {
*/
private void addScoreItemIfChanged(List<InspectionOpLogItem> items, String fieldLabel, String fieldKey,
Object oldValue, Object newValue, int sortSeq) {
if (oldValue instanceof BigDecimal oldVal && newValue instanceof BigDecimal newVal) {
if (oldVal.compareTo(newVal) == 0) {
return;
} else {
oldValue = oldVal.setScale(0, RoundingMode.HALF_UP);
newValue = newVal.setScale(0, RoundingMode.HALF_UP);
}
}
String oldStr = oldValue != null ? oldValue.toString() : null;
String newStr = newValue != null ? newValue.toString() : null;
if (!ObjectUtil.equal(oldStr, newStr)) {
InspectionOpLogItem item = new InspectionOpLogItem();
item.setModuleName("检测评分");
String moduleName = "检测评分";
item.setModuleName(moduleName);
item.setSubModuleName(StrUtil.EMPTY);
item.setTriModuleName(fieldLabel);
item.setFieldLabel(fieldLabel);
item.setFieldLabel(moduleName + SymbolConsts.HYPHEN + fieldLabel);
item.setFieldKey(fieldKey);
item.setBeforeValue(oldStr);
item.setAfterValue(newStr);
......
......@@ -26,6 +26,7 @@ import com.glsx.usedcar.module.inspect.dao.InspectionValueRepository;
import com.glsx.usedcar.module.inspect.dao.InspectionWorkOrderRepository;
import com.glsx.usedcar.module.inspect.dto.AccidentBurnWadeDTO;
import com.glsx.usedcar.module.inspect.dto.InspectionResultDTO;
import com.glsx.usedcar.module.inspect.dto.InspectionScoreDTO;
import com.glsx.usedcar.module.inspect.dto.InspectionTemplateDTO;
import com.glsx.usedcar.module.inspect.entity.*;
import com.glsx.usedcar.module.inspect.service.strategy.TemplateValueStrategy;
......@@ -46,6 +47,7 @@ import org.summerframework.core.enums.ErrorCodeEnum;
import org.summerframework.core.exception.BusinessCodeException;
import org.summerframework.core.util.StringUtils;
import java.math.RoundingMode;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.TimeUnit;
......@@ -79,7 +81,6 @@ public class InspectionRecordService {
private final InspectionWorkOrderService inspectionWorkOrderService;
private final InspectionValueStrategyRouter inspectionValueStrategyRouter;
private final InspectionWorkOrderRepository inspectionWorkOrderRepository;
private final InspectionEditLogService inspectionEditLogService;
/**
* <pre>
......@@ -1015,8 +1016,11 @@ public class InspectionRecordService {
InspectionRecord record = saveOrUpdateRecord(req, templateDTO, taskId,
delegate.getPlatType(), delegate.getOperatorId(), delegate.getOperatorName());
// 2. 评分保存后钩子(PC端:记录评分修改日志)
delegate.afterScoreSave(record, taskId, workOrder);
// 2. 构建评分 DTO(用于日志对比)
InspectionScoreDTO newScore = InspectionScoreDTO.fromEntity(record);
// 3. 评分保存后钩子(PC端:记录评分修改日志)
delegate.afterScoreSave(null, newScore, taskId, workOrder);
// 3. 获取节点树
List<InspectionNodeVO> allNodes = inspectionNodeService.inspectionNodesByTaskId(taskId);
......@@ -1304,8 +1308,12 @@ public class InspectionRecordService {
NoticeTemplate.TemplateType.DETECT_REPORT,
Map.of(
NoticeField.CAR_INFO, carInfo,
NoticeField.CORE_SCORE, record.getOverallScore(),
NoticeField.EXTERNAL_SCORE, record.getExteriorScore(),
NoticeField.CORE_SCORE, Optional.ofNullable(record.getOverallScore())
.map(score -> score.setScale(0, RoundingMode.HALF_UP).toPlainString())
.orElse(StrUtil.EMPTY),
NoticeField.EXTERNAL_SCORE, Optional.ofNullable(record.getExteriorScore())
.map(score -> score.setScale(0, RoundingMode.HALF_UP).toPlainString())
.orElse(StrUtil.EMPTY),
NoticeField.FRAME_RATING, record.getSkeletonLevel(),
NoticeField.INTERIOR_RATING, record.getInteriorLevel(),
NoticeField.DETECT_NAME, workOrderOpt
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!