feat:对接无量云数据接口,增加业务动态字典模块

1.增加无量云对接api
2.增加多线程、队列包处理无量云接口数据
3.增加业务动态字典,解析接口数据插入动态字典。
4.增加lombok工具依赖
pull/1/head
shuliYao 1 year ago
parent b2215e52ba
commit c79581f00b

@ -13,6 +13,9 @@
<artifactId>jyjz-system-oa</artifactId>
<version>1.0.0</version>
<name>jyjz-system-oa</name>
<properties>
<lombok.version>1.18.24</lombok.version>
</properties>
<dependencies>
<dependency>
@ -112,6 +115,11 @@
<groupId>cn.jyjz</groupId>
<artifactId>jyjz-system-admin</artifactId>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
</dependency>
</dependencies>
</project>
</project>

@ -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,199 @@
package cn.jyjz.xiaoyao.ocr.api.entity;
import lombok.Data;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
* api
*
* @author hugh(shuli.yao) 1397940314@qq.com
* @version 1.0
* @date 2024/3/14 10:19
*/
@Data
public class PictureSourceResult {
/**
* no
*/
Long tenantNo;
/**
*
*/
String tenantName;
/**
*
*/
Integer tenantStatus;
/**
* no
*/
Long accountNo;
/**
*
*/
String accountName;
/**
*
*/
Integer accountStatus;
/**
* ID
*/
Long projectNo;
/**
*
*/
String projectName;
/**
*
*/
Integer projectStatus;
/**
* ID
*/
Long planNo;
/**
*
*/
String planName;
/**
*
*/
String planstatus;
/**
* ID
*/
Long planChildNo;
/**
*
*/
String planChildName;
/**
*
*/
String planChildStatus;
/**
* ID
*/
Long taskId;
/**
*
*/
String taskName;
/**
*
*/
Integer taskStatus;
/**
* no
*/
Long userNo;
/**
*
*/
String userName;
/**
* 访/
*/
Map<String,Object> province;
/**
* 访
*/
Map<String,Object> city;
/**
* 访
*/
Map<String,Object> terminalType;
/**
* 访
*/
Map<String,Object> terminalLevel;
/**
* 访
*/
Map<String,Object> customerName;
/**
* 访
*/
Map<String,Object> projectType;
/**
*
*/
List<Map<String,Object>> productCard;
/**
* 访
*/
Map<String,Object> productName;
/**
*
*/
String manufacturer;
/**
* 访
*/
String discoveredIssues;
/**
* /
*/
String feedback;
/**
*
*/
Map<String,Object> location;
/**
*
*/
String distance;
/**
* 访
*/
String visitDate;
/**
*
*/
List<Map<String,Object>> livePhoto;
/**
*
*/
Map<String,Object> extendedField;
}

