|
|
@@ -17,6 +17,7 @@ import me.zhengjie.application.bank.service.UserAXQInfoService;
|
|
|
import me.zhengjie.base.util.FileUploadUtil;
|
|
|
import me.zhengjie.base.ResponseDTO;
|
|
|
import me.zhengjie.base.ResultCode;
|
|
|
+import me.zhengjie.base.pdf.PdfUtils;
|
|
|
import me.zhengjie.dao.mybatis.OrderFileRepository;
|
|
|
import me.zhengjie.dao.mybatis.mapper.OrderFileMapper;
|
|
|
import me.zhengjie.base.util.CFCACertUtil;
|
|
|
@@ -24,6 +25,7 @@ import me.zhengjie.utils.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
+import java.io.ByteArrayInputStream;
|
|
|
import java.io.ByteArrayOutputStream;
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
@@ -164,24 +166,36 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
|
|
|
*
|
|
|
* @param signInfoList
|
|
|
* @param businessNo
|
|
|
+ * @throws Exception
|
|
|
*/
|
|
|
- private void signContract(List<UploadSignInfoVO> signInfoList, String businessNo) {
|
|
|
- List<OrderFileEntity> orderFileList = orderFileRepository.getOrderFileListWithCodes(businessNo, "1,2,3,4,5,6,7,8,9".split(","));
|
|
|
- CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
|
|
|
+ private void signContract(List<UploadSignInfoVO> signInfoList, String businessNo) throws Exception {
|
|
|
+ String[] codes = { "1", "2", "3", "4", "5", "6", "7", "8", "9" };
|
|
|
+ List<OrderFileEntity> orderFileList = orderFileRepository.getOrderFileListWithCodes(businessNo, codes);
|
|
|
+ // 取出所有的二进制流
|
|
|
+ List<InputStream> list = new ArrayList<>();
|
|
|
+ String fileName = "";
|
|
|
+ for (OrderFileEntity orderFile : orderFileList) {
|
|
|
+ if(StringUtils.isNotBlank(fileName)) {
|
|
|
+ fileName = FileUploadUtil.getFileName(orderFile.getPdfUrl());
|
|
|
+ }
|
|
|
+ InputStream inputStream = FileUploadUtil.getInputStream(orderFile.getPdfUrl());
|
|
|
+ list.add(inputStream);
|
|
|
+ }
|
|
|
+ byte[] b = PdfUtils.mergePdf(list);
|
|
|
+ //将所有需要签名的pdf进行合并
|
|
|
+ InputStream input = new ByteArrayInputStream(b);
|
|
|
+ String axqContractNo = CFCACertUtil.uploadMultiSignContract(signInfoList, null, null, input, fileName);
|
|
|
+ String path = businessNo + "/signed-doc/";
|
|
|
+ String filePath = CFCACertUtil.download(path, axqContractNo);
|
|
|
for (OrderFileEntity orderFile : orderFileList) {
|
|
|
- String path = businessNo + "/signed-doc-" + orderFile.getId() + "/";
|
|
|
OrderFileEntity updateOrderFile = new OrderFileEntity();
|
|
|
updateOrderFile.setId(orderFile.getId());
|
|
|
updateOrderFile.setUpdateTime(new Date());
|
|
|
updateOrderFile.setUpdaterId(-1l);
|
|
|
try {
|
|
|
- InputStream inputStream = FileUploadUtil.getInputStream(orderFile.getPdfUrl());
|
|
|
- String fileName = FileUploadUtil.getFileName(orderFile.getPdfUrl());
|
|
|
- String axqContractNo = CFCACertUtil.uploadMultiSignContract(signInfoList, null, null, inputStream, fileName);
|
|
|
updateOrderFile.setAxqContractNo(axqContractNo);
|
|
|
updateOrderFile.setAxqSignedTime(new Date());
|
|
|
- //
|
|
|
- String filePath = CFCACertUtil.download(path, axqContractNo);
|
|
|
+ //设置签名的pdf
|
|
|
updateOrderFile.setSignedPdfUrl(filePath);
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
@@ -196,7 +210,8 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
|
|
|
userQw.eq("id_card", idCard);
|
|
|
userQw.eq("user_status", "1");
|
|
|
UserAXQInfoEntity userAXQInfoEntity = userAXQInfoMapper.selectOne(userQw);
|
|
|
- String authStatus = StringUtils.isEmpty(userAXQInfoEntity.getAxqIsAuth()) ? "0" : userAXQInfoEntity.getAxqIsAuth();
|
|
|
+ String authStatus = StringUtils.isEmpty(userAXQInfoEntity.getAxqIsAuth()) ? "0"
|
|
|
+ : userAXQInfoEntity.getAxqIsAuth();
|
|
|
System.out.println("身份证号:" + idCard + ";授权状态:" + authStatus);
|
|
|
if ("0".equals(authStatus)) {
|
|
|
CFCACertUtil.proxySwitchOn = "dev".equals(systemEnv);
|
|
|
@@ -220,6 +235,7 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
|
|
|
|
|
|
/**
|
|
|
* 将InputStream转为Base64
|
|
|
+ *
|
|
|
* @param is
|
|
|
* @return
|
|
|
* @throws Exception
|
|
|
@@ -252,11 +268,11 @@ public class UserAXQInfoServiceImpl implements UserAXQInfoService {
|
|
|
String keyName = "10020220620124519009/borrower/01a245333ef6463984fefbabc6a12dee.pdf";
|
|
|
int index = keyName.lastIndexOf("/");
|
|
|
if (index != -1) {
|
|
|
- String fileName = keyName.substring(index+1);
|
|
|
+ String fileName = keyName.substring(index + 1);
|
|
|
System.out.println(fileName);
|
|
|
}
|
|
|
// return keyName
|
|
|
System.out.println("");
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
}
|