Merge branch 'wq' of SH-Arbitrate/Arbitrate-Backend into dev

This commit was merged in pull request #284.
This commit is contained in:
2023-12-07 15:08:44 +08:00
committed by Gitea
5 changed files with 145 additions and 132 deletions
@@ -15,7 +15,7 @@ public interface FatchRuleMapper {
/**
* 根据批次查询
*/
List<FatchRule> listByTemplateId(@Param("templateId")String templateId);
List<FatchRule> listByTemplateId(@Param("templateId")Long templateId);
List<FatchRule> selectFatchRuleList(FatchRule fatchRule);
@@ -14,6 +14,7 @@ import com.documents4j.job.LocalConverter;
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.config.RuoYiConfig;
import com.ruoyi.common.constant.CaseApplicationConstants;
@@ -37,7 +38,6 @@ import com.ruoyi.system.mapper.SysUserRoleMapper;
import com.ruoyi.wisdomarbitrate.domain.vo.ColumnValue;
import com.ruoyi.wisdomarbitrate.domain.vo.ReservedConferenceVO;
import com.ruoyi.wisdomarbitrate.domain.vo.ToDoCount;
import com.ruoyi.wisdomarbitrate.utils.CaseLogUtils;
import com.ruoyi.wisdomarbitrate.domain.*;
import com.ruoyi.wisdomarbitrate.domain.vo.SendRoomNoMessageVO;
import com.ruoyi.wisdomarbitrate.mapper.*;
@@ -46,41 +46,33 @@ import com.ruoyi.wisdomarbitrate.utils.OCRUtils;
import com.ruoyi.wisdomarbitrate.utils.SignAward;
import com.ruoyi.wisdomarbitrate.utils.UnZipFileUtils;
import com.tencentyun.TLSSigAPIv2;
import org.apache.http.HttpEntity;
import org.apache.http.client.methods.CloseableHttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
import org.apache.pdfbox.pdmodel.PDDocument;
import org.apache.poi.xwpf.usermodel.Document;
import org.apache.poi.xwpf.usermodel.XWPFDocument;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.multipart.MultipartFile;
import java.io.*;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.ZoneId;
import java.util.*;
import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.function.Function;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;
import java.util.zip.ZipEntry;
import java.util.zip.ZipInputStream;
import static com.ruoyi.common.core.domain.AjaxResult.error;
import static com.ruoyi.common.core.domain.AjaxResult.success;
import static com.ruoyi.common.utils.PageUtils.startPage;
import static com.ruoyi.common.utils.SecurityUtils.getLoginUser;
@@ -253,6 +245,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
@Override
public ToDoCount selectToDoCount() {
@@ -398,9 +391,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
if (file.isEmpty()) {
return AjaxResult.error("请选择要上传的文件");
}
// todo 服务器路径需要改
String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
// String targetPath = "D:/";
File zipFile = null;
InputStream ins = null;
try {
@@ -416,10 +408,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
//得到解压缩的所有文件
String zipName = file.getOriginalFilename();
String subzipName = zipName.substring(0, zipName.indexOf(".zip"));
// String zipPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile\\"+subzipName;
// todo 服务器路径需要改
// todo
String zipPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
// String zipPath = "D:/" + subzipName;
// String zipPath = "D:/home/ruoyi/uploadPath/upload/unzipFile/" + subzipName;
File dirUnzipPath = new File(zipPath);
List<File> allFiles = new ArrayList<>();
@@ -511,9 +502,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
String day = String.format("%02d", now.getDayOfMonth());
// // todo 服务器路径需要改
// todo
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
// String saveFolderPath = "D:/" + year + "/" + month + "/" + day;
// String saveFolderPath = "D:/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
String fileName = UUID.randomUUID().toString().replace("-", "") + "_" + substrfile;
String resultFilePath = saveFolderPath + "/" + fileName;
try {
@@ -3003,17 +2994,17 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
return AjaxResult.error("请选择要上传的文件");
}
UUID uuid = UUID.randomUUID();
// todo 服务器路径需要改
// todo
String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile/" + uuid + "/";
// String targetPath = "D:/zip";
// String targetPath = "D:/home/ruoyi/uploadPath/upload/unzipFile/"+uuid+ "/";
File zipFile = null;
InputStream ins = null;
try {
ins = file.getInputStream();
//上传的压缩包保存的路径
// todo 服务器路径需要改
// todo
String savePath = "/home/ruoyi/uploadPath/upload/zipFile/";
// String savePath = "D:/zip/";
// String savePath = "D:/home/ruoyi/uploadPath/upload/zipFile/";
String saveName = uuid + "_" + file.getOriginalFilename();
zipFile = new File(savePath + saveName);
inputChangeToFile(ins, zipFile);
@@ -3025,7 +3016,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
if (unzipSuccess) {
// 查询抓取规则
// todo 批次需要再上传压缩包时用户填写
List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId("9");
List<FatchRule> fatchRuleList = fatchRuleMapper.listByTemplateId(17L);
if (CollectionUtil.isEmpty(fatchRuleList)) {
return error("未设置抓取规则");
}
File directory = new File(targetPath);
Map<String, String> andConvertPDF = findAndConvertPDF(directory, fatchRuleList);
if (andConvertPDF != null && andConvertPDF.size() > 0) {
@@ -3037,7 +3031,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
OCRAndBuildInfo(andConvertPDF, entry.getKey(), fatchMap, entry.getValue());
}
}
if (fatchMap.size() <= 0) {
return error("从压缩包中未抓取到内容,请检查抓取字段配置");
}
if (fatchMap.size() > 0) {
// todo 从压缩包中识别各字段填充到数据库
@@ -3169,7 +3165,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseAffiliate.setContactTelphoneAgent(fatchMap.get("agentPhone"));
// 代理人电子邮件
caseAffiliate.setAgentEmail(fatchMap.get("agentEmail").replaceAll("\\s", ""));
caseAffiliate.setAgentEmail(StrUtil.isNotEmpty(fatchMap.get("agentEmail")) ? fatchMap.get("agentEmail").replaceAll("\\s", "") : null);
//设置默认代理人的身份证号码,暂时写死 要不然新增方法报错
@@ -3211,7 +3207,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
// }
// }
// 被申请人电子邮件
respondentAffiliate.setEmail(fatchMap.get("respondentEmail").replaceAll("\\s", ""));
respondentAffiliate.setEmail(StrUtil.isNotEmpty(fatchMap.get("respondentEmail")) ? fatchMap.get("respondentEmail").replaceAll("\\s", "") : null);
// 被申请人联系电话
respondentAffiliate.setContactTelphone(fatchMap.get("respondentPhone"));
// 被申请人住所
@@ -3298,9 +3294,9 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
// return false;
}
StringBuilder ocrText = new StringBuilder(); // 创建一个StringBuilder对象
for (int i = 0; i < fileNumPage; i++) {
for (int i = 1; i <= fileNumPage; i++) {
//对接腾讯云接口.识别里面的数据
String text = OCRUtils.pdfIdentifyText(base64, i + 1, fatchRules);
String text = OCRUtils.pdfIdentifyText(base64, i , fatchRules);
ocrText.append(text); // 拼接当前的字符串
}
if(StrUtil.isNotEmpty(ocrText)){
@@ -3377,12 +3373,15 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
// 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
path = directory.getAbsolutePath();
} else {
String extension = getFileExtension(directory);
if( extension.contains("doc")|| extension.contains("docx")) {
// 如果不是PDF格式,进行转换成PDF并返回路径
String pdfPath = convertToPDF(directory);
if (pdfPath != null) {
path = pdfPath;
}
}
}
// 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
// 如果是PDF格式,直接添加到列表中
// if(CollectionUtil.isNotEmpty(fatchRuleList)) {
@@ -3450,19 +3449,23 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
private static String convertToPDF(File file) {
String wordFilePath = file.getAbsolutePath();
//String pdfSaveDirectory = "D:\\home\\unzip\\wordToPDF\\";
// todo 服务器路径需要改
// todo
String pdfSaveDirectory = "/home/ruoyi/uploadPath/upload/wordToPDF/";
// String pdfSaveDirectory = "D:/";
// String pdfSaveDirectory = "D:/home/ruoyi/uploadPath/upload/wordToPDF/";
File directory = new File(pdfSaveDirectory);
if (!directory.exists()) {
directory.mkdirs();
}
String name = file.getName();
String nameWithoutExtension = name.substring(0, name.lastIndexOf("."));
String pdfFilePath = pdfSaveDirectory + nameWithoutExtension + ".pdf";
File inputWord = new File(wordFilePath);
if(!inputWord.exists()){
throw new ServiceException("文件不存在wordFilePath:"+wordFilePath);
}
File outputFile = new File(pdfFilePath);
try {
InputStream docxInputStream = new FileInputStream(inputWord);
OutputStream outputStream = new FileOutputStream(outputFile);
@@ -3472,7 +3475,8 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
outputStream.close();
} catch (Exception e) {
e.printStackTrace();
throw new ServiceException(e.getMessage()+"wordFilePath:"+wordFilePath+"pdfFilePath:"+pdfFilePath);
// e.printStackTrace();
}
return pdfFilePath;
}
@@ -555,12 +555,8 @@ public class DeptIdentifyServiceImpl implements IDeptIdentifyService {
public AjaxResult saveFatchRules(TemplateManage templateManage) {
TemplateFatchRule templateFatchRule = new TemplateFatchRule();
templateFatchRule.setTemplateId(templateManage.getId());
List<TemplateFatchRule> templateFatchRulelist = templateFatchRuleMapper.selectTemplateFatchRuleList(templateFatchRule);
if(templateFatchRulelist!=null&&templateFatchRulelist.size()>0){
List<Long> fatchRuleIds = templateFatchRulelist.stream().map(TemplateFatchRule::getFatchRuleId).collect(Collectors.toList());
fatchRuleMapper.deletebatchFatchRule(fatchRuleIds);
templateFatchRuleMapper.deleteTemplateFatchRule(templateManage.getId());
}
List<FatchRule> fatchRules = templateManage.getFatchRules();
if(fatchRules!=null&&fatchRules.size()>0){
for (FatchRule fatchRule : fatchRules) {
@@ -221,11 +221,15 @@ public class OCRUtils {
// 开始截取字符串 申请人:赵会
// String[] startContentSplit = ocrText.split(fatchRule.getStartContent());
int startFirstIndex = ocrText.indexOf(fatchRule.getStartContent()) + fatchRule.getStartContent().length();
if(startFirstIndex<0){
continue;
}
if (ocrText.length() >= startFirstIndex) {
ocrText = ocrText.substring(startFirstIndex);
}
if (StrUtil.isNotEmpty(fatchRule.getEndContent())) {
if(ocrText.indexOf(fatchRule.getEndContent())>=0) {
int endFirstIndex = ocrText.indexOf(fatchRule.getEndContent()) + fatchRule.getEndContent().length();
if (ocrText.length() >= (endFirstIndex - fatchRule.getEndContent().length())) {
fatchMap.put(fatchRule.getColumn(), ocrText.substring(0, endFirstIndex - fatchRule.getEndContent().length()));
@@ -233,6 +237,7 @@ public class OCRUtils {
}
}
}
}
}
}
@@ -129,12 +129,15 @@
<!--根据角色和状态过滤-->
<!--被申请人-->
<if test="idCard != null and idCard != ''">
or (t.identity_num=#{idCard} AND t.identity_type=2 and (t.case_status=4 or t.case_status=17))
or (t.identity_num=#{idCard} AND t.identity_type=2
<!-- and (t.case_status=4 or t.case_status=17) -->
)
</if>
<!--仲裁员-->
<if test="userId != null and userId != ''">
or ( t.identity_type=1 and
t.case_status in (7,13,17,18)
<!-- or ( t.identity_type=1 and
t.case_status in (7,13,17,18) -->
or (t.identity_type=1
and
instr (t.arbitrator_id,#{userId})>0)
</if>
@@ -147,14 +150,17 @@
<!-- </if>-->
<!--部门长-->
<if test="deptHeadStatus != null and deptHeadStatus.size() > 0">
or (t.identity_type=1 and t.case_status in
or (t.identity_type=1)
<!--and t.case_status in
<foreach item="caseStatus" collection="deptHeadStatus" open="(" separator="," close=")">
#{caseStatus}
</foreach>)
</foreach>)-->
</if>
<!--财务-->
<if test="financeStatus != null and financeStatus != ''">
or (t.identity_type=1 and t.case_status =#{financeStatus})
or (t.identity_type=1
<!-- and t.case_status =#{financeStatus}-->
)
</if>
@@ -165,7 +171,8 @@
<foreach item="deptId" collection="agentDeptIds" open="(" separator="," close=")">#{deptId}
</foreach>
AND t.identity_type=1
and t.case_status in (0,9))
<!-- and t.case_status in (0,9)-->
)
</if>
</where>
@@ -205,7 +212,8 @@
JOIN case_affiliate ca ON ca.case_appli_id =c.id AND ca.identity_type = 1
<where>
(c.case_status &lt;= 10 or c.case_status=31) AND ca.identity_type=1
<!--(c.case_status &lt;= 10 or c.case_status=31) AND-->
ca.identity_type=1
<if test="applicationOrganId != null and applicationOrganId != ''">
AND ca.application_organ_id = #{applicationOrganId}
@@ -295,7 +303,7 @@
WHERE
ca.identity_type=1
and c.case_status in (1,5,8,9,11,14,15,16,17,31)
<!-- and c.case_status in (1,5,8,9,11,14,15,16,17,31)-->
<!-- <if test="deptIds != null and deptIds.size() > 0">
and ca.application_organ_id in