parent
cbe77aeef3
commit
105e339464
|
@ -61,4 +61,5 @@ public class Message implements Serializable {
|
|||
public static final String WORK_SHIFT_NAME_EXIST = "班次名称已经存在";
|
||||
public static final String WORK_SHIFT_NOT_EXIST = "班次不存在";
|
||||
public static final String WORK_SHIFT_IS_NOT_UNPUBLISH = "班次的状态不是未发布";
|
||||
public static final String IMAGE_AUTO_MARK_ERROR = "自动标注出错:";
|
||||
}
|
||||
|
|
|
@ -23,9 +23,6 @@ public class DefectMarkReq implements Serializable {
|
|||
@ApiModelProperty("图片id")
|
||||
private String imageId;
|
||||
|
||||
@ApiModelProperty("图片集id")
|
||||
private String collectId;
|
||||
|
||||
@NotBlank(groups = {ValidationGroup.Request.class}, message = "模型id不能为空")
|
||||
@ApiModelProperty("模型id")
|
||||
private String modelId;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.dite.znpt.domain.bo.Detection;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
|
@ -51,6 +52,9 @@ public class DefectReq implements Serializable {
|
|||
@ApiModelProperty("标注信息")
|
||||
private String labelInfo;
|
||||
|
||||
@ApiModelProperty("标注信息")
|
||||
private Detection markInfo;
|
||||
|
||||
@ApiModelProperty("说明")
|
||||
private String description;
|
||||
|
||||
|
|
|
@ -1,16 +1,11 @@
|
|||
package com.dite.znpt.domain.vo;
|
||||
|
||||
import com.alibaba.excel.annotation.ExcelProperty;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author huise23
|
||||
|
@ -27,6 +22,9 @@ public class DefectResp extends DefectReq implements Serializable {
|
|||
@ApiModelProperty("缺陷id")
|
||||
private String defectId;
|
||||
|
||||
@ApiModelProperty("图像id")
|
||||
private String imageId;
|
||||
|
||||
@ApiModelProperty("缺陷类型描述")
|
||||
private String defectTypeLabel;
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ import java.util.List;
|
|||
*/
|
||||
@Getter
|
||||
public enum DefectTypeEnum {
|
||||
CRAZE("BMLW", "合缝开裂"),
|
||||
BMLW("bmlw", "表面裂纹"),
|
||||
ABRASION("ABRASION", "合缝磨损"),
|
||||
LEATHER_BREAKAGE("LEATHER_BREAKAGE", "蒙皮破损"),
|
||||
FABRIC_BREAKAGE("FABRIC_BREAKAGE", "布层破损"),
|
||||
|
|
|
@ -14,8 +14,7 @@ public enum FilePathEnum {
|
|||
IMAGE_TEMP("/static/image/temp/", "image-temp"),
|
||||
VIDEO("/static/video/", "video"),
|
||||
AUDIO("/static/audio/", "audio"),
|
||||
ATTACH("/static/attach/", "attach"),
|
||||
INSURANCE("/static/insurance/", "insurance");
|
||||
ATTACH("/static/attach/", "attach");
|
||||
|
||||
@Getter
|
||||
private final String urlPath;
|
||||
|
|
|
@ -13,19 +13,17 @@ import java.util.List;
|
|||
*/
|
||||
@Getter
|
||||
public enum ImageSourceEnum {
|
||||
COLLECT("collect", "图像采集", Boolean.TRUE),
|
||||
OUT_WORK("out-work", "外部工作", Boolean.TRUE),
|
||||
IN_WORK("in-work", "内部工作", Boolean.TRUE),
|
||||
LIGHTNING_PROTECTING_WORK("lightning-protection-work", "防雷工作", Boolean.FALSE);
|
||||
COLLECT("collect", "图像采集"),
|
||||
OUT_WORK("out-work", "外部工作"),
|
||||
IN_WORK("in-work", "内部工作"),
|
||||
LIGHTNING_PROTECTING_WORK("lightning-protection-work", "防雷工作");
|
||||
|
||||
private final String code;
|
||||
private final String desc;
|
||||
private final boolean isDefectImage;
|
||||
|
||||
ImageSourceEnum(String code, String desc, boolean isDefectImage){
|
||||
ImageSourceEnum(String code, String desc){
|
||||
this.code = code;
|
||||
this.desc = desc;
|
||||
this.isDefectImage = isDefectImage;
|
||||
}
|
||||
|
||||
public static ImageSourceEnum getByCode(String code){
|
||||
|
@ -42,15 +40,13 @@ public enum ImageSourceEnum {
|
|||
return null == e ? null : e.desc;
|
||||
}
|
||||
|
||||
public static List<JSONObject> list(Boolean isDefectImage){
|
||||
public static List<JSONObject> list(){
|
||||
List<JSONObject> list = new ArrayList<>(ImageSourceEnum.values().length);
|
||||
for (ImageSourceEnum e : ImageSourceEnum.values() ) {
|
||||
if(isDefectImage.equals(e.isDefectImage)){
|
||||
JSONObject jsonObject = new JSONObject();
|
||||
jsonObject.set(e.code, e.desc);
|
||||
list.add(jsonObject);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,10 +77,10 @@ public interface DefectService extends IService<DefectEntity> {
|
|||
* 功能描述:缺陷自动检测
|
||||
*
|
||||
* @param markReq 马克请求类
|
||||
* @return {@link DefectResp }
|
||||
* @return {@link List }<{@link DefectResp }>
|
||||
* @author cuizhibin
|
||||
* @date 2025/07/04 10:55
|
||||
* @date 2025/07/04 14:53
|
||||
**/
|
||||
DefectResp detect(DefectMarkReq markReq);
|
||||
List<DefectResp> detect(DefectMarkReq markReq);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
package com.dite.znpt.service.impl;
|
||||
|
||||
import ai.onnxruntime.OrtException;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
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.DefectEntity;
|
||||
import com.dite.znpt.domain.entity.ImageEntity;
|
||||
import com.dite.znpt.domain.vo.*;
|
||||
import com.dite.znpt.enums.DefectSourceEnum;
|
||||
import com.dite.znpt.enums.DefectTypeEnum;
|
||||
import com.dite.znpt.enums.RepairStatusEnum;
|
||||
import com.dite.znpt.enums.*;
|
||||
import com.dite.znpt.exception.ServiceException;
|
||||
import com.dite.znpt.mapper.DefectMapper;
|
||||
import com.dite.znpt.service.DefectService;
|
||||
|
@ -21,9 +23,11 @@ import org.springframework.stereotype.Service;
|
|||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
@ -51,12 +55,19 @@ public class DefectServiceImpl extends ServiceImpl<DefectMapper, DefectEntity> i
|
|||
@Override
|
||||
public List<DefectResp> page(DefectListReq req) {
|
||||
PageUtil.startPage();
|
||||
return this.list(req);
|
||||
List<DefectResp> list = this.list(req);
|
||||
list.forEach(defect -> {
|
||||
defect.setMarkInfo(JSONUtil.toBean(defect.getLabelInfo(), Detection.class));
|
||||
});
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DefectResp> list(DefectListReq req) {
|
||||
List<DefectResp> defectList= this.baseMapper.queryBySelective(req);
|
||||
defectList.forEach(defect -> {
|
||||
defect.setMarkInfo(JSONUtil.toBean(defect.getLabelInfo(), Detection.class));
|
||||
});
|
||||
return defectList;
|
||||
}
|
||||
|
||||
|
@ -72,9 +83,10 @@ public class DefectServiceImpl extends ServiceImpl<DefectMapper, DefectEntity> i
|
|||
public DefectResp detail(String defectId) {
|
||||
DefectResp defectResp = this.baseMapper.detail(defectId);
|
||||
defectResp.setDefectTypeLabel(DefectTypeEnum.getDescByCode(defectResp.getDefectType()));
|
||||
defectResp.setDefectLevel(DefectTypeEnum.getDescByCode(defectResp.getDefectLevel()));
|
||||
defectResp.setDefectLevel(DefectLevelEnum.getDescByCode(defectResp.getDefectLevel()));
|
||||
defectResp.setRepairStatusLabel(RepairStatusEnum.getDescByCode(defectResp.getRepairStatus()));
|
||||
defectResp.setSourceLabel(DefectSourceEnum.getDescByCode(defectResp.getSourceLabel()));
|
||||
defectResp.setMarkInfo(JSONUtil.toBean(defectResp.getLabelInfo(), Detection.class));
|
||||
return defectResp;
|
||||
}
|
||||
|
||||
|
@ -94,6 +106,7 @@ public class DefectServiceImpl extends ServiceImpl<DefectMapper, DefectEntity> i
|
|||
}
|
||||
DefectEntity defectEntity = Converts.INSTANCE.toDefectEntity(req);
|
||||
defectEntity.setImageId(imageId);
|
||||
defectEntity.setLabelInfo(JSONUtil.toJsonStr(req.getMarkInfo()));
|
||||
this.save(defectEntity);
|
||||
}
|
||||
|
||||
|
@ -115,6 +128,7 @@ public class DefectServiceImpl extends ServiceImpl<DefectMapper, DefectEntity> i
|
|||
if(imageMap.containsKey(key)){
|
||||
DefectEntity defectEntity = Converts.INSTANCE.toDefectEntity(req);
|
||||
defectEntity.setImageId(imageMap.get(key).getImageId());
|
||||
defectEntity.setLabelInfo(JSONUtil.toJsonStr(req.getMarkInfo()));
|
||||
defectEntityList.add(defectEntity);
|
||||
}
|
||||
});
|
||||
|
@ -137,6 +151,7 @@ public class DefectServiceImpl extends ServiceImpl<DefectMapper, DefectEntity> i
|
|||
throw new ServiceException(Message.DEFECT_ID_IS_NOT_EXIST);
|
||||
}
|
||||
DefectEntity defectEntity = Converts.INSTANCE.toDefectEntity(req);
|
||||
defectEntity.setLabelInfo(JSONUtil.toJsonStr(req.getMarkInfo()));
|
||||
this.updateById(defectEntity);
|
||||
}
|
||||
|
||||
|
@ -157,13 +172,38 @@ public class DefectServiceImpl extends ServiceImpl<DefectMapper, DefectEntity> i
|
|||
* 功能描述:缺陷自动检测
|
||||
*
|
||||
* @param markReq 马克请求类
|
||||
* @return {@link DefectResp }
|
||||
* @return {@link List }<{@link DefectResp }>
|
||||
* @author cuizhibin
|
||||
* @date 2025/07/04 10:55
|
||||
**/
|
||||
@Override
|
||||
public DefectResp detect(DefectMarkReq markReq) {
|
||||
// multiModelYoloService.runFolderDetection();
|
||||
return null;
|
||||
public List<DefectResp> detect(DefectMarkReq markReq) {
|
||||
ImageEntity image = imageService.getById(markReq.getImageId());
|
||||
if (Objects.isNull(image)) {
|
||||
throw new ServiceException(Message.IMAGE_ID_IS_NOT_EXIST);
|
||||
}
|
||||
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));
|
||||
try {
|
||||
List<Detection> detect = multiModelYoloService.detect(markReq.getModelId(), inputPath, outputPath, markReq.getConfThreshold());
|
||||
List<DefectResp> respList = new ArrayList<>();
|
||||
for (Detection detection : detect) {
|
||||
DefectResp resp = new DefectResp();
|
||||
resp.setImageId(markReq.getImageId());
|
||||
resp.setDefectType(detection.getLabel());
|
||||
resp.setDefectTypeLabel(DefectTypeEnum.getDescByCode(detection.getLabel()));
|
||||
resp.setDetectionDate(LocalDate.now());
|
||||
resp.setSource(DefectSourceEnum.AI.getCode());
|
||||
resp.setSourceLabel(DefectSourceEnum.AI.getDesc());
|
||||
resp.setMarkInfo(detection);
|
||||
resp.setRepairStatus(RepairStatusEnum.INCOMPLETE.getCode());
|
||||
resp.setRepairStatusLabel(RepairStatusEnum.INCOMPLETE.getDesc());
|
||||
respList.add(resp);
|
||||
}
|
||||
return respList;
|
||||
} catch (OrtException e) {
|
||||
throw new ServiceException(Message.IMAGE_AUTO_MARK_ERROR + e.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -148,7 +148,7 @@ public class ImageServiceImpl extends ServiceImpl<ImageMapper, ImageEntity> impl
|
|||
temCategory.mkdirs();
|
||||
}
|
||||
String temPathPrefix = FilePathEnum.IMAGE_TEMP.getFileAbsolutePathPrefix().concat(imageSource).concat(FileUtil.FILE_SEPARATOR).concat(partId).concat(FileUtil.FILE_SEPARATOR);
|
||||
ImageCollectEntity imageCollect = BeanUtil.copyProperties(collectReq, ImageCollectEntity.class);
|
||||
ImageCollectEntity imageCollect = Optional.ofNullable(BeanUtil.copyProperties(collectReq, ImageCollectEntity.class)).orElse(new ImageCollectEntity());
|
||||
imageCollect.setCollectId(IdUtil.simpleUUID());
|
||||
List<ImageEntity> imageList = new ArrayList<>();
|
||||
for (MultipartFile file : files) {
|
||||
|
|
|
@ -90,7 +90,7 @@ public class CommonController {
|
|||
@ApiOperation(value = "查询通用图片来源", httpMethod = "GET")
|
||||
@GetMapping("/list/common-image-source")
|
||||
public Result<?> listCommonImageSource(){
|
||||
return Result.ok(ImageSourceEnum.list(Boolean.FALSE));
|
||||
return Result.ok(ImageSourceEnum.list());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "查询学历", httpMethod = "GET")
|
||||
|
|
|
@ -68,8 +68,8 @@ public class DefectController {
|
|||
}
|
||||
|
||||
@ApiOperation(value = "单图自动标注缺陷", httpMethod = "POST")
|
||||
@PostMapping("/run")
|
||||
public Result<DefectResp> runBatch(@Validated(ValidationGroup.Request.class) @RequestBody DefectMarkReq markReq) {
|
||||
@PostMapping("/detect")
|
||||
public Result<List<DefectResp>> runBatch(@Validated(ValidationGroup.Request.class) @RequestBody DefectMarkReq markReq) {
|
||||
return Result.ok(defectService.detect(markReq));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ package com.dite.znpt.web.controller;
|
|||
import com.dite.znpt.domain.PageResult;
|
||||
import com.dite.znpt.domain.Result;
|
||||
import com.dite.znpt.domain.vo.*;
|
||||
import com.dite.znpt.enums.ImageSourceEnum;
|
||||
import com.dite.znpt.service.ImageCollectService;
|
||||
import com.dite.znpt.service.ImageService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
@ -60,7 +59,7 @@ public class ImageController {
|
|||
@PostMapping("/{imageSource}/upload/{partId}")
|
||||
public Result<String> uploadOutWork(@PathVariable String imageSource, @PathVariable String partId, ImageCollectReq collectReq, @RequestParam("file") MultipartFile file) {
|
||||
MultipartFile[] files = {file};
|
||||
return Result.ok(imageService.batchUploadDefectImage(partId, ImageSourceEnum.OUT_WORK.getCode(), collectReq, files).get(0).getImagePath());
|
||||
return Result.ok(imageService.batchUploadDefectImage(partId, imageSource, collectReq, files).get(0).getImagePath());
|
||||
}
|
||||
|
||||
@ApiOperation(value = "设置信息", httpMethod = "POST")
|
||||
|
|
|
@ -8,7 +8,7 @@ spring:
|
|||
datasource:
|
||||
type: com.alibaba.druid.pool.DruidDataSource
|
||||
driverClassName: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://39.99.201.243:3306/test?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
url: jdbc:mysql://39.99.201.243:3306/znpt_dev?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
|
||||
username: root
|
||||
password: BUw8YW6%@^8q
|
||||
druid:
|
||||
|
|
Loading…
Reference in New Issue