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

This commit was merged in pull request #40.
This commit is contained in:
2023-10-09 17:37:40 +08:00
committed by Gitea
7 changed files with 211 additions and 47 deletions
@@ -26,4 +26,6 @@ public class RegisterController {
public AjaxResult createDocument(@Validated @RequestBody PersonRegisterVO personRegisterVO) { public AjaxResult createDocument(@Validated @RequestBody PersonRegisterVO personRegisterVO) {
return signRegisterService.registerPerson(personRegisterVO); return signRegisterService.registerPerson(personRegisterVO);
} }
// @PostMapping("/registerEnterprise")
// public AjaxResult
} }
@@ -41,12 +41,46 @@ public class AdjudicationController extends BaseController {
/** /**
* 根据快递单号查询物流信息 * 根据快递单号查询物流信息
* @param trackingNum 单号 * @param caseApplication
* @param phoneLastFour 收/寄件人手机号后四位,顺丰快递需填写本字段。
* @return * @return
*/ */
@GetMapping("/logistics") @GetMapping("/logistics")
public AjaxResult getLogisticsInfo(String trackingNum,Integer phoneLastFour){ public AjaxResult getLogisticsInfo(CaseApplication caseApplication){
return adjudicationService.getLogisticsInfo(trackingNum,phoneLastFour); return adjudicationService.getLogisticsInfo(caseApplication);
}
/**
* 签名(暂时只改案件状态)
* @param caseApplication
* @return
*/
@PostMapping("/signature")
public AjaxResult signature(@Validated @RequestBody CaseApplication caseApplication){
return adjudicationService.signature(caseApplication);
}
/**
* 归档(暂时只改案件状态)
* @param caseApplication
* @return
*/
@PostMapping("/caseFile")
public AjaxResult caseFile(@Validated @RequestBody CaseApplication caseApplication){
return adjudicationService.caseFile(caseApplication);
}
/**
* 送达(不包含发送电子邮件)
* @param id
* @param appEmail
* @param resEmail
* @param apptrackingNum
* @param restrackingNum
* @return
*/
@PostMapping("/service")
public AjaxResult service(Long id,String appEmail,String resEmail
,String apptrackingNum,String restrackingNum){
return adjudicationService.service(id,appEmail,resEmail,apptrackingNum,restrackingNum);
} }
} }
@@ -37,12 +37,13 @@ public class CaseApplicationConstants {
/**待仲裁文书签名*/ /**待仲裁文书签名*/
public static final int SIGN_ARBITRATION = 13; public static final int SIGN_ARBITRATION = 13;
/** 待仲裁文书用印 */ /** 待仲裁文书用印 */
public static final int ARBITRATED_SEAL = 14; public static final int ARBITRATED_SEAL = 14;
/** 待仲裁文书送达 */ /** 待仲裁文书送达 */
public static final int ARBITRATION_DELIVERY = 15; public static final int ARBITRATION_DELIVERY = 15;
/** 待案件归档*/ /** 待案件归档*/
public static final int CASE_FILING = 16; public static final int CASE_FILING = 16;
/** 已归档*/
public static final int CASE_ARCHIVED = 17;
@@ -0,0 +1,16 @@
package com.ruoyi.wisdomarbitrate.domain.vo;
import lombok.Data;
@Data
public class LogisticsInfoVO {
/**
* 案件关联人身份类型
*/
private Integer identityType;
/**
* 物流信息
*/
private String logisticsInfo;
}
@@ -8,5 +8,12 @@ public interface IAdjudicationService {
AjaxResult sendDocumentByEmail(Long id,String appEmail,String resEmail ,String apptrackingNum,String restrackingNum); AjaxResult sendDocumentByEmail(Long id,String appEmail,String resEmail ,String apptrackingNum,String restrackingNum);
AjaxResult getLogisticsInfo(String trackingNum,Integer phoneLastFour); AjaxResult getLogisticsInfo(CaseApplication caseApplication);
AjaxResult signature(CaseApplication caseApplication);
AjaxResult caseFile(CaseApplication caseApplication);
AjaxResult service(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum);
} }
@@ -1,16 +1,21 @@
package com.ruoyi.wisdomarbitrate.service.impl; package com.ruoyi.wisdomarbitrate.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.deepoove.poi.config.Configure; import com.deepoove.poi.config.Configure;
import com.ruoyi.common.constant.CaseApplicationConstants; import com.ruoyi.common.constant.CaseApplicationConstants;
import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.EmailOutUtil; import com.ruoyi.common.utils.EmailOutUtil;
import com.ruoyi.common.utils.WordUtil; import com.ruoyi.common.utils.WordUtil;
import com.ruoyi.wisdomarbitrate.domain.*; import com.ruoyi.wisdomarbitrate.domain.*;
import com.ruoyi.wisdomarbitrate.domain.vo.LogisticsInfoVO;
import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper; import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper;
import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper; import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper;
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper; import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper; import com.ruoyi.wisdomarbitrate.mapper.CaseAttachMapper;
import com.ruoyi.wisdomarbitrate.service.IAdjudicationService; import com.ruoyi.wisdomarbitrate.service.IAdjudicationService;
import com.ruoyi.wisdomarbitrate.service.ICaseApplicationService;
import lombok.extern.slf4j.Slf4j;
import org.apache.poi.xwpf.usermodel.*; import org.apache.poi.xwpf.usermodel.*;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.MailSendException; import org.springframework.mail.MailSendException;
@@ -31,6 +36,7 @@ import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
@Service @Service
@Slf4j
public class AdjudicationServiceImpl implements IAdjudicationService { public class AdjudicationServiceImpl implements IAdjudicationService {
private final String apiUrl = "http://api.cainiaoapi.com/api/exp/v1/index"; private final String apiUrl = "http://api.cainiaoapi.com/api/exp/v1/index";
@@ -44,6 +50,8 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
private CaseAttachMapper caseAttachMapper; private CaseAttachMapper caseAttachMapper;
@Autowired @Autowired
private EmailOutUtil emailOutUtil; private EmailOutUtil emailOutUtil;
@Autowired
private ICaseApplicationService caseApplicationService;
@Override @Override
public AjaxResult createDocument(CaseApplication caseApplication) { public AjaxResult createDocument(CaseApplication caseApplication) {
@@ -123,14 +131,18 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
datas.put("arbitratorName2", secondName); datas.put("arbitratorName2", secondName);
} }
LocalDate now = LocalDate.now(); LocalDate now = LocalDate.now();
datas.put("year", now.getYear()); String year = Integer.toString(now.getYear());
datas.put("months", now.getMonthValue()); String month = String.format("%02d", now.getMonthValue());
datas.put("day", now.getDayOfMonth()); String day = String.format("%02d", now.getDayOfMonth());
datas.put("year", year);
datas.put("months", month);
datas.put("day", day);
String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx"; String modalFilePath = "/data/arbitrate-document/template/仲裁裁决书模板.docx";
//String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx"; //String modalFilePath = "D:/develop/仲裁裁决书模板 (2).docx";
String saveFolderPath = "/data/arbitrate-document/formal/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth(); String saveFolderPath = "/home/ruoyi/uploadPath/upload/" + year + "/" + month + "/" + day;
//String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth(); //String saveFolderPath = "D:/data/" + now.getYear() + "/" + now.getMonthValue() + "/" + now.getDayOfMonth();
String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx"; String fileName = UUID.randomUUID().toString().replace("-", "") + ".docx";
String saveName = "/profile/upload/" + year + "/" + month + "/" + day + "/" + fileName;
String resultFilePath = saveFolderPath + "/" + fileName; String resultFilePath = saveFolderPath + "/" + fileName;
// 创建日期目录 // 创建日期目录
File saveFolder = new File(saveFolderPath); File saveFolder = new File(saveFolderPath);
@@ -141,14 +153,15 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
Path destinationPath = new File(resultFilePath).toPath(); Path destinationPath = new File(resultFilePath).toPath();
Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING); Files.copy(sourcePath, destinationPath, StandardCopyOption.REPLACE_EXISTING);
String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath); String docFilePath = WordUtil.getDocFilePath(datas, modalFilePath, resultFilePath);
String savePath = docFilePath.substring(0, docFilePath.indexOf("/upload/") + 8);
//修改案件状态 //修改案件状态
caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION); caseApplication1.setCaseStatus(CaseApplicationConstants.VERPRIF_ARBITRATION);
caseApplicationMapper.submitCaseApplication(caseApplication1); caseApplicationMapper.submitCaseApplication(caseApplication1);
//将裁决书保存到附件表里 //将裁决书保存到附件表里
CaseAttach caseAttach = CaseAttach.builder() CaseAttach caseAttach = CaseAttach.builder()
.caseAppliId(id) .caseAppliId(id)
.annexName(fileName) .annexName(saveName)
.annexPath(docFilePath) .annexPath(savePath)
.annexType(3) .annexType(3)
.build(); .build();
int i = caseAttachMapper.save(caseAttach); int i = caseAttachMapper.save(caseAttach);
@@ -169,7 +182,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
@Override @Override
@Transactional @Transactional
public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail ,String apptrackingNum,String restrackingNum) { public AjaxResult sendDocumentByEmail(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) {
CaseApplication caseApplication = new CaseApplication(); CaseApplication caseApplication = new CaseApplication();
caseApplication.setId(id); caseApplication.setId(id);
CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication); CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
@@ -180,16 +193,21 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
//根据案件id查询裁决书 //根据案件id查询裁决书
try { try {
List<File> fileList = new ArrayList<>(); List<File> fileList = new ArrayList<>();
List<CaseAttach> caseAttachList = caseAttachMapper.queryAnnexPathByCaseId(id); CaseApplication caseApplication2 = caseApplicationService.selectCaseApplication(caseApplication);
List<CaseAttach> caseAttachList = caseApplication2.getCaseAttachList();
if (caseAttachList != null && caseAttachList.size() > 0) { if (caseAttachList != null && caseAttachList.size() > 0) {
for (CaseAttach caseAttach : caseAttachList) { for (CaseAttach caseAttach : caseAttachList) {
if (caseAttach.getAnnexType() == 3) { if (caseAttach.getAnnexType() == 3) {
String annexPath = caseAttach.getAnnexPath(); String annexPath = caseAttach.getAnnexPath();
fileList.add(new File(annexPath)); //File file = new File("/home/ruoyi/" + annexPath);
String path = "/home/ruoyi/" + annexPath;
File file = new File(path);
System.out.println("文件是:" + file);
fileList.add(file);
} }
} }
} }
if (fileList.size()<1){ if (fileList.size() < 1) {
return AjaxResult.error("未查询到裁决书"); return AjaxResult.error("未查询到裁决书");
} }
File file = fileList.get(0); File file = fileList.get(0);
@@ -210,13 +228,13 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
CaseAffiliate caseAffiliate = new CaseAffiliate(); CaseAffiliate caseAffiliate = new CaseAffiliate();
caseAffiliate.setCaseAppliId(id); caseAffiliate.setCaseAppliId(id);
List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate); List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
if (caseAffiliates!=null&&caseAffiliates.size()>0){ if (caseAffiliates != null && caseAffiliates.size() > 0) {
for (CaseAffiliate affiliate : caseAffiliates) { for (CaseAffiliate affiliate : caseAffiliates) {
if (affiliate.getIdentityType() == 1){ //申请人 if (affiliate.getIdentityType() == 1) { //申请人
affiliate.setSendEmail(appEmail); affiliate.setSendEmail(appEmail);
affiliate.setTrackNum(apptrackingNum); affiliate.setTrackNum(apptrackingNum);
caseAffiliateMapper.updataCaseAffiliate(affiliate); caseAffiliateMapper.updataCaseAffiliate(affiliate);
}else { } else {
affiliate.setSendEmail(resEmail); affiliate.setSendEmail(resEmail);
affiliate.setTrackNum(restrackingNum); affiliate.setTrackNum(restrackingNum);
caseAffiliateMapper.updataCaseAffiliate(affiliate); caseAffiliateMapper.updataCaseAffiliate(affiliate);
@@ -230,40 +248,124 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
} }
@Override @Override
public AjaxResult getLogisticsInfo(String trackingNum, Integer phoneLastFour) { public AjaxResult getLogisticsInfo(CaseApplication caseApplication) {
try { try {
//快递单号查询 //快递单号查询
String key = "70ba5c7b327f71fccd5924f70e3e7b7f"; String key = "729437f92468910aee6c12dbfeaee3c1";
String com = "auto"; String com = "auto";
// 构造查询字符串参数 //根据案件id查询单号信息
String queryParameters = String.format("key=%s&com=%s&no=%s&phone=%d", CaseAffiliate caseAffiliate = new CaseAffiliate();
URLEncoder.encode(key, "UTF-8"), caseAffiliate.setCaseAppliId(caseApplication.getId());
URLEncoder.encode(com, "UTF-8"), List<LogisticsInfoVO> logisticsInfoVOList = new ArrayList<>();
URLEncoder.encode(trackingNum, "UTF-8"), List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
phoneLastFour); if (caseAffiliates != null && caseAffiliates.size() > 0) {
// 拼接到API URL中 for (CaseAffiliate affiliate : caseAffiliates) {
String fullUrl = apiUrl + "?" + queryParameters; LogisticsInfoVO logisticsInfoVO = new LogisticsInfoVO();
URL url = new URL(fullUrl); String trackNum = affiliate.getTrackNum();
HttpURLConnection connection = (HttpURLConnection) url.openConnection(); if (trackNum != null) {
connection.setRequestMethod("GET"); // 构造查询字符串参数
int responseCode = connection.getResponseCode(); String queryParameters = String.format("key=%s&com=%s&no=%s&phone=%d",
if (responseCode == HttpURLConnection.HTTP_OK) { URLEncoder.encode(key, "UTF-8"),
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream())); URLEncoder.encode(com, "UTF-8"),
String line; URLEncoder.encode(trackNum, "UTF-8"), null);
StringBuilder response = new StringBuilder(); // 拼接到API URL中
while ((line = reader.readLine()) != null) { String fullUrl = apiUrl + "?" + queryParameters;
response.append(line); 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();
// 处理返回的响应数据\
JSONObject jsonObject = JSON.parseObject(response.toString());
// 提取 "data" 字段并转换为字符串
String data = jsonObject.getString("data");
if (data != null) {
logisticsInfoVO.setIdentityType(affiliate.getIdentityType());
logisticsInfoVO.setLogisticsInfo(data);
logisticsInfoVOList.add(logisticsInfoVO);
}
} else {
// 请求失败
return AjaxResult.error("请求失败,错误码:" + responseCode);
}
}
} }
reader.close(); return AjaxResult.success(logisticsInfoVOList);
// 处理返回的响应数据
return AjaxResult.success(response);
} else {
// 请求失败
return AjaxResult.error("请求失败,错误码:" + responseCode);
} }
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
return null; return null;
} }
@Override
public AjaxResult signature(CaseApplication caseApplication) {
//更改案件状态(暂时)
caseApplication.setCaseStatus(CaseApplicationConstants.ARBITRATED_SEAL);
caseApplicationMapper.submitCaseApplication(caseApplication);
return AjaxResult.success("签名成功,案件状态已改为待仲裁文书用印");
}
@Override
public AjaxResult caseFile(CaseApplication caseApplication) {
//更改案件状态(暂时)
caseApplication.setCaseStatus(CaseApplicationConstants.CASE_ARCHIVED);
caseApplicationMapper.submitCaseApplication(caseApplication);
return AjaxResult.success("归档成功,案件状态已改为已归档");
}
@Override
public AjaxResult service(Long id, String appEmail, String resEmail, String apptrackingNum, String restrackingNum) {
CaseApplication caseApplication = new CaseApplication();
caseApplication.setId(id);
CaseApplication caseApplication1 = caseApplicationMapper.selectCaseApplication(caseApplication);
if (caseApplication1 == null) {
return AjaxResult.error("未查询到相关案件");
}
//修改案件状态
caseApplication1.setCaseStatus(CaseApplicationConstants.CASE_FILING);
caseApplicationMapper.submitCaseApplication(caseApplication1);
//保存邮箱信息和快递单号到关联人表
CaseAffiliate caseAffiliate = new CaseAffiliate();
caseAffiliate.setCaseAppliId(id);
List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
if (caseAffiliates != null && caseAffiliates.size() > 0) {
for (CaseAffiliate affiliate : caseAffiliates) {
if (affiliate.getIdentityType() == 1) { //申请人
affiliate.setSendEmail(appEmail);
affiliate.setTrackNum(apptrackingNum);
caseAffiliateMapper.updataCaseAffiliate(affiliate);
} else {
affiliate.setSendEmail(resEmail);
affiliate.setTrackNum(restrackingNum);
caseAffiliateMapper.updataCaseAffiliate(affiliate);
}
}
}
return AjaxResult.success("仲裁文书送达成功");
}
public static void main(String[] args) {
try {
List<File> fileList = new ArrayList<>();
fileList.add(new File("D:\\home\\ruoyi\\uploadPath\\upload\\2023\\10\\7\\b442880179844a848f1f8b08c29e3d0c.docx"));
File file = fileList.get(0);
//电子邮件送达
EmailOutUtil emailOutUtil = new EmailOutUtil();
JavaMailSender javaMailSender = emailOutUtil.rebuildMailSender();
if (javaMailSender != null) {
emailOutUtil.sendMessageCarryFile("1154956315@qq.com", "案件裁决书", "您的裁决书已送达,详情请查阅附件", file
, "hjbjava@163.com", javaMailSender);
}
} catch (MailSendException e) {
e.printStackTrace();
}
}
} }
@@ -18,12 +18,14 @@
<result property="identityNumAgent" column="identity_num_agent" /> <result property="identityNumAgent" column="identity_num_agent" />
<result property="contactTelphoneAgent" column="contact_telphone_agent" /> <result property="contactTelphoneAgent" column="contact_telphone_agent" />
<result property="contactAddressAgent" column="contact_address_agent" /> <result property="contactAddressAgent" column="contact_address_agent" />
<result property="trackNum" column="track_num" />
</resultMap> </resultMap>
<select id="selectCaseAffiliate" parameterType="CaseAffiliate" resultMap="CaseAffiliateResult"> <select id="selectCaseAffiliate" parameterType="CaseAffiliate" resultMap="CaseAffiliateResult">
select c.id ,c.case_appli_id ,c.identity_type ,c.name ,c.identity_num ,c.contact_telphone ,c.contact_address , select c.id ,c.case_appli_id ,c.identity_type ,c.name ,c.identity_num ,c.contact_telphone ,c.contact_address ,
c.work_address ,c.work_telphone ,c.name_agent, c.identity_num_agent ,c.contact_telphone_agent ,c.contact_address_agent c.work_address ,c.work_telphone ,c.name_agent, c.identity_num_agent ,c.contact_telphone_agent ,c.contact_address_agent,
c.track_num
from case_affiliate c from case_affiliate c
<where> <where>
<if test="caseAppliId != null "> <if test="caseAppliId != null ">