master
周文涛 2 years ago
parent 6d6ae664ef
commit 03eed5fa84

@ -1,5 +1,7 @@
package org.jeecg.common.constant;
import java.util.Arrays;
import java.util.List;
import java.util.Random;
/**
@ -27,8 +29,6 @@ public class OcrConstant {
/**
* Api
*/
public static String api_test_identify_url="http://47.103.213.109:8071/aitest/semantic";
public static String api_test2_identify_url="http://127.0.0.1:7003/semantic";
//public static String api_test2_identify_url="http://127.0.0.1:8000/semantic";
@ -41,6 +41,12 @@ public class OcrConstant {
*/
public static String FILE_REVIEW_URL_PREFIX="http://47.103.213.109:8072/files";
//目前仅支持的字段
public static List<String> SUPPORTED_FIELDS= Arrays.asList("hospitalName","doctor_name","departmentName","time");
//目前仅支持的字段中文名
public static List<String> SUPPORTED_FIELD_NAMES= Arrays.asList("医院名称","医生名称","科室","时间");
public static void main(String[] args) {
for (int i = 0; i < 100; i++) {
System.out.println(new Random().nextInt(10));

@ -11,10 +11,10 @@ import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.modules.ocr.entity.OcrApiCallStatistics;
import org.jeecg.modules.ocr.service.IOcrApiCallStatisticsService;
import org.jeecg.modules.ocr.vo.CommonQueryVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
@ -30,35 +30,25 @@ import java.util.Arrays;
@RequestMapping("/ocrApiCallStatistics")
@Slf4j
public class OcrApiCallStatisticsController extends JeecgController<OcrApiCallStatistics, IOcrApiCallStatisticsService> {
@Autowired
@Resource
private IOcrApiCallStatisticsService ocrApiCallStatisticsService;
/**
*
*
* @param commonQueryVO
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "api调用统计-分页列表查询")
@ApiOperation(value="api调用统计-分页列表查询", notes="api调用统计-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<OcrApiCallStatistics>> queryPageList(CommonQueryVO commonQueryVO,
@RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
Page<OcrApiCallStatistics> page = new Page<OcrApiCallStatistics>(pageNo, pageSize);
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize) {
Page<OcrApiCallStatistics> page = new Page<>(pageNo, pageSize);
IPage<OcrApiCallStatistics> pageList = ocrApiCallStatisticsService.pageList(page, commonQueryVO);
return Result.OK(pageList);
}
/**
*
*
* @param ocrApiCallStatistics
* @return
*/
@AutoLog(value = "api调用统计-添加")
@ApiOperation(value="api调用统计-添加", notes="api调用统计-添加")
@ -71,9 +61,6 @@ public class OcrApiCallStatisticsController extends JeecgController<OcrApiCallSt
/**
*
*
* @param ocrApiCallStatistics
* @return
*/
@AutoLog(value = "api调用统计-编辑")
@ApiOperation(value="api调用统计-编辑", notes="api调用统计-编辑")
@ -86,44 +73,35 @@ public class OcrApiCallStatisticsController extends JeecgController<OcrApiCallSt
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "api调用统计-通过id删除")
@ApiOperation(value="api调用统计-通过id删除", notes="api调用统计-通过id删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_api_call_statistics:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
public Result<String> delete(@RequestParam(name="id") String id) {
ocrApiCallStatisticsService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "api调用统计-批量删除")
@ApiOperation(value="api调用统计-批量删除", notes="api调用统计-批量删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_api_call_statistics:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
public Result<String> deleteBatch(@RequestParam(name="ids") String ids) {
this.ocrApiCallStatisticsService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "api调用统计-通过id查询")
@ApiOperation(value="api调用统计-通过id查询", notes="api调用统计-通过id查询")
@GetMapping(value = "/queryById")
public Result<OcrApiCallStatistics> queryById(@RequestParam(name="id",required=true) String id) {
public Result<OcrApiCallStatistics> queryById(@RequestParam(name="id") String id) {
OcrApiCallStatistics ocrApiCallStatistics = ocrApiCallStatisticsService.getById(id);
if(ocrApiCallStatistics==null) {
return Result.error("未找到对应数据");
@ -133,9 +111,6 @@ public class OcrApiCallStatisticsController extends JeecgController<OcrApiCallSt
/**
* excel
*
* @param request
* @param ocrApiCallStatistics
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_api_call_statistics:exportXls")
@RequestMapping(value = "/exportXls")
@ -144,10 +119,6 @@ public class OcrApiCallStatisticsController extends JeecgController<OcrApiCallSt
}
/**
* excel
*
* @param request
* @param response
* @return
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_api_call_statistics:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)

@ -1,37 +0,0 @@
package org.jeecg.modules.ocr.controller;
import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.AssertUtils;
import org.jeecg.modules.ocr.service.IOcrApiCallStatisticsService;
import org.jeecg.modules.ocr.service.IOcrIdentifyService;
import org.jeecg.modules.ocr.service.IOcrRuleCheckService;
import org.jeecg.modules.ocr.service.IOcrTaskTypeService;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @Description
* @Author ZhouWenTao
* @Date 2023/7/19 11:03
*/
@RequestMapping(value = "/ocrApi")
@RestController
@Slf4j
public class OcrApiController {
@Resource
IOcrIdentifyService ocrIdentifyService;
@Resource
IOcrRuleCheckService ruleCheckService;
@Resource
IOcrApiCallStatisticsService ocrApiCallStatisticsService;
@Resource
IOcrTaskTypeService ocrTaskTypeService;
public static final String semanticUrl="http://47.103.213.109:9099/semantic";
public static void main(String[] args) {
String scenes = "door";
AssertUtils.notTrue(!"door".equals(scenes),String.format("暂不支持该场景类型[%s]",scenes));
}
}

@ -13,10 +13,10 @@ import org.jeecg.common.system.base.controller.JeecgController;
import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.modules.ocr.entity.OcrIdentifyCallbackLog;
import org.jeecg.modules.ocr.service.IOcrIdentifyCallbackLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
@ -32,17 +32,11 @@ import java.util.Arrays;
@RequestMapping("/ocr/ocrIdentifyCallbackLog")
@Slf4j
public class OcrIdentifyCallbackLogController extends JeecgController<OcrIdentifyCallbackLog, IOcrIdentifyCallbackLogService> {
@Autowired
@Resource
private IOcrIdentifyCallbackLogService ocrIdentifyCallbackLogService;
/**
*
*
* @param ocrIdentifyCallbackLog
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "ocr识别无量云回调记录-分页列表查询")
@ApiOperation(value="ocr识别无量云回调记录-分页列表查询", notes="ocr识别无量云回调记录-分页列表查询")
@ -52,16 +46,13 @@ public class OcrIdentifyCallbackLogController extends JeecgController<OcrIdentif
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
HttpServletRequest req) {
QueryWrapper<OcrIdentifyCallbackLog> queryWrapper = QueryGenerator.initQueryWrapper(ocrIdentifyCallbackLog, req.getParameterMap());
Page<OcrIdentifyCallbackLog> page = new Page<OcrIdentifyCallbackLog>(pageNo, pageSize);
Page<OcrIdentifyCallbackLog> page = new Page<>(pageNo, pageSize);
IPage<OcrIdentifyCallbackLog> pageList = ocrIdentifyCallbackLogService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
*
*
* @param ocrIdentifyCallbackLog
* @return
*/
@AutoLog(value = "ocr识别无量云回调记录-添加")
@ApiOperation(value="ocr识别无量云回调记录-添加", notes="ocr识别无量云回调记录-添加")
@ -74,9 +65,6 @@ public class OcrIdentifyCallbackLogController extends JeecgController<OcrIdentif
/**
*
*
* @param ocrIdentifyCallbackLog
* @return
*/
@AutoLog(value = "ocr识别无量云回调记录-编辑")
@ApiOperation(value="ocr识别无量云回调记录-编辑", notes="ocr识别无量云回调记录-编辑")
@ -89,44 +77,35 @@ public class OcrIdentifyCallbackLogController extends JeecgController<OcrIdentif
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "ocr识别无量云回调记录-通过id删除")
@ApiOperation(value="ocr识别无量云回调记录-通过id删除", notes="ocr识别无量云回调记录-通过id删除")
@RequiresPermissions("ocr:ocr_identify_callback_log:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
public Result<String> delete(@RequestParam(name="id") String id) {
ocrIdentifyCallbackLogService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "ocr识别无量云回调记录-批量删除")
@ApiOperation(value="ocr识别无量云回调记录-批量删除", notes="ocr识别无量云回调记录-批量删除")
@RequiresPermissions("ocr:ocr_identify_callback_log:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
public Result<String> deleteBatch(@RequestParam(name="ids") String ids) {
this.ocrIdentifyCallbackLogService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "ocr识别无量云回调记录-通过id查询")
@ApiOperation(value="ocr识别无量云回调记录-通过id查询", notes="ocr识别无量云回调记录-通过id查询")
@GetMapping(value = "/queryById")
public Result<OcrIdentifyCallbackLog> queryById(@RequestParam(name="id",required=true) String id) {
public Result<OcrIdentifyCallbackLog> queryById(@RequestParam(name="id") String id) {
OcrIdentifyCallbackLog ocrIdentifyCallbackLog = ocrIdentifyCallbackLogService.getById(id);
if(ocrIdentifyCallbackLog==null) {
return Result.error("未找到对应数据");
@ -136,9 +115,6 @@ public class OcrIdentifyCallbackLogController extends JeecgController<OcrIdentif
/**
* excel
*
* @param request
* @param ocrIdentifyCallbackLog
*/
@RequiresPermissions("ocr:ocr_identify_callback_log:exportXls")
@RequestMapping(value = "/exportXls")
@ -148,10 +124,6 @@ public class OcrIdentifyCallbackLogController extends JeecgController<OcrIdentif
/**
* excel
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("ocr:ocr_identify_callback_log:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)

@ -32,13 +32,13 @@ import org.jeecg.modules.system.service.ISysDictService;
import org.jeecgframework.poi.excel.ExcelImportUtil;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
@ -56,33 +56,27 @@ import java.util.stream.Collectors;
@RequestMapping("/ocrIdentify")
@Slf4j
public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIdentifyService> {
@Autowired
@Resource
private IOcrIdentifyService ocrIdentifyService;
@Autowired
@Resource
private IOcrIdentifyDetailService ocrIdentifyDetailService;
@Autowired
@Resource
private DownloadTemplateUtil downloadTemplateUtil;
@Autowired
@Resource
private IOcrTaskTypeService ocrTaskTypeService;
@Autowired
@Resource
private IOcrMetadataConfigService ocrMetadataConfigService;
@Autowired
@Resource
private IOcrRuleCheckService ocrRuleCheckService;
@Autowired
@Resource
private ISysDictService sysDictService;
@Autowired
@Resource
private TaskService taskService;
@Value("${spring.profiles.active}")
private String profiles;
/**
*
*
* @param ocrIdentify
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "ocr识别-分页列表查询")
@ApiOperation(value = "ocr识别-分页列表查询", notes = "ocr识别-分页列表查询")
@ -109,7 +103,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
QueryWrapper<OcrIdentify> queryWrapper = QueryGenerator.initQueryWrapper(ocrIdentify, req.getParameterMap());
queryWrapper.ne("task_source", "模拟实验");//排除模拟实验的数据
if (startTime != null && endTime != null) {
endTime.setTime(endTime.getTime() + 86400000l);
endTime.setTime(endTime.getTime() + 86400000L);
queryWrapper.between("end_time", startTime, endTime);
}
Page<OcrIdentify> page = new Page<>(pageNo, pageSize);
@ -118,7 +112,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
Map<String, String> taskNameMap = ocrTaskTypeService.listNameToMap(null);
IPage<OcrIdentify> pageList = ocrIdentifyService.page(page, queryWrapper);
if (pageList != null && pageList.getRecords() != null && pageList.getRecords().size() > 0) {
List<String> identifyIdList = pageList.getRecords().stream().map(p -> p.getId()).collect(Collectors.toList());
List<String> identifyIdList = pageList.getRecords().stream().map(OcrIdentify::getId).collect(Collectors.toList());
List<OcrIdentifyDetail> identifyDetailList = ocrIdentifyDetailService.list(new LambdaQueryWrapper<OcrIdentifyDetail>().in(OcrIdentifyDetail::getIdentifyId, identifyIdList));
for (OcrIdentify record : pageList.getRecords()) {
long count = identifyDetailList.stream().filter(i -> i.getIdentifyId().equals(record.getId())).count();
@ -126,7 +120,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
if (StringUtils.isNotBlank(record.getTaskResultInfo())) {
List<OcrResultDTO> ocrResultDTOS = JSONObject.parseArray(record.getTaskResultInfo()).toJavaList(OcrResultDTO.class);
int tagNum = ocrResultDTOS.size();
int successNum = (int) ocrResultDTOS.stream().filter(o -> o.getRuleValidation()).count();
int successNum = (int) ocrResultDTOS.stream().filter(OcrResultDTO::getRuleValidation).count();
record.setTagNum(tagNum);
record.setTagSuccessNum(successNum);
record.setSuccessRate(successNum + "/" + tagNum);
@ -149,9 +143,6 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
/**
*
*
* @param ocrIdentify
* @return
*/
@AutoLog(value = "ocr识别-添加")
@ApiOperation(value = "ocr识别-添加", notes = "ocr识别-添加")
@ -192,17 +183,11 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
ocrIdentifyService.save(ocrIdentify);
//3.请求python ocr识别异步执行
taskService.postSemantic(ocrIdentify, fileList);
//ocrIdentifyService.postSemantic(ocrIdentify, fileList);
//请求ocr识别接口
//ocrIdentifyService.postSemantic(ocrIdentify.getId(),Arrays.asList(ocrIdentify.getIdentifyUrl()));
return Result.OK("添加成功!");
}
/**
*
*
* @param ocrIdentify
* @return
*/
@AutoLog(value = "ocr识别-编辑")
@ApiOperation(value = "ocr识别-编辑", notes = "ocr识别-编辑")
@ -210,25 +195,18 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST})
public Result<String> edit(@RequestBody OcrIdentify ocrIdentify) {
AssertUtils.notEmpty(ocrIdentify.getId(), "[id]不可为空");
OcrIdentify identify = ocrIdentifyService.getById(ocrIdentify.getId());
/*if (Arrays.asList("0","1","2").contains(identify.getStatus())) {
throw new JeecgBootException("当前状态不可编辑");
}*/
ocrIdentifyService.updateById(ocrIdentify);
return Result.OK("编辑成功!");
}
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "ocr识别-通过id删除")
@ApiOperation(value = "ocr识别-通过id删除", notes = "ocr识别-通过id删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_identify:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
public Result<String> delete(@RequestParam(name = "id") String id) {
OcrIdentify ocrIdentify = ocrIdentifyService.getById(id);
AssertUtils.isTrue(OcrStatusEnum.OVER.getStatus().equals(ocrIdentify.getStatus()), "当前状态不可删除");
ocrIdentifyService.removeById(id);
@ -237,15 +215,12 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "ocr识别-批量删除")
@ApiOperation(value = "ocr识别-批量删除", notes = "ocr识别-批量删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_identify:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
List<OcrIdentify> ocrIdentifies = ocrIdentifyService.listByIds(Arrays.asList(ids.split(",")));
for (OcrIdentify ocrIdentify : ocrIdentifies) {
AssertUtils.isTrue(OcrStatusEnum.OVER.getStatus().equals(ocrIdentify.getStatus()), "当前ocr识别状态不可删除");
@ -256,14 +231,11 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "ocr识别-通过id查询")
@ApiOperation(value = "ocr识别-通过id查询", notes = "ocr识别-通过id查询")
@GetMapping(value = "/queryById")
public Result<OcrIdentify> queryById(@RequestParam(name = "id", required = true) String id) {
public Result<OcrIdentify> queryById(@RequestParam(name = "id") String id) {
OcrIdentify ocrIdentify = ocrIdentifyService.getById(id);
if (ocrIdentify == null) {
return Result.error("未找到对应数据");
@ -276,7 +248,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
if (StringUtils.isNotBlank(ocrIdentify.getTaskResultInfo())) {
List<OcrResultDTO> ocrResultDTOList = JSONObject.parseArray(ocrIdentify.getTaskResultInfo()).toJavaList(OcrResultDTO.class);
int tagNum = ocrResultDTOList.size();
int successNum = (int) ocrResultDTOList.stream().filter(o -> o.getRuleValidation()).count();
int successNum = (int) ocrResultDTOList.stream().filter(OcrResultDTO::getRuleValidation).count();
ocrIdentify.setTagNum(tagNum);
ocrIdentify.setTagSuccessNum(successNum);
ocrIdentify.setSuccessRate(successNum + "/" + tagNum);
@ -300,9 +272,6 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
/**
* excel
*
* @param request
* @param ocrIdentify
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_identify:exportXls")
@RequestMapping(value = "/exportXls")
@ -320,7 +289,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
public Result<?> importExcel(HttpServletRequest request) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
@ -393,7 +362,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
//update-begin-author:taoyan date:20211124 for: 导入数据重复增加提示
String msg = e.getMessage();
log.error(msg, e);
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
if (msg != null && msg.contains("Duplicate entry")) {
return Result.error("文件导入失败:有重复数据!");
} else {
return Result.error("文件导入失败:" + e.getMessage());
@ -412,10 +381,6 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
/**
* excel
*
* @param request
* @param response
* @return
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_identify:importExcel")
@RequestMapping(value = "/importExcel1", method = RequestMethod.POST)
@ -457,7 +422,7 @@ public class OcrIdentifyController extends JeecgController<OcrIdentify, IOcrIden
AssertUtils.isTrue("1".equals(entity.getStatus()), String.format("[任务名称]-%s 当前正在识别中,不可进行上报", entity.getTaskName()));
AssertUtils.isTrue(entity.getNoticeStatus().equals("0"), String.format("[任务名称]-%s 当前已上报,不可再次进行上报", entity.getTaskName()));
}
for (String identifyId : Arrays.asList(id.split(","))) {
for (String identifyId : id.split(",")) {
ocrIdentifyService.callbackWlyAsync(identifyId);
}
return Result.OK("操作成功");

@ -15,11 +15,11 @@ import org.jeecg.common.system.query.QueryGenerator;
import org.jeecg.common.util.AssertUtils;
import org.jeecg.modules.ocr.entity.OcrIdentifyDetail;
import org.jeecg.modules.ocr.service.IOcrIdentifyDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
@ -36,7 +36,7 @@ import java.util.Arrays;
@RequestMapping("/ocrIdentifyDetail")
@Slf4j
public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDetail, IOcrIdentifyDetailService> {
@Autowired
@Resource
private IOcrIdentifyDetailService ocrIdentifyDetailService;
//系统环境
@Value("${system.project.env}")
@ -44,12 +44,6 @@ public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDeta
/**
*
*
* @param ocrIdentifyDetail
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "ocr识别结果明细-分页列表查询")
@ApiOperation(value="ocr识别结果明细-分页列表查询", notes="ocr识别结果明细-分页列表查询")
@ -60,7 +54,7 @@ public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDeta
HttpServletRequest req) {
AssertUtils.notEmpty(ocrIdentifyDetail.getIdentifyId(),"[identifyId]不可为空-请选择ocr识别信息");
QueryWrapper<OcrIdentifyDetail> queryWrapper = QueryGenerator.initQueryWrapper(ocrIdentifyDetail, req.getParameterMap());
Page<OcrIdentifyDetail> page = new Page<OcrIdentifyDetail>(pageNo, pageSize);
Page<OcrIdentifyDetail> page = new Page<>(pageNo, pageSize);
IPage<OcrIdentifyDetail> pageList = ocrIdentifyDetailService.page(page, queryWrapper);
if (pageList!=null&& pageList.getRecords()!=null) {
for (OcrIdentifyDetail record : pageList.getRecords()) {
@ -101,9 +95,6 @@ public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDeta
/**
*
*
* @param ocrIdentifyDetail
* @return
*/
@AutoLog(value = "ocr识别结果明细-添加")
@ApiOperation(value="ocr识别结果明细-添加", notes="ocr识别结果明细-添加")
@ -116,9 +107,6 @@ public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDeta
/**
*
*
* @param ocrIdentifyDetail
* @return
*/
@AutoLog(value = "ocr识别结果明细-编辑")
@ApiOperation(value="ocr识别结果明细-编辑", notes="ocr识别结果明细-编辑")
@ -131,44 +119,35 @@ public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDeta
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "ocr识别结果明细-通过id删除")
@ApiOperation(value="ocr识别结果明细-通过id删除", notes="ocr识别结果明细-通过id删除")
@RequiresPermissions("ocr:ocr_identify_detail:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
public Result<String> delete(@RequestParam(name="id") String id) {
ocrIdentifyDetailService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "ocr识别结果明细-批量删除")
@ApiOperation(value="ocr识别结果明细-批量删除", notes="ocr识别结果明细-批量删除")
@RequiresPermissions("ocr:ocr_identify_detail:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
public Result<String> deleteBatch(@RequestParam(name="ids") String ids) {
this.ocrIdentifyDetailService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "ocr识别结果明细-通过id查询")
@ApiOperation(value="ocr识别结果明细-通过id查询", notes="ocr识别结果明细-通过id查询")
@GetMapping(value = "/queryById")
public Result<OcrIdentifyDetail> queryById(@RequestParam(name="id",required=true) String id) {
public Result<OcrIdentifyDetail> queryById(@RequestParam(name="id") String id) {
OcrIdentifyDetail ocrIdentifyDetail = ocrIdentifyDetailService.getById(id);
if(ocrIdentifyDetail==null) {
return Result.error("未找到对应数据");
@ -178,9 +157,6 @@ public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDeta
/**
* excel
*
* @param request
* @param ocrIdentifyDetail
*/
@RequiresPermissions("ocr:ocr_identify_detail:exportXls")
@RequestMapping(value = "/exportXls")
@ -190,10 +166,6 @@ public class OcrIdentifyDetailController extends JeecgController<OcrIdentifyDeta
/**
* excel
*
* @param request
* @param response
* @return
*/
@RequiresPermissions("ocr:ocr_identify_detail:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)

@ -28,7 +28,6 @@ import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
@ -37,7 +36,6 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@ -57,48 +55,38 @@ import java.util.stream.Collectors;
@RequestMapping("/ocrMetadataConfig")
@Slf4j
public class OcrMetadataConfigController extends JeecgController<OcrMetadataConfig, IOcrMetadataConfigService> {
@Autowired
@Resource
private IOcrMetadataConfigService ocrMetadataConfigService;
@Autowired
@Resource
private IOcrRuleCheckService ocrRuleCheckService;
@Autowired
@Resource
private DownloadTemplateUtil downloadTemplateUtil;
@Resource
private JeecgBaseConfig jeecgBaseConfig;
/**
*
*
* @param ocrMetadataConfig
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "元数据配置-分页列表查询")
@ApiOperation(value = "元数据配置-分页列表查询", notes = "元数据配置-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<OcrMetadataConfigDTO>> queryPageList(OcrMetadataConfig ocrMetadataConfig,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
Page<OcrMetadataConfig> page = new Page<OcrMetadataConfig>(pageNo, pageSize);
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<OcrMetadataConfig> page = new Page<>(pageNo, pageSize);
IPage<OcrMetadataConfigDTO> pageList = ocrMetadataConfigService.pageVo(page, ocrMetadataConfig);
return Result.OK(pageList);
}
@ApiOperation(value = "元数据配置-下拉列表", notes = "元数据配置-下拉列表")
@GetMapping(value = "/allList")
public Result<List<OcrMetadataConfigDTO>> allList(HttpServletRequest req) {
public Result<List<OcrMetadataConfigDTO>> allList() {
List<OcrMetadataConfigDTO> allList = ocrMetadataConfigService.allList(null);
return Result.OK(allList);
}
/**
*
*
* @param saveOcrMetadataConfigVO
* @return
*/
@AutoLog(value = "元数据配置-添加")
@ApiOperation(value = "元数据配置-添加", notes = "元数据配置-添加")
@ -116,8 +104,6 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
/**
*
*
* @param saveOcrMetadataConfigVO
*/
public void checkSaveModel(SaveOcrMetadataConfigVO saveOcrMetadataConfigVO) {
AssertUtils.notEmpty(saveOcrMetadataConfigVO.getConfigName(), "[配置名称]不可为空");
@ -131,9 +117,6 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
/**
*
*
* @param saveOcrMetadataConfigVO
* @return
*/
@AutoLog(value = "元数据配置-编辑")
@ApiOperation(value = "元数据配置-编辑", notes = "元数据配置-编辑")
@ -151,48 +134,39 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "元数据配置-通过id删除")
@ApiOperation(value = "元数据配置-通过id删除", notes = "元数据配置-通过id删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_metadata_config:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
public Result<String> delete(@RequestParam(name = "id") String id) {
long count = ocrRuleCheckService.count(new LambdaQueryWrapper<OcrRuleCheck>().eq(OcrRuleCheck::getMetadataConfigId, id));
AssertUtils.notTrue(count>0, String.format("所选元数据配置不可删除,原因:[被规则检查配置使用中]"));
AssertUtils.notTrue(count>0, "所选元数据配置不可删除,原因:[被规则检查配置使用中]");
ocrMetadataConfigService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "元数据配置-批量删除")
@ApiOperation(value = "元数据配置-批量删除", notes = "元数据配置-批量删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_metadata_config:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
long count = ocrRuleCheckService.count(new LambdaQueryWrapper<OcrRuleCheck>().in(OcrRuleCheck::getMetadataConfigId, Arrays.asList(ids.split(","))));
AssertUtils.notTrue(count>0, String.format("所选元数据配置不可删除,原因:[被规则检查配置使用中]"));
AssertUtils.notTrue(count>0, "所选元数据配置不可删除,原因:[被规则检查配置使用中]");
this.ocrMetadataConfigService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "元数据配置-通过id查询")
@ApiOperation(value = "元数据配置-通过id查询", notes = "元数据配置-通过id查询")
@GetMapping(value = "/queryById")
public Result<OcrMetadataConfigDTO> queryById(@RequestParam(name = "id", required = true) String id) {
public Result<OcrMetadataConfigDTO> queryById(@RequestParam(name = "id") String id) {
OcrMetadataConfigDTO ocrMetadataConfig = ocrMetadataConfigService.findById(id);
if (ocrMetadataConfig == null) {
return Result.error("未找到对应数据");
@ -202,13 +176,10 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
/**
* excel
*
* @param request
* @param ocrMetadataConfig
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_metadata_config:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, OcrMetadataConfig ocrMetadataConfig) {
public ModelAndView exportXls(HttpServletRequest request) {
// 过滤选中数据
String selections = request.getParameter("selections");
String title = "元数据配置";
@ -220,7 +191,6 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = ocrMetadataConfigService.allList(selectionList);
}
if(true){
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.FILE_NAME, title);
mv.addObject(NormalExcelConstants.CLASS, OcrMetadataConfigDTO.class);
@ -228,7 +198,6 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
}
return mv;
}
@ -242,14 +211,10 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
/**
* excel
*
* @param request
* @param response
* @return
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_metadata_config:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
public Result<?> importExcel(HttpServletRequest request) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
@ -263,8 +228,8 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
List<OcrMetadataConfigDTO> list = ExcelImportUtil.importExcel(file.getInputStream(), OcrMetadataConfigDTO.class, params);
AssertUtils.hasSize(list,"未获取到数据!");
//判断重复字段名
Map<String, Long> countMap = list.stream().map(o->o.getConfigName()).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
AssertUtils.notTrue(countMap.values().stream().filter(f->f>1).count()>0,"不可有重复的配置名称!");
Map<String, Long> countMap = list.stream().map(OcrMetadataConfig::getConfigName).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
AssertUtils.notTrue(countMap.values().stream().anyMatch(f -> f > 1),"不可有重复的配置名称!");
//入库保存的元数据对象
List<SaveOcrMetadataConfigVO> saveModelList=new ArrayList<>();
//元数据循环copy add的对象
@ -309,7 +274,7 @@ public class OcrMetadataConfigController extends JeecgController<OcrMetadataConf
} catch (Exception e) {
String msg = e.getMessage();
log.error(msg, e);
if(msg!=null && msg.indexOf("Duplicate entry")>=0){
if(msg!=null && msg.contains("Duplicate entry")){
return Result.error("文件导入失败:有重复数据!");
}else{
return Result.error("文件导入失败:" + e.getMessage());

@ -28,7 +28,6 @@ import org.jeecgframework.poi.excel.def.NormalExcelConstants;
import org.jeecgframework.poi.excel.entity.ExportParams;
import org.jeecgframework.poi.excel.entity.ImportParams;
import org.jeecgframework.poi.excel.view.JeecgEntityExcelView;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.MultipartHttpServletRequest;
@ -36,7 +35,6 @@ import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
@ -56,51 +54,32 @@ import java.util.stream.Collectors;
@RequestMapping("/ocrRuleCheck")
@Slf4j
public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRuleCheckService> {
@Autowired
@Resource
private IOcrRuleCheckService ocrRuleCheckService;
@Autowired
@Resource
private DownloadTemplateUtil downloadTemplateUtil;
@Autowired
@Resource
private IOcrMetadataConfigService ocrMetadataConfigService;
@Resource
private JeecgBaseConfig jeecgBaseConfig;
@Autowired
@Resource
private IOcrIdentifyService ocrIdentifyService;
/**
*
*
* @param ocrRuleCheck
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "规则检查配置-分页列表查询")
@ApiOperation(value = "规则检查配置-分页列表查询", notes = "规则检查配置-分页列表查询")
@GetMapping(value = "/list")
public Result<IPage<OcrRuleCheckDTO>> queryPageList(OcrRuleCheck ocrRuleCheck,
@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
HttpServletRequest req) {
/*if (StringUtils.isNotBlank(ocrRuleCheck.getConfigName())) {
ocrRuleCheck.setConfigName("*" + ocrRuleCheck.getConfigName() + "*");
}*/
/*if (StringUtils.isNotBlank(ocrRuleCheck.getResultName())){
ocrRuleCheck.setResultName("*"+ocrRuleCheck.getResultName()+"*");
}*/
/*if (StringUtils.isNotBlank(ocrRuleCheck.getConfigRule())) {
ocrRuleCheck.setConfigRule("*" + ocrRuleCheck.getConfigRule() + "*");
}*/
Page<OcrRuleCheck> page = new Page<OcrRuleCheck>(pageNo, pageSize);
@RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
Page<OcrRuleCheck> page = new Page<>(pageNo, pageSize);
IPage<OcrRuleCheckDTO> pageList = ocrRuleCheckService.pageVo(page, ocrRuleCheck);
return Result.OK(pageList);
}
/**
*
*
* @param saveOcrRuleCheckVO
* @return
*/
@AutoLog(value = "规则检查配置-添加")
@ApiOperation(value = "规则检查配置-添加", notes = "规则检查配置-添加")
@ -117,8 +96,6 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
/**
*
*
* @param saveOcrRuleCheckVO
*/
public void checkSaveModel(SaveOcrRuleCheckVO saveOcrRuleCheckVO) {
AssertUtils.notEmpty(saveOcrRuleCheckVO.getConfigName(), "[配置名称]不可为空");
@ -126,9 +103,6 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
/**
*
*
* @param saveOcrRuleCheckVO
* @return
*/
@AutoLog(value = "规则检查配置-编辑")
@ApiOperation(value = "规则检查配置-编辑", notes = "规则检查配置-编辑")
@ -146,48 +120,39 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "规则检查配置-通过id删除")
@ApiOperation(value = "规则检查配置-通过id删除", notes = "规则检查配置-通过id删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_rule_check:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name = "id", required = true) String id) {
public Result<String> delete(@RequestParam(name = "id") String id) {
long count = ocrIdentifyService.count(new LambdaQueryWrapper<OcrIdentify>().eq(OcrIdentify::getRuleCheck, id));
AssertUtils.notTrue(count>0, String.format("所选规则配置不可删除,原因:[被识别任务使用中]"));
AssertUtils.notTrue(count>0, "所选规则配置不可删除,原因:[被识别任务使用中]");
ocrRuleCheckService.removeById(id);
return Result.OK("删除成功!");
}
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "规则检查配置-批量删除")
@ApiOperation(value = "规则检查配置-批量删除", notes = "规则检查配置-批量删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_rule_check:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
public Result<String> deleteBatch(@RequestParam(name = "ids") String ids) {
long count = ocrIdentifyService.count(new LambdaQueryWrapper<OcrIdentify>().in(OcrIdentify::getRuleCheck, Arrays.asList(ids.split(","))));
AssertUtils.notTrue(count>0, String.format("所选规则配置不可删除,原因:[被识别任务使用中]"));
AssertUtils.notTrue(count>0, "所选规则配置不可删除,原因:[被识别任务使用中]");
this.ocrRuleCheckService.removeByIds(Arrays.asList(ids.split(",")));
return Result.OK("批量删除成功!");
}
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "规则检查配置-通过id查询")
@ApiOperation(value = "规则检查配置-通过id查询", notes = "规则检查配置-通过id查询")
@GetMapping(value = "/queryById")
public Result<OcrRuleCheck> queryById(@RequestParam(name = "id", required = true) String id) {
public Result<OcrRuleCheck> queryById(@RequestParam(name = "id") String id) {
OcrRuleCheck ocrRuleCheck = ocrRuleCheckService.getById(id);
if (ocrRuleCheck == null) {
return Result.error("未找到对应数据");
@ -197,25 +162,19 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
/**
* excel
*
* @param request
* @param ocrRuleCheck
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_rule_check:exportXls")
@RequestMapping(value = "/exportXls")
public ModelAndView exportXls(HttpServletRequest request, OcrRuleCheck ocrRuleCheck) {
public ModelAndView exportXls(HttpServletRequest request) {
// 过滤选中数据
String selections = request.getParameter("selections");
String title = "规则检查配置";
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
List<OcrRuleCheckDTO> exportList = new ArrayList<>();
if (oConvertUtils.isNotEmpty(selections)) {
List<String> selectionList = Arrays.asList(selections.split(","));
exportList = ocrRuleCheckService.allList(selectionList);
}
if (true) {
LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
mv.addObject(NormalExcelConstants.FILE_NAME, title);
mv.addObject(NormalExcelConstants.CLASS, OcrRuleCheckDTO.class);
@ -223,7 +182,6 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
exportParams.setImageBasePath(jeecgBaseConfig.getPath().getUpload());
mv.addObject(NormalExcelConstants.PARAMS, exportParams);
mv.addObject(NormalExcelConstants.DATA_LIST, exportList);
}
return mv;
}
@ -237,14 +195,10 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
/**
* excel
*
* @param request
* @param response
* @return
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_rule_check:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
public Result<?> importExcel(HttpServletRequest request) {
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
@ -258,12 +212,12 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
List<SaveOcrRuleCheckVO> list = ExcelImportUtil.importExcel(file.getInputStream(), SaveOcrRuleCheckVO.class, params);
AssertUtils.hasSize(list, "未获取到数据!");
//判断重复字段名
Map<String, Long> countMap = list.stream().map(o -> o.getConfigName()).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
AssertUtils.notTrue(countMap.values().stream().filter(f -> f > 1).count() > 0, "不可有重复的配置名称!");
Map<String, Long> countMap = list.stream().map(SaveOcrRuleCheckVO::getConfigName).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
AssertUtils.notTrue(countMap.values().stream().anyMatch(f -> f > 1), "不可有重复的配置名称!");
Map<String, String> metadataConfigNameMap = ocrMetadataConfigService.list(new LambdaQueryWrapper<>()).stream().collect(Collectors.toMap(OcrMetadataConfig::getConfigName, OcrMetadataConfig::getId));
List<SaveOcrRuleCheckVO> saveModelList = new ArrayList<>();
SaveOcrRuleCheckVO saveOcrRuleCheckVO;
boolean existsFlag = false;
boolean existsFlag;
String configRule;//规则配置
String metadataConfigName;//元数据配置名称
String metadataConfigId;//元数据配置id
@ -288,7 +242,7 @@ public class OcrRuleCheckController extends JeecgController<OcrRuleCheck, IOcrRu
} catch (Exception e) {
String msg = e.getMessage();
log.error(msg, e);
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
if (msg != null && msg.contains("Duplicate entry")) {
return Result.error("文件导入失败:有重复数据!");
}else {
return Result.error("文件导入失败:" + e.getMessage());

@ -22,6 +22,7 @@ import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
@ -46,7 +47,6 @@ public class OcrSimulatorController{
@Value("${jeecg.path.upload}")
private String uploadFilePath;
String ss = "{\"Inputs\":{\"RequestJson\":{\"Header\":{\"InterfaceCode\":\"QMS-MES-001\",\"RequestTime\":\"20230731163802\"},\"RequestInfo\":{\"Containers\":[\"M500000000002806\",\"M500000000002805\",\"M500000000002390\"],\"SerialNos\":[],\"Characteristics\":[{\"Characteristic\":\"N1SHP_PR019\",\"OprSequenceNo\":\"N1SHP01\"}],\"ProductionType\":\"C\"}}}}";
@ApiOperation(value = "场景识别")
@PostMapping(value = "/identify")
@ -61,10 +61,9 @@ public class OcrSimulatorController{
OcrIdentify ocrIdentify=new OcrIdentify();
ocrIdentify.setTaskSource("模拟实验");//模拟实验-场景识别
ocrIdentifyService.save(ocrIdentify);
int i = 1;
List<OcrIdentifyDetail> ocrIdentifyDetailList=new ArrayList<>();
Double nluTimeSum=0d;
Double ocrTimeSum=0d;
double nluTimeSum=0d;
double ocrTimeSum=0d;
for (String image : imageList) {
long time = new Date().getTime();
//执行识别
@ -82,8 +81,8 @@ public class OcrSimulatorController{
//执行时间 调整小数点
Double nluTime = semanticResponseJson.getDouble("nlu_time");
Double ocrTime = semanticResponseJson.getDouble("ocr_time");
nluTime = nluTime != null && nluTime != 0 ? new BigDecimal(nluTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() : 0;
ocrTime = ocrTime != null && ocrTime != 0 ? new BigDecimal(ocrTime).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue() : 0;
nluTime = nluTime != null && nluTime != 0 ? new BigDecimal(nluTime).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0;
ocrTime = ocrTime != null && ocrTime != 0 ? new BigDecimal(ocrTime).setScale(2, RoundingMode.HALF_UP).doubleValue() : 0;
//入库
ocrIdentifyDetail.setIdentifyId(ocrIdentify.getId());
ocrIdentifyDetail.setOcrTime(ocrTime);
@ -100,8 +99,8 @@ public class OcrSimulatorController{
ocrIdentifyDetailService.saveBatch(ocrIdentifyDetailList);
//返回前端的json
responseBody.put("ocrTime",new BigDecimal(ocrTimeSum).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
responseBody.put("nluTime",new BigDecimal(nluTimeSum).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue());
responseBody.put("ocrTime",new BigDecimal(ocrTimeSum).setScale(2, RoundingMode.HALF_UP).doubleValue());
responseBody.put("nluTime",new BigDecimal(nluTimeSum).setScale(2, RoundingMode.HALF_UP).doubleValue());
responseBody.put("detailList",ocrIdentifyDetailList);
return Result.OK(responseBody);
}

@ -15,13 +15,14 @@ import org.jeecg.common.util.AssertUtils;
import org.jeecg.modules.ocr.entity.OcrTaskType;
import org.jeecg.modules.ocr.service.IOcrTaskTypeService;
import org.jeecg.modules.ocr.utils.DownloadTemplateUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
@ -35,19 +36,13 @@ import java.util.List;
@RequestMapping("/ocrTaskType")
@Slf4j
public class OcrTaskTypeController extends JeecgController<OcrTaskType, IOcrTaskTypeService> {
@Autowired
@Resource
private IOcrTaskTypeService ocrTaskTypeService;
@Autowired
@Resource
private DownloadTemplateUtil downloadTemplateUtil;
/**
*
*
* @param ocrTaskType
* @param pageNo
* @param pageSize
* @param req
* @return
*/
//@AutoLog(value = "任务类型-分页列表查询")
@ApiOperation(value="任务类型-分页列表查询", notes="任务类型-分页列表查询")
@ -63,55 +58,46 @@ public class OcrTaskTypeController extends JeecgController<OcrTaskType, IOcrTask
ocrTaskType.setCreateBy("*"+ocrTaskType.getCreateBy()+"*");
}
QueryWrapper<OcrTaskType> queryWrapper = QueryGenerator.initQueryWrapper(ocrTaskType, req.getParameterMap());
Page<OcrTaskType> page = new Page<OcrTaskType>(pageNo, pageSize);
Page<OcrTaskType> page = new Page<>(pageNo, pageSize);
IPage<OcrTaskType> pageList = ocrTaskTypeService.page(page, queryWrapper);
return Result.OK(pageList);
}
/**
*
*
* @param ocrTaskType
* @return
*/
@AutoLog(value = "任务类型-添加")
@ApiOperation(value="任务类型-添加", notes="任务类型-添加")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_task_type:add")
@PostMapping(value = "/add")
public Result<String> add(@RequestBody OcrTaskType ocrTaskType) {
ocrTaskTypeService.existsByTypeNameList(Arrays.asList(ocrTaskType));
ocrTaskTypeService.existsByTypeNameList(Collections.singletonList(ocrTaskType));
ocrTaskTypeService.save(ocrTaskType);
return Result.OK("添加成功!");
}
/**
*
*
* @param ocrTaskType
* @return
*/
@AutoLog(value = "任务类型-编辑")
@ApiOperation(value="任务类型-编辑", notes="任务类型-编辑")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_task_type:edit")
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
public Result<String> edit(@RequestBody OcrTaskType ocrTaskType) {
ocrTaskTypeService.existsByTypeNameList(Arrays.asList(ocrTaskType));
ocrTaskTypeService.existsByTypeNameList(Collections.singletonList(ocrTaskType));
ocrTaskTypeService.updateById(ocrTaskType);
return Result.OK("编辑成功!");
}
/**
* id
*
* @param id
* @return
*/
@AutoLog(value = "任务类型-通过id删除")
@ApiOperation(value="任务类型-通过id删除", notes="任务类型-通过id删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_task_type:delete")
@DeleteMapping(value = "/delete")
public Result<String> delete(@RequestParam(name="id",required=true) String id) {
boolean flag=ocrTaskTypeService.checkMetadataConfigUse(Arrays.asList(id));
public Result<String> delete(@RequestParam(name="id") String id) {
boolean flag=ocrTaskTypeService.checkMetadataConfigUse(Collections.singletonList(id));
AssertUtils.notTrue(flag,"任务类型不可删除,原因:[被元数据配置使用中]");
ocrTaskTypeService.removeById(id);
return Result.OK("删除成功!");
@ -119,15 +105,12 @@ public class OcrTaskTypeController extends JeecgController<OcrTaskType, IOcrTask
/**
*
*
* @param ids
* @return
*/
@AutoLog(value = "任务类型-批量删除")
@ApiOperation(value="任务类型-批量删除", notes="任务类型-批量删除")
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_task_type:deleteBatch")
@DeleteMapping(value = "/deleteBatch")
public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
public Result<String> deleteBatch(@RequestParam(name="ids") String ids) {
boolean flag=ocrTaskTypeService.checkMetadataConfigUse(Arrays.asList(ids.split(",")));
AssertUtils.notTrue(flag,"任务类型不可删除,原因:[被元数据配置使用中]");
this.ocrTaskTypeService.removeByIds(Arrays.asList(ids.split(",")));
@ -136,14 +119,11 @@ public class OcrTaskTypeController extends JeecgController<OcrTaskType, IOcrTask
/**
* id
*
* @param id
* @return
*/
//@AutoLog(value = "任务类型-通过id查询")
@ApiOperation(value="任务类型-通过id查询", notes="任务类型-通过id查询")
@GetMapping(value = "/queryById")
public Result<OcrTaskType> queryById(@RequestParam(name="id",required=true) String id) {
public Result<OcrTaskType> queryById(@RequestParam(name="id") String id) {
OcrTaskType ocrTaskType = ocrTaskTypeService.getById(id);
if(ocrTaskType==null) {
return Result.error("未找到对应数据");
@ -153,9 +133,6 @@ public class OcrTaskTypeController extends JeecgController<OcrTaskType, IOcrTask
/**
* excel
*
* @param request
* @param ocrTaskType
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_task_type:exportXls")
@RequestMapping(value = "/exportXls")
@ -173,10 +150,6 @@ public class OcrTaskTypeController extends JeecgController<OcrTaskType, IOcrTask
/**
* excel
*
* @param request
* @param response
* @return
*/
// @RequiresPermissions("org.jeecg.modules.ocr:ocr_task_type:importExcel")
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)

@ -2,6 +2,7 @@ package org.jeecg.modules.ocr.dto;
import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.ocr.entity.OcrIdentify;
import java.util.List;
@ -11,6 +12,7 @@ import java.util.List;
* @Author ZhouWenTao
* @Date 2023/7/19 18:20
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class OcrIdentifyDTO extends OcrIdentify {
/**规则检查配置*/

@ -1,6 +1,7 @@
package org.jeecg.modules.ocr.dto;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.ocr.entity.OcrMetadataConfig;
import org.jeecg.modules.ocr.entity.OcrMetadataConfigDetail;
import org.jeecgframework.poi.excel.annotation.Excel;
@ -13,6 +14,7 @@ import java.util.List;
* @Author ZhouWenTao
* @Date 2023/7/17 16:53
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class OcrMetadataConfigDTO extends OcrMetadataConfig {
/**任务类型_字段中文*/

@ -2,6 +2,7 @@ package org.jeecg.modules.ocr.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.jeecg.modules.ocr.entity.OcrRuleCheck;
import org.jeecgframework.poi.excel.annotation.Excel;
@ -14,6 +15,7 @@ import java.util.Map;
* @Date: 2023-07-14
* @Version: V1.0
*/
@EqualsAndHashCode(callSuper = true)
@Data
public class OcrRuleCheckDTO extends OcrRuleCheck {
private static final long serialVersionUID = 1L;

@ -118,8 +118,4 @@ public class OcrIdentifyDetail implements Serializable {
@ApiModelProperty(value = "虚线图片预览地址")
@TableField(exist = false)
private String drawDashedImagePreviewUrl;
///===========================================
/*字段校验成功对象.*//*
@TableField(exist = false)
private Map<String, Boolean> fieldRightMap;*/
}

@ -60,10 +60,6 @@ public class OcrRuleCheck implements Serializable {
@Excel(name = "配置规则", width = 15)
@ApiModelProperty(value = "配置规则")
private String configRule;
/**结果名称*/
/*@Excel(name = "结果名称", width = 15)
@ApiModelProperty(value = "结果名称")
private String resultName;*/
@ApiModelProperty(value = "元数据配置id")
/*@Excel(name = "元数据配置id", width = 15)*/

@ -45,26 +45,18 @@ public class HandleTransInit implements ApplicationRunner {
@Value("${system.project.enableHandleTask}")
private boolean enableHandleTask;
public static void main(String[] args) {
}
/**
*
* @param args
*/
@Override
@Async
public void run(ApplicationArguments args) throws UnknownHostException {
if (enableHandleTask) {
try {
Thread.sleep(5000l);
Thread.sleep(5000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
while (true) {
try {
Thread.sleep(10000l);
Thread.sleep(10000L);
} catch (InterruptedException e) {
e.printStackTrace();
}
@ -101,7 +93,7 @@ public class HandleTransInit implements ApplicationRunner {
/**
*
*
* @param taskId
* @param taskId id
* @param status 1 2
*/
public void flushTask(String taskId, int status) {

@ -4,7 +4,9 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.jeecg.common.constant.OcrConstant;
import org.jeecg.common.util.AssertUtils;
import org.jeecg.modules.ocr.dto.OcrMetadataConfigDTO;
import org.jeecg.modules.ocr.entity.OcrMetadataConfig;
@ -15,8 +17,6 @@ import org.jeecg.modules.ocr.service.IOcrMetadataConfigDetailService;
import org.jeecg.modules.ocr.service.IOcrMetadataConfigService;
import org.jeecg.modules.ocr.service.IOcrTaskTypeService;
import org.jeecg.modules.ocr.vo.SaveOcrMetadataConfigVO;
import org.jeecg.modules.system.service.ISysDictItemService;
import org.jeecg.modules.system.service.ISysDictService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@ -37,25 +37,19 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
@Resource
IOcrMetadataConfigDetailService ocrMetadataConfigDetailService;
@Resource
OcrMetadataConfigMapper ocrMetadataConfigMapper;
@Resource
IOcrTaskTypeService ocrTaskTypeService;
@Resource
ISysDictItemService sysDictItemService;
@Resource
ISysDictService sysDictService;
@Override
public boolean existsByConfigName(String configName, String id) {
LambdaQueryWrapper<OcrMetadataConfig> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(OcrMetadataConfig::getConfigName,configName);
queryWrapper.ne(StringUtils.isNotBlank(id),OcrMetadataConfig::getId,id);
return this.baseMapper.selectCount(queryWrapper)>0?true:false;
return this.baseMapper.selectCount(queryWrapper) > 0;
}
@Override
public void saveModel(SaveOcrMetadataConfigVO saveOcrMetadataConfigVO) {
saveModelBatch(Arrays.asList(saveOcrMetadataConfigVO));
/*return ocrMetadataConfig;*/
saveModelBatch(Collections.singletonList(saveOcrMetadataConfigVO));
}
@Override
@ -64,9 +58,8 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
for (SaveOcrMetadataConfigVO saveOcrMetadataConfigVO : saveModelList) {
OcrMetadataConfig ocrMetadataConfig=new OcrMetadataConfig();
ocrMetadataConfig.setConfigName(saveOcrMetadataConfigVO.getConfigName());
Boolean existsFlag=existsByConfigName(saveOcrMetadataConfigVO.getConfigName(), saveOcrMetadataConfigVO.getId());
boolean existsFlag=existsByConfigName(saveOcrMetadataConfigVO.getConfigName(), saveOcrMetadataConfigVO.getId());
AssertUtils.notTrue(existsFlag, String.format("[配置名称]-%s 已存在", saveOcrMetadataConfigVO.getConfigName()));
//判断 元数据 所选的 任务类型 是否存在
if (StringUtils.isBlank(saveOcrMetadataConfigVO.getTaskType())&& StringUtils.isNotBlank(saveOcrMetadataConfigVO.getTaskTypeName())) {
OcrTaskType ocrTaskType = ocrTaskTypeService.saveTaskType(saveOcrMetadataConfigVO.getTaskTypeName());
@ -74,18 +67,20 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
}else{
ocrMetadataConfig.setTaskType(saveOcrMetadataConfigVO.getTaskType());
}
this.save(ocrMetadataConfig);
List<OcrMetadataConfigDetail> ocrMetadataConfigDetailList = saveOcrMetadataConfigVO.getOcrMetadataConfigDetailList();
if(ocrMetadataConfigDetailList!=null&&ocrMetadataConfigDetailList.size()>0){
//判断重复字段名
Map<String, Long> countMap = ocrMetadataConfigDetailList.stream().map(o->o.getFieldName()).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
Map<String, Long> countMap = ocrMetadataConfigDetailList.stream().map(OcrMetadataConfigDetail::getFieldName).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
if (countMap.keySet().size()>0) {
//有重复的字段名
String fieldsName = countMap.keySet().stream().filter(key -> countMap.get(key) > 1).distinct().collect(Collectors.joining(","));
AssertUtils.isEmpty(fieldsName,String.format("字段名[%s]-重复了",fieldsName));
}
//判断字段是否支持
for (OcrMetadataConfigDetail detail : saveOcrMetadataConfigVO.getOcrMetadataConfigDetailList()) {
AssertUtils.isTrue(OcrConstant.SUPPORTED_FIELDS.contains(detail.getFieldName()),String.format("字段名[%s]-目前不支持",detail.getFieldName()));
AssertUtils.isTrue(OcrConstant.SUPPORTED_FIELD_NAMES.contains(detail.getGetField()),String.format("获取字段[%s]-目前不支持",detail.getGetField()));
detail.setMetadataConfigId(ocrMetadataConfig.getId());
ocrMetadataConfigDetailService.saveOrUpdate(detail);
}
@ -96,8 +91,7 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
@Override
public Map<String, OcrMetadataConfigDTO> listToMap(List<String> idList) {
List<OcrMetadataConfigDTO> metadataConfigVoList =baseMapper.allList(idList!=null&&idList.size()>0?idList:null);
Map<String, OcrMetadataConfigDTO> metadataConfigVoMap = metadataConfigVoList.stream().collect(Collectors.toMap(OcrMetadataConfigDTO::getId, o -> o));
return metadataConfigVoMap;
return metadataConfigVoList.stream().collect(Collectors.toMap(OcrMetadataConfigDTO::getId, o -> o));
}
@ -108,16 +102,17 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
ocrMetadataConfig.setConfigName(saveOcrMetadataConfigVO.getConfigName());
this.updateById(ocrMetadataConfig);
List<OcrMetadataConfigDetail> ocrMetadataConfigDetailList = saveOcrMetadataConfigVO.getOcrMetadataConfigDetailList();
if(ocrMetadataConfigDetailList!=null&&ocrMetadataConfigDetailList.size()>0){
//判断重复字段名
Map<String, Long> countMap = ocrMetadataConfigDetailList.stream().map(o->o.getFieldName()).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
Map<String, Long> countMap = ocrMetadataConfigDetailList.stream().map(OcrMetadataConfigDetail::getFieldName).collect(Collectors.groupingBy(Function.identity(), Collectors.counting()));
if (countMap.keySet().size()>0) {
//有重复的字段名
String fieldsName = countMap.keySet().stream().filter(key -> countMap.get(key) > 1).distinct().collect(Collectors.joining(","));
AssertUtils.isEmpty(fieldsName,String.format("字段名[%s]-重复了",fieldsName));
}
for (OcrMetadataConfigDetail detail : saveOcrMetadataConfigVO.getOcrMetadataConfigDetailList()) {
AssertUtils.isTrue(OcrConstant.SUPPORTED_FIELDS.contains(detail.getFieldName()),String.format("字段名[%s]-目前不支持",detail.getFieldName()));
AssertUtils.isTrue(OcrConstant.SUPPORTED_FIELD_NAMES.contains(detail.getGetField()),String.format("获取字段[%s]-目前不支持",detail.getGetField()));
detail.setMetadataConfigId(ocrMetadataConfig.getId());
ocrMetadataConfigDetailService.saveOrUpdate(detail);
}
@ -126,11 +121,11 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
//删除旧明细
List<String> notRemoveIdList = new ArrayList<>();
if (saveOcrMetadataConfigVO.getOcrMetadataConfigDetailList().size()>0) {
notRemoveIdList = saveOcrMetadataConfigVO.getOcrMetadataConfigDetailList().stream().map(o -> o.getId()).collect(Collectors.toList());
notRemoveIdList = saveOcrMetadataConfigVO.getOcrMetadataConfigDetailList().stream().map(OcrMetadataConfigDetail::getId).collect(Collectors.toList());
}
LambdaQueryWrapper<OcrMetadataConfigDetail> removeQueryWrapper = new LambdaQueryWrapper<OcrMetadataConfigDetail>();
LambdaQueryWrapper<OcrMetadataConfigDetail> removeQueryWrapper = new LambdaQueryWrapper<>();
removeQueryWrapper.eq(OcrMetadataConfigDetail::getMetadataConfigId, saveOcrMetadataConfigVO.getId());
removeQueryWrapper.notIn(notRemoveIdList!=null&&notRemoveIdList.size()>0, OcrMetadataConfigDetail::getId,notRemoveIdList);
removeQueryWrapper.notIn(CollectionUtils.isNotEmpty(notRemoveIdList), OcrMetadataConfigDetail::getId,notRemoveIdList);
//TODO zwt先检测这些删除的有没有被规则检查配置 绑定(删除元数据配置明细时,需不需要先检查该元数据配置明细有没有被规则检查配置绑定,如果被绑定是否需要提示 不可删除)
ocrMetadataConfigDetailService.remove(removeQueryWrapper);
return ocrMetadataConfig;
@ -142,30 +137,24 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
params.put("getField",ocrMetadataConfig.getGetField());
params.put("configName",ocrMetadataConfig.getConfigName());
params.put("resultName",ocrMetadataConfig.getResultName());
/*params.put("column","createTime");
params.put("order","desc");*/
IPage<OcrMetadataConfigDTO> pageList=baseMapper.pageVo(page,params);
List<OcrMetadataConfigDetail> metadataConfigDetails = ocrMetadataConfigDetailService.list();
List<OcrMetadataConfigDetail> arrayTestList=new ArrayList<>();
List<String> taskTypeIdList = pageList.getRecords().stream().map(a -> a.getTaskType()).collect(Collectors.toList());
List<OcrMetadataConfigDetail> arrayTestList;
List<String> taskTypeIdList = pageList.getRecords().stream().map(OcrMetadataConfig::getTaskType).collect(Collectors.toList());
List<OcrTaskType> ocrTaskTypeList=new ArrayList<>();
if (taskTypeIdList.size()>0) {
ocrTaskTypeList = ocrTaskTypeService.listByIds(taskTypeIdList);
}
String fieldName=null,getField=null;
String fieldName,getField;
for (OcrMetadataConfigDTO record : pageList.getRecords()) {
if (StringUtils.isNotBlank(record.getTaskType())) {
String taskTypeName = ocrTaskTypeList.stream().filter(o -> o.getId().equals(record.getTaskType())).map(o -> o.getTypeName()).collect(Collectors.joining(""));
String taskTypeName = ocrTaskTypeList.stream().filter(o -> o.getId().equals(record.getTaskType())).map(OcrTaskType::getTypeName).collect(Collectors.joining(""));
record.setTaskType_dictText(taskTypeName);
}
if (metadataConfigDetails!=null && metadataConfigDetails.size()>0) {
arrayTestList = metadataConfigDetails.stream().filter(m -> m.getMetadataConfigId().equals(record.getId())).collect(Collectors.toList());
fieldName = arrayTestList.stream().map(o -> o.getFieldName()).collect(Collectors.joining(","));
getField = arrayTestList.stream().map(o -> o.getGetField()).collect(Collectors.joining(","));
fieldName = arrayTestList.stream().map(OcrMetadataConfigDetail::getFieldName).collect(Collectors.joining(","));
getField = arrayTestList.stream().map(OcrMetadataConfigDetail::getGetField).collect(Collectors.joining(","));
record.setResultName(fieldName);
record.setGetField(getField);
record.setOcrMetadataConfigDetailList(arrayTestList);
@ -176,13 +165,13 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
@Override
public List<OcrMetadataConfigDTO> allList(List<String> idList) {
List<OcrMetadataConfigDTO> allList=new ArrayList<>();
List<OcrMetadataConfigDTO> allList;
if (idList!=null && idList.size()>0) {
allList=baseMapper.allList(idList);
}else{
allList=baseMapper.allList(null);
}
List<String> taskTypeIdList = allList.stream().map(a -> a.getTaskType()).collect(Collectors.toList());
List<String> taskTypeIdList = allList.stream().map(OcrMetadataConfig::getTaskType).collect(Collectors.toList());
List<OcrTaskType> ocrTaskTypeList=new ArrayList<>();
if (taskTypeIdList.size()>0) {
ocrTaskTypeList = ocrTaskTypeService.listByIds(taskTypeIdList);
@ -190,20 +179,20 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
}
List<OcrMetadataConfigDetail> metadataConfigDetails = ocrMetadataConfigDetailService.list();
List<OcrMetadataConfigDetail> arrayTestList=new ArrayList<>();
String fieldName=null,getField=null;
List<OcrMetadataConfigDetail> arrayTestList;
String fieldName,getField;
for (OcrMetadataConfigDTO ocrMetadataConfig : allList) {
ocrMetadataConfig.setId(ocrMetadataConfig.getId());
ocrMetadataConfig.setConfigName(ocrMetadataConfig.getConfigName());
if (StringUtils.isNotBlank(ocrMetadataConfig.getTaskType())) {
String taskTypeName = ocrTaskTypeList.stream().filter(o -> o.getId().equals(ocrMetadataConfig.getTaskType())).map(o -> o.getTypeName()).collect(Collectors.joining(""));
String taskTypeName = ocrTaskTypeList.stream().filter(o -> o.getId().equals(ocrMetadataConfig.getTaskType())).map(OcrTaskType::getTypeName).collect(Collectors.joining(""));
ocrMetadataConfig.setTaskType_dictText(taskTypeName);
}
if (metadataConfigDetails!=null&&metadataConfigDetails.size()>0) {
arrayTestList = metadataConfigDetails.stream().filter(m -> m.getMetadataConfigId().equals(ocrMetadataConfig.getId())).collect(Collectors.toList());
fieldName = arrayTestList.stream().map(o -> o.getFieldName()).collect(Collectors.joining(","));
getField = arrayTestList.stream().map(o -> o.getGetField()).collect(Collectors.joining(","));
fieldName = arrayTestList.stream().map(OcrMetadataConfigDetail::getFieldName).collect(Collectors.joining(","));
getField = arrayTestList.stream().map(OcrMetadataConfigDetail::getGetField).collect(Collectors.joining(","));
ocrMetadataConfig.setResultName(fieldName);
ocrMetadataConfig.setGetField(getField);
ocrMetadataConfig.setOcrMetadataConfigDetailList(arrayTestList);
@ -218,8 +207,8 @@ public class OcrMetadataConfigServiceImpl extends ServiceImpl<OcrMetadataConfigM
OcrMetadataConfig ocrMetadataConfig = this.getById(id);
BeanUtils.copyProperties(ocrMetadataConfig,copyEntityVo);
List<OcrMetadataConfigDetail> list = ocrMetadataConfigDetailService.list(new LambdaQueryWrapper<OcrMetadataConfigDetail>().eq(OcrMetadataConfigDetail::getMetadataConfigId, id));
String fieldName = list.stream().map(o -> o.getFieldName()).collect(Collectors.joining(","));
String getField = list.stream().map(o -> o.getGetField()).collect(Collectors.joining(","));
String fieldName = list.stream().map(OcrMetadataConfigDetail::getFieldName).collect(Collectors.joining(","));
String getField = list.stream().map(OcrMetadataConfigDetail::getGetField).collect(Collectors.joining(","));
copyEntityVo.setResultName(fieldName);
copyEntityVo.setGetField(getField);
copyEntityVo.setOcrMetadataConfigDetailList(list);

Loading…
Cancel
Save