diff --git a/src/main/java/com/jiagutech/common/exception/BizCode.java b/src/main/java/com/jiagutech/common/exception/BizCode.java index 1ebe4a3..f52eb80 100644 --- a/src/main/java/com/jiagutech/common/exception/BizCode.java +++ b/src/main/java/com/jiagutech/common/exception/BizCode.java @@ -48,6 +48,7 @@ public enum BizCode implements CodeInterface { USER_PHONE_EXIST(40012, "用户手机号已存在"), + ; diff --git a/src/main/java/com/jiagutech/controller/RecordController.java b/src/main/java/com/jiagutech/controller/RecordController.java index a7ef1f2..38d99b3 100644 --- a/src/main/java/com/jiagutech/controller/RecordController.java +++ b/src/main/java/com/jiagutech/controller/RecordController.java @@ -1,13 +1,10 @@ package com.jiagutech.controller; 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.PageResult; import com.jiagutech.dto.common.R; -import com.jiagutech.dto.RecordDetail; import com.jiagutech.entity.RecordContentEntity; import com.jiagutech.service.RecordService; import io.swagger.annotations.Api; @@ -49,7 +46,7 @@ public class RecordController { return R.ok(recordService.getRecordDetail(recordId)); } - @ApiOperation(value = "导出识别记录",notes = "下载文件(响应类型为文件流)") + @ApiOperation(value = "导出识别记录", notes = "下载文件(响应类型为文件流)") @GetMapping(value = "/export/{recordId}", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) public void exportRecord(@PathVariable Long recordId, HttpServletResponse response) { recordService.exportRecord(recordId, response); @@ -73,4 +70,11 @@ public class RecordController { public R getModels() { return R.ok(recordService.getModels()); } + + @ApiOperation(value = "比例尺设置") + @PutMapping("/scale") + public void updateScale( @RequestBody UpdateScaleRequest request) { + recordService.updateScale(request); + } + } diff --git a/src/main/java/com/jiagutech/dto/Scale.java b/src/main/java/com/jiagutech/dto/Scale.java new file mode 100644 index 0000000..4f4abaa --- /dev/null +++ b/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; +} diff --git a/src/main/java/com/jiagutech/dto/UpdateScaleRequest.java b/src/main/java/com/jiagutech/dto/UpdateScaleRequest.java new file mode 100644 index 0000000..1f89b11 --- /dev/null +++ b/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; + +} diff --git a/src/main/java/com/jiagutech/entity/RecordContentEntity.java b/src/main/java/com/jiagutech/entity/RecordContentEntity.java index c958476..b7bb7b9 100644 --- a/src/main/java/com/jiagutech/entity/RecordContentEntity.java +++ b/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.extension.handlers.JacksonTypeHandler; import com.jiagutech.dto.ModelPredictResponse; +import com.jiagutech.dto.Scale; import lombok.Data; import lombok.experimental.Accessors; @@ -31,10 +32,11 @@ public class RecordContentEntity { private int handleNum; 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; diff --git a/src/main/java/com/jiagutech/service/RecordService.java b/src/main/java/com/jiagutech/service/RecordService.java index bb8c631..49223d3 100644 --- a/src/main/java/com/jiagutech/service/RecordService.java +++ b/src/main/java/com/jiagutech/service/RecordService.java @@ -1,9 +1,6 @@ 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.PageResult; import com.jiagutech.entity.RecordContentEntity; @@ -30,4 +27,5 @@ public interface RecordService { RecordModel getModels(); + void updateScale(UpdateScaleRequest request); } diff --git a/src/main/java/com/jiagutech/service/RecordServiceImpl.java b/src/main/java/com/jiagutech/service/RecordServiceImpl.java index 1dc0c4a..b1d9060 100644 --- a/src/main/java/com/jiagutech/service/RecordServiceImpl.java +++ b/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.RecordTaskManager; import com.jiagutech.record.RecordTaskProcessor; +import com.sun.xml.bind.v2.TODO; import lombok.RequiredArgsConstructor; import lombok.SneakyThrows; 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.VerticalAlignment; 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.servlet.mvc.method.annotation.SseEmitter; @@ -128,9 +131,10 @@ public class RecordServiceImpl implements RecordService { List handleLenList = new ArrayList<>(); List 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) { float len; if (size > 0 && scale > 0) { @@ -161,7 +165,7 @@ public class RecordServiceImpl implements RecordService { contentExcel.setBeakNum(record.getBeakNum()); contentExcel.setRapeNum(record.getSiliquaNum()); contentExcel.setHandleNum(record.getHandleNum()); - contentExcel.setScale(record.getScale()); + contentExcel.setScale(scale); contentExcel.setConf(record.getConf()); contentExcel.setIou(record.getIou()); //需要合并的列结束 @@ -283,4 +287,49 @@ public class RecordServiceImpl implements RecordService { public RecordModel getModels() { return recognitionModelClient.models(); } + + @Override + @Transactional + public void updateScale(UpdateScaleRequest request) { + QueryWrapper 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); + } + + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 825cdb9..40152b5 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -51,6 +51,9 @@ mybatis-plus: configuration: map-underscore-to-camel-case: true log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + global-config: + db-config: + update-strategy: not_null recognition: model: diff --git a/src/main/resources/mapper/RecordContentMapper.xml b/src/main/resources/mapper/RecordContentMapper.xml index 274b36a..5fa6830 100644 --- a/src/main/resources/mapper/RecordContentMapper.xml +++ b/src/main/resources/mapper/RecordContentMapper.xml @@ -12,7 +12,11 @@ - + + + +