This commit is contained in:
hejinbo
2023-09-27 15:33:53 +08:00
parent c60ad9f3fc
commit 2a147f119e
7 changed files with 346 additions and 106 deletions
@@ -6,6 +6,7 @@ import com.ruoyi.wisdomarbitrate.domain.CaseApplication;
public interface IAdjudicationService {
AjaxResult createDocument(CaseApplication caseApplication);
AjaxResult sendDocumentByEmail();
AjaxResult sendDocumentByEmail(Long id,String appEmail,String resEmail);
AjaxResult getLogisticsInfo(String trackingNum,Integer phoneLastFour);
}
@@ -3,6 +3,7 @@ package com.ruoyi.wisdomarbitrate.service.impl;
import com.deepoove.poi.config.Configure;
import com.ruoyi.common.constant.CaseApplicationConstants;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.EmailOutUtil;
import com.ruoyi.common.utils.WordUtil;
import com.ruoyi.wisdomarbitrate.domain.*;
import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper;
@@ -12,9 +13,14 @@ import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
import com.ruoyi.wisdomarbitrate.service.IAdjudicationService;
import org.apache.poi.xwpf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSendException;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
@@ -25,6 +31,8 @@ import java.util.*;
@Service
public class AdjudicationServiceImpl implements IAdjudicationService {
private final String apiUrl = "http://api.cainiaoapi.com/api/exp/v1/index";
@Autowired
private CaseApplicationMapper caseApplicationMapper;
@Autowired
@@ -33,13 +41,15 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
private ArbitrateRecordMapper arbitrateRecordMapper;
@Autowired
private CaseAttachMapper caseAttachMapper;
@Autowired
private EmailOutUtil emailOutUtil;
@Override
public AjaxResult createDocument(CaseApplication caseApplication) {
try {
Map<String, Object> datas = new HashMap<>();
Long id = caseApplication.getId();
if (id == null){
if (id == null) {
return null;
}
//获取案件详细信息
@@ -53,8 +63,8 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
CaseAffiliate caseAffiliate = new CaseAffiliate();
caseAffiliate.setCaseAppliId(id);
List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
if (caseAffiliates != null && caseAffiliates.size() > 0){
for (CaseAffiliate affiliate : caseAffiliates){
if (caseAffiliates != null && caseAffiliates.size() > 0) {
for (CaseAffiliate affiliate : caseAffiliates) {
//获取身份类型
int identityType = affiliate.getIdentityType();
if (identityType == 1) { //申请人
@@ -62,34 +72,34 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
datas.put("appIDNo", affiliate.getIdentityNum());
datas.put("appAddress", affiliate.getContactAddress());
datas.put("appAgentName", affiliate.getNameAgent());
datas.put("appAgentIDNo",affiliate.getIdentityNumAgent());
}else if (identityType == 2){ //被申请人
datas.put("appAgentIDNo", affiliate.getIdentityNumAgent());
} else if (identityType == 2) { //被申请人
datas.put("resName", affiliate.getName());
datas.put("resIDNo", affiliate.getIdentityNum());
datas.put("resAddress", affiliate.getContactAddress());
datas.put("resAgentName", affiliate.getNameAgent());
datas.put("resAgentIDNo",affiliate.getIdentityNumAgent());
datas.put("resAgentIDNo", affiliate.getIdentityNumAgent());
}
}
}
String arbitratorName = caseApplication1.getArbitratorName();
datas.put("caseName",caseApplication1.getCaseName());
datas.put("arbitratorName",arbitratorName);
datas.put("caseName", caseApplication1.getCaseName());
datas.put("arbitratorName", arbitratorName);
Date hearDate = caseApplication1.getHearDate();
if (hearDate != null) {
LocalDate localDate = hearDate.toInstant()
.atZone(ZoneId.systemDefault())
.toLocalDate();
datas.put("hearYear", localDate.getYear());
datas.put("hearMonths", localDate.getMonthValue());
datas.put("hearDay", localDate.getDayOfMonth());
}else {
datas.put("hearYear", null);
datas.put("hearMonths", null);
datas.put("hearDay", null);
datas.put("hearYear", localDate.getYear());
datas.put("hearMonths", localDate.getMonthValue());
datas.put("hearDay", localDate.getDayOfMonth());
} else {
datas.put("hearYear", null);
datas.put("hearMonths", null);
datas.put("hearDay", null);
}
datas.put("appArbitrationClaims", caseApplication1.getArbitratClaims());
if (arbitrateRecord1!=null){
datas.put("appArbitrationClaims", caseApplication1.getArbitratClaims());
if (arbitrateRecord1 != null) {
datas.put("evidenDetermi", arbitrateRecord1.getEvidenDetermi());
datas.put("factDetermi", arbitrateRecord1.getFactDetermi());
datas.put("caseSketch", arbitrateRecord1.getCaseSketch());
@@ -97,10 +107,10 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
datas.put("rulingFollows", arbitrateRecord1.getRulingFollows());
}
datas.put("legalProvisions", "仲裁法");
if (arbitratorName==null){
if (arbitratorName == null) {
datas.put("arbitratorName1", null);
datas.put("arbitratorName2", null);
}else if (arbitratorName.contains(",")){
} else if (arbitratorName.contains(",")) {
String[] nameArray = arbitratorName.split(",");
String firstName = nameArray[0];
String secondName = nameArray[1];
@@ -115,10 +125,10 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
datas.put("year", now.getYear());
datas.put("months", now.getMonthValue());
datas.put("day", now.getDayOfMonth());
String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx";
//String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx";
String saveFolderPath = "/data/arbitrate-document/formal/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
//String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
//String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx";
String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx";
//String saveFolderPath = "/data/arbitrate-document/formal/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
String resultFilePath = saveFolderPath + "/" + fileName;
// 创建日期目录
@@ -129,7 +139,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
Path sourcePath = new File(modalFilePath).toPath();
Path destinationPath = new File(resultFilePath).toPath();
Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
String docFilePath = WordUtil.getDocFilePath(datas,modalFilePath,resultFilePath);
String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
//修改案件状态
caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
caseApplicationMapper.submitCaseApplication(caseApplication1);
@@ -141,8 +151,8 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
.annexType(3)
.build();
int i = caseAttachMapper.save(caseAttach);
if (i>0){
if (arbitrateRecord1!=null){
if (i > 0) {
if (arbitrateRecord1 != null) {
Integer annexId = caseAttach.getAnnexId();
//将附件id保存到仲裁记录表里面
arbitrateRecord1.setAnnexId(annexId);
@@ -157,7 +167,81 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
}
@Override
public AjaxResult sendDocumentByEmail() {
public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail) {
CaseApplication caseApplication = new CaseApplication();
caseApplication.setId(id);
CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
if (caseApplication1 == null) {
return AjaxResult.error("未查询到相关案件");
}
//根据案件id查询裁决书
try {
List<File> fileList = new ArrayList<>();
List<CaseAttach> caseAttachList = caseAttachMapper.queryAnnexPathByCaseId(id);
if (caseAttachList != null && caseAttachList.size() > 0) {
for (CaseAttach caseAttach : caseAttachList) {
if (caseAttach.getAnnexType() == 3) {
String annexPath = caseAttach.getAnnexPath();
fileList.add(new File(annexPath));
}
}
}
//电子邮件送达
JavaMailSender javaMailSender = emailOutUtil.rebuildMailSender();
if (appEmail != null) {
emailOutUtil.sendMessageCarryFiles(appEmail, "案件裁决书", "您的裁决书已送达,详情请查阅附件", fileList
, "hjbjava@163.com", javaMailSender);
}
if (resEmail != null) {
emailOutUtil.sendMessageCarryFiles(resEmail, "案件裁决书", "您的裁决书已送达,详情请查阅附件", fileList
, "hjbjava@163.com", javaMailSender);
}
//修改案件状态
caseApplication1.setCaseStatus(CaseApplicationConstants.CASE_FILING);
caseApplicationMapper.submitCaseApplication(caseApplication1);
return AjaxResult.success("仲裁文书送达成功");
} catch (MailSendException e) {
return AjaxResult.error("发送失败,请检查文件路径");
}
}
@Override
public AjaxResult getLogisticsInfo(String trackingNum, Integer phoneLastFour) {
try {
//快递单号查询
String key = "70ba5c7b327f71fccd5924f70e3e7b7f";
String com = "auto";
// 构造查询字符串参数
String queryParameters = String.format("key=%s&com=%s&no=%s&phone=%d",
URLEncoder.encode(key, "UTF-8"),
URLEncoder.encode(com, "UTF-8"),
URLEncoder.encode(trackingNum, "UTF-8"),
phoneLastFour);
// 拼接到API URL中
String fullUrl = apiUrl + "?" + queryParameters;
URL url = new URL(fullUrl);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
connection.setRequestMethod("GET");
int responseCode = connection.getResponseCode();
if (responseCode == HttpURLConnection.HTTP_OK) {
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String line;
StringBuilder response = new StringBuilder();
while ((line = reader.readLine()) != null) {
response.append(line);
}
reader.close();
// 处理返回的响应数据
return AjaxResult.success(response);
} else {
// 请求失败
return AjaxResult.error("请求失败,错误码:" + responseCode);
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
}