|
|
@@ -1,32 +1,44 @@
|
|
|
package me.zhengjie.application.admin.service.impl;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.InputStream;
|
|
|
+import java.nio.charset.Charset;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+import javax.annotation.PostConstruct;
|
|
|
+
|
|
|
+import org.apache.commons.io.FileUtils;
|
|
|
+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 cn.hutool.core.util.ArrayUtil;
|
|
|
+import cn.hutool.core.util.ZipUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import me.zhengjie.application.admin.service.AdminOrderService;
|
|
|
import me.zhengjie.application.admin.service.CochainLogService;
|
|
|
import me.zhengjie.application.admin.service.OrderCochainService;
|
|
|
-import me.zhengjie.application.bank.service.BankOrderService;
|
|
|
import me.zhengjie.base.chain.CochainService;
|
|
|
import me.zhengjie.base.util.FileUploadUtil;
|
|
|
-import me.zhengjie.dao.mybatis.entity.BorrowerEntity;
|
|
|
import me.zhengjie.dao.mybatis.entity.CochainLogEntity;
|
|
|
+import me.zhengjie.dao.mybatis.entity.ContractOrderEntity;
|
|
|
import me.zhengjie.dao.mybatis.entity.FileInfoEntity;
|
|
|
import me.zhengjie.dao.mybatis.entity.OrderCochainEntity;
|
|
|
-import me.zhengjie.dao.mybatis.mapper.*;
|
|
|
-import org.apache.commons.io.FileUtils;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.stereotype.Service;
|
|
|
-
|
|
|
-import java.io.File;
|
|
|
-import java.io.InputStream;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Map;
|
|
|
+import me.zhengjie.dao.mybatis.entity.OrderFileEntity;
|
|
|
+import me.zhengjie.dao.mybatis.entity.OrderRoomIdEntity;
|
|
|
+import me.zhengjie.dao.mybatis.mapper.ContractOrderMapper;
|
|
|
+import me.zhengjie.dao.mybatis.mapper.ICochainLogDao;
|
|
|
+import me.zhengjie.dao.mybatis.mapper.OrderFileMapper;
|
|
|
+import me.zhengjie.dao.mybatis.mapper.OrderRoomIdMapper;
|
|
|
|
|
|
/**
|
|
|
- * TODO 这个需要去掉抵押人,可以有联合借款,联合抵押,现在都是按照单个处理,
|
|
|
+ *
|
|
|
*
|
|
|
* <p>
|
|
|
* 服务实现类
|
|
|
@@ -41,16 +53,8 @@ public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLo
|
|
|
|
|
|
@Autowired
|
|
|
OrderCochainService orderCochainService;
|
|
|
- @Autowired
|
|
|
- BorrowerMapper borrowerMapper;
|
|
|
- @Autowired
|
|
|
- MortgageMapper mortgageMapper;
|
|
|
- @Autowired
|
|
|
- GuaranteeMapper guaranteeMapper;
|
|
|
|
|
|
@Autowired
|
|
|
- BankOrderService bankOrderService;
|
|
|
- @Autowired
|
|
|
AdminOrderService adminOrderService;
|
|
|
@Autowired
|
|
|
CochainService cochainService;
|
|
|
@@ -60,8 +64,12 @@ public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLo
|
|
|
OrderFileMapper orderFileMapper;
|
|
|
@Autowired
|
|
|
OrderRoomIdMapper orderRoomIdMapper;
|
|
|
+ @Autowired
|
|
|
+ ContractOrderMapper contractOrderMapper;
|
|
|
+
|
|
|
+ private static String UPLOAD_FILE_PATH;
|
|
|
|
|
|
-// @PostConstruct
|
|
|
+ @PostConstruct
|
|
|
public void init() {
|
|
|
new Thread(new Runnable() {
|
|
|
|
|
|
@@ -72,222 +80,100 @@ public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLo
|
|
|
} catch (InterruptedException e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- chainEvidence();
|
|
|
+ try {
|
|
|
+ chainEvidence();
|
|
|
+ } catch (Exception e) {
|
|
|
+ // TODO Auto-generated catch block
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
}).start();
|
|
|
// t.set
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void chainEvidence() {
|
|
|
+ private void initCochainPath(String path) {
|
|
|
+ // 得到文件的临时目录
|
|
|
+ String applicationDir = FileUploadUtil.getApplicationTempDir();
|
|
|
+ String downloadPath = applicationDir + "/" + path + "/";
|
|
|
+ UPLOAD_FILE_PATH = downloadPath;
|
|
|
+ }
|
|
|
+
|
|
|
+ private void chainEvidence() throws Exception {
|
|
|
|
|
|
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();
|
|
|
- // 得到文件的临时目录
|
|
|
- String applicationDir = FileUploadUtil.getApplicationTempDir();
|
|
|
- String downloadPath = applicationDir + "/" + businessNo;
|
|
|
+ initCochainPath(businessNo);
|
|
|
+ List<File> zipList = new ArrayList<>();
|
|
|
+ QueryWrapper<ContractOrderEntity> orderqw = new QueryWrapper<>();
|
|
|
+ orderqw.eq("business_no", businessNo);
|
|
|
+ ContractOrderEntity contractOrder = contractOrderMapper.selectOne(orderqw);
|
|
|
// 查询数据
|
|
|
log.info("【开始】调用上链业务编号:" + businessNo);
|
|
|
-
|
|
|
// 查询所有上传的图片
|
|
|
Map<String, FileInfoEntity> map = adminOrderService.getUploadFile(businessNo);
|
|
|
- // 身份证正面
|
|
|
- //recordCochain(obj.getCardFront(), "");
|
|
|
-// for (BorrowerEntity obj : borrowers) {
|
|
|
-//
|
|
|
-// }
|
|
|
-// List<CochainLogEntity> logs = new ArrayList<CochainLogEntity>();
|
|
|
-// final String borrower = "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);
|
|
|
+ // 身份证正面idcard_front_pic
|
|
|
+ download(contractOrder.getIdcardFrontPic(), map, "身份证正面", zipList);
|
|
|
+ // 身份证反面
|
|
|
+ download(contractOrder.getIdcardBackPic(), map, "身份证反面", zipList);
|
|
|
+ // 合同contract_attachment
|
|
|
+ download(contractOrder.getContractAttachment(), map, "合同", zipList);
|
|
|
+ // 抵押物 mortgage_pic
|
|
|
+ download(contractOrder.getMortgagePic(), map, "抵押物", zipList);
|
|
|
+ // 结婚证
|
|
|
+ download(contractOrder.getMarragePic(), map, "结婚证", zipList);
|
|
|
+ // 其他上传
|
|
|
+ download(contractOrder.getOtherUpload(), map, "其他上传", zipList);
|
|
|
+ // 户口本
|
|
|
+ download(contractOrder.getHkbPic(), map, "户口本", zipList);
|
|
|
+ // 配偶身份证正面照片
|
|
|
+ download(contractOrder.getJointIdcardFrontPic(), map, "共同借款身份证正面", zipList);
|
|
|
+ // 配偶身份证反面照片
|
|
|
+ download(contractOrder.getJointIdcardBackPic(), map, "共同借款身份证反面照片", zipList);
|
|
|
|
|
|
// 带有盖章的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 = orderRoomIdMapper.selectList(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 = orderRoomIdMapper.selectList(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 = orderRoomIdMapper.selectList(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);
|
|
|
+ QueryWrapper<OrderFileEntity> wrapper = new QueryWrapper<>();
|
|
|
+ wrapper.eq("business_no", businessNo);
|
|
|
+ // 这里处理,如果没有盖章的就把签名的pdf上传
|
|
|
+ List<OrderFileEntity> orderFiles = orderFileMapper.selectList(wrapper);
|
|
|
+ for (OrderFileEntity orderFile : orderFiles) {
|
|
|
+ if (StringUtils.isNotBlank(orderFile.getSignedPdfUrl())) {
|
|
|
+ downloadByPath(orderFile.getSignedPdfUrl(), map, orderFile.getFileName(), zipList);
|
|
|
+ } else {
|
|
|
+ downloadByPath(orderFile.getPdfUrl(), map, orderFile.getFileName(), zipList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 处理视频
|
|
|
+ QueryWrapper<OrderRoomIdEntity> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.eq("business_no", businessNo);
|
|
|
+ queryWrapper.orderByDesc("create_time");
|
|
|
+ List<OrderRoomIdEntity> orderRoomList = orderRoomIdMapper.selectList(queryWrapper);
|
|
|
+ if (orderRoomList != null && orderRoomList.size() > 0) {
|
|
|
+ OrderRoomIdEntity orderRoomId = orderRoomList.get(0);
|
|
|
+ downloadByPath(orderRoomId.getAppVideoUrl(), map, "APP视频", zipList);
|
|
|
+ downloadByPath(orderRoomId.getPcVideoUrl(), map, "PC视频", zipList);
|
|
|
+ }
|
|
|
+ String fileName = businessNo + ".zip";
|
|
|
+ // 对文件进行压缩
|
|
|
+ File targetFile = new File(UPLOAD_FILE_PATH + fileName);
|
|
|
+ ZipUtil.zip(targetFile, Charset.forName("utf-8"), false, ArrayUtil.toArray(zipList, File.class));
|
|
|
+ // 将压缩完成的文件上传到文件服务器
|
|
|
+ String contentType = "application/x-zip-compressed";
|
|
|
+ String uploadPath = businessNo + "/" + fileName;
|
|
|
+
|
|
|
+ FileUploadUtil.uploadFile(uploadPath, contentType, targetFile);
|
|
|
+ // 删除本地的所有文件
|
|
|
+ FileUtils.forceDelete(targetFile.getParentFile());
|
|
|
+ log.info("【结束】调用上链业务编号:" + businessNo);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -295,11 +181,11 @@ public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLo
|
|
|
*/
|
|
|
@XxlJob("cochain")
|
|
|
public void jobCochain() {
|
|
|
- chainEvidence();
|
|
|
+ // chainEvidence();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 通过文件下载
|
|
|
+ * 通过文件路径上传
|
|
|
*
|
|
|
* @param businessNo
|
|
|
* @param orderId
|
|
|
@@ -308,13 +194,18 @@ public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLo
|
|
|
* @param cochainLogs
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
- public void recordCochain(String filePath, String destination) throws Exception {
|
|
|
+ public void downloadByPath(String filePath, Map<String, FileInfoEntity> map, String fileName, List<File> list)
|
|
|
+ throws Exception {
|
|
|
if (StringUtils.isNotBlank(filePath)) {
|
|
|
-
|
|
|
InputStream input = null;
|
|
|
try {
|
|
|
input = FileUploadUtil.getInputStream(filePath);
|
|
|
- FileUtils.copyInputStreamToFile(input, new File(destination));
|
|
|
+ int index = filePath.lastIndexOf(".");
|
|
|
+ String suffix = filePath.substring(index);
|
|
|
+ String destFile = UPLOAD_FILE_PATH + fileName + suffix;
|
|
|
+ File file = new File(destFile);
|
|
|
+ FileUtils.copyInputStreamToFile(input, file);
|
|
|
+ list.add(file);
|
|
|
} catch (Exception e) {
|
|
|
throw e;
|
|
|
} finally {
|
|
|
@@ -325,22 +216,45 @@ public class CochainLogServiceImpl extends ServiceImpl<ICochainLogDao, CochainLo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public void downloadFile(Long orderId, String fileId, Map<String, FileInfoEntity> map) {
|
|
|
- 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);
|
|
|
-
|
|
|
+ public void download(String fileId, Map<String, FileInfoEntity> map, String fileName, List<File> list)
|
|
|
+ throws Exception {
|
|
|
+ if (StringUtils.isBlank(fileId)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ // 先初始化
|
|
|
+ String[] fileIds = { fileId };
|
|
|
+ if (fileId.contains(",")) {
|
|
|
+ fileIds = fileId.split(",");
|
|
|
+ }
|
|
|
+ int i = 1;
|
|
|
+ for (String key : fileIds) {
|
|
|
+ // 计算是否已经包含了插入数据
|
|
|
+ FileInfoEntity fileInfo = map.get(key);
|
|
|
+ InputStream input = null;
|
|
|
+ try {
|
|
|
+ String filePath = fileInfo.getPath();
|
|
|
+ input = FileUploadUtil.getInputStream(filePath);
|
|
|
+ int index = filePath.lastIndexOf(".");
|
|
|
+ String suffix = filePath.substring(index);
|
|
|
+ String destFile = UPLOAD_FILE_PATH + fileName + (i++) + suffix;
|
|
|
+ File file = new File(destFile);
|
|
|
+ FileUtils.copyInputStreamToFile(input, file);
|
|
|
+ list.add(file);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
+ } finally {
|
|
|
+ if (input != null) {
|
|
|
+ input.close();
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ String path = "b13f8c4a31034286962c7c7d985b64d8_1.jpeg";
|
|
|
+ int index = path.lastIndexOf(".");
|
|
|
+ System.out.println(path.substring(index));
|
|
|
+ }
|
|
|
}
|