|
@@ -0,0 +1,595 @@
|
|
|
+package com.pavis.ai.app.cr.service.impl;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.pavis.ai.app.cr.common.config.properties.CommonProperties;
|
|
|
+import com.pavis.ai.app.cr.common.utils.DateUtils;
|
|
|
+import com.pavis.ai.app.cr.form.ResData;
|
|
|
+import com.pavis.ai.app.cr.form.SendUrl;
|
|
|
+import com.pavis.ai.app.cr.mapper.*;
|
|
|
+import com.pavis.ai.app.cr.model.*;
|
|
|
+import com.pavis.ai.app.cr.service.SendService;
|
|
|
+import com.pavis.ai.app.cr.service.UploadService;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.UUID;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author guanhuijuan
|
|
|
+ * @create 2020-03-16 15:42
|
|
|
+ * @desc UploadServiceImpl
|
|
|
+ **/
|
|
|
+@Slf4j
|
|
|
+@Service
|
|
|
+@Transactional(rollbackFor = Exception.class)
|
|
|
+public class UploadServiceImpl implements UploadService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private CommonProperties commonProperties;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SendService sendService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private UploadMapper uploadMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractAddressMapper contractAddressMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractAmountCheckMapper contractAmountCheckMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractClassificationMapper contractClassificationMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractEnterpriseMapper contractEnterpriseMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractSubjectNameMapper contractSubjectNameMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractSubjectMobileMapper contractSubjectMobileMapper;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ContractSubjectDateMapper contractSubjectDateMapper;
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public ResData upload(MultipartFile file) {
|
|
|
+ String fileUrl = commonProperties.getDir().getUpload();
|
|
|
+ String uuid = UUID.randomUUID().toString();
|
|
|
+ String suffix = StringUtils.substringAfterLast(file.getOriginalFilename(), ".");
|
|
|
+ String pathName = uuid + "." + suffix;
|
|
|
+ String parsedFilePath = fileUrl + pathName;
|
|
|
+ File f = new File(parsedFilePath);
|
|
|
+ try {
|
|
|
+ file.transferTo(new File(parsedFilePath));
|
|
|
+ } catch (IllegalStateException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ // 上传文件入库
|
|
|
+ String upload = save(file);
|
|
|
+ if (!upload.equals("")) {
|
|
|
+ // todo 调用算法,获取解析结果。
|
|
|
+ // 文件路径方式
|
|
|
+ SendUrl sendUrl = SendUrl.builder()
|
|
|
+ // 上线时用
|
|
|
+ // .fileUrl(fileUrl + pathName)
|
|
|
+ // 线下测试时用
|
|
|
+ // .fileUrl("/mnt/text-extract/file_down/jpg/广告公司合同范本.docx")
|
|
|
+ .fileUrl(parsedFilePath)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ // String resStr2 = "";
|
|
|
+ String resStr2 = sendService.sendUrl(JSON.toJSONString(sendUrl));
|
|
|
+ System.err.println("resStr2>" + resStr2);
|
|
|
+ // okhttp远程发送文件,formdata形式
|
|
|
+ // String resStr = ocrByFormData(f,file.getOriginalFilename());
|
|
|
+
|
|
|
+ // 测试用
|
|
|
+ // int rd = Math.random() > 0.5 ? 1 : 0;
|
|
|
+ // String resStr = "";
|
|
|
+ // if (rd == 0){
|
|
|
+ // resStr = OcrUtils.getStrEmptyFinal();
|
|
|
+ // }else {
|
|
|
+ // resStr = OcrUtils.getStrFinal();
|
|
|
+ // }
|
|
|
+ // 将解析结果入库,判断是否有结果。
|
|
|
+ // return parseRes(resStr2, upload, uuid + ".pdf");
|
|
|
+ return parseRes(resStr2, upload, "广告公司合同范本" + ".pdf");
|
|
|
+
|
|
|
+ }
|
|
|
+ return new ResData();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 文件上传入库。
|
|
|
+ *
|
|
|
+ * @param file
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public String save(MultipartFile file) {
|
|
|
+ Upload upload = Upload.builder()
|
|
|
+ // .fileName(file.getOriginalFilename())
|
|
|
+ .fileName(file.getOriginalFilename())
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ uploadMapper.insert(upload);
|
|
|
+ return upload.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ public ResData parseRes(String resStr, String upload, String fileName) {
|
|
|
+ JSONObject strJson = JSONObject.parseObject(resStr);
|
|
|
+ if (strJson.get("code").toString().equals("1")) {
|
|
|
+ // 解析成功
|
|
|
+ JSONObject dataJson = JSONObject.parseObject(strJson.get("data").toString());
|
|
|
+
|
|
|
+ // 地址解析
|
|
|
+ JSONArray addressJa = JSONArray.parseArray(dataJson.get("locations").toString());
|
|
|
+ List<ContractAddress> contractAddresss = parseAddress(addressJa, upload);
|
|
|
+ // 合同主体解析
|
|
|
+ JSONArray subjectPersonJa = JSONArray.parseArray(dataJson.get("person").toString());
|
|
|
+ List<ContractSubjectName> contractSubjectNames = parseSubjectName(subjectPersonJa, upload);
|
|
|
+ JSONArray subjectTimesJa = JSONArray.parseArray(dataJson.get("times").toString());
|
|
|
+ List<ContractSubjectDate> contractSubjectDates = parseSubjectDate(subjectTimesJa, upload);
|
|
|
+ JSONArray subjectPhoneJa = JSONArray.parseArray(dataJson.get("phone_numbers").toString());
|
|
|
+ List<ContractSubjectMobile> contractSubjectMobiles = parseSubjectMobile(subjectPhoneJa, upload);
|
|
|
+
|
|
|
+ // 金额核验解析
|
|
|
+ JSONArray amountCheckJa = JSONArray.parseArray(dataJson.get("amount").toString());
|
|
|
+ List<ContractAmountCheck> contractAmountChecks = parseAmountCheck(amountCheckJa, upload);
|
|
|
+
|
|
|
+ // 企业名称解析
|
|
|
+ JSONArray enterpriseJa = JSONArray.parseArray(dataJson.get("orgs_info").toString());
|
|
|
+ List<ContractEnterprise> contractEnterprises = parseEnterprise(enterpriseJa, upload);
|
|
|
+
|
|
|
+ // 合同分类、免责声明解析
|
|
|
+ List<ContractClassification> contractClassifications = parseClassification(dataJson, upload);
|
|
|
+
|
|
|
+ // 返回结果封装。
|
|
|
+ ResData resData = ResData.builder()
|
|
|
+ .fileUrl(commonProperties.getUrl().getPath() + strJson.get("pdffilename").toString())
|
|
|
+ .locations(contractAddresss.size() > 0 ? resCa(contractAddresss) : getEmpty())
|
|
|
+ .person(contractSubjectNames.size() > 0 ? resCsn(contractSubjectNames) : getEmpty())
|
|
|
+ .times(contractSubjectDates.size() > 0 ? resCsd(contractSubjectDates) : getEmpty())
|
|
|
+ .amount(contractAmountChecks.size() > 0 ? resCac(contractAmountChecks) : getEmpty())
|
|
|
+ .orgs_info(contractEnterprises.size() > 0 ? resCe(contractEnterprises) : getEmpty())
|
|
|
+ .phone_numbers(contractSubjectMobiles.size() > 0 ? resCsm(contractSubjectMobiles) : getEmpty())
|
|
|
+ .classification(contractClassifications.size() > 0 ? contractClassifications.get(0).getContractClassification() : "无")
|
|
|
+ .disclaimer(contractClassifications.size() > 0 ? resCcd(contractClassifications) : getEmpty())
|
|
|
+ .build();
|
|
|
+ System.err.println(JSON.toJSONString(resData));
|
|
|
+ return resData;
|
|
|
+ } else {
|
|
|
+ // 解析失败。
|
|
|
+ return new ResData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public List<ContractClassification> parseClassification(JSONObject dataJson, String upload) {
|
|
|
+ String classification = dataJson.get("classification").toString();
|
|
|
+ List<ContractClassification> contractClassifications = new ArrayList<>();
|
|
|
+ JSONArray classificationJa = JSONArray.parseArray(dataJson.get("disclaimer").toString());
|
|
|
+ if (classificationJa.size() >= 1) {
|
|
|
+ ContractClassification contractClassification;
|
|
|
+ for (int i = 0; i < classificationJa.size(); i++) {
|
|
|
+ if (!classificationJa.get(i).toString().equals("") || !classificationJa.get(i).toString().equals("[]")) {
|
|
|
+ contractClassification = ContractClassification.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .contractClassification(classification)
|
|
|
+ .disclaimer(classificationJa.get(i).toString())
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractClassificationMapper.insert(contractClassification);
|
|
|
+ contractClassifications.add(contractClassification);
|
|
|
+ } else {
|
|
|
+ contractClassification = ContractClassification.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .contractClassification("无")
|
|
|
+ .disclaimer("无")
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractClassificationMapper.insert(contractClassification);
|
|
|
+ contractClassifications.add(contractClassification);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return contractClassifications;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ContractAddress> parseAddress(JSONArray addressJa, String upload) {
|
|
|
+ List<ContractAddress> contractAddresss = new ArrayList<>();
|
|
|
+ System.err.println("size>" + addressJa.size());
|
|
|
+ if (addressJa.size() > 0) {
|
|
|
+ ContractAddress contractAddress;
|
|
|
+ for (int i = 0; i < addressJa.size(); i++) {
|
|
|
+ System.err.println(addressJa.get(i).toString());
|
|
|
+ if (!addressJa.get(i).toString().equals("") || !addressJa.get(i).toString().equals("[]")) {
|
|
|
+ System.err.println("if");
|
|
|
+ JSONArray address = JSONArray.parseArray(addressJa.get(i).toString());
|
|
|
+ String[] arr = StringUtils.remove(StringUtils.remove(address.toString(), "["), "]").split(",");
|
|
|
+ contractAddress = ContractAddress.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .locationParagraph(StringUtils.remove(arr[0], "\""))
|
|
|
+ .locationPosition(StringUtils.remove(arr[1], "\""))
|
|
|
+ .address(StringUtils.remove(arr[2], "\""))
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractAddressMapper.insert(contractAddress);
|
|
|
+ contractAddresss.add(contractAddress);
|
|
|
+ } else {
|
|
|
+ System.err.println("else");
|
|
|
+ contractAddresss.add(new ContractAddress());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ System.err.println("else insert");
|
|
|
+ ContractAddress contractAddress = ContractAddress.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .locationParagraph("无")
|
|
|
+ .locationPosition("无")
|
|
|
+ .address("无")
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractAddressMapper.insert(contractAddress);
|
|
|
+ }
|
|
|
+ return contractAddresss;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ContractSubjectName> parseSubjectName(JSONArray subjectPersonJa, String upload) {
|
|
|
+ List<ContractSubjectName> contractSubjectNames = new ArrayList<>();
|
|
|
+ if (subjectPersonJa.size() > 0) {
|
|
|
+ ContractSubjectName contractSubjectName;
|
|
|
+ for (int i = 0; i < subjectPersonJa.size(); i++) {
|
|
|
+ if (!subjectPersonJa.get(i).toString().equals("") || !subjectPersonJa.get(i).toString().equals("[]")) {
|
|
|
+ JSONArray address = JSONArray.parseArray(subjectPersonJa.get(i).toString());
|
|
|
+ String[] arr = StringUtils.remove(StringUtils.remove(address.toString(), "["), "]").split(",");
|
|
|
+ contractSubjectName = ContractSubjectName.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .nameLocationParagraph(StringUtils.remove(arr[0], "\""))
|
|
|
+ .nameLocationPosition(StringUtils.remove(arr[1], "\""))
|
|
|
+ .subjectName(StringUtils.remove(arr[2], "\""))
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractSubjectNameMapper.insert(contractSubjectName);
|
|
|
+ contractSubjectNames.add(contractSubjectName);
|
|
|
+ } else {
|
|
|
+
|
|
|
+ contractSubjectNames.add(new ContractSubjectName());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ContractSubjectName contractSubjectName = ContractSubjectName.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .nameLocationParagraph("无")
|
|
|
+ .nameLocationPosition("无")
|
|
|
+ .subjectName("无")
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractSubjectNameMapper.insert(contractSubjectName);
|
|
|
+ }
|
|
|
+ return contractSubjectNames;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ContractSubjectDate> parseSubjectDate(JSONArray subjectDateJa, String upload) {
|
|
|
+ List<ContractSubjectDate> contractSubjectDates = new ArrayList<>();
|
|
|
+ if (subjectDateJa.size() > 0) {
|
|
|
+ ContractSubjectDate contractSubjectDate;
|
|
|
+ for (int i = 0; i < subjectDateJa.size(); i++) {
|
|
|
+ if (!subjectDateJa.get(i).toString().equals("") || !subjectDateJa.get(i).toString().equals("[]")) {
|
|
|
+ JSONArray address = JSONArray.parseArray(subjectDateJa.get(i).toString());
|
|
|
+ String[] arr = StringUtils.remove(StringUtils.remove(address.toString(), "["), "]").split(",");
|
|
|
+ contractSubjectDate = ContractSubjectDate.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .dateLocationParagraph(StringUtils.remove(arr[0], "\""))
|
|
|
+ .dateLocationPosition(StringUtils.remove(arr[1], "\""))
|
|
|
+ .subjectDate(StringUtils.remove(arr[2], "\""))
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractSubjectDateMapper.insert(contractSubjectDate);
|
|
|
+ contractSubjectDates.add(contractSubjectDate);
|
|
|
+ } else {
|
|
|
+ contractSubjectDates.add(new ContractSubjectDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ContractSubjectDate contractSubjectDate = ContractSubjectDate.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .dateLocationParagraph("无")
|
|
|
+ .dateLocationPosition("无")
|
|
|
+ .subjectDate("无")
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractSubjectDateMapper.insert(contractSubjectDate);
|
|
|
+ }
|
|
|
+ return contractSubjectDates;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ContractSubjectMobile> parseSubjectMobile(JSONArray subjectMobileJa, String upload) {
|
|
|
+ List<ContractSubjectMobile> contractSubjectMobiles = new ArrayList<>();
|
|
|
+ if (subjectMobileJa.size() > 0) {
|
|
|
+ ContractSubjectMobile contractSubjectMobile;
|
|
|
+ for (int i = 0; i < subjectMobileJa.size(); i++) {
|
|
|
+ if (!subjectMobileJa.get(i).toString().equals("") || !subjectMobileJa.get(i).toString().equals("[]")) {
|
|
|
+ JSONArray address = JSONArray.parseArray(subjectMobileJa.get(i).toString());
|
|
|
+ String[] arr = StringUtils.remove(StringUtils.remove(address.toString(), "["), "]").split(",");
|
|
|
+ contractSubjectMobile = ContractSubjectMobile.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .mobileLocationParagraph(StringUtils.remove(arr[0], "\""))
|
|
|
+ .mobileLocationPosition(StringUtils.remove(arr[1], "\""))
|
|
|
+ .subjectMobile(StringUtils.remove(arr[2], "\""))
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractSubjectMobileMapper.insert(contractSubjectMobile);
|
|
|
+ contractSubjectMobiles.add(contractSubjectMobile);
|
|
|
+ } else {
|
|
|
+ contractSubjectMobiles.add(new ContractSubjectMobile());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ContractSubjectMobile contractSubjectMobile = ContractSubjectMobile.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .mobileLocationParagraph("无")
|
|
|
+ .mobileLocationPosition("无")
|
|
|
+ .subjectMobile("无")
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractSubjectMobileMapper.insert(contractSubjectMobile);
|
|
|
+ }
|
|
|
+ return contractSubjectMobiles;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ContractAmountCheck> parseAmountCheck(JSONArray amountCheckJa, String upload) {
|
|
|
+ List<ContractAmountCheck> contractAmountChecks = new ArrayList<>();
|
|
|
+ if (amountCheckJa.size() > 0) {
|
|
|
+
|
|
|
+ ContractAmountCheck contractAmountCheck;
|
|
|
+ for (int i = 0; i < amountCheckJa.size(); i++) {
|
|
|
+ if (!amountCheckJa.get(i).toString().equals("") || !amountCheckJa.get(i).toString().equals("[]")) {
|
|
|
+ JSONArray address = JSONArray.parseArray(amountCheckJa.get(i).toString());
|
|
|
+ String[] arr = StringUtils.remove(StringUtils.remove(address.toString(), "["), "]").split(",");
|
|
|
+ contractAmountCheck = ContractAmountCheck.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .locationParagraph(StringUtils.remove(arr[0], "\""))
|
|
|
+ .locationPosition(StringUtils.remove(arr[1], "\""))
|
|
|
+ .capital(StringUtils.remove(arr[2], "\""))
|
|
|
+ .lower(StringUtils.remove(arr[3], "\""))
|
|
|
+ .unit(StringUtils.remove(arr[4], "\""))
|
|
|
+ .result(StringUtils.remove(arr[5], "\""))
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractAmountCheckMapper.insert(contractAmountCheck);
|
|
|
+ contractAmountChecks.add(contractAmountCheck);
|
|
|
+ } else {
|
|
|
+ contractAmountChecks.add(new ContractAmountCheck());
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ContractAmountCheck contractAmountCheck = ContractAmountCheck.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .locationParagraph("无")
|
|
|
+ .locationPosition("无")
|
|
|
+ .capital("无")
|
|
|
+ .lower("无")
|
|
|
+ .unit("无")
|
|
|
+ .result("无")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractAmountCheckMapper.insert(contractAmountCheck);
|
|
|
+ }
|
|
|
+ return contractAmountChecks;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<ContractEnterprise> parseEnterprise(JSONArray enterpriseJa, String upload) {
|
|
|
+ List<ContractEnterprise> contractEnterprises = new ArrayList<>();
|
|
|
+ if (enterpriseJa.size() > 0) {
|
|
|
+
|
|
|
+ ContractEnterprise contractEnterprise;
|
|
|
+ for (int i = 0; i < enterpriseJa.size(); i++) {
|
|
|
+ if (!enterpriseJa.get(i).toString().equals("") || !enterpriseJa.get(i).toString().equals("[]")) {
|
|
|
+ JSONArray address = JSONArray.parseArray(enterpriseJa.get(i).toString());
|
|
|
+ String[] arr = StringUtils.remove(StringUtils.remove(address.toString(), "["), "]").split(",");
|
|
|
+ contractEnterprise = ContractEnterprise.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .agency(StringUtils.remove(arr[0], "\""))
|
|
|
+ .locationParagraph(StringUtils.remove(arr[1], "\""))
|
|
|
+ .locationPosition(StringUtils.remove(arr[2], "\""))
|
|
|
+ .enterpriseName(StringUtils.remove(arr[3], "\""))
|
|
|
+ .result(StringUtils.remove(arr[4], "\""))
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractEnterpriseMapper.insert(contractEnterprise);
|
|
|
+ contractEnterprises.add(contractEnterprise);
|
|
|
+ } else {
|
|
|
+ contractEnterprises.add(new ContractEnterprise());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ ContractEnterprise contractEnterprise = ContractEnterprise.builder()
|
|
|
+ .cId(upload)
|
|
|
+ .agency("无")
|
|
|
+ .locationParagraph("无")
|
|
|
+ .locationPosition("无")
|
|
|
+ .enterpriseName("无")
|
|
|
+ .result("无")
|
|
|
+ .operator("")
|
|
|
+ .operatorId("")
|
|
|
+ .operateIp("")
|
|
|
+ .operateTime(DateUtils.now())
|
|
|
+ .remarks("")
|
|
|
+ .build();
|
|
|
+ contractEnterpriseMapper.insert(contractEnterprise);
|
|
|
+ }
|
|
|
+ return contractEnterprises;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ public List<List<String>> getEmpty() {
|
|
|
+ List<String> resList = new ArrayList<>();
|
|
|
+ resList.add("无");
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ res.add(resList);
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<List<String>> resCa(List<ContractAddress> contractAddresss) {
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ for (ContractAddress addresss : contractAddresss) {
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add(addresss.getLocationParagraph());
|
|
|
+ data.add(addresss.getLocationPosition());
|
|
|
+ data.add(addresss.getAddress());
|
|
|
+ res.add(data);
|
|
|
+ }
|
|
|
+
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<List<String>> resCsn(List<ContractSubjectName> contractSubjectNames) {
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ for (ContractSubjectName subjectName : contractSubjectNames) {
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add(subjectName.getNameLocationParagraph());
|
|
|
+ data.add(subjectName.getNameLocationPosition());
|
|
|
+ data.add(subjectName.getSubjectName());
|
|
|
+ res.add(data);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<List<String>> resCsd(List<ContractSubjectDate> contractSubjectDates) {
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ for (ContractSubjectDate subjectDate : contractSubjectDates) {
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add(subjectDate.getDateLocationParagraph());
|
|
|
+ data.add(subjectDate.getDateLocationPosition());
|
|
|
+ data.add(subjectDate.getSubjectDate());
|
|
|
+ res.add(data);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<List<String>> resCac(List<ContractAmountCheck> contractAmountChecks) {
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ for (ContractAmountCheck amountCheck : contractAmountChecks) {
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add(amountCheck.getLocationParagraph());
|
|
|
+ data.add(amountCheck.getLocationPosition());
|
|
|
+ data.add(amountCheck.getCapital());
|
|
|
+ data.add(amountCheck.getLower());
|
|
|
+ data.add(amountCheck.getUnit());
|
|
|
+ data.add(amountCheck.getResult());
|
|
|
+ res.add(data);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<List<String>> resCe(List<ContractEnterprise> contractEnterprises) {
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ for (ContractEnterprise enterprise : contractEnterprises) {
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add(enterprise.getAgency());
|
|
|
+ data.add(enterprise.getLocationParagraph());
|
|
|
+ data.add(enterprise.getLocationPosition());
|
|
|
+ data.add(enterprise.getEnterpriseName());
|
|
|
+ data.add(enterprise.getResult());
|
|
|
+ res.add(data);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<List<String>> resCsm(List<ContractSubjectMobile> contractSubjectMobiles) {
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ for (ContractSubjectMobile mobile : contractSubjectMobiles) {
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ data.add(mobile.getMobileLocationParagraph());
|
|
|
+ data.add(mobile.getMobileLocationPosition());
|
|
|
+ data.add(mobile.getSubjectMobile());
|
|
|
+ res.add(data);
|
|
|
+ }
|
|
|
+ return res;
|
|
|
+ }
|
|
|
+
|
|
|
+ public List<String> resCcd(List<ContractClassification> contractClassifications) {
|
|
|
+ List<List<String>> res = new ArrayList<>();
|
|
|
+ List<String> data = new ArrayList<>();
|
|
|
+ for (ContractClassification contractClassification : contractClassifications) {
|
|
|
+ data.add(contractClassification.getDisclaimer());
|
|
|
+ res.add(data);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ }
|
|
|
+
|
|
|
+}
|