Browse Source

融资管理/授信管理

peixh 4 years ago
parent
commit
a4ee5a1fc4

+ 85 - 65
sc-service/src/main/java/com/huyi/service/creditLine/controller/CreditLineController.java

@@ -57,6 +57,8 @@ public class CreditLineController extends BaseController {
     private IZcFinanceQuotaConRelService iZcFinanceQuotaConRelService;
     @Autowired
     private IZcFinanceContractService iZcFinanceContractService;
+
+    public final static String REGEX = "^\\d\\.([0-9]{1,2}|[0-9][0-9])$|^[0-9]\\d{0,1}(\\.\\d{1,2}){0,1}$|^100(\\.0{1,2}){0,1}$";
      /**
      * 查询授信额度列表
      */
@@ -139,7 +141,7 @@ public class CreditLineController extends BaseController {
         Map map = new HashMap();
         map.put("zfpcrId",zfpcrId);
         List<Map> list = creditLineService.selectCreditLineDetail(map);
-        //授信合同信息
+        //授信合同信息关联表
         LambdaQueryWrapper<ZcFinanceQuotaConRel> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(ZcFinanceQuotaConRel::getZfqcrCreditId,zfpcrId);
         List<ZcFinanceQuotaConRel> quotaConRelList = iZcFinanceQuotaConRelService.findZcFinanceQuotaConRels(queryWrapper);
@@ -148,6 +150,7 @@ public class CreditLineController extends BaseController {
             String contractId = quotaConRelList.get(i).getZfqcrContractId();
             id.add(contractId);
         }
+        //通过主键查询合同表
         if (id.size() > 0) {
             LambdaQueryWrapper<ZcFinanceContract> contractWrapper = new LambdaQueryWrapper<>();
             contractWrapper.in(ZcFinanceContract::getZfcId, id);
@@ -187,9 +190,15 @@ public class CreditLineController extends BaseController {
         //日期范围
         List<String> dateTime = (List<String>) map.get("dateTime");
         //开始日期
-        String zfpcrStartDate = dateTime.get(0);
+        String zfpcrStartDate = "";
         //结束日期
-        String zfpcrEndDate = dateTime.get(1);
+        String zfpcrEndDate = "";
+        if (dateTime != null) {
+            //开始日期
+            zfpcrStartDate = dateTime.get(0);
+            //结束日期
+            zfpcrEndDate = dateTime.get(1);
+        }
         //融资网点
         String zfpcrAddress =  CommonUtil.objToString(map.get("zfpcrAddress"));
         //是否收取手续费(0:不收取, 1收取)
@@ -204,88 +213,89 @@ public class CreditLineController extends BaseController {
         String zfpcrLoanType = CommonUtil.objToString(map.get("zfpcrLoanType"));
         //记账簿托管方式
         String zfpcrBookkeepingType = CommonUtil.objToString(map.get("zfpcrLoanType"));
-        String regex = "^\\d\\.([0-9]{1,2}|[0-9][0-9])$|^[0-9]\\d{0,1}(\\.\\d{1,2}){0,1}$|^100(\\.0{1,2}){0,1}$";
-        Pattern pattern = Pattern.compile(regex);
+        //校验百分百
+        Pattern pattern = Pattern.compile(REGEX);
         //融资产品
         if(CommonUtil.isEmpty(zfpcrProductId)){
-            throw new Exception("融资产品不能为空");
+            return AjaxResult.error("融资产品不能为空");
         }
         LambdaQueryWrapper<ZcFinanceProComRel> queryWrapper = new LambdaQueryWrapper<>();
         queryWrapper.eq(ZcFinanceProComRel::getZfpcrProductId,zfpcrProductId);
         queryWrapper.eq(ZcFinanceProComRel::getZfpcrCompanyId,zfpcrCompanyId);
         int count = iZcFinanceProComRelService.count(queryWrapper);
         if (count > 0){
-            throw new Exception("此企业已授信该融资产品");
+            return AjaxResult.error("此企业已授信该融资产品");
         }
         //授信企业名称
         if(CommonUtil.isEmpty(zfpcrCompanyId)){
-            throw new Exception("授信企业名称不能为空");
+            return AjaxResult.error("授信企业名称不能为空");
         }
         //授信额度
         if(CommonUtil.isNotEmpty(zfpcrAmount)) {
             if(AmtUtil.isMoney(zfpcrAmount) == false) {
-                throw new Exception("请输入正确的授信额度");
+                return AjaxResult.error("请输入正确的授信额度");
             }
         }else {
-            throw new Exception("授信额度不能为空");
+            return AjaxResult.error("授信额度不能为空");
         }
         //利率
         if(CommonUtil.isNotEmpty(zfpcrRate)) {
             if(!pattern.matcher(zfpcrRate).matches()) {
-                throw new Exception("请输入正确的利率");
+                return AjaxResult.error("请输入正确的利率");
             }
         }else {
-            throw new Exception("利率不能为空");
+            return AjaxResult.error("利率不能为空");
         }
         //有效期
         if(CommonUtil.isEmpty(zfpcrDateType)){
-            throw new Exception("有效期不能为空");
+            return AjaxResult.error("有效期不能为空");
         }
         //时间范围
         if ("1".equals(zfpcrDateType)){
             //时间范围
             if(dateTime.size() == 0){
-                throw new Exception("时间范围不能为空");
+                return AjaxResult.error("时间范围不能为空");
             }
         }
         //是否收取手续费(0:不收取, 1收取)
         if(CommonUtil.isEmpty(zfpcrCharge)){
-            throw new Exception("是否收取手续费不能为空");
+            return AjaxResult.error("是否收取手续费不能为空");
         }
         //平台服务费收取费率
         if("1".equals(zfpcrCharge)){
             if(CommonUtil.isNotEmpty(zfpcrChargeRate)) {
                 if(!pattern.matcher(zfpcrChargeRate).matches()) {
-                    throw new Exception("请输入正确的平台服务费收取费率");
+                    return AjaxResult.error("请输入正确的平台服务费收取费率");
                 }
             }else {
-                throw new Exception("平台服务费收取费率不能为空");
+                return AjaxResult.error("平台服务费收取费率不能为空");
             }
         }
         //核心企业还款账户账号
         if(CommonUtil.isEmpty(zfpcrAccount)){
-            throw new Exception("核心企业还款账户账号不能为空");
+            return AjaxResult.error("核心企业还款账户账号不能为空");
         }
         //核心企业还款账户账号
         if(CommonUtil.isEmpty(zfpcrAccountBank)){
-            throw new Exception("核心企业还款账户开户行不能为空");
+            return AjaxResult.error("核心企业还款账户开户行不能为空");
         }
         if (zfpcrAccountBank.length() > 30){
-            throw new Exception("核心企业还款账户开户行长度过长");
+            return AjaxResult.error("核心企业还款账户开户行长度过长");
         }
         //融资放款方式
         if(CommonUtil.isEmpty(zfpcrLoanType)){
-            throw new Exception("融资放款方式不能为空");
+            return AjaxResult.error("融资放款方式不能为空");
         }
         //记账簿托管方式
         if(CommonUtil.isEmpty(zfpcrBookkeepingType)){
-            throw new Exception("记账簿托管方式不能为空");
+            return AjaxResult.error("记账簿托管方式不能为空");
         }
         //合同信息
         List<Map<String, String>> tableData = (List<Map<String, String>>) map.get("ticketList");
-        if (tableData.size() == 0 ){
-            throw new Exception("请选择合同信息");
-        }
+//        if (tableData.size() == 0 ){
+//            return AjaxResult.error("请选择合同信息");
+//        }
+
         //执行新增
         ZcFinanceProComRel zcFinanceProComRel = new ZcFinanceProComRel();
         //主键
@@ -328,13 +338,15 @@ public class CreditLineController extends BaseController {
         iZcFinanceProComRelService.createZcFinanceProComRel(zcFinanceProComRel);
         //新增授信合同关联表
         for (int i = 0; i < tableData.size(); i++) {
-            String zfcId = tableData.get(i).get("zfcId");
-            ZcFinanceQuotaConRel zcFinanceQuotaConRel = new ZcFinanceQuotaConRel();
-            //合同id
-            zcFinanceQuotaConRel.setZfqcrContractId(zfcId);
-            //授信id
-            zcFinanceQuotaConRel.setZfqcrCreditId(zfpcrId);
-            iZcFinanceQuotaConRelService.createZcFinanceQuotaConRel(zcFinanceQuotaConRel);
+            if (tableData != null) {
+                String zfcId = tableData.get(i).get("zfcId");
+                ZcFinanceQuotaConRel zcFinanceQuotaConRel = new ZcFinanceQuotaConRel();
+                //合同id
+                zcFinanceQuotaConRel.setZfqcrContractId(zfcId);
+                //授信id
+                zcFinanceQuotaConRel.setZfqcrCreditId(zfpcrId);
+                iZcFinanceQuotaConRelService.createZcFinanceQuotaConRel(zcFinanceQuotaConRel);
+            }
         }
         return AjaxResult.success();
     }
@@ -372,9 +384,15 @@ public class CreditLineController extends BaseController {
         //日期范围
         List<String> dateTime = (List<String>) map.get("dateTime");
         //开始日期
-        String zfpcrStartDate = dateTime.get(0);
+        String zfpcrStartDate = "";
         //结束日期
-        String zfpcrEndDate = dateTime.get(1);
+        String zfpcrEndDate = "";
+        if (dateTime != null) {
+            //开始日期
+            zfpcrStartDate = dateTime.get(0);
+            //结束日期
+            zfpcrEndDate = dateTime.get(1);
+        }
         //融资网点
         String zfpcrAddress =  CommonUtil.objToString(map.get("zfpcrAddress"));
         //是否收取手续费(0:不收取, 1收取)
@@ -389,11 +407,11 @@ public class CreditLineController extends BaseController {
         String zfpcrLoanType = CommonUtil.objToString(map.get("zfpcrLoanType"));
         //记账簿托管方式
         String zfpcrBookkeepingType = CommonUtil.objToString(map.get("zfpcrLoanType"));
-        String regex = "^\\d\\.([0-9]{1,2}|[0-9][0-9])$|^[0-9]\\d{0,1}(\\.\\d{1,2}){0,1}$|^100(\\.0{1,2}){0,1}$";
-        Pattern pattern = Pattern.compile(regex);
+        //校验百分百
+        Pattern pattern = Pattern.compile(REGEX);
         //融资产品
         if(CommonUtil.isEmpty(zfpcrProductId)){
-            throw new Exception("融资产品不能为空");
+            return AjaxResult.error("融资产品不能为空");
         }
         LambdaQueryWrapper<ZcFinanceProComRel> wrapper = new LambdaQueryWrapper<>();
         wrapper.eq(ZcFinanceProComRel::getZfpcrProductId,zfpcrProductId);
@@ -401,77 +419,77 @@ public class CreditLineController extends BaseController {
         wrapper.ne(ZcFinanceProComRel::getZfpcrId,zfpcrId);
         int count = iZcFinanceProComRelService.count(wrapper);
         if (count > 0){
-            throw new Exception("此企业已授信盖融资产品");
+            return AjaxResult.error("此企业已授信盖融资产品");
         }
         //授信企业名称
         if(CommonUtil.isEmpty(zfpcrCompanyId)){
-            throw new Exception("授信企业名称不能为空");
+            return AjaxResult.error("授信企业名称不能为空");
         }
         //授信额度
         if(CommonUtil.isNotEmpty(zfpcrAmount)) {
             if(AmtUtil.isMoney(zfpcrAmount) == false) {
-                throw new Exception("请输入正确的授信额度");
+                return AjaxResult.error("请输入正确的授信额度");
             }
         }else {
-            throw new Exception("授信额度不能为空");
+            return AjaxResult.error("授信额度不能为空");
         }
         //利率
         if(CommonUtil.isNotEmpty(zfpcrRate)) {
             if(!pattern.matcher(zfpcrRate).matches()) {
-                throw new Exception("请输入正确的利率");
+                return AjaxResult.error("请输入正确的利率");
             }
         }else {
-            throw new Exception("利率不能为空");
+            return AjaxResult.error("利率不能为空");
         }
         //有效期
         if(CommonUtil.isEmpty(zfpcrDateType)){
-            throw new Exception("有效期不能为空");
+            return AjaxResult.error("有效期不能为空");
         }
         //时间范围
         if ("1".equals(zfpcrDateType)){
             //时间范围
             if(dateTime.size() == 0){
-                throw new Exception("时间范围不能为空");
+                return AjaxResult.error("时间范围不能为空");
             }
         }
         //是否收取手续费(0:不收取, 1收取)
         if(CommonUtil.isEmpty(zfpcrCharge)){
-            throw new Exception("是否收取手续费不能为空");
+            return AjaxResult.error("是否收取手续费不能为空");
         }
         //平台服务费收取费率
         if("1".equals(zfpcrCharge)){
             if(CommonUtil.isNotEmpty(zfpcrChargeRate)) {
                 if(!pattern.matcher(zfpcrChargeRate).matches()) {
-                    throw new Exception("请输入正确的平台服务费收取费率");
+                    return AjaxResult.error("请输入正确的平台服务费收取费率");
                 }
             }else {
-                throw new Exception("平台服务费收取费率不能为空");
+                return AjaxResult.error("平台服务费收取费率不能为空");
             }
         }
         //核心企业还款账户账号
         if(CommonUtil.isEmpty(zfpcrAccount)){
-            throw new Exception("核心企业还款账户账号不能为空");
+            return AjaxResult.error("核心企业还款账户账号不能为空");
         }
         //核心企业还款账户账号
         if(CommonUtil.isEmpty(zfpcrAccountBank)){
-            throw new Exception("核心企业还款账户开户行不能为空");
+            return AjaxResult.error("核心企业还款账户开户行不能为空");
         }
         if (zfpcrAccountBank.length() > 30){
-            throw new Exception("核心企业还款账户开户行长度过长");
+            return AjaxResult.error("核心企业还款账户开户行长度过长");
         }
         //融资放款方式
         if(CommonUtil.isEmpty(zfpcrLoanType)){
-            throw new Exception("融资放款方式不能为空");
+            return AjaxResult.error("融资放款方式不能为空");
         }
         //记账簿托管方式
         if(CommonUtil.isEmpty(zfpcrBookkeepingType)){
-            throw new Exception("记账簿托管方式不能为空");
+            return AjaxResult.error("记账簿托管方式不能为空");
         }
         //合同信息
         List<Map<String, String>> tableData = (List<Map<String, String>>) map.get("ticketList");
-        if (tableData.size() == 0 ){
-            throw new Exception("请选择合同信息");
-        }
+//        if (tableData.size() == 0 ){
+//            return AjaxResult.error("请选择合同信息");
+//        }
         //执行修改
         ZcFinanceProComRel zcFinanceProComRel = new ZcFinanceProComRel();
         //主键
@@ -522,14 +540,16 @@ public class CreditLineController extends BaseController {
         }
         //新增授信合同
         // 关联表
-        for (int i = 0; i < tableData.size(); i++) {
-            String zfcId = tableData.get(i).get("zfcId");
-            ZcFinanceQuotaConRel zcFinanceQuotaConRel = new ZcFinanceQuotaConRel();
-            //合同id
-            zcFinanceQuotaConRel.setZfqcrContractId(zfcId);
-            //授信id
-            zcFinanceQuotaConRel.setZfqcrCreditId(zfpcrId);
-            iZcFinanceQuotaConRelService.createZcFinanceQuotaConRel(zcFinanceQuotaConRel);
+        if (tableData != null) {
+            for (int i = 0; i < tableData.size(); i++) {
+                String zfcId = tableData.get(i).get("zfcId");
+                ZcFinanceQuotaConRel zcFinanceQuotaConRel = new ZcFinanceQuotaConRel();
+                //合同id
+                zcFinanceQuotaConRel.setZfqcrContractId(zfcId);
+                //授信id
+                zcFinanceQuotaConRel.setZfqcrCreditId(zfpcrId);
+                iZcFinanceQuotaConRelService.createZcFinanceQuotaConRel(zcFinanceQuotaConRel);
+            }
         }
         return AjaxResult.success();
     }
@@ -557,7 +577,7 @@ public class CreditLineController extends BaseController {
                 zcFinanceProComRel.setZfpcrStatus("01");
                 iZcFinanceProComRelService.updateZcFinanceProComRel(zcFinanceProComRel);
             }else {
-                throw new Exception("此授信正在使用无法冻结");
+                return AjaxResult.error("此授信正在使用无法冻结");
             }
         }else {
             zcFinanceProComRel.setZfpcrStatus("00");

+ 78 - 24
sc-service/src/main/java/com/huyi/service/financeRecord/controller/FinanceRecordController.java

@@ -91,9 +91,15 @@ public class FinanceRecordController extends BaseController {
     @Autowired
     private RemoteConfigService configService;
     @Autowired
+    private IZcFinanceFileRelService iZcFinanceFileRelService;
+    @Autowired
     private FlowableService flowableService;
     // 开始流程
     public final static String STRART_FLOW = "flow/strartFlow";
+
+    //正整数正则
+    private static final String REGEX =  "^[0-9]*[1-9][0-9]*$";
+
      /**
      * 查询融资管理列表
      */
@@ -109,9 +115,9 @@ public class FinanceRecordController extends BaseController {
         //获取企业
         String companyId = use.getCompanyId();
         Map map = new HashMap();
-        if (!SalaryConstants.OPEX.equals(companyId)) {
-            map.put("companyId", companyId);
-        }
+//        if (!SalaryConstants.OPEX.equals(companyId)) {
+//            map.put("companyId", companyId);
+//        }
         map.put("zfrStatus",zfrStatus);
         //00:我签收的   01:我开立的
         if ("00".equals(zfrTypes)){
@@ -143,16 +149,23 @@ public class FinanceRecordController extends BaseController {
     public AjaxResult getInfo(@PathVariable("zfrId") String zfrId)
     {
         ZcFinanceRecord zcFinanceRecord = iZcFinanceRecordService.getById(zfrId);
-        Map map = new HashMap();
-        if (zcFinanceRecord != null) {
-            com.huyi.service.base.entity.SysUser user = iSysUserService.getById(zcFinanceRecord.getCreateBy());
-            BeanMap beanMap = BeanMap.create(zcFinanceRecord);
-            for (Object key : beanMap.keySet()) {
-                map.put(key + "", beanMap.get(key));
-            }
-            //创建人
-            map.put("createUser", user.getNickName());
-        }
+        //融信id
+        String zfrFinanceId = zcFinanceRecord.getZfrFinanceId();
+        Map map = CommonUtil.entityToMap(zcFinanceRecord);
+        //查询创建人
+        com.huyi.service.base.entity.SysUser user = iSysUserService.getById(zcFinanceRecord.getCreateBy());
+        //创建人
+        map.put("createUser", user.getNickName());
+        //查询融信信息
+        ZcFinanceInf zcFinanceInf = iZcFinanceInfService.getById(zfrFinanceId);
+        map.put("zcFinanceInf",zcFinanceInf);
+        //融资产品id
+        String zfiProductId = zcFinanceInf.getZfiProductId();
+        //查询融资产品
+        ZcFinanceProduct zcFinanceProduct = iZcFinanceProductService.getById(zfiProductId);
+        //签署意愿类型(00:全部, 01:人脸识别, 02:短信)
+        String  zfpAuthType = zcFinanceProduct.getZfpAuthType();
+        map.put("zfpAuthType",zfpAuthType);
         return AjaxResult.success(map);
     }
 
@@ -182,10 +195,10 @@ public class FinanceRecordController extends BaseController {
             //是否经办人 0:不是, 1:是
             String handler = list.get(0).getSucrHandler();
             if (!"1".equals(handler)){
-                throw new Exception("此操作需经办人权限,请确认您是否是经办人");
+                return AjaxResult.error("此操作需经办人权限,请确认您是否是经办人");
             }
         }else {
-            throw new Exception("此操作需经办人权限,请确认您是否是经办人");
+            return AjaxResult.error("此操作需经办人权限,请确认您是否是经办人");
         }
         //融信id
         String zfrFinanceId = CommonUtil.objToString(map.get("zfrFinanceId"));
@@ -207,10 +220,10 @@ public class FinanceRecordController extends BaseController {
         //获取当前时间
         String currentTime = DateUtils.parseDateToStr("yyyyMMddHHmmss",createTime);
         if (CommonUtil.isEmpty(zfrFinanceId)) {
-            throw new Exception("融信编号不能为空");
+            return AjaxResult.error("融信编号不能为空");
         }
         if (CommonUtil.isEmpty(zfrAmount)){
-            throw new Exception("融资金额不能为空");
+            return AjaxResult.error("融资金额不能为空");
         }
         //融资编号
         String  zfrNumber = "MB";
@@ -224,9 +237,14 @@ public class FinanceRecordController extends BaseController {
         zfrNumber += zfpNumber;
         zfrNumber += currentTime;
         //融资放款方式为:平台电子记账簿=>融资收款账号为资方电子账户,供应商指定账户=>融资收款账号为必输,供应商线下面签=>融资收款账号为非必输
+        Pattern pattern = Pattern.compile(REGEX);
         if ("1".equals(zfpcrLoanType)){
             if (CommonUtil.isEmpty(zfrCollectionAccount)){
-                throw new Exception("融资收款账号不能为空");
+                return AjaxResult.error("融资收款账号不能为空");
+            }else {
+                if(!pattern.matcher(zfrCollectionAccount).matches()) {
+                    return AjaxResult.error("请输入正确的融资收款账号");
+                }
             }
         }else if ("0".equals(zfpcrLoanType)){
             //通过资方id查询电子账户表
@@ -239,10 +257,16 @@ public class FinanceRecordController extends BaseController {
             accInfWrapper.eq(PayAccInf::getPaiCstno,zfpManagementId);
             List<PayAccInf> accInfList = iPayAccInfService.findPayAccInfs(accInfWrapper);
             if (accInfList.size() == 0){
-                throw new Exception("暂无电子账户");
+                return AjaxResult.error("暂无电子账户");
             }else {
                 zfrCollectionAccount = accInfList.get(0).getPaiAccno();
             }
+        }else if ("2".equals(zfpcrLoanType)){
+            if(CommonUtil.isNotEmpty(zfrCollectionAccount)) {
+                if(!pattern.matcher(zfrCollectionAccount).matches()) {
+                    return AjaxResult.error("请输入正确的融资收款账号");
+                }
+            }
         }
         /*---------------新增融资表----------*/
         ZcFinanceRecord zcFinanceRecord = new ZcFinanceRecord();
@@ -333,14 +357,14 @@ public class FinanceRecordController extends BaseController {
         //授信额度
         if(CommonUtil.isNotEmpty(zfrLoanAmount)) {
             if(AmtUtil.isMoney(zfrLoanAmount) == false) {
-                throw new Exception("请输入正确的放款金额");
+                return AjaxResult.error("请输入正确的放款金额");
             }
         }else {
-            throw new Exception("放款金额不能为空");
+            return AjaxResult.error("放款金额不能为空");
         }
         int count = CommonUtil.compare(zfrLoanAmount,zfrAmount);
         if (count == 1){
-            throw new Exception("实际放款金额不能大于融资金额");
+            return AjaxResult.error("实际放款金额不能大于融资金额");
         }
         //图片
         String zfrLoanFile = "";
@@ -389,7 +413,7 @@ public class FinanceRecordController extends BaseController {
      * @return
      */
     @GetMapping("listBillInf/{zfiId}")
-    public AjaxResult listBillInf(@PathVariable("zfiId") String zfiId) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+    public AjaxResult listBillInf(@PathVariable("zfiId") String zfiId) throws Exception {
         //最终结果
         Map result = new HashMap();
         //查询当前操作员
@@ -507,6 +531,8 @@ public class FinanceRecordController extends BaseController {
         List<PubFileInf> contractFileList = new ArrayList<>();
         //收付款的其他文件
         List<PubFileInf> otherFileList = new ArrayList<>();
+        //融信相关文件
+        List<PubFileInf> financeFileList = new ArrayList<>();
         //提取收付款编号
         List<String> zbiIdList = CommonUtil.getIdFromList(billInfList,"zbiId");
         //发票与收付款相关
@@ -560,7 +586,19 @@ public class FinanceRecordController extends BaseController {
             fileInfLambdaQueryWrapper.eq(PubFileInf::getPfiIsDel,"00");
             otherFileList = fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
         }
-//        String directory = "D:\\record" ;
+        //融信附件关联表
+        LambdaQueryWrapper<ZcFinanceFileRel> financeFileRelWrapper = new LambdaQueryWrapper<>();
+        financeFileRelWrapper.in(ZcFinanceFileRel::getZffrFinanceId,zbiIdList);
+        List<ZcFinanceFileRel> fileRelList = iZcFinanceFileRelService.findZcFinanceFileRels(financeFileRelWrapper);
+        //不为空
+        if (fileRelList.size() > 0){
+            //提取文件编号
+            List<String> idList = CommonUtil.getIdFromList(fileRelList,"zbfrFileId");
+            LambdaQueryWrapper<PubFileInf> fileInfLambdaQueryWrapper = new LambdaQueryWrapper<>();
+            fileInfLambdaQueryWrapper.in(PubFileInf::getPfiFileId,idList);
+            fileInfLambdaQueryWrapper.eq(PubFileInf::getPfiIsDel,"00");
+            financeFileList = fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
+        }
         String directory = configService.selectConfigByKey("zc_record_file").getMsg();
 
         for (int i = 0; i < otherFileList.size(); i++) {
@@ -594,6 +632,16 @@ public class FinanceRecordController extends BaseController {
             list.add(map);
 
         }
+        for (int x = 0; x < financeFileList.size(); x++) {
+            Map map = new HashMap();
+            //文件路径
+            String pfiFileUrl = financeFileList.get(x).getPfiFileUrl();
+            //文件名称
+            String pfiFileName = financeFileList.get(x).getPfiFileName();
+            map.put("pfiFileUrl",pfiFileUrl);
+            map.put("pfiFileName",pfiFileName);
+            list.add(map);
+        }
         for (int l = 0; l < list.size(); l++) {
             String files = list.get(l).get("pfiFileUrl");
             String names = list.get(l).get("pfiFileName");
@@ -610,6 +658,12 @@ public class FinanceRecordController extends BaseController {
         return null;
     }
 
+    /**
+     * 文件下载
+     * @param response
+     * @param fileName
+     * @param path
+     */
     public void down(HttpServletResponse response, String fileName, String path) {
         response.setHeader("content-type", "application/octet-stream");
         response.setContentType("application/octet-stream");

+ 752 - 0
sc-service/src/main/java/com/huyi/service/financeRecord/controller/RecordSealController.java

@@ -0,0 +1,752 @@
+package com.huyi.service.financeRecord.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.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.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.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.RemoteConfigService;
+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.transaction.annotation.Transactional;
+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.text.SimpleDateFormat;
+import java.util.*;
+
+
+/**
+ * 融资盖章
+ * peixh
+ * 2021-08-24
+ */
+@RestController
+@RequestMapping("/recordSeal")
+public class RecordSealController 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;
+    //系统参数服务类
+    @Autowired
+    private RemoteConfigService configService;
+    //融信和文件的关系服务类
+    @Autowired
+    private IZcFinanceFileRelService financeFileRelService;
+    @Autowired
+    private RemoteFileService remoteFileService;
+    /**
+     * 获取合同文件
+     * @param map
+     * @return
+     * @throws Exception
+     */
+    @PutMapping("/getContractFile")
+    public AjaxResult getContract(@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 code = "01";
+
+        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");
+            }
+        }
+
+        //返回
+        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.like(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");
+                fileInfList = fileInfService.findPubFileInfs(fileInfLambdaQueryWrapper);
+            }
+
+        }
+        if(fileInfList.size() > 0 ){
+            //提取所有的文件url
+            List<String> urlList = CommonUtil.getIdFromList(fileInfList,"pfiFileUrl");
+            //提取文件名
+            List<String> fileNameList = CommonUtil.getIdFromList(fileInfList,"pfiFileName");
+            for(int i =0 ; i < urlList.size() ;i++){
+                //TODO 文件路径需要修改
+                //替换word文档中的变量
+                //String directory = FileConstants.REMOTE_FILE_PATH;
+                String directory = configService.selectConfigByKey("credit_file_path").getMsg();
+                //文件下载
+                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",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示例文档
+                Document doc = new Document();
+                doc.loadFromFile(filePath);
+                //保存为PDF格式
+                //截取文件名称
+                //获取.的位置
+                int index  = fileNameList.get(i).indexOf(".");
+                String fileName = fileNameList.get(i).substring(0,index);
+                doc.saveToFile(directory + fileName + currecntDate + ".pdf", FileFormat.PDF);
+                filePath = directory + fileName + currecntDate + ".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 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 code = "01";
+
+        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++){
+            //判断是否为已盖章文件
+            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;
+                String directory = configService.selectConfigByKey("credit_file_path").getMsg();
+                //文件下载
+                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/";
+            String path = configService.selectConfigByKey("cfca_file_path").getMsg();
+            //下载文件
+            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);
+            }
+        }
+        /**-------- 盖章完成修改融信状态并且发起审批 结束--------**/
+        return AjaxResult.success();
+    }
+
+    /**
+     * 下载远程文件并保存到本地
+     * @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("转换成功");
+        }
+    }*/
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 23 - 7
sc-service/src/main/resources/mapper/common/FinanceInfMapper.xml

@@ -6,14 +6,30 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectFinanceInfList" parameterType="map" resultType="map">
         SELECT
-        zfi_id 		        'zfiId',
-        zfi_number 		    'zfiNumber',
-        zfi_amount 		    'zfiAmount',
+        zfi_id 		                                  'zfiId',
+        zfi_number 		                              'zfiNumber',
+        zfi_supplier_id                               'zfiSupplierId',
+        zfi_core_id                                   'zfiCoreId',
+        zfi_core_quota_id                             'zfiCoreQuotaId',
+        zfi_supplier_quota_id                         'zfiSupplierQuotaId',
+        zfi_product_id                                'zfiProductId',
+        zfi_create_type                               'zfiCreateType',
+        zfi_amount 		                              'zfiAmount',
+        zfi_collection_account                        'zfiCollectionAccount',
+        zfi_rate                                      'zfiRate',
+        zfi_payment_number                            'zfiPaymentNumber',
+        DATE_FORMAT(zfi_effective_date,'%Y-%m-%d')    'zfiEffectiveDate',
+        DATE_FORMAT(zfi_sign_date,'%Y-%m-%d')         'zfiSignDate',
         DATE_FORMAT(zfi_expire_date,'%Y-%m-%d %H:%i:%s') AS 	'zfiExpireDate',
-        zfi_product_id      'zfiProductId',
-        zfpcr_rate 		    'zfpcrRate',
-        zfpcr_loan_type 	'zfpcrLoantype',
-        zfpcr_charge_rate   'zfpcrChargeRate'
+        zfi_platform_status                           'zfiPlatformStatus',
+        zfi_supplier_status                           'zfiSupplierStatus',
+        zfi_core_status                               'zfiCoreStatus',
+        zfi_cfca_core_no                              'zfiCfcaCoreNo',
+        zfi_cfca_supplier_no                          'zfiCfcaSupplierNo',
+        zfi_status                                    'zfiStatus',
+        zfpcr_rate 		                              'zfpcrRate',
+        zfpcr_loan_type 	                          'zfpcrLoantype',
+        zfpcr_charge_rate                             'zfpcrChargeRate'
         FROM
         zc_finance_inf
         LEFT JOIN zc_finance_pro_com_rel