Commit c75479df by 章家宝

feat:获取工单详情接口兼容报告id输入

1 parent 757757a2
...@@ -185,7 +185,7 @@ public class InspectionWorkOrderExportBean implements Serializable { ...@@ -185,7 +185,7 @@ public class InspectionWorkOrderExportBean implements Serializable {
// 基础信息 // 基础信息
if (vehicle.getBaseInfo() != null) { if (vehicle.getBaseInfo() != null) {
this.sourceNo = vehicle.getBaseInfo().getSourceNo(); this.sourceNo = vehicle.getBaseInfo().getSourceNo();
this.carTypeName = vehicle.getBaseInfo().getCarTypeName(); this.carTypeName = vehicle.getBaseInfo().getCarSeriesName() + " " + vehicle.getBaseInfo().getCarTypeName();
this.vin = vehicle.getBaseInfo().getVin(); this.vin = vehicle.getBaseInfo().getVin();
this.licensePlate = vehicle.getBaseInfo().getLicensePlate(); this.licensePlate = vehicle.getBaseInfo().getLicensePlate();
} else { } else {
......
...@@ -119,11 +119,11 @@ public class InspectionWorkOrderController { ...@@ -119,11 +119,11 @@ public class InspectionWorkOrderController {
@Operation(summary = "获取检测工单详情", description = "获取检测工单详情") @Operation(summary = "获取检测工单详情", description = "获取检测工单详情")
@GetMapping("/detail/{id}") @PostMapping("/detail")
public BaseResp<InspectionWODetailRespVO> detail(@PathVariable("id") Long id) { public BaseResp<InspectionWODetailRespVO> detail(@RequestBody InspectionWorkOrderDetailReqVO reqVO) {
log.info("获取检测工单详情: {}", id); log.info("获取检测工单详情: {} {}", reqVO.getWorkOrderId(), reqVO.getReportId());
try { try {
InspectionWODetailRespVO result = inspectionWorkOrderService.detail(id); InspectionWODetailRespVO result = inspectionWorkOrderService.detail(reqVO);
return BaseResp.success(result); return BaseResp.success(result);
} catch (Exception e) { } catch (Exception e) {
log.error("获取检测工单详情失败!系统异常!", e); log.error("获取检测工单详情失败!系统异常!", e);
......
package com.glsx.usedcar.converts; package com.glsx.usedcar.converts;
import com.glsx.usedcar.module.inspect.entity.InspectionReportOpLog;
import com.glsx.usedcar.module.inspect.entity.InspectionWorkOrderOpLog; import com.glsx.usedcar.module.inspect.entity.InspectionWorkOrderOpLog;
import com.glsx.usedcar.module.inspect.vo.InspectionWOOpLogRespVo; import com.glsx.usedcar.module.inspect.vo.InspectionWOOpLogRespVo;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
...@@ -17,6 +18,8 @@ public interface InspectionWorkOrderOpLogConverter { ...@@ -17,6 +18,8 @@ public interface InspectionWorkOrderOpLogConverter {
*/ */
InspectionWOOpLogRespVo inspectionWorkOrderOpLogMapRespVO(InspectionWorkOrderOpLog log); InspectionWOOpLogRespVo inspectionWorkOrderOpLogMapRespVO(InspectionWorkOrderOpLog log);
InspectionWOOpLogRespVo inspectionReportOpLogMapRespVO(InspectionReportOpLog log);
/** /**
* 多个实体转换为VO * 多个实体转换为VO
* *
...@@ -25,5 +28,6 @@ public interface InspectionWorkOrderOpLogConverter { ...@@ -25,5 +28,6 @@ public interface InspectionWorkOrderOpLogConverter {
*/ */
List<InspectionWOOpLogRespVo> inspectionWorkOrderOpLogMapRespVO(List<InspectionWorkOrderOpLog> list); List<InspectionWOOpLogRespVo> inspectionWorkOrderOpLogMapRespVO(List<InspectionWorkOrderOpLog> list);
List<InspectionWOOpLogRespVo> inspectionReportOpLogMapRespVO(List<InspectionReportOpLog> list);
} }
...@@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit; ...@@ -44,6 +44,7 @@ import java.util.concurrent.TimeUnit;
public class InspectionWorkOrderService { public class InspectionWorkOrderService {
private final InspectionWorkOrderRepository inspectionWorkOrderRepository; private final InspectionWorkOrderRepository inspectionWorkOrderRepository;
private final InspectionWorkOrderOpLogRepository inspectionWorkOrderOpLogRepository; private final InspectionWorkOrderOpLogRepository inspectionWorkOrderOpLogRepository;
private final InspectionReportOpLogRepository inspectionReportOpLogRepository;
private final RedisCacheUtil redisCacheUtil; private final RedisCacheUtil redisCacheUtil;
private final InspectionWorkOrderConverter inspectionWorkOrderConverter; private final InspectionWorkOrderConverter inspectionWorkOrderConverter;
private final InspectionWorkOrderOpLogConverter inspectionWorkOrderOpLogConverter; private final InspectionWorkOrderOpLogConverter inspectionWorkOrderOpLogConverter;
...@@ -419,33 +420,50 @@ public class InspectionWorkOrderService { ...@@ -419,33 +420,50 @@ public class InspectionWorkOrderService {
} }
public InspectionWODetailRespVO detail(Long id) { public InspectionWODetailRespVO detail(InspectionWorkOrderDetailReqVO reqVO) {
InspectionWorkOrder wo = inspectionWorkOrderRepository.findByIdAndDeleteFlag(id, DeleteFlag.NOT_DELETED.getCode()).orElse(null); if (reqVO.getWorkOrderId() != null) {
if (wo == null) { Long id = reqVO.getWorkOrderId();
throw new BusinessCodeException(ErrorCodeEnum.PARAM_ERROR, "工单没有找到"); InspectionWorkOrder wo = inspectionWorkOrderRepository.findByIdAndDeleteFlag(id, DeleteFlag.NOT_DELETED.getCode()).orElse(null);
} if (wo == null) {
InspectionReport report = inspectionReportRepository.findByWoIdAndDeleteFlag(wo.getWoId(), DeleteFlag.NOT_DELETED.getCode()).orElse(null); throw new BusinessCodeException(ErrorCodeEnum.PARAM_ERROR, "工单没有找到");
InspectionReportRespVO inspectionReportRespVO = inspectionReportConverter.inspectionReportMapRespVO(report); }
InspectionWORespVO inspectionWORespVO = inspectionWorkOrderConverter.inspectorMapRespVO(wo); InspectionReport report = inspectionReportRepository.findByWoIdAndDeleteFlag(wo.getWoId(), DeleteFlag.NOT_DELETED.getCode()).orElse(null);
List<InspectionWorkOrderOpLog> logList = inspectionWorkOrderOpLogRepository.findByWorkOrderInnerIdAndDeleteFlagOrderByIdDesc(wo.getId(), DeleteFlag.NOT_DELETED.getCode()); InspectionReportRespVO inspectionReportRespVO = inspectionReportConverter.inspectionReportMapRespVO(report);
List<InspectionWOOpLogRespVo> inspectionWOOpLogRespVos = inspectionWorkOrderOpLogConverter.inspectionWorkOrderOpLogMapRespVO(logList); InspectionWORespVO inspectionWORespVO = inspectionWorkOrderConverter.inspectorMapRespVO(wo);
InspectionWODetailRespVO result = new InspectionWODetailRespVO(); List<InspectionWorkOrderOpLog> logList = inspectionWorkOrderOpLogRepository.findByWorkOrderInnerIdAndDeleteFlagOrderByIdDesc(wo.getId(), DeleteFlag.NOT_DELETED.getCode());
result.setInspectionWORespVO(inspectionWORespVO); List<InspectionWOOpLogRespVo> inspectionWOOpLogRespVos = inspectionWorkOrderOpLogConverter.inspectionWorkOrderOpLogMapRespVO(logList);
result.setLogList(inspectionWOOpLogRespVos); InspectionWODetailRespVO result = new InspectionWODetailRespVO();
if (wo.getStatus().equals(InspectionWorkOrderStatusEnum.COMPLETED.getCode()) && wo.getAuditStatus().equals(InspectionWorkOrderAuditStatusEnum.WAIT_AUDIT.getCode())) { result.setInspectionWORespVO(inspectionWORespVO);
inspectionReportRespVO = new InspectionReportRespVO(); result.setLogList(inspectionWOOpLogRespVos);
// 拼接一个默认报告 if (wo.getStatus().equals(InspectionWorkOrderStatusEnum.COMPLETED.getCode()) && wo.getAuditStatus().equals(InspectionWorkOrderAuditStatusEnum.WAIT_AUDIT.getCode())) {
InspectionRecord inspectionRecord = inspectionRecordRepository.findByTaskIdAndDeletedFlag(wo.getId(), DeleteFlag.NOT_DELETED.getCode()) inspectionReportRespVO = new InspectionReportRespVO();
.orElseThrow(() -> new BusinessCodeException(ErrorCodeEnum.COMMON_ERROR, "检测记录不存在,ID:" + wo.getId())); // 拼接一个默认报告
String h5Url = String.format(inspectorConfig.getInspectionRecordH5Url(), inspectionRecord.getId()); InspectionRecord inspectionRecord = inspectionRecordRepository.findByTaskIdAndDeletedFlag(wo.getId(), DeleteFlag.NOT_DELETED.getCode())
inspectionReportRespVO.setH5Url(h5Url); .orElseThrow(() -> new BusinessCodeException(ErrorCodeEnum.COMMON_ERROR, "检测记录不存在,ID:" + wo.getId()));
} String h5Url = String.format(inspectorConfig.getInspectionRecordH5Url(), inspectionRecord.getId());
if (inspectionReportRespVO != null) { inspectionReportRespVO.setH5Url(h5Url);
}
if (inspectionReportRespVO != null) {
result.setInspectionReportRespVO(inspectionReportRespVO);
}
List<InspectionNodeSummaryDTO> nodeVOList = inspectionNodeService.summaryLeafNodes(id);
result.setNodeVOList(nodeVOList);
return result;
} else {
Long reportId = reqVO.getReportId();
InspectionReport report = inspectionReportRepository.findByIdAndDeleteFlag(reportId, DeleteFlag.NOT_DELETED.getCode()).orElse(null);
InspectionWorkOrder wo = report.getWorkOrder();
List<InspectionReportOpLog> logList = inspectionReportOpLogRepository.findByReportInnerIdAndDeleteFlag(reportId, DeleteFlag.NOT_DELETED.getCode());
List<InspectionNodeSummaryDTO> nodeVOList = inspectionNodeService.summaryLeafNodes(wo.getId());
InspectionWODetailRespVO result = new InspectionWODetailRespVO();
InspectionWORespVO inspectionWORespVO = inspectionWorkOrderConverter.inspectorMapRespVO(wo);
result.setInspectionWORespVO(inspectionWORespVO);
result.setNodeVOList(nodeVOList);
InspectionReportRespVO inspectionReportRespVO = inspectionReportConverter.inspectionReportMapRespVO(report);
result.setInspectionReportRespVO(inspectionReportRespVO); result.setInspectionReportRespVO(inspectionReportRespVO);
result.setLogList(inspectionWorkOrderOpLogConverter.inspectionReportOpLogMapRespVO(logList));
return result;
} }
List<InspectionNodeSummaryDTO> nodeVOList = inspectionNodeService.summaryLeafNodes(id);
result.setNodeVOList(nodeVOList);
return result;
} }
...@@ -726,4 +744,15 @@ public class InspectionWorkOrderService { ...@@ -726,4 +744,15 @@ public class InspectionWorkOrderService {
return countVO; return countVO;
} }
/**
* 获取工单H5地址
* @param id 工单ID
* @return 工单H5地址
*/
public String getH5Url(Long id) {
// 拼接一个默认报告
InspectionRecord inspectionRecord = inspectionRecordRepository.findByTaskIdAndDeletedFlag(id, DeleteFlag.NOT_DELETED.getCode())
.orElseThrow(() -> new BusinessCodeException(ErrorCodeEnum.COMMON_ERROR, "检测记录不存在,ID:" + id));
return String.format(inspectorConfig.getInspectionRecordH5Url(), inspectionRecord.getId());
}
} }
\ No newline at end of file \ No newline at end of file
package com.glsx.usedcar.module.inspect.vo;
import lombok.Data;
/**
*
*/
@Data
public class InspectionWorkOrderDetailReqVO {
private Long workOrderId;
private Long reportId;
}
...@@ -61,6 +61,19 @@ public class InspectionWorkOrderController { ...@@ -61,6 +61,19 @@ public class InspectionWorkOrderController {
return BaseResp.fail("分页查询检测工单失败:" + e.getMessage()); return BaseResp.fail("分页查询检测工单失败:" + e.getMessage());
} }
} }
@Operation(summary = "根据id获取h5地址", description = "根据id获取h5地址")
@GetMapping("/getH5Url/{id}")
public BaseResp<String> getH5Url(@PathVariable("id") Long id) {
try {
log.info("根据id获取h5地址请求: id={}", id);
String result = inspectionWorkOrderService.getH5Url(id);
return BaseResp.success(result);
} catch (Exception e) {
log.error("分页查询检测工单失败!系统异常!", e);
return BaseResp.fail("分页查询检测工单失败:" + e.getMessage());
}
}
/** /**
* 获取检测工单详情 * 获取检测工单详情
...@@ -73,7 +86,9 @@ public class InspectionWorkOrderController { ...@@ -73,7 +86,9 @@ public class InspectionWorkOrderController {
public BaseResp<InspectionWODetailRespVO> getDetail(@PathVariable("id") Long id) { public BaseResp<InspectionWODetailRespVO> getDetail(@PathVariable("id") Long id) {
log.info("获取检测工单详情: id={}", id); log.info("获取检测工单详情: id={}", id);
try { try {
InspectionWODetailRespVO result = inspectionWorkOrderService.detail(id); InspectionWorkOrderDetailReqVO reqVO = new InspectionWorkOrderDetailReqVO();
reqVO.setWorkOrderId(id);
InspectionWODetailRespVO result = inspectionWorkOrderService.detail(reqVO);
return BaseResp.success(result); return BaseResp.success(result);
} catch (Exception e) { } catch (Exception e) {
log.error("获取检测工单详情失败!系统异常!", e); log.error("获取检测工单详情失败!系统异常!", e);
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!