humuyu před 3 roky
rodič
revize
c1317f8e03

+ 0 - 70
eladmin-common/src/main/java/me/zhengjie/utils/DownloadUtils.java

@@ -1,70 +0,0 @@
-package me.zhengjie.utils;
-
-import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
-import java.io.InputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.util.HashMap;
-
-import cn.hutool.http.HttpUtil;
-
-/**
- * 使用java中的文件流下载网上的图片,保存到本地
- *
- * @author humuyu
- * @since 2021/12/28/0028 下午 15:06
- **/
-
-public class DownloadUtils {
-
-	public static void downloadFile(String videoUrl, String filePath) throws Exception {
-
-		// 定义一个URL对象,就是你想下载的图片的URL地址
-		URL url = new URL(videoUrl);
-		// 打开连接
-		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
-		// 设置请求方式为"GET"
-		conn.setRequestMethod("GET");
-		// 超时响应时间为10秒
-		conn.setConnectTimeout(10 * 1000);
-		// 通过输入流获取图片数据
-		InputStream is = conn.getInputStream();
-		// 得到图片的二进制数据,以二进制封装得到数据,具有通用性
-		byte[] data = readInputStream(is);
-		// 创建一个文件对象用来保存文件
-		File imageFile = new File(filePath);
-		// 判断文件,需要创建
-		if (!imageFile.exists())
-			FileUtil.mkParentDirs(filePath);
-		// 创建输出流
-		FileOutputStream outStream = new FileOutputStream(imageFile);
-		// 写入数据
-		outStream.write(data);
-		// 关闭输出流,释放资源
-		outStream.close();
-
-	}
-
-	public static void main(String[] args) throws Exception { 
-		
-	}
-
-	public static byte[] readInputStream(InputStream inStream) throws Exception {
-		ByteArrayOutputStream outStream = new ByteArrayOutputStream();
-		// 创建一个Buffer字符串
-		byte[] buffer = new byte[6024];
-		// 每次读取的字符串长度,如果为-1,代表全部读取完毕
-		int len;
-		// 使用一个输入流从buffer里把数据读取出来
-		while ((len = inStream.read(buffer)) != -1) {
-			// 用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
-			outStream.write(buffer, 0, len);
-		}
-		// 关闭输入流
-		inStream.close();
-		// 把outStream里的数据写入内存
-		return outStream.toByteArray();
-	}
-}

+ 103 - 29
eladmin-system/src/main/java/me/zhengjie/application/admin/controller/DemoController.java

@@ -1,17 +1,30 @@
 package me.zhengjie.application.admin.controller;
 
 import com.tencentyun.TLSSigAPIv2;
+
+import cfca.trustsign.common.vo.cs.UploadSignInfoVO;
+import cfca.trustsign.constant.Request;
+import cfca.trustsign.util.PdfUtil;
 import me.zhengjie.annotation.AnonymousAccess;
+import me.zhengjie.annotation.rest.AnonymousPostMapping;
 import me.zhengjie.base.BaseResponse;
 import me.zhengjie.base.ResultData;
 import me.zhengjie.base.config.AppConfigInfo;
+import me.zhengjie.base.util.CFCACertUtil;
+import me.zhengjie.base.util.HttpConnector;
 import me.zhengjie.websocket.MsgType;
 import me.zhengjie.websocket.SocketMsg;
 import me.zhengjie.websocket.WebSocketServer;
+
+import org.apache.commons.io.FileUtils;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.File;
+import java.io.FileInputStream;
 import java.io.IOException;
+import java.io.InputStream;
+import java.util.List;
 import java.util.Map;
 
 /**
@@ -24,33 +37,94 @@ import java.util.Map;
 @RequestMapping("/demo")
 public class DemoController {
 
-    @ResponseBody
-    @AnonymousAccess
-    @RequestMapping("/socket/push/{cid}")
-    public String pushToWeb(@PathVariable String cid,String mesg){
-        try {
-            WebSocketServer.sendInfo(new SocketMsg(mesg, MsgType.INFO), cid);
-        } catch (IOException e) {
-            e.printStackTrace();
-            return "failure";
-        }
-        return "success";
-    }
-
-    /**
-     * 机构 查询  银行+公证处
-     *
-     * @return
-     */
-    @ResponseBody
-    @RequestMapping("/getUserSig")
-    public BaseResponse getUserSig(@RequestBody Map<String, String> map) {
-        System.out.println("SDK_APP_ID: " + AppConfigInfo.SDK_APP_ID);
-        System.out.println("TTL_SIG_KEY: " + AppConfigInfo.TTL_SIG_KEY);
-        TLSSigAPIv2 api = new TLSSigAPIv2(AppConfigInfo.SDK_APP_ID, AppConfigInfo.TTL_SIG_KEY);
-        BaseResponse response = new BaseResponse();
-        String s = api.genUserSig(map.get("userId"), 604800);
-        response.setData(new ResultData(s));
-        return response;
-    }
+	@ResponseBody
+	@AnonymousAccess
+	@RequestMapping("/socket/push/{cid}")
+	public String pushToWeb(@PathVariable String cid, String mesg) {
+		try {
+			WebSocketServer.sendInfo(new SocketMsg(mesg, MsgType.INFO), cid);
+		} catch (IOException e) {
+			e.printStackTrace();
+			return "failure";
+		}
+		return "success";
+	}
+
+	/**
+	 * 机构 查询 银行+公证处
+	 *
+	 * @return
+	 */
+	@ResponseBody
+	@RequestMapping("/getUserSig")
+	public BaseResponse<?> getUserSig(@RequestBody Map<String, String> map) {
+		System.out.println("SDK_APP_ID: " + AppConfigInfo.SDK_APP_ID);
+		System.out.println("TTL_SIG_KEY: " + AppConfigInfo.TTL_SIG_KEY);
+		TLSSigAPIv2 api = new TLSSigAPIv2(AppConfigInfo.SDK_APP_ID, AppConfigInfo.TTL_SIG_KEY);
+		BaseResponse<String> response = new BaseResponse<>();
+		String s = api.genUserSig(map.get("userId"), 604800);
+		response.setData(new ResultData<String>(s));
+		return response;
+	}
+
+	/**
+	 * 多人签发
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	@ResponseBody
+	@AnonymousPostMapping("/notarySign")
+	public BaseResponse<?> notarySign(@RequestBody List<UploadSignInfoVO> notaryUserInfos,String fileName) throws Exception {
+
+		BaseResponse<?> response = new BaseResponse<>();
+//    	UploadSignInfoVO notaryUserInfo = new UploadSignInfoVO();
+		// List<UploadSignInfoVO> notaryUserInfos = new ArrayList<>();
+//		notaryUserInfo.setUserId("E06DAAB5F6894542E05312016B0AC8F1");
+//		notaryUserInfo.setSealId("E06DAB4AFAEF4DB7E05311016B0A5154");
+//		notaryUserInfo.setLocation("210.74.41.0");
+//		notaryUserInfo.setAuthorizationTime("20220214171200");
+//		notaryUserInfos.add(notaryUserInfo);
+//		notaryUserInfos.add(notaryUserInfo);
+//		UploadSignInfoVO notaryOfficeInfo = new UploadSignInfoVO();
+//		notaryOfficeInfo.setUserId(notaryOffice.getAxqUserId());
+//		notaryOfficeInfo.setSealId(notaryOffice.getAxqSealId());
+//		notaryOfficeInfo.setLocation("210.74.41.1");
+//		notaryOfficeInfo.setAuthorizationTime("20220214171200");
+		String path = "/home/oss/pdftest/"+fileName;
+		InputStream inputStream = new FileInputStream(path);
+//		String contractNO = CFCACertUtil.uploadMultiSignContract(notaryUserInfos, inputStream, fileName);
+//		System.out.println(contractNO);
+//		response.setMsg(contractNO);
+		return response;
+	}
+
+	/**
+	 * 多人签发
+	 *
+	 * @return
+	 * @throws Exception
+	 */
+	@ResponseBody
+	@AnonymousPostMapping("/download")
+	public BaseResponse<?> download(@RequestBody Map<String,String> param) throws Exception {
+
+		BaseResponse<?> response = new BaseResponse<>();
+		HttpConnector httpConnector = new HttpConnector();
+		String contractNo=param.get("contractNo");
+		httpConnector.init();
+		String filePath = "platId/" + Request.AXQ_PLAT_ID + "/contractNo/" + contractNo + "/downloading";
+		byte[] fileBtye = httpConnector.getFile(filePath);
+
+		String suffix;
+		if (PdfUtil.isPdf(fileBtye)) {
+			suffix = ".pdf";
+		} else {
+			suffix = ".ofd";
+		}
+		String fullFilePath = "/home/oss/" + contractNo + suffix;
+		FileUtils.writeByteArrayToFile(new File(fullFilePath), fileBtye);
+		return response;
+	}
+
 }