@ -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;
@ -116,7 +115,7 @@ public class ApiHelper {
* @throws Exception
*/
public static RequestData buildQueryRequest(String tenantCode, String accessKey, String accessCode,
Map<String, String> parameters) throws Exception {
Map<String, String> parameters) throws Exception {
RequestData requestData = new RequestData();
// tenant code
@ -630,9 +629,9 @@ public class ApiHelper {
// 转换为AES专用密钥
return new SecretKeySpec(key.getEncoded(), KEY_ALGORITHM);
}
public static void main(String arg[]){
BigDecimal b1 = new BigDecimal("42.29");
BigDecimal b2 = new BigDecimal("100");
int val = b1.compareTo(b2);
@ -647,26 +646,26 @@ public class ApiHelper {
queryParam.put("key1", "111");
try {
RequestData requestData = ApiHelper.buildQueryRequest("tenantCode", "accessKey", "accessCode", queryParam);
System.out.println(requestData.getData());
} catch (Exception e) {
throw new RuntimeException(e);
}
RequestData requestData = null;
try {
requestData = ApiHelper.buildRequest("tenantCode", "accessKey", "accessCode", queryParam);
} catch (Exception e) {
throw new RuntimeException(e);
}
System.out.println(requestData.getData());
ResultData<String> resultData = new ResultData<>(); // 实际返回对象
String data = null;
try {
data = ApiHelper.decryptResponse("accessCode", resultData);

@ -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;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
@ -62,19 +62,19 @@ public class RequestData implements Serializable {
private String accessKey;
/**
*
* @see cn.jyjz.xiaoyao.ocr.util.ApiHelper#encrypt(String, String, String)
* @see ApiHelper#encrypt(String, String, String)
*/
@ApiModelProperty(value = "加密的请求数据")
private String data;
/**
* Salt
* @see cn.jyjz.xiaoyao.ocr.util.ApiHelper # combineSalt(String, String)
* @see ApiHelper#combineSalt(String, String)
*/
@ApiModelProperty(value = "请求时间戳")
private long timestamp ;
/**
*
* @see cn.jyjz.xiaoyao.ocr.util.ApiHelper # getSignature(String, String, Map)
* @see ApiHelper#getSignature(String, String, Map)
*/
@ApiModelProperty(value = "数据签名")
private String signature;

@ -1,4 +1,4 @@
package cn.jyjz.xiaoyao.ocr.util;
package cn.jyjz.xiaoyao.ocr.api.utils;
import com.fasterxml.jackson.annotation.JsonIgnore;
import io.swagger.annotations.ApiModel;
@ -33,7 +33,7 @@ public class ResultData<T> implements Serializable {
/**
* Base64{@link String}
* @see cn.jyjz.xiaoyao.ocr.util.ApiHelper#encrypt(String, String, String)
* @see ApiHelper#encrypt(String, String, String)
*/
@ApiModelProperty(value = "后端返回结果")
private T data;
@ -45,13 +45,13 @@ public class ResultData<T> implements Serializable {
private boolean success;
/**
* Salt
* @see cn.jyjz.xiaoyao.ocr.util.ApiHelper#combineSalt(String, String)
* @see ApiHelper#combineSalt(String, String)
*/
@ApiModelProperty(value = "响应时间戳")
private long timestamp ;
/**
*
* @see cn.jyjz.xiaoyao.ocr.util.ApiHelper#getSignature(String, String, Map)
* @see ApiHelper#getSignature(String, String, Map)
*/
@ApiModelProperty(value = "数据签名")
private String signature;

@ -0,0 +1,77 @@
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.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
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.pictureDownloadPushData(pictureSourceResult);
}
return "当前区间内图片总数:"+count+"条,本次获取:"+localCount+"条,可处理数据:"+size+"条";
} catch (Exception e) {
e.printStackTrace();
}
return "处理失败";
}
}

@ -0,0 +1,64 @@
package cn.jyjz.xiaoyao.ocr.controller;
import cn.jyjz.xiaoyao.common.base.vo.ResultVo;
import cn.jyjz.xiaoyao.common.base.vo.ResultVoUtil;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionary;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionaryGroup;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrUpuser;
import cn.jyjz.xiaoyao.ocr.service.OcrDictionaryService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
/**
* ocr_
*
* @author hugh(shuli.yao) 1397940314@qq.com
* @version 1.0
* @date 2024/3/16 15:16
*/
@Api(tags="ocr_业务数据数据字典")
@RestController
@RequestMapping("/ocr/dictionary")
public class OcrDictionaryController {
@Autowired
private OcrDictionaryService ocrDictionaryService;
/**
*
*mail.zhangyong@gmail.com
*2024-01-14 10:27:02
**/
@GetMapping("/getDictionaryByField")
@ResponseBody
public ResultVo<IPage<OcrDictionary>> getDictionaryByField(HttpServletResponse response,
HttpServletRequest request,
@RequestParam(name="pageNo", defaultValue="1",required = true) Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10",required = true) Integer pageSize,
@RequestParam(name="field", defaultValue="upName",required = true) String field) {
String tenantId = request.getHeader("X-Tenant-Id");
if(StringUtils.isBlank(tenantId)){
return ResultVoUtil.error("租户主键不能为空");
}
OcrDictionaryGroup ocrDictionaryGroup= ocrDictionaryService.queryGroupByField(field);
if(ocrDictionaryGroup!=null){
Page<OcrDictionary> page = new Page<OcrDictionary>(pageNo, pageSize);
QueryWrapper queryWrapper =new QueryWrapper();
queryWrapper.eq("group_id",ocrDictionaryGroup.getId());
queryWrapper.eq("tenant_id",tenantId);
IPage<OcrDictionary> pageList = ocrDictionaryService.page(page, queryWrapper);
return new ResultVo<>(ResultVo.SUCCESS,"查询成功",pageList);
}
return new ResultVo<>(ResultVo.ERROR,"根据field查询不到字典组!");
}
}

@ -228,7 +228,7 @@ public class OcrPictureController extends BaseController{
Map<String,Object> paraMap = new HashMap<>();
for(SearchConfigEnum config : SearchConfigEnum.values()){
String searchvalue = req.getParameter(config.getId());
if(StringUtils.isNotBlank(searchvalue)){
if(!StringUtils.isEmpty(searchvalue)){
paraMap.put(config.getMeaning(),searchvalue);
}
}

@ -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,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;
}

@ -35,286 +35,286 @@ import java.util.stream.Collectors;
@ApiModel(value="图片信息表", description="图片信息表")
@TableName(value = "ocr_picture")
public class OcrPicture implements BaseDto,java.io.Serializable {
private static final long serialVersionUID = -10378331243377607L;
@ApiModelProperty(value ="主键")
@TableId(value = "id",type = IdType.ASSIGN_ID)
@JsonSerialize(using = ToStringSerializer.class)
@TableField(value="ID")
private Long id;
@ApiModelProperty(value ="创建人")
@TableField(value="create_by")
private String createBy;
@ApiModelProperty(value ="创建时间")
@TableField(value="create_time")
@JsonSerialize(using = DateSerializer.class)
private Long createTime;
@ApiModelProperty(value ="修改人")
@TableField(value="update_by")
private String updateBy;
@ApiModelProperty(value ="修改时间")
@TableField(value="update_time")
@JsonSerialize(using = DateSerializer.class)
private Long updateTime;
@ApiModelProperty(value ="分类表主键--通过“图片分类”字段做匹配,如果没有自动添加")
@TableField(value="classificationid")
private String classificationid;
@ApiModelProperty(value ="图片类型--通过“AI图片分类接口获得”")
@TableField(value="pictureclassid")
private String pictureclassid;
@Schema(description = "图片类型相似度,图片类型--通过“AI图片分类接口获得”")
@TableField(value="pictureclassscores")
private String pictureclassscores;
@ApiModelProperty(value ="图片真假0:假1真")
@TableField(value="iztrueorfalse",updateStrategy = FieldStrategy.IGNORED)
private Integer iztrueorfalse;
@ApiModelProperty(value ="选判真假原因id,从字典表中获得,其他时,当前字段为零")
@TableField(value="judgeid",updateStrategy = FieldStrategy.IGNORED)
@JsonSerialize(using = ToStringSerializer.class)
private Long judgeid;
@ApiModelProperty(value ="图片为假的其他原因长度不超过50个汉字")
@TableField(value="judgedesc",updateStrategy = FieldStrategy.IGNORED)
private String judgedesc;
@ApiModelProperty(value ="公司ID")
@JsonSerialize(using = ToStringSerializer.class)
@TableField(value="tenant_id")
private Long tenantId;
@ApiModelProperty(value ="公司状态")
@TableField(value="tenantstatus")
private String tenantstatus;
@ApiModelProperty(value ="公司代码,第三方系统")
@TableField(value="plantCode")
private String plantcode;
@ApiModelProperty(value ="公司名称")
@TableField(value="tenantname")
private String tenantname;
@ApiModelProperty(value ="业务主体ID--图片主键")
@TableField(value="pictureid")
private String pictureid;
@ApiModelProperty(value ="业务主体名称--图片成名")
@TableField(value="picturename")
private String picturename;
@ApiModelProperty(value ="图片名称")
@TableField(value="imgName")
private String imgname;
@ApiModelProperty(value ="图片地址")
@TableField(value="imgUrl")
private String imgurl;
@ApiModelProperty(value ="业务主体状态")
@TableField(value="picturestatus")
private String picturestatus;
@ApiModelProperty(value ="源项目id")
@TableField(value="projectId")
private String projectid;
@ApiModelProperty(value ="项目名称")
@TableField(value="projectIdName")
private String projectidname;
@ApiModelProperty(value ="项目状态")
@TableField(value="projectstatus")
private String projectstatus;
@ApiModelProperty(value ="源计划id")
@TableField(value="planId")
private String planid;
@ApiModelProperty(value ="计划名称")
@TableField(value="planName")
private String planname;
@ApiModelProperty(value ="计划状态")
@TableField(value="planstatus")
private String planstatus;
@ApiModelProperty(value ="所属子计划ID")
@TableField(value="planchildid")
private String planchildid;
@ApiModelProperty(value ="所属子计划名称")
@TableField(value="planchildname")
private String planchildname;
@ApiModelProperty(value ="所属子计划状态")
@TableField(value="planchildstatus")
private String planchildstatus;
@ApiModelProperty(value ="上传时间")
@JsonSerialize(using = DateNotimeSerializer.class)
@TableField(value="upTime")
private Long uptime;
@ApiModelProperty(value ="生成时间")
@JsonSerialize(using = DateNotimeSerializer.class)
@TableField(value="genTime")
private Long gentime;
@ApiModelProperty(value ="色彩空间")
@TableField(value="space")
private String space;
@ApiModelProperty(value ="来源")
@TableField(value="source")
private String source;
@ApiModelProperty(value ="上报者头像--接口传送")
@TableField(value="upHead")
private String uphead;
@ApiModelProperty(value ="上报人主键")
@TableField(value="upuserid")
private String upuserid;
@ApiModelProperty(value ="上报者名称--接口传送")
@TableField(value="upName")
private String upname;
@ApiModelProperty(value ="发布地区,拜访城市,城市名称,例如:北京市、天津市、石家庄市")
@TableField(value="releaseArea")
private String releasearea;
@ApiModelProperty(value ="拜访省份")
@TableField(value="releaseProvince")
private String releaseprovince;
@ApiModelProperty(value ="任务id")
@TableField(value="remark")
private String remark;
@ApiModelProperty(value ="任务名称,源系统")
@TableField(value="taskName")
private String taskname;
@ApiModelProperty(value ="是否已经生成任务,01是")
@TableField(value="taskstatus")
private String taskstatus;
@ApiModelProperty(value ="是否已经审批0未生成1审批中2已审批")
@TableField(value="work_status")
private String workStatus;
@ApiModelProperty(value ="现项目ID")
@TableField(value="categoryid")
private Long categoryid;
@ApiModelProperty(value ="任务-工单主键")
@TableField(value="taskchildpictureid")
private String taskchildpictureid;
@ApiModelProperty(value ="提报人")
@TableField(value="field1")
private String field1;
@ApiModelProperty(value ="拜访客户类型")
@TableField(value="field2")
private String field2;
@ApiModelProperty(value ="拜访客户名称,终端名称,例如中日友好医院")
@TableField(value="field3")
private String field3;
@ApiModelProperty(value ="任务来源")
@TableField(value="field4")
private String field4;
@ApiModelProperty(value ="厂商")
@TableField(value="field5")
private String field5;
@ApiModelProperty(value ="拜访客户级别")
@TableField(value="field6")
private String field6;
@ApiModelProperty(value ="科室名称")
@TableField(value="field7")
private String field7;
@ApiModelProperty(value ="拜访小结")
@TableField(value="field8")
private String field8;
@ApiModelProperty(value ="产品名称")
@TableField(value="field9")
private String field9;
@ApiModelProperty(value ="地区定位信息例如北京市朝阳区文苑路10号")
@TableField(value="field10")
private String field10;
@ApiModelProperty(value ="拜访日期")
@TableField(value="field11")
private Long field11;
private String field11;
@ApiModelProperty(value ="定位距离")
@TableField(value="field12")
private String field12;
@ApiModelProperty(value ="病历号")
@TableField(value="field13")
private String field13;
@ApiModelProperty(value ="是否重复")
@TableField(value="field14")
private String field14;
@ApiModelProperty(value ="任务类型")
@TableField(value="field15")
private String field15;
@ApiModelProperty(value ="任务状态")
@TableField(value="field16")
private String field16;
@Schema(description = "拜访项目类别")
@TableField(value="field17")
private String field17;
@Schema(description = "备用字段")
@TableField(value="field18")
private String field18;
@ApiModelProperty(value = "图片查重的比对图片集合")
@TableField(exist = false)
private List<OcrPicture> listCom;
@ApiModelProperty(value = "非历史图片主键集合")
@TableField(exist = false)
private List<String> picturecompareList;
@ApiModelProperty(value = "图片对应的工单对象")
@TableField(exist = false)
private OcrTaskchildPicture ocrTaskchildPicture;
@ApiModelProperty(value = "当前图片与参考图比对结果")
//当前图片与参考图比对结果
@TableField(exist = false)
private String result;
//图片分类
@TableField(exist = false)
private OcrPictureclass ocrPictureclass;
//保存当前登录用户的数据权限范围的搜索条件
@TableField(exist = false)
@JsonIgnore

@ -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);
}

@ -88,4 +88,10 @@ public interface OcrPictureService extends BaseService<OcrPicture> {
*/
IPage<OcrPicture> queryPageByUserSearchId(Integer pageNo, Integer pageSize, String userSearchId);
/**
*
* @param ocrPictureList
* @return
*/
int savePictures(List<OcrPicture> ocrPictureList);
}

@ -10,7 +10,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
*
*/
public interface OcrUpuserService extends BaseService<OcrUpuser> {
/**
*
*
@ -18,4 +18,6 @@ public interface OcrUpuserService extends BaseService<OcrUpuser> {
* @return List<OcrPictureclass>
*/
List<OcrUpuser> queryListNoPage(QueryWrapper<OcrUpuser> queryWrapper);
Long selectByUpNameCount(String upname,Long tenantId);
}

@ -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;
}
}

@ -14,6 +14,7 @@ import cn.jyjz.xiaoyao.oa.from.service.CategoryService;
import cn.jyjz.xiaoyao.ocr.dataDao.OcrPictureMybatisDao;
import cn.jyjz.xiaoyao.ocr.dataobject.*;
import cn.jyjz.xiaoyao.ocr.service.*;
import cn.jyjz.xiaoyao.ocr.util.DataDictionaryUtil;
import cn.jyjz.xiaoyao.ocr.util.ImageClassUtil;
import cn.jyjz.xiaoyao.ocr.util.SearchEnum;
import cn.jyjz.xiaoyao.ocr.util.SearchParaFormatting;
@ -31,6 +32,8 @@ import org.apache.commons.lang.time.DateFormatUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.poi.hpsf.Decimal;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.parameters.P;
import org.springframework.stereotype.Service;
import cn.jyjz.xiaoyao.common.mybatisplus.base.BaseServiceImpl;
import lombok.extern.slf4j.Slf4j;
@ -48,7 +51,7 @@ import java.util.List;
/**
*
*/
@Service
@Service("ocrPictureService")
@Slf4j
public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao, OcrPicture> implements OcrPictureService {
@Resource
@ -77,6 +80,20 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
private OcrPictureclassService ocrPictureclassService;
@Resource
private CategoryService categoryService;
private Object lock = new Object();
/**
*
*/
@Value("${ocr.api.wly.interface-domain}")
private String interfaceDomain;
/**
*
*/
@Autowired
DataDictionaryUtil dataDictionaryUtil;
public ResultVo createTaskChild(List<OcrPicture> ocrPictureList, String tenantId , UserToken sysUser, String search_month, HttpServletRequest request, String buessinessno){
//图片错误信息
@ -503,6 +520,28 @@ public class OcrPictureServiceImpl extends BaseServiceImpl<OcrPictureMybatisDao,
return pageList;
}
@Override
@Transactional(rollbackFor = Exception.class)
public int savePictures(List<OcrPicture> ocrPictureList) {
//1.字典数据 解析入库
boolean b = dataDictionaryUtil.pictureDataDictionarySaveArray(ocrPictureList);
//2.调整图片地址,补齐域名
for (OcrPicture picture : ocrPictureList) {
picture.setCreateTime(System.currentTimeMillis()); //获取创建时间戳
picture.setImgurl(interfaceDomain+picture.getImgurl());
}
//3.添加图片信息
if(this.saveBatch(ocrPictureList)){
return ocrPictureList.size();
}
return 0;
}
/**
*
* @param queryWrapper

@ -27,13 +27,21 @@ public class OcrUpuserServiceImpl extends BaseServiceImpl<OcrUpuserMybatisDao, O
* @return List<OcrPictureclass>
*/
public List<OcrUpuser> queryListNoPage(QueryWrapper<OcrUpuser> queryWrapper){
Long count = ocrupusermybatisdao.selectCount(queryWrapper);
Page<OcrUpuser> page = new Page(1,count);
page.setMaxLimit(count);
IPage<OcrUpuser> iPage = this.page(page,queryWrapper);
return iPage.getRecords();
}
@Override
public Long selectByUpNameCount(String upname,Long tenantId) {
QueryWrapper queryWrapper = new QueryWrapper();
queryWrapper.eq("tenant_id",tenantId);
queryWrapper.eq("upname",upname);
return baseMapper.selectCount(queryWrapper);
}
}

@ -0,0 +1,48 @@
package cn.jyjz.xiaoyao.ocr.thread;
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.concurrent.LinkedBlockingQueue;
/**
*
*
* @author hugh(shuli.yao) 1397940314@qq.com
* @version 1.0
* @date 2024/03/14 3:08
*/
public class TaskQueue {
private static Logger logger = LoggerFactory.getLogger(TaskQueue.class);
/**
*
*/
public static LinkedBlockingQueue pictureDownloadQueue = new LinkedBlockingQueue();
/**
* push
* @return
* @param pictureSourceResult //三方拉取 获取到的图片对象
*/
public static boolean pictureDownloadPushData(PictureSourceResult pictureSourceResult){
try {
pictureDownloadQueue.put(pictureSourceResult);
} catch (InterruptedException e) {
logger.error("任务队列添加异常:{}",e.getMessage());
return false;
}
return true;
}
/**
*
* @return
*/
public static PictureSourceResult pictureDownloadPullData(){
return (PictureSourceResult) pictureDownloadQueue.poll();
}
}

@ -0,0 +1,20 @@
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.startControllerPull();
}
}

@ -0,0 +1,60 @@
package cn.jyjz.xiaoyao.ocr.thread;
import cn.jyjz.xiaoyao.ocr.api.entity.PictureSourceResult;
import cn.jyjz.xiaoyao.ocr.thread.tasks.PictureDownloadTask;
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,
20,
3,
TimeUnit.SECONDS,
new LinkedBlockingDeque<>(),
Executors.defaultThreadFactory(),
new ThreadPoolExecutor.DiscardOldestPolicy());
}
}
/**
*
* @return
*/
public boolean startControllerPull(){
Runnable runnable = new Runnable() {
@SneakyThrows
@Override
public void run() {
logger.info("图片下载任务线程检查中...");
while (true){
PictureSourceResult pictureSourceResult = TaskQueue.pictureDownloadPullData();
if(pictureSourceResult!=null){
threadPool.execute(new PictureDownloadTask(pictureSourceResult));
}else{
Thread.sleep(5000);
}
}
}
};
Thread thread=new Thread(runnable);
thread.start();
return true;
}
}

@ -0,0 +1,191 @@
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 PictureDownloadTask implements Runnable{
protected Logger logger = LoggerFactory.getLogger(getClass());
private PictureSourceResult pictureSourceResult;
public PictureDownloadTask(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());
}
//项目名称
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,47 @@
package cn.jyjz.xiaoyao.ocr.timerJob;
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 org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
/**
*
*
* @author hugh(shuli.yao) 1397940314@qq.com
* @version 1.0
* @date 2024/3/14 9:49
*/
@Component
public class PictureSourceTimerJob {
private static Logger logger = LoggerFactory.getLogger(PictureSourceTimerJob.class);
@Autowired
PrevailCloudApi prevailCloudApi;
/**
* job
* @return
*/
private String pictureSourceRequestJob(){
//组装拉取参数
PictureSourceParameter pictureSourceParameter = new PictureSourceParameter();
// pictureSourceParameter.setStartTime();
// pictureSourceParameter.setEndTime();
pictureSourceParameter.setPageNo(1);
pictureSourceParameter.setPageSize(200);
// pictureSourceParameter.setAccountNo();
//1.拉取数据
// ApiPage<PictureSourceResult> pictureSourceResultApiPage = prevailCloudApi.pullPictureSource(pictureSourceParameter);
return "";
}
}

@ -0,0 +1,272 @@
package cn.jyjz.xiaoyao.ocr.util;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionary;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrDictionaryGroup;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrPicture;
import cn.jyjz.xiaoyao.ocr.dataobject.OcrUpuser;
import cn.jyjz.xiaoyao.ocr.service.OcrDictionaryService;
import cn.jyjz.xiaoyao.ocr.service.OcrPlanService;
import cn.jyjz.xiaoyao.ocr.service.OcrUpuserService;
import liquibase.pro.packaged.E;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.List;
/**
*
*
* @author hugh(shuli.yao) 1397940314@qq.com
* @version 1.0
* @date 2024/3/16 11:18
*/
@Component
public class DataDictionaryUtil {
/**
*
*/
@Autowired
private OcrDictionaryService ocrDictionaryService;
/**
*
* @return
*/
public boolean pictureDataDictionarySave(){
return true;
}
/**
*
* @param ocrPictureList
* @return
*/
public boolean pictureDataDictionarySaveArray(List<OcrPicture> ocrPictureList) {
for (OcrPicture picture : ocrPictureList) {
//1.检查提报人字典是否包含数据
if(picture.getUpname()!=null && picture.getUpuserid()!=null){
OcrDictionaryGroup upNameDG = ocrDictionaryService.queryGroupByField("upName");
if(upNameDG!=null && ocrDictionaryService.isValueExists(upNameDG.getId(),picture.getUpname(),picture.getTenantId())){
OcrDictionary dictionary= new OcrDictionary();
dictionary.setLable(picture.getUpname());
dictionary.setValue(picture.getUpuserid());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(upNameDG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//2.任务计划
if(picture.getPlanname()!=null && picture.getPlanid()!=null) {
OcrDictionaryGroup planNameDG = ocrDictionaryService.queryGroupByField("planName");
if (planNameDG!=null && ocrDictionaryService.isValueExists(planNameDG.getId(), picture.getPlanname(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getPlanname());
dictionary.setValue(picture.getPlanid());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(planNameDG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//3.拜访客户类型
if(picture.getField2()!=null) {
OcrDictionaryGroup field2DG = ocrDictionaryService.queryGroupByField("field2");
if (field2DG!=null && ocrDictionaryService.isValueExists(field2DG.getId(), picture.getField2(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getField2());
dictionary.setValue(picture.getField2());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(field2DG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//4.拜访客户名称
if(picture.getField3()!=null) {
OcrDictionaryGroup field3DG = ocrDictionaryService.queryGroupByField("field3");
if (field3DG!=null && ocrDictionaryService.isValueExists(field3DG.getId(), picture.getField3(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getField3());
dictionary.setValue(picture.getField3());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(field3DG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//5.任务来源
if(picture.getField4()!=null) {
OcrDictionaryGroup field4DG = ocrDictionaryService.queryGroupByField("field4");
if (field4DG!=null && ocrDictionaryService.isValueExists(field4DG.getId(), picture.getField4(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getField4());
dictionary.setValue(picture.getField4());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(field4DG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//6.厂商
if(picture.getField5()!=null) {
OcrDictionaryGroup field5DG = ocrDictionaryService.queryGroupByField("field5");
if (field5DG!=null && ocrDictionaryService.isValueExists(field5DG.getId(), picture.getField5(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getField5());
dictionary.setValue(picture.getField5());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(field5DG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//7.拜访客户级别
if(picture.getField6()!=null) {
OcrDictionaryGroup field6DG = ocrDictionaryService.queryGroupByField("field6");
if (field6DG!=null && ocrDictionaryService.isValueExists(field6DG.getId(), picture.getField6(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getField6());
dictionary.setValue(picture.getField6());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(field6DG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//8.拜访项目类别
if(picture.getField17()!=null) {
OcrDictionaryGroup field17DG = ocrDictionaryService.queryGroupByField("field17");
if (field17DG!=null && ocrDictionaryService.isValueExists(field17DG.getId(), picture.getField17(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getField17());
dictionary.setValue(picture.getField17());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(field17DG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//9.任务状态
if(picture.getTaskstatus()!=null) {
OcrDictionaryGroup taskStatusDG = ocrDictionaryService.queryGroupByField("taskStatus");
if (taskStatusDG!=null && ocrDictionaryService.isValueExists(taskStatusDG.getId(), picture.getTaskstatus(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getTaskstatus());
dictionary.setValue(picture.getTaskstatus());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(taskStatusDG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//10.产品名称
if(picture.getField9()!=null) {
OcrDictionaryGroup field9DG = ocrDictionaryService.queryGroupByField("field9");
if (field9DG!=null && ocrDictionaryService.isValueExists(field9DG.getId(), picture.getField9(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getField9());
dictionary.setValue(picture.getField9());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(field9DG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//11.地区(城市信息)
if(picture.getReleasearea()!=null) {
OcrDictionaryGroup releaseAreaDG = ocrDictionaryService.queryGroupByField("releaseArea");
if (releaseAreaDG!=null && ocrDictionaryService.isValueExists(releaseAreaDG.getId(), picture.getReleasearea(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getReleasearea());
dictionary.setValue(picture.getReleasearea());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(releaseAreaDG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//12.地区(省信息)
if(picture.getReleaseprovince()!=null) {
OcrDictionaryGroup releaseProvinceDG = ocrDictionaryService.queryGroupByField("releaseProvince");
if (releaseProvinceDG!=null && ocrDictionaryService.isValueExists(releaseProvinceDG.getId(), picture.getReleaseprovince(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getReleaseprovince());
dictionary.setValue(picture.getReleaseprovince());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(releaseProvinceDG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
//13.项目信息
if(picture.getProjectidname()!=null) {
OcrDictionaryGroup projectNameDG = ocrDictionaryService.queryGroupByField("projectName");
if (projectNameDG!=null && ocrDictionaryService.isValueExists(projectNameDG.getId(), picture.getProjectidname(), picture.getTenantId())) {
OcrDictionary dictionary = new OcrDictionary();
dictionary.setLable(picture.getProjectidname());
dictionary.setValue(picture.getProjectidname());
dictionary.setTenantId(picture.getTenantId());
dictionary.setGroupId(projectNameDG.getId());
try {
ocrDictionaryService.save(dictionary);
}catch (Exception e){
}
}
}
}
return true;
}
}

@ -1,4 +1,3 @@
server:
compression:
enabled: true
@ -95,9 +94,38 @@ spring:
session:
store-type: none
cache:
type: ehcache
ehcache:
config: classpath:/myehcache.xml
# type: redis
# redis:
# #Redis服务器地址
# #host: 192.168.0.198
# host: 127.0.0.1
# # Redis服务器连接端口
# port: 6379
# # 链接超时时间 单位 ms毫秒
# timeout: 20000
# # cluster:
# # nodes:
# # 192.168.0.191:7001,
# # 192.168.0.192:7001,
# # 192.168.0.193:7001,
# # 192.168.0.201:7001,
# # 192.168.0.202:7001,
# # 192.168.0.203:7001
# # #跨集群执行命令时要遵循的最大重定向数量
# # max-redirects: 18
# #lettuce:
# jedis:
# pool:
# #连接池最大连接数(使用负值表示没有限制) 默认 8
# max-active: 20
# #连接池中的最大空闲连接 默认 8
# max-idle: 10
# #连接池中的最小空闲连接 默认 0
# min-idle: 10
# #连接池最大阻塞等待时间(使用负值表示没有限制) 默认 -1
# max-wait: 10000
flowable:
modeler:
app:
@ -105,7 +133,7 @@ flowable:
#关闭定时任务JOB
async-executor-activate: false
database-schema-update: false
#
# cache:
# type: redis
# redis:
@ -140,7 +168,7 @@ flowable:
mybatis:
mapper-locations:
- classpath*:mapper/**/*.xml
# - classpath*:/META-INF/modeler-mybatis-mappings/*.xml
# - classpath*:/META-INF/modeler-mybatis-mappings/*.xml
configuration:
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
configuration-properties:
@ -161,15 +189,15 @@ mybatis-plus:
xiaoyao:
web:
#上传文件路径
uploadPath: X:/project3/2024_ai_gd/ocr/htmlweb/upload
uploadPath: D:/ideaWork/jeecg/ocrproject/htmlweb/upload
#页面根路径
frontPath: X:/project3/2024_ai_gd/ocr/htmlweb
frontPath: D:/ideaWork/jeecg/ocrproject/htmlweb
#js、css、图片存放路径
staticPath: X:/project3/2024_ai_gd/ocr/htmlweb/static
staticPath: D:/ideaWork/jeecg/ocrproject/htmlweb/static
#页面模版路径
webPath: X:/project3/2024_ai_gd/ocr/htmlweb/web
webPath: D:/ideaWork/jeecg/ocrproject/htmlweb/web
#Lucene索引路径
lucenePath: X:/project3/2024_ai_gd/ocr/htmlweb/lucene/indexDir
lucenePath: D:/ideaWork/jeecg/ocrproject/htmlweb/lucene/indexDir
#是否开启flowable
haveFlowable: true
webconfig:
@ -262,7 +290,7 @@ xiaoyao:
#缓存默认名称
managerName: cacheMgrGps
#有效时长(秒)目前登录用户、session使用
tokenExpire: 18000
tokenExpire: 360000
#缓存名称分隔符
cacheNamePrix: "_"
#存放缓存刷新时间是,使用临时缓存名称前缀
@ -273,3 +301,13 @@ springfox:
enabled: true
# 是否启用swagger,postman调试
debugger_tools: true
#无量云api配置信息
ocr:
api:
wly:
interface-domain: https://b-dr.prevailcloud.com #接口域名
accessKey: 7390F0221A1A73D8E13F8C8BB96F33B0 #秘钥
accessCode: ED6F7B39768AF95E87AEA8ACCCC71A6F #秘钥编码
connectTimeout: 5000 #请求超时时间 毫秒
readTimeout: 60000 #接收超时时间 毫秒

@ -1,5 +1,7 @@
server:
tomcat:
connection-timeout: 3600ms #设置超时时间
compression:
enabled: true
min-response-size: 10KB
@ -104,7 +106,7 @@ flowable:
deployment-api-url: http://127.0.0.1:8311/jeecg-boot/flowable-task/app-api
#关闭定时任务JOB
async-executor-activate: false
database-schema-update: true
database-schema-update: false
#
# cache:
# type: redis
@ -262,7 +264,7 @@ xiaoyao:
#缓存默认名称
managerName: cacheMgrOcr
#有效时长(秒)目前登录用户、session使用
tokenExpire: 18000
tokenExpire: 360000
#缓存名称分隔符
cacheNamePrix: "_"
#存放缓存刷新时间是,使用临时缓存名称前缀
@ -272,4 +274,16 @@ springfox:
swagger-ui:
enabled: true
# 是否启用swagger,postman调试
debugger_tools: true
debugger_tools: true
#无量云api配置信息
ocr:
api:
wly:
interface-domain: https://b-dr.prevailcloud.com #接口域名
accessKey: 7390F0221A1A73D8E13F8C8BB96F33B0 #秘钥
accessCode: ED6F7B39768AF95E87AEA8ACCCC71A6F #秘钥编码
connectTimeout: 5000 #请求超时时间 毫秒
readTimeout: 60000 #接收超时时间 毫秒

@ -1,3 +1,3 @@
spring:
profiles:
active: dev
active: dev

Loading…
Cancel
Save