|
@@ -6,9 +6,7 @@ import com.alibaba.excel.EasyExcel;
|
|
|
import com.alibaba.excel.ExcelReader;
|
|
|
import com.alibaba.excel.read.listener.PageReadListener;
|
|
|
import com.alibaba.excel.read.metadata.ReadSheet;
|
|
|
-import com.aspose.words.Document;
|
|
|
-import com.aspose.words.DocumentBuilder;
|
|
|
-import com.aspose.words.ImportFormatMode;
|
|
|
+import com.aspose.words.*;
|
|
|
import com.dayou.bo.CRReportFillBO;
|
|
|
import com.dayou.bo.EqptReportFillBO;
|
|
|
import com.dayou.config.FileNetConfig;
|
|
@@ -41,9 +39,8 @@ import java.math.RoundingMode;
|
|
|
import java.nio.file.Files;
|
|
|
import java.nio.file.Paths;
|
|
|
import java.text.DecimalFormat;
|
|
|
-import java.util.ArrayList;
|
|
|
+import java.util.*;
|
|
|
import java.util.List;
|
|
|
-import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -52,6 +49,7 @@ import static com.dayou.enums.CRReportTmplCode.*;
|
|
|
import static com.dayou.enums.DocumentType.CR_REPORT;
|
|
|
import static com.dayou.enums.DocumentType.EQPT_REPORT;
|
|
|
import static com.dayou.enums.EqptReportTmplCode.*;
|
|
|
+import static com.dayou.utils.AsposeWordUtil.findTableIndex;
|
|
|
import static com.dayou.utils.EasyExcelUtil.getCellValueByIndex;
|
|
|
import static com.dayou.utils.EasyExcelUtil.hasColumnIndexGetRowIndexByValue;
|
|
|
|
|
@@ -486,6 +484,8 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
.collect(Collectors.toList());
|
|
|
// 处理债务人信息
|
|
|
List<CRReportBaseInfoBO.DebtorInfo> debtorInfoList = new ArrayList<>();
|
|
|
+ // 目前来说只考虑一个债务人的情况,所以只拿第一个元素的受偿分析即可
|
|
|
+ crReportBaseInfoBO.setRepaymentCapacityAnalysis(debtorInfoStrList.get(0).getRepaymentCapacityAnalysisStr());
|
|
|
for (DebtorInfoStrBO infoStr : debtorInfoStrList) {
|
|
|
CRReportBaseInfoBO.DebtorInfo debtorInfo = new CRReportBaseInfoBO.DebtorInfo();
|
|
|
String debtorStr = infoStr.getInfoStr();
|
|
@@ -528,6 +528,7 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
}
|
|
|
if (infoStr.getGuarantorType().equals("企业")) {
|
|
|
CRReportBaseInfoBO.EnterpriseGuarantor enterpriseGuarantor = new CRReportBaseInfoBO.EnterpriseGuarantor();
|
|
|
+ enterpriseGuarantor.setRepaymentCapacityAnalysis(infoStr.getRepaymentCapacityAnalysisStr());
|
|
|
String guarantorStr = infoStr.getInfoStr();
|
|
|
enterpriseGuarantor.setGuarantorName(guarantorStr.substring(guarantorStr.indexOf("公司名称:") + "公司名称:".length(), guarantorStr.indexOf("\n")));
|
|
|
guarantorStr = guarantorStr.replaceFirst("\n", "");
|
|
@@ -550,6 +551,7 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
enterpriseGuarantorList.add(enterpriseGuarantor);
|
|
|
} else if (infoStr.getGuarantorType().equals("自然人")) {
|
|
|
CRReportBaseInfoBO.PersonGuarantor personGuarantor = new CRReportBaseInfoBO.PersonGuarantor();
|
|
|
+ personGuarantor.setRepaymentCapacityAnalysis(infoStr.getRepaymentCapacityAnalysisStr());
|
|
|
String guarantorStr = infoStr.getInfoStr();
|
|
|
personGuarantor.setGuarantorName(guarantorStr.substring(guarantorStr.indexOf("姓名:") + "姓名:".length(), guarantorStr.indexOf("\n")));
|
|
|
guarantorStr = guarantorStr.replaceFirst("\n", "");
|
|
@@ -598,28 +600,54 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
crReportFillBO.setChineseReportDate(DateToChinese.dateStrConvertChinese(crReportFillBO.getReportBaseInfo().getReportDate()));
|
|
|
|
|
|
// 获取汇总表合计行的下标(用来获取债权汇总表的合计信息)
|
|
|
- Integer rowindex = hasColumnIndexGetRowIndexByValue(1,"合计",fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表");
|
|
|
- if (ObjectUtil.isNotNull(rowindex)) {
|
|
|
+ Integer rowindexAggregate = hasColumnIndexGetRowIndexByValue(1,"合计",fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表");
|
|
|
+ if (ObjectUtil.isNotNull(rowindexAggregate)) {
|
|
|
// 千分位格式处理
|
|
|
DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");
|
|
|
// 设置贷款本金
|
|
|
- crReportFillBO.setLoanPrincipal(new BigDecimal(getCellValueByIndex(rowindex, 2, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
+ crReportFillBO.setLoanPrincipal(new BigDecimal(getCellValueByIndex(rowindexAggregate, 2, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
crReportFillBO.setLoanPrincipalStr(decimalFormat.format(crReportFillBO.getLoanPrincipal()));
|
|
|
// 设置应收利息(含罚息)
|
|
|
- crReportFillBO.setInterest(new BigDecimal(getCellValueByIndex(rowindex, 3, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
+ crReportFillBO.setInterest(new BigDecimal(getCellValueByIndex(rowindexAggregate, 3, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
crReportFillBO.setInterestStr(decimalFormat.format(crReportFillBO.getInterest()));
|
|
|
// 设置其他费用
|
|
|
- crReportFillBO.setOtherExpenses(new BigDecimal(getCellValueByIndex(rowindex, 4, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
+ crReportFillBO.setOtherExpenses(new BigDecimal(getCellValueByIndex(rowindexAggregate, 4, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
crReportFillBO.setOtherExpensesStr(decimalFormat.format(crReportFillBO.getOtherExpenses()));
|
|
|
// 设置各项债权合计
|
|
|
- crReportFillBO.setCRTotal(new BigDecimal(getCellValueByIndex(rowindex, 5, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
+ crReportFillBO.setCRTotal(new BigDecimal(getCellValueByIndex(rowindexAggregate, 5, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
crReportFillBO.setCRTotalStr(decimalFormat.format(crReportFillBO.getCRTotal()));
|
|
|
-
|
|
|
// 设置债权清算价值
|
|
|
- crReportFillBO.setTotalLiquidationValue(new BigDecimal(getCellValueByIndex(rowindex, 11, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
+ crReportFillBO.setTotalLiquidationValue(new BigDecimal(getCellValueByIndex(rowindexAggregate, 11, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总表")));
|
|
|
crReportFillBO.setTotalLiquidationValueStr(decimalFormat.format(crReportFillBO.getTotalLiquidationValue()));
|
|
|
}
|
|
|
|
|
|
+ // 获取汇总表合计行的下标(用来获取债权汇总表的合计信息)
|
|
|
+ Integer rowindexAggregateTenThousand = hasColumnIndexGetRowIndexByValue(1,"合计",fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总万元表");
|
|
|
+ if (ObjectUtil.isNotNull(rowindexAggregateTenThousand)) {
|
|
|
+ // 千分位格式处理
|
|
|
+ DecimalFormat decimalFormat = new DecimalFormat("#,##0.00");
|
|
|
+ // 设置优先受偿价值合计
|
|
|
+ crReportFillBO.setTotalPriorityClaimValue(new BigDecimal(getCellValueByIndex(rowindexAggregateTenThousand, 6, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总万元表")));
|
|
|
+ crReportFillBO.setTotalPriorityClaimValueStr(decimalFormat.format(crReportFillBO.getTotalPriorityClaimValue()));
|
|
|
+ // 设置一般受偿价值合计
|
|
|
+ crReportFillBO.setTotalGeneralClaimValue(new BigDecimal(getCellValueByIndex(rowindexAggregateTenThousand, 7, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总万元表")));
|
|
|
+ crReportFillBO.setTotalGeneralClaimValueStr(decimalFormat.format(crReportFillBO.getTotalGeneralClaimValue()));
|
|
|
+ // 设置保证受偿价值合计
|
|
|
+ crReportFillBO.setTotalGuaranteedClaimValue(new BigDecimal(getCellValueByIndex(rowindexAggregateTenThousand, 8, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总万元表")));
|
|
|
+ crReportFillBO.setTotalGuaranteedClaimValueStr(decimalFormat.format(crReportFillBO.getTotalGuaranteedClaimValue()));
|
|
|
+ // 设置债权可回收金额合计
|
|
|
+ crReportFillBO.setTotalRecoverableAmount(new BigDecimal(getCellValueByIndex(rowindexAggregateTenThousand, 9, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总万元表")));
|
|
|
+ crReportFillBO.setTotalRecoverableAmountStr(decimalFormat.format(crReportFillBO.getTotalRecoverableAmount()));
|
|
|
+
|
|
|
+ // 设置债权清算价值合计
|
|
|
+ crReportFillBO.setTotalCreditorLiquidationValue(new BigDecimal(getCellValueByIndex(rowindexAggregateTenThousand, 11, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总万元表")));
|
|
|
+ crReportFillBO.setTotalCreditorLiquidationValueStr(decimalFormat.format(crReportFillBO.getTotalCreditorLiquidationValue()));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 设置本次所需处置时间与清算率取值
|
|
|
+ crReportFillBO.setTimeNeededForThisDisposal(getCellValueByIndex(66, 1, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "债权清算率"));
|
|
|
+ crReportFillBO.setLiquidationRateForThis(String.valueOf(new Double(getCellValueByIndex(66, 2, fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "债权清算率")) * 100));
|
|
|
+
|
|
|
// 获取汇总万元表合计行的下标
|
|
|
Integer allSheetRowIndex = hasColumnIndexGetRowIndexByValue(1,"合计",fileNetConfig.getBaseDir() + calculateDoc.getDocUrl(), "汇总万元表");
|
|
|
if (ObjectUtil.isNotNull(allSheetRowIndex)) {
|
|
@@ -635,6 +663,15 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
consolidatedList.remove(consolidatedList.size() - 1);
|
|
|
crReportFillBO.setConsolidatedList(consolidatedList);
|
|
|
|
|
|
+ // 读取综合因素分析表信息
|
|
|
+ List<CRReportFillBO.IntegratedAnalysis> integratedAnalysisList = EasyExcel.read(fileNetConfig.getBaseDir() + calculateDoc.getDocUrl()).head(CRReportFillBO.IntegratedAnalysis.class).sheet("债权清算率").doReadSync();
|
|
|
+ for (int i = 0; i < 56; i++) {
|
|
|
+ if (ObjectUtil.isNotEmpty(integratedAnalysisList.get(i).getWeight())) {
|
|
|
+ integratedAnalysisList.get(i).setWeight( (int) (new Double(integratedAnalysisList.get(i).getWeight()) * 100) + "%");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ crReportFillBO.setIntegratedAnalysisList(integratedAnalysisList.subList(0, 56)); // 后边的信息是清算率信息,此处不需要
|
|
|
+
|
|
|
// 第一步:设置封面
|
|
|
// 封面模板文件位置
|
|
|
String coverTmplPath = fileNetConfig.getBaseDir() + coverTmpl.getSectionFileUrl() + coverTmpl.getSectionFileName();
|
|
@@ -757,7 +794,7 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
lawsuitIs.close();
|
|
|
}
|
|
|
|
|
|
- // 诉讼情况信息模板文件位置
|
|
|
+ // 保证人补充偿债来源分析
|
|
|
String guarantorAdditionalDebtRepaymentSourcesPath = fileNetConfig.getBaseDir() + guarantorAdditionalDebtRepaymentSourcesTmpl.getSectionFileUrl() + guarantorAdditionalDebtRepaymentSourcesTmpl.getSectionFileName();
|
|
|
// 插入时会导致先插入的排在后插入的后面,所以把顺序反转一下(企业和自然人用同一个序号排序)
|
|
|
for (int i = guarantorInfoStrBOList.size(); i > 0; i--) {
|
|
@@ -798,6 +835,92 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
// 将目录插入到框架
|
|
|
AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, catalogueDoc, "insertCatalogue", false, false);
|
|
|
|
|
|
+ // 创建综合因素分析表
|
|
|
+ Document tableDoc = new Document();
|
|
|
+ DocumentBuilder tableBuilder = new DocumentBuilder(tableDoc);
|
|
|
+ tableBuilder.startBookmark("table");
|
|
|
+ tableBuilder.endBookmark("table");
|
|
|
+ AsposeWordUtil.createTable(tableDoc, CRReportFillBO.IntegratedAnalysis.class, crReportFillBO.getIntegratedAnalysisList(), "table", false);
|
|
|
+ //将第一列整列合并
|
|
|
+ tableBuilder.moveToCell(0,1,0,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 2; i < 56; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 0, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第2行合并到31行
|
|
|
+ tableBuilder.moveToCell(0,1,1,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 2; i < 31; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 1, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第33行合并到38行
|
|
|
+ tableBuilder.moveToCell(0,32,1,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 33; i < 38; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 1, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第40行合并到47行
|
|
|
+ tableBuilder.moveToCell(0,39,1,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 40; i < 47; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 1, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第49行合并到51行
|
|
|
+ tableBuilder.moveToCell(0,48,1,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 49; i < 51; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 1, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第53行合并到55行
|
|
|
+ tableBuilder.moveToCell(0,52,1,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 53; i < 55; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 1, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+
|
|
|
+ //将第三列第2行合并到31行
|
|
|
+ tableBuilder.moveToCell(0,1,2,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 2; i < 31; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 2, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第33行合并到38行
|
|
|
+ tableBuilder.moveToCell(0,32,2,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 33; i < 38; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 2, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第40行合并到47行
|
|
|
+ tableBuilder.moveToCell(0,39,2,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 40; i < 47; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 2, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第49行合并到51行
|
|
|
+ tableBuilder.moveToCell(0,48,2,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 49; i < 51; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 2, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ //将第二列第53行合并到55行
|
|
|
+ tableBuilder.moveToCell(0,52,2,0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.FIRST);//合并的第一个单元格 保留的值是第一个单元格的值
|
|
|
+ for(int i = 53; i < 55; i++ ) {
|
|
|
+ tableBuilder.moveToCell(0, i, 2, 0);
|
|
|
+ tableBuilder.getCellFormat().setVerticalMerge(CellMerge.PREVIOUS);
|
|
|
+ }
|
|
|
+ AsposeWordUtil.insertDocumentAfterBookMark(mainDoc, tableDoc, "insertIntegratedAnalysis", false, false);
|
|
|
+
|
|
|
// 第七步:删除预留书签插入位置的空白行
|
|
|
DocumentBuilder mainBuilder = new DocumentBuilder(mainDoc);
|
|
|
mainBuilder.moveToBookmark("insertDetail");
|
|
@@ -818,6 +941,12 @@ public class AssetsReportServiceImpl extends ServiceImpl<AssetsReportMapper, Ass
|
|
|
mainBuilder.getCurrentParagraph().remove();
|
|
|
mainBuilder.moveToBookmark("insertLawsuit");
|
|
|
mainBuilder.getCurrentParagraph().remove();
|
|
|
+ mainBuilder.moveToBookmark("insertIntegratedAnalysis");
|
|
|
+ mainBuilder.getCurrentParagraph().remove();
|
|
|
+ mainBuilder.moveToBookmark("insertGuarantorAdditionalDebtRepaymentSo");
|
|
|
+ mainBuilder.getCurrentParagraph().remove();
|
|
|
+ mainBuilder.moveToBookmark("table");
|
|
|
+ mainBuilder.getCurrentParagraph().remove();
|
|
|
|
|
|
// 第八步:生成并保存文档
|
|
|
// 将封面和文档进行拼接
|