Browse Source

角果识别后台

master
zhangyeguang 4 weeks ago
parent
commit
a2e4adc706
  1. 1
      src/main/java/com/jiagutech/common/exception/BizCode.java
  2. 12
      src/main/java/com/jiagutech/controller/RecordController.java
  3. 10
      src/main/java/com/jiagutech/dto/Scale.java
  4. 19
      src/main/java/com/jiagutech/dto/UpdateScaleRequest.java
  5. 8
      src/main/java/com/jiagutech/entity/RecordContentEntity.java
  6. 6
      src/main/java/com/jiagutech/service/RecordService.java
  7. 55
      src/main/java/com/jiagutech/service/RecordServiceImpl.java
  8. 3
      src/main/resources/application.yml
  9. 6
      src/main/resources/mapper/RecordContentMapper.xml

1
src/main/java/com/jiagutech/common/exception/BizCode.java

@ -48,6 +48,7 @@ public enum BizCode implements CodeInterface {
USER_PHONE_EXIST(40012, "用户手机号已存在"), USER_PHONE_EXIST(40012, "用户手机号已存在"),
; ;

12
src/main/java/com/jiagutech/controller/RecordController.java

@ -1,13 +1,10 @@
package com.jiagutech.controller; package com.jiagutech.controller;
import cn.hutool.core.map.MapUtil; import cn.hutool.core.map.MapUtil;
import com.jiagutech.dto.CreateRecordRequest;
import com.jiagutech.dto.RecordItem;
import com.jiagutech.dto.RecordModel;
import com.jiagutech.dto.*;
import com.jiagutech.dto.common.PageRequest; import com.jiagutech.dto.common.PageRequest;
import com.jiagutech.dto.common.PageResult; import com.jiagutech.dto.common.PageResult;
import com.jiagutech.dto.common.R; import com.jiagutech.dto.common.R;
import com.jiagutech.dto.RecordDetail;
import com.jiagutech.entity.RecordContentEntity; import com.jiagutech.entity.RecordContentEntity;
import com.jiagutech.service.RecordService; import com.jiagutech.service.RecordService;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
@ -73,4 +70,11 @@ public class RecordController {
public R<RecordModel> getModels() { public R<RecordModel> getModels() {
return R.ok(recordService.getModels()); return R.ok(recordService.getModels());
} }
@ApiOperation(value = "比例尺设置")
@PutMapping("/scale")
public void updateScale( @RequestBody UpdateScaleRequest request) {
recordService.updateScale(request);
}
} }

10
src/main/java/com/jiagutech/dto/Scale.java

@ -0,0 +1,10 @@
package com.jiagutech.dto;
import lombok.Data;
@Data
public class Scale {
private int scale;
private float size;
private int[][] points;
}

19
src/main/java/com/jiagutech/dto/UpdateScaleRequest.java

@ -0,0 +1,19 @@
package com.jiagutech.dto;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@Data
@ApiModel("更新比例尺")
public class UpdateScaleRequest {
@ApiModelProperty("记录id")
private long recordId;
@ApiModelProperty("记录内容id")
private long recordContentId;
@ApiModelProperty("比例尺类型,1=统一、2=自用、3=延用")
private int scaleType;
@ApiModelProperty("比例尺")
private Scale scale;
}

8
src/main/java/com/jiagutech/entity/RecordContentEntity.java

@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler; import com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler;
import com.jiagutech.dto.ModelPredictResponse; import com.jiagutech.dto.ModelPredictResponse;
import com.jiagutech.dto.Scale;
import lombok.Data; import lombok.Data;
import lombok.experimental.Accessors; import lombok.experimental.Accessors;
@ -31,10 +32,11 @@ public class RecordContentEntity {
private int handleNum; private int handleNum;
private int beakNum; private int beakNum;
private int size;
//比例尺类型 ,1=统一/2=自用/3=延用/0=无
private int scaleType;
//比例 //比例
private int scale;
@TableField(typeHandler = JacksonTypeHandler.class)
private Scale scale;
private float conf; private float conf;

6
src/main/java/com/jiagutech/service/RecordService.java

@ -1,9 +1,6 @@
package com.jiagutech.service; package com.jiagutech.service;
import com.jiagutech.dto.CreateRecordRequest;
import com.jiagutech.dto.RecordDetail;
import com.jiagutech.dto.RecordItem;
import com.jiagutech.dto.RecordModel;
import com.jiagutech.dto.*;
import com.jiagutech.dto.common.PageRequest; import com.jiagutech.dto.common.PageRequest;
import com.jiagutech.dto.common.PageResult; import com.jiagutech.dto.common.PageResult;
import com.jiagutech.entity.RecordContentEntity; import com.jiagutech.entity.RecordContentEntity;
@ -30,4 +27,5 @@ public interface RecordService {
RecordModel getModels(); RecordModel getModels();
void updateScale(UpdateScaleRequest request);
} }

55
src/main/java/com/jiagutech/service/RecordServiceImpl.java