+ 1 - 1
eladmin-system/src/main/java/me/zhengjie/application/admin/job/GenerateNotarizationJob.java

@@ -131,7 +131,7 @@ public class GenerateNotarizationJob {
 
         CFCACertUtil.proxySwitchOn = "dev".equals(AppConfigInfo.APP_ENV_TYPE);
         String path = orderFile.getPdfUrl();
-        InputStream inputStream=  FileUploadUtil.getInputStream(path);
+        InputStream inputStream = FileUploadUtil.getInputStream(path);
         String fileName=FileUploadUtil.getFileName(path);
         String contractNO = CFCACertUtil.uploadSignContract(notaryUserInfo, notaryOfficeInfo, inputStream,fileName);
         orderFile.setAxqContractNo(contractNO);

+ 513 - 441
eladmin-system/src/main/java/me/zhengjie/base/util/CFCACertUtil.java

@@ -18,449 +18,521 @@ import com.fasterxml.jackson.databind.ObjectMapper;
 
 import java.io.File;
 import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.List;
 
 @Slf4j
 public class CFCACertUtil {
-    private static final int PROXY_SIGN_ON = 1;
-    private static final String PROJECT_CODE = "004";
-    private static final String AUTH_MODE = "公安部";
-    public static boolean proxySwitchOn = false;
-
-    /**
-     * 注册安心签企业用户
-     *
-     * @param enterprise           企业信息
-     * @param enterpriseTransactor 企业经办人信息
-     * @return 安心签用户ID
-     * @throws Exception
-     */
-    public static String registerCompany(EnterpriseVO enterprise, EnterpriseTransactorVO enterpriseTransactor) throws Exception {
-
-        enterprise.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-        enterprise.setAuthenticationMode(AUTH_MODE);
-        enterprise.setIdentTypeCode("N");
-        enterpriseTransactor.setIdentTypeCode("0");
-
-        Tx3002ReqVO tx3002ReqVO = new Tx3002ReqVO();
-        tx3002ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
-        tx3002ReqVO.setEnterprise(enterprise);
-        tx3002ReqVO.setEnterpriseTransactor(enterpriseTransactor);
-
-        String response = requestAPI(tx3002ReqVO, "3002");
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-        Tx3002ResVO tx3002ResVO = new ObjectMapper().readValue(response, Tx3002ResVO.class);
-        return tx3002ResVO.getEnterprise().getUserId();
-    }
-
-    /**
-     * 注册安心签个人用户
-     *
-     * @throws Exception
-     */
-    public static String registerPerson(PersonVO person) throws Exception {
-        person.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-        person.setAuthenticationMode(AUTH_MODE);
-
-        Tx3001ReqVO tx3001ReqVO = new Tx3001ReqVO();
-        tx3001ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
-        tx3001ReqVO.setPerson(person);
-
-        String response = requestAPI(tx3001ReqVO, "3001");
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-        Tx3001ResVO tx3001ResVO = new ObjectMapper().readValue(response, Tx3001ResVO.class);
-        return tx3001ResVO.getPerson().getUserId();
-    }
-
-    /**
-     * 查询证书信息
-     * @param cert
-     * @return
-     * @throws Exception
-     */
-    public static CertVO queryCertificate(CertVO cert) throws Exception{
-        Tx3311ReqVO tx3311ReqVO = new Tx3311ReqVO();
-        tx3311ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
-        tx3311ReqVO.setCert(cert);
-        String response = requestAPI(tx3311ReqVO, "3311");
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-        Tx3311ResVO tx3311ResVO = new ObjectMapper().readValue(response, Tx3311ResVO.class);
-        return tx3311ResVO.getCert();
-    }
-
-
-    public static void updateSealWithContent(String userId, String sealId, String content) throws Exception {
-
-        HeadVO head = new HeadVO();
-        head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-
-        SealVO sealVO = new SealVO();
-        sealVO.setSealId(sealId);
-        sealVO.setImageData(content);
-
-        SealUpdateVO sealUpdateVO = new SealUpdateVO();
-        sealUpdateVO.setUserId(userId);
-        sealUpdateVO.setSeal(sealVO);
-
-        Tx3012ReqVO tx3012ReqVO = new Tx3012ReqVO();
-        tx3012ReqVO.setHead(head);
-        tx3012ReqVO.setSealUpdate(sealUpdateVO);
-
-        String response = requestAPI(tx3012ReqVO, "3012");
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-    }
-
-    /**
-     * 修改签章
-     * @param userId
-     * @param sealId
-     * @param filePath
-     * @throws Exception
-     */
-    public static void updateSeal(String userId, String sealId, byte[] b) throws Exception {
-    	//这里将图片的路径下载文件
+	private static final int PROXY_SIGN_ON = 1;
+	private static final String PROJECT_CODE = "004";
+	private static final String AUTH_MODE = "公安部";
+	public static boolean proxySwitchOn = false;
+
+	/**
+	 * 注册安心签企业用户
+	 *
+	 * @param enterprise           企业信息
+	 * @param enterpriseTransactor 企业经办人信息
+	 * @return 安心签用户ID
+	 * @throws Exception
+	 */
+	public static String registerCompany(EnterpriseVO enterprise, EnterpriseTransactorVO enterpriseTransactor)
+			throws Exception {
+
+		enterprise.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+		enterprise.setAuthenticationMode(AUTH_MODE);
+		enterprise.setIdentTypeCode("N");
+		enterpriseTransactor.setIdentTypeCode("0");
+
+		Tx3002ReqVO tx3002ReqVO = new Tx3002ReqVO();
+		tx3002ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
+		tx3002ReqVO.setEnterprise(enterprise);
+		tx3002ReqVO.setEnterpriseTransactor(enterpriseTransactor);
+
+		String response = requestAPI(tx3002ReqVO, "3002");
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+		Tx3002ResVO tx3002ResVO = new ObjectMapper().readValue(response, Tx3002ResVO.class);
+		return tx3002ResVO.getEnterprise().getUserId();
+	}
+
+	/**
+	 * 注册安心签个人用户
+	 *
+	 * @throws Exception
+	 */
+	public static String registerPerson(PersonVO person) throws Exception {
+		person.setAuthenticationTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+		person.setAuthenticationMode(AUTH_MODE);
+
+		Tx3001ReqVO tx3001ReqVO = new Tx3001ReqVO();
+		tx3001ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
+		tx3001ReqVO.setPerson(person);
+
+		String response = requestAPI(tx3001ReqVO, "3001");
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+		Tx3001ResVO tx3001ResVO = new ObjectMapper().readValue(response, Tx3001ResVO.class);
+		return tx3001ResVO.getPerson().getUserId();
+	}
+
+	/**
+	 * 查询证书信息
+	 * 
+	 * @param cert
+	 * @return
+	 * @throws Exception
+	 */
+	public static CertVO queryCertificate(CertVO cert) throws Exception {
+		Tx3311ReqVO tx3311ReqVO = new Tx3311ReqVO();
+		tx3311ReqVO.setHead(HeadVO.builder().txTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14)).build());
+		tx3311ReqVO.setCert(cert);
+		String response = requestAPI(tx3311ReqVO, "3311");
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+		Tx3311ResVO tx3311ResVO = new ObjectMapper().readValue(response, Tx3311ResVO.class);
+		return tx3311ResVO.getCert();
+	}
+
+	public static void updateSealWithContent(String userId, String sealId, String content) throws Exception {
+
+		HeadVO head = new HeadVO();
+		head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+
+		SealVO sealVO = new SealVO();
+		sealVO.setSealId(sealId);
+		sealVO.setImageData(content);
+
+		SealUpdateVO sealUpdateVO = new SealUpdateVO();
+		sealUpdateVO.setUserId(userId);
+		sealUpdateVO.setSeal(sealVO);
+
+		Tx3012ReqVO tx3012ReqVO = new Tx3012ReqVO();
+		tx3012ReqVO.setHead(head);
+		tx3012ReqVO.setSealUpdate(sealUpdateVO);
+
+		String response = requestAPI(tx3012ReqVO, "3012");
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+	}
+
+	/**
+	 * 修改签章
+	 * 
+	 * @param userId
+	 * @param sealId
+	 * @param filePath
+	 * @throws Exception
+	 */
+	public static void updateSeal(String userId, String sealId, byte[] b) throws Exception {
+		// 这里将图片的路径下载文件
 //    	byte[] b=DownloadUtils.downloadFile(filePath);
-        String content = Base64.toBase64String(b);
-        updateSealWithContent(userId, sealId, content);
-    }
-    /**
-     * 为指定用户添加印章
-     *
-     * @param userId
-     * @param content
-     * @return 返回印章ID
-     * @throws Exception
-     */
-    public static String addSealWithContent(String userId, String content) throws Exception {
-
-        HeadVO head = new HeadVO();
-        head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-
-        SealAddVO sealAddVO = new SealAddVO();
-        sealAddVO.setUserId(userId);
-        SealVO sealVO = new SealVO();
-        sealVO.setImageData(content);
-        sealAddVO.setSeal(sealVO);
-
-        Tx3011ReqVO tx3011ReqVO = new Tx3011ReqVO();
-        tx3011ReqVO.setHead(head);
-        tx3011ReqVO.setSealAdd(sealAddVO);
-
-        String response = requestAPI(tx3011ReqVO, "3011");
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-        Tx3011ResVO tx3011ResVO = new ObjectMapper().readValue(response, Tx3011ResVO.class);
-        return tx3011ResVO.getSealAdd().getSeal().getSealId();
-    }
-
-    /**
-     * 为指定用户添加印章
-     *
-     * @param userId
-     * @param filePath
-     * @return 返回印章ID
-     * @throws Exception
-     */
-    public static String addSeal(String userId, byte[] b) throws Exception {
-        String content = Base64.toBase64String(b);
-        return addSealWithContent(userId, content);
-    }
-
-    /**
-     * 对指定用户发送授权验证码
-     *
-     * @param userId
-     * @throws Exception
-     */
-    public static boolean sendAuthMessage(String userId) throws Exception {
-
-        Tx3101ReqVO tx3101ReqVO = new Tx3101ReqVO();
-        HeadVO head = new HeadVO();
-        head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-
-        ProxySignVO proxySignVO = new ProxySignVO();
-        proxySignVO.setUserId(userId);
-        proxySignVO.setProjectCode(PROJECT_CODE);
-
-        tx3101ReqVO.setHead(head);
-        tx3101ReqVO.setProxySign(proxySignVO);
-
-        String response = requestAPI(tx3101ReqVO, "3101");
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            if (!"60030401".equals(errorResVO.getErrorCode())) {
-                throw new Exception("安心签服务请求失败");
-            }else {
-                return true;
-            }
-        }
-        return false;
-    }
-
-    /**
-     * 确认授权验证码
-     *
-     * @param userId
-     * @param checkCode
-     * @throws Exception
-     */
-    public static void confirmAuthMessage(String userId, String checkCode) throws Exception {
-
-        Tx3102ReqVO tx3102ReqVO = new Tx3102ReqVO();
-        HeadVO head = new HeadVO();
-        head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-
-        ProxySignVO proxySignVO = new ProxySignVO();
-        proxySignVO.setUserId(userId);
-        proxySignVO.setProjectCode(PROJECT_CODE);
-        proxySignVO.setCheckCode(checkCode);
-
-        tx3102ReqVO.setHead(head);
-        tx3102ReqVO.setProxySign(proxySignVO);
-
-        String response = requestAPI(tx3102ReqVO, "3102");
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-    }
-
-    /**
-     * 上传签署合同
-     *
-     * @param notaryUser   公证员签名信息
-     * @param notaryOffice 公证处签名信息
-     * @param file         签名文件
-     * @return 返回合同编号
-     * @throws Exception
-     */
-    public static String uploadSignContract(UploadSignInfoVO notaryUser, UploadSignInfoVO notaryOffice, InputStream file,String fileName) throws Exception {
-        SignKeywordVO keywordNotaryUser = getSignKeywork("公证员", "70", "0", "160", "60");
-        setSignInfoDefault(notaryUser, keywordNotaryUser);
-        SignKeywordVO keywordNotaryOffice = getSignKeywork("签章", "0", "0", "150", "150");
-        setSignInfoDefault(notaryOffice, keywordNotaryOffice);
-
-        UploadSignInfoVO[] signInfos = {notaryUser, notaryOffice};
-        UploadContractVO uploadContract = new UploadContractVO();
-        uploadContract.setSignInfos(signInfos);
-        uploadContract.setContractTypeCode("WT");
-        uploadContract.setContractName("赋强公证");
-
-        HeadVO head = new HeadVO();
-        head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-
-        Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
-        tx3203ReqVO.setHead(head);
-        tx3203ReqVO.setUploadContract(uploadContract);
-
-        String response = requestAPI(tx3203ReqVO, "3203", file,fileName);
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-        Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
-        return tx3203ResVO.getContract().getContractNo();
-    }
-
-    /**
-     * 上传签署合同
-     *
-     * @param user
-     * @param file
-     * @return
-     * @throws Exception
-     */
-    public static String uploadSignContract(UploadSignInfoVO user, InputStream file,String fileName) throws Exception {
-        SignKeywordVO keywordUser = getSignKeywork("签名:", "70", "0", "160", "60");
-        setSignInfoDefault(user, keywordUser);
-
-        UploadSignInfoVO[] signInfos = {user};
-        UploadContractVO uploadContract = new UploadContractVO();
-        uploadContract.setSignInfos(signInfos);
-        uploadContract.setContractTypeCode("WT");
-        uploadContract.setContractName("赋强公证");
-
-        HeadVO head = new HeadVO();
-        head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
-
-        Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
-        tx3203ReqVO.setHead(head);
-        tx3203ReqVO.setUploadContract(uploadContract);
-        //读取文件的流,TODO 
-        String response = requestAPI(tx3203ReqVO, "3203", file,fileName);
-        if (!isSucess(response)) {
-            ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
-            System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
-            throw new Exception("安心签服务请求失败");
-        }
-        Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
-        return tx3203ResVO.getContract().getContractNo();
-    }
-
-    /**
-     * 下载签名公证书
-     *
-     * @param filePath
-     * @param contractNo
-     * @throws Exception
-     */
-    public static String download(String filePath, String contractNo) throws Exception {
-        HttpConnector httpConnector = new HttpConnector();
-        httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
-        httpConnector.init();
-
-        byte[] fileBtye = httpConnector.getFile("platId/" + Request.AXQ_PLAT_ID + "/contractNo/" + contractNo + "/downloading");
-       
-       String contentType;
-       String suffix;
-       if(PdfUtil.isPdf(fileBtye)) { 
-    		contentType = "application/pdf";
-    		suffix=".pdf";
-       }else {
-    	   contentType = "application/ofd";
-    	   suffix=".ofd";
-       }
-       String fullFilePath = filePath + contractNo + suffix;
-       //上传文件路径
-       log.info("上传文件的目录:"+ fullFilePath);
-       FileUploadUtil.uploadFile(fullFilePath, contentType, fileBtye);
-     
-        return fullFilePath;
-    }
-
-    /**
-     * 发送安心签API请求
-     *
-     * @param txReqVO
-     * @param txCode
-     * @return
-     * @throws Exception
-     */
-    private static String requestAPI(Object txReqVO, String txCode) throws Exception {
-        return requestAPI(txReqVO, txCode, null);
-    }
-
-    /**
-     * 发送安心签API请求
-     *
-     * @param txReqVO
-     * @param txCode
-     * @throws PKIException
-     */
-    private static String requestAPI(Object txReqVO, String txCode, File file) throws Exception {
-        HttpConnector httpConnector = new HttpConnector();
-        httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
-        httpConnector.init();
-        String req = new JsonObjectMapper().writeValueAsString(txReqVO);
-        System.out.println("req:" + req);
-        String signature = SecurityUtil.p7SignMessageDetach(Request.AXQ_JKS_PATH, Request.AXQ_JKS_PWD, Request.AXQ_JKS_ALIAS, req);
-        String res = "";
-        if ("3203".equals(txCode)) {
-            res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature, file);
-        } else {
-            res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature);
-        }
-        System.out.println("res:" + res);
-        return res;
-    }
-    /**
-     * 发送安心签API请求
-     *
-     * @param txReqVO
-     * @param txCode
-     * @throws PKIException
-     */
-    private static String requestAPI(Object txReqVO, String txCode, InputStream file,String fileName) throws Exception {
-        HttpConnector httpConnector = new HttpConnector();
-        httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
-        httpConnector.init();
-        String req = new JsonObjectMapper().writeValueAsString(txReqVO);
-        System.out.println("req:" + req);
-        String signature = SecurityUtil.p7SignMessageDetach(Request.AXQ_JKS_PATH, Request.AXQ_JKS_PWD, Request.AXQ_JKS_ALIAS, req);
-        String res = "";
-        if ("3203".equals(txCode)) {
-            res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature, file,fileName);
-        } else {
-            res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req, signature);
-        }
-        System.out.println("res:" + res);
-        return res;
-    }
-
-    /**
-     * 设置签名默认信息
-     *
-     * @param signInfo
-     * @param keyword
-     */
-    private static void setSignInfoDefault(UploadSignInfoVO signInfo, SignKeywordVO keyword) {
-        signInfo.setIsProxySign(PROXY_SIGN_ON);
-        signInfo.setProjectCode(PROJECT_CODE);
-        signInfo.setSignKeyword(keyword);
-    }
-
-    /**
-     * 获得签名定位关键词对象
-     *
-     * @param keyword
-     * @param offsetX
-     * @param offsetY
-     * @param width
-     * @param height
-     * @return
-     */
-    private static SignKeywordVO getSignKeywork(String keyword, String offsetX, String offsetY, String width, String height) {
-        SignKeywordVO signKeyword = new SignKeywordVO();
-        signKeyword.setKeyword(keyword);
-        signKeyword.setOffsetCoordX(offsetX);
-        signKeyword.setOffsetCoordY(offsetY);
-        signKeyword.setImageWidth(width);
-        signKeyword.setImageHeight(height);
-        return signKeyword;
-    }
-
-    /**
-     * 判断请求是否成功
-     *
-     * @param response
-     * @return
-     */
-    private static boolean isSucess(String response) {
-        if (response.indexOf("\"head\"") < 0) {
-            return false;
-        }
-        return true;
-    }
-
-    public static void main(String[] args) {
-        proxySwitchOn = true;
-        CertVO certVO = new CertVO();
-        certVO.setUserId("DD25A736C37D345DE05311016B0AB061");
-        try {
-            queryCertificate(certVO);
-        }catch (Exception e){
-            e.printStackTrace();
-        }
-    }
+		String content = Base64.toBase64String(b);
+		updateSealWithContent(userId, sealId, content);
+	}
+
+	/**
+	 * 为指定用户添加印章
+	 *
+	 * @param userId
+	 * @param content
+	 * @return 返回印章ID
+	 * @throws Exception
+	 */
+	public static String addSealWithContent(String userId, String content) throws Exception {
+
+		HeadVO head = new HeadVO();
+		head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+
+		SealAddVO sealAddVO = new SealAddVO();
+		sealAddVO.setUserId(userId);
+		SealVO sealVO = new SealVO();
+		sealVO.setImageData(content);
+		sealAddVO.setSeal(sealVO);
+
+		Tx3011ReqVO tx3011ReqVO = new Tx3011ReqVO();
+		tx3011ReqVO.setHead(head);
+		tx3011ReqVO.setSealAdd(sealAddVO);
+
+		String response = requestAPI(tx3011ReqVO, "3011");
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+		Tx3011ResVO tx3011ResVO = new ObjectMapper().readValue(response, Tx3011ResVO.class);
+		return tx3011ResVO.getSealAdd().getSeal().getSealId();
+	}
+
+	/**
+	 * 为指定用户添加印章
+	 *
+	 * @param userId
+	 * @param filePath
+	 * @return 返回印章ID
+	 * @throws Exception
+	 */
+	public static String addSeal(String userId, byte[] b) throws Exception {
+		String content = Base64.toBase64String(b);
+		return addSealWithContent(userId, content);
+	}
+
+	/**
+	 * 对指定用户发送授权验证码
+	 *
+	 * @param userId
+	 * @throws Exception
+	 */
+	public static boolean sendAuthMessage(String userId) throws Exception {
+
+		Tx3101ReqVO tx3101ReqVO = new Tx3101ReqVO();
+		HeadVO head = new HeadVO();
+		head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+
+		ProxySignVO proxySignVO = new ProxySignVO();
+		proxySignVO.setUserId(userId);
+		proxySignVO.setProjectCode(PROJECT_CODE);
+
+		tx3101ReqVO.setHead(head);
+		tx3101ReqVO.setProxySign(proxySignVO);
+
+		String response = requestAPI(tx3101ReqVO, "3101");
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			if (!"60030401".equals(errorResVO.getErrorCode())) {
+				throw new Exception("安心签服务请求失败");
+			} else {
+				return true;
+			}
+		}
+		return false;
+	}
+
+	/**
+	 * 确认授权验证码
+	 *
+	 * @param userId
+	 * @param checkCode
+	 * @throws Exception
+	 */
+	public static void confirmAuthMessage(String userId, String checkCode) throws Exception {
+
+		Tx3102ReqVO tx3102ReqVO = new Tx3102ReqVO();
+		HeadVO head = new HeadVO();
+		head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+
+		ProxySignVO proxySignVO = new ProxySignVO();
+		proxySignVO.setUserId(userId);
+		proxySignVO.setProjectCode(PROJECT_CODE);
+		proxySignVO.setCheckCode(checkCode);
+
+		tx3102ReqVO.setHead(head);
+		tx3102ReqVO.setProxySign(proxySignVO);
+
+		String response = requestAPI(tx3102ReqVO, "3102");
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+	}
+
+	/**
+	 * 上传签署合同
+	 *
+	 * @param notaryUser   公证员签名信息
+	 * @param notaryOffice 公证处签名信息
+	 * @param file         签名文件
+	 * @return 返回合同编号
+	 * @throws Exception
+	 */
+	public static String uploadSignContract(UploadSignInfoVO notaryUser, UploadSignInfoVO notaryOffice,
+			InputStream file, String fileName) throws Exception {
+		SignKeywordVO keywordNotaryUser = getSignKeywork("公证员", "70", "0", "160", "60");
+		setSignInfoDefault(notaryUser, keywordNotaryUser);
+		SignKeywordVO keywordNotaryOffice = getSignKeywork("签章", "0", "0", "150", "150");
+		setSignInfoDefault(notaryOffice, keywordNotaryOffice);
+
+		UploadSignInfoVO[] signInfos = { notaryUser, notaryOffice };
+		UploadContractVO uploadContract = new UploadContractVO();
+		uploadContract.setSignInfos(signInfos);
+		uploadContract.setContractTypeCode("WT");
+		uploadContract.setContractName("赋强公证");
+
+		HeadVO head = new HeadVO();
+		head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+
+		Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
+		tx3203ReqVO.setHead(head);
+		tx3203ReqVO.setUploadContract(uploadContract);
+
+		String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+		Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
+		return tx3203ResVO.getContract().getContractNo();
+	}
+
+	/**
+	 * 上传签署合同
+	 *
+	 * @param user
+	 * @param file
+	 * @return
+	 * @throws Exception
+	 */
+	public static String uploadSignContract(UploadSignInfoVO user, InputStream file, String fileName) throws Exception {
+		SignKeywordVO keywordUser = getSignKeywork("签名:", "70", "0", "160", "60");
+		setSignInfoDefault(user, keywordUser);
+
+		UploadSignInfoVO[] signInfos = { user };
+		UploadContractVO uploadContract = new UploadContractVO();
+		uploadContract.setSignInfos(signInfos);
+		uploadContract.setContractTypeCode("WT");
+		uploadContract.setContractName("赋强公证");
+
+		HeadVO head = new HeadVO();
+		head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+
+		Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
+		tx3203ReqVO.setHead(head);
+		tx3203ReqVO.setUploadContract(uploadContract);
+		// 读取文件的流,TODO
+		String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+		Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
+		return tx3203ResVO.getContract().getContractNo();
+	}
+
+	/**
+	 * 下载签名公证书
+	 *
+	 * @param filePath
+	 * @param contractNo
+	 * @throws Exception
+	 */
+	public static String download(String filePath, String contractNo) throws Exception {
+		HttpConnector httpConnector = new HttpConnector();
+		httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
+		httpConnector.init();
+
+		byte[] fileBtye = httpConnector
+				.getFile("platId/" + Request.AXQ_PLAT_ID + "/contractNo/" + contractNo + "/downloading");
+
+		String contentType;
+		String suffix;
+		if (PdfUtil.isPdf(fileBtye)) {
+			contentType = "application/pdf";
+			suffix = ".pdf";
+		} else {
+			contentType = "application/ofd";
+			suffix = ".ofd";
+		}
+		String fullFilePath = filePath + contractNo + suffix;
+		// 上传文件路径
+		log.info("上传文件的目录:" + fullFilePath);
+		FileUploadUtil.uploadFile(fullFilePath, contentType, fileBtye);
+
+		return fullFilePath;
+	}
+
+	/**
+	 * 发送安心签API请求
+	 *
+	 * @param txReqVO
+	 * @param txCode
+	 * @return
+	 * @throws Exception
+	 */
+	private static String requestAPI(Object txReqVO, String txCode) throws Exception {
+		return requestAPI(txReqVO, txCode, null);
+	}
+
+	/**
+	 * 发送安心签API请求
+	 *
+	 * @param txReqVO
+	 * @param txCode
+	 * @throws PKIException
+	 */
+	private static String requestAPI(Object txReqVO, String txCode, File file) throws Exception {
+		HttpConnector httpConnector = new HttpConnector();
+		httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
+		httpConnector.init();
+		String req = new JsonObjectMapper().writeValueAsString(txReqVO);
+		System.out.println("req:" + req);
+		String signature = SecurityUtil.p7SignMessageDetach(Request.AXQ_JKS_PATH, Request.AXQ_JKS_PWD,
+				Request.AXQ_JKS_ALIAS, req);
+		String res = "";
+		if ("3203".equals(txCode)) {
+			res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
+					signature, file);
+		} else {
+			res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
+					signature);
+		}
+		System.out.println("res:" + res);
+		return res;
+	}
+
+	/**
+	 * 发送安心签API请求
+	 *
+	 * @param txReqVO
+	 * @param txCode
+	 * @throws PKIException
+	 */
+	private static String requestAPI(Object txReqVO, String txCode, InputStream file, String fileName)
+			throws Exception {
+		HttpConnector httpConnector = new HttpConnector();
+		httpConnector.isProxyUsed = proxySwitchOn ? Request.PROXY_IN_USED : Request.PROXY_NO_USED;
+		httpConnector.init();
+		String req = new JsonObjectMapper().writeValueAsString(txReqVO);
+		System.out.println("req:" + req);
+		String signature = SecurityUtil.p7SignMessageDetach(Request.AXQ_JKS_PATH, Request.AXQ_JKS_PWD,
+				Request.AXQ_JKS_ALIAS, req);
+		String res = "";
+		if ("3203".equals(txCode)) {
+			res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
+					signature, file, fileName);
+		} else {
+			res = httpConnector.post("platId/" + Request.AXQ_PLAT_ID + "/txCode/" + txCode + "/transaction", req,
+					signature);
+		}
+		System.out.println("res:" + res);
+		return res;
+	}
+
+	/**
+	 * 多个人签证,最多三个人
+	 ** @param notaryUserInfos  签名多个,包含了可能是借款人,抵押人,担保人
+	 * @param notaryUser   公证员签名信息
+	 * @param seal  盖章的位置
+	 * @param file   文件的   
+	 * @param fileName 文件名称
+	 * @return 返回合同编号
+	 * @throws Exception
+	 */
+	public static String uploadMultiSignContract(List<UploadSignInfoVO> notaryUserInfos, UploadSignInfoVO notaryUser,
+			UploadSignInfoVO seal, InputStream file, String fileName) throws Exception {
+
+
+		int i = 0;
+		for (UploadSignInfoVO user : notaryUserInfos) {
+			String x = String.valueOf(10 + i * 70);
+			i++;
+			SignKeywordVO keywordNotaryUser = CFCACertUtil.getSignKeywork("签章:", x, "0", "80", "40");
+			CFCACertUtil.setSignInfoDefault(user, keywordNotaryUser);
+		}
+		//公证员签名
+		if (notaryUser != null) {
+			SignKeywordVO keywordNotaryUser = getSignKeywork("公证员", "70", "0", "160", "60");
+			setSignInfoDefault(notaryUser, keywordNotaryUser);
+			notaryUserInfos.add(notaryUser);
+		}
+		//盖章
+		if (seal != null) {
+			SignKeywordVO keywordNotaryOffice = getSignKeywork("签章", "0", "0", "150", "150");
+			setSignInfoDefault(seal, keywordNotaryOffice);
+			notaryUserInfos.add(seal);
+		}
+
+		UploadContractVO uploadContract = new UploadContractVO();
+		uploadContract.setSignInfos(notaryUserInfos.toArray(new UploadSignInfoVO[0]));
+		uploadContract.setContractTypeCode("WT");
+		uploadContract.setContractName("赋强公证");
+
+		HeadVO head = new HeadVO();
+		head.setTxTime(TimeUtil.getCurrentTime(TimeUtil.FORMAT_14));
+
+		Tx3203ReqVO tx3203ReqVO = new Tx3203ReqVO();
+		tx3203ReqVO.setHead(head);
+		tx3203ReqVO.setUploadContract(uploadContract);
+
+		String response = requestAPI(tx3203ReqVO, "3203", file, fileName);
+		if (!isSucess(response)) {
+			ErrorResVO errorResVO = new ObjectMapper().readValue(response, ErrorResVO.class);
+			System.out.println(errorResVO.getErrorCode() + ": " + errorResVO.getErrorMessage());
+			throw new Exception("安心签服务请求失败");
+		}
+		Tx3203ResVO tx3203ResVO = new ObjectMapper().readValue(response, Tx3203ResVO.class);
+		return tx3203ResVO.getContract().getContractNo();
+	}
+
+	/**
+	 * 设置签名默认信息
+	 *
+	 * @param signInfo
+	 * @param keyword
+	 */
+	public static void setSignInfoDefault(UploadSignInfoVO signInfo, SignKeywordVO keyword) {
+		signInfo.setIsProxySign(PROXY_SIGN_ON);
+		signInfo.setProjectCode(PROJECT_CODE);
+		signInfo.setSignKeyword(keyword);
+	}
+
+	/**
+	 * 获得签名定位关键词对象
+	 *
+	 * @param keyword
+	 * @param offsetX
+	 * @param offsetY
+	 * @param width
+	 * @param height
+	 * @return
+	 */
+	public static SignKeywordVO getSignKeywork(String keyword, String offsetX, String offsetY, String width,
+			String height) {
+		SignKeywordVO signKeyword = new SignKeywordVO();
+		signKeyword.setKeyword(keyword);
+		signKeyword.setOffsetCoordX(offsetX);
+		signKeyword.setOffsetCoordY(offsetY);
+		signKeyword.setImageWidth(width);
+		signKeyword.setImageHeight(height);
+		return signKeyword;
+	}
+
+	/**
+	 * 判断请求是否成功
+	 *
+	 * @param response
+	 * @return
+	 */
+	private static boolean isSucess(String response) {
+		if (response.indexOf("\"head\"") < 0) {
+			return false;
+		}
+		return true;
+	}
+
+	public static void main(String[] args) {
+		proxySwitchOn = true;
+		CertVO certVO = new CertVO();
+		certVO.setUserId("DD25A736C37D345DE05311016B0AB061");
+		try {
+			queryCertificate(certVO);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
 }

+ 100 - 0
eladmin-system/src/main/java/me/zhengjie/base/util/DownloadUtils.java

@@ -1,10 +1,30 @@
 package me.zhengjie.base.util;
 
+import java.io.FileInputStream;
 import java.io.InputStream;
 import java.net.HttpURLConnection;
 import java.net.URL;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.List;
 
+import org.apache.commons.collections.CollectionUtils;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.xxl.job.core.context.XxlJobHelper;
+
+import cfca.trustsign.common.vo.cs.UploadSignInfoVO;
 import cn.hutool.core.io.IoUtil;
+import me.zhengjie.base.config.AppConfigInfo;
+import me.zhengjie.base.util.StatusEnum.StepStatusEnum;
+import me.zhengjie.dao.mybatis.entity.BorrowerEntity;
+import me.zhengjie.dao.mybatis.entity.GuaranteeEntity;
+import me.zhengjie.dao.mybatis.entity.MortgageEntity;
+import me.zhengjie.dao.mybatis.entity.NotaryOfficeEntity;
+import me.zhengjie.dao.mybatis.entity.NotaryOrderEntity;
+import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
+import me.zhengjie.dao.mybatis.entity.SysUserEntity;
+import me.zhengjie.utils.StringUtils;
 
 /**
  * 使用java中的文件流下载网上的图片,保存到本地
@@ -51,4 +71,84 @@ public class DownloadUtils {
 
 	}
 
+	/**
+	 * 公证书电子签名
+	 * 
+	 * @param orderFile
+	 */
+	public static void signNotarization() throws Exception {
+
+		UploadSignInfoVO notaryUserInfo = new UploadSignInfoVO();
+		List<UploadSignInfoVO> notaryUserInfos = new ArrayList<>();
+		//
+		notaryUserInfo.setUserId("E06DAAB5F6894542E05312016B0AC8F1");
+		notaryUserInfo.setSealId("E06DAB4AFAEF4DB7E05311016B0A5154");
+		notaryUserInfo.setLocation("210.74.41.0");
+		notaryUserInfo.setAuthorizationTime("20220214171200");
+		notaryUserInfos.add(notaryUserInfo);
+		notaryUserInfos.add(notaryUserInfo);
+//		UploadSignInfoVO notaryOfficeInfo = new UploadSignInfoVO();
+//		notaryOfficeInfo.setUserId(notaryOffice.getAxqUserId());
+//		notaryOfficeInfo.setSealId(notaryOffice.getAxqSealId());
+//		notaryOfficeInfo.setLocation("210.74.41.1");
+//		notaryOfficeInfo.setAuthorizationTime("20220214171200");
+
+		String path = "E:\\image\\logo\\sqb.pdf";
+		InputStream inputStream = new FileInputStream(path);
+		String fileName = "sqb.pdf";
+	//	String contractNO = CFCACertUtil.uploadMultiSignContract(notaryUserInfos, inputStream, fileName);
+//		System.out.println(contractNO);
+//		orderFile.setAxqContractNo(contractNO);
+//		// 保存合同编号
+//		saveNotarizationInfo(contractNO, orderFile.getId());
+	}
+
+	/**
+	 * 记录合同信息
+	 *
+	 * @param id
+	 */
+	private static void saveNotarizationInfo(String contractNo, int id) {
+		OrderFileEntity saveOrderFile = new OrderFileEntity();
+		saveOrderFile.setId(id);
+		saveOrderFile.setAxqContractNo(contractNo);
+		saveOrderFile.setAxqSignedTime(new Date());
+		saveOrderFile.setUpdateTime(new Date());
+		saveOrderFile.setUpdaterId(777l);
+		System.out.println(saveOrderFile.toString());
+	}
+
+	/**
+	 * 下载公证书
+	 * 
+	 * @param orderFile
+	 */
+	public static void downloadNotarization(OrderFileEntity orderFile) throws Exception {
+		String orderType = StepStatusEnum.getType(orderFile.getContractId());
+		CFCACertUtil.proxySwitchOn = "dev".equals(AppConfigInfo.APP_ENV_TYPE);
+		String uplaodPath = orderFile.getBusinessNo() + "/" + orderType + "/";
+		String path = uplaodPath + "notary-signed-" + orderFile.getBusinessNo() + "/";
+		String filePath = CFCACertUtil.download(path, orderFile.getAxqContractNo());
+		saveAuthNorizationUrlById(filePath, orderFile.getId());
+	}
+
+	/**
+	 * 保存签名文件URL
+	 *
+	 * @param fileUrl
+	 * @param id
+	 */
+	public static void saveAuthNorizationUrlById(String fileUrl, int id) {
+		OrderFileEntity saveOrderFile = new OrderFileEntity();
+		saveOrderFile.setId(id);
+		saveOrderFile.setSignedPdfUrl(fileUrl);
+		saveOrderFile.setUpdaterId(777l);
+		saveOrderFile.setUpdateTime(new Date());
+		// orderFileMapper.updateById(saveOrderFile);
+	}
+
+	public static void main(String[] args) throws Exception {
+		signNotarization();
+	}
+
 }

