|
|
@@ -1,11 +1,17 @@
|
|
|
package com.sckw.contract.service;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.sckw.contract.dao.KwcContractLogisticsMapper;
|
|
|
import com.sckw.contract.dao.KwcContractTradeMapper;
|
|
|
+import com.sckw.contract.model.dto.req.EsignGetFlowReqDto;
|
|
|
import com.sckw.contract.model.entity.KwcContractLogistics;
|
|
|
import com.sckw.contract.model.entity.KwcContractTrade;
|
|
|
+import com.sckw.contract.model.vo.req.ContractLogisticsReqVo;
|
|
|
import com.sckw.contract.model.vo.req.ESignCallBackReqVo;
|
|
|
import com.sckw.core.exception.SystemException;
|
|
|
+import com.sckw.core.utils.BeanUtils;
|
|
|
+import com.sckw.core.utils.OkHttpUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.order.api.dubbo.TradeOrderInfoService;
|
|
|
import com.sckw.order.api.model.ContractSignCompletedParam;
|
|
|
@@ -17,6 +23,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.FileOutputStream;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.io.OutputStream;
|
|
|
+import java.net.URL;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.Objects;
|
|
|
@@ -92,4 +104,77 @@ public class CommonBusinessService {
|
|
|
contractSignCompletedParam.setUpdateByName(Objects.isNull(userCacheResDto) ? "" : userCacheResDto.getName());
|
|
|
tradeOrderInfoService.contractSignCompleted(contractSignCompletedParam);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * @param firstAccount 发起方签约电话
|
|
|
+ * secondAccount 对方签约电话
|
|
|
+ * orgFirst 发起方企业id
|
|
|
+ * orgSeconId 对方企业id
|
|
|
+ * contractFile 合同文件
|
|
|
+ * id 合同id
|
|
|
+ * contractName 合同名
|
|
|
+ * @desc: 调e签宝
|
|
|
+ * @author: czh
|
|
|
+ * @date: 2023/8/14
|
|
|
+ */
|
|
|
+ public void postToEsign(String firstAccount, String secondAccount, Long orgFirst, Long orgSeconId, String contractFile, Long id, String contractName) {
|
|
|
+ EsignGetFlowReqDto esignGetFlowReqDto = new EsignGetFlowReqDto();
|
|
|
+ JSONArray jsonArray = JSONArray.parseArray(contractFile);
|
|
|
+ JSONObject jsonObject = jsonArray.getJSONObject(0);
|
|
|
+ String fileName = jsonObject.getString("name");
|
|
|
+ String url = jsonObject.getString("url");
|
|
|
+ File file = getFileByHttpURL(url, fileName);
|
|
|
+
|
|
|
+ List<Long> entIds = new ArrayList<>(2);
|
|
|
+ entIds.add(orgFirst);
|
|
|
+ entIds.add(orgSeconId);
|
|
|
+ Map<Long, EntCacheResDto> longListMap = remoteSystemService.queryEntCacheMapByIds(entIds);
|
|
|
+
|
|
|
+ esignGetFlowReqDto.setFile(file);
|
|
|
+ esignGetFlowReqDto.setSeqId(String.valueOf(id));
|
|
|
+ esignGetFlowReqDto.setSignFlowTitle(contractName);
|
|
|
+ esignGetFlowReqDto.setOrgFirstName(longListMap.get(orgFirst).getFirmName());
|
|
|
+ esignGetFlowReqDto.setPsnFirstAccount(firstAccount);
|
|
|
+ esignGetFlowReqDto.setOrgSecondName(longListMap.get(orgSeconId).getFirmName());
|
|
|
+ esignGetFlowReqDto.setPsnSecondAccount(secondAccount);
|
|
|
+ Map<String, Object> map = BeanUtils.convertToMap(esignGetFlowReqDto);
|
|
|
+ String res = OkHttpUtils.doPostUploadFile("http://10.10.10.224:8840/v1/sign/getFlow", map);
|
|
|
+ //todo 解析返参,返参有流程id返回,表需要新加字段来存储
|
|
|
+ }
|
|
|
+
|
|
|
+ public static File getFileByHttpURL(String newUrl, String fileName) {
|
|
|
+ String[] suffix = newUrl.split("/");
|
|
|
+ //得到最后一个分隔符后的名字
|
|
|
+ File file = null;
|
|
|
+ InputStream inputStream = null;
|
|
|
+ OutputStream outputStream = null;
|
|
|
+ try {
|
|
|
+ file = File.createTempFile("", fileName);
|
|
|
+ URL urlFile = new URL(newUrl);
|
|
|
+ inputStream = urlFile.openStream();
|
|
|
+ outputStream = new FileOutputStream(file);
|
|
|
+
|
|
|
+ int bytesRead = 0;
|
|
|
+ byte[] buffer = new byte[8192];
|
|
|
+ while ((bytesRead = inputStream.read(buffer, 0, 8192)) != -1) {
|
|
|
+ outputStream.write(buffer, 0, bytesRead);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ } finally {
|
|
|
+ try {
|
|
|
+ if (null != outputStream) {
|
|
|
+ outputStream.close();
|
|
|
+ }
|
|
|
+ if (null != inputStream) {
|
|
|
+ inputStream.close();
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (Exception e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return file;
|
|
|
+ }
|
|
|
}
|