@ -26,6 +26,7 @@ import com.jiagutech.mapper.RecordMapper;
import com.jiagutech.record.RecordTaskHandler; import com.jiagutech.record.RecordTaskHandler;
import com.jiagutech.record.RecordTaskManager; import com.jiagutech.record.RecordTaskManager;
import com.jiagutech.record.RecordTaskProcessor; import com.jiagutech.record.RecordTaskProcessor;
import com.sun.xml.bind.v2.TODO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows; import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@ -33,6 +34,8 @@ import org.apache.commons.math3.analysis.function.Max;
import org.apache.poi.ss.usermodel.HorizontalAlignment; import org.apache.poi.ss.usermodel.HorizontalAlignment;
import org.apache.poi.ss.usermodel.VerticalAlignment; import org.apache.poi.ss.usermodel.VerticalAlignment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.validation.BindException;
import org.springframework.web.multipart.MultipartFile; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter; import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
@ -128,9 +131,10 @@ public class RecordServiceImpl implements RecordService {
List<Float> handleLenList = new ArrayList<>(); List<Float> handleLenList = new ArrayList<>();
List<ModelPredictResponse> recognitionData = record.getRecognitionData(); List<ModelPredictResponse> recognitionData = record.getRecognitionData();
int size = record.getSize();
int scale = record.getScale();
Scale scaleDto = record.getScale();
//把识别数据进行分类 //把识别数据进行分类
float size = scaleDto.getSize();
int scale = scaleDto.getScale();
for (ModelPredictResponse item : recognitionData) { for (ModelPredictResponse item : recognitionData) {
float len; float len;
if (size > 0 && scale > 0) { if (size > 0 && scale > 0) {
@ -161,7 +165,7 @@ public class RecordServiceImpl implements RecordService {
contentExcel.setBeakNum(record.getBeakNum()); contentExcel.setBeakNum(record.getBeakNum());
contentExcel.setRapeNum(record.getSiliquaNum()); contentExcel.setRapeNum(record.getSiliquaNum());
contentExcel.setHandleNum(record.getHandleNum()); contentExcel.setHandleNum(record.getHandleNum());
contentExcel.setScale(record.getScale());
contentExcel.setScale(scale);
contentExcel.setConf(record.getConf()); contentExcel.setConf(record.getConf());
contentExcel.setIou(record.getIou()); contentExcel.setIou(record.getIou());
//需要合并的列结束 //需要合并的列结束
@ -283,4 +287,49 @@ public class RecordServiceImpl implements RecordService {
public RecordModel getModels() { public RecordModel getModels() {
return recognitionModelClient.models(); return recognitionModelClient.models();
} }
@Override
@Transactional
public void updateScale(UpdateScaleRequest request) {
QueryWrapper<RecordContentEntity> queryWrapper = Wrappers.query();
RecordContentEntity own = null;
RecordContentEntity other = null;
switch (request.getScaleType()) {
case 1:
own = new RecordContentEntity();
own.setScale(request.getScale());
own.setScaleType(request.getScaleType());
own.setId(request.getRecordContentId());
other = new RecordContentEntity().setScale(request.getScale());
queryWrapper.eq("record_id", request.getRecordId());
queryWrapper.eq("scale_type", 3);
break;
case 2:
own = recordContentMapper.selectById(request.getRecordContentId());
if (own.getScaleType() == 1) {
queryWrapper.eq("record_id", own.getRecordId());
queryWrapper.eq("scale_type", 3);
other = new RecordContentEntity().setScaleType(0).setScale(null);
}
own.setScale(request.getScale());
own.setScaleType(request.getScaleType());
break;
case 3:
default:
own = new RecordContentEntity().setScaleType(3);
queryWrapper.eq("record_id", request.getRecordId());
queryWrapper.eq("scale_type", 1);
RecordContentEntity recordContentEntity = recordContentMapper.selectOne(queryWrapper);
if (recordContentEntity != null) {
own.setScale(recordContentEntity.getScale());
}
own.setId(request.getRecordContentId());
}
recordContentMapper.updateById(own);
if (other != null) {
recordContentMapper.update(other, queryWrapper);
}
}
} }

3
src/main/resources/application.yml

@ -51,6 +51,9 @@ mybatis-plus:
configuration: configuration:
map-underscore-to-camel-case: true map-underscore-to-camel-case: true
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
global-config:
db-config:
update-strategy: not_null
recognition: recognition:
model: model:

6
src/main/resources/mapper/RecordContentMapper.xml

@ -12,7 +12,11 @@
<result column="siliqua_num" property="siliquaNum"/> <result column="siliqua_num" property="siliquaNum"/>
<result column="handle_num" property="handleNum"/> <result column="handle_num" property="handleNum"/>
<result column="beak_num" property="beakNum"/> <result column="beak_num" property="beakNum"/>
<result column="scale_type" property="scaleType"/>
<result column="scale" property="scale" javaType="com.jiagutech.dto.Scale"
typeHandler="com.baomidou.mybatisplus.extension.handlers.JacksonTypeHandler"/>
<result column="conf" property="conf"/>
<result column="iou" property="iou"/>
</resultMap> </resultMap>
<select id="selectListByRecordId" resultMap="RecordContentMap"> <select id="selectListByRecordId" resultMap="RecordContentMap">
select * select *

Loading…
Cancel
Save