Merge branch 'master' of https://git.mcnetmart.com/guoxiangbin/ocr
# Conflicts: # jyjz-system/jyjz-system-oa/src/main/java/cn/jyjz/xiaoyao/ocr/service/impl/OcrTaskchildPictureServiceImpl.javadev
commit
fa6c8b937a
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,22 @@
|
||||
package cn.jyjz.xiaoyao.ocr.api;
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceParameter;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
|
||||
import cn.jyjz.xiaoyao.ocr.api.utils.ApiPage;
|
||||
|
||||
/**
|
||||
* 无量云三方api接口
|
||||
*
|
||||
* @author shuli.Yao
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 9:55
|
||||
*/
|
||||
public interface PrevailCloudApi {
|
||||
|
||||
/**
|
||||
* 根据参数调用
|
||||
* @param pictureSourceParameter
|
||||
* @return
|
||||
*/
|
||||
ApiPage<PictureSourceResult> pullPictureSource(PictureSourceParameter pictureSourceParameter) throws Exception;
|
||||
}
|
@ -0,0 +1,57 @@
|
||||
package cn.jyjz.xiaoyao.ocr.api.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 图片数据源api 请求参数实体
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 10:19
|
||||
*/
|
||||
@Data
|
||||
public class PictureSourceParameter {
|
||||
|
||||
/**
|
||||
* 开始日期
|
||||
*/
|
||||
Date startTime;
|
||||
|
||||
/**
|
||||
* 结束日期
|
||||
*/
|
||||
Date endTime;
|
||||
|
||||
/**
|
||||
* 每页数量 每次最大200条
|
||||
*/
|
||||
Integer pageSize;
|
||||
|
||||
/**
|
||||
* 页码
|
||||
*/
|
||||
Integer pageNo;
|
||||
|
||||
/**
|
||||
* 项目编号
|
||||
*/
|
||||
Long projectNo;
|
||||
|
||||
/**
|
||||
* 计划id
|
||||
*/
|
||||
Long planId;
|
||||
|
||||
/**
|
||||
* 业务主体
|
||||
*/
|
||||
Long accountNo;
|
||||
|
||||
/**
|
||||
* 租户信息
|
||||
*/
|
||||
Long tenantNo;
|
||||
|
||||
}
|
@ -0,0 +1,115 @@
|
||||
package cn.jyjz.xiaoyao.ocr.api.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import cn.jyjz.xiaoyao.ocr.api.PrevailCloudApi;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceParameter;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
|
||||
import cn.jyjz.xiaoyao.ocr.api.utils.*;
|
||||
import cn.jyjz.xiaoyao.ocr.thread.TaskQueue;
|
||||
import cn.jyjz.xiaoyao.ocr.util.httputil.HttpClient;
|
||||
import cn.jyjz.xiaoyao.ocr.util.httputil.HttpMethod;
|
||||
import cn.jyjz.xiaoyao.ocr.util.httputil.HttpParamers;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import liquibase.pro.packaged.S;
|
||||
import org.apache.commons.collections.SequencedHashMap;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 图片数据接口实现类
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 10:16
|
||||
*/
|
||||
@Service
|
||||
public class PrevailCloudApiImpl implements PrevailCloudApi {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(PrevailCloudApiImpl.class);
|
||||
|
||||
/**
|
||||
* 注入api 配置信息
|
||||
*/
|
||||
@Autowired
|
||||
private ApiConfig apiConfig;
|
||||
|
||||
/**
|
||||
* 拉取图片信息
|
||||
*/
|
||||
private String pictureSourceUrl = "/pangu/jingwei/ocr/query/pb/task/pageList";
|
||||
|
||||
/**
|
||||
* 拉取项目信息
|
||||
*/
|
||||
private String projectSourceUrl = "/pangu/jingwei/ocr/query/pb/project/pageList";
|
||||
|
||||
/**
|
||||
* 拉取租户信息
|
||||
*/
|
||||
private String tenantSourceUrl = "/pangu/jingwei/ocr/query/pb/tenant/info";
|
||||
|
||||
|
||||
@Override
|
||||
public ApiPage<PictureSourceResult> pullPictureSource(PictureSourceParameter pictureSourceParameter) throws Exception {
|
||||
//1.检查api配置是否正常
|
||||
if(!apiConfig.checkConfig()){
|
||||
return null;
|
||||
}
|
||||
|
||||
//2.对象转map
|
||||
Map<String, Object> queryParam = BeanUtil.beanToMap(pictureSourceParameter);
|
||||
Map<String,String> queryParamStr = new HashMap<>();
|
||||
//map值转string 注意对日期类型进行操作,加密包要求值全部为string
|
||||
for (String key : queryParam.keySet()) {
|
||||
if(queryParam.get(key)!=null){
|
||||
queryParamStr.put(key,queryParam.get(key).toString());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//加密请求参数
|
||||
String tenantNo = pictureSourceParameter.getTenantNo().toString();
|
||||
String json = JSONObject.toJSONString(queryParam);
|
||||
RequestData requestData = ApiHelper.buildRequest(tenantNo, apiConfig.getAccessKey(), apiConfig.getAccessCode(),json);
|
||||
|
||||
//组装请求参数
|
||||
String url = apiConfig.getInterfaceDomain()+pictureSourceUrl;
|
||||
String requestBodyJson = JSONObject.toJSONString(requestData);
|
||||
HttpParamers httpParamers = new HttpParamers(HttpMethod.POST);
|
||||
httpParamers.setJsonParamer(requestBodyJson);
|
||||
//发起请求
|
||||
String responseJsonStr = HttpClient.doPost(url,httpParamers,null,apiConfig.getConnectTimeout(),apiConfig.getReadTimeout());
|
||||
System.out.println(responseJsonStr);
|
||||
ResultData<String> resultData =JSONUtil.toBean(responseJsonStr,ResultData.class);
|
||||
|
||||
//解密请求数据
|
||||
if(resultData.getStatus()==100){
|
||||
//解析基础数据
|
||||
String data = ApiHelper.decryptResponse(apiConfig.getAccessCode(), resultData);
|
||||
ApiPage<String> apiPage = JSONUtil.toBean(data,ApiPage.class);
|
||||
//解析数据结果为List
|
||||
List<PictureSourceResult> listResult = JSONUtil.toList(JSONObject.toJSONString(apiPage.getRecords()),PictureSourceResult.class);
|
||||
ApiPage<PictureSourceResult> resultApiPage = new ApiPage<>();
|
||||
resultApiPage.setPageNo(apiPage.getPageNo());
|
||||
resultApiPage.setPageSize(apiPage.getPageSize());
|
||||
resultApiPage.setTotal(apiPage.getTotal());
|
||||
resultApiPage.setRecords(listResult);
|
||||
return resultApiPage;
|
||||
}else{
|
||||
logger.debug("请求图片接口数据失败,参数:{},返回值:{}",json,responseJsonStr);
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package cn.jyjz.xiaoyao.ocr.api.utils;
|
||||
|
||||
import cn.jyjz.xiaoyao.common.base.util.StringUtils;
|
||||
import lombok.Data;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* api 环境配置
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 11:54
|
||||
*/
|
||||
@Component
|
||||
@Data
|
||||
public class ApiConfig {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(ApiConfig.class);
|
||||
|
||||
/**
|
||||
* 无量云 接口域名
|
||||
*/
|
||||
@Value("${ocr.api.wly.interface-domain}")
|
||||
private String interfaceDomain;
|
||||
|
||||
/**
|
||||
* 无量云 秘钥
|
||||
*/
|
||||
@Value("${ocr.api.wly.accessKey}")
|
||||
private String accessKey;
|
||||
|
||||
/**
|
||||
* 无量云 编码
|
||||
*/
|
||||
@Value("${ocr.api.wly.accessCode}")
|
||||
private String accessCode;
|
||||
|
||||
|
||||
/**
|
||||
* 请求超时时间 默认请求5秒
|
||||
*/
|
||||
@Value("${ocr.api.wly.connectTimeout}")
|
||||
private Integer connectTimeout = 5000;
|
||||
|
||||
/**
|
||||
* 接收超时时间 默认请求1分钟
|
||||
*/
|
||||
@Value("${ocr.api.wly.readTimeout}")
|
||||
private Integer readTimeout = 60000;
|
||||
|
||||
/**
|
||||
* 检查配置文件是否 正确注入
|
||||
* @return
|
||||
*/
|
||||
public boolean checkConfig(){
|
||||
if(!StringUtils.isEmpty(interfaceDomain) && !StringUtils.isEmpty(accessKey) && !StringUtils.isEmpty(accessCode)){
|
||||
return true;
|
||||
}
|
||||
logger.error("获取api配置包含为空信息,域名:{},秘钥:{},秘钥编码:{}",this.interfaceDomain,this.accessKey,this.accessCode);
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
@ -1,7 +1,6 @@
|
||||
package cn.jyjz.xiaoyao.ocr.util;
|
||||
package cn.jyjz.xiaoyao.ocr.api.utils;
|
||||
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.springframework.lang.Nullable;
|
@ -0,0 +1,37 @@
|
||||
package cn.jyjz.xiaoyao.ocr.api.utils;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* api分页对象
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 11:31
|
||||
*/
|
||||
@Data
|
||||
public class ApiPage<T> {
|
||||
|
||||
/**
|
||||
* 当前页码
|
||||
*/
|
||||
Integer pageNo;
|
||||
|
||||
/**
|
||||
* 每页条数
|
||||
*/
|
||||
Integer pageSize;
|
||||
|
||||
/**
|
||||
* 总数
|
||||
*/
|
||||
Integer total;
|
||||
|
||||
/**
|
||||
* 内容
|
||||
*/
|
||||
List<T> records;
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package cn.jyjz.xiaoyao.ocr.util;
|
||||
package cn.jyjz.xiaoyao.ocr.api.utils;
|
||||
|
||||
/**
|
||||
* @ClassName ReturnCode
|
@ -0,0 +1,74 @@
|
||||
package cn.jyjz.xiaoyao.ocr.controller;
|
||||
|
||||
import cn.hutool.core.date.DateTime;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.jyjz.xiaoyao.ocr.api.PrevailCloudApi;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceParameter;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
|
||||
import cn.jyjz.xiaoyao.ocr.api.utils.ApiPage;
|
||||
import cn.jyjz.xiaoyao.ocr.thread.TaskQueue;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.Instant;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 19:47
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/test/api")
|
||||
public class ApiTestController {
|
||||
@Autowired
|
||||
private PrevailCloudApi prevailCloudApi;
|
||||
|
||||
@GetMapping("psTest")
|
||||
public String psTset(HttpServletRequest request){
|
||||
String beginStr = request.getParameter("beginStr");
|
||||
String endStr = request.getParameter("endStr");
|
||||
String pageSize = request.getParameter("pageSize");
|
||||
String pageNo = request.getParameter("pageNo");
|
||||
|
||||
PictureSourceParameter pictureSourceParameter = new PictureSourceParameter();
|
||||
// DateTime dateTime = DateUtil.parse(beginStr+" 00:00:00","yyyy-MM-dd HH:mm:ss");
|
||||
DateTime dateTime = DateUtil.parse("2024-03-31 07:00:000","yyyy-MM-dd HH:mm:ss");
|
||||
Instant binstant = dateTime.toInstant();
|
||||
// DateTime dateTime1 = DateUtil.parse(" 00:00:00","yyyy-MM-dd HH:mm:ss");
|
||||
DateTime dateTime1 = DateUtil.parse("2024-03-31 09:00:00","yyyy-MM-dd HH:mm:ss");
|
||||
Instant einstant = dateTime1.toInstant();
|
||||
pictureSourceParameter.setStartTime(Date.from(binstant));
|
||||
pictureSourceParameter.setEndTime(Date.from(einstant));
|
||||
pictureSourceParameter.setPageNo(Integer.parseInt(pageNo));
|
||||
pictureSourceParameter.setPageSize(Integer.parseInt(pageSize));
|
||||
pictureSourceParameter.setTenantNo(1714548920583360512L);
|
||||
pictureSourceParameter.setAccountNo(1714559587755397120L);
|
||||
try {
|
||||
ApiPage<PictureSourceResult> apiPage = prevailCloudApi.pullPictureSource(pictureSourceParameter);
|
||||
List<PictureSourceResult> listResult= apiPage.getRecords();
|
||||
int count = apiPage.getTotal();
|
||||
int localCount = listResult.size();
|
||||
int size = 0;
|
||||
for (PictureSourceResult pictureSourceResult : listResult) {
|
||||
if(pictureSourceResult.getLivePhoto()==null){
|
||||
continue;
|
||||
}
|
||||
size++;
|
||||
//将可以处理数据放入处理队列中
|
||||
TaskQueue.pictureDisposePushData(pictureSourceResult);
|
||||
}
|
||||
return "当前区间内图片总数:"+count+"条,本次获取:"+localCount+"条,可处理数据:"+size+"条";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
return "处理失败";
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,97 @@
|
||||
package cn.jyjz.xiaoyao.ocr.controller;
|
||||
|
||||
import cn.jyjz.xiaoyao.common.base.service.UserTokenService;
|
||||
import cn.jyjz.xiaoyao.common.base.util.RequestBaseUtil;
|
||||
import cn.jyjz.xiaoyao.common.base.vo.ResultVo;
|
||||
import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil;
|
||||
import cn.jyjz.xiaoyao.common.base.vo.UserToken;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import cn.jyjz.xiaoyao.ocr.service.IOcrSearchHistoryService;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* ocr控制器
|
||||
*
|
||||
* @author 你的肉
|
||||
* @Date 2024-03-15 19:53:30
|
||||
*/
|
||||
@CrossOrigin
|
||||
@RestController
|
||||
@RequestMapping("/ocr/history")
|
||||
public class OcrSearchHistoryController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private IOcrSearchHistoryService ocrSearchHistoryService;
|
||||
|
||||
@Autowired
|
||||
private UserTokenService userTokenService;
|
||||
|
||||
/**
|
||||
* 搜索查询
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/searchList", method = RequestMethod.GET)
|
||||
public ResultVo searchList(HttpServletRequest request,
|
||||
@RequestParam(value = "search", required = false) String search) {
|
||||
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request));
|
||||
//执行查询方法
|
||||
List<String> selectsearch = ocrSearchHistoryService.selectsearch(search, userToken.getUsername());
|
||||
|
||||
OcrSearchHistory ocrsearchhistory =new OcrSearchHistory();
|
||||
ocrsearchhistory.setHistoryname(search);
|
||||
ocrsearchhistory.setUserid(Long.valueOf(userToken.getUserid()));
|
||||
ocrsearchhistory.setCreatedate(System.currentTimeMillis());
|
||||
ocrSearchHistoryService.save(ocrsearchhistory);
|
||||
|
||||
// return new ResponseEntity<Object>(selectsearch, HttpStatus.OK);
|
||||
|
||||
return ResultVoUtil.success(selectsearch);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 通过 删除历史记录
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/searchdelete", method = RequestMethod.DELETE)
|
||||
public ResultVo searchdelete(HttpServletRequest request) {
|
||||
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request));
|
||||
QueryWrapper<OcrSearchHistory> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("userid",userToken.getUserid());
|
||||
//根据具体情况 判断 是否需要 进行数据返回, 默认不返回数据
|
||||
ocrSearchHistoryService.remove(wrapper);
|
||||
// return new ResponseEntity<Object>("true",HttpStatus.OK);
|
||||
return ResultVoUtil.success(ResultVo.SUCCESS);
|
||||
}
|
||||
|
||||
/**
|
||||
* 历史搜索
|
||||
*
|
||||
* @param request
|
||||
* @return
|
||||
*/
|
||||
@RequestMapping(value = "/historySearch", method = RequestMethod.GET)
|
||||
public ResultVo historySearch(HttpServletRequest request) {
|
||||
UserToken userToken = this.userTokenService.getUserToken(RequestBaseUtil.getToken(request));
|
||||
|
||||
QueryWrapper<OcrSearchHistory> wrapper = new QueryWrapper<>();
|
||||
wrapper.select("historyname","createdate").eq("userid",userToken.getUserid()).orderByDesc("createdate").last("limit 8");
|
||||
List<OcrSearchHistory> list = ocrSearchHistoryService.list(wrapper);
|
||||
|
||||
// return new ResponseEntity<List<OcrSearchHistory>>(list, HttpStatus.OK);
|
||||
return ResultVoUtil.success(list);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataDao;
|
||||
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionary;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrMsg;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface OcrDictionaryDao extends BaseMapper<OcrDictionary> {
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataDao;
|
||||
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionary;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionaryGroup;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Mapper
|
||||
public interface OcrDictionaryGroupDao extends BaseMapper<OcrDictionaryGroup> {
|
||||
}
|
@ -0,0 +1,23 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataDao;
|
||||
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import liquibase.pro.packaged.S;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
@Mapper
|
||||
public interface OcrSearchHistoryMapper extends BaseMapper<OcrSearchHistory> {
|
||||
List<String> selectsearch(@Param("search")String search,@Param("assignee") String assignee);
|
||||
}
|
@ -0,0 +1,60 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataobject;
|
||||
|
||||
import cn.jyjz.xiaoyao.common.base.jsonDomain.DateSerializer;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/16 12:40
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "业务数据字典值表", title = "业务数据字典值表")
|
||||
@ApiModel(value="业务数据字典值表", description="业务数据字典值表")
|
||||
@TableName(value = "ocr_dictionary")
|
||||
public class OcrDictionary {
|
||||
|
||||
@ApiModelProperty(value ="主键")
|
||||
@TableId(value = "id",type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField(value="id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value ="三方系统 原始id 可为空")
|
||||
@TableField(value="source_id")
|
||||
private Long sourceId;
|
||||
|
||||
@ApiModelProperty(value ="字典值")
|
||||
@TableField(value="value")
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty(value ="描述")
|
||||
@TableField(value="lable")
|
||||
private String lable;
|
||||
|
||||
@ApiModelProperty(value ="租户id")
|
||||
@TableField(value="tenant_id")
|
||||
private Long tenantId;
|
||||
|
||||
@ApiModelProperty(value ="字典组")
|
||||
@TableField(value="group_id")
|
||||
private Long groupId;
|
||||
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import liquibase.pro.packaged.S;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Builder;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
/**
|
||||
* TODO
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/16 12:40
|
||||
*/
|
||||
@Data
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Schema(name = "业务数据字典组表", title = "业务数据字典组表")
|
||||
@ApiModel(value="业务数据字典组表", description="业务数据字典组表")
|
||||
@TableName(value = "ocr_dictionary_group")
|
||||
public class OcrDictionaryGroup {
|
||||
@ApiModelProperty(value ="主键")
|
||||
@TableId(value = "id",type = IdType.ASSIGN_ID)
|
||||
@JsonSerialize(using = ToStringSerializer.class)
|
||||
@TableField(value="id")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty(value ="字典组中文描述")
|
||||
@TableField(value="label")
|
||||
private String label;
|
||||
|
||||
@ApiModelProperty(value ="对应属性字段名称")
|
||||
@TableField(value="field")
|
||||
private String field;
|
||||
|
||||
@ApiModelProperty(value ="备注")
|
||||
@TableField(value="remark")
|
||||
private String remark;
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package cn.jyjz.xiaoyao.ocr.dataobject;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
@TableName("ocr_search_history")
|
||||
public class OcrSearchHistory extends Model<OcrSearchHistory> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 历史主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Integer id;
|
||||
/**
|
||||
* 搜索历史名称
|
||||
*/
|
||||
private String historyname;
|
||||
|
||||
public Long getUserid() {
|
||||
return userid;
|
||||
}
|
||||
|
||||
public void setUserid(Long userid) {
|
||||
this.userid = userid;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long userid;
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private Long createdate;
|
||||
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
|
||||
public String getHistoryname() {
|
||||
return historyname;
|
||||
}
|
||||
|
||||
public void setHistoryname(String historyname) {
|
||||
this.historyname = historyname;
|
||||
}
|
||||
|
||||
public Long getCreatedate() {
|
||||
return createdate;
|
||||
}
|
||||
|
||||
public void setCreatedate(Long createdate) {
|
||||
this.createdate = createdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable pkVal() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "OcrSearchHistory{" +
|
||||
"id=" + id +
|
||||
", historyname=" + historyname +
|
||||
", userid=" + userid +
|
||||
", createdate=" + createdate +
|
||||
"}";
|
||||
}
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package cn.jyjz.xiaoyao.ocr.service;
|
||||
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
public interface IOcrSearchHistoryService extends IService<OcrSearchHistory> {
|
||||
List<String> selectsearch(String search,String assignee);
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package cn.jyjz.xiaoyao.ocr.service;
|
||||
import cn.jyjz.xiaoyao.common.mybatisplus.base.BaseService;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionary;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionaryGroup;
|
||||
import liquibase.pro.packaged.L;
|
||||
|
||||
/**
|
||||
* 业务向 数据字典 操作接口
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/16 12:48
|
||||
*/
|
||||
public interface OcrDictionaryService extends BaseService<OcrDictionary> {
|
||||
/**
|
||||
* 根据 字组标识、字典值、租户过滤当前字典是否存在此字典值。
|
||||
* @param groupId 字典组标识
|
||||
* @param value 字典值
|
||||
* @param tenantId 租户
|
||||
* @return
|
||||
*/
|
||||
boolean isValueExists(Long groupId, String value, Long tenantId);
|
||||
|
||||
/**
|
||||
* 获取字典组信息
|
||||
* @param field
|
||||
* @return
|
||||
*/
|
||||
OcrDictionaryGroup queryGroupByField(String field);
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package cn.jyjz.xiaoyao.ocr.service.impl;
|
||||
|
||||
import cn.jyjz.xiaoyao.common.mybatisplus.base.BaseServiceImpl;
|
||||
import cn.jyjz.xiaoyao.ocr.dataDao.OcrDictionaryDao;
|
||||
import cn.jyjz.xiaoyao.ocr.dataDao.OcrDictionaryGroupDao;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionary;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionaryGroup;
|
||||
import cn.jyjz.xiaoyao.ocr.service.OcrDictionaryService;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 业务向 数据字典 操作接口实现类
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/16 12:48
|
||||
*/
|
||||
@Service
|
||||
@Slf4j
|
||||
public class OcrDictionaryServiceImpl extends BaseServiceImpl<OcrDictionaryDao, OcrDictionary> implements OcrDictionaryService {
|
||||
|
||||
@Autowired
|
||||
private OcrDictionaryGroupDao ocrDictionaryGroupDao;
|
||||
|
||||
@Override
|
||||
public boolean isValueExists(Long groupId, String value, Long tenantId) {
|
||||
QueryWrapper queryWrapper =new QueryWrapper();
|
||||
queryWrapper.eq("group_id",groupId);
|
||||
queryWrapper.eq("value",value);
|
||||
queryWrapper.eq("tenant_id",groupId);
|
||||
Long count = baseMapper.selectCount(queryWrapper);
|
||||
return count>0 ? false:true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OcrDictionaryGroup queryGroupByField(String field) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("field",field);
|
||||
List<OcrDictionaryGroup> ocrDictionaryGroupList = ocrDictionaryGroupDao.selectList(queryWrapper);
|
||||
if(ocrDictionaryGroupList!=null && ocrDictionaryGroupList.size()>0){
|
||||
return ocrDictionaryGroupList.get(0);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.jyjz.xiaoyao.ocr.service.impl;
|
||||
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory;
|
||||
import cn.jyjz.xiaoyao.ocr.service.IOcrSearchHistoryService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
import cn.jyjz.xiaoyao.ocr.dataDao.OcrSearchHistoryMapper;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 综合搜索历史表 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author 你的肉123
|
||||
* @since 2024-03-15
|
||||
*/
|
||||
@Service
|
||||
public class OcrSearchHistoryServiceImpl extends ServiceImpl<OcrSearchHistoryMapper, OcrSearchHistory> implements IOcrSearchHistoryService {
|
||||
|
||||
@Resource
|
||||
OcrSearchHistoryMapper ocrsearchhistorymapper;
|
||||
|
||||
@Override
|
||||
public List<String> selectsearch(String search, String assignee) {
|
||||
return ocrsearchhistorymapper.selectsearch(search,assignee);
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.jyjz.xiaoyao.ocr.thread;
|
||||
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* 初始化执行器
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/03/14 3:08
|
||||
*/
|
||||
@Component
|
||||
public class TaskRunner implements CommandLineRunner {
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
TaskThreadPool taskThreadPool = new TaskThreadPool();
|
||||
taskThreadPool.startPictureDisposePull();
|
||||
taskThreadPool.startPictureImgToLocalPull();
|
||||
}
|
||||
}
|
@ -0,0 +1,87 @@
|
||||
package cn.jyjz.xiaoyao.ocr.thread;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
|
||||
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
|
||||
import cn.jyjz.xiaoyao.ocr.thread.tasks.PictureDisposeTask;
|
||||
import cn.jyjz.xiaoyao.ocr.thread.tasks.PictureImgToLocalTask;
|
||||
import lombok.SneakyThrows;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* 任务线程池
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/03/14 3:08
|
||||
*/
|
||||
public class TaskThreadPool {
|
||||
|
||||
private static Logger logger = LoggerFactory.getLogger(TaskQueue.class);
|
||||
ExecutorService threadPool = null;
|
||||
|
||||
public TaskThreadPool(){
|
||||
if(threadPool ==null){
|
||||
threadPool = new ThreadPoolExecutor(
|
||||
10,
|
||||
40,
|
||||
3,
|
||||
TimeUnit.SECONDS,
|
||||
new LinkedBlockingDeque<>(),
|
||||
Executors.defaultThreadFactory(),
|
||||
new ThreadPoolExecutor.DiscardOldestPolicy());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动任务 入库消费者
|
||||
* @return
|
||||
*/
|
||||
public boolean startPictureDisposePull(){
|
||||
Runnable runnable = new Runnable() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug("无量云接口数据处理消费线程检测中...");
|
||||
while (true){
|
||||
PictureSourceResult pictureSourceResult = TaskQueue.pictureDisposePullData();
|
||||
if(pictureSourceResult!=null){
|
||||
threadPool.execute(new PictureDisposeTask(pictureSourceResult));
|
||||
}else{
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread thread=new Thread(runnable);
|
||||
thread.start();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 启动任务 入库消费者
|
||||
* @return
|
||||
*/
|
||||
public boolean startPictureImgToLocalPull(){
|
||||
Runnable runnable = new Runnable() {
|
||||
@SneakyThrows
|
||||
@Override
|
||||
public void run() {
|
||||
logger.debug("图片下载消费线程检测中...");
|
||||
while (true){
|
||||
PictureImgToLocalEntity pictureImgToLocalEntity = TaskQueue.pictureImgToLocalPullData();
|
||||
if(pictureImgToLocalEntity!=null){
|
||||
threadPool.execute(new PictureImgToLocalTask(pictureImgToLocalEntity));
|
||||
}else{
|
||||
Thread.sleep(5000);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread thread=new Thread(runnable);
|
||||
thread.start();
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,31 @@
|
||||
package cn.jyjz.xiaoyao.ocr.thread.entity;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 图片转储本地处理对象
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/16 17:11
|
||||
*/
|
||||
@Data
|
||||
public class PictureImgToLocalEntity {
|
||||
|
||||
/**
|
||||
* 图片表id
|
||||
*/
|
||||
private Long pictureId;
|
||||
|
||||
/**
|
||||
* 图片地址
|
||||
*/
|
||||
private String ImgUrl;
|
||||
|
||||
|
||||
/**
|
||||
* 本地存储地址
|
||||
*/
|
||||
private String localPath;
|
||||
|
||||
}
|
@ -0,0 +1,194 @@
|
||||
package cn.jyjz.xiaoyao.ocr.thread.tasks;
|
||||
|
||||
import cn.jyjz.xiaoyao.common.base.util.SpringUtils;
|
||||
import cn.jyjz.xiaoyao.common.base.util.StringUtils;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
|
||||
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 无量云接口 数据处理队列
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 11:15
|
||||
*/
|
||||
public class PictureDisposeTask implements Runnable{
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private PictureSourceResult pictureSourceResult;
|
||||
|
||||
public PictureDisposeTask(PictureSourceResult pictureSourceResult){
|
||||
this.pictureSourceResult = pictureSourceResult;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//1.对图片对象进行入库操作
|
||||
OcrPictureService ocrPictureService = SpringUtils.getBean("ocrPictureService");
|
||||
|
||||
//获取当前任务中有多少图片
|
||||
List<Map<String,Object>> livePhoto = pictureSourceResult.getLivePhoto();
|
||||
|
||||
//定义新增集合对象
|
||||
List<OcrPicture> ocrPictureList = new ArrayList<>();
|
||||
for (Map<String, Object> map : livePhoto) {
|
||||
//检查图片地址是否为空
|
||||
if(map.get("imgUrl")!=null && !StringUtils.isEmpty(map.get("imgUrl").toString())){
|
||||
//不为空开始组装参数 入库
|
||||
OcrPicture picture = new OcrPicture();
|
||||
//租户编号
|
||||
picture.setTenantId(pictureSourceResult.getTenantNo());
|
||||
//租户名称
|
||||
picture.setTenantname(pictureSourceResult.getTenantName());
|
||||
//租户状态
|
||||
if(pictureSourceResult.getTenantStatus()!=null){
|
||||
picture.setTenantstatus(pictureSourceResult.getTenantStatus().toString());
|
||||
}
|
||||
//业务主体
|
||||
if(pictureSourceResult.getAccountNo()!=null){
|
||||
picture.setPictureid(pictureSourceResult.getAccountNo().toString());
|
||||
}
|
||||
//业务主体名称
|
||||
picture.setPicturename(pictureSourceResult.getAccountName());
|
||||
//业务主体状态
|
||||
picture.setPicturestatus(pictureSourceResult.getPlanChildStatus());
|
||||
//项目编号
|
||||
if(pictureSourceResult.getProjectNo()!=null){
|
||||
picture.setProjectid(pictureSourceResult.getProjectNo().toString());
|
||||
}
|
||||
//项目id
|
||||
picture.setCategoryid(251374070600303007L);
|
||||
|
||||
//项目名称
|
||||
picture.setPicturename(pictureSourceResult.getProjectName());
|
||||
//项目状态
|
||||
if(pictureSourceResult.getProjectNo()!=null) {
|
||||
picture.setProjectstatus(pictureSourceResult.getProjectNo().toString());
|
||||
}
|
||||
//所属主计划id
|
||||
if(pictureSourceResult.getPlanNo()!=null) {
|
||||
picture.setPlanid(pictureSourceResult.getPlanNo().toString());
|
||||
}
|
||||
//所属计划名称
|
||||
picture.setPlanname(pictureSourceResult.getPlanName());
|
||||
//所属计划状态
|
||||
picture.setPlanstatus( pictureSourceResult.getPlanstatus());
|
||||
//所属子计划id
|
||||
if(pictureSourceResult.getPlanChildNo()!=null) {
|
||||
picture.setPlanchildid(pictureSourceResult.getPlanChildNo().toString());
|
||||
}
|
||||
//所属子计划名称
|
||||
picture.setPlanchildname(pictureSourceResult.getPlanChildName());
|
||||
//所属子计划状态
|
||||
picture.setPlanchildstatus(pictureSourceResult.getPlanChildStatus());
|
||||
//所属任务id
|
||||
picture.setRemark(pictureSourceResult.getTaskId().toString());
|
||||
//所属任务名称
|
||||
picture.setTaskname(pictureSourceResult.getTaskName());
|
||||
//任务来源名称
|
||||
picture.setField4(pictureSourceResult.getTaskName());
|
||||
//所属任务状态
|
||||
if(pictureSourceResult.getTenantStatus()!=null) {
|
||||
picture.setTaskstatus(pictureSourceResult.getTenantStatus().toString());
|
||||
}
|
||||
//提报人id
|
||||
picture.setUpuserid(pictureSourceResult.getUserNo().toString());
|
||||
//提报人名称
|
||||
picture.setUpname(pictureSourceResult.getUserName());
|
||||
//提报人名称
|
||||
picture.setField1(pictureSourceResult.getUserName());
|
||||
// picture.setUphead();//缺失提报人头像
|
||||
|
||||
//拜访详细地址
|
||||
StringBuilder addressDetails = new StringBuilder();
|
||||
//拜访省份
|
||||
if(pictureSourceResult.getProvince()!=null){
|
||||
if(pictureSourceResult.getProvince().get("name")!=null){
|
||||
addressDetails.append(pictureSourceResult.getProvince().get("name").toString());
|
||||
picture.setReleaseprovince(pictureSourceResult.getProvince().get("name").toString());
|
||||
}
|
||||
}
|
||||
//拜访城市
|
||||
if(pictureSourceResult.getCity()!=null){
|
||||
if(pictureSourceResult.getCity().get("name")!=null){
|
||||
addressDetails.append(pictureSourceResult.getCity().get("name").toString());
|
||||
picture.setReleasearea(pictureSourceResult.getCity().get("name").toString());
|
||||
}
|
||||
}
|
||||
//拜访定位信息
|
||||
if(pictureSourceResult.getLocation()!=null){
|
||||
if(pictureSourceResult.getCity().get("address")!=null){
|
||||
addressDetails.append(pictureSourceResult.getCity().get("address").toString());
|
||||
}
|
||||
}
|
||||
picture.setField10(addressDetails.toString());
|
||||
|
||||
//拜访客户类型
|
||||
if(pictureSourceResult.getTerminalType()!=null){
|
||||
if(pictureSourceResult.getTerminalType().get("name")!=null){
|
||||
picture.setField2(pictureSourceResult.getTerminalType().get("name").toString());
|
||||
}
|
||||
}
|
||||
|
||||
//拜访客户名称
|
||||
if(pictureSourceResult.getCustomerName()!=null){
|
||||
if(pictureSourceResult.getCustomerName().get("name")!=null){
|
||||
picture.setField3(pictureSourceResult.getCustomerName().get("name").toString());
|
||||
}
|
||||
}
|
||||
//拜访客户级别
|
||||
if(pictureSourceResult.getTerminalLevel()!=null){
|
||||
if(pictureSourceResult.getTerminalLevel().get("name")!=null){
|
||||
picture.setField6(pictureSourceResult.getTerminalLevel().get("name").toString());
|
||||
}
|
||||
}
|
||||
|
||||
//拜访项目类别
|
||||
if(pictureSourceResult.getProjectType()!=null){
|
||||
if(pictureSourceResult.getTerminalLevel().get("name")!=null){
|
||||
picture.setField17(pictureSourceResult.getTerminalLevel().get("name").toString());
|
||||
}
|
||||
}
|
||||
//拜访品种
|
||||
if(pictureSourceResult.getProductName()!=null){
|
||||
if(pictureSourceResult.getProductName().get("name")!=null){
|
||||
picture.setField9(pictureSourceResult.getProductName().get("name").toString());
|
||||
}
|
||||
}
|
||||
//生产基地
|
||||
picture.setField5(pictureSourceResult.getManufacturer());
|
||||
//拜访小结
|
||||
picture.setField8(pictureSourceResult.getDiscoveredIssues());
|
||||
//拜访日期
|
||||
picture.setField11(pictureSourceResult.getVisitDate());
|
||||
//定位距离
|
||||
picture.setField12(pictureSourceResult.getDistance());
|
||||
|
||||
//设置图片信息
|
||||
if(map.get("imgName")!=null){
|
||||
picture.setImgname(map.get("imgName").toString());
|
||||
}
|
||||
if(map.get("imgUrl")!=null){
|
||||
picture.setImgurl(map.get("imgUrl").toString());
|
||||
}
|
||||
//默认为创建人为admin
|
||||
picture.setCreateBy("1");
|
||||
ocrPictureList.add(picture);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//调用图片入库方法
|
||||
int size = ocrPictureService.savePictures(ocrPictureList);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.jyjz.xiaoyao.ocr.thread.tasks;
|
||||
|
||||
import cn.jyjz.xiaoyao.common.base.util.SpringUtils;
|
||||
import cn.jyjz.xiaoyao.common.base.util.StringUtils;
|
||||
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
|
||||
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
|
||||
import cn.jyjz.xiaoyao.ocr.service.OcrPictureService;
|
||||
import cn.jyjz.xiaoyao.ocr.thread.entity.PictureImgToLocalEntity;
|
||||
import cn.jyjz.xiaoyao.ocr.util.DownloadImgUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 无量云接口 数据处理队列
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/14 11:15
|
||||
*/
|
||||
public class PictureImgToLocalTask implements Runnable{
|
||||
protected Logger logger = LoggerFactory.getLogger(getClass());
|
||||
|
||||
private PictureImgToLocalEntity pictureImgToLocal;
|
||||
|
||||
public PictureImgToLocalTask(PictureImgToLocalEntity pictureImgToLocal){
|
||||
this.pictureImgToLocal = pictureImgToLocal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
//1.开始转储图片
|
||||
DownloadImgUtil.downloadImage(pictureImgToLocal.getImgUrl(), pictureImgToLocal.getLocalPath());
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,40 @@
|
||||
package cn.jyjz.xiaoyao.ocr.util;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
||||
|
||||
/**
|
||||
* 转储图片工具类
|
||||
*
|
||||
* @author hugh(shuli.yao) 1397940314@qq.com
|
||||
* @version 1.0
|
||||
* @date 2024/3/16 18:37
|
||||
*/
|
||||
public class DownloadImgUtil {
|
||||
private static Logger logger = LoggerFactory.getLogger(DownloadImgUtil.class);
|
||||
|
||||
/**
|
||||
* 下载网络图片缓存到本地服务器
|
||||
* @param imageUrl
|
||||
* @param destinationFile
|
||||
*/
|
||||
public static void downloadImage(String imageUrl, String destinationFile) {
|
||||
try (InputStream in = new URL(imageUrl).openStream();
|
||||
FileOutputStream out = new FileOutputStream(destinationFile)) {
|
||||
|
||||
byte[] buffer = new byte[4096];
|
||||
int n;
|
||||
while ((n = in.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, n);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,27 @@
|
||||
package cn.jyjz.xiaoyao.ocr.util;
|
||||
/**
|
||||
* 分页请求
|
||||
*/
|
||||
public class PageRequest {
|
||||
/**
|
||||
* 当前页码
|
||||
*/
|
||||
private int pageNum;
|
||||
/**
|
||||
* 每页数量
|
||||
*/
|
||||
private int pageSize;
|
||||
|
||||
public int getPageNum() {
|
||||
return pageNum;
|
||||
}
|
||||
public void setPageNum(int pageNum) {
|
||||
this.pageNum = pageNum;
|
||||
}
|
||||
public int getPageSize() {
|
||||
return pageSize;
|
||||
}
|
||||
public void setPageSize(int pageSize) {
|
||||
this.pageSize = pageSize;
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="cn.jyjz.xiaoyao.ocr.dataDao.OcrSearchHistoryMapper">
|
||||
|
||||
<!-- 通用查询映射结果 -->
|
||||
<resultMap id="BaseResultMap" type="cn.jyjz.xiaoyao.ocr.dataobject.OcrSearchHistory">
|
||||
<id column="id" property="id" />
|
||||
<result column="historyname" property="historyname" />
|
||||
<result column="userid" property="userid" />
|
||||
<result column="createdate" property="createdate" />
|
||||
</resultMap>
|
||||
|
||||
<!-- 通用查询结果列 -->
|
||||
<sql id="Base_Column_List">
|
||||
id, historyname, userid, createdate
|
||||
</sql>
|
||||
|
||||
<select id="selectsearch" resultType="map">
|
||||
|
||||
SELECT
|
||||
|
||||
CONCAT_WS("-",r.FROMTASKNAME,t.planName) as name
|
||||
FROM
|
||||
ocr_taskchild_picture r
|
||||
LEFT JOIN ocr_picture t ON r.PICTUREID = t.ID
|
||||
WHERE
|
||||
r.STATES='1'
|
||||
and
|
||||
r.ASSIGNEE=#{assignee}
|
||||
AND
|
||||
r.FROMTASKID like "%"#{search}"%"
|
||||
OR r.FROMTASKNAME like "%"#{search}"%"
|
||||
OR t.field1 like "%"#{search}"%"
|
||||
ORDER BY r.CREATEDATE DESC
|
||||
LIMIT 3
|
||||
|
||||
|
||||
|
||||
|
||||
</select>
|
||||
|
||||
|
||||
</mapper>
|
Loading…
Reference in new issue