+ 178 - 0
eladmin-system/src/main/java/me/zhengjie/base/util/HttpUtil.java

@@ -0,0 +1,178 @@
+package me.zhengjie.base.util;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import java.io.PrintWriter;
+import java.net.URL;
+import java.net.URLConnection;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.alibaba.fastjson.JSONObject;
+
+import cfca.trustsign.common.vo.cs.SignKeywordVO;
+import cfca.trustsign.common.vo.cs.UploadSignInfoVO;
+
+public class HttpUtil {
+
+	/**
+	 * 默认超时时间为30秒
+	 */
+	private static int DEFAULT_TIME_OUT = 1800000000;
+
+	//
+
+	/**
+	 * jdk 原生 http post 请求,默认超时时间为30秒
+	 *
+	 * @param url         请求地址
+	 * @param body        入参String
+	 * @param contentType 内容类型
+	 * @param charSet     编码格式
+	 * @return respone的body
+	 */
+	public static String sendPost(String url, String json) {
+		return sendPost(url, json, DEFAULT_TIME_OUT);
+	}
+
+	/**
+	 * JDK原生post请求
+	 *
+	 * @param url         访问地址
+	 * @param body        request请求体
+	 * @param contentType 请求类型
+	 * @param charSet     编码格式
+	 * @param timeOut     超时时间,单位毫秒
+	 * @return 响应体string
+	 */
+	public static String sendPost(String url, String body, int timeOut) {
+		URLConnection conn = null;
+		try {
+			URL realUrl = new URL(url);
+			// 打开和URL之间的连接
+			conn = realUrl.openConnection();
+			// 设置通用的请求头属性
+			conn.setRequestProperty("Content-Type", "application/json");
+			conn.setRequestProperty("accept", "*/*");
+			conn.setRequestProperty("connection", "Keep-Alive");
+			conn.setRequestProperty("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1;SV1)");
+			conn.setRequestProperty("charsert", "utf-8");
+			conn.setConnectTimeout(timeOut);
+			conn.setReadTimeout(timeOut);
+			//
+
+			// 发送POST请求必须设置如下两行
+			conn.setDoOutput(true);
+			conn.setDoInput(true);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		return sendRequest(conn, body, "utf-8");
+	}
+
+	private static String sendRequest(URLConnection conn, String body, String charSet) {
+
+		PrintWriter out = null;
+		InputStreamReader ir;
+		BufferedReader in = null;// 读取响应输入流
+		StringBuilder stringBuilder = null;
+
+		try {
+			if (body != null) {
+				out = new PrintWriter(conn.getOutputStream()); // 用PrintWriter进行包装
+				out.println(body);
+				// flush输出流的缓冲
+				out.flush();
+			}
+
+			ir = new InputStreamReader(conn.getInputStream(), charSet);
+			in = new BufferedReader(ir);
+			String line;
+			stringBuilder = new StringBuilder();
+			while ((line = in.readLine()) != null) {
+				stringBuilder.append(line);
+			}
+		} catch (IOException e1) {
+			e1.printStackTrace();
+		}
+		// 使用finally块来关闭输出流、输入流
+		finally {
+			try {
+				if (out != null) {
+					out.close();
+				}
+				if (in != null) {
+					in.close();
+				}
+			} catch (Exception ex) {
+				ex.printStackTrace();
+			}
+		}
+
+		if (stringBuilder == null)
+			return null;
+		return stringBuilder.toString();
+	}
+
+	public static void main(String[] args) throws Exception {
+
+	
+		int i = 0;
+		String pdf = "gzs.pdf";
+
+		String localUrl = "https://flowbb.show.xjrkj.com/demo";
+		// String localUrl = "http://localhost:8000/demo";
+
+		List<UploadSignInfoVO> notaryUserInfos = new ArrayList<>();
+		// --------------------------------------------------------------------------------------
+//		UploadSignInfoVO xj = new UploadSignInfoVO();
+//		xj.setUserId("E06DAAB5F6894542E05312016B0AC8F1");
+//		xj.setSealId("E06DAB4AFAEF4DB7E05311016B0A5154");
+//		xj.setLocation("210.74.41.0");
+//		xj.setAuthorizationTime("20220214171200");
+//		notaryUserInfos.add(xj);
+//		UploadSignInfoVO ttt = new UploadSignInfoVO();
+//		ttt.setUserId("E658B207485F141AE05311016B0A5F19");
+//		ttt.setSealId("E658C5DBBAF1340DE05311016B0A3C4D");
+//		ttt.setLocation("210.74.41.0");
+//		ttt.setAuthorizationTime("20220214171200");
+//		notaryUserInfos.add(ttt);
+//		UploadSignInfoVO wcc = new UploadSignInfoVO();
+//		wcc.setUserId("E150B42F789F53D8E05311016B0A24B0");
+//		wcc.setSealId("E150B90286FA6E31E05312016B0A03F2");
+//		wcc.setLocation("210.74.41.0");
+//		wcc.setAuthorizationTime("20220214171200");
+//		notaryUserInfos.add(wcc);
+//		for (UploadSignInfoVO user : notaryUserInfos) {
+//			String x = String.valueOf(10 + i * 70);
+//			i++;
+//			SignKeywordVO keywordNotaryUser = CFCACertUtil.getSignKeywork("签章:", x, "0", "80", "40");
+//			CFCACertUtil.setSignInfoDefault(user, keywordNotaryUser);
+//		}
+		// --------------------------------------------------------------------------------------
+//		SignKeywordVO keywordNotaryOffice = CFCACertUtil.getSignKeywork("签章", "0", "0", "150", "150");
+//		if (notaryOffice != null) {
+//			setSignInfoDefault(notaryOffice, keywordNotaryOffice);
+//			signInfos.add(notaryOffice);
+//		}
+		
+
+		String result = HttpUtil.sendPost(localUrl + "/notarySign?fileName=" + pdf,
+				JSONObject.toJSONString(notaryUserInfos));
+		JSONObject jsonObj = JSONObject.parseObject(result);
+		System.out.println(jsonObj.getString("msg") + ".pdf");
+		Map<String, String> param = new HashMap<String, String>();
+		param.put("contractNo", jsonObj.getString("msg"));
+		result = HttpUtil.sendPost(localUrl + "/download", JSONObject.toJSONString(param));
+		System.out.println(result);
+//		System.out.println("用户近6个月平均话费评分:" + result);
+
+	}
+}