|
@@ -0,0 +1,571 @@
|
|
|
+package com.huyi.service.credit.controller;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.huyi.service.base.entity.*;
|
|
|
+import com.huyi.service.base.service.*;
|
|
|
+import com.huyi.service.constant.FileConstants;
|
|
|
+import com.spire.doc.Document;
|
|
|
+import com.spire.doc.FileFormat;
|
|
|
+import com.tianhu.common.core.utils.AmtUtil;
|
|
|
+import com.tianhu.common.core.utils.CommonUtil;
|
|
|
+import com.tianhu.common.core.utils.DateUtils;
|
|
|
+import com.tianhu.common.core.utils.poi.WordUtil;
|
|
|
+import com.tianhu.common.core.web.controller.BaseController;
|
|
|
+import com.tianhu.common.core.web.domain.AjaxResult;
|
|
|
+import com.tianhu.common.log.annotation.Log;
|
|
|
+import com.tianhu.common.log.enums.BusinessType;
|
|
|
+import com.tianhu.common.security.annotation.PreAuthorize;
|
|
|
+import com.tianhu.common.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.domain.SysUser;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import sun.misc.BASE64Encoder;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 融信相关操作
|
|
|
+ * xuefy
|
|
|
+ * 2021-08-24
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/ownCreditHandle")
|
|
|
+public class CreditHandleController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+ //融信服务类
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceInfService financeInfService;
|
|
|
+ //供应商授信服务类
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceSupplierQuotaService financeSupplierQuotaService;
|
|
|
+ //融信和应收账款的关系
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceBillRelService financeBillRelService;
|
|
|
+ //授信和合同的关系表
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceQuotaConRelService quotaConRelService;
|
|
|
+ //合同和合同的关系表
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceProConRelService proConRelService;
|
|
|
+ //合同服务类
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceContractService contractService;
|
|
|
+ //文件服务类
|
|
|
+ @Autowired
|
|
|
+ private IPubFileInfService fileInfService;
|
|
|
+ //公司服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysCompanyService companyService;
|
|
|
+ //银行账户表
|
|
|
+ @Autowired
|
|
|
+ private IPayBankAccInfService bankAccInfService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 融信确权
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "credit:credit:approve")
|
|
|
+ @Log(title = "融信管理", businessType = BusinessType.UPDATE)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult approve(@RequestBody Map<String,Object> map)throws Exception
|
|
|
+ {
|
|
|
+ //获取融信编号
|
|
|
+ String zfiId = CommonUtil.objToString(map.get("zfiId"));
|
|
|
+ //获取融信类型
|
|
|
+ String zfiCreateType = CommonUtil.objToString(map.get("zfiCreateType"));
|
|
|
+ //获取通过或者拒绝
|
|
|
+ String flag = CommonUtil.objToString(map.get("flag"));
|
|
|
+ ZcFinanceInf financeInf = new ZcFinanceInf();
|
|
|
+ //编号
|
|
|
+ financeInf.setZfiId(zfiId);
|
|
|
+ //供应商申请
|
|
|
+ if("0".equals(zfiCreateType)){
|
|
|
+ //获取授信额度
|
|
|
+ //供应商企业授信额度
|
|
|
+ String zfiSupplierQuotaId = CommonUtil.objToString(map.get("zfiSupplierQuotaId"));
|
|
|
+ if(!CommonUtil.isEmpty(zfiSupplierQuotaId)){
|
|
|
+ financeInf.setZfiSupplierQuotaId(zfiSupplierQuotaId);
|
|
|
+ //获取供应商对应的核心授信额度
|
|
|
+ ZcFinanceSupplierQuota supplierQuota = financeSupplierQuotaService.getById(zfiSupplierQuotaId);
|
|
|
+ if(supplierQuota == null){
|
|
|
+ throw new Exception("获取供应商授信额度失败");
|
|
|
+ }
|
|
|
+ String zfsqCoreQuotaId = supplierQuota.getZfsqCoreQuotaId();
|
|
|
+ //核心授信额度
|
|
|
+ financeInf.setZfiCoreQuotaId(zfsqCoreQuotaId);
|
|
|
+ }
|
|
|
+ //承诺付款日
|
|
|
+ String zfiExpireDate = CommonUtil.objToString(map.get("zfiExpireDate"));
|
|
|
+ //签发有效期
|
|
|
+ String zfiEffectiveDate = CommonUtil.objToString(map.get("zfiEffectiveDate"));
|
|
|
+ if("00".equals(flag)){
|
|
|
+ if(CommonUtil.isEmpty(zfiEffectiveDate)){
|
|
|
+ throw new Exception("请选择签发有效期");
|
|
|
+ }
|
|
|
+ if(CommonUtil.isEmpty(zfiExpireDate)){
|
|
|
+ throw new Exception("请选择承诺付款日");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(!CommonUtil.isEmpty(zfiEffectiveDate)){
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date date = simpleDateFormat.parse(zfiEffectiveDate);
|
|
|
+ financeInf.setZfiEffectiveDate(date);
|
|
|
+
|
|
|
+ }
|
|
|
+ if(!CommonUtil.isEmpty(zfiExpireDate)){
|
|
|
+ SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ Date signDate = simpleDateFormat.parse(zfiExpireDate);
|
|
|
+ financeInf.setZfiExpireDate(signDate);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //通过
|
|
|
+ if("00".equals(flag)){
|
|
|
+ //申请
|
|
|
+ if("0".equals(zfiCreateType)){
|
|
|
+ //待签收
|
|
|
+ financeInf.setZfiStatus("01");
|
|
|
+ }else if("2".equals(zfiCreateType)){
|
|
|
+ //已生效
|
|
|
+ financeInf.setZfiStatus("02");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else if("01".equals(flag)){//拒绝
|
|
|
+ //已失效
|
|
|
+ financeInf.setZfiStatus("03");
|
|
|
+ }
|
|
|
+ financeInfService.updateById(financeInf);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 补充资料
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "credit:credit:addInfor")
|
|
|
+ @Log(title = "融信", businessType = BusinessType.UPDATE)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult addinfor(@RequestBody Map<String,Object> map)throws Exception
|
|
|
+ {
|
|
|
+ //获取融信编号
|
|
|
+ String zfiId = CommonUtil.objToString(map.get("zfiId"));
|
|
|
+ //获取应收账款
|
|
|
+ List<Map<String,String>> ticketList = (List<Map<String, String>>) map.get("ticketList");
|
|
|
+ if(ticketList.size() < 1){
|
|
|
+ throw new Exception("请选择应收账款");
|
|
|
+ }
|
|
|
+ if(ticketList.size() > 1){
|
|
|
+ //获取预计还款日期
|
|
|
+ String zbiPayDate = ticketList.get(0).get("zbiPayDate");
|
|
|
+ for(int i = 0 ; i < ticketList.size();i++){
|
|
|
+ if(!zbiPayDate.equals(ticketList.get(i).get("zbiPayDate"))){
|
|
|
+ throw new Exception("请选择预计还款日期相同的应收账款");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ //删除融信之前对应的应收账款
|
|
|
+ LambdaQueryWrapper<ZcFinanceBillRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ relLambdaQueryWrapper.eq(ZcFinanceBillRel::getZfbrFinanceId,zfiId);
|
|
|
+ financeBillRelService.deleteZcFinanceBillRel(relLambdaQueryWrapper);
|
|
|
+ for(int i = 0 ;i < ticketList.size();i++){
|
|
|
+ //获取收付款编号
|
|
|
+ String billId = ticketList.get(i).get("zbiId");
|
|
|
+ ZcFinanceBillRel rel = new ZcFinanceBillRel();
|
|
|
+ rel.setZfbrFinanceId(zfiId);
|
|
|
+ rel.setZfbrBillId(billId);
|
|
|
+ financeBillRelService.createZcFinanceBillRel(rel);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 签收
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PreAuthorize(hasPermi = "credit:credit:signFor")
|
|
|
+ @Log(title = "融信", businessType = BusinessType.UPDATE)
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @PutMapping("/signFor")
|
|
|
+ public AjaxResult signFor(@RequestBody Map<String,Object> map)throws Exception
|
|
|
+ {
|
|
|
+ //获取融信编号
|
|
|
+ String zfiId = CommonUtil.objToString(map.get("zfiId"));
|
|
|
+ //获取通过还是拒绝
|
|
|
+ String flag = CommonUtil.objToString(map.get("flag"));
|
|
|
+ //获取类型
|
|
|
+ String zfiCreateType = CommonUtil.objToString(map.get("zfiCreateType"));
|
|
|
+ ZcFinanceInf financeInf = new ZcFinanceInf();
|
|
|
+ //获取时间
|
|
|
+ Date time = DateUtils.getNowDate();
|
|
|
+ //获取此操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser user = userInfo.getSysUser();
|
|
|
+ //编号
|
|
|
+ financeInf.setZfiId(zfiId);
|
|
|
+ //修改时间
|
|
|
+ financeInf.setUpdateTime(time);
|
|
|
+ //获取用户编号
|
|
|
+ String userId = user.getUserId()+"";
|
|
|
+ //修改人
|
|
|
+ financeInf.setUpdateBy(userId);
|
|
|
+ //通过
|
|
|
+ if("00".equals(flag)){
|
|
|
+ //核心开立
|
|
|
+ if("1".equals(zfiCreateType)){
|
|
|
+ //获取收付款
|
|
|
+ List<Map<String,String>> ticketList = (List<Map<String, String>>) map.get("ticketList");
|
|
|
+ if(ticketList.size() < 1){
|
|
|
+ throw new Exception("请选择应收账款");
|
|
|
+ }
|
|
|
+ //删除融信之前对应的应收账款
|
|
|
+ LambdaQueryWrapper<ZcFinanceBillRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ relLambdaQueryWrapper.eq(ZcFinanceBillRel::getZfbrFinanceId,zfiId);
|
|
|
+ financeBillRelService.deleteZcFinanceBillRel(relLambdaQueryWrapper);
|
|
|
+ for(int i = 0 ;i < ticketList.size();i++){
|
|
|
+ //获取收付款编号
|
|
|
+ String billId = ticketList.get(i).get("zbiId");
|
|
|
+ ZcFinanceBillRel rel = new ZcFinanceBillRel();
|
|
|
+ rel.setZfbrFinanceId(zfiId);
|
|
|
+ rel.setZfbrBillId(billId);
|
|
|
+ financeBillRelService.createZcFinanceBillRel(rel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //已生效
|
|
|
+ financeInf.setZfiStatus("02");
|
|
|
+ //签收日期
|
|
|
+ //获取当前时间
|
|
|
+ Date currentTime = DateUtils.getNowDate();
|
|
|
+ financeInf.setZfiSignDate(currentTime);
|
|
|
+ }else if("01".equals(flag)){
|
|
|
+ //已失效
|
|
|
+ financeInf.setZfiStatus("03");
|
|
|
+ }
|
|
|
+ financeInfService.updateById(financeInf);
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取合同文件
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PutMapping("/getContractFile")
|
|
|
+ public AjaxResult getContract(@RequestBody Map<String,Object> map)throws Exception
|
|
|
+ {
|
|
|
+ //获取此操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ //存放合同编号
|
|
|
+ List<String> contractIdList = new ArrayList<>();
|
|
|
+ //获取授信编号
|
|
|
+ String zfpcrId = CommonUtil.objToString(map.get("zfpcrId"));
|
|
|
+ //获取产品
|
|
|
+ String zfpcrProductId = CommonUtil.objToString(map.get("zfpcrProductId"));
|
|
|
+ //获取节点
|
|
|
+ String code = CommonUtil.objToString(map.get("code"));
|
|
|
+ //获取接收方
|
|
|
+ String zfiSupplierId = CommonUtil.objToString(map.get("zfiSupplierId"));
|
|
|
+ //开立方
|
|
|
+ String zfiCoreId = CommonUtil.objToString(map.get("zfiCoreId"));
|
|
|
+ //金额
|
|
|
+ String zfiAmount = CommonUtil.objToString(map.get("zfiAmount"));
|
|
|
+ //承诺还款日期
|
|
|
+ String zfiExpireDate = CommonUtil.objToString(map.get("zfiExpireDate"));
|
|
|
+ //还款编号
|
|
|
+ String zfiPaymentNumber = CommonUtil.objToString(map.get("zfiPaymentNumber"));
|
|
|
+ //获取开立方
|
|
|
+ String openName = "";
|
|
|
+ //获取开立方的社会统一码
|
|
|
+ String openCode = "";
|
|
|
+ //开户银行
|
|
|
+ String openBank = "";
|
|
|
+ //账号
|
|
|
+ String openAccount = "";
|
|
|
+ //获取接收方
|
|
|
+ String receiverName = "";
|
|
|
+ //获取开立方的社会统一码
|
|
|
+ String receiverCode = "";
|
|
|
+ //开户银行
|
|
|
+ String receiverBank = "";
|
|
|
+ //账号
|
|
|
+ String receiverAccount = "";
|
|
|
+ //大写金额
|
|
|
+ String zfiAmountBig = "";
|
|
|
+ //起止日期
|
|
|
+ String stopDate = "";
|
|
|
+ SysCompany company = companyService.getById(zfiCoreId);
|
|
|
+ if(company != null){
|
|
|
+ //企业名称
|
|
|
+ openName = company.getScyName();
|
|
|
+ //社会统一代码
|
|
|
+ openCode = company.getScySocialCode();
|
|
|
+ //查询银行账号
|
|
|
+ LambdaQueryWrapper<PayBankAccInf> bankAccInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ bankAccInfLambdaQueryWrapper.eq(PayBankAccInf::getPbaiCstno,zfiCoreId);
|
|
|
+ //基本户
|
|
|
+ bankAccInfLambdaQueryWrapper.eq(PayBankAccInf::getPbaiBasic,"1");
|
|
|
+ //正常
|
|
|
+ bankAccInfLambdaQueryWrapper.eq(PayBankAccInf::getPbaiStatus,"0");
|
|
|
+ //查询
|
|
|
+ List<PayBankAccInf> bankAccInfList = bankAccInfService.findPayBankAccInfs(bankAccInfLambdaQueryWrapper);
|
|
|
+ if(bankAccInfList.size() > 0){
|
|
|
+ //银行名称
|
|
|
+ openBank = bankAccInfList.get(0).getPbaiBankName();
|
|
|
+ //账号
|
|
|
+ openAccount = bankAccInfList.get(0).getPbaiBankaccountId();
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ SysCompany supplierCompany = companyService.getById(zfiSupplierId);
|
|
|
+ if(supplierCompany != null){
|
|
|
+ //企业名称
|
|
|
+ receiverName = supplierCompany.getScyName();
|
|
|
+ //社会统一代码
|
|
|
+ receiverCode = supplierCompany.getScySocialCode();
|
|
|
+ //查询银行账号
|
|
|
+ LambdaQueryWrapper<PayBankAccInf> bankAccInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ bankAccInfLambdaQueryWrapper.eq(PayBankAccInf::getPbaiCstno,zfiSupplierId);
|
|
|
+ //基本户
|
|
|
+ bankAccInfLambdaQueryWrapper.eq(PayBankAccInf::getPbaiBasic,"1");
|
|
|
+ //正常
|
|
|
+ bankAccInfLambdaQueryWrapper.eq(PayBankAccInf::getPbaiStatus,"0");
|
|
|
+ //查询
|
|
|
+ List<PayBankAccInf> bankAccInfList = bankAccInfService.findPayBankAccInfs(bankAccInfLambdaQueryWrapper);
|
|
|
+ if(bankAccInfList.size() > 0){
|
|
|
+ //银行名称
|
|
|
+ receiverBank = bankAccInfList.get(0).getPbaiBankName();
|
|
|
+ //账号
|
|
|
+ receiverAccount = bankAccInfList.get(0).getPbaiBankaccountId();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取签发金额大写
|
|
|
+ zfiAmountBig = AmtUtil.formatCurrency(zfiAmount);
|
|
|
+ //承诺日期
|
|
|
+ //获取当前时间
|
|
|
+ Date date = DateUtils.getNowDate();
|
|
|
+ //格式化当前日期
|
|
|
+ String currecntDate = DateUtils.parseDateToStr("yyyy年MM月dd日",date);
|
|
|
+ Date expireDate = DateUtils.StrToDate(zfiExpireDate);
|
|
|
+ String expireDateA = DateUtils.parseDateToStr("yyyy年MM月dd日",expireDate);
|
|
|
+ stopDate = currecntDate +"-"+expireDateA;
|
|
|
+ //查询授信额度下的文件
|
|
|
+ LambdaQueryWrapper<ZcFinanceQuotaConRel> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper.eq(ZcFinanceQuotaConRel::getZfqcrCreditId,zfpcrId);
|
|
|
+ List<ZcFinanceQuotaConRel> relList = quotaConRelService.findZcFinanceQuotaConRels(lambdaQueryWrapper);
|
|
|
+ if(relList.size() > 0 ){
|
|
|
+ //提取合同编号
|
|
|
+ contractIdList = CommonUtil.getIdFromList(relList,"zfqcrContractId");
|
|
|
+ }else if(relList.size() == 0 ){
|
|
|
+ //授信额度下没有合同则查询产品下关联的合同
|
|
|
+ LambdaQueryWrapper<ZcFinanceProConRel> proConRelLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ proConRelLambdaQueryWrapper.eq(ZcFinanceProConRel::getZfpcrProductId,zfpcrProductId);
|
|
|
+ List<ZcFinanceProConRel> proConRelsList = proConRelService.findZcFinanceProConRels(proConRelLambdaQueryWrapper);
|
|
|
+ if(proConRelsList.size() > 0 ){
|
|
|
+ //提取合同编号
|
|
|
+ contractIdList = CommonUtil.getIdFromList(proConRelsList,"zfpcrContractId");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //返回
|
|
|
+ Map<String,Object> p = new HashMap<>();
|
|
|
+ //文件信息
|
|
|
+ List<Map<String,String>> list = new ArrayList<>();
|
|
|
+ List<PubFileInf> fileInfList = new ArrayList<>();
|
|
|
+ p.put("list",list);
|
|
|
+ if(contractIdList.size() < 1){
|
|
|
+ return AjaxResult.success(p);
|
|
|
+ }else{
|
|
|
+ //查询合同
|
|
|
+ LambdaQueryWrapper<ZcFinanceContract> contractLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ contractLambdaQueryWrapper.in(ZcFinanceContract::getZfcId,contractIdList);
|
|
|
+ contractLambdaQueryWrapper.eq(ZcFinanceContract::getZfcNode,code);
|
|
|
+ List<ZcFinanceContract> contractList = contractService.findZcFinanceContracts(contractLambdaQueryWrapper);
|
|
|
+ if(contractList.size() > 0 ){
|
|
|
+ //提取文件编号
|
|
|
+ List<String> fileIdList = CommonUtil.getIdFromList(contractList,"zfcFile");
|
|
|
+ LambdaQueryWrapper<PubFileInf> fileInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fileInfLambdaQueryWrapper.in(PubFileInf::getPfiFileId,fileIdList);
|
|
|
+ fileInfLambdaQueryWrapper.eq(PubFileInf::getPfiIsDel,"00");
|
|
|
+ List<PubFileInf> fileList = fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(fileInfList.size() > 0 ){
|
|
|
+ //提取所有的文件url
|
|
|
+ List<String> urlList = CommonUtil.getIdFromList(list,"pfiFileUrl");
|
|
|
+ //提取文件名
|
|
|
+ List<String> fileNameList = CommonUtil.getIdFromList(list,"pfiFileName");
|
|
|
+ for(int i =0 ; i < urlList.size() ;i++){
|
|
|
+ //替换word文档中的变量
|
|
|
+ String directory = FileConstants.REMOTE_FILE_PATH;
|
|
|
+ //文件下载
|
|
|
+ String filePath = downloadFile(urlList.get(i),fileNameList.get(i));
|
|
|
+ //往word中填充数据
|
|
|
+ Map<String,Object> ps = new HashMap<>();
|
|
|
+ //开立方
|
|
|
+ ps.put("openName",openName);
|
|
|
+ //开立方社会统一代码
|
|
|
+ ps.put("openCode",openCode);
|
|
|
+ //开立方银行
|
|
|
+ ps.put("openBank",openBank);
|
|
|
+ //开立方账号
|
|
|
+ ps.put("openAccount",openAccount);
|
|
|
+ //接收方
|
|
|
+ ps.put("receiverName",receiverName);
|
|
|
+ //接收方社会统一代码
|
|
|
+ ps.put("receiverCode",receiverCode);
|
|
|
+ //接收方银行
|
|
|
+ ps.put("receiverBank",receiverBank);
|
|
|
+ //接收方账号
|
|
|
+ ps.put("receiverAccount",receiverAccount);
|
|
|
+ //小写金额
|
|
|
+ ps.put("zfiAmount",zfiAmount);
|
|
|
+ //大写金额
|
|
|
+ ps.put("zfiAmountBig",zfiAmountBig);
|
|
|
+ //起止日期
|
|
|
+ ps.put("stopDate",stopDate);
|
|
|
+ //当前日期
|
|
|
+ ps.put("currecntDate",currecntDate);
|
|
|
+ //还款编号
|
|
|
+ ps.put("zfiPaymentNumber",zfiPaymentNumber);
|
|
|
+ //调用替换word中的变量
|
|
|
+ WordUtil.wordTemplate(filePath,filePath,ps);
|
|
|
+ //加载word示例文档
|
|
|
+ Document doc = new Document();
|
|
|
+ doc.loadFromFile(filePath);
|
|
|
+ //保存为PDF格式
|
|
|
+ doc.saveToFile(directory + fileNameList.get(i) +date+ ".pdf", FileFormat.PDF);
|
|
|
+ filePath = directory + fileNameList.get(i) +date+ ".pdf";
|
|
|
+ File pdfFile = new File(filePath);
|
|
|
+ FileInputStream inputFile = new FileInputStream(pdfFile);
|
|
|
+ byte[] buffer = new byte[(int)pdfFile.length()];
|
|
|
+ inputFile.read(buffer);
|
|
|
+ inputFile.close();
|
|
|
+ String base64 = new BASE64Encoder().encode(buffer);
|
|
|
+ //声明map
|
|
|
+ Map<String,String> pm = new HashMap<>();
|
|
|
+ pm.put("filePath",filePath);
|
|
|
+ pm.put("base64",base64);
|
|
|
+ list.add(pm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ p.put("list",list);
|
|
|
+ return AjaxResult.success(p);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载远程文件并保存到本地
|
|
|
+ * @param remoteFilePath 远程文件路径
|
|
|
+ * @param localFilePath 本地文件路径(带文件名)
|
|
|
+ */
|
|
|
+ public static String downloadFile(String remoteFilePath, String localFilePath)
|
|
|
+ {
|
|
|
+ URL urlfile = null;
|
|
|
+ HttpURLConnection httpUrl = null;
|
|
|
+ BufferedInputStream bis = null;
|
|
|
+ BufferedOutputStream bos = null;
|
|
|
+
|
|
|
+ File path = new File(FileConstants.REMOTE_FILE_PATH);
|
|
|
+ //判断文件是否存在
|
|
|
+ if(!path.exists()){
|
|
|
+ path.mkdirs();
|
|
|
+ }
|
|
|
+ File f = new File(FileConstants.REMOTE_FILE_PATH + localFilePath);
|
|
|
+ try
|
|
|
+ {
|
|
|
+ urlfile = new URL(remoteFilePath);
|
|
|
+ httpUrl = (HttpURLConnection)urlfile.openConnection();
|
|
|
+ httpUrl.connect();
|
|
|
+ bis = new BufferedInputStream(httpUrl.getInputStream());
|
|
|
+ bos = new BufferedOutputStream(new FileOutputStream(f));
|
|
|
+ int len = 2048;
|
|
|
+ byte[] b = new byte[len];
|
|
|
+ while ((len = bis.read(b)) != -1)
|
|
|
+ {
|
|
|
+ bos.write(b, 0, len);
|
|
|
+ }
|
|
|
+ bos.flush();
|
|
|
+ bis.close();
|
|
|
+ httpUrl.disconnect();
|
|
|
+ }
|
|
|
+ catch (Exception e)
|
|
|
+ {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ finally
|
|
|
+ {
|
|
|
+ try
|
|
|
+ {
|
|
|
+ bis.close();
|
|
|
+ bos.close();
|
|
|
+ }
|
|
|
+ catch (IOException e)
|
|
|
+ {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return f.getAbsolutePath();
|
|
|
+ }
|
|
|
+ /* public static void main(String[] args) {
|
|
|
+ String date = DateUtils.dateTimeNow();
|
|
|
+ List<String> urlList = new ArrayList<>();
|
|
|
+ urlList.add("http://huyi.img.minpay.cc/file/000000/doc/20210823/8a2ea656-8f98-4d37-98a1-132c1d4fc768.doc");
|
|
|
+ //提取文件名
|
|
|
+ List<String> fileNameList = new ArrayList<>();
|
|
|
+ fileNameList.add("招采文件.doc");
|
|
|
+ for(int i =0 ; i < urlList.size() ;i++){
|
|
|
+ String directory = FileConstants.REMOTE_FILE_PATH;
|
|
|
+ //文件下载
|
|
|
+ String filePath = downloadFile(urlList.get(i),fileNameList.get(i));
|
|
|
+ //加载word示例文档
|
|
|
+ Document doc = new Document();
|
|
|
+ doc.loadFromFile(filePath);
|
|
|
+ //保存为PDF格式
|
|
|
+ doc.saveToFile(directory + fileNameList.get(i) +date+ ".pdf", FileFormat.PDF);
|
|
|
+ filePath = directory + fileNameList.get(i) +date+ ".pdf";
|
|
|
+ System.out.println("转换成功");
|
|
|
+ }
|
|
|
+ }*/
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|