案件压缩包导入开发 #241

Merged
hejinbo merged 3 commits from hjb into dev 2023-11-25 10:08:23 +00:00
9 changed files with 352 additions and 255 deletions
@@ -429,4 +429,17 @@ public class CaseApplicationController extends BaseController {
return success(caseApplicationService.reserveConferenceList(caseId));
}
/**
* 案件压缩包导入
* @param file
* @return
* @throws IOException
*/
@PostMapping("/uploadCaseZipFile")
public AjaxResult uploadCaseZipFile(@RequestParam("file") MultipartFile file) throws IOException {
return caseApplicationService.uploadCaseZipFile(file);
}
}
+14
View File
@@ -164,6 +164,20 @@
<version>1.9.1</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-local</artifactId>
<version>1.0.3</version>
</dependency>
<dependency>
<groupId>com.documents4j</groupId>
<artifactId>documents4j-transformer-msoffice-word</artifactId>
<version>1.0.3</version>
</dependency>
<!-- 发送邮件-->
<dependency>
<groupId>org.springframework.boot</groupId>
+2
View File
@@ -22,6 +22,7 @@
<groupId>com.ruoyi</groupId>
<artifactId>ruoyi-common</artifactId>
</dependency>
<dependency>
<groupId>com.ruoyi</groupId>
<artifactId>pay</artifactId>
@@ -32,6 +33,7 @@
<artifactId>tls-sig-api-v2</artifactId>
<version>1.2</version>
</dependency>
</dependencies>
</project>
@@ -112,4 +112,6 @@ public interface ICaseApplicationService {
AjaxResult deleteRoom( String roomId);
AjaxResult uploadCaseZipFile(MultipartFile file);
}
@@ -4,13 +4,18 @@ package com.ruoyi.wisdomarbitrate.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.IdcardUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.core.util.ZipUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.documents4j.api.DocumentType;
import com.documents4j.api.IConverter;
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;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.*;
@@ -19,6 +24,7 @@ import com.ruoyi.common.enums.UpdateSubmitStatus;
import com.ruoyi.common.exception.EsignDemoException;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.*;
import com.ruoyi.common.utils.file.FileUploadUtils;
import com.ruoyi.common.utils.file.SaaSAPIFileUtils;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.utils.thread.ThreadPoolUtil;
@@ -44,11 +50,14 @@ 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.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;
@@ -61,6 +70,8 @@ import java.time.ZoneId;
import java.util.*;
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.success;
import static com.ruoyi.common.utils.PageUtils.startPage;
@@ -159,7 +170,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
for (SysRole role : roles) {
if(StrUtil.isEmpty(role.getRoleName())){
if (StrUtil.isEmpty(role.getRoleName())) {
continue;
}
// 超级管理员和仲裁委(部门长)案件,可查看所有案件 √
@@ -190,7 +201,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseApplication.setDeptIds(deptIds);
}
if ("申请人".equals(role.getRoleName())) {
// caseApplication.setIsOtherRole(1);
// caseApplication.setIsOtherRole(1);
// 查询有关的用户部门
caseApplication.setApplicationOrganId(String.valueOf(sysUser.getDeptId()));
}
@@ -202,7 +213,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
if ("代理人".equals(role.getRoleName())) {
caseApplication.setIsOtherRole(1);
// 查询角色有关的用户部门
// List<Long> agentDeptIds = sysDeptMapper.selectUserDeptListByRoleId(role.getRoleId());
// List<Long> agentDeptIds = sysDeptMapper.selectUserDeptListByRoleId(role.getRoleId());
List<Long> agentDeptIds = new ArrayList<>();
agentDeptIds.add(sysUser.getDeptId());
caseApplication.setAgentDeptIds(agentDeptIds);
@@ -235,7 +246,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
CaseApplication caseApplication = new CaseApplication();
List<Integer> caseStatusList = new ArrayList<>();
for (SysRole role : roles) {
if(StrUtil.isEmpty(role.getRoleName())){
if (StrUtil.isEmpty(role.getRoleName())) {
continue;
}
// 超级管理员和仲裁委(部门长)案件,可查看所有案件 √
@@ -266,7 +277,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseApplication.setDeptIds(deptIds);
}
if ("申请人".equals(role.getRoleName())) {
// caseApplication.setIsOtherRole(1);
// caseApplication.setIsOtherRole(1);
// 查询角色有关的用户部门
caseApplication.setApplicationOrganId(String.valueOf(sysUser.getDeptId()));
}
@@ -288,7 +299,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
// 根据条件查询申请人,被申请人,仲裁员,法律顾问案件
ToDoCount toDoCount = caseApplicationMapper.selectTodoCountByRole(caseApplication);
if(toDoCount==null){
if (toDoCount == null) {
return new ToDoCount();
}
return toDoCount;
@@ -362,7 +373,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
return AjaxResult.error("请选择要上传的文件");
}
String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
// String targetPath = "F:\\testZip\\uploadPath\\upload\\upload1\\unzipFile";
// String targetPath = "D:\\home\\unzip\\";
File zipFile = null;
InputStream ins = null;
try {
@@ -542,7 +553,6 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
}
}
return success();
}
@@ -880,6 +890,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
/**
* 新增案件
*
* @param caseApplication
* @return
*/
@@ -900,7 +911,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseApplication.setVersion(1);
// 新增立案信息
int rows = caseApplicationMapper.insertCaseApplication(caseApplication);
if(rows==0){
if (rows == 0) {
return rows;
}
List<CaseAffiliate> caseAffiliates = caseApplication.getCaseAffiliates();
@@ -1024,12 +1035,12 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseApplication.setFeePayable(feePayable);
caseApplication.setUpdateBy(getUsername());
// 立案申请状态直接修改主表信息
if(caseApplication.getCaseStatus()!=null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
if (caseApplication.getCaseStatus() != null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
caseApplicationMapper.updataCaseApplication(caseApplication);
// 修改记录表状态为同意提交修改的内容
caseApplication.setUpdateSubmitStatus(0);
}else {
} else {
// 修改记录表状态为已提交修改的内容
caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.COMMITTED.getCode());
}
@@ -1078,7 +1089,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
// 立案申请状态直接修改主表信息
if(caseApplication.getCaseStatus()!=null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
if (caseApplication.getCaseStatus() != null && caseApplication.getCaseStatus().equals(CaseApplicationConstants.CASE_APPLICATION)) {
caseAffiliateMapper.updataCaseAffiliate(caseAffiliate);
}
@@ -1111,11 +1122,11 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
if (maxVersion == null) {
maxVersion = 1;
}
caseApplication.setVersion(maxVersion+1);
caseApplication.setVersion(maxVersion + 1);
// 将修改提交状态改为未提交
// caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.UNCOMMITTED.getCode());
// caseApplication.setUpdateSubmitStatus(UpdateSubmitStatus.UNCOMMITTED.getCode());
// 修改案件表的版本号
// caseApplicationMapper.updateVersionById(caseApplication.getId(),caseApplication.getVersion());
// caseApplicationMapper.updateVersionById(caseApplication.getId(),caseApplication.getVersion());
// 异步新增案件日志
ThreadPoolUtil.execute(() -> {
@@ -1353,7 +1364,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
StringBuilder failureMsg = new StringBuilder();
StringBuilder successMsg = new StringBuilder();
int successNum = 0;
List<CaseAffiliate> caseAffiliateLogList=new ArrayList<>();
List<CaseAffiliate> caseAffiliateLogList = new ArrayList<>();
if (caseApplicationList != null && caseApplicationList.size() > 0) {
// 1,查询所有的组织机构,组装成map
List<SysDept> deptList = sysDeptMapper.selectDeptList(new SysDept());
@@ -1420,7 +1431,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseApplicationItera.setCreateBy(getUsername());
caseApplicationItera.setImportFlag(1);
int rows = caseApplicationMapper.insertCaseApplication(caseApplicationItera);
if(rows==0){
if (rows == 0) {
continue;
}
// 新增日志
@@ -1440,7 +1451,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
caseApplicationItera.setVersion(1);
int insertRow = caseApplicationLogMapper.insert(caseApplicationItera);
if(insertRow>0){
if (insertRow > 0) {
caseAffiliates.forEach(caseAffiliate -> caseAffiliate.setCaseAppliLogId(caseApplicationItera.getId()));
caseAffiliateLogList.addAll(caseAffiliates);
}
@@ -1454,7 +1465,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
// 异步新增案件日志
ThreadPoolUtil.execute(() -> {
if ( CollectionUtil.isNotEmpty(caseAffiliateLogList)) {
if (CollectionUtil.isNotEmpty(caseAffiliateLogList)) {
// 插入案件日志人员相关表
caseAffiliateLogMapper.batchCaseAffiliate(caseAffiliateLogList);
}
@@ -1503,7 +1514,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
if (StrUtil.isEmpty(caseApplication.getDebtorIdentityNumAgent())) {
failureMsg.append("【被申请人主体信息-代理人身份证号】字段不能为空;");
} else if (! IdcardUtil.isValidCard((caseApplication.getDebtorIdentityNumAgent()))) {
} else if (!IdcardUtil.isValidCard((caseApplication.getDebtorIdentityNumAgent()))) {
failureMsg.append("【被申请人主体信息-代理人身份证号】不合法;");
}
String debtorContactTelphoneAgent = caseApplication.getDebtorContactTelphoneAgent();
@@ -1533,7 +1544,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
if (StrUtil.isEmpty(caseApplication.getDebtorIdentityNum())) {
failureMsg.append("【被申请人主体信息-身份证号】字段不能为空;");
} else if (! IdcardUtil.isValidCard(caseApplication.getDebtorIdentityNum())) {
} else if (!IdcardUtil.isValidCard(caseApplication.getDebtorIdentityNum())) {
failureMsg.append("【被申请人主体信息-身份证号】不合法;");
}
String debtorContactTelphone = caseApplication.getDebtorContactTelphone();
@@ -1570,7 +1581,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
if (StrUtil.isEmpty(caseApplication.getDebtorEmail())) {
failureMsg.append("【被申请人主体信息-邮箱】字段不能为空;");
} else if(!EMAIL_PATTERN.matcher(caseApplication.getDebtorEmail()).matches()){
} else if (!EMAIL_PATTERN.matcher(caseApplication.getDebtorEmail()).matches()) {
failureMsg.append("【被申请人主体信息-邮箱】字段不合法;");
}
@@ -1676,7 +1687,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
}
if (StrUtil.isEmpty(caseApplication.getEmail())) {
failureMsg.append("【申请人主体信息-邮箱】字段不能为空;");
} else if(!EMAIL_PATTERN.matcher(caseApplication.getEmail()).matches()){
} else if (!EMAIL_PATTERN.matcher(caseApplication.getEmail()).matches()) {
failureMsg.append("【申请人主体信息-邮箱】字段不合法;");
}
@@ -1974,7 +1985,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
EsignHttpResponse response3 = SignAward.createByFile(sealSignRecord, sealIdList);
JSONObject jsonObject3 = JSONObject.parseObject(response3.getBody());
if (jsonObject3 != null){
if (jsonObject3 != null) {
if (jsonObject3.getIntValue("code") == 0) {
//获取签署流程ID
JSONObject data1 = jsonObject3.getJSONObject("data");
@@ -1987,7 +1998,7 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
} else {
throw new ServiceException("发起签署流程失败,请检查参数是否有误");
}
}else {
} else {
return AjaxResult.error();
}
@@ -2738,14 +2749,14 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
*/
@Transactional
@Override
public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) {
public AjaxResult reservedConference(ReservedConferenceVO reservedConferenceVO) {
// 新增预约会议表
ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(),SecurityUtils.getUserId(), reservedConferenceVO.getRoomId(),
reservedConferenceVO.getScheduleStartTime(), reservedConferenceVO.getScheduleEndTime());
ReservedConference conference = new ReservedConference(reservedConferenceVO.getCaseId(), SecurityUtils.getUserId(), reservedConferenceVO.getRoomId(),
reservedConferenceVO.getScheduleStartTime(), reservedConferenceVO.getScheduleEndTime());
reservedConferenceMapper.insert(conference);
return success("预约会议成功");
reservedConferenceMapper.insert(conference);
return success("预约会议成功");
}
@@ -2774,10 +2785,10 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
// 查询最大房间号
Long maxRoomId = caseApplicationMapper.selectMaxRoomId();
if (null == maxRoomId || maxRoomId >4294967294L) {
if (null == maxRoomId || maxRoomId > 4294967294L) {
return 1L;
} else {
return maxRoomId+1;
return maxRoomId + 1;
}
}
@@ -2833,9 +2844,144 @@ public class CaseApplicationServiceImpl implements ICaseApplicationService {
@Override
public AjaxResult deleteRoom(String roomId) {
return success( reservedConferenceMapper.deleteByRoomId(roomId));
return success(reservedConferenceMapper.deleteByRoomId(roomId));
}
@Override
public AjaxResult uploadCaseZipFile(MultipartFile file) {
if (file.isEmpty()) {
return AjaxResult.error("请选择要上传的文件");
}
//String targetPath = "/home/ruoyi/uploadPath/upload/unzipFile";
UUID uuid = UUID.randomUUID();
String targetPath = "D:\\home\\unzip\\"+uuid+"\\";
File zipFile = null;
InputStream ins = null;
try {
ins = file.getInputStream();
String savePath = "D:\\develop\\java\\";
String saveName = uuid+file.getOriginalFilename();
zipFile = new File(savePath+saveName);
inputChangeToFile(ins, zipFile);
} catch (IOException e) {
e.printStackTrace();
}
//解压缩上传的压缩包
boolean unzipSuccess = UnZipFileUtils.unZipFile(zipFile, targetPath);
if (unzipSuccess ) {
//去掉后缀名,拿到解压后的文件夹路径
String fileName = file.getOriginalFilename();
String nameWithoutExtension = fileName.substring(0, fileName.lastIndexOf("."));
File directory = new File(targetPath);
List<String> andConvertPDF = findAndConvertPDF(directory);
if (andConvertPDF != null && andConvertPDF.size() > 0){
// 返回找到的PDF文件路径
return AjaxResult.success(andConvertPDF);
}else {
// 没有找到符合条件的文件
return AjaxResult.error("未找到符合条件的文件");
}
}else {
// 解压失败
return AjaxResult.error("解压失败");
}
}
public static List<String> findAndConvertPDF(File directory) {
List<String> pdfPaths = new ArrayList<>();
if (directory.isFile()) {
String path = "";
// 如果传入的参数是一个文件
if (directory.getName().contains("仲裁申请书")) {
if (isPDF(directory)) {
// 如果文件名包含"仲裁申请书"且是PDF格式,直接返回路径
path = directory.getAbsolutePath();
} else {
// 如果不是PDF格式,进行转换成PDF并返回路径
String pdfPath = convertToPDF(directory);
if (pdfPath != null) {
path = pdfPath;
}
}
if (path!= null) {
pdfPaths.add(path);
}
}
} else if (directory.isDirectory()) {
searchAndConvertPDF(directory, pdfPaths);
}else {
return null;
}
return pdfPaths;
}
public static boolean isPDF(File file) {
String extension = getFileExtension(file);
return extension.equalsIgnoreCase("pdf");
}
public static String getFileExtension(File file) {
String name = file.getName();
int lastIndexOfDot = name.lastIndexOf(".");
if (lastIndexOfDot != -1 && lastIndexOfDot < name.length() - 1) {
return name.substring(lastIndexOfDot + 1);
} else {
return "";
}
}
public static void searchAndConvertPDF(File directory, List<String> pdfPaths) {
File[] files = directory.listFiles();
if (files != null) {
for (File file : files) {
if (file.isFile()) {
// 如果是文件且文件名包含"仲裁申请书"
if (file.getName().contains("仲裁申请书")) {
if (isPDF(file)) {
// 如果是PDF格式,直接添加到列表中
pdfPaths.add(file.getAbsolutePath());
} else {
// 如果不是PDF格式,进行转换成PDF并添加转换后的路径到列表中
String pdfPath = convertToPDF(file);
if (pdfPath != null) {
pdfPaths.add(pdfPath);
}
}
}
} else if (file.isDirectory()) {
// 如果是目录,递归查找
searchAndConvertPDF(file, pdfPaths);
}
}
}
}
private static String convertToPDF(File file) {
String wordFilePath = file.getAbsolutePath();
String pdfSaveDirectory ="D:\\home\\unzip\\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);
File outputFile = new File(pdfFilePath);
try {
InputStream docxInputStream = new FileInputStream(inputWord);
OutputStream outputStream = new FileOutputStream(outputFile);
IConverter converter = LocalConverter.builder().build();
converter.convert(docxInputStream).as(DocumentType.DOCX).to(outputStream).as(DocumentType.PDF).execute();
docxInputStream.close();
outputStream.close();
System.out.println("success");
File file1= new File(pdfFilePath);
System.out.println("这是转化后的PDF文件路径"+file1);
} catch (Exception e) {
e.printStackTrace();
}
return pdfFilePath;
}
}
@@ -223,7 +223,6 @@ public class CasePaymentServiceImpl implements ICasePaymentService {
casePaymentRecordMapper.saveRecord(paymentRecord);
// 新增日志
CaseLogUtils.insertCaseLog(caseApplication.getId(), CaseApplicationConstants.PENDING_PAYMENT_CONFIRM, "");
}
}
@@ -182,192 +182,93 @@ public class FixSelectFlowDetailUtils {
public void fixExecuteSelectDeptIndentifyUtils() throws Exception {
Gson gson = new Gson();
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setIdentifyStatus(0);
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify);
if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) {
for (int i = 0; i < deptIdentifysnew.size(); i++) {
DeptIdentify deptIdentify1 = deptIdentifysnew.get(i);
String authFlowId = deptIdentify1.getAuthFlowId();
if (authFlowId != null) {
EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentify1);
JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
int code = identifyInfoJsonObject.get("code").getAsInt();
if (code == 0) {
JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
if (realnameStatus == 1) {
String orgId = identifyInfoData.get("orgId").getAsString();
//查询企业内部印章
EsignHttpResponse response = SignAward.deptIdentifySealList(orgId);
JsonObject jsonObject = gson.fromJson(response.getBody(), JsonObject.class);
int code1 = jsonObject.get("code").getAsInt();
if (code1 == 0) {
JsonObject data = jsonObject.getAsJsonObject("data");
JsonArray seals = data.get("seals").getAsJsonArray();
if (seals.size() > 0) {
for (int j = 0; j < seals.size(); j++) {
//保存印章信息到数据库
JsonObject asJsonObject = seals.get(j).getAsJsonObject();
SealManage sealManage = new SealManage();
String sealName = asJsonObject.get("sealName").toString();
String sealId = asJsonObject.get("sealId").toString();
String url = asJsonObject.get("sealImageDownloadUrl").toString();
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
String day = String.format("%02d", now.getDayOfMonth());
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
String fileName = UUID.randomUUID().toString().replace("-", "") + ".jpg";
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
String savePath = "/home/ruoyi/uploadPath/upload/";
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
String fileDownloadUrlnew = url.substring(1, url.length() - 1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
if (downLoadFile) {
CaseAttach caseAttach = new CaseAttach();
caseAttach.setAnnexType(10); //10代表印章图片
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
int i1 = caseAttachMapper.save(caseAttach);
if (i1 > 0) {
//将印章信息保存到公章管理表里
String sealName1 = sealName.substring(1, sealName.length() - 1);
String sealId1 = sealId.substring(1, sealId.length() - 1);
Integer annexId1 = caseAttach.getAnnexId();
sealManage.setAnnexId(annexId1);
sealManage.setSealId(sealId1);
sealManage.setSealName(sealName1);
sealManage.setIdentifyId(deptIdentify1.getId());
sealManage.setSealStatus(1);
sealManage.setIsUse(1);
sealManageMapper.insertSealManage(sealManage);
Integer identifyStatus = deptIdentify1.getIdentifyStatus();
if (identifyStatus!=1){
String authFlowId = deptIdentify1.getAuthFlowId();
if (authFlowId != null) {
EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentify1);
JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
int code = identifyInfoJsonObject.get("code").getAsInt();
if (code == 0) {
JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
if (realnameStatus == 1) {
String orgId = identifyInfoData.get("orgId").getAsString();
//查询企业内部印章
EsignHttpResponse response = SignAward.deptIdentifySealList(orgId);
JsonObject jsonObject = gson.fromJson(response.getBody(), JsonObject.class);
int code1 = jsonObject.get("code").getAsInt();
if (code1 == 0) {
JsonObject data = jsonObject.getAsJsonObject("data");
JsonArray seals = data.get("seals").getAsJsonArray();
if (seals.size() > 0) {
for (int j = 0; j < seals.size(); j++) {
//保存印章信息到数据库
JsonObject asJsonObject = seals.get(j).getAsJsonObject();
SealManage sealManage = new SealManage();
String sealName = asJsonObject.get("sealName").toString();
String sealId = asJsonObject.get("sealId").toString();
String url = asJsonObject.get("sealImageDownloadUrl").toString();
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
String day = String.format("%02d", now.getDayOfMonth());
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
String fileName = UUID.randomUUID().toString().replace("-", "") + ".jpg";
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
String savePath = "/home/ruoyi/uploadPath/upload/";
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
String fileDownloadUrlnew = url.substring(1, url.length() - 1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
if (downLoadFile) {
CaseAttach caseAttach = new CaseAttach();
caseAttach.setAnnexType(10); //10代表印章图片
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
int i1 = caseAttachMapper.save(caseAttach);
if (i1 > 0) {
//将印章信息保存到公章管理表里
String sealName1 = sealName.substring(1, sealName.length() - 1);
String sealId1 = sealId.substring(1, sealId.length() - 1);
Integer annexId1 = caseAttach.getAnnexId();
sealManage.setAnnexId(annexId1);
sealManage.setSealId(sealId1);
sealManage.setSealName(sealName1);
sealManage.setIdentifyId(deptIdentify1.getId());
sealManage.setSealStatus(1);
sealManage.setIsUse(1);
sealManageMapper.insertSealManage(sealManage);
}
}
}
}
}
}
//将orgId保存到数据库里
deptIdentify1.setOrgId(orgId);
deptIdentify1.setIdentifyStatus(1);
deptIdentify1.setIsUse(0); //默认机构为未启用
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify1);
}
//将orgId保存到数据库里
deptIdentify1.setOrgId(orgId);
deptIdentify1.setIdentifyStatus(1);
deptIdentify1.setIsUse(0); //默认机构为未启用
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify1);
}else {
deptIdentify1.setIdentifyStatus(2);
deptIdentifyMapper.updateDeptIdentify(deptIdentify1);
}
}else {
deptIdentify1.setIdentifyStatus(2);
deptIdentifyMapper.updateDeptIdentify(deptIdentify1);
}
}
}
}
}
/**
* 定时查询企业认证状态
*
* @throws Exception
*/
@Scheduled(cron = "*/30 * * * * *")
@Transactional
public void fixExecuteSelectDeptIndentify() throws Exception {
Gson gson = new Gson();
DeptIdentify deptIdentify = new DeptIdentify();
deptIdentify.setIdentifyStatus(2);
List<DeptIdentify> deptIdentifysnew = deptIdentifyMapper.selectDeptIdentify(deptIdentify);
if (deptIdentifysnew != null && deptIdentifysnew.size() > 0) {
for (int i = 0; i < deptIdentifysnew.size(); i++) {
DeptIdentify deptIdentify1 = deptIdentifysnew.get(i);
String authFlowId = deptIdentify1.getAuthFlowId();
if (authFlowId != null) {
EsignHttpResponse identifyInfo = SignAward.getDeptIdentifyInfo(deptIdentify1);
JsonObject identifyInfoJsonObject = gson.fromJson(identifyInfo.getBody(), JsonObject.class);
int code = identifyInfoJsonObject.get("code").getAsInt();
if (code == 0) {
JsonObject identifyInfoData = identifyInfoJsonObject.getAsJsonObject("data");
int realnameStatus = identifyInfoData.get("realnameStatus").getAsInt();
if (realnameStatus == 1) {
String orgId = identifyInfoData.get("orgId").getAsString();
//查询企业内部印章
EsignHttpResponse response = SignAward.deptIdentifySealList(orgId);
JsonObject jsonObject = gson.fromJson(response.getBody(), JsonObject.class);
int code1 = jsonObject.get("code").getAsInt();
if (code1 == 0) {
JsonObject data = jsonObject.getAsJsonObject("data");
JsonArray seals = data.get("seals").getAsJsonArray();
if (seals.size() > 0) {
for (int j = 0; j < seals.size(); j++) {
//保存印章信息到数据库
JsonObject asJsonObject = seals.get(j).getAsJsonObject();
SealManage sealManage = new SealManage();
String sealName = asJsonObject.get("sealName").toString();
String sealId = asJsonObject.get("sealId").toString();
String url = asJsonObject.get("sealImageDownloadUrl").toString();
LocalDate now = LocalDate.now();
String year = Integer.toString(now.getYear());
String month = String.format("%02d", now.getMonthValue());
String day = String.format("%02d", now.getDayOfMonth());
String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
String fileName = UUID.randomUUID().toString().replace("-", "") + ".jpg";
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
String savePath = "/home/ruoyi/uploadPath/upload/";
// 创建日期目录
File saveFolder = new File(saveFolderPath);
if (!saveFolder.exists()) {
saveFolder.mkdirs();
}
String resultFilePath = saveFolderPath + "/" + fileName;
File resultFilePathFile = new File(resultFilePath);
if (!resultFilePathFile.exists()) {
resultFilePathFile.createNewFile();
}
String fileDownloadUrlnew = url.substring(1, url.length() - 1);
boolean downLoadFile = FileTransformation.downLoadFileByUrl(fileDownloadUrlnew, resultFilePath);
if (downLoadFile) {
CaseAttach caseAttach = new CaseAttach();
caseAttach.setAnnexType(10); //10代表印章图片
caseAttach.setAnnexPath(savePath);
caseAttach.setAnnexName(saveName);
int i1 = caseAttachMapper.save(caseAttach);
if (i1 > 0) {
//将印章信息保存到公章管理表里
String sealName1 = sealName.substring(1, sealName.length() - 1);
String sealId1 = sealId.substring(1, sealId.length() - 1);
Integer annexId1 = caseAttach.getAnnexId();
sealManage.setAnnexId(annexId1);
sealManage.setSealId(sealId1);
sealManage.setSealName(sealName1);
sealManage.setIdentifyId(deptIdentify1.getId());
sealManage.setSealStatus(1);
sealManage.setIsUse(1);
sealManageMapper.insertSealManage(sealManage);
}
}
}
}
}
//将orgId保存到数据库里
deptIdentify1.setOrgId(orgId);
deptIdentify1.setIdentifyStatus(1);
deptIdentify1.setIsUse(0); //默认机构为未启用
int row = deptIdentifyMapper.updateDeptIdentify(deptIdentify1);
}
}else {
deptIdentify1.setIdentifyStatus(2);
deptIdentifyMapper.updateDeptIdentify(deptIdentify1);
}
}
}
}
}
@@ -0,0 +1,52 @@
package com.ruoyi.wisdomarbitrate.utils;
import com.documents4j.api.DocumentType;
import com.documents4j.api.IConverter;
import com.documents4j.job.LocalConverter;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.exception.TencentCloudSDKException;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.ocr.v20181119.OcrClient;
import com.tencentcloudapi.ocr.v20181119.models.GeneralAccurateOCRRequest;
import com.tencentcloudapi.ocr.v20181119.models.GeneralAccurateOCRResponse;
import java.io.*;
public class Tset {
public static void main(String[] args) {
//API的SecretId
final String SECRET_ID = "AKIDeEf2A8uX1HSainvvnXAc3X9ZlhtyvkMp";
//API的SecretKey
final String SECRET_KEY = "QjphKo8zkHZigT8j9PVtFPJyfIvO3d6V";
String pdfFilePath = "D:\\data\\1. 仲裁申请书-陈博.pdf";
try{
// 实例化一个认证对象,入参需要传入腾讯云账户 SecretId 和 SecretKey,此处还需注意密钥对的保密
// 代码泄露可能会导致 SecretId 和 SecretKey 泄露,并威胁账号下所有资源的安全性。以下代码示例仅供参考,建议采用更安全的方式来使用密钥,请参见:https://cloud.tencent.com/document/product/1278/85305
// 密钥可前往官网控制台 https://console.cloud.tencent.com/cam/capi 进行获取
Credential cred = new Credential(SECRET_ID, SECRET_KEY);
// 实例化一个http选项,可选的,没有特殊需求可以跳过
HttpProfile httpProfile = new HttpProfile();
httpProfile.setEndpoint("ocr.tencentcloudapi.com");
// 实例化一个client选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
clientProfile.setHttpProfile(httpProfile);
// 实例化要请求产品的client对象,clientProfile是可选的
OcrClient client = new OcrClient(cred, "ap-beijing", clientProfile);
// 实例化一个请求对象,每个接口都会对应一个request对象
GeneralAccurateOCRRequest req = new GeneralAccurateOCRRequest();
req.setImageUrl(pdfFilePath);
req.setIsPdf(true);
req.setPdfPageNumber(1L);
// 返回的resp是一个GeneralAccurateOCRResponse的实例,与请求对象对应
GeneralAccurateOCRResponse resp = client.GeneralAccurateOCR(req);
// 输出json格式的字符串回包
System.out.println(GeneralAccurateOCRResponse.toJsonString(resp));
} catch (TencentCloudSDKException e) {
System.out.println(e.toString());
}
}
}
@@ -17,43 +17,14 @@ import java.util.zip.ZipFile;
public class UnZipFileUtils {
public static void main(String[] args) {
// 压缩包路径
// String zipPath = "F:\\testZip\\zipFile\\上传申请书证据材料.zip";
// 解压后存放路径
// String targetPath = "F:\\testZip\\unzipFile";
// unZipFile(new File(zipPath),targetPath);
// String zipPath = "F:\\testZip\\unzipFile\\上传申请书证据材料";
// File dirUnzipPath = new File(zipPath);
// List<File> allFiles = new ArrayList<>();
// getFiles(dirUnzipPath,allFiles);
// if(allFiles!=null&&allFiles.size()>0){
// for (File fileIter : allFiles) {
// System.out.println(fileIter.getName());
// System.out.println(fileIter.getAbsolutePath());
// }
// }
String key = "\\";
String str = "F:\\testZip\\上传申请书证据材料\\证据材料\\仲裁裁决书模板.docx";
List<Integer> allindex = new ArrayList<>();
int a = str.indexOf(key);//*第一个出现的索引位置
allindex.add(a);
while (a != -1) {
System.out.print(a + "\t");
a = str.indexOf(key, a + 1);//*从这个索引往后开始第一个出现的位置
allindex.add(a);
}
String substr = str.substring(allindex.get(1)+1,allindex.get(2));
System.out.println("substr---"+substr);
File file = new File("D:\\home\\ruoyi\\仲裁委项目-测试单.zip");
String targetPath = "D:\\home\\unzip\\";
unZipFile(file,targetPath);
}
public static boolean unZipFile(File aboriginalFile, String targetPath) {
if (!aboriginalFile.exists()) {
log.error("此文件不存在:",aboriginalFile.getPath());
log.error("此文件不存在:", aboriginalFile.getPath());
return false;
}
try {
@@ -65,18 +36,18 @@ public class UnZipFileUtils {
String directPath = targetPath + File.separator + entryZip.getName();
File directFile = new File(directPath);
boolean makeDirs = directFile.mkdirs();
System.out.println("创建文件夹是否成功:" +makeDirs);
System.out.println("创建文件夹是否成功:" + makeDirs);
} else {
//若是文件,就创建文件
File sourceFile = new File(targetPath + File.separator + entryZip.getName());
if(!sourceFile.getParentFile().exists()){
if (!sourceFile.getParentFile().exists()) {
boolean mDirect = sourceFile.getParentFile().mkdirs();
System.out.println("创建压缩文件时,创建父文件夹是否成功:" +mDirect);
System.out.println("创建压缩文件时,创建父文件夹是否成功:" + mDirect);
}
boolean newUnZipFile = sourceFile.createNewFile();
if (newUnZipFile){
if (newUnZipFile) {
// 将压缩文件内容写入到这个文件中
try{
try {
InputStream is = srcZipFile.getInputStream(entryZip);
FileOutputStream fos = new FileOutputStream(sourceFile);
int len;
@@ -84,8 +55,8 @@ public class UnZipFileUtils {
while ((len = is.read(buf)) != -1) {
fos.write(buf, 0, len);
}
} catch (Exception e){
log.error("解压失败",e);
} catch (Exception e) {
log.error("解压失败", e);
}
}
}
@@ -93,7 +64,7 @@ public class UnZipFileUtils {
return true;
} catch (IOException e) {
log.error("解压失败",e);
log.error("解压失败", e);
return false;
}
@@ -106,11 +77,11 @@ public class UnZipFileUtils {
return;
}
File[] fileArray = fileSource.listFiles();
if(fileArray!=null&&fileArray.length>0){
if (fileArray != null && fileArray.length > 0) {
for (File fileIter : fileArray) {
if (fileIter.isDirectory()) {
getFiles(fileIter,allFiles);
}else {
getFiles(fileIter, allFiles);
} else {
allFiles.add(fileIter);
}
@@ -120,7 +91,4 @@ public class UnZipFileUtils {
}
}