Commit 0f7212f2 by 杨卫

feat:检测师代码调整

1 parent 379396b6
Showing 20 changed files with 617 additions and 25 deletions
......@@ -107,19 +107,12 @@ public class InspectorController {
}
@Operation(summary = "禁用/启用检测师", description = "根据检测师ID修改状态,0-禁用,1-启用")
@PostMapping("/status/{id}")
public BaseResp<Void> updateStatus(
@Parameter(description = "检测师ID", required = true)
@NotNull(message = "检测师ID不能为空")
@Positive(message = "检测师ID必须为正数")
@PathVariable("id") Long id,
@Parameter(description = "状态值:0-禁用,1-启用", required = true)
@NotNull(message = "状态值不能为空")
@RequestParam("status") Integer status) {
log.info("禁用/启用检测师请求: ID={}, status={}", id, status);
@PostMapping("/status")
public BaseResp<Void> updateStatus(@Valid @RequestBody UpdateInspectorStatusVO updateVO) {
log.info("禁用/启用检测师请求: ID={}, status={}", updateVO.getId(), updateVO.getStatus());
try {
inspectorService.updateStatus(id, status);
inspectorService.updateStatus(updateVO.getId(), updateVO.getStatus(), updateVO.getRemark());
} catch (BusinessCodeException be) {
log.error("禁用/启用检测师失败!业务异常!", be);
return BaseResp.fail(StrUtil.toString(be.getCode()), be.getMessage());
......@@ -133,15 +126,14 @@ public class InspectorController {
@Operation(summary = "分页查询检测师", description = "分页查询检测师列表,支持姓名或手机号模糊查询,自动过滤逻辑删除数据")
@PostMapping("/page")
public BaseResp<Page<InspectorRespVO>> pageInspectors(@Valid @RequestBody Pagination<Inspector> pagination) {
public Page<InspectorRespVO> pageInspectors(@Valid @RequestBody Pagination<Inspector> pagination) {
log.info("分页查询检测师请求: offset={}, limit={}", pagination.getOffset(), pagination.getLimit());
try {
Page<InspectorRespVO> result = inspectorService.pageInspectors(pagination);
return BaseResp.success(result);
return inspectorService.pageInspectors(pagination);
} catch (Exception e) {
log.error("分页查询检测师失败!系统异常!", e);
return BaseResp.fail("系统异常: " + e.getMessage());
return Page.empty();
}
}
......
package com.glsx.usedcar.config;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
/**
* 检测师配置
* @author yangwei
* @version 1.0
* @since 2026/03/18 11:13
*/
@Data
@Configuration
@NoArgsConstructor
@AllArgsConstructor
@ConfigurationProperties(prefix = "inspector")
public class InspectorConfig {
/**
* 检测审核接口地址
*/
private String inspectionAuditUrl;
}
......@@ -13,4 +13,8 @@ public interface SymbolConsts {
/** 逗号 */
String COMMA = ",";
/** - */
String HYPHEN = "-";
}
package com.glsx.usedcar.consts.inspect;
/**
* 检测相关常量
* @author yangwei
* @version 1.0
* @since 2026/03/18 15:23
*/
public interface InspectConstants {
// ==================== 节点类型 ====================
/** 节点类型:模块 */
int NODE_TYPE_MODULE = 1;
/** 节点类型:分组 */
int NODE_TYPE_GROUP = 2;
/** 节点类型:叶子节点 */
int NODE_TYPE_LEAF = 3;
// ==================== 展现模式 ====================
/** 展现模式:列表表单 */
int DISPLAY_MODE_LIST_FORM = 1;
/** 展现模式:网格检测 */
int DISPLAY_MODE_GRID = 2;
/** 展现模式:区域分组 */
int DISPLAY_MODE_AREA_GROUP = 3;
/** 展现模式:图片上传 */
int DISPLAY_MODE_IMAGE_UPLOAD = 4;
/** 展现模式:基础信息 */
int DISPLAY_MODE_BASE_INFO = 5;
/** 展现模式:视频录制 */
int DISPLAY_MODE_VIDEO = 6;
// ==================== 检测项类型 ====================
/** 检测项类型:基础字段 */
int ITEM_TYPE_BASE = 1;
/** 检测项类型:故障检测 */
int ITEM_TYPE_FAULT = 2;
// ==================== 结果状态 ====================
/** 结果状态:正常 */
int RESULT_STATUS_NORMAL = 1;
/** 结果状态:故障 */
int RESULT_STATUS_FAULT = 2;
/** 结果状态:无此结构 */
int RESULT_STATUS_NO_STRUCTURE = 3;
// ==================== 完成标志 ====================
/** 完成标志:未完成 */
String COMPLETED_FLAG_NO = "0";
/** 完成标志:已完成 */
String COMPLETED_FLAG_YES = "1";
// ==================== 默认值类型 ====================
/** 默认值类型:固定值 */
int DEFAULT_TYPE_FIXED = 1;
/** 默认值类型:接口获取 */
int DEFAULT_TYPE_API = 2;
/** 默认值类型:表达式 */
int DEFAULT_TYPE_EXPR = 3;
// 选项数据源类型:1-固定值,2-接口获取
int OPTION_DATA_TYPE_FIXED = 1;
int OPTION_DATA_TYPE_API = 2;
}
......@@ -135,4 +135,22 @@ public interface InspectorConverter {
*/
InspectionRecord completeInspectionVo2InspectionRecord(CompleteInspectionVO completeInspectionVO);
/**
* 检测节点VO 转 检测节点详情VO
* @author yangwei
* @since 2026/3/18 15:30
* @param vo 检测节点VO
* @return com.glsx.usedcar.module.inspect.vo.InspectionNodeDetailVO
*/
InspectionNodeDetailVO inspectionNodeVO2DetailVO(InspectionNodeVO vo);
/**
* 检测节点VO列表 转 检测节点详情VO列表
* @author yangwei
* @since 2026/3/18 15:30
* @param vos 检测节点VO列表
* @return 检测节点详情VO列表
*/
List<InspectionNodeDetailVO> inspectionNodeVOs2DetailVOs(List<InspectionNodeVO> vos);
}
package com.glsx.usedcar.enums.inspect;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 检测项基础信息字段枚举
* 用于映射检测节点的 nodeCode 到车辆基础信息字段
*
* @author yangwei
* @version 1.0
* @since 2026/03/18 16:00
*/
@Getter
@AllArgsConstructor
public enum InspectionBaseInfoFieldEnum {
/** 车系ID */
CAR_SERIES_ID("carSeriesId", "车系ID"),
/** 车系名称 */
CAR_SERIES_NAME("carSeriesName", "车系名称"),
/** 车型ID */
CAR_TYPE_ID("carTypeId", "车型ID"),
/** 车型名称 */
CAR_TYPE_NAME("carTypeName", "车型名称"),
/** 车牌号 */
LICENSE_PLATE("licensePlate", "车牌号"),
/** 首次上牌 */
FIRST_PLATE("firstPlate", "首次上牌"),
/** 排放标准 */
EMISSION_STANDARD("emissionStandard", "排放标准"),
/** 排量 */
DISPLACEMENT("displacement", "排量"),
;
private final String code;
private final String description;
/**
* 根据code获取枚举
*
* @param code 字段编码
* @return 枚举实例,未找到返回null
*/
public static InspectionBaseInfoFieldEnum getByCode(String code) {
if (code == null) {
return null;
}
for (InspectionBaseInfoFieldEnum e : values()) {
if (e.getCode().equals(code)) {
return e;
}
}
return null;
}
/**
* 判断是否是基础信息字段
*
* @param code 字段编码
* @return 是否是基础信息字段
*/
public static boolean isBaseInfoField(String code) {
return getByCode(code) != null;
}
}
package com.glsx.usedcar.module.inspect.dto;
import jakarta.persistence.Column;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -33,6 +34,11 @@ public class InspectionNodeDTO implements Serializable {
@Builder.Default
private Long parentId = 0L;
/**
* 节点代码
*/
private String nodeCode;
/** 节点名称 */
private String nodeName;
......
......@@ -50,6 +50,9 @@ public class InspectionResultDTO implements Serializable {
@Serial
private static final long serialVersionUID = 7281943562814735109L;
/** 值对应的key */
private String valueKey;
/** 值内容(统一存储:文本/数字/日期/文件路径等) */
private String valueText;
......
......@@ -55,6 +55,12 @@ public class InspectionNode extends AuditingEntity implements Serializable {
private Long parentId = 0L;
/**
* 节点代码
*/
@Column(name = "NODE_CODE", length = 100)
private String nodeCode;
/**
* 节点名称
*/
@Column(name = "NODE_NAME", nullable = false, length = 100)
......
......@@ -58,6 +58,12 @@ public class InspectionNodeVersion extends AuditingEntity implements Serializabl
private Long templateHistoryId;
/**
* 节点代码
*/
@Column(name = "NODE_CODE", length = 100)
private String nodeCode;
/**
* 节点名称
*/
@Column(name = "NODE_NAME", nullable = false, length = 100)
......
......@@ -48,6 +48,12 @@ public class InspectionValue extends AuditingEntity implements Serializable {
private Long resultId;
/**
* 值对应的key,一般选项才有
*/
@Column(name = "VALUE_KEY", nullable = false, length = 1024)
private String valueKey;
/**
* 值内容(统一存储:文本/数字/日期/文件路径/JSON等)
*/
@Column(name = "VALUE_TEXT", nullable = false, length = 1024)
......
......@@ -171,7 +171,7 @@ public class InspectorService {
* @since 2026/3/9 17:00
*/
@Transactional(rollbackFor = Exception.class)
public void updateStatus(Long id, Integer status) {
public void updateStatus(Long id, Integer status, String remark) {
// 参数校验
if (status == null || (status != 0 && status != 1)) {
throw new BusinessCodeException(ErrorCodeEnum.COMMON_ERROR, "状态值必须是0或1");
......@@ -187,12 +187,20 @@ public class InspectorService {
return;
}
if (status == 0) {
if (StrUtil.isBlank(remark)) {
throw new BusinessCodeException(ErrorCodeEnum.COMMON_ERROR, "禁用时必须填写禁用原因");
} else {
inspector.setRemark(remark);
}
}
// 更新状态
inspector.setStatus(status);
inspectorRepository.save(inspector);
// 记录操作日志
String desc = status == 0 ? "账号禁用" : "账号启用";
String desc = status == 0 ? String.format("禁用账号,原因为:%s", remark) : "启用账号";
insertInspectorOpLog(inspector.getId(), desc);
log.info("检测师状态更新成功: ID={}, 新状态={}", inspector.getId(), status);
......
package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.summerframework.orm.validator.CreateValidGroup;
import org.summerframework.orm.validator.UpdateValidGroup;
import java.io.Serial;
import java.io.Serializable;
......@@ -32,9 +37,33 @@ public class InspectionDetailRespVO implements Serializable {
@Schema(description = "关联任务ID")
private Long taskId;
@Schema(description = "车系id")
private Integer carSeriesId;
@Schema(description = "车系名字 奔驰GLC")
private String carSeriesName;
@Schema(description = "车型id")
private Integer carTypeId;
@Schema(description = "车牌号")
private String licensePlate;
@Schema(description = "车型名称(品牌/车系/年款/配置)")
private String carTypeName;
@Schema(description = "首次上牌")
private String firstPlate;
@Schema(description = "排放标准")
private String emissionStandard;
@Schema(description = "排量")
private String displacement;
@Schema(description = "评分评级")
private InspectionScoreVO inspectionScoreVO;
@Schema(description = "检测节点列表")
private List<InspectionNodeVO> inspectionNodeList;
private List<InspectionNodeDetailVO> inspectionNodeList;
}
package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serial;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;
/**
* @author yangwei
* @version 1.0
* @since 2026/03/18 14:53
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "检测节点查询响应 VO")
public class InspectionNodeDetailVO implements Serializable {
@Serial
private static final long serialVersionUID = 6177108860298484327L;
/**
* 节点 ID
*/
@Schema(description = "节点 ID")
private Long id;
/**
* 所属模版 ID
*/
@Schema(description = "所属模版 ID")
private Long templateId;
/**
* 父节点 ID,0 表示根节点
*/
@Schema(description = "父节点 ID,0 表示根节点")
@Builder.Default
private Long parentId = 0L;
/**
* 节点名称
*/
@Schema(description = "节点名称")
private String nodeName;
/**
* 节点类型:1-模块,2-分组,3-叶子节点
*/
@Schema(description = "节点类型:1-模块,2-分组,3-叶子节点")
private Integer nodeType;
/**
* 展示节点名称:1-展示 0-不展示
*/
@Schema(description = "展示节点名称:1-展示 0-不展示")
@Builder.Default
private String showNodeName = "1";
/**
* 编辑权限,0 不可编辑,1 可编辑
*/
@Schema(description = "编辑权限,0 不可编辑,1 可编辑")
@Builder.Default
private String editPermission = "1";
/**
* 展现模式:1-列表表单,2-网格检测,3-区域分组,4-图片上传,5-基础信息,6-视频录制
*/
@Schema(description = "展现模式:1-列表表单,2-网格检测,3-区域分组,4-图片上传,5-基础信息,6-视频录制")
private Integer displayMode;
/**
* 检测项类型:1-基础字段,2-故障检测
*/
@Schema(description = "检测项类型:1-基础字段,2-故障检测")
private Integer itemType;
/**
* 交互类型:text_input、number_input、date_picker、dropdown、cascade、button_select、image_upload、video_upload
*/
@Schema(description = "交互类型", example = "text_input")
private String interactionType;
/**
* 数据格式:string、number、date、datetime
*/
@Schema(description = "数据格式:string、number、date、datetime")
private String dataFormat;
/**
* 日期格式,如:yyyy-MM-dd
*/
@Schema(description = "日期格式", example = "yyyy-MM-dd")
private String datePattern;
/**
* 预留字段
*/
@Schema(description = "预留字段")
private String reserved;
/**
* 占位提示词
*/
@Schema(description = "占位提示词")
private String placeholder;
/**
* 后缀(单位)
*/
@Schema(description = "后缀(单位)")
private String suffix;
/**
* 是否必填:0-选填,1-必填
*/
@Schema(description = "是否必填:0-选填,1-必填")
@Builder.Default
private Integer required = 1;
/**
* 选项配置(JSON 格式文本):固定选项或动态接口配置
*/
@Schema(description = "选项配置(JSON 格式文本)")
private String optionsJson;
/**
* 选项数据源类型:1-固定值,2-接口获取
*/
@Schema(description = "选项数据源类型:1-固定值,2-接口获取")
@Builder.Default
private Integer optionsSourceType = 1;
/**
* 校验规则(JSON 格式文本):{"min": 2, "max": 9, "regex": "..."}
*/
@Schema(description = "校验规则(JSON 格式文本)")
private String validationRules;
/**
* 可选项列表(JSON 格式文本)
*/
@Schema(description = "可选项列表(JSON 格式文本)")
private String options;
/**
* 是否支持"无此结构":0-否,1-是
*/
@Schema(description = "是否支持\"无此结构\":0-否,1-是")
@Builder.Default
private Integer allowNoStructure = 0;
/**
* 是否存在默认值:1-存在 0-不存在
*/
@Schema(description = "是否存在默认值:1-存在 0-不存在")
@Builder.Default
private String existsDefaultValue = "0";
/**
* 默认值(固定值)
*/
@Schema(description = "默认值(固定值)")
private String defaultValue;
/**
* 默认值(接口获取字段)
*/
@Schema(description = "默认值(接口获取字段)")
private String defaultField;
/**
* 默认值(表达式)
*/
@Schema(description = "默认值(表达式)")
private String defaultExpr;
/**
* 默认值类型:1-固定值,2-接口获取,3-表达式
*/
@Schema(description = "默认值类型:1-固定值,2-接口获取,3-表达式")
@Builder.Default
private Integer defaultType = 1;
/**
* 默认值配置(JSON 格式文本)
*/
@Schema(description = "默认值配置(JSON 格式文本)")
private String defaultConfig;
/**
* 最大上传数量
*/
@Schema(description = "最大上传数量")
@Builder.Default
private Integer maxCount = 1;
/**
* 拍摄要求说明
*/
@Schema(description = "拍摄要求说明")
private String captureRequirement;
/**
* 最大大小,单位 (KB)
*/
@Schema(description = "最大大小,单位 (KB)")
private Long maxKb;
/**
* 节点路径,如:/1/7/8/
*/
@Schema(description = "节点路径")
private String nodePath;
/**
* 节点层级,根节点为 0
*/
@Schema(description = "节点层级,根节点为 0")
@Builder.Default
private Integer nodeLevel = 0;
/**
* 同级排序号
*/
@Schema(description = "同级排序号")
@Builder.Default
private Integer sortOrder = 0;
/**
* 状态:0-禁用,1-启用
*/
@Schema(description = "状态:0-禁用,1-启用")
@Builder.Default
private Integer status = 1;
/**
* 备注
*/
@Schema(description = "备注")
private String remark;
/**
* 创建时间
*/
@Schema(description = "创建时间")
private LocalDateTime createTime;
@Schema(description = "失败数")
private Integer failNum;
@Schema(description = "成功数")
private Integer successNum;
@Schema(description = "无此结构数")
private Integer noStructureNum;
/**
* 更新时间
*/
@Schema(description = "更新时间")
private LocalDateTime updateTime;
@Schema(description = "检测项值,叶子节点才有")
private InspectionResultVO inspectionResultVO;
@Schema(description = "子节点列表")
private List<InspectionNodeDetailVO> childrenNodes;
}
package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.persistence.Column;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
......@@ -47,6 +48,9 @@ public class InspectionNodeVO implements Serializable {
@Builder.Default
private Long parentId = 0L;
@Schema(description = "节点代码")
private String nodeCode;
/**
* 节点名称
*/
......
......@@ -31,6 +31,10 @@ public class InspectionValueVO implements Serializable {
@Schema(description = "关联结果ID(inspection_result.id)")
private Long resultId;
/** 值对应的key */
@Schema(description = "值对应的key,不一定存在")
private String valueKey;
@Schema(description = "值内容(统一存储:文本/数字/日期/文件路径/JSON等)")
private String valueText;
......
package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotNull;
import jakarta.validation.constraints.Positive;
import jakarta.validation.constraints.Size;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import me.chanjar.weixin.common.annotation.Required;
import java.io.Serial;
import java.io.Serializable;
/**
* 更新检测师状态 VO
* @author yangwei
* @version 1.0
* @since 2026/03/19 09:40
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Schema(description = "更新检测师状态 VO")
public class UpdateInspectorStatusVO implements Serializable {
@Serial
private static final long serialVersionUID = 6880730705706357204L;
@Schema(description = "检测师ID", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "检测师ID不能为空")
@Positive(message = "检测师ID必须为正数")
private Long id;
@Schema(description = "检测师状态", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "检测师状态不能为空")
private Integer status;
@Schema(description = "禁用原因, 禁用时必填")
@Size(max = 256, message = "禁用原因长度不能超过{max}")
private String remark;
}
......@@ -6,6 +6,8 @@ import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.glsx.usedcar.consts.common.SymbolConsts;
import com.glsx.usedcar.consts.inspect.InspectConstants;
import com.glsx.usedcar.consts.inspect.ValidatorConstants;
import com.glsx.usedcar.module.inspect.dto.InspectionNodeDTO;
import com.glsx.usedcar.module.inspect.dto.InspectionResultDTO;
......@@ -307,13 +309,23 @@ public abstract class AbstractNodeValidator implements NodeValidator {
*/
protected ValidationResult validateOptions(List<String> values, InspectionNodeDTO node) {
String optionsStr = node.getOptions();
if (StrUtil.isBlank(optionsStr) || CollUtil.isEmpty(values)) {
// 如果是固定值存在值才进行校验
if (node.getOptionsSourceType() != InspectConstants.OPTION_DATA_TYPE_FIXED || StrUtil.isBlank(optionsStr) || CollUtil.isEmpty(values)) {
return ValidationResult.success();
}
List<String> validOptions;
try {
JSONArray arr = JSON.parseArray(optionsStr);
validOptions = arr.stream().map(Object::toString).toList();
validOptions = arr.stream().map(el -> {
String elStr = ObjectUtil.toString(el);
if (StrUtil.isNotBlank(elStr) && StrUtil.contains(elStr, SymbolConsts.HYPHEN)) {
List<String> split = StrUtil.split(elStr, SymbolConsts.HYPHEN);
if (split.size() > 1) {
elStr = split.get(1);
}
}
return elStr;
}).toList();
} catch (Exception e) {
log.warn("节点【{}】options 配置解析失败:{}", node.getNodeName(), optionsStr);
return ValidationResult.success();
......
......@@ -46,17 +46,22 @@ public class InspectionRecordController {
@PostMapping("/completeInspection")
@Operation(summary = "完成检测", description = "完成检测,全量检查所有必填选项")
public BaseResp<CompleteInspectionRespVO> completeInspection(@RequestBody @Valid CompleteInspectionVO req) {
CompleteInspectionRespVO result = inspectionRecordService.completeInspection(req);
return BaseResp.success(CompleteInspectionRespVO.builder().build(), "完成检测");
return BaseResp.success(inspectionRecordService.completeInspection(req), "完成检测");
}
@PostMapping("/{recordId}/detail")
/**
* 编写查询检测详情接口,根据检测记录id查询,检测节点还要统计根节点以及模块节点的正常数,故障数以及无此结构数量
* @author yangwei
* @since 2026/3/18 15:00
* @param recordId
* @return com.glsx.usedcar.resp.BaseResp<com.glsx.usedcar.module.inspect.vo.InspectionDetailRespVO>
*/
@GetMapping("/{recordId}/detail")
@Operation(summary = "详情", description = "检测详情")
public BaseResp<InspectionDetailRespVO> detail(
@PathVariable("recordId")
@Parameter(description = "检测记录id", required = true) Long recordId
) {
return BaseResp.success(InspectionDetailRespVO.builder().build(), "检测详情");
return BaseResp.success(inspectionRecordService.getInspectionDetail(recordId), "检测详情");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!