|
|
@@ -19,6 +19,7 @@ import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.time.LocalDate;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import static cn.com.zfc.day018.ZipMultiFile.zipFiles;
|
|
|
|
|
|
@@ -63,7 +64,7 @@ public class EasyExcelUtils {
|
|
|
head2.add("开户银行");
|
|
|
List<String> head3 = ListUtils.newArrayList();
|
|
|
head3.add("银行卡余额");
|
|
|
- list.add(0,head);
|
|
|
+ list.add(0, head);
|
|
|
list.add(1, head1);
|
|
|
list.add(2, head2);
|
|
|
list.add(3, head3);
|
|
|
@@ -78,22 +79,21 @@ public class EasyExcelUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
private static List<List<Object>> dataList(List<InvAccount> invAccounts, List<InvAccountOp> invAccountOpList, List<InvAccountProfit> invAccountProfitList) {
|
|
|
List<List<Object>> list = ListUtils.newArrayList();
|
|
|
invAccounts.forEach(invAccount -> {
|
|
|
List<Object> data = ListUtils.newArrayList();
|
|
|
invAccount.getInvAccountCardList().forEach(invAccountCard -> {
|
|
|
if (invAccountCard.getBankCardNum() != null) {
|
|
|
- data.add(invAccount.getOuterFlag().equals("0")?"内部账户":"外部账户");
|
|
|
+ data.add(invAccount.getOuterFlag().equals("0") ? "内部账户" : "外部账户");
|
|
|
data.add(invAccount.getAccountName());
|
|
|
data.add(invAccountCard.getBankName());
|
|
|
data.add(invAccountCard.getBalance());
|
|
|
|
|
|
invAccountProfitList.forEach(invAccountProfitList1 -> {
|
|
|
String a = "0";
|
|
|
- for (InvAccountOp invAccountProfit : invAccountOpList){
|
|
|
- if (invAccountProfitList1.getProfitEng().equals(invAccountProfit.getProfit())&&invAccountCard.getBankCardNum().equals(invAccountProfit.getCardNum())) {
|
|
|
+ for (InvAccountOp invAccountProfit : invAccountOpList) {
|
|
|
+ if (invAccountProfitList1.getProfitEng().equals(invAccountProfit.getProfit()) && invAccountCard.getBankCardNum().equals(invAccountProfit.getCardNum())) {
|
|
|
a = new BigDecimal(a).add(new BigDecimal(invAccountProfit.getMoney())).toString();
|
|
|
}
|
|
|
}
|
|
|
@@ -108,7 +108,6 @@ public class EasyExcelUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
/**
|
|
|
* 不创建对象的写
|
|
|
*/
|
|
|
@@ -137,8 +136,10 @@ public class EasyExcelUtils {
|
|
|
head5.add("分项");
|
|
|
List<String> head6 = ListUtils.newArrayList();
|
|
|
head6.add("支出金额");
|
|
|
+ List<String> head7 = ListUtils.newArrayList();
|
|
|
+ head7.add("转账类型");
|
|
|
|
|
|
- list.add(0,head);
|
|
|
+ list.add(0, head);
|
|
|
list.add(1, head1);
|
|
|
list.add(2, head2);
|
|
|
list.add(3, head3);
|
|
|
@@ -155,8 +156,7 @@ public class EasyExcelUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
- private static List<List<Object>> operatedataList( List<InvAccountOperate> invAccountOperates , List<InvAccountProfit> invAccountProfitList) {
|
|
|
+ private static List<List<Object>> operatedataList(List<InvAccountOperate> invAccountOperates, List<InvAccountProfit> invAccountProfitList) {
|
|
|
List<List<Object>> list = ListUtils.newArrayList();
|
|
|
invAccountOperates.forEach(invAccountOperate -> {
|
|
|
List<Object> data = ListUtils.newArrayList();
|
|
|
@@ -167,10 +167,11 @@ public class EasyExcelUtils {
|
|
|
data.add(invAccountOperate.getFundUse());
|
|
|
data.add(invAccountOperate.getFundFen());
|
|
|
data.add(invAccountOperate.getApplyAmount());
|
|
|
+ data.add(invAccountOperate.getRevenueOutlay().equals("0")?"收入":"支出");
|
|
|
invAccountProfitList.forEach(invAccountProfit -> {
|
|
|
- if (invAccountOperate.getOutProfit() != null){
|
|
|
- for (Map.Entry<String, Object> entry:invAccountOperate.getOutProfit().entrySet()){
|
|
|
- if (entry.getKey().equals(invAccountProfit.getProfitEng())){
|
|
|
+ if (invAccountOperate.getOutProfit() != null) {
|
|
|
+ for (Map.Entry<String, Object> entry : invAccountOperate.getOutProfit().entrySet()) {
|
|
|
+ if (entry.getKey().equals(invAccountProfit.getProfitEng())) {
|
|
|
data.add(entry.getValue());
|
|
|
}
|
|
|
}
|
|
|
@@ -182,15 +183,6 @@ public class EasyExcelUtils {
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
public static String downExcel(String uploadFilePath, String fileName, Class clz, List<?> list) {
|
|
|
|
|
|
String file = fileName + System.currentTimeMillis() + ".xlsx";
|
|
|
@@ -224,32 +216,55 @@ public class EasyExcelUtils {
|
|
|
/**
|
|
|
* 导出资金申请模板
|
|
|
*/
|
|
|
- public String downAccountExcel(String uploadFilePath, List<InvAccountExcel> invAccountExcel) {
|
|
|
+ public String downAccountExcel(String uploadFilePath, List<InvAccountExcel> invAccountExcel,List<InvAccountProfit> invAccountProfit) {
|
|
|
// 加载模板
|
|
|
String templateFile = "资金申请单模板.xlsx";
|
|
|
List<InvAccountExcel> list = new ArrayList<>();
|
|
|
// 获取工作表并填充
|
|
|
for (InvAccountExcel excel : invAccountExcel) {
|
|
|
- // 写入文件
|
|
|
- Date date = new Date();
|
|
|
- String file = date.getTime() + ".xlsx";
|
|
|
- String fileName = uploadFilePath + file;
|
|
|
- excel.setExcelApplyTime(new SimpleDateFormat("yyyy-MM-dd").format(excel.getApplyTime()));
|
|
|
- String payMethod = excel.getPayMethod();
|
|
|
- String[] split = payMethod.split(",");
|
|
|
- StringBuilder a = new StringBuilder();
|
|
|
- for (String i : split) {
|
|
|
- a.append(InvPayMethodEnum.getNameByCode(i)).append(",");
|
|
|
+ // 写入文件
|
|
|
+ Date date = new Date();
|
|
|
+ String file = date.getTime() + ".xlsx";
|
|
|
+ String fileName = uploadFilePath + file;
|
|
|
+ excel.setExcelApplyTime(new SimpleDateFormat("yyyy-MM-dd").format(excel.getApplyTime()));
|
|
|
+ String payMethod = excel.getPayMethod();
|
|
|
+ String[] split = payMethod.split(",");
|
|
|
+ StringBuilder a = new StringBuilder();
|
|
|
+ for (String i : split) {
|
|
|
+ a.append(InvPayMethodEnum.getNameByCode(i)).append(",");
|
|
|
+ }
|
|
|
+
|
|
|
+ StringBuilder stringBuffer = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, List<InvAccountProfit>> collect = invAccountProfit.stream().collect(
|
|
|
+ Collectors.groupingBy(
|
|
|
+ InvAccountProfit::getProfitEng
|
|
|
+ ));
|
|
|
+
|
|
|
+ for (Map.Entry<String, Object> entry : excel.getEntProfit().entrySet()) {
|
|
|
+ if (Integer.parseInt(entry.getValue().toString()) != 0) {
|
|
|
+ stringBuffer.append(collect.get(entry.getKey()).get(0).getProfitName()).append(" ").append(entry.getValue()).append("%");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ stringBuffer.append("→");
|
|
|
+
|
|
|
+ for (Map.Entry<String, Object> entry : excel.getOutProfit().entrySet()) {
|
|
|
+ if (Integer.parseInt(entry.getValue().toString()) != 0) {
|
|
|
+ stringBuffer.append(collect.get(entry.getKey()).get(0).getProfitName()).append(" ").append(entry.getValue()).append("%");
|
|
|
}
|
|
|
- excel.setPayMethod(a.toString());
|
|
|
- // 生成工作簿对象
|
|
|
- ExcelWriterBuilder workBookWriter = EasyExcel.write(fileName, InvAccountExcel.class)
|
|
|
- .withTemplate(templateFile);
|
|
|
-
|
|
|
- workBookWriter.sheet().doFill(excel);
|
|
|
- excel.setUplodePath(file);
|
|
|
- excel.setPayMethod(payMethod);
|
|
|
- list.add(excel);
|
|
|
+ }
|
|
|
+ excel.setPlate(stringBuffer.toString());
|
|
|
+
|
|
|
+
|
|
|
+ excel.setPayMethod(a.toString());
|
|
|
+ // 生成工作簿对象
|
|
|
+ ExcelWriterBuilder workBookWriter = EasyExcel.write(fileName, InvAccountExcel.class)
|
|
|
+ .withTemplate(templateFile);
|
|
|
+
|
|
|
+ workBookWriter.sheet().doFill(excel);
|
|
|
+ excel.setUplodePath(file);
|
|
|
+ excel.setPayMethod(payMethod);
|
|
|
+ list.add(excel);
|
|
|
}
|
|
|
insAccountExcelService.updateBatchById(list);
|
|
|
|
|
|
@@ -257,8 +272,8 @@ public class EasyExcelUtils {
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
srcFiles[i] = new File(uploadFilePath + list.get(i).getUplodePath());
|
|
|
}
|
|
|
- String a = LocalDate.now()+".zip";
|
|
|
- File zipFile = new File(uploadFilePath+a);
|
|
|
+ String a = LocalDate.now() + ".zip";
|
|
|
+ File zipFile = new File(uploadFilePath + a);
|
|
|
// 调用压缩方法
|
|
|
zipFiles(srcFiles, zipFile);
|
|
|
|