|
@@ -3,24 +3,26 @@ package com.fdkankan.scene.service.impl;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
import cn.hutool.core.lang.UUID;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
import com.fdkankan.scene.entity.SceneMarkShape;
|
|
|
-import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
-import com.fdkankan.scene.mapper.IScenePlusExtMapper;
|
|
|
import com.fdkankan.scene.mapper.MarkShapeMapper;
|
|
|
import com.fdkankan.scene.service.ISceneMarkShapeService;
|
|
|
-import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
import com.fdkankan.scene.util.ConverxyUtil;
|
|
|
import com.fdkankan.scene.vo.SceneMarkShapeParamVO;
|
|
|
+import com.fdkankan.scene.vo.SceneMarkShapeReDetectParamVO;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -37,6 +39,67 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
@Service
|
|
|
public class SceneMarkShapeServiceImpl extends ServiceImpl<MarkShapeMapper, SceneMarkShape> implements ISceneMarkShapeService {
|
|
|
+ @Autowired
|
|
|
+ private RabbitMqProducer rabbitMqProducer;
|
|
|
+ @Value("${queue.scene.yolov5-re-detect-queue}")
|
|
|
+ private String yolov5ReDetectQueue;
|
|
|
+ @Value("${main.url}")
|
|
|
+ private String mainUrl;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void editReDetectStatus(SceneMarkShapeParamVO param) {
|
|
|
+ SceneMarkShape byNumAndImagePath = findByNumAndImagePath(param.getNum(), param.getImagePath());
|
|
|
+ if (ObjectUtil.isNotNull(byNumAndImagePath)){
|
|
|
+ byNumAndImagePath.setReDetect(0);
|
|
|
+ byNumAndImagePath.setToDetect(1);
|
|
|
+ updateById(byNumAndImagePath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SceneMarkShape> findByReDetectStatus(Integer reDetect){
|
|
|
+ LambdaQueryWrapper<SceneMarkShape> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.eq(SceneMarkShape::getReDetect,reDetect);
|
|
|
+ return list(wrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<SceneMarkShape> findByToDetectStatus(Integer toDetect) {
|
|
|
+ QueryWrapper queryWrapper = new QueryWrapper();
|
|
|
+ queryWrapper.select("DISTINCT num")
|
|
|
+ .eq("to_detect",toDetect) ;
|
|
|
+ return getBaseMapper().selectList(queryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void reDetectScene(SceneMarkShapeReDetectParamVO param) {
|
|
|
+ //查询需要重新训练的图片
|
|
|
+ List<SceneMarkShape> reDetectStatuList = findByReDetectStatus(1);
|
|
|
+ for (SceneMarkShape shape : reDetectStatuList) {
|
|
|
+ SceneMarkShapeReDetectParamVO paramVO=new SceneMarkShapeReDetectParamVO();
|
|
|
+ paramVO.setWebSite(mainUrl);
|
|
|
+ if (StrUtil.isNotEmpty(param.getSaveDir())){
|
|
|
+ paramVO.setSaveDir(param.getSaveDir());
|
|
|
+ }
|
|
|
+ paramVO.setNum(shape.getNum());
|
|
|
+ paramVO.setImagePath(shape.getImagePath());
|
|
|
+ paramVO.setDetectType(1);
|
|
|
+ rabbitMqProducer.sendByWorkQueue(yolov5ReDetectQueue,paramVO);
|
|
|
+ }
|
|
|
+ //查询需要进入训练的场景
|
|
|
+ List<SceneMarkShape> byToDetectStatus = findByToDetectStatus(0);
|
|
|
+ for (SceneMarkShape shape : byToDetectStatus) {
|
|
|
+ SceneMarkShapeReDetectParamVO paramVO=new SceneMarkShapeReDetectParamVO();
|
|
|
+ paramVO.setWebSite(mainUrl);
|
|
|
+ if (StrUtil.isNotEmpty(param.getSaveDir())){
|
|
|
+ paramVO.setSaveDir(param.getSaveDir());
|
|
|
+ }
|
|
|
+ paramVO.setNum(shape.getNum());
|
|
|
+ paramVO.setDetectType(2);
|
|
|
+ rabbitMqProducer.sendByWorkQueue(yolov5ReDetectQueue,paramVO);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public ResultData editLabelByFile(String num, String imgPath, MultipartFile file) throws IOException {
|
|
|
|