Commit 438c26d2 by 杨卫

feat:检测接口自测提交

1 parent 92530f15
...@@ -89,6 +89,7 @@ spring: ...@@ -89,6 +89,7 @@ spring:
message: message:
wechat-webhooks: wechat-webhooks:
- https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4934cd82-2879-4c97-ae8a-601c6febf0b0 - https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=4934cd82-2879-4c97-ae8a-601c6febf0b0
- https://qyapi.weixin.qq.com/cgi-bin/webhook/send?key=6ab14b47-ea51-426a-9c58-c41c602cf6f8
aliyun: aliyun:
oss: oss:
endpoint: oss-cn-shenzhen.aliyuncs.com endpoint: oss-cn-shenzhen.aliyuncs.com
......
...@@ -119,8 +119,11 @@ public class InspectionRecordService extends AbstractAuctionService { ...@@ -119,8 +119,11 @@ public class InspectionRecordService extends AbstractAuctionService {
// 3. 对比提交的节点数据以及节点配置:节点必须存在,且为叶子节点(nodeLevel=2) // 3. 对比提交的节点数据以及节点配置:节点必须存在,且为叶子节点(nodeLevel=2)
List<InspectionLeafNodeVO> leafNodes = CollUtil.emptyIfNull(req.getLeafNodes()).stream() List<InspectionLeafNodeVO> leafNodes = CollUtil.emptyIfNull(req.getLeafNodes()).stream()
.filter(leafNode -> CollUtil.isNotEmpty(leafNode.getData()) .filter(leafNode ->
(CollUtil.isNotEmpty(leafNode.getData())
&& leafNode.getData().stream().anyMatch(v -> StrUtil.isNotBlank(v.getValueText()))) && leafNode.getData().stream().anyMatch(v -> StrUtil.isNotBlank(v.getValueText())))
|| (leafNode.getResultStatus() == InspectConstants.RESULT_STATUS_NO_STRUCTURE)
)
.toList(); .toList();
for (InspectionLeafNodeVO leafNode : leafNodes) { for (InspectionLeafNodeVO leafNode : leafNodes) {
Long nodeId = leafNode.getNodeId(); Long nodeId = leafNode.getNodeId();
...@@ -478,8 +481,7 @@ public class InspectionRecordService extends AbstractAuctionService { ...@@ -478,8 +481,7 @@ public class InspectionRecordService extends AbstractAuctionService {
.filter(StrUtil::isNotBlank).orElse(StrUtil.EMPTY) .filter(StrUtil::isNotBlank).orElse(StrUtil.EMPTY)
)); ));
// todo 5. 更新施工单状态 inspectionWorkOrderService.completeInspection(taskId);
log.info("检测师完成检测成功,recordId: {}", record.getId()); log.info("检测师完成检测成功,recordId: {}", record.getId());
return CompleteInspectionRespVO.builder() return CompleteInspectionRespVO.builder()
.firstUncompletedNodeId(null) .firstUncompletedNodeId(null)
...@@ -626,14 +628,9 @@ public class InspectionRecordService extends AbstractAuctionService { ...@@ -626,14 +628,9 @@ public class InspectionRecordService extends AbstractAuctionService {
// 1. 查询检测记录 // 1. 查询检测记录
InspectionRecord record = inspectionRecordRepository.findByIdAndDeletedFlag(recordId, DeleteFlag.NOT_DELETED.getCode()) InspectionRecord record = inspectionRecordRepository.findByIdAndDeletedFlag(recordId, DeleteFlag.NOT_DELETED.getCode())
.orElseThrow(() -> new BusinessCodeException(ErrorCodeEnum.DATA_NOT_EXISTS, recordId, "检测记录")); .orElseThrow(() -> new BusinessCodeException(ErrorCodeEnum.DATA_NOT_EXISTS, recordId, "检测记录"));
Long taskId = record.getTaskId(); Long taskId = record.getTaskId();
// 2. 获取工单信息 // 3. 获取所有节点配置
InspectionWorkOrder workOrder = inspectionWorkOrderRepository.findByIdAndDeleteFlag(taskId, DeleteFlag.NOT_DELETED.getCode())
.orElseThrow(() -> new BusinessCodeException(ErrorCodeEnum.DATA_NOT_EXISTS, taskId, "检测工单"));
// 3. 获取所有节点配置(树形结构)
List<InspectionNodeVO> allNodes = inspectionNodeService.inspectionNodesByTaskId(taskId); List<InspectionNodeVO> allNodes = inspectionNodeService.inspectionNodesByTaskId(taskId);
// 4. 查询检测结果 // 4. 查询检测结果
......
package com.glsx.usedcar.module.inspect.vo; package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.NotBlank;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -34,6 +35,7 @@ public class InspectionLeafNodeDataVO implements Serializable { ...@@ -34,6 +35,7 @@ public class InspectionLeafNodeDataVO implements Serializable {
private String valueKey; private String valueKey;
@Schema(description = "交互类型,复合类型取子集") @Schema(description = "交互类型,复合类型取子集")
@NotBlank(message = "交互类型 不能为空")
private String interactionType; private String interactionType;
@Schema(description = "值序号,同一结果多条值时递") @Schema(description = "值序号,同一结果多条值时递")
......
package com.glsx.usedcar.module.inspect.vo; package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Data; import lombok.Data;
...@@ -26,17 +29,20 @@ public class InspectionLeafNodeVO implements Serializable { ...@@ -26,17 +29,20 @@ public class InspectionLeafNodeVO implements Serializable {
private static final long serialVersionUID = -5859350827159981915L; private static final long serialVersionUID = -5859350827159981915L;
@Schema(description = "节点 ID(inspection_node_version.nodeId,叶子节点)") @Schema(description = "节点 ID(inspection_node_version.nodeId,叶子节点)")
@NotNull(message = "节点 ID 不能为空")
private Long nodeId; private Long nodeId;
@Schema(description = "节点名称(快照)") @Schema(description = "节点名称(快照)")
@NotBlank(message = "节点名称不能为空")
private String nodeName; private String nodeName;
@Schema(description = "结果状态:1-正常,2-故障,3-无此结构") @Schema(description = "结果状态:1-正常,2-故障,3-无此结构")
@NotNull(message = "结果状态 不能为空")
private Integer resultStatus = 1; private Integer resultStatus = 1;
@Schema(description = "备注") @Schema(description = "备注")
private String remark; private String remark;
@Schema(description = "数据") @Schema(description = "数据")
private List<InspectionLeafNodeDataVO> data; private @Valid List<InspectionLeafNodeDataVO> data;
} }
package com.glsx.usedcar.module.inspect.vo; package com.glsx.usedcar.module.inspect.vo;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull; import jakarta.validation.constraints.NotNull;
import lombok.Data; import lombok.Data;
...@@ -50,7 +51,7 @@ public class InspectionSaveVO implements Serializable { ...@@ -50,7 +51,7 @@ public class InspectionSaveVO implements Serializable {
* 叶子节点数据列表,可以为空,为空表示都是正常的 * 叶子节点数据列表,可以为空,为空表示都是正常的
*/ */
@Schema(description = "叶子节点数据列表") @Schema(description = "叶子节点数据列表")
private List<InspectionLeafNodeVO> leafNodes; private @Valid List<InspectionLeafNodeVO> leafNodes;
} }
...@@ -57,8 +57,9 @@ public abstract class AbstractNodeValidator implements NodeValidator { ...@@ -57,8 +57,9 @@ public abstract class AbstractNodeValidator implements NodeValidator {
// 2. 必填校验(检查所有类型的值,不限于当前 interactionType) // 2. 必填校验(检查所有类型的值,不限于当前 interactionType)
if (node.getRequired() != null && node.getRequired() == InspectConstants.IS_REQUIRED_YES) { if (node.getRequired() != null && node.getRequired() == InspectConstants.IS_REQUIRED_YES) {
boolean hasAnyValue = CollUtil.isNotEmpty(result.getValues()) boolean hasAnyValue = (CollUtil.isNotEmpty(result.getValues())
&& result.getValues().stream().anyMatch(v -> StrUtil.isNotBlank(v.getValueText())); && result.getValues().stream().anyMatch(v -> StrUtil.isNotBlank(v.getValueText())))
|| result.getResultStatus() == InspectConstants.RESULT_STATUS_NO_STRUCTURE;
if (!hasAnyValue) { if (!hasAnyValue) {
return ValidationResult.error(String.format("【%s】为必填项,值不能为空", nodeName), nodeName); return ValidationResult.error(String.format("【%s】为必填项,值不能为空", nodeName), nodeName);
} }
......
package com.glsx.usedcar.validators.inspector; package com.glsx.usedcar.validators.inspector;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.glsx.usedcar.consts.common.DatePatternConsts; import com.glsx.usedcar.consts.common.DatePatternConsts;
import com.glsx.usedcar.module.inspect.dto.InspectionNodeDTO; import com.glsx.usedcar.module.inspect.dto.InspectionNodeDTO;
...@@ -318,7 +319,7 @@ public enum DataFormatValidator { ...@@ -318,7 +319,7 @@ public enum DataFormatValidator {
int decimalPartDigits = Math.max(number.scale(), 0); int decimalPartDigits = Math.max(number.scale(), 0);
// 校验整数位数 // 校验整数位数
if (integerPartDigits > integerDigits) { if (ObjectUtil.isNotNull(integerDigits) && integerPartDigits > integerDigits) {
return ValidationResult.error( return ValidationResult.error(
String.format("【%s】整数位不能超过%d位,当前%d位", nodeName, integerDigits, integerDigits), String.format("【%s】整数位不能超过%d位,当前%d位", nodeName, integerDigits, integerDigits),
nodeName, value nodeName, value
...@@ -326,7 +327,7 @@ public enum DataFormatValidator { ...@@ -326,7 +327,7 @@ public enum DataFormatValidator {
} }
// 校验小数位数 // 校验小数位数
if (decimalPartDigits > decimalDigits) { if (ObjectUtil.isNotNull(decimalDigits) && decimalPartDigits > decimalDigits) {
return ValidationResult.error( return ValidationResult.error(
String.format("【%s】小数位不能超过%d位,当前%d位", nodeName, decimalPartDigits, decimalDigits), String.format("【%s】小数位不能超过%d位,当前%d位", nodeName, decimalPartDigits, decimalDigits),
nodeName, value nodeName, value
...@@ -357,6 +358,7 @@ public enum DataFormatValidator { ...@@ -357,6 +358,7 @@ public enum DataFormatValidator {
return ValidationResult.success(); return ValidationResult.success();
} }
/** /**
* 计算日期格式对应的预期字符串长度 * 计算日期格式对应的预期字符串长度
* <p> * <p>
......
...@@ -42,8 +42,8 @@ public enum ErrorCodeEnum { ...@@ -42,8 +42,8 @@ public enum ErrorCodeEnum {
NODE_NOT_LEAF(1001102, "[{0}-{1}]不是叶子节点,无法保存检测值"), NODE_NOT_LEAF(1001102, "[{0}-{1}]不是叶子节点,无法保存检测值"),
NODE_CHECK_ERROR(1001103, "数据校验失败:{0}"), NODE_CHECK_ERROR(1001103, "数据校验失败:{0}"),
NOT_ABLE_INSPECT(1001104, "当前工单不允许检测"), NOT_ABLE_INSPECT(1001104, "当前工单无法提交检测"),
NODE_CHECK_RULE_ERROR(1001105, "[{0}]校验规则解析异常"), NODE_CHECK_RULE_ERROR(1001105, "【{0}】校验规则解析异常"),
; ;
private final Integer code; private final Integer code;
......
package com.glsx.usedcar.controller; package com.glsx.usedcar.controller;
import cn.hutool.core.map.MapUtil;
import com.glsx.usedcar.annotation.RequireLogin; import com.glsx.usedcar.annotation.RequireLogin;
import com.glsx.usedcar.module.inspect.service.InspectionRecordService; import com.glsx.usedcar.module.inspect.service.InspectionRecordService;
import com.glsx.usedcar.module.inspect.vo.CompleteInspectionRespVO; import com.glsx.usedcar.module.inspect.vo.CompleteInspectionRespVO;
...@@ -12,9 +13,13 @@ import io.swagger.v3.oas.annotations.Parameter; ...@@ -12,9 +13,13 @@ import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.Value;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Map;
/** /**
* 检测记录前端控制器 * 检测记录前端控制器
* @author yangwei * @author yangwei
...@@ -31,6 +36,7 @@ public class InspectionRecordController { ...@@ -31,6 +36,7 @@ public class InspectionRecordController {
private final InspectionRecordService inspectionRecordService; private final InspectionRecordService inspectionRecordService;
/** /**
* 保存检测工单(分步保存同一级的所有根节点) * 保存检测工单(分步保存同一级的所有根节点)
* *
...@@ -44,7 +50,6 @@ public class InspectionRecordController { ...@@ -44,7 +50,6 @@ public class InspectionRecordController {
return BaseResp.success(recordId, "保存成功"); return BaseResp.success(recordId, "保存成功");
} }
@PostMapping("/completeInspection") @PostMapping("/completeInspection")
@Operation(summary = "完成检测", description = "完成检测,全量检查所有必填选项") @Operation(summary = "完成检测", description = "完成检测,全量检查所有必填选项")
public BaseResp<CompleteInspectionRespVO> completeInspection(@RequestBody @Valid CompleteInspectionVO req) { public BaseResp<CompleteInspectionRespVO> completeInspection(@RequestBody @Valid CompleteInspectionVO req) {
......
package com.glsx.usedcar.module.inspect.service;
import cn.hutool.core.map.MapUtil;
import com.glsx.usedcar.module.inspect.vo.InspectionSaveVO;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import java.util.List;
import java.util.Map;
/**
* @author yangwei
* @version 1.0
* @since 2026/03/20 20:39
*/
@SpringBootTest
public class InspectionRecordServiceTest {
@Autowired
private InspectionRecordService inspectionRecordService;
@Test
public void testSaveInspection() {
// List<Long> secondModuleIds204 = List.of(205L, 206L, 207L, 208L, 209L, 210L, 211L, 212L, 213L, 214L, 215L, 216L, 217L, 218L, 219L, 220L, 221L, 222L, 223L, 224L, 225L, 226L, 227L);
// List<Long> secondModuleIds251 = List.of(252L, 253L, 254L, 255L, 256L, 257L, 258L, 259L);
// List<Long> secondModuleIds268 = List.of(269L, 270L, 271L, 272L, 273L, 274L, 275L, 276L, 277L, 278L, 279L, 280L, 281L, 282L, 283L, 284L, 285L, 286L, 287L);
// List<Long> secondModuleIds307 = List.of(308L, 309L, 310L, 311L, 312L, 313L, 314L, 315L, 316L, 317L, 318L, 319L);
// List<Long> secondModuleIds332 = List.of(333L, 334L, 335L, 336L, 337L, 338L, 339L, 340L, 341L, 342L, 343L);
// List<Long> secondModuleIds355 = List.of(356L, 357L, 358L, 359L, 360L, 361L, 362L, 363L, 364L, 365L, 366L, 367L, 368L, 369L, 370L, 371L, 372L, 373L, 374L, 375L, 376L, 377L, 378L, 379L, 380L);
// List<Long> secondModuleIds406 = List.of(407L, 408L, 409L, 410L, 411L, 412L, 413L, 414L, 415L, 416L, 417L, 418L, 419L, 420L, 421L, 422L, 423L, 424L, 425L);
// List<Long> secondModuleIds445 = List.of(446L, 447L, 448L, 449L, 450L, 451L, 452L, 453L, 454L);
// List<Long> secondModuleIds464 = List.of(465L, 466L, 467L, 468L, 469L, 470L, 471L, 472L, 473L, 474L, 475L, 476L, 477L, 478L, 479L, 480L, 481L, 482L, 483L, 484L, 485L, 486L, 487L);
// List<Long> secondModuleIds511 = List.of(512L, 513L, 514L, 515L, 516L, 517L, 518L, 519L, 520L, 521L, 522L, 523L, 524L, 525L, 526L, 527L);
// List<Long> secondModuleIds544 = List.of(545L, 546L, 547L);
// List<Long> secondModuleIds163 = List.of(164L/*, 165L, 166L, 167L, 168L, 169L, 170L, 171L, 172L, 173L, 174L, 175L, 176L, 177L, 178L, 179L, 180L, 181L, 182L, 183L*/);
Map<Long, List<Long>> firstModuleIds = MapUtil.<Long, List<Long>>builder()
// .put(204L, secondModuleIds204)
// .put(251L, secondModuleIds251)
// .put(268L, secondModuleIds268)
// .put(307L, secondModuleIds307)
// .put(332L, secondModuleIds332)
// .put(355L, secondModuleIds355)
// .put(406L, secondModuleIds406)
// .put(445L, secondModuleIds445)
// .put(464L, secondModuleIds464)
// .put(511L, secondModuleIds511)
// .put(544L, secondModuleIds544)
// .put(163L, secondModuleIds163)
.build();
for (Map.Entry<Long, List<Long>> longListEntry : firstModuleIds.entrySet()) {
Long key = longListEntry.getKey();
List<Long> value = longListEntry.getValue();
for (Long sub : value) {
InspectionSaveVO vo = new InspectionSaveVO();
vo.setTaskId(1L);
vo.setLocationModule(key);
vo.setLocationSubModule(sub);
inspectionRecordService.saveInspection(vo);
}
}
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!