第三方合同接口示例记录
public static String contractSign(Contract contract,Userbasicsinfo loanUser,Userbasicsinfo tenderUser,HttpServletRequest request){ String osName = System.getProperties().getProperty("os.name").toLowerCase(); String outputPath = null; String downloadPath = null; if(osName.startsWith("win")){ outputPath = "D:\\contract_" + contract.getContractNo() + ".doc"; downloadPath = "D:\\contract_" + contract.getContractNo() + ".pdf"; }else{ File dir = new File("/home/p2ptemp/"); if(!dir.exists()){ dir.mkdirs(); } outputPath = "/home/p2ptemp/contract_" + contract.getContractNo() + ".doc"; downloadPath = "/home/p2ptemp/contract_" + contract.getContractNo() + ".pdf"; } try { boolean bool = HtmlToDoc.writeWordFileString(getContractEmptyHtml(contract.getContent()), outputPath); if(bool){ //2. 发起人签章 Userrelationinfo loanRela = loanUser.getUserrelationinfo(); String response = FddClient.invokeSyncPersonAuto(loanUser.getName(),loanRela.getEmail() , loanRela.getCardId(), loanRela.getPhone()); Map<String,String> map = JSON.parseObject(response, Map.class); String customer_id = map.get("customer_id"); String cnum = "ZC"+System.currentTimeMillis(); response = FddClient.invokeUploadDocs(cnum, new File(outputPath), "", ".doc"); response = FddClient.invokeExtSignAuto("ZCSIGN"+cnum, customer_id, "", "", "1", "3", cnum, "xxx合同", loanUser.getName(), "", ""); map = JSON.parseObject(response, Map.class); String downloadUrl = map.get("download_url"); //2.5 下载 FddDownload.download(downloadUrl, downloadPath); response = FddClient.invokeContractFilling(cnum); //3. 投资人签章 Userrelationinfo tenderRela = tenderUser.getUserrelationinfo(); response = FddClient.invokeSyncPersonAuto(tenderUser.getName(),tenderRela.getEmail() , tenderRela.getCardId(), tenderRela.getPhone()); map = JSON.parseObject(response, Map.class); customer_id = map.get("customer_id"); cnum = "ZC"+System.currentTimeMillis(); response = FddClient.invokeUploadDocs(cnum, new File(downloadPath), "", ".pdf"); response = FddClient.invokeExtSignAuto("ZCSIGN"+cnum, customer_id, "", "", "1", "3", cnum, "xxx合同", tenderUser.getName(), "", ""); map = JSON.parseObject(response, Map.class); downloadUrl = map.get("download_url"); //4. 合同归档 response = FddClient.invokeContractFilling(cnum); return downloadUrl; } } catch (Exception e) { e.printStackTrace(); } return null; } public static String getContractEmptyHtml(String content) { String path = ProjectPathUtils.getClassesPath(); path = path.replaceAll("/classes", "")+"views/contract/detail.jsp"; if(path.indexOf("/")!=0&&path.indexOf(":")!=1){ path = "/"+path; } File file = new File(path); FileInputStream fis = null; InputStreamReader read = null; BufferedReader bufferedReader = null; try{ fis = new FileInputStream(file); read = new InputStreamReader(fis,"UTF-8"); bufferedReader = new BufferedReader(read); StringBuilder lineTxt = new StringBuilder(""); String tempLine = null; while((tempLine = bufferedReader.readLine()) != null){ lineTxt.append(tempLine); } String returnValue = lineTxt.toString(); int index = returnValue.indexOf("<!DOCTYPE "); returnValue = returnValue.substring(index, returnValue.length()).replace("${content}", content); return returnValue; }catch(Exception ex){ } return null; }
以上代码在工作上使用到了,记录一下下
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?