|
|
@@ -1,357 +0,0 @@
|
|
|
-package me.zhengjie.application.admin.service.impl;
|
|
|
-
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
-import me.zhengjie.dao.mybatis.mapper.*;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.xxl.job.core.handler.annotation.XxlJob;
|
|
|
-
|
|
|
-import lombok.extern.slf4j.Slf4j;
|
|
|
-import me.zhengjie.application.admin.service.CochainLogService;
|
|
|
-import me.zhengjie.application.admin.service.OrderCochainService;
|
|
|
-import me.zhengjie.application.bank.service.OrderRoomIdService;
|
|
|
-import me.zhengjie.application.bank.service.OrderService;
|
|
|
-import me.zhengjie.application.bank.service.SysDictService;
|
|
|
-import me.zhengjie.base.chain.CochainService;
|
|
|
-import me.zhengjie.base.util.FileUploadUtil;
|
|
|
-import me.zhengjie.base.util.UUIDGenerator;
|
|
|
-import me.zhengjie.dao.mybatis.entity.BorrowerEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.CochainLogEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.GuaranteeEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.MortgageEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
|
|
|
-import me.zhengjie.dao.mybatis.entity.OrderRoomIdEntity;
|
|
|
-
|
|
|
-/**
|
|
|
- * TODO 这个需要去掉抵押人,可以有联合借款,联合抵押,现在都是按照单个处理,
|
|
|
- *
|
|
|
- * <p>
|
|
|
- * 服务实现类
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @author humuyu
|
|
|
- * @since 2022-07-25
|
|
|
- */
|
|
|
-@Service
|
|
|
-@Slf4j
|
|
|
-public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLogEntity> implements CochainLogService {
|
|
|
-
|
|
|
- @Autowired
|
|
|
- OrderCochainService orderCochainService;
|
|
|
- @Autowired
|
|
|
- BorrowerMapper borrowerMapper;
|
|
|
- @Autowired
|
|
|
- MortgageMapper mortgageMapper;
|
|
|
- @Autowired
|
|
|
- GuaranteeMapper guaranteeMapper;
|
|
|
-
|
|
|
- @Autowired
|
|
|
- OrderService orderService;
|
|
|
- @Autowired
|
|
|
- CochainService cochainService;
|
|
|
- @Autowired
|
|
|
- CochainLogService cochainLogService;
|
|
|
- @Autowired
|
|
|
- OrderFileMapper orderFileMapper;
|
|
|
- @Autowired
|
|
|
- OrderRoomIdService orderRoomService;
|
|
|
- @Autowired
|
|
|
- SysDictService sysDictService;
|
|
|
-// @PostConstruct
|
|
|
- public void init() {
|
|
|
- new Thread(new Runnable() {
|
|
|
-
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- try {
|
|
|
- Thread.sleep(1000l);
|
|
|
- } catch (InterruptedException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- chainEvidence();
|
|
|
- }
|
|
|
- }).start();
|
|
|
- // t.set
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- private void chainEvidence() {
|
|
|
-
|
|
|
- QueryWrapper<OrderCochainEntity> qw = new QueryWrapper<>();
|
|
|
- qw = qw.in("status", 0, 2).orderByAsc("create_time").last("limit 1");
|
|
|
-
|
|
|
- OrderCochainEntity cochainEntity = orderCochainService.getOne(qw);
|
|
|
- if (cochainEntity == null) {
|
|
|
- log.info("没有上链数据:");
|
|
|
- return;
|
|
|
- }
|
|
|
- // 先读取借款人的,
|
|
|
- String businessNo = cochainEntity.getBusinessNo();
|
|
|
- // 查询数据
|
|
|
- log.info("【开始】调用上链业务编号:"+businessNo);
|
|
|
- CochainLogEntity cochainLog = new CochainLogEntity();
|
|
|
- cochainLog.setBusinessNo(businessNo);
|
|
|
- // 查询已经插入过的
|
|
|
- QueryWrapper<CochainLogEntity> callCochainLog = cochainLogService.convertQuery(cochainLog).select("file_path");
|
|
|
- List<String> cochainLogs = cochainLogService.listObjs(callCochainLog, a -> {
|
|
|
- return String.valueOf(a.toString());
|
|
|
- });
|
|
|
- // 查询所有上传的图片
|
|
|
- Map<String, FileInfoEntity> map = orderService.getUploadFile(businessNo);
|
|
|
- // 借款人查询数据
|
|
|
- QueryWrapper<BorrowerEntity> borrowerQW = new QueryWrapper<>();
|
|
|
- borrowerQW.eq("business_no",businessNo);
|
|
|
- List<BorrowerEntity> borrowers = borrowerMapper.selectList(borrowerQW);
|
|
|
- for (BorrowerEntity obj : borrowers) {
|
|
|
- List<CochainLogEntity> logs = new ArrayList<CochainLogEntity>();
|
|
|
- final String borrower="借款人";
|
|
|
- //身份证正面
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCardFront(), map, logs, cochainLogs,"身份证正面",borrower);
|
|
|
- //身份证反面
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCardBack(), map, logs, cochainLogs,"身份证反面",borrower);
|
|
|
- // 合同
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCompactPic(), map, logs, cochainLogs,"合同",borrower);
|
|
|
- // 抵押物
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getMortgagePic(), map, logs, cochainLogs,"抵押物",borrower);
|
|
|
- // 结婚证
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getMarragePic(), map, logs, cochainLogs,"结婚证",borrower);
|
|
|
- // 其他上传
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getOtherUpload(), map, logs, cochainLogs,"其他上传",borrower);
|
|
|
- // 户口本
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getHkbPic(), map, logs, cochainLogs,"户口本",borrower);
|
|
|
- // 配偶身份证正面照片
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getSpouseIdcardFrontPic(), map, logs, cochainLogs,"配偶身份证正面照片",borrower);
|
|
|
- //配偶身份证反面照片
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getSpouseIdcardBackPic(), map, logs, cochainLogs,"配偶身份证反面照片",borrower);
|
|
|
-
|
|
|
- // 带有盖章的pdf
|
|
|
- QueryWrapper<OrderFileEntity> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("business_no", businessNo);
|
|
|
- wrapper.eq("contract_id", obj.getId());
|
|
|
- // 这里处理,如果没有盖章的就把签名的pdf上传
|
|
|
- List<OrderFileEntity> orderFiles = orderFileMapper.selectList(wrapper);
|
|
|
- for (OrderFileEntity orderFile : orderFiles) {
|
|
|
- if (StringUtils.isNotBlank(orderFile.getSignedPdfUrl())) {
|
|
|
- recordCochain(businessNo, obj.getId(), orderFile.getSignedPdfUrl(), logs, cochainLogs,orderFile.getFileName(),borrower);
|
|
|
- } else {
|
|
|
- recordCochain(businessNo, obj.getId(), orderFile.getPdfUrl(), logs, cochainLogs,orderFile.getFileName(),borrower);
|
|
|
- }
|
|
|
- }
|
|
|
- // 处理视频
|
|
|
- QueryWrapper<OrderRoomIdEntity> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("orderId", obj.getId());
|
|
|
- queryWrapper.orderByDesc("create_time");
|
|
|
- List<OrderRoomIdEntity> orderRoomList = orderRoomService.list(queryWrapper);
|
|
|
- if (orderRoomList != null && orderRoomList.size() > 0) {
|
|
|
- OrderRoomIdEntity orderRoomId = orderRoomList.get(0);
|
|
|
- recordCochain(businessNo, obj.getId(), orderRoomId.getAppVideoUrl(), logs, cochainLogs,"APP视频",borrower);
|
|
|
- recordCochain(businessNo, obj.getId(), orderRoomId.getPcVideoUrl(), logs, cochainLogs,"PC视频",borrower);
|
|
|
- }
|
|
|
- // 数据插入
|
|
|
- cochainLogService.saveBatch(logs);
|
|
|
- }
|
|
|
- // 抵押人查询数据
|
|
|
- QueryWrapper<MortgageEntity> mortgageQW = new QueryWrapper<>();
|
|
|
- mortgageQW.eq("business_no",businessNo);
|
|
|
- List<MortgageEntity> mortgages = mortgageMapper.selectList(mortgageQW);
|
|
|
- for (MortgageEntity obj : mortgages) {
|
|
|
- final String mortgage="抵押人";
|
|
|
- List<CochainLogEntity> logs = new ArrayList<CochainLogEntity>();
|
|
|
- // 身份证正面
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCardFront(), map, logs, cochainLogs,"身份证正面",mortgage);
|
|
|
- // 身份证反面
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCardBack(), map, logs, cochainLogs,"身份证反面",mortgage);
|
|
|
- // 合同
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCompactPic(), map, logs, cochainLogs,"身份证反面",mortgage);
|
|
|
- // 房产证
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getMarragePic(), map, logs, cochainLogs,"身份证反面",mortgage);
|
|
|
- // 房产证
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getMarragePic(), map, logs, cochainLogs,"身份证反面",mortgage);
|
|
|
- // 其他上传
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getOtherUpload(), map, logs, cochainLogs,"身份证反面",mortgage);
|
|
|
- // 户口本
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getHkbPic(), map, logs, cochainLogs,"身份证反面",mortgage);
|
|
|
-
|
|
|
- // 配偶身份证正面照片
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getSpouseIdcardFrontPic(), map, logs, cochainLogs,"配偶身份证正面照片",mortgage);
|
|
|
- //配偶身份证反面照片
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getSpouseIdcardBackPic(), map, logs, cochainLogs,"配偶身份证反面照片",mortgage);
|
|
|
-
|
|
|
- // 带有盖章的pdf
|
|
|
- QueryWrapper<OrderFileEntity> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("business_no", businessNo);
|
|
|
- wrapper.eq("contract_id", obj.getId());
|
|
|
- // 这里处理,如果没有盖章的就把签名的pdf上传
|
|
|
- List<OrderFileEntity> orderFiles = orderFileMapper.selectList(wrapper);
|
|
|
- for (OrderFileEntity orderFile : orderFiles) {
|
|
|
- if (StringUtils.isNotBlank(orderFile.getSignedPdfUrl())) {
|
|
|
- recordCochain(businessNo, obj.getId(), orderFile.getSignedPdfUrl(), logs, cochainLogs,orderFile.getFileName(),mortgage);
|
|
|
- } else {
|
|
|
- recordCochain(businessNo, obj.getId(), orderFile.getPdfUrl(), logs, cochainLogs,orderFile.getFileName(),mortgage);
|
|
|
- }
|
|
|
- }
|
|
|
- // 处理视频
|
|
|
- QueryWrapper<OrderRoomIdEntity> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("orderId", obj.getId());
|
|
|
- queryWrapper.orderByDesc("create_time");
|
|
|
- List<OrderRoomIdEntity> orderRoomList = orderRoomService.list(queryWrapper);
|
|
|
- if (orderRoomList != null && orderRoomList.size() > 0) {
|
|
|
- OrderRoomIdEntity orderRoomId = orderRoomList.get(0);
|
|
|
- recordCochain(businessNo, obj.getId(), orderRoomId.getAppVideoUrl(), logs, cochainLogs,"APP视频",mortgage);
|
|
|
- recordCochain(businessNo, obj.getId(), orderRoomId.getPcVideoUrl(), logs, cochainLogs,"APP视频",mortgage);
|
|
|
- }
|
|
|
- // 数据插入
|
|
|
- cochainLogService.saveBatch(logs);
|
|
|
- }
|
|
|
- // 担保人查询数据
|
|
|
- QueryWrapper<GuaranteeEntity> guaranteeQW = new QueryWrapper<>();
|
|
|
- guaranteeQW.eq("business_no",businessNo);
|
|
|
- List<GuaranteeEntity> guarantees = guaranteeMapper.selectList(guaranteeQW);
|
|
|
- for (GuaranteeEntity obj : guarantees) {
|
|
|
- final String guarantee="担保人";
|
|
|
- List<CochainLogEntity> logs = new ArrayList<CochainLogEntity>();
|
|
|
- // 身份证正面
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCardFront(), map, logs, cochainLogs,"身份证反面",guarantee);
|
|
|
- // 身份证反面
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCardBack(), map, logs, cochainLogs,"身份证反面",guarantee);
|
|
|
- // 合同
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getCompactPic(), map, logs, cochainLogs,"身份证反面",guarantee);
|
|
|
- // 房产证
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getMarragePic(), map, logs, cochainLogs,"身份证反面",guarantee);
|
|
|
- // 房产证
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getMarragePic(), map, logs, cochainLogs,"身份证反面",guarantee);
|
|
|
- // 其他上传
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getOtherUpload(), map, logs, cochainLogs,"身份证反面",guarantee);
|
|
|
- // 户口本
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getHkbPic(), map, logs, cochainLogs,"身份证反面",guarantee);
|
|
|
- // 配偶身份证正面照片
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getSpouseIdcardFrontPic(), map, logs, cochainLogs,"配偶身份证正面照片",guarantee);
|
|
|
- //配偶身份证反面照片
|
|
|
- recordCochain(businessNo, obj.getId(), obj.getSpouseIdcardBackPic(), map, logs, cochainLogs,"配偶身份证反面照片",guarantee);
|
|
|
-
|
|
|
- // 带有盖章的pdf
|
|
|
- QueryWrapper<OrderFileEntity> wrapper = new QueryWrapper<>();
|
|
|
- wrapper.eq("business_no", businessNo);
|
|
|
- wrapper.eq("contract_id", obj.getId());
|
|
|
- // 这里处理,如果没有盖章的就把签名的pdf上传
|
|
|
- List<OrderFileEntity> orderFiles = orderFileMapper.selectList(wrapper);
|
|
|
- for (OrderFileEntity orderFile : orderFiles) {
|
|
|
- if (StringUtils.isNotBlank(orderFile.getSignedPdfUrl())) {
|
|
|
- recordCochain(businessNo, obj.getId(), orderFile.getSignedPdfUrl(), logs, cochainLogs,orderFile.getFileName(),guarantee);
|
|
|
- } else {
|
|
|
- recordCochain(businessNo, obj.getId(), orderFile.getPdfUrl(), logs, cochainLogs,orderFile.getFileName(),guarantee);
|
|
|
- }
|
|
|
- }
|
|
|
- // 处理视频
|
|
|
- QueryWrapper<OrderRoomIdEntity> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("orderId", obj.getId());
|
|
|
- queryWrapper.orderByDesc("create_time");
|
|
|
- List<OrderRoomIdEntity> orderRoomList = orderRoomService.list(queryWrapper);
|
|
|
- if (orderRoomList != null && orderRoomList.size() > 0) {
|
|
|
- OrderRoomIdEntity orderRoomId = orderRoomList.get(0);
|
|
|
- recordCochain(businessNo, obj.getId(), orderRoomId.getAppVideoUrl(), logs, cochainLogs,"APP视频",guarantee);
|
|
|
- recordCochain(businessNo, obj.getId(), orderRoomId.getPcVideoUrl(), logs, cochainLogs,"PC视频",guarantee);
|
|
|
- }
|
|
|
- // 数据插入
|
|
|
- cochainLogService.saveBatch(logs);
|
|
|
- }
|
|
|
- // 查询是否有失败的
|
|
|
- CochainLogEntity success = new CochainLogEntity();
|
|
|
- success.setBusinessNo(businessNo);
|
|
|
- success.setStatus("0");
|
|
|
- long count = cochainLogService.count(success);
|
|
|
- if (count > 0) {
|
|
|
- cochainEntity.setStatus("2");
|
|
|
- cochainEntity.setUpdateTime(LocalDateTime.now());
|
|
|
- } else {
|
|
|
- cochainEntity.setStatus("1");
|
|
|
- cochainEntity.setUpdateTime(LocalDateTime.now());
|
|
|
- }
|
|
|
- orderCochainService.updateById(cochainEntity);
|
|
|
- log.info("【结束】调用上链业务编号:"+businessNo);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 调用第三方上链接口
|
|
|
- */
|
|
|
- @XxlJob("cochain")
|
|
|
- public void jobCochain() {
|
|
|
- chainEvidence();
|
|
|
- }
|
|
|
- /**
|
|
|
- * 通过文件路径上传
|
|
|
- * @param businessNo
|
|
|
- * @param orderId
|
|
|
- * @param filePath
|
|
|
- * @param logs
|
|
|
- * @param cochainLogs
|
|
|
- */
|
|
|
- public void recordCochain(String businessNo, Long orderId, String filePath, List<CochainLogEntity> logs,
|
|
|
- List<String> cochainLogs,String fileType,String desc) {
|
|
|
- if (StringUtils.isNotBlank(filePath) && !cochainLogs.contains(filePath)) {
|
|
|
- // 先初始化
|
|
|
- CochainLogEntity chainLog = new CochainLogEntity();
|
|
|
- String bisCode = UUIDGenerator.uuid();
|
|
|
- chainLog.setBusinessNo(businessNo);
|
|
|
- chainLog.setOrderId(orderId.toString());
|
|
|
- chainLog.setFilePath(filePath);
|
|
|
- chainLog.setCreateTime(LocalDateTime.now());
|
|
|
- chainLog.setUpdateTime(LocalDateTime.now());
|
|
|
- chainLog.setBisCode(bisCode);
|
|
|
- chainLog.setFileType(fileType);
|
|
|
- chainLog.setDesc(desc);
|
|
|
- long size = FileUploadUtil.getSize(filePath);
|
|
|
- cochainService.sendRequest(chainLog, String.valueOf(size));
|
|
|
- logs.add(chainLog);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- public void recordCochain(String businessNo, Long orderId, String fileId, Map<String, FileInfoEntity> map,
|
|
|
- List<CochainLogEntity> logs, List<String> cochainLogs,String fileType,String desc) {
|
|
|
- if (StringUtils.isNotBlank(fileId)) {
|
|
|
- // 先初始化
|
|
|
- String[] list = { fileId };
|
|
|
- if (fileId.contains(",")) {
|
|
|
- list = fileId.split(",");
|
|
|
- }
|
|
|
- int i=1;
|
|
|
- for (String key : list) {
|
|
|
- // 计算是否已经包含了插入数据
|
|
|
- FileInfoEntity fileInfo = map.get(key);
|
|
|
- if (!cochainLogs.contains(fileInfo.getPath())) {
|
|
|
- CochainLogEntity chainLog = new CochainLogEntity();
|
|
|
- long size = FileUploadUtil.getSize(fileInfo.getPath());
|
|
|
- String bisCode = UUIDGenerator.uuid();
|
|
|
- chainLog.setBusinessNo(businessNo);
|
|
|
- chainLog.setOrderId(orderId.toString());
|
|
|
- chainLog.setFilePath(fileInfo.getPath());
|
|
|
- chainLog.setImageId(fileId);
|
|
|
- chainLog.setCreateTime(LocalDateTime.now());
|
|
|
- chainLog.setUpdateTime(LocalDateTime.now());
|
|
|
- chainLog.setBisCode(bisCode);
|
|
|
- chainLog.setFileType(fileType);
|
|
|
- chainLog.setDesc(desc);
|
|
|
- chainLog.setSeq(i++);
|
|
|
- cochainService.sendRequest(chainLog, String.valueOf(size));
|
|
|
- logs.add(chainLog);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- public static void main(String[] args) {
|
|
|
- int i=1;
|
|
|
- System.out.println(i++);
|
|
|
- }
|
|
|
-}
|