From a0b239f34e0265c6f4eb5a66199e2f5fc396bfc1 Mon Sep 17 00:00:00 2001 From: cuizhibin Date: Fri, 4 Jul 2025 16:09:58 +0800 Subject: [PATCH] =?UTF-8?q?1.=E7=BC=BA=E9=99=B7=E6=89=8B=E5=8A=A8=E6=A0=87?= =?UTF-8?q?=E6=B3=A8=E4=BF=AE=E6=94=B9=EF=BC=8C=E5=A2=9E=E5=8A=A0=E7=BC=BA?= =?UTF-8?q?=E9=99=B7=E6=A0=87=E6=B3=A8=E5=9B=BE=E7=89=87=E9=99=84=E4=BB=B6?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/dite/znpt/domain/vo/DefectReq.java | 3 +++ .../com/dite/znpt/domain/vo/DefectResp.java | 3 +++ .../znpt/enums/AttachBusinessTypeEnum.java | 1 + .../znpt/service/impl/DefectServiceImpl.java | 21 ++++++++++++++++++- 4 files changed, 27 insertions(+), 1 deletion(-) diff --git a/core/src/main/java/com/dite/znpt/domain/vo/DefectReq.java b/core/src/main/java/com/dite/znpt/domain/vo/DefectReq.java index c4a45cd..d07b6c0 100644 --- a/core/src/main/java/com/dite/znpt/domain/vo/DefectReq.java +++ b/core/src/main/java/com/dite/znpt/domain/vo/DefectReq.java @@ -60,4 +60,7 @@ public class DefectReq implements Serializable { @ApiModelProperty("维修建议") private String repairIdea; + + @ApiModelProperty("附件id") + private String attachId; } diff --git a/core/src/main/java/com/dite/znpt/domain/vo/DefectResp.java b/core/src/main/java/com/dite/znpt/domain/vo/DefectResp.java index 4ff545f..e2efbde 100644 --- a/core/src/main/java/com/dite/znpt/domain/vo/DefectResp.java +++ b/core/src/main/java/com/dite/znpt/domain/vo/DefectResp.java @@ -37,5 +37,8 @@ public class DefectResp extends DefectReq implements Serializable { @ApiModelProperty("来源描述") private String sourceLabel; + @ApiModelProperty("缺陷附件路径") + private String attachPath; + } diff --git a/core/src/main/java/com/dite/znpt/enums/AttachBusinessTypeEnum.java b/core/src/main/java/com/dite/znpt/enums/AttachBusinessTypeEnum.java index 502a022..096af63 100644 --- a/core/src/main/java/com/dite/znpt/enums/AttachBusinessTypeEnum.java +++ b/core/src/main/java/com/dite/znpt/enums/AttachBusinessTypeEnum.java @@ -16,6 +16,7 @@ public enum AttachBusinessTypeEnum { PROJECT_TASK("PROJECT_TASK", "项目任务"), INSURANCE_FILE("insurance", "保险文件"), MODEL_FILE("model", "模型文件"), + DEFECT_MARK_PIC("defect_mark_pic", "缺陷标注图片"), ; private final String code; private final String desc; diff --git a/core/src/main/java/com/dite/znpt/service/impl/DefectServiceImpl.java b/core/src/main/java/com/dite/znpt/service/impl/DefectServiceImpl.java index 8bc2ad5..c30661b 100644 --- a/core/src/main/java/com/dite/znpt/service/impl/DefectServiceImpl.java +++ b/core/src/main/java/com/dite/znpt/service/impl/DefectServiceImpl.java @@ -1,6 +1,7 @@ package com.dite.znpt.service.impl; import ai.onnxruntime.OrtException; +import cn.hutool.core.collection.ListUtil; import cn.hutool.core.io.FileUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; @@ -8,12 +9,14 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.dite.znpt.constant.Message; import com.dite.znpt.converts.Converts; import com.dite.znpt.domain.bo.Detection; +import com.dite.znpt.domain.entity.AttachInfoEntity; import com.dite.znpt.domain.entity.DefectEntity; import com.dite.znpt.domain.entity.ImageEntity; import com.dite.znpt.domain.vo.*; import com.dite.znpt.enums.*; import com.dite.znpt.exception.ServiceException; import com.dite.znpt.mapper.DefectMapper; +import com.dite.znpt.service.AttachInfoService; import com.dite.znpt.service.DefectService; import com.dite.znpt.service.ImageService; import com.dite.znpt.util.PageUtil; @@ -43,6 +46,8 @@ public class DefectServiceImpl extends ServiceImpl i private ImageService imageService; @Autowired private MultiModelYoloService multiModelYoloService; + @Autowired + private AttachInfoService attachInfoService; /** * 功能描述:查询缺陷记录列表 @@ -107,6 +112,7 @@ public class DefectServiceImpl extends ServiceImpl i DefectEntity defectEntity = Converts.INSTANCE.toDefectEntity(req); defectEntity.setImageId(imageId); defectEntity.setLabelInfo(JSONUtil.toJsonStr(req.getMarkInfo())); + attachInfoService.updateBusinessIdByAttachIds(defectEntity.getImageId(), ListUtil.of(req.getAttachId()), AttachBusinessTypeEnum.DEFECT_MARK_PIC); this.save(defectEntity); } @@ -153,6 +159,7 @@ public class DefectServiceImpl extends ServiceImpl i DefectEntity defectEntity = Converts.INSTANCE.toDefectEntity(req); defectEntity.setLabelInfo(JSONUtil.toJsonStr(req.getMarkInfo())); this.updateById(defectEntity); + attachInfoService.updateBusinessIdByAttachIds(defectEntity.getImageId(), ListUtil.of(req.getAttachId()), AttachBusinessTypeEnum.DEFECT_MARK_PIC); } /** @@ -177,6 +184,7 @@ public class DefectServiceImpl extends ServiceImpl i * @date 2025/07/04 10:55 **/ @Override + @Transactional(rollbackFor = Exception.class) public List detect(DefectMarkReq markReq) { ImageEntity image = imageService.getById(markReq.getImageId()); if (Objects.isNull(image)) { @@ -184,7 +192,16 @@ public class DefectServiceImpl extends ServiceImpl i } FilePathEnum pathEnum = image.getImagePath().contains("temp") ? FilePathEnum.IMAGE_TEMP : FilePathEnum.IMAGE; String inputPath = pathEnum.getFileAbsolutePath(image.getImagePath()); - String outputPath = FileUtil.getParent(inputPath, 1).concat(FileUtil.mainName(inputPath)+"_mark").concat(StrUtil.DOT).concat(FileUtil.extName(inputPath)); +// 写入attach同层级文件夹下 + String attachPath = FilePathEnum.ATTACH.getUrlPath() + StrUtil.removePrefix(image.getImagePath(), pathEnum.getUrlPath()); + String outputPath = FilePathEnum.ATTACH.getFileAbsolutePath(attachPath); + FileUtil.mkParentDirs(outputPath); + + AttachInfoEntity attachInfo = new AttachInfoEntity(); + attachInfo.setBusinessId(image.getImageId()); + attachInfo.setAttachPath(attachPath); + attachInfo.setBusinessType(AttachBusinessTypeEnum.DEFECT_MARK_PIC.getCode()); + attachInfoService.save(attachInfo); try { List detect = multiModelYoloService.detect(markReq.getModelId(), inputPath, outputPath, markReq.getConfThreshold()); List respList = new ArrayList<>(); @@ -199,6 +216,8 @@ public class DefectServiceImpl extends ServiceImpl i resp.setMarkInfo(detection); resp.setRepairStatus(RepairStatusEnum.INCOMPLETE.getCode()); resp.setRepairStatusLabel(RepairStatusEnum.INCOMPLETE.getDesc()); + resp.setAttachId(attachInfo.getAttachId()); + resp.setAttachPath(attachPath); respList.add(resp); } return respList;