|
@ -1,6 +1,7 @@ |
|
|
package com.jiagutech.service; |
|
|
package com.jiagutech.service; |
|
|
|
|
|
|
|
|
import cn.dev33.satoken.stp.StpUtil; |
|
|
import cn.dev33.satoken.stp.StpUtil; |
|
|
|
|
|
import cn.hutool.core.collection.CollectionUtil; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.EasyExcel; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
import com.alibaba.excel.util.MapUtils; |
|
|
import com.alibaba.excel.util.MapUtils; |
|
@ -16,6 +17,8 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
|
|
import com.jiagutech.client.RecognitionModelClient; |
|
|
import com.jiagutech.client.RecognitionModelClient; |
|
|
|
|
|
import com.jiagutech.common.exception.BizCode; |
|
|
|
|
|
import com.jiagutech.common.exception.BusinessException; |
|
|
import com.jiagutech.dto.*; |
|
|
import com.jiagutech.dto.*; |
|
|
import com.jiagutech.dto.common.LoginUser; |
|
|
import com.jiagutech.dto.common.LoginUser; |
|
|
import com.jiagutech.dto.common.PageRequest; |
|
|
import com.jiagutech.dto.common.PageRequest; |
|
@ -35,6 +38,8 @@ 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.jiagutech.utils.LoginUtil; |
|
|
import com.jiagutech.utils.LoginUtil; |
|
|
|
|
|
import com.jiagutech.utils.RecognitionUtil; |
|
|
|
|
|
import jdk.nashorn.internal.ir.IfNode; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.RequiredArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
|
|
import org.apache.poi.ss.usermodel.HorizontalAlignment; |
|
@ -76,8 +81,17 @@ public class RecordServiceImpl implements RecordService { |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 同时处理的任务数小于等于8个 |
|
|
|
|
|
* |
|
|
|
|
|
* @param request |
|
|
|
|
|
* @return |
|
|
|
|
|
*/ |
|
|
@Override |
|
|
@Override |
|
|
public String createRecordAsync(CreateRecordRequest request) { |
|
|
public String createRecordAsync(CreateRecordRequest request) { |
|
|
|
|
|
if (RecordTaskManager.taskCount() >= 9) { |
|
|
|
|
|
throw new BusinessException(BizCode.SERVER_BUSY); |
|
|
|
|
|
} |
|
|
String taskId = UUID.randomUUID().toString(); |
|
|
String taskId = UUID.randomUUID().toString(); |
|
|
RecordTaskHandler recordTaskHandler = new RecordTaskHandler(customThreadPool, taskProcessor, tmpPath); |
|
|
RecordTaskHandler recordTaskHandler = new RecordTaskHandler(customThreadPool, taskProcessor, tmpPath); |
|
|
recordTaskHandler.createTask(request, taskId); |
|
|
recordTaskHandler.createTask(request, taskId); |
|
@ -142,8 +156,13 @@ public class RecordServiceImpl implements RecordService { |
|
|
List<ModelPredictResponse> recognitionData = record.getRecognitionData(); |
|
|
List<ModelPredictResponse> recognitionData = record.getRecognitionData(); |
|
|
Scale scaleDto = record.getScale(); |
|
|
Scale scaleDto = record.getScale(); |
|
|
//把识别数据进行分类
|
|
|
//把识别数据进行分类
|
|
|
float size = scaleDto.getSize(); |
|
|
|
|
|
int scale = scaleDto.getScale(); |
|
|
|
|
|
|
|
|
float size = 0; |
|
|
|
|
|
int scale = 0; |
|
|
|
|
|
if (scaleDto != null) { |
|
|
|
|
|
size = scaleDto.getSize(); |
|
|
|
|
|
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) { |
|
@ -191,11 +210,13 @@ public class RecordServiceImpl implements RecordService { |
|
|
} |
|
|
} |
|
|
//创建单元格的合并策略, 前7列数据需要合并
|
|
|
//创建单元格的合并策略, 前7列数据需要合并
|
|
|
for (int i = 0; i <= 6; i++) { |
|
|
for (int i = 0; i <= 6; i++) { |
|
|
OnceAbsoluteMergeStrategy mergeStrategy = new OnceAbsoluteMergeStrategy( |
|
|
|
|
|
startRowIndex, |
|
|
|
|
|
endRowIndex, |
|
|
|
|
|
i, i); |
|
|
|
|
|
mergeStrategies.add(mergeStrategy); |
|
|
|
|
|
|
|
|
if (endRowIndex > startRowIndex) { |
|
|
|
|
|
OnceAbsoluteMergeStrategy mergeStrategy = new OnceAbsoluteMergeStrategy( |
|
|
|
|
|
startRowIndex, |
|
|
|
|
|
endRowIndex, |
|
|
|
|
|
i, i); |
|
|
|
|
|
mergeStrategies.add(mergeStrategy); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
startRowIndex += len; |
|
|
startRowIndex += len; |
|
@ -294,6 +315,30 @@ public class RecordServiceImpl implements RecordService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void updateRecordContent(RecordContentEntity recordContentEntity) { |
|
|
public void updateRecordContent(RecordContentEntity recordContentEntity) { |
|
|
|
|
|
if (CollectionUtil.isNotEmpty(recordContentEntity.getRecognitionData())) { |
|
|
|
|
|
int handleNum = 0; |
|
|
|
|
|
int rapeNum = 0; |
|
|
|
|
|
int beakNum = 0; |
|
|
|
|
|
for (ModelPredictResponse item : recordContentEntity.getRecognitionData()) { |
|
|
|
|
|
if (item.getLength() == null || item.getLength() == 0) { |
|
|
|
|
|
item.setLength(RecognitionUtil.getMaxLength(item.getPoints())); |
|
|
|
|
|
} |
|
|
|
|
|
switch (item.getClassify()) { |
|
|
|
|
|
case 0: |
|
|
|
|
|
rapeNum++; |
|
|
|
|
|
break; |
|
|
|
|
|
case 1: |
|
|
|
|
|
beakNum++; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
handleNum++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
recordContentEntity.setHandleNum(handleNum) |
|
|
|
|
|
.setBeakNum(beakNum) |
|
|
|
|
|
.setSiliquaNum(rapeNum); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
recordContentMapper.updateById(recordContentEntity); |
|
|
recordContentMapper.updateById(recordContentEntity); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -314,9 +359,10 @@ public class RecordServiceImpl implements RecordService { |
|
|
own.setScale(request.getScale()); |
|
|
own.setScale(request.getScale()); |
|
|
own.setScaleType(request.getScaleType()); |
|
|
own.setScaleType(request.getScaleType()); |
|
|
own.setId(request.getRecordContentId()); |
|
|
own.setId(request.getRecordContentId()); |
|
|
other = new RecordContentEntity().setScale(request.getScale()); |
|
|
|
|
|
|
|
|
other = new RecordContentEntity().setScaleType(3).setScale(request.getScale()); |
|
|
queryWrapper.eq("record_id", request.getRecordId()); |
|
|
queryWrapper.eq("record_id", request.getRecordId()); |
|
|
queryWrapper.eq("scale_type", 3); |
|
|
|
|
|
|
|
|
queryWrapper.in("scale_type", 0, 1, 3); |
|
|
|
|
|
queryWrapper.ne("id", request.getRecordContentId()); |
|
|
break; |
|
|
break; |
|
|
case 2: |
|
|
case 2: |
|
|
own = recordContentMapper.selectById(request.getRecordContentId()); |
|
|
own = recordContentMapper.selectById(request.getRecordContentId()); |
|
@ -330,14 +376,16 @@ public class RecordServiceImpl implements RecordService { |
|
|
break; |
|
|
break; |
|
|
case 3: |
|
|
case 3: |
|
|
default: |
|
|
default: |
|
|
own = new RecordContentEntity().setScaleType(3); |
|
|
|
|
|
queryWrapper.eq("record_id", request.getRecordId()); |
|
|
queryWrapper.eq("record_id", request.getRecordId()); |
|
|
queryWrapper.eq("scale_type", 1); |
|
|
queryWrapper.eq("scale_type", 1); |
|
|
RecordContentEntity recordContentEntity = recordContentMapper.selectOne(queryWrapper); |
|
|
RecordContentEntity recordContentEntity = recordContentMapper.selectOne(queryWrapper); |
|
|
if (recordContentEntity != null) { |
|
|
if (recordContentEntity != null) { |
|
|
|
|
|
own = new RecordContentEntity().setScaleType(3); |
|
|
own.setScale(recordContentEntity.getScale()); |
|
|
own.setScale(recordContentEntity.getScale()); |
|
|
|
|
|
own.setId(request.getRecordContentId()); |
|
|
|
|
|
} else { |
|
|
|
|
|
throw new BusinessException(BizCode.General_Failure, "当前无统一的比例尺"); |
|
|
} |
|
|
} |
|
|
own.setId(request.getRecordContentId()); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
recordContentMapper.updateById(own); |
|
|
recordContentMapper.updateById(own); |
|
@ -380,4 +428,5 @@ public class RecordServiceImpl implements RecordService { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|