|
|
@@ -0,0 +1,808 @@
|
|
|
+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.common.cfcaCommon.ICfcaFaceAuthService;
|
|
|
+import com.huyi.service.common.flowable.service.ApprovalService;
|
|
|
+import com.huyi.service.constant.FileConstants;
|
|
|
+import com.keao.tianhu.core.util.AmtUtil;
|
|
|
+import com.spire.doc.Document;
|
|
|
+import com.spire.doc.FileFormat;
|
|
|
+import com.tianhu.common.core.cfca.AxqCommonUtil;
|
|
|
+import com.tianhu.common.core.cfca.CfcaUtil;
|
|
|
+import com.tianhu.common.core.domain.R;
|
|
|
+import com.tianhu.common.core.utils.*;
|
|
|
+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.security.service.TokenService;
|
|
|
+import com.tianhu.system.api.RemoteFileService;
|
|
|
+import com.tianhu.system.api.domain.SysUser;
|
|
|
+import com.tianhu.system.api.model.LoginUser;
|
|
|
+import org.apache.commons.io.IOUtils;
|
|
|
+import org.json.JSONObject;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.mock.web.MockMultipartFile;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.multipart.MultipartFile;
|
|
|
+import sun.misc.BASE64Encoder;
|
|
|
+
|
|
|
+import java.io.*;
|
|
|
+import java.net.HttpURLConnection;
|
|
|
+import java.net.URL;
|
|
|
+import java.util.*;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 短信相关
|
|
|
+ * xuefy
|
|
|
+ * 2021-08-30
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/ownMessage")
|
|
|
+public class OwnMessageController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private TokenService tokenService;
|
|
|
+ //经办人关系服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysUserCompanyRelService relService;
|
|
|
+ //用户信息服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysUserService userService;
|
|
|
+ //人脸识别服务类
|
|
|
+ @Autowired
|
|
|
+ private ICfcaFaceAuthService faceAuthService;
|
|
|
+ //融信服务类
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceInfService financeInfService;
|
|
|
+ //公司服务类
|
|
|
+ @Autowired
|
|
|
+ private ISysCompanyService companyService;
|
|
|
+ //银行账户表
|
|
|
+ @Autowired
|
|
|
+ private IPayBankAccInfService bankAccInfService;
|
|
|
+ //授信和合同的关系表
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceQuotaConRelService quotaConRelService;
|
|
|
+ //产品和合同的关系表
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceProConRelService proConRelService;
|
|
|
+ //合同服务类
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceContractService contractService;
|
|
|
+ //文件服务类
|
|
|
+ @Autowired
|
|
|
+ private IPubFileInfService fileInfService;
|
|
|
+ @Autowired
|
|
|
+ private RemoteFileService remoteFileService;
|
|
|
+ //融信和文件的关系服务类
|
|
|
+ @Autowired
|
|
|
+ private IZcFinanceFileRelService financeFileRelService;
|
|
|
+ //审批服务类
|
|
|
+ @Autowired
|
|
|
+ private ApprovalService approvalService;
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发送短信
|
|
|
+ */
|
|
|
+ @GetMapping("/sendMessage")
|
|
|
+ public R list() throws Exception {
|
|
|
+ //查询当前操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //查询该企业的经办人信息
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //该企业
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
|
|
|
+ //经办人
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
+ List<SysUserCompanyRel> relList = relService.findSysUserCompanyRels(relLambdaQueryWrapper);
|
|
|
+ if(relList.size() != 1){
|
|
|
+ throw new Exception("该企业经办人信息存在错误");
|
|
|
+ }
|
|
|
+ //经办人
|
|
|
+ String handler = CommonUtil.objToString(relList.get(0).getSucrUserId());
|
|
|
+ LambdaQueryWrapper<com.huyi.service.base.entity.SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //非删除
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getDelFlag,"0");
|
|
|
+ //用户编号
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getUserId,handler);
|
|
|
+ //正常
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getStatus,"0");
|
|
|
+ List<com.huyi.service.base.entity.SysUser> userList = userService.findSysUsers(sysUserLambdaQueryWrapper);
|
|
|
+ if(userList.size() < 1){
|
|
|
+ throw new Exception("获取经办人信息失败");
|
|
|
+ }
|
|
|
+ //获取手机号 // TODO 手机号写死
|
|
|
+ // String iphone = userList.get(0).getUserName();
|
|
|
+ String iphone = "13333333554";
|
|
|
+ if(CommonUtil.isEmpty(iphone)){
|
|
|
+ throw new Exception("获取经办人手机号失败");
|
|
|
+ }
|
|
|
+ //发送短信验证码
|
|
|
+ JSONObject jsonObject = CfcaUtil.sendSmsCode(false,"100804","",iphone,"");
|
|
|
+ //获取结果
|
|
|
+ String result = jsonObject.getString("Status");
|
|
|
+ //手机号掩码
|
|
|
+ String newIphone = iphone.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
|
|
|
+ Map<String,String > map = new HashMap<>();
|
|
|
+ //结果
|
|
|
+ map.put("result",result);
|
|
|
+ //掩码后的手机号
|
|
|
+ map.put("newIphone",newIphone);
|
|
|
+ return R.ok(map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 校验验证码
|
|
|
+ * @param validCode
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/checkCode")
|
|
|
+ public AjaxResult checkCode(@RequestParam(required=false) String validCode) throws Exception {
|
|
|
+
|
|
|
+ if(CommonUtil.isEmpty(validCode)){
|
|
|
+ throw new Exception("请输入验证码");
|
|
|
+ }
|
|
|
+ //查询当前操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //获取企业
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //查询该企业的经办人信息
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //该企业
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
|
|
|
+ //经办人
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
+ List<SysUserCompanyRel> relList = relService.findSysUserCompanyRels(relLambdaQueryWrapper);
|
|
|
+ if(relList.size() != 1){
|
|
|
+ throw new Exception("该企业经办人信息存在错误");
|
|
|
+ }
|
|
|
+ //经办人
|
|
|
+ String handler = CommonUtil.objToString(relList.get(0).getSucrUserId());
|
|
|
+ LambdaQueryWrapper<com.huyi.service.base.entity.SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //非删除
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getDelFlag,"0");
|
|
|
+ //用户编号
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getUserId,handler);
|
|
|
+ //正常
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getStatus,"0");
|
|
|
+ List<com.huyi.service.base.entity.SysUser> userList = userService.findSysUsers(sysUserLambdaQueryWrapper);
|
|
|
+ if(userList.size() < 1){
|
|
|
+ throw new Exception("获取经办人信息失败");
|
|
|
+ }
|
|
|
+ //获取手机号 // TODO 手机号写死
|
|
|
+ // String iphone = userList.get(0).getUserName();
|
|
|
+ String iphone = "13333333554";
|
|
|
+ if(CommonUtil.isEmpty(iphone)){
|
|
|
+ throw new Exception("获取经办人手机号失败");
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = CfcaUtil.checkSmsCode(false,"100804",iphone,validCode,"");
|
|
|
+ //获取结果
|
|
|
+ String verification = jsonObject.getString("Verification");
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("verification",verification);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 合同盖章
|
|
|
+ * @param map
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @PostMapping("/contractSigning")
|
|
|
+ public AjaxResult contractSigning(@RequestBody Map<String,Object> map) throws Exception {
|
|
|
+
|
|
|
+ //存放合同编号
|
|
|
+ List<String> contractIdList = new ArrayList<>();
|
|
|
+ //获取授信编号
|
|
|
+ String zfiCoreQuotaId = CommonUtil.objToString(map.get("zfiCoreQuotaId"));
|
|
|
+ //获取产品
|
|
|
+ String zfpcrProductId = CommonUtil.objToString(map.get("zfpcrProductId"));
|
|
|
+ //获取融信编号
|
|
|
+ String zfiId = CommonUtil.objToString(map.get("zfiId"));
|
|
|
+ //获取融信编号
|
|
|
+ ZcFinanceInf financeInf = financeInfService.getById(zfiId);
|
|
|
+ if(financeInf == null){
|
|
|
+ throw new Exception("获取融信信息失败");
|
|
|
+ }
|
|
|
+ //获取融信的类型
|
|
|
+ String createType = financeInf.getZfiCreateType();
|
|
|
+ //获取融信状态
|
|
|
+ String status = financeInf.getZfiStatus();
|
|
|
+ //获取核心企业审批状态
|
|
|
+ String coreStatus = financeInf.getZfiCoreStatus();
|
|
|
+ //获取融资方审批状态
|
|
|
+ String supplierStatus = financeInf.getZfiSupplierStatus();
|
|
|
+ //节点
|
|
|
+ String code = "";
|
|
|
+ //供应商申请
|
|
|
+ if("0".equals(createType)){
|
|
|
+ if("00".equals(status) && "01".equals(coreStatus)){
|
|
|
+ //开立确权
|
|
|
+ code = "02";
|
|
|
+ }
|
|
|
+ if("01".equals(status) && "01".equals(supplierStatus)){
|
|
|
+ //签收
|
|
|
+ code = "00";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //核心开立
|
|
|
+ if("1".equals(createType)){
|
|
|
+ if(CommonUtil.isEmpty(status) && "01".equals(coreStatus)){
|
|
|
+ //开立确权
|
|
|
+ code = "02";
|
|
|
+ }
|
|
|
+ if("01".equals(status) && "01".equals(supplierStatus)){
|
|
|
+ //签收
|
|
|
+ code = "00";
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ //供应商开立
|
|
|
+ if("2".equals(createType)){
|
|
|
+ if(CommonUtil.isEmpty(status) && "01".equals(supplierStatus)){
|
|
|
+ //融资开立
|
|
|
+ code = "03";
|
|
|
+ }
|
|
|
+ if("00".equals(status) && "01".equals(coreStatus)){
|
|
|
+ //开立确权
|
|
|
+ code = "02";
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if(CommonUtil.isEmpty(code)){
|
|
|
+ throw new Exception("盖章节点异常");
|
|
|
+ }
|
|
|
+ //获取接收方
|
|
|
+ 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.convert(AmtUtil.moneyFormat(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,zfiCoreQuotaId);
|
|
|
+ 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");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ List<PubFileInf> fileInfList = new ArrayList<>();
|
|
|
+ List<ZcFinanceContract> contractList = new ArrayList<>();
|
|
|
+ if(contractIdList.size() < 1){
|
|
|
+ return AjaxResult.success();
|
|
|
+ }else{
|
|
|
+ //查询合同
|
|
|
+ LambdaQueryWrapper<ZcFinanceContract> contractLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ contractLambdaQueryWrapper.in(ZcFinanceContract::getZfcId,contractIdList);
|
|
|
+ contractLambdaQueryWrapper.like(ZcFinanceContract::getZfcNode,code);
|
|
|
+ contractLambdaQueryWrapper.orderByAsc(ZcFinanceContract::getZfcFile);
|
|
|
+ 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");
|
|
|
+ fileInfLambdaQueryWrapper.orderByAsc(PubFileInf::getPfiFileId);
|
|
|
+ fileInfList = fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ for(int i = 0 ; i < fileInfList.size(); i++){
|
|
|
+ //TODO 文件路径需要修改
|
|
|
+ //判断是否为已盖章文件
|
|
|
+ LambdaQueryWrapper<ZcFinanceFileRel> fileRelLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ fileRelLambdaQueryWrapper.eq(ZcFinanceFileRel::getZffrFinanceId, zfiId);
|
|
|
+ fileRelLambdaQueryWrapper.eq(ZcFinanceFileRel::getZffrContractId, contractList.get(i).getZfcId());
|
|
|
+ // 核心企业盖章
|
|
|
+ if ("01".equals(tokenService.getLoginUser().getSysUser().getCompanyType())) {
|
|
|
+ // 查询融资企业是否盖章
|
|
|
+ fileRelLambdaQueryWrapper.eq(ZcFinanceFileRel::getZffrSupplierNode, code);
|
|
|
+ // 融资企业盖章
|
|
|
+ } else if ("02".equals(tokenService.getLoginUser().getSysUser().getCompanyType())) {
|
|
|
+ // 查询核心企业是否盖章
|
|
|
+ fileRelLambdaQueryWrapper.eq(ZcFinanceFileRel::getZffrCoreNode, code);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ZcFinanceFileRel> financeFileList = financeFileRelService.findZcFinanceFileRels(fileRelLambdaQueryWrapper);
|
|
|
+
|
|
|
+ // 文件路径
|
|
|
+ String filePath;
|
|
|
+ // 文件名称
|
|
|
+ String fileName;
|
|
|
+ // 不是已盖章文件
|
|
|
+ if (financeFileList.size() == 0) {
|
|
|
+ /**-------- word 变量替换 开始--------**/
|
|
|
+ //替换word文档中的变量
|
|
|
+ String directory = FileConstants.REMOTE_FILE_PATH;
|
|
|
+ //文件下载
|
|
|
+ filePath = downloadFile(fileInfList.get(i).getPfiFileUrl(),fileInfList.get(i).getPfiFileName());
|
|
|
+ //往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",AmtUtil.moneyFormat(zfiAmount));
|
|
|
+ //大写金额
|
|
|
+ ps.put("zfiAmountBig",zfiAmountBig);
|
|
|
+ //起止日期
|
|
|
+ ps.put("stopDate",stopDate);
|
|
|
+ //当前日期
|
|
|
+ ps.put("currecntDate",currecntDate);
|
|
|
+ //还款编号
|
|
|
+ ps.put("zfiPaymentNumber",zfiPaymentNumber);
|
|
|
+ //承诺还款日
|
|
|
+ ps.put("expireDate",expireDateA);
|
|
|
+ //调用替换word中的变量
|
|
|
+ WordUtil.wordTemplate(filePath,filePath,ps);
|
|
|
+ /**-------- word 变量替换 结束--------**/
|
|
|
+ /**-------- word 转PDF 开始--------**/
|
|
|
+ //加载word示例文档
|
|
|
+ Document doc = new Document();
|
|
|
+ doc.loadFromFile(filePath);
|
|
|
+ //保存为PDF格式
|
|
|
+ //截取文件名称
|
|
|
+ //获取.的位置
|
|
|
+ int index = fileInfList.get(i).getPfiFileName().indexOf(".");
|
|
|
+ fileName = fileInfList.get(i).getPfiFileName().substring(0,index);
|
|
|
+ doc.saveToFile(directory + fileName + currecntDate + ".pdf", FileFormat.PDF);
|
|
|
+ filePath = directory + fileName + currecntDate + ".pdf";
|
|
|
+ /**-------- word 转PDF 结束--------**/
|
|
|
+ // 是已盖章文件
|
|
|
+ } else {
|
|
|
+ // 文件服务器的文件下载到本地
|
|
|
+ PubFileInf fileInf = fileInfService.getById(financeFileList.get(0).getZffrFileId());
|
|
|
+ filePath = downloadFile(fileInf.getPfiFileUrl(), fileInf.getPfiFileName());
|
|
|
+ int index = fileInf.getPfiFileName().indexOf(".");
|
|
|
+ fileName = fileInf.getPfiFileName().substring(0,index);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**-------- 获取合同盖章关键字 开始--------**/
|
|
|
+ //获取合同信息
|
|
|
+ //获取合同的节点
|
|
|
+ String contractNode = contractList.get(i).getZfcNode();
|
|
|
+ //关键字
|
|
|
+ String keyWords = "";
|
|
|
+ //判断节点是否用,分割
|
|
|
+ if(contractNode.contains(",")){
|
|
|
+ String [] arr = contractNode.split(",");
|
|
|
+ //字节所在的节点
|
|
|
+ int site = 0;
|
|
|
+ for(int j = 0 ; j < arr.length; j++){
|
|
|
+ if(code.equals(arr[j])){
|
|
|
+ site = j;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ String signKeyWord = contractList.get(i).getZfcSignKeyword();
|
|
|
+ String [] arrKeyWord = signKeyWord.split(",");
|
|
|
+ if(arr.length != arrKeyWord.length){
|
|
|
+ throw new Exception("合同信息有误");
|
|
|
+ }
|
|
|
+ keyWords = arrKeyWord[site];
|
|
|
+
|
|
|
+ }else {
|
|
|
+ keyWords = contractList.get(i).getZfcSignKeyword();
|
|
|
+ }
|
|
|
+ if(CommonUtil.isEmpty(keyWords)){
|
|
|
+ throw new Exception("获取关键字失败");
|
|
|
+ }
|
|
|
+ /**-------- 获取合同盖章关键字 结束--------**/
|
|
|
+ /**-------- CFCA盖章 开始--------**/
|
|
|
+ //盖章
|
|
|
+ //人员编号
|
|
|
+ String userId = "CA74686406B322C7E05311016B0A442F";
|
|
|
+ //项目编号
|
|
|
+ String projectCode = DateUtils.dateTimeNow();
|
|
|
+ JSONObject jsonObject = AxqCommonUtil.contractSigning(userId,"MM",fileName,keyWords,"0","0","250","250",projectCode,filePath);
|
|
|
+ /**-------- CFCA盖章 结束--------**/
|
|
|
+ /**-------- CFCA盖章文件下载 开始--------**/
|
|
|
+ //获取错误码
|
|
|
+ String errorCode = null;
|
|
|
+ try {
|
|
|
+ errorCode = CommonUtil.objToString(jsonObject.get("errorCode"));
|
|
|
+ } catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+ if(!CommonUtil.isEmpty(errorCode)){
|
|
|
+ //获取错误信息
|
|
|
+ String errorMessage = CommonUtil.objToString(jsonObject.get("errorMessage"));
|
|
|
+ throw new Exception(errorMessage);
|
|
|
+ }
|
|
|
+ String contractNo = CommonUtil.objToString(((JSONObject)(jsonObject.get("contract"))).get("contractNo"));
|
|
|
+ String path = "D:/zhuomian/cfca/";
|
|
|
+ //下载文件
|
|
|
+ AxqCommonUtil.downloadFile(contractNo,path);
|
|
|
+ /**-------- CFCA盖章文件下载 结束--------**/
|
|
|
+ //上传到文件服务器
|
|
|
+ //获取token
|
|
|
+ String token = SecurityUtils.getToken(ServletUtils.getRequest());
|
|
|
+ String companyId = tokenService.getLoginUser().getSysUser().getCompanyId();
|
|
|
+ //文件传输
|
|
|
+ File file = new File(path + contractNo + ".pdf");
|
|
|
+ FileInputStream input = new FileInputStream(file);
|
|
|
+ MultipartFile multipartFile =new MockMultipartFile("file", file.getName(), "text/plain", IOUtils.toByteArray(input));
|
|
|
+ R<com.tianhu.system.api.domain.PubFileInf> fileResult = remoteFileService.uploadFile(multipartFile,"01", "02","00",companyId,token);
|
|
|
+
|
|
|
+ ZcFinanceFileRel financeFileRel;
|
|
|
+ // 不是已盖章文件
|
|
|
+ if (financeFileList.size() == 0) {
|
|
|
+ // zc_finance_file_rel 存入数据
|
|
|
+ financeFileRel = new ZcFinanceFileRel();
|
|
|
+ financeFileRel.setZffrId(IdUtils.fastSimpleUUID());
|
|
|
+ financeFileRel.setZffrFinanceId(zfiId);
|
|
|
+ financeFileRel.setZffrContractId(contractList.get(i).getZfcId());
|
|
|
+ // 已盖章文件
|
|
|
+ } else {
|
|
|
+ // 修改zc_finance_file_rel 数据
|
|
|
+ financeFileRel = financeFileList.get(0);
|
|
|
+ }
|
|
|
+ financeFileRel.setZffrFileId(fileResult.getData().getPfiFileId());
|
|
|
+ financeFileRel.setZffrCfcaNumber(contractNo);
|
|
|
+ // 核心企业盖章
|
|
|
+ if ("01".equals(tokenService.getLoginUser().getSysUser().getCompanyType())) {
|
|
|
+ financeFileRel.setZffrCoreId(companyId);
|
|
|
+ financeFileRel.setZffrCoreUserId(tokenService.getLoginUser().getSysUser().getUserId());
|
|
|
+ financeFileRel.setZffrCoreTime(new Date());
|
|
|
+ financeFileRel.setZffrCoreNode(code);
|
|
|
+
|
|
|
+ // 融资企业盖章
|
|
|
+ } else if ("02".equals(tokenService.getLoginUser().getSysUser().getCompanyType())) {
|
|
|
+ financeFileRel.setZffrSupplierId(companyId);
|
|
|
+ financeFileRel.setZffrSupplierUserId(tokenService.getLoginUser().getSysUser().getUserId());
|
|
|
+ financeFileRel.setZffrSupplierTime(new Date());
|
|
|
+ financeFileRel.setZffrSupplierNode(code);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 不是已盖章文件
|
|
|
+ if (financeFileList.size() == 0) {
|
|
|
+ // zc_finance_file_rel 存入数据
|
|
|
+ financeFileRelService.createZcFinanceFileRel(financeFileRel);
|
|
|
+ // 已盖章文件
|
|
|
+ } else {
|
|
|
+ // 修改zc_finance_file_rel 数据
|
|
|
+ financeFileRelService.updateById(financeFileRel);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //获取此操作员
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser user = userInfo.getSysUser();
|
|
|
+ //获取用户编号
|
|
|
+ String userId = user.getUserId()+"";
|
|
|
+
|
|
|
+ //获取企业类型
|
|
|
+ String companyType = tokenService.getLoginUser().getSysUser().getCompanyType();
|
|
|
+ /**-------- 盖章完成修改融信状态并且发起审批 开始--------**/
|
|
|
+ //核心开立
|
|
|
+ if("1".equals(createType)){
|
|
|
+ //核心企业
|
|
|
+ if("01".equals(companyType)){
|
|
|
+ //修改融信状态
|
|
|
+ ZcFinanceInf finance = new ZcFinanceInf();
|
|
|
+ finance.setZfiId(zfiId);
|
|
|
+ //待签收
|
|
|
+ finance.setZfiStatus("01");
|
|
|
+ //修改时间
|
|
|
+ finance.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //修改人
|
|
|
+ finance.setUpdateBy(userId);
|
|
|
+ financeInfService.updateById(finance);
|
|
|
+ //补充资料的审批方法
|
|
|
+ approvalService.addInformationApproval(map);
|
|
|
+ }else if("02".equals(companyType)){
|
|
|
+ //融资企业
|
|
|
+ //平台审批方法
|
|
|
+ approvalService.addPlatformApproval(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //融资申请
|
|
|
+ if("0".equals(companyType)){
|
|
|
+ //核心企业
|
|
|
+ if("01".equals(companyType)){
|
|
|
+ //修改融信状态
|
|
|
+ ZcFinanceInf finance = new ZcFinanceInf();
|
|
|
+ finance.setZfiId(zfiId);
|
|
|
+ //待签收
|
|
|
+ finance.setZfiStatus("01");
|
|
|
+ //修改时间
|
|
|
+ finance.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //修改人
|
|
|
+ finance.setUpdateBy(userId);
|
|
|
+ financeInfService.updateById(finance);
|
|
|
+ //融资企业签收审批
|
|
|
+ approvalService.addSignApproval(map);
|
|
|
+ }else if("02".equals(companyType)){
|
|
|
+ //融资企业
|
|
|
+ //修改融信状态
|
|
|
+ ZcFinanceInf finance = new ZcFinanceInf();
|
|
|
+ finance.setZfiId(zfiId);
|
|
|
+ //已生效
|
|
|
+ finance.setZfiStatus("02");
|
|
|
+ //修改时间
|
|
|
+ finance.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //修改人
|
|
|
+ finance.setUpdateBy(userId);
|
|
|
+ financeInfService.updateById(finance);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ //融资开立
|
|
|
+ if("2".equals(createType)){
|
|
|
+ //核心企业
|
|
|
+ if("01".equals(companyType)){
|
|
|
+ //修改融信状态
|
|
|
+ ZcFinanceInf finance = new ZcFinanceInf();
|
|
|
+ finance.setZfiId(zfiId);
|
|
|
+ //已生效
|
|
|
+ finance.setZfiStatus("02");
|
|
|
+ //修改时间
|
|
|
+ finance.setUpdateTime(DateUtils.getNowDate());
|
|
|
+ //修改人
|
|
|
+ finance.setUpdateBy(userId);
|
|
|
+ financeInfService.updateById(finance);
|
|
|
+
|
|
|
+ }else if("02".equals(companyType)){
|
|
|
+ //融资企业
|
|
|
+ //平台审批方法
|
|
|
+ approvalService.addPlatformApproval(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ /**-------- 盖章完成修改融信状态并且发起审批 结束--------**/
|
|
|
+ return AjaxResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 人脸识别
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @GetMapping("/faceAuth")
|
|
|
+ public AjaxResult faceAuth() throws Exception {
|
|
|
+ //TODO 需要配置系统参数
|
|
|
+ //获取当前用户
|
|
|
+ LoginUser userInfo = tokenService.getLoginUser();
|
|
|
+ SysUser use = userInfo.getSysUser();
|
|
|
+ //获取公司
|
|
|
+ String companyId = use.getCompanyId();
|
|
|
+ //查询该企业的经办人信息
|
|
|
+ LambdaQueryWrapper<SysUserCompanyRel> relLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //该企业
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrCompanyId,companyId);
|
|
|
+ //经办人
|
|
|
+ relLambdaQueryWrapper.eq(SysUserCompanyRel::getSucrHandler,"1");
|
|
|
+ List<SysUserCompanyRel> relList = relService.findSysUserCompanyRels(relLambdaQueryWrapper);
|
|
|
+ if(relList.size() != 1){
|
|
|
+ throw new Exception("该企业经办人信息存在错误");
|
|
|
+ }
|
|
|
+ //经办人
|
|
|
+ String handler = CommonUtil.objToString(relList.get(0).getSucrUserId());
|
|
|
+ LambdaQueryWrapper<com.huyi.service.base.entity.SysUser> sysUserLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ //非删除
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getDelFlag,"0");
|
|
|
+ //用户编号
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getUserId,handler);
|
|
|
+ //正常
|
|
|
+ sysUserLambdaQueryWrapper.eq(com.huyi.service.base.entity.SysUser::getStatus,"0");
|
|
|
+ List<com.huyi.service.base.entity.SysUser> userList = userService.findSysUsers(sysUserLambdaQueryWrapper);
|
|
|
+ if(userList.size() < 1){
|
|
|
+ throw new Exception("获取经办人信息失败");
|
|
|
+ }
|
|
|
+ //获取身份证号 // TODO 身份证号写死
|
|
|
+ //String idCard = userList.get(0).getIdCard();
|
|
|
+ String idCard = "37091119960712402X";
|
|
|
+ //获取姓名 // TODO 姓名写死
|
|
|
+ //String name = userList.get(0).getNickName();
|
|
|
+ String name = "小兰";
|
|
|
+ //前后台通知
|
|
|
+ String backFrontUrl = "https://www.baidu.com";
|
|
|
+ //对公
|
|
|
+ String publicName = "http://zcyl.keao.tech/#/";
|
|
|
+ Map<String,String> m = faceAuthService.faceAuth(false,"100804",name,"0",idCard,backFrontUrl,backFrontUrl,"",publicName);
|
|
|
+ String fileUrl= m.get("fileUrl");
|
|
|
+ //源流水号
|
|
|
+ String originalTxSN = m.get("originalTxSN");
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("fileUrl",fileUrl);
|
|
|
+ map.put("originalTxSN",originalTxSN);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 人脸识别结果查证
|
|
|
+ * @param originalTxSN 源流水号
|
|
|
+ * @return
|
|
|
+ * @throws Exception
|
|
|
+ */
|
|
|
+ @GetMapping("/checkFaceAuth")
|
|
|
+ public AjaxResult checkFaceAuth (@RequestParam(required=false) String originalTxSN) throws Exception {
|
|
|
+ //人脸识别结果查证
|
|
|
+ JSONObject jsonObject = CfcaUtil.checkFaceAuth(false,"100804",originalTxSN,"0","");
|
|
|
+ String Verification = "";
|
|
|
+ String Message = "";
|
|
|
+ try {
|
|
|
+ //获取查证结果
|
|
|
+ Verification = jsonObject.getString("Verification");
|
|
|
+ //获取响应消息
|
|
|
+ Message = jsonObject.getString("Message");
|
|
|
+ }catch (Exception e){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String,String> map = new HashMap<>();
|
|
|
+ map.put("Verification",Verification);
|
|
|
+ map.put("Message",Message);
|
|
|
+ return AjaxResult.success(map);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下载远程文件并保存到本地
|
|
|
+ * @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();
|
|
|
+ }
|
|
|
+}
|