10.8开发

This commit is contained in:
hejinbo
2023-10-08 16:56:30 +08:00
parent 80e9814cd6
commit 848581e155
5 changed files with 81 additions and 40 deletions
@@ -41,12 +41,11 @@ public class AdjudicationController extends BaseController {
/**
* 根据快递单号查询物流信息
* @param trackingNum 单号
* @param phoneLastFour 收/寄件人手机号后四位,顺丰快递需填写本字段。
* @param caseApplication
* @return
*/
@GetMapping("/logistics")
public AjaxResult getLogisticsInfo(String trackingNum,Integer phoneLastFour){
return adjudicationService.getLogisticsInfo(trackingNum,phoneLastFour);
public AjaxResult getLogisticsInfo(@Validated @RequestBody CaseApplication caseApplication){
return adjudicationService.getLogisticsInfo(caseApplication);
}
}
@@ -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,5 @@ public interface IAdjudicationService {
AjaxResult sendDocumentByEmail(Long id,String appEmail,String resEmail ,String apptrackingNum,String restrackingNum);
AjaxResult getLogisticsInfo(String trackingNum,Integer phoneLastFour);
AjaxResult getLogisticsInfo(CaseApplication caseApplication);
}
@@ -1,11 +1,14 @@
package com.ruoyi.wisdomarbitrate.service.impl;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
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.domain.vo.LogisticsInfoVO;
import com.ruoyi.wisdomarbitrate.mapper.ArbitrateRecordMapper;
import com.ruoyi.wisdomarbitrate.mapper.CaseAffiliateMapper;
import com.ruoyi.wisdomarbitrate.mapper.CaseApplicationMapper;
@@ -47,6 +50,7 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
private EmailOutUtil emailOutUtil;
@Autowired
private ICaseApplicationService caseApplicationService;
@Override
public AjaxResult createDocument(CaseApplication caseApplication) {
try {
@@ -238,17 +242,26 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
}
@Override
public AjaxResult getLogisticsInfo(String trackingNum, Integer phoneLastFour) {
public AjaxResult getLogisticsInfo(CaseApplication caseApplication) {
try {
//快递单号查询
String key = "70ba5c7b327f71fccd5924f70e3e7b7f";
String com = "auto";
//根据案件id查询单号信息
CaseAffiliate caseAffiliate = new CaseAffiliate();
caseAffiliate.setCaseAppliId(caseApplication.getId());
List<LogisticsInfoVO> logisticsInfoVOList = new ArrayList<>();
List<CaseAffiliate> caseAffiliates = caseAffiliateMapper.selectCaseAffiliate(caseAffiliate);
if (caseAffiliates != null && caseAffiliates.size() > 0) {
for (CaseAffiliate affiliate : caseAffiliates) {
LogisticsInfoVO logisticsInfoVO = new LogisticsInfoVO();
String trackNum = affiliate.getTrackNum();
if (trackNum != null) {
// 构造查询字符串参数
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);
URLEncoder.encode(trackNum, "UTF-8"), null);
// 拼接到API URL中
String fullUrl = apiUrl + "?" + queryParameters;
URL url = new URL(fullUrl);
@@ -263,12 +276,23 @@ public class AdjudicationServiceImpl implements IAdjudicationService {
response.append(line);
}
reader.close();
// 处理返回的响应数据
return AjaxResult.success(response);
// 处理返回的响应数据\
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);
}
}
}
return AjaxResult.success(logisticsInfoVOList);
}
} catch (IOException e) {
e.printStackTrace();
}
@@ -18,12 +18,14 @@
<result property="identityNumAgent" column="identity_num_agent" />
<result property="contactTelphoneAgent" column="contact_telphone_agent" />
<result property="contactAddressAgent" column="contact_address_agent" />
<result property="trackNum" column="track_num" />
</resultMap>
<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 ,
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
<where>
<if test="caseAppliId != null ">