|
@@ -1,11 +1,18 @@
|
|
|
package com.dgtly.wxportal.service.impl;
|
|
|
|
|
|
+
|
|
|
+import cn.hutool.crypto.digest.DigestAlgorithm;
|
|
|
+import cn.hutool.crypto.digest.Digester;
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.dgtly.common.config.Global;
|
|
|
import com.dgtly.common.constant.Constants;
|
|
|
import com.dgtly.common.utils.DateUtils;
|
|
|
+import com.dgtly.common.utils.http.HttpUtils;
|
|
|
import com.dgtly.system.domain.*;
|
|
|
+
|
|
|
+import com.dgtly.system.service.ITransferLogService;
|
|
|
import com.dgtly.wxportal.config.ESignConfig;
|
|
|
import com.dgtly.wxportal.domain.OrderFile;
|
|
|
import com.dgtly.wxportal.service.IEsignSignService;
|
|
@@ -13,6 +20,7 @@ import com.dgtly.wxportal.service.IOrderFileService;
|
|
|
import com.dgtly.wxportal.utils.ESign.ESignHttpUtil;
|
|
|
import com.dgtly.wxportal.utils.ESign.ESignUrl;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -22,11 +30,11 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.client.RestClientException;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
+
|
|
|
import java.io.*;
|
|
|
import java.net.HttpURLConnection;
|
|
|
import java.net.URL;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @description:签署服务API
|
|
@@ -51,6 +59,18 @@ public class EsignSignServiceImpl implements IEsignSignService {
|
|
|
private String cloudPath;
|
|
|
//完成收货回调
|
|
|
private String confirmUrl="order/order/deliver-quantity-confirm/confirmCollect";
|
|
|
+ //E签宝签署完需返回给tms
|
|
|
+ @Value(value = "${spring.tms.tmsToken}")
|
|
|
+ private String tmsToken;
|
|
|
+ @Value(value = "${spring.tms.tmsUrl}")
|
|
|
+ private String tmsUrl;
|
|
|
+ @Value(value = "${spring.tms.suishenbang}")
|
|
|
+ private String suishenbang;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ITransferLogService transferLogService;
|
|
|
|
|
|
/**
|
|
|
* @description: 授权
|
|
@@ -234,15 +254,16 @@ public class EsignSignServiceImpl implements IEsignSignService {
|
|
|
public void saveFile(String flowId, OrderFile orderFlag) {
|
|
|
// System.out.println("executeAysncTask1 method: 执行异步保存{} -------"+ i);
|
|
|
String fileUrl = processDocumentDownload(flowId);
|
|
|
+ String uId=UUID.randomUUID().toString();
|
|
|
/*下载保存签署后的文件,返回文件存储地址*/
|
|
|
OrderFile orderFile = new OrderFile();
|
|
|
orderFile.setFlowId(flowId);
|
|
|
if(orderFlag.getTypes()==1){
|
|
|
downloadFile(Global.getPdfPath(), orderFlag.getOrderId() + ".pdf", fileUrl);
|
|
|
- orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getOrderId() + ".pdf");
|
|
|
+ orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getOrderId()+uId + ".pdf");
|
|
|
}else if( orderFlag.getTypes()==2){
|
|
|
downloadFile(Global.getPdfPath(), orderFlag.getFlowId() + "_授权委托.pdf", fileUrl);
|
|
|
- orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getFlowId() + "_授权委托.pdf");
|
|
|
+ orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getFlowId()+uId + "_授权委托.pdf");
|
|
|
}else{
|
|
|
downloadFile(Global.getPdfPath(), orderFlag.getOrderId() + "_签收订单.pdf", fileUrl);
|
|
|
orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getOrderId() + "_签收订单.pdf");
|
|
@@ -251,28 +272,40 @@ public class EsignSignServiceImpl implements IEsignSignService {
|
|
|
// orderFile.setFileUrl(refile);
|
|
|
orderFileService.updateOrderFileByFlowId(orderFile);
|
|
|
}
|
|
|
-
|
|
|
+ /**
|
|
|
+ * @description: orders交货单
|
|
|
+ * @param: [orders, certificateUrl]
|
|
|
+ * @return: void
|
|
|
+ * @author: njs
|
|
|
+ * @date: 2023/4/12 18:29
|
|
|
+ */
|
|
|
@Override
|
|
|
- public void saveFileFalse(String flowId, OrderFile orderFlag) {
|
|
|
- String fileUrl = processDocumentDownload(flowId);
|
|
|
- /*下载保存签署后的文件,返回文件存储地址*/
|
|
|
- OrderFile orderFile = new OrderFile();
|
|
|
- orderFile.setFlowId(flowId);
|
|
|
- if(orderFlag.getTypes()==1){
|
|
|
- downloadFile(Global.getPdfPath(), orderFlag.getOrderId() + ".pdf", fileUrl);
|
|
|
- orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getOrderId() + ".pdf");
|
|
|
- }else if( orderFlag.getTypes()==2){
|
|
|
- downloadFile(Global.getPdfPath(), orderFlag.getFlowId() + "_授权委托.pdf", fileUrl);
|
|
|
- orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getFlowId() + "_授权委托.pdf");
|
|
|
- }else{
|
|
|
- downloadFile(Global.getPdfPath(), orderFlag.getOrderId() + "_签收订单.pdf", fileUrl);
|
|
|
- orderFile.setFileUrl(Constants.RESOURCE_PREFIX+"/pdf/"+DateUtils.datePath()+"/"+orderFlag.getOrderId() + "_签收订单.pdf");
|
|
|
+ public void tmsCertificate(String orders,String certificateUrl) throws IOException {
|
|
|
+ // 获取请求参数
|
|
|
+ String url = tmsUrl;
|
|
|
+ String token = tmsToken;
|
|
|
+ long ts = System.currentTimeMillis();
|
|
|
+ String sign = new Digester(DigestAlgorithm.MD5).digestHex(new Digester(DigestAlgorithm.SHA1).digestHex(StringUtils.join(token, ts)));
|
|
|
+// 发送请求
|
|
|
+ // name1=value1&name2=value2
|
|
|
+ String pj = "orders="+orders+"&authFile="+suishenbang+certificateUrl;
|
|
|
+ String jsonObject= HttpUtils.sendTmsPost(url,pj,ts,sign);
|
|
|
+ JSONObject object=JSONObject.parseObject(jsonObject);
|
|
|
+ log.info("Tms url = [{}], params = [{}], token = [{}]", url, pj, token);
|
|
|
+// 解析返回值
|
|
|
+ String code = object.getString("sys_code");
|
|
|
+ TransferLog transferLog = new TransferLog();
|
|
|
+ transferLog.setAuthFile(certificateUrl);
|
|
|
+ transferLog.setCodeing(code);
|
|
|
+ transferLog.setDeliveryNumber(orders);
|
|
|
+ transferLog.setRemarks("向TMS发送签署司机授权书");
|
|
|
+ transferLogService.insertTransferLog(transferLog);
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- }
|
|
|
-// orderFile.setFileUrl(refile);
|
|
|
- orderFileService.updateOrderFileByFlowId(orderFile);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
/**
|
|
|
* @description 模拟构建一步发起请求参数
|
|
|
* <p>
|
|
@@ -464,4 +497,5 @@ public class EsignSignServiceImpl implements IEsignSignService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|