Commit 40d17afb by yancanhua

Merge branch 'v1.3.0' of https://gitee.com/foutouren/aus into v1.3.0

2 parents 856c63ae 4e430c70
......@@ -25,22 +25,6 @@ import org.summerframework.orm.paging.Pagination;
public class InspectionReportController {
private final InspectionReportService inspectionReportService;
@Operation(summary = "新增检测报告", description = "添加新的检测报告")
@PostMapping("/add")
public BaseResp<Void> add(@Valid @RequestBody InspectionReportAddVO addVO) {
log.info("新增检测报告请求: {}", JSON.toJSONString(addVO));
try {
inspectionReportService.addInspectionReport(addVO);
} catch (BusinessCodeException be) {
log.error("新增检测报告失败!业务异常!", be);
return BaseResp.fail(StrUtil.toString(be.getCode()), StrUtil.toString(be.getMessage()));
} catch (Exception e) {
log.error("新增检测报告失败!系统异常!", e);
return BaseResp.fail("系统异常: " + e.getMessage());
}
return BaseResp.success();
}
@Operation(summary = "编辑检测报告", description = "编辑检测报告信息")
@PostMapping("/update")
public BaseResp<Void> update(@Valid @RequestBody InspectionReportUpdateVO vo) {
......
package com.glsx.usedcar.converts;
import com.glsx.usedcar.module.inspect.entity.InspectionReport;
import com.glsx.usedcar.module.inspect.vo.InspectionReportRespVO;
import org.mapstruct.Mapper;
import java.util.List;
/**
* 检测报告实体转换器
* @author yangwei
* @version 1.0
* @since 2026/03/17 15:00
*/
@Mapper(componentModel = "spring")
public interface InspectionReportConverter {
/**
* 单个实体转换为VO
*
* @param inspectionReport 检测报告实体
* @return 检测报告响应VO
*/
InspectionReportRespVO inspectionReportMapRespVO(InspectionReport inspectionReport);
/**
* 多个实体转换为VO
*
* @param inspectionReports 检测报告实体列表
* @return 检测报告响应VO列表
*/
List<InspectionReportRespVO> inspectionReportsMapRespVO(List<InspectionReport> inspectionReports);
}
\ No newline at end of file
package com.glsx.usedcar.module.inspect.dao;
import com.glsx.usedcar.module.inspect.entity.InspectionReport;
import com.glsx.usedcar.module.vehicle.entity.Vehicle;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.data.jpa.repository.EntityGraph;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.stereotype.Repository;
import org.summerframework.orm.BaseRepository;
......@@ -33,20 +38,12 @@ public interface InspectionReportRepository extends BaseRepository<InspectionRep
/**
* 根据车辆ID查询未删除的检测报告
*
* @param vehicleId 车辆ID
* @param vehicle 车辆
* @param deleteFlag 删除标识(N:未删除 D:已删除)
* @return 检测报告列表
*/
List<InspectionReport> findByVehicleIdAndDeleteFlag(Integer vehicleId, String deleteFlag);
List<InspectionReport> findByVehicleAndDeleteFlag(Vehicle vehicle, String deleteFlag);
/**
* 根据VIN码查询未删除的检测报告
*
* @param vin VIN码
* @param deleteFlag 删除标识
* @return 检测报告列表
*/
List<InspectionReport> findByVinAndDeleteFlag(String vin, String deleteFlag);
/**
* 根据绑定状态查询未删除的检测报告
......@@ -66,4 +63,15 @@ public interface InspectionReportRepository extends BaseRepository<InspectionRep
*/
List<InspectionReport> findByScoreLevelAndDeleteFlag(String scoreLevel, String deleteFlag);
/**
* 分页查询检测报告(关联查询车辆、工单信息,避免N+1查询)
* 参考 InspectionWorkOrderRepository 的 EntityGraph 写法
*
* @param spec 查询条件
* @param pageable 分页参数
* @return 检测报告分页结果
*/
@Override
@EntityGraph(attributePaths = {"vehicle", "workOrder"})
Page<InspectionReport> findAll(Specification<InspectionReport> spec, Pageable pageable);
}
\ No newline at end of file
package com.glsx.usedcar.module.inspect.entity;
import com.fasterxml.jackson.annotation.JsonView;
import com.glsx.usedcar.module.vehicle.entity.Vehicle;
import jakarta.persistence.*;
import jakarta.validation.constraints.*;
import lombok.*;
......@@ -19,6 +20,7 @@ import static jakarta.persistence.GenerationType.IDENTITY;
/**
* 检测报告(InspectionReport)实体类
* 严格对齐数据库表 inspection_report 结构
*/
@Entity
@Getter
......@@ -28,7 +30,17 @@ import static jakarta.persistence.GenerationType.IDENTITY;
@DynamicUpdate
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "inspection_report") // 对应检测报告表名
@Table(
name = "inspection_report",
indexes = {
// 对齐数据库索引配置
@Index(name = "uk_report_no", columnList = "report_no", unique = true),
@Index(name = "idx_wo_id_del", columnList = "wo_id, delete_flag"),
@Index(name = "idx_work_order_inner_id_del", columnList = "work_order_inner_id, delete_flag"),
@Index(name = "idx_vehicle_id_del", columnList = "vehicle_id, delete_flag"),
@Index(name = "idx_score_level_bind_status_del", columnList = "score_level, bind_status, delete_flag")
}
)
@EntityListeners(AuditingEntityListener.class)
public class InspectionReport extends AuditingEntity implements Serializable {
......@@ -56,7 +68,7 @@ public class InspectionReport extends AuditingEntity implements Serializable {
@JsonView(value = Summary.class)
@NotBlank(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Size(max = 50, groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "report_no", nullable = false, length = 50, unique = true)
@Column(name = "report_no", nullable = false, length = 50)
private String reportNo;
/**
......@@ -69,83 +81,55 @@ public class InspectionReport extends AuditingEntity implements Serializable {
private String woId;
/**
* 车辆ID(对应inspection_work_order.vehicle_id)
*/
@JsonView(value = Summary.class)
@NotNull(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "vehicle_id", nullable = false)
private Integer vehicleId;
/**
* 车型名称(如:2023款 宝马3系 325Li M运动套装)
*/
@JsonView(value = Summary.class)
@NotBlank(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Size(max = 128, groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "car_type_name", nullable = false, length = 128)
private String carTypeName;
/**
* 车源号(车源唯一标识)
* 关联检测工单主键ID(对应inspection_work_order.id)
* 关联InspectionWorkOrder实体(懒加载,非级联)
*/
@JsonView(value = Summary.class)
@NotBlank(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Size(max = 64, groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "car_source_no", nullable = false, length = 64)
private String carSourceNo;
/**
* 车辆识别码(VIN码,固定17位)
*/
@JsonView(value = Summary.class)
@NotBlank(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Size(max = 17, groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "vin", nullable = false, length = 17)
private String vin;
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(
name = "work_order_inner_id",
referencedColumnName = "id",
nullable = false
)
private InspectionWorkOrder workOrder;
/**
* 车牌号(如:京A12345,未上牌则为空)
* 车辆ID(关联Vehicle实体)
*/
@JsonView(value = Summary.class)
@Size(max = 20, groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "plate_no", nullable = true, length = 20)
private String plateNo;
/**
* 车辆状态
* 枚举值:INVENTORY(待入库)、VENUE(场地待维护)、TO_BE_PRICED(待定价)、PRICED(待关联拍场)、
* PENDING_AUCTION(待上拍)、WAIT_AUCTION(待拍卖)、PREVIEW(预展中)、AUCTIONING(拍卖中)、
* CONTRACT_UNSIGNED(待签署合同)、UNPAID(待付车款)、WAIT_PICKUP(待提车)、TRANSFERRING(待过户)、
* COMPLETED(已完成)、CANCELED(已取消)
*/
@JsonView(value = Summary.class)
@NotBlank(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Size(max = 64, groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "vehicle_status", nullable = false, length = 64)
private String vehicleStatus;
@ManyToOne(cascade = {}, fetch = FetchType.LAZY)
@JoinColumn(
name = "vehicle_id",
referencedColumnName = "vehicleId",
nullable = false
)
private Vehicle vehicle;
/**
* 评分(保留1位小数,与工单评分一致)
* 对齐数据库 decimal(4,1)
*/
@JsonView(value = Summary.class)
@Column(name = "score", nullable = true, precision = 2, scale = 1)
@Column(name = "score", nullable = true, precision = 4, scale = 1)
private BigDecimal score;
/**
* 评分级别(ABCDEF)
* 对齐数据库 char(1)
*/
@JsonView(value = Summary.class)
@NotBlank(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Size(max = 1, groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "score_level", nullable = false, length = 1)
@Column(name = "score_level", nullable = false, columnDefinition = "char(1)")
private String scoreLevel;
/**
* 绑定状态(1:已绑定;2:未绑定)
* 对齐数据库 tinyint(2)
*/
@JsonView(value = Summary.class)
@NotNull(groups = {CreateValidGroup.class, UpdateValidGroup.class})
@Column(name = "bind_status", nullable = false)
@Column(name = "bind_status", nullable = false, columnDefinition = "tinyint(2)")
private Integer bindStatus;
/**
......@@ -158,9 +142,10 @@ public class InspectionReport extends AuditingEntity implements Serializable {
/**
* 删除标识 N:未删除 D:已删除
* 对齐数据库 char(1) DEFAULT 'N'
*/
@Builder.Default
@Column(name = "deleted_flag", nullable = false, length = 1)
@Column(name = "delete_flag", nullable = false, length = 1, columnDefinition = "char(1) DEFAULT 'N'")
private String deleteFlag = "N";
}
\ No newline at end of file
......@@ -136,7 +136,7 @@ public class InspectionReportOpLog extends AuditingEntity implements Serializabl
* 删除标识 N:未删除 D:已删除
*/
@Builder.Default
@Column(name = "deleted_flag", nullable = false, length = 1)
@Column(name = "delete_flag", nullable = false, length = 1)
private String deleteFlag = "N";
}
\ No newline at end of file
package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Size;
import lombok.Data;
import java.io.Serial;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 检测报告新增请求参数
*/
@Data
@Schema(description = "检测报告新增请求参数")
public class InspectionReportAddVO implements Serializable {
@Serial
private static final long serialVersionUID = 1234567890123456789L;
@Schema(description = "报告编号(唯一)", requiredMode = Schema.RequiredMode.REQUIRED, example = "REP20260312001")
@NotBlank(message = "报告编号不能为空")
@Size(max = 50, message = "报告编号长度不能超过50个字符")
private String reportNo;
@Schema(description = "关联工单号", requiredMode = Schema.RequiredMode.REQUIRED, example = "WO20260312001")
@NotBlank(message = "关联工单号不能为空")
@Size(max = 50, message = "关联工单号长度不能超过50个字符")
private String woId;
@Schema(description = "车辆ID", requiredMode = Schema.RequiredMode.REQUIRED, example = "1001")
@NotNull(message = "车辆ID不能为空")
private Integer vehicleId;
@Schema(description = "车型名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "2023款 宝马3系 325Li M运动套装")
@NotBlank(message = "车型名称不能为空")
@Size(max = 128, message = "车型名称长度不能超过128个字符")
private String carTypeName;
@Schema(description = "车源号", requiredMode = Schema.RequiredMode.REQUIRED, example = "CS20260312001")
@NotBlank(message = "车源号不能为空")
@Size(max = 64, message = "车源号长度不能超过64个字符")
private String carSourceNo;
@Schema(description = "车辆识别码(VIN码)", requiredMode = Schema.RequiredMode.REQUIRED, example = "LVGDS123456789012")
@NotBlank(message = "VIN码不能为空")
@Size(max = 17, message = "VIN码长度不能超过17个字符")
private String vin;
@Schema(description = "车牌号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "京A12345")
@Size(max = 20, message = "车牌号长度不能超过20个字符")
private String plateNo;
@Schema(description = "车辆状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "PREVIEW")
@NotBlank(message = "车辆状态不能为空")
@Size(max = 64, message = "车辆状态长度不能超过64个字符")
private String vehicleStatus;
@Schema(description = "评分(保留1位小数)", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "4.5")
private BigDecimal score;
@Schema(description = "评分级别(ABCDEF)", requiredMode = Schema.RequiredMode.REQUIRED, example = "A")
@NotBlank(message = "评分级别不能为空")
@Size(max = 1, message = "评分级别只能是单个字符")
private String scoreLevel;
@Schema(description = "绑定状态(1:已绑定;2:未绑定)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "绑定状态不能为空")
private Integer bindStatus;
@Schema(description = "H5链接地址", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "https://xxx.com/report/REP20260312001")
@Size(max = 512, message = "H5链接地址长度不能超过512个字符")
private String h5Url;
}
\ No newline at end of file
package com.glsx.usedcar.module.inspect.vo;
import com.glsx.usedcar.module.vehicle.entity.Vehicle;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.math.BigDecimal;
@Data
@Schema(description = "检测报告分页返回")
public class InspectionReportRespVO {
@Schema(description = "报告ID")
@Schema(description = "报告ID", example = "10001")
private Long id;
@Schema(description = "关联工单ID")
private Long workOrderId;
@Schema(description = "报告编号(唯一)", example = "REPORT20260317001")
private String reportNo;
@Schema(description = "关联工单号", example = "WO20260317001")
private String woId;
@Schema(description = "关联工单信息")
private InspectionWORespVO workOrder;
@Schema(description = "车辆信息")
private Vehicle vehicle;
@Schema(description = "检测评分(保留1位小数)", example = "95.5")
private BigDecimal score;
@Schema(description = "评分级别(ABCDEF)", example = "A")
private String scoreLevel;
@Schema(description = "绑定状态(1:已绑定;2:未绑定)", example = "1")
private Integer bindStatus;
@Schema(description = "H5报告预览链接", example = "https://report.glsx.com/h5/REPORT20260317001")
private String h5Url;
@Schema(description = "检测结论")
@Schema(description = "检测结论", example = "车辆无重大事故,发动机工况良好")
private String conclusion;
}
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!