|
@@ -1,504 +1,533 @@
|
|
|
-package com.pavis.ai.app.fjsocrasy;
|
|
|
-
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.pavis.ai.app.fjsocrasy.common.config.constants.Constants;
|
|
|
-import com.pavis.ai.app.fjsocrasy.common.utils.DateUtils;
|
|
|
-import com.pavis.ai.app.fjsocrasy.common.utils.DiskUtils;
|
|
|
-import com.pavis.ai.app.fjsocrasy.common.utils.ocr.AipOcrUtils;
|
|
|
-import com.pavis.ai.app.fjsocrasy.form.Desk;
|
|
|
-import com.pavis.ai.app.fjsocrasy.form.eighteen.Eighteen;
|
|
|
-import com.pavis.ai.app.fjsocrasy.mapper.ContractEighteenMapper;
|
|
|
-import com.pavis.ai.app.fjsocrasy.mapper.ShuntMapper;
|
|
|
-import com.pavis.ai.app.fjsocrasy.mapper.UploadMapper;
|
|
|
-import com.pavis.ai.app.fjsocrasy.model.ContractEighteen;
|
|
|
-import com.pavis.ai.app.fjsocrasy.model.Shunt;
|
|
|
-import com.pavis.ai.app.fjsocrasy.model.Upload;
|
|
|
-import com.pavis.ai.app.fjsocrasy.service.BackService;
|
|
|
-import com.pavis.ai.app.fjsocrasy.service.OcrService;
|
|
|
-import com.pavis.ai.app.fjsocrasy.service.UploadService;
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.junit.Test;
|
|
|
-import org.junit.runner.RunWith;
|
|
|
-import org.springframework.beans.BeanUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.boot.test.context.SpringBootTest;
|
|
|
-import org.springframework.test.context.junit4.SpringRunner;
|
|
|
-import sun.misc.BASE64Decoder;
|
|
|
-import sun.misc.BASE64Encoder;
|
|
|
-
|
|
|
-import java.io.BufferedReader;
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.io.InputStreamReader;
|
|
|
-import java.security.MessageDigest;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
-import java.time.temporal.ChronoUnit;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.HashMap;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-@RunWith(SpringRunner.class)
|
|
|
-@SpringBootTest
|
|
|
-@Slf4j
|
|
|
-public class FjsOcrAsyApplicationTests {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private BackService backService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private UploadMapper uploadMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private OcrService ocrService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ContractEighteenMapper contractEighteenMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private UploadService uploadService;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- private ShuntMapper shuntMapper;
|
|
|
-
|
|
|
- int countFlag = 1;
|
|
|
- @Test
|
|
|
- public void testShuntType(){
|
|
|
- List<Integer> uploadLists = new ArrayList<>();
|
|
|
- uploadLists.add(1);uploadLists.add(2);uploadLists.add(3);
|
|
|
- uploadLists.add(4);uploadLists.add(5);uploadLists.add(6);
|
|
|
- uploadLists.add(7);uploadLists.add(12);uploadLists.add(13);
|
|
|
- uploadLists.add(14);
|
|
|
- for (Integer uploadList : uploadLists) {
|
|
|
- System.err.println("countFlag:" + countFlag);
|
|
|
- String type = "1";
|
|
|
- QueryWrapper<Shunt> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(Shunt::getType, uploadList);
|
|
|
- List<Shunt> shunts = shuntMapper.selectList(queryWrapper);
|
|
|
- System.out.println("此"+uploadList+"应该:");
|
|
|
- String shuntType = AipOcrUtils.checkLocalOrAli(shunts,countFlag);
|
|
|
- System.out.println("shuntType:"+shuntType);
|
|
|
- countFlag = countFlag + 1;
|
|
|
- int proportion = Integer.valueOf(shunts.get(0).getProportion());
|
|
|
- System.err.println("proportion:" + proportion);
|
|
|
- if(countFlag == proportion){
|
|
|
- countFlag = 0;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testFenliu(){
|
|
|
- String fileType = "1";
|
|
|
- List<String> lists = new ArrayList<>();
|
|
|
- for (int i = 0; i < 10; i++) {
|
|
|
- System.err.println("开始调用:"+i);
|
|
|
- int countFlag = Integer.valueOf(toSelShuntByType("-1").get(0).getRemarks());
|
|
|
- System.err.println("sql:" + countFlag);
|
|
|
- List<Shunt> shunts = toSelShuntByType(fileType);
|
|
|
- String shuntType = AipOcrUtils.checkLocalOrAli(shunts, countFlag);
|
|
|
-// log.info("shuntType调取结果为:{}", shuntType);
|
|
|
- System.err.println("shuntType调取结果为:{}" + shuntType);
|
|
|
- lists.add(shuntType);
|
|
|
- System.out.println("to ocr ..........");
|
|
|
- // todo 等于数据库存取的proportion如:100时,置为0;可从数据库获取,按照比例来。
|
|
|
- countFlag = countFlag + 1;
|
|
|
- int proportion = Integer.valueOf(shunts.get(0).getProportion());
|
|
|
- // 当countFlag == proportion时,将countFlag置为1;
|
|
|
- initShuntVal(countFlag,proportion,false);
|
|
|
- initShuntVal(countFlag,proportion,true);
|
|
|
- System.err.println("sql end:" + Integer.valueOf(toSelShuntByType("-1").get(0).getRemarks()));
|
|
|
- }
|
|
|
-
|
|
|
- System.err.println(JSON.toJSONString(lists));
|
|
|
- }
|
|
|
-
|
|
|
- public void initShuntVal(int countFlag, int proportion,Boolean isReset) {
|
|
|
- if (isReset == true){
|
|
|
-// if (countFlag == (proportion - 1)) {
|
|
|
- if (countFlag > proportion) {
|
|
|
- List<Shunt> tmpShunts = toSelShuntByType("-1");
|
|
|
- for (Shunt tmpShunt : tmpShunts) {
|
|
|
- tmpShunt.setRemarks("1");
|
|
|
- shuntMapper.updateById(tmpShunt);
|
|
|
- }
|
|
|
- }
|
|
|
- }else {
|
|
|
- List<Shunt> tmpShunts = toSelShuntByType("-1");
|
|
|
- for (Shunt tmpShunt : tmpShunts) {
|
|
|
- tmpShunt.setRemarks(String.valueOf(countFlag));
|
|
|
- shuntMapper.updateById(tmpShunt);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public List<Shunt> toSelShuntByType(String type) {
|
|
|
- QueryWrapper<Shunt> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(Shunt::getType, type);
|
|
|
- return shuntMapper.selectList(queryWrapper);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testPwd() throws Exception {
|
|
|
- String pwd = "B1nJH8SWMGimTLoI1rBKGA==";
|
|
|
- System.err.println(getEncryptPwds(pwd));
|
|
|
- }
|
|
|
- public static String getEncryptPwds(String str) throws Exception {
|
|
|
- MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
- BASE64Encoder encoder = new BASE64Encoder();
|
|
|
- String pwd = encoder.encode(md.digest(str.getBytes("utf-8")));
|
|
|
- return pwd;
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testBo(){
|
|
|
- String reqId = "BO20201120008801-01-2";
|
|
|
- String bo1 = StringUtils.substringBeforeLast(reqId,"-");
|
|
|
- // todo 201127
|
|
|
- String bo2 = StringUtils.substringBefore(reqId,"-");
|
|
|
- System.out.println(bo1);
|
|
|
- System.out.println(bo2);
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testDiskMq(){
|
|
|
- String rabbitmqHost = "192.168.0.100";
|
|
|
- String rabbitmqPort = "15672";
|
|
|
- String userName = "xxxx";
|
|
|
- String password = "password";
|
|
|
-
|
|
|
- String url = String.format("http://%s:%s/api/overview",rabbitmqHost,rabbitmqPort);
|
|
|
-
|
|
|
-
|
|
|
- BASE64Encoder base64Encoder = new BASE64Encoder();
|
|
|
- String base64Str = String.format("%s:%s",userName,password);
|
|
|
- String base64Val = base64Encoder.encode(base64Str.getBytes());
|
|
|
-
|
|
|
- Map<String,String> headerMap = new HashMap<>();
|
|
|
- String authHash = String.format("Basic %s",base64Val );
|
|
|
- headerMap.put("authorization",authHash);
|
|
|
-
|
|
|
- // System.err.println(JSON.toJSON(headerMap));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testDisk(){
|
|
|
- File diskPartition = new File("C:");
|
|
|
-
|
|
|
- long totalCapacity = diskPartition.getTotalSpace();
|
|
|
-
|
|
|
- long freePartitionSpace = diskPartition.getFreeSpace();
|
|
|
- long usablePatitionSpace = diskPartition.getUsableSpace();
|
|
|
-
|
|
|
- System.out.println("**** Sizes in Mega Bytes ****\n");
|
|
|
-
|
|
|
- System.out.println("Total C partition size : " + totalCapacity / (1024*1024) + " MB");
|
|
|
- System.out.println("Usable Space : " + usablePatitionSpace / (1024 *1024) + " MB");
|
|
|
- System.out.println("Free Space : " + freePartitionSpace / (1024 *1024) + " MB");
|
|
|
-
|
|
|
- System.out.println("\n**** Sizes in Giga Bytes ****\n");
|
|
|
-
|
|
|
- System.out.println("Total C partition size : " + totalCapacity / (1024*1024*1024) + " GB");
|
|
|
- System.out.println("Usable Space : " + usablePatitionSpace / (1024 *1024*1024) + " GB");
|
|
|
- System.out.println("Free Space : " + freePartitionSpace / (1024 *1024*1024) + " GB");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testLinux(){
|
|
|
- // Desk desk = getDeskUsage();
|
|
|
- // String os = System.getProperty("os.name");
|
|
|
- // System.err.println(os);
|
|
|
- // if(os.toLowerCase().startsWith("win")){
|
|
|
- // System.out.println(os + " can't gunzip");
|
|
|
- // }
|
|
|
- //
|
|
|
- // Properties prop = System.getProperties();
|
|
|
- //
|
|
|
- // os = prop.getProperty("os.name");
|
|
|
- // if (os != null && os.toLowerCase().indexOf("linux") > -1) {
|
|
|
- // System.err.println("true: "+os);
|
|
|
- // } else {
|
|
|
- // System.err.println("false: "+os);
|
|
|
- // }
|
|
|
- Map<String,String> map = DiskUtils.getHdInfo();
|
|
|
- // System.err.println(JSON.toJSON(map));
|
|
|
-
|
|
|
- File directory = new File(".");//设定为当前文件夹
|
|
|
- String canPath = "";
|
|
|
- String absPath = "";
|
|
|
- try{
|
|
|
- canPath = directory.getCanonicalPath();//获取标准的路径
|
|
|
- absPath = directory.getAbsolutePath();//获取绝对路径
|
|
|
- }catch(Exception e){
|
|
|
- e.getMessage();
|
|
|
- }
|
|
|
- // System.err.println(canPath);
|
|
|
- // System.err.println(absPath);
|
|
|
- // double canSpace = DiskUtils.getWinDiskStoresInfo(canPath);
|
|
|
- // System.err.println(canSpace);
|
|
|
-
|
|
|
- // double absSpace = DiskUtils.getWinDiskStoresInfo(absPath);
|
|
|
- // System.err.println(absSpace);
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- public static Desk getDeskUsage() {
|
|
|
- Desk desk = new Desk();
|
|
|
- try {
|
|
|
- Runtime rt = Runtime.getRuntime();
|
|
|
- Process p = rt.exec("df -hl");// df -hl 查看硬盘空间
|
|
|
- BufferedReader in = null;
|
|
|
- try {
|
|
|
- in = new BufferedReader(new InputStreamReader(
|
|
|
- p.getInputStream()));
|
|
|
- String str = null;
|
|
|
- String[] strArray = null;
|
|
|
- int line = 0;
|
|
|
- while ((str = in.readLine()) != null) {
|
|
|
- line++;
|
|
|
- if (line != 2) {
|
|
|
- continue;
|
|
|
- }
|
|
|
- int m = 0;
|
|
|
- strArray = str.split(" ");
|
|
|
- for (String para : strArray) {
|
|
|
- if (para.trim().length() == 0)
|
|
|
- continue;
|
|
|
- ++m;
|
|
|
- if (para.endsWith("G") || para.endsWith("Gi")) {
|
|
|
- // 目前的服务器
|
|
|
- if (m == 2) {
|
|
|
- desk.setTotal(para);
|
|
|
- }
|
|
|
- if (m == 3) {
|
|
|
- desk.setUsed(para);
|
|
|
- }
|
|
|
- }
|
|
|
- if (para.endsWith("%")) {
|
|
|
- if (m == 5) {
|
|
|
- desk.setUse_rate(para);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- } finally {
|
|
|
- in.close();
|
|
|
- }
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- return desk;
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void contextLoads() {
|
|
|
- String data = "{ \"lender\":\"王俞\", \"address\":\"上海市上海市管辖区浦东新区祝桥镇千汇路750弄60号401室\", \"mobile\":\"18501631918\", \"postCode\":\"200000\", \"idCode\":\"310225198803253034\", \"lower\":\"200000\", \"account\":\"王俞\", \"accountCode\":\"6217900800003831631\", \"deadline\":\"36\" , \"compareDate\":\"2020.04.15\" }";
|
|
|
-
|
|
|
- System.err.println(changeSourceDataBy18(data));
|
|
|
- // ResData resData = new ResData();
|
|
|
- // resData.setMidConfidence("2");
|
|
|
- // resData.setOverallConfidence("2");
|
|
|
- // backService.backToFjs(resData,"10",System.currentTimeMillis(),"1");
|
|
|
- }
|
|
|
-
|
|
|
- public String changeSourceDataBy18(String data){
|
|
|
- JSONObject js = JSON.parseObject(data);
|
|
|
- if (js.containsKey("postCode")){
|
|
|
- js.remove("postCode");
|
|
|
- }
|
|
|
- if (js.containsKey("deadline")){
|
|
|
- js.remove("deadline");
|
|
|
- }
|
|
|
- System.err.println(js.toJSONString());
|
|
|
- if (js.containsKey("address")){
|
|
|
- js.put("addressSign",js.get("address").toString());
|
|
|
- }
|
|
|
- return js.toJSONString();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testjs(){
|
|
|
- JSONObject ocr = null;
|
|
|
- System.err.println(JSON.toJSONString(ocr));
|
|
|
- org.json.JSONObject res = new org.json.JSONObject();
|
|
|
- try {
|
|
|
- String resStr = res.toString();
|
|
|
- ocr = JSON.parseObject(resStr);
|
|
|
-
|
|
|
- System.err.println("ocr 2:"+JSON.toJSONString(ocr));
|
|
|
- }catch (Exception e){
|
|
|
- e.getMessage();
|
|
|
- System.err.println(e.getMessage());
|
|
|
- }
|
|
|
- String resstr = res.toString();
|
|
|
- ocr = res.equals("noneex") ? ocr : JSON.parseObject(resstr);
|
|
|
- System.err.println("ocr 4:"+JSON.toJSONString(ocr));
|
|
|
-
|
|
|
-
|
|
|
- ocr = JSON.parseObject(resstr);
|
|
|
-
|
|
|
- System.err.println("ocr 3:"+JSON.toJSONString(ocr));
|
|
|
- if (null != ocr && ocr.containsKey("image_status") && ocr.get("image_status").toString().equals("normal")) {
|
|
|
- System.err.println("...");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testMD5() throws Exception {
|
|
|
- String str = base64Dcrypt("BPMFvLeFYr8zWKdkGIlhhg==");
|
|
|
- System.err.println(str.getBytes("utf-8"));
|
|
|
- System.out.println(new String(str.getBytes("utf-8")));
|
|
|
- System.err.println(JM(base64Dcrypt("BPMFvLeFYr8zWKdkGIlhhg==")));
|
|
|
- //(a)首先对md5(base64)进行base64解码
|
|
|
-
|
|
|
- //(b)对base64解码后的值通过二进制方式进行读取,其结果应该为32位字符串
|
|
|
-
|
|
|
- //(c)对获取的32位字符串进行md5解密。
|
|
|
- System.err.println(getEncryptPwd("097197"));
|
|
|
-
|
|
|
- // String mailPassword = "xivaxiva";
|
|
|
- // BASE64Encoder encoder = new BASE64Encoder();
|
|
|
- // String pass = encoder.encode(mailPassword.getBytes());
|
|
|
-
|
|
|
- String name = "BPMFvLeFYr8zWKdkGIlhhg==";
|
|
|
- BASE64Decoder decoder = new BASE64Decoder();
|
|
|
- byte[] decoderName = decoder.decodeBuffer(name);
|
|
|
-
|
|
|
- System.out.println(new String(decoderName).getBytes("utf-8"));
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * MD5加密字符串
|
|
|
- *
|
|
|
- * @param str 加密字符串
|
|
|
- * @return 加密后的字符串
|
|
|
- * @throws Exception 异常
|
|
|
- */
|
|
|
- public static String getEncryptPwd(String str) throws Exception {
|
|
|
- MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
- BASE64Encoder encoder = new BASE64Encoder();
|
|
|
- return encoder.encode(md.digest(str.getBytes("utf-8")));
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * base64解密
|
|
|
- */
|
|
|
- public static String base64Dcrypt(String str) {
|
|
|
- if (str == null) return null;
|
|
|
- String decoderStr = "";
|
|
|
-
|
|
|
- try {
|
|
|
- BASE64Decoder decoder = new BASE64Decoder();
|
|
|
- byte[] b = decoder.decodeBuffer(str);
|
|
|
- decoderStr = new String(b);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- return decoderStr;
|
|
|
- }
|
|
|
- // 加密后解密
|
|
|
- public static String JM(String inStr) {
|
|
|
- char[] a = inStr.toCharArray();
|
|
|
- for (int i = 0; i < a.length; i++) {
|
|
|
- a[i] = (char) (a[i] ^ 't');
|
|
|
- }
|
|
|
- String k = new String(a);
|
|
|
- return k;
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test() throws IOException {
|
|
|
- String data = "{ \"lender\":\"占小琴\", \"idCode\":\"420281198501257247\", \"mobile\":\"13872114908\", \"address\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\", \"lower\":\"150000\", \"postCode\":\"200000\", \"deadline\":\"36\", \"period\":\"36\", \"account\":\"占小琴\", \"accountCode\":\"6217907600006022664\", \"loanType\":\"装修\", \"sendAddress\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\" , \"compareDate\":\"2020.07.30\" }";
|
|
|
- String reqId = "BO202008210002";
|
|
|
- String fileType = "5";
|
|
|
- String url = "";
|
|
|
- String fileName = "";
|
|
|
- Long startTime = System.currentTimeMillis();
|
|
|
- // ocrService.toOcr(reqId, fileType, url, fileName, data, startTime);
|
|
|
- ocrService.toOcr(reqId, fileType, url, fileName, data, startTime);
|
|
|
- // ocrService.singleFileOcrSyn( reqId, fileType, FileDetails parsedFilePath, List<FileDetails> paths, sourceData, startTime);
|
|
|
-
|
|
|
- System.err.println(changeSourceDataBy18(data));
|
|
|
- // ResData resData = new ResData();
|
|
|
- // resData.setMidConfidence("2");
|
|
|
- // resData.setOverallConfidence("2");
|
|
|
- // backService.backToFjs(resData,"10",System.currentTimeMillis(),"1");
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void test18(){
|
|
|
- String data = "{\"account\":\"占小琴\",\"accountCode\":\"6217907600006022664\",\"address\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\",\"compareDate\":\"2020.07.30\",\"deadline\":\"\",\"idCode\":\"420281198501257247\",\"lender\":\"占小琴\",\"loanType\":\"装修\",\"lower\":\"150000\",\"mobile\":\"13872114908\",\"operateIp\":\"\",\"operateTime\":\"2020-08-21 15:37:16\",\"operator\":\"\",\"operatorId\":\"\",\"period\":\"36\",\"postCode\":\"\",\"remarks\":\"1301.0ms\",\"reqId\":\"BO202008210005\",\"sendAddress\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\"}\n";
|
|
|
- ContractEighteen contractEighteen;
|
|
|
- if (null != data) {
|
|
|
- Eighteen eighteen = JSONObject.parseObject(JSON.parseObject(data).toJSONString(), Eighteen.class);
|
|
|
- contractEighteen = new ContractEighteen();
|
|
|
- BeanUtils.copyProperties(eighteen, contractEighteen);
|
|
|
- contractEighteen.setReqId("1111111111111111111111");
|
|
|
- contractEighteen.setPostCode("");
|
|
|
- contractEighteen.setDeadline("");
|
|
|
- contractEighteen.setOperator("");
|
|
|
- contractEighteen.setOperatorId("");
|
|
|
- contractEighteen.setOperateIp("");
|
|
|
- contractEighteen.setOperateTime(DateUtils.now());
|
|
|
- contractEighteen.setRemarks(String.valueOf(System.currentTimeMillis()));
|
|
|
- } else {
|
|
|
- contractEighteen = new ContractEighteen();
|
|
|
- }
|
|
|
- System.err.println(contractEighteenMapper.insert(contractEighteen));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testDate(){
|
|
|
- LocalDate date = LocalDate.now();
|
|
|
- System.out.println("当前日期=" + date);
|
|
|
- System.err.println(DateUtils.createFilesByDate());
|
|
|
- System.out.println(DateUtils.now());
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testUnBack(){
|
|
|
- QueryWrapper<Upload> uploadQueryWrapper = new QueryWrapper<>();
|
|
|
- uploadQueryWrapper.lambda()
|
|
|
- .between(Upload::getOperateTime, DateUtils.startDate(), DateUtils.endDate());
|
|
|
- // List<Upload> uploads = uploadMapper.selectList();
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testOcrBack(){
|
|
|
- List list = uploadService.findByReqId("10","BO20200414000005-03");
|
|
|
- System.out.println(JSON.toJSONString(list));
|
|
|
- }
|
|
|
-
|
|
|
- @Test
|
|
|
- public void testDates(){
|
|
|
- String date = "2020-11-06 10:14:40";
|
|
|
- System.out.println(daysBetweenDates(date));
|
|
|
- }
|
|
|
-
|
|
|
- public static long daysBetweenDates(String date) {
|
|
|
- LocalDateTime localDate1 = LocalDateTime.parse(DateUtils.now(), DateTimeFormatter.ofPattern(Constants.DEFAULT_DATETIME_FORMAT));
|
|
|
- LocalDateTime localDate2 = LocalDateTime.parse(date, DateTimeFormatter.ofPattern(Constants.DEFAULT_DATETIME_FORMAT));
|
|
|
- System.out.println(localDate1);
|
|
|
- System.out.println(localDate2);
|
|
|
- return Math.abs(ChronoUnit.MINUTES.between(localDate1, localDate2));
|
|
|
- }
|
|
|
-
|
|
|
-}
|
|
|
+//package com.pavis.ai.app.fjsocrasy;
|
|
|
+//
|
|
|
+//import com.alibaba.fastjson.JSON;
|
|
|
+//import com.alibaba.fastjson.JSONObject;
|
|
|
+//import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.common.config.constants.Constants;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.common.utils.DateUtils;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.common.utils.DiskUtils;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.common.utils.ocr.AipOcrUtils;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.form.Desk;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.form.eighteen.Eighteen;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.mapper.ContractEighteenMapper;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.mapper.ShuntMapper;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.mapper.UploadMapper;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.model.ContractEighteen;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.model.Shunt;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.model.Upload;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.service.BackService;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.service.OcrService;
|
|
|
+//import com.pavis.ai.app.fjsocrasy.service.UploadService;
|
|
|
+//import lombok.extern.slf4j.Slf4j;
|
|
|
+//import org.apache.commons.lang3.StringUtils;
|
|
|
+//import org.junit.Test;
|
|
|
+//import org.junit.runner.RunWith;
|
|
|
+//import org.springframework.beans.BeanUtils;
|
|
|
+//import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+//import org.springframework.boot.test.context.SpringBootTest;
|
|
|
+//import org.springframework.test.context.junit4.SpringRunner;
|
|
|
+//import sun.misc.BASE64Decoder;
|
|
|
+//import sun.misc.BASE64Encoder;
|
|
|
+//
|
|
|
+//import java.io.BufferedReader;
|
|
|
+//import java.io.File;
|
|
|
+//import java.io.IOException;
|
|
|
+//import java.io.InputStreamReader;
|
|
|
+//import java.security.MessageDigest;
|
|
|
+//import java.time.LocalDate;
|
|
|
+//import java.time.LocalDateTime;
|
|
|
+//import java.time.format.DateTimeFormatter;
|
|
|
+//import java.time.temporal.ChronoUnit;
|
|
|
+//import java.util.ArrayList;
|
|
|
+//import java.util.HashMap;
|
|
|
+//import java.util.List;
|
|
|
+//import java.util.Map;
|
|
|
+//
|
|
|
+//@RunWith(SpringRunner.class)
|
|
|
+//@SpringBootTest
|
|
|
+//@Slf4j
|
|
|
+//public class FjsOcrAsyApplicationTests {
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private BackService backService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private UploadMapper uploadMapper;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private OcrService ocrService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private ContractEighteenMapper contractEighteenMapper;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private UploadService uploadService;
|
|
|
+//
|
|
|
+// @Autowired
|
|
|
+// private ShuntMapper shuntMapper;
|
|
|
+//
|
|
|
+// int countFlag = 1;
|
|
|
+// public static final String BASIC_TL_HEAD = "{0:\"企业名称\",1:\"法定代表人\",2:\"注册资本(万元)\",3:\"成立日期\",4:\"统一社会信用代码\",5:\"纳税人识别号\",6:\"组织机构代码\",7:\"企业类型\",8:\"所属行业\",9:\"曾用名\",10:\"官网\",11:\"所属乡镇\",12:\"企业地址\",13:\"资质1\",14:\"认定年限1\",15:\"资质2\",16:\"认定年限2\",17:\"资质3\",18:\"认定年限3\",19:\"是否规上\",20:\"老总姓名\",21:\"电话1\",22:\"研发总监姓名\",23:\"电话2\",24:\"科技联络人姓名\",25:\"电话3\",26:\"企业简介\",27:\"主导产品1\",28:\"主导产品2\",29:\"主导产品3\",30:\"发明专利\",31:\"实用新型\",32:\"外观设计\",33:\"软件著作权\",34:\"研究机构\",35:\"研究机构名称\"}";
|
|
|
+// // 企业税务数据信息模板表头
|
|
|
+// public static final String TAX_TL_HEAD = "{0:\"企业名称\",1:\"统一社会信用代码\",2:\"时间段1\",3:\"企业税收利润1\",4:\"企业税收收入1\",5:\"研发费加计扣除1\",6:\"留县税收1\",7:\"时间段2\",8:\"企业税收利润2\",9:\"企业税收收入2\",10:\"研发费加计扣除2\",11:\"留县税收2\",12:\"时间段3\",13:\"企业税收利润3\",14:\"企业税收收入3\",15:\"研发费加计扣除3\",16:\"留县税收3\",17:\"时间段4\",18:\"企业税收利润4\",19:\"企业税收收入4\",20:\"研发费加计扣除4\",21:\"留县税收4\"}";
|
|
|
+// // 企业专利信息模板表头
|
|
|
+// public static final String PATENT_TL_HEAD = "{0:\"企业名称\",1:\"统一社会信用代码\",2:\"专利名称\",3:\"申请号\",4:\"申请日\",5:\"专利类型\",6:\"专利权人\",7:\"授权号\"}";
|
|
|
+// // 高校成果信息模板表头
|
|
|
+// public static final String CU_TL_RESULTS = "{0:\"所属单位\",1:\"成果名称\",2:\"应用领域\",3:\"合作模式\",4:\"成熟度\",5:\"联系人\",6:\"联系方式\",7:\"联系邮箱\",8:\"研究人员\",9:\"成果描述\",10:\"知识产权授权号\"}";
|
|
|
+// // 金融库信息模板表头
|
|
|
+// public static final String FINANCIAL_TL_HEAD = "{0:\"单位\",1:\"联系人\",2:\"电话\",3:\"职务\",4:\"关键词\",5:\"特色贷产品名称1\",6:\"贷款利率1\",7:\"注1(日利率or月利率or年利率、是否浮动利率)\",8:\"产品简介1\",9:\"特色贷产品名称2\",10:\"贷款利率2\",11:\"注2\",12:\"产品简介2\",13:\"特色贷产品名称3\",14:\"贷款利率3\",15:\"注3\",16:\"产品简介3\",17:\"其他金融产品名称a\",18:\"简介a\",19:\"其他金融产品名称b\",20:\"简介b\",21:\"其他金融产品名称c\",22:\"简介c\",23:\"银行简介\"}";
|
|
|
+// // 人才库人才信息模板表头
|
|
|
+// public static final String PERSONNEL_TL_HEAD = "{0:\"企业名称\",1:\"社会统一信用代码\",2:\"姓名\",3:\"出生年月\",4:\"出生地\",5:\"政治面貌\",6:\"职务\",7:\"专业\",8:\"学历\",9:\"职称\",10:\"联系电话\",11:\"现从事技术领域(多)\",12:\"人才认定级别\",13:\"主要贡献\"}";
|
|
|
+// // 专家库专家信息模板表头
|
|
|
+// public static final String EXPERT_TL_HEAD = "{0:\"所属学校\",1:\"所属院校\",2:\"专家姓名\",3:\"研究领域\",4:\"学位\",5:\"职称\",6:\"联系方式\",7:\"邮箱\",8:\"简介≤200字\",9:\"关键词(输入多个标签时以“,”隔开\"}"; // 政策库政策信息模板表头
|
|
|
+// // 政策库政策信息模板表头
|
|
|
+// public static final String POLICY_TL_HEAD = "{0:\"关键词\",1:\"政策名称\",2:\"政策编号\",3:\"政策内容\"}";
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testExcelModel(){
|
|
|
+// JSONObject js = JSON.parseObject(BASIC_TL_HEAD);
|
|
|
+// js.replace("0","name");
|
|
|
+// System.err.println(js.toJSONString());
|
|
|
+// String str = BASIC_TL_HEAD;
|
|
|
+// str = str.replace("0","\"name\"");
|
|
|
+// str = str.replace("1","\"legalRepresentative\"");
|
|
|
+//
|
|
|
+//// StringUtils.replace()
|
|
|
+// System.err.println(str);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testShuntType(){
|
|
|
+// List<Integer> uploadLists = new ArrayList<>();
|
|
|
+// uploadLists.add(1);uploadLists.add(2);uploadLists.add(3);
|
|
|
+// uploadLists.add(4);uploadLists.add(5);uploadLists.add(6);
|
|
|
+// uploadLists.add(7);uploadLists.add(12);uploadLists.add(13);
|
|
|
+// uploadLists.add(14);
|
|
|
+// for (Integer uploadList : uploadLists) {
|
|
|
+// System.err.println("countFlag:" + countFlag);
|
|
|
+// String type = "1";
|
|
|
+// QueryWrapper<Shunt> queryWrapper = new QueryWrapper<>();
|
|
|
+// queryWrapper.lambda()
|
|
|
+// .eq(Shunt::getType, uploadList);
|
|
|
+// List<Shunt> shunts = shuntMapper.selectList(queryWrapper);
|
|
|
+// System.out.println("此"+uploadList+"应该:");
|
|
|
+// String shuntType = AipOcrUtils.checkLocalOrAli(shunts,countFlag);
|
|
|
+// System.out.println("shuntType:"+shuntType);
|
|
|
+// countFlag = countFlag + 1;
|
|
|
+// int proportion = Integer.valueOf(shunts.get(0).getProportion());
|
|
|
+// System.err.println("proportion:" + proportion);
|
|
|
+// if(countFlag == proportion){
|
|
|
+// countFlag = 0;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testFenliu(){
|
|
|
+// String fileType = "1";
|
|
|
+// List<String> lists = new ArrayList<>();
|
|
|
+// for (int i = 0; i < 10; i++) {
|
|
|
+// System.err.println("开始调用:"+i);
|
|
|
+// int countFlag = Integer.valueOf(toSelShuntByType("-1").get(0).getRemarks());
|
|
|
+// System.err.println("sql:" + countFlag);
|
|
|
+// List<Shunt> shunts = toSelShuntByType(fileType);
|
|
|
+// String shuntType = AipOcrUtils.checkLocalOrAli(shunts, countFlag);
|
|
|
+//// log.info("shuntType调取结果为:{}", shuntType);
|
|
|
+// System.err.println("shuntType调取结果为:{}" + shuntType);
|
|
|
+// lists.add(shuntType);
|
|
|
+// System.out.println("to ocr ..........");
|
|
|
+// // todo 等于数据库存取的proportion如:100时,置为0;可从数据库获取,按照比例来。
|
|
|
+// countFlag = countFlag + 1;
|
|
|
+// int proportion = Integer.valueOf(shunts.get(0).getProportion());
|
|
|
+// // 当countFlag == proportion时,将countFlag置为1;
|
|
|
+// initShuntVal(countFlag,proportion,false);
|
|
|
+// initShuntVal(countFlag,proportion,true);
|
|
|
+// System.err.println("sql end:" + Integer.valueOf(toSelShuntByType("-1").get(0).getRemarks()));
|
|
|
+// }
|
|
|
+//
|
|
|
+// System.err.println(JSON.toJSONString(lists));
|
|
|
+// }
|
|
|
+//
|
|
|
+// public void initShuntVal(int countFlag, int proportion,Boolean isReset) {
|
|
|
+// if (isReset == true){
|
|
|
+//// if (countFlag == (proportion - 1)) {
|
|
|
+// if (countFlag > proportion) {
|
|
|
+// List<Shunt> tmpShunts = toSelShuntByType("-1");
|
|
|
+// for (Shunt tmpShunt : tmpShunts) {
|
|
|
+// tmpShunt.setRemarks("1");
|
|
|
+// shuntMapper.updateById(tmpShunt);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }else {
|
|
|
+// List<Shunt> tmpShunts = toSelShuntByType("-1");
|
|
|
+// for (Shunt tmpShunt : tmpShunts) {
|
|
|
+// tmpShunt.setRemarks(String.valueOf(countFlag));
|
|
|
+// shuntMapper.updateById(tmpShunt);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// public List<Shunt> toSelShuntByType(String type) {
|
|
|
+// QueryWrapper<Shunt> queryWrapper = new QueryWrapper<>();
|
|
|
+// queryWrapper.lambda()
|
|
|
+// .eq(Shunt::getType, type);
|
|
|
+// return shuntMapper.selectList(queryWrapper);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testPwd() throws Exception {
|
|
|
+// String pwd = "B1nJH8SWMGimTLoI1rBKGA==";
|
|
|
+// System.err.println(getEncryptPwds(pwd));
|
|
|
+// }
|
|
|
+// public static String getEncryptPwds(String str) throws Exception {
|
|
|
+// MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
+// BASE64Encoder encoder = new BASE64Encoder();
|
|
|
+// String pwd = encoder.encode(md.digest(str.getBytes("utf-8")));
|
|
|
+// return pwd;
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testBo(){
|
|
|
+// String reqId = "BO20201120008801-01-2";
|
|
|
+// String bo1 = StringUtils.substringBeforeLast(reqId,"-");
|
|
|
+// // todo 201127
|
|
|
+// String bo2 = StringUtils.substringBefore(reqId,"-");
|
|
|
+// System.out.println(bo1);
|
|
|
+// System.out.println(bo2);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testDiskMq(){
|
|
|
+// String rabbitmqHost = "192.168.0.100";
|
|
|
+// String rabbitmqPort = "15672";
|
|
|
+// String userName = "xxxx";
|
|
|
+// String password = "password";
|
|
|
+//
|
|
|
+// String url = String.format("http://%s:%s/api/overview",rabbitmqHost,rabbitmqPort);
|
|
|
+//
|
|
|
+//
|
|
|
+// BASE64Encoder base64Encoder = new BASE64Encoder();
|
|
|
+// String base64Str = String.format("%s:%s",userName,password);
|
|
|
+// String base64Val = base64Encoder.encode(base64Str.getBytes());
|
|
|
+//
|
|
|
+// Map<String,String> headerMap = new HashMap<>();
|
|
|
+// String authHash = String.format("Basic %s",base64Val );
|
|
|
+// headerMap.put("authorization",authHash);
|
|
|
+//
|
|
|
+// // System.err.println(JSON.toJSON(headerMap));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testDisk(){
|
|
|
+// File diskPartition = new File("C:");
|
|
|
+//
|
|
|
+// long totalCapacity = diskPartition.getTotalSpace();
|
|
|
+//
|
|
|
+// long freePartitionSpace = diskPartition.getFreeSpace();
|
|
|
+// long usablePatitionSpace = diskPartition.getUsableSpace();
|
|
|
+//
|
|
|
+// System.out.println("**** Sizes in Mega Bytes ****\n");
|
|
|
+//
|
|
|
+// System.out.println("Total C partition size : " + totalCapacity / (1024*1024) + " MB");
|
|
|
+// System.out.println("Usable Space : " + usablePatitionSpace / (1024 *1024) + " MB");
|
|
|
+// System.out.println("Free Space : " + freePartitionSpace / (1024 *1024) + " MB");
|
|
|
+//
|
|
|
+// System.out.println("\n**** Sizes in Giga Bytes ****\n");
|
|
|
+//
|
|
|
+// System.out.println("Total C partition size : " + totalCapacity / (1024*1024*1024) + " GB");
|
|
|
+// System.out.println("Usable Space : " + usablePatitionSpace / (1024 *1024*1024) + " GB");
|
|
|
+// System.out.println("Free Space : " + freePartitionSpace / (1024 *1024*1024) + " GB");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testLinux(){
|
|
|
+// // Desk desk = getDeskUsage();
|
|
|
+// // String os = System.getProperty("os.name");
|
|
|
+// // System.err.println(os);
|
|
|
+// // if(os.toLowerCase().startsWith("win")){
|
|
|
+// // System.out.println(os + " can't gunzip");
|
|
|
+// // }
|
|
|
+// //
|
|
|
+// // Properties prop = System.getProperties();
|
|
|
+// //
|
|
|
+// // os = prop.getProperty("os.name");
|
|
|
+// // if (os != null && os.toLowerCase().indexOf("linux") > -1) {
|
|
|
+// // System.err.println("true: "+os);
|
|
|
+// // } else {
|
|
|
+// // System.err.println("false: "+os);
|
|
|
+// // }
|
|
|
+// Map<String,String> map = DiskUtils.getHdInfo();
|
|
|
+// // System.err.println(JSON.toJSON(map));
|
|
|
+//
|
|
|
+// File directory = new File(".");//设定为当前文件夹
|
|
|
+// String canPath = "";
|
|
|
+// String absPath = "";
|
|
|
+// try{
|
|
|
+// canPath = directory.getCanonicalPath();//获取标准的路径
|
|
|
+// absPath = directory.getAbsolutePath();//获取绝对路径
|
|
|
+// }catch(Exception e){
|
|
|
+// e.getMessage();
|
|
|
+// }
|
|
|
+// // System.err.println(canPath);
|
|
|
+// // System.err.println(absPath);
|
|
|
+// // double canSpace = DiskUtils.getWinDiskStoresInfo(canPath);
|
|
|
+// // System.err.println(canSpace);
|
|
|
+//
|
|
|
+// // double absSpace = DiskUtils.getWinDiskStoresInfo(absPath);
|
|
|
+// // System.err.println(absSpace);
|
|
|
+//
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static Desk getDeskUsage() {
|
|
|
+// Desk desk = new Desk();
|
|
|
+// try {
|
|
|
+// Runtime rt = Runtime.getRuntime();
|
|
|
+// Process p = rt.exec("df -hl");// df -hl 查看硬盘空间
|
|
|
+// BufferedReader in = null;
|
|
|
+// try {
|
|
|
+// in = new BufferedReader(new InputStreamReader(
|
|
|
+// p.getInputStream()));
|
|
|
+// String str = null;
|
|
|
+// String[] strArray = null;
|
|
|
+// int line = 0;
|
|
|
+// while ((str = in.readLine()) != null) {
|
|
|
+// line++;
|
|
|
+// if (line != 2) {
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// int m = 0;
|
|
|
+// strArray = str.split(" ");
|
|
|
+// for (String para : strArray) {
|
|
|
+// if (para.trim().length() == 0)
|
|
|
+// continue;
|
|
|
+// ++m;
|
|
|
+// if (para.endsWith("G") || para.endsWith("Gi")) {
|
|
|
+// // 目前的服务器
|
|
|
+// if (m == 2) {
|
|
|
+// desk.setTotal(para);
|
|
|
+// }
|
|
|
+// if (m == 3) {
|
|
|
+// desk.setUsed(para);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if (para.endsWith("%")) {
|
|
|
+// if (m == 5) {
|
|
|
+// desk.setUse_rate(para);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// } finally {
|
|
|
+// in.close();
|
|
|
+// }
|
|
|
+// } catch (Exception e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// return desk;
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void contextLoads() {
|
|
|
+// String data = "{ \"lender\":\"王俞\", \"address\":\"上海市上海市管辖区浦东新区祝桥镇千汇路750弄60号401室\", \"mobile\":\"18501631918\", \"postCode\":\"200000\", \"idCode\":\"310225198803253034\", \"lower\":\"200000\", \"account\":\"王俞\", \"accountCode\":\"6217900800003831631\", \"deadline\":\"36\" , \"compareDate\":\"2020.04.15\" }";
|
|
|
+//
|
|
|
+// System.err.println(changeSourceDataBy18(data));
|
|
|
+// // ResData resData = new ResData();
|
|
|
+// // resData.setMidConfidence("2");
|
|
|
+// // resData.setOverallConfidence("2");
|
|
|
+// // backService.backToFjs(resData,"10",System.currentTimeMillis(),"1");
|
|
|
+// }
|
|
|
+//
|
|
|
+// public String changeSourceDataBy18(String data){
|
|
|
+// JSONObject js = JSON.parseObject(data);
|
|
|
+// if (js.containsKey("postCode")){
|
|
|
+// js.remove("postCode");
|
|
|
+// }
|
|
|
+// if (js.containsKey("deadline")){
|
|
|
+// js.remove("deadline");
|
|
|
+// }
|
|
|
+// System.err.println(js.toJSONString());
|
|
|
+// if (js.containsKey("address")){
|
|
|
+// js.put("addressSign",js.get("address").toString());
|
|
|
+// }
|
|
|
+// return js.toJSONString();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testjs(){
|
|
|
+// JSONObject ocr = null;
|
|
|
+// System.err.println(JSON.toJSONString(ocr));
|
|
|
+// org.json.JSONObject res = new org.json.JSONObject();
|
|
|
+// try {
|
|
|
+// String resStr = res.toString();
|
|
|
+// ocr = JSON.parseObject(resStr);
|
|
|
+//
|
|
|
+// System.err.println("ocr 2:"+JSON.toJSONString(ocr));
|
|
|
+// }catch (Exception e){
|
|
|
+// e.getMessage();
|
|
|
+// System.err.println(e.getMessage());
|
|
|
+// }
|
|
|
+// String resstr = res.toString();
|
|
|
+// ocr = res.equals("noneex") ? ocr : JSON.parseObject(resstr);
|
|
|
+// System.err.println("ocr 4:"+JSON.toJSONString(ocr));
|
|
|
+//
|
|
|
+//
|
|
|
+// ocr = JSON.parseObject(resstr);
|
|
|
+//
|
|
|
+// System.err.println("ocr 3:"+JSON.toJSONString(ocr));
|
|
|
+// if (null != ocr && ocr.containsKey("image_status") && ocr.get("image_status").toString().equals("normal")) {
|
|
|
+// System.err.println("...");
|
|
|
+// }
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testMD5() throws Exception {
|
|
|
+// String str = base64Dcrypt("BPMFvLeFYr8zWKdkGIlhhg==");
|
|
|
+// System.err.println(str.getBytes("utf-8"));
|
|
|
+// System.out.println(new String(str.getBytes("utf-8")));
|
|
|
+// System.err.println(JM(base64Dcrypt("BPMFvLeFYr8zWKdkGIlhhg==")));
|
|
|
+// //(a)首先对md5(base64)进行base64解码
|
|
|
+//
|
|
|
+// //(b)对base64解码后的值通过二进制方式进行读取,其结果应该为32位字符串
|
|
|
+//
|
|
|
+// //(c)对获取的32位字符串进行md5解密。
|
|
|
+// System.err.println(getEncryptPwd("097197"));
|
|
|
+//
|
|
|
+// // String mailPassword = "xivaxiva";
|
|
|
+// // BASE64Encoder encoder = new BASE64Encoder();
|
|
|
+// // String pass = encoder.encode(mailPassword.getBytes());
|
|
|
+//
|
|
|
+// String name = "BPMFvLeFYr8zWKdkGIlhhg==";
|
|
|
+// BASE64Decoder decoder = new BASE64Decoder();
|
|
|
+// byte[] decoderName = decoder.decodeBuffer(name);
|
|
|
+//
|
|
|
+// System.out.println(new String(decoderName).getBytes("utf-8"));
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * MD5加密字符串
|
|
|
+// *
|
|
|
+// * @param str 加密字符串
|
|
|
+// * @return 加密后的字符串
|
|
|
+// * @throws Exception 异常
|
|
|
+// */
|
|
|
+// public static String getEncryptPwd(String str) throws Exception {
|
|
|
+// MessageDigest md = MessageDigest.getInstance("MD5");
|
|
|
+// BASE64Encoder encoder = new BASE64Encoder();
|
|
|
+// return encoder.encode(md.digest(str.getBytes("utf-8")));
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * base64解密
|
|
|
+// */
|
|
|
+// public static String base64Dcrypt(String str) {
|
|
|
+// if (str == null) return null;
|
|
|
+// String decoderStr = "";
|
|
|
+//
|
|
|
+// try {
|
|
|
+// BASE64Decoder decoder = new BASE64Decoder();
|
|
|
+// byte[] b = decoder.decodeBuffer(str);
|
|
|
+// decoderStr = new String(b);
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// return null;
|
|
|
+// }
|
|
|
+//
|
|
|
+// return decoderStr;
|
|
|
+// }
|
|
|
+// // 加密后解密
|
|
|
+// public static String JM(String inStr) {
|
|
|
+// char[] a = inStr.toCharArray();
|
|
|
+// for (int i = 0; i < a.length; i++) {
|
|
|
+// a[i] = (char) (a[i] ^ 't');
|
|
|
+// }
|
|
|
+// String k = new String(a);
|
|
|
+// return k;
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void test() throws IOException {
|
|
|
+// String data = "{ \"lender\":\"占小琴\", \"idCode\":\"420281198501257247\", \"mobile\":\"13872114908\", \"address\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\", \"lower\":\"150000\", \"postCode\":\"200000\", \"deadline\":\"36\", \"period\":\"36\", \"account\":\"占小琴\", \"accountCode\":\"6217907600006022664\", \"loanType\":\"装修\", \"sendAddress\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\" , \"compareDate\":\"2020.07.30\" }";
|
|
|
+// String reqId = "BO202008210002";
|
|
|
+// String fileType = "5";
|
|
|
+// String url = "";
|
|
|
+// String fileName = "";
|
|
|
+// Long startTime = System.currentTimeMillis();
|
|
|
+// // ocrService.toOcr(reqId, fileType, url, fileName, data, startTime);
|
|
|
+// ocrService.toOcr(reqId, fileType, url, fileName, data, startTime);
|
|
|
+// // ocrService.singleFileOcrSyn( reqId, fileType, FileDetails parsedFilePath, List<FileDetails> paths, sourceData, startTime);
|
|
|
+//
|
|
|
+// System.err.println(changeSourceDataBy18(data));
|
|
|
+// // ResData resData = new ResData();
|
|
|
+// // resData.setMidConfidence("2");
|
|
|
+// // resData.setOverallConfidence("2");
|
|
|
+// // backService.backToFjs(resData,"10",System.currentTimeMillis(),"1");
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void test18(){
|
|
|
+// String data = "{\"account\":\"占小琴\",\"accountCode\":\"6217907600006022664\",\"address\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\",\"compareDate\":\"2020.07.30\",\"deadline\":\"\",\"idCode\":\"420281198501257247\",\"lender\":\"占小琴\",\"loanType\":\"装修\",\"lower\":\"150000\",\"mobile\":\"13872114908\",\"operateIp\":\"\",\"operateTime\":\"2020-08-21 15:37:16\",\"operator\":\"\",\"operatorId\":\"\",\"period\":\"36\",\"postCode\":\"\",\"remarks\":\"1301.0ms\",\"reqId\":\"BO202008210005\",\"sendAddress\":\"湖北省黄石市下陆区半山骊园6栋1单元304室\"}\n";
|
|
|
+// ContractEighteen contractEighteen;
|
|
|
+// if (null != data) {
|
|
|
+// Eighteen eighteen = JSONObject.parseObject(JSON.parseObject(data).toJSONString(), Eighteen.class);
|
|
|
+// contractEighteen = new ContractEighteen();
|
|
|
+// BeanUtils.copyProperties(eighteen, contractEighteen);
|
|
|
+// contractEighteen.setReqId("1111111111111111111111");
|
|
|
+// contractEighteen.setPostCode("");
|
|
|
+// contractEighteen.setDeadline("");
|
|
|
+// contractEighteen.setOperator("");
|
|
|
+// contractEighteen.setOperatorId("");
|
|
|
+// contractEighteen.setOperateIp("");
|
|
|
+// contractEighteen.setOperateTime(DateUtils.now());
|
|
|
+// contractEighteen.setRemarks(String.valueOf(System.currentTimeMillis()));
|
|
|
+// } else {
|
|
|
+// contractEighteen = new ContractEighteen();
|
|
|
+// }
|
|
|
+// System.err.println(contractEighteenMapper.insert(contractEighteen));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testDate(){
|
|
|
+// LocalDate date = LocalDate.now();
|
|
|
+// System.out.println("当前日期=" + date);
|
|
|
+// System.err.println(DateUtils.createFilesByDate());
|
|
|
+// System.out.println(DateUtils.now());
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testUnBack(){
|
|
|
+// QueryWrapper<Upload> uploadQueryWrapper = new QueryWrapper<>();
|
|
|
+// uploadQueryWrapper.lambda()
|
|
|
+// .between(Upload::getOperateTime, DateUtils.startDate(), DateUtils.endDate());
|
|
|
+// // List<Upload> uploads = uploadMapper.selectList();
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testOcrBack(){
|
|
|
+// List list = uploadService.findByReqId("10","BO20200414000005-03");
|
|
|
+// System.out.println(JSON.toJSONString(list));
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Test
|
|
|
+// public void testDates(){
|
|
|
+// String date = "2020-11-06 10:14:40";
|
|
|
+// System.out.println(daysBetweenDates(date));
|
|
|
+// }
|
|
|
+//
|
|
|
+// public static long daysBetweenDates(String date) {
|
|
|
+// LocalDateTime localDate1 = LocalDateTime.parse(DateUtils.now(), DateTimeFormatter.ofPattern(Constants.DEFAULT_DATETIME_FORMAT));
|
|
|
+// LocalDateTime localDate2 = LocalDateTime.parse(date, DateTimeFormatter.ofPattern(Constants.DEFAULT_DATETIME_FORMAT));
|
|
|
+// System.out.println(localDate1);
|
|
|
+// System.out.println(localDate2);
|
|
|
+// return Math.abs(ChronoUnit.MINUTES.between(localDate1, localDate2));
|
|
|
+// }
|
|
|
+//
|
|
|
+//}
|