Commit a8063e31 by kangxiaoshan

修复收入导出

parent a337353b
...@@ -98,7 +98,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -98,7 +98,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
List<Object[]> contracts = contractRepository.findByDmpContractCode(codes); List<Object[]> contracts = contractRepository.findByDmpContractCode(codes);
Map<String, Object[]> names = contracts.stream().collect(Collectors.toMap(v -> v[0] + "", v -> v, (v1, v2) -> v1)); Map<String, Object[]> names = contracts.stream().collect(Collectors.toMap(v -> v[0] + "", v -> v, (v1, v2) -> v1));
for (DmpIncome dmpIncome : dmpIncomes) { for (DmpIncome dmpIncome : dmpIncomes) {
Object[] nameItem = names.get(dmpIncome.getCreateTime()); Object[] nameItem = names.get(dmpIncome.getContractCode());
//my_body_name, customer_body, customer_short, business_type, agreement_type //my_body_name, customer_body, customer_short, business_type, agreement_type
if (nameItem != null) { if (nameItem != null) {
dmpIncome.setMyBodyName(nameItem[1] + ""); dmpIncome.setMyBodyName(nameItem[1] + "");
...@@ -115,8 +115,8 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -115,8 +115,8 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
public HSSFWorkbook exportIncomeList(String startDate, String endDate, String bodyCode, String serchName) { public HSSFWorkbook exportIncomeList(String startDate, String endDate, String bodyCode, String serchName) {
List<DmpIncome> dmpIncomes = this.listByDs(startDate, endDate); List<DmpIncome> dmpIncomes = this.listByDs(startDate, endDate);
dmpIncomes = dmpIncomes.stream() dmpIncomes = dmpIncomes.stream()
.filter(v -> !StringUtils.isEmpty(bodyCode) && bodyCode.equals(v.getMyBodyName())) .filter(v -> StringUtils.isEmpty(bodyCode) || "all".equals(bodyCode) || bodyCode.equals(v.getMyBodyName()))
.filter(v -> StringUtils.isEmpty(serchName) && (v.getContractCode().contains(serchName) || v.getCustomerBody().contains(serchName))) .filter(v -> StringUtils.isEmpty(serchName) || (v.getContractCode().contains(serchName) || v.getCustomerBody().contains(serchName) || v.getMyBodyName().contains(serchName)))
.collect(Collectors.toList()); .collect(Collectors.toList());
DecimalFormat df = new DecimalFormat("##,##0.00"); DecimalFormat df = new DecimalFormat("##,##0.00");
...@@ -137,9 +137,10 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -137,9 +137,10 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
for (int j = 0; j < dmpIncomes.size(); j++) { for (int j = 0; j < dmpIncomes.size(); j++) {
HSSFRow rowBody = sheet.createRow(j + 1); HSSFRow rowBody = sheet.createRow(j + 1);
DmpIncome income = dmpIncomes.get(j); DmpIncome income = dmpIncomes.get(j);
String bussinesTypeName = income.getBusinessType() == null ? "" : bussinesName[Integer.parseInt(income.getBusinessType())];
String[] dataItem = new String[]{ String[] dataItem = new String[]{
income.getMyBodyName(), income.getIncomeMonth(), income.getCustomerBody(), income.getMyBodyName(), income.getIncomeMonth(), income.getCustomerBody(),
income.getCustomerShort(), income.getContractCode(), bussinesName[Integer.parseInt(income.getBusinessType())], income.getCustomerShort(), income.getContractCode(), bussinesTypeName,
income.getPeriod(), income.getSysSettlement(), income.getMonthSettlement(), income.getPeriod(), income.getSysSettlement(), income.getMonthSettlement(),
income.getTaxRate(), income.getConfirmSettlement() income.getTaxRate(), income.getConfirmSettlement()
}; };
...@@ -193,13 +194,20 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -193,13 +194,20 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
} }
Sheet sheet = workbook.getSheetAt(0); Sheet sheet = workbook.getSheetAt(0);
DecimalFormat df = new DecimalFormat("##,##0.00");
CompletableFuture.runAsync(() -> { CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch(); StopWatch stopWatch = new StopWatch();
stopWatch.start(); stopWatch.start();
ExecutorService executorService = Executors.newFixedThreadPool(30); ExecutorService executorService = Executors.newFixedThreadPool(30);
CompletableFuture[] futures = Stream.iterate(1, n -> n + 1).limit(rowNumber - 1).map(index -> CompletableFuture[] futures = Stream.iterate(1, n -> n + 1).limit(rowNumber - 1).map(index ->
CompletableFuture.runAsync( CompletableFuture.runAsync(
() -> saveDmpIncomeItem(sheet, index, loginAccount), executorService) () -> {
DmpIncome income = saveDmpIncomeItem(sheet, index, loginAccount);
if (income != null) {
income.setConfirmSettlement(new BigDecimal(income.getConfirmSettlement()).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
dmpIncomeRepository.save(income);
}
}, executorService)
.exceptionally((t) -> null) .exceptionally((t) -> null)
).toArray(size -> new CompletableFuture[size]); ).toArray(size -> new CompletableFuture[size]);
CompletableFuture.allOf(futures).join(); CompletableFuture.allOf(futures).join();
...@@ -289,9 +297,9 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -289,9 +297,9 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
contract.setSale(salseMap.get(contract.getSaleName())); contract.setSale(salseMap.get(contract.getSaleName()));
} }
if (StringUtils.isEmpty(contract.getEmail())) { /*if (StringUtils.isEmpty(contract.getEmail())) {
return erroValueTip(i, "客户主账号"); return erroValueTip(i, "客户主账号");
} }*/
if (StringUtils.isEmpty(contract.getContractCode())) { if (StringUtils.isEmpty(contract.getContractCode())) {
return erroValueTip(i, "合同编号"); return erroValueTip(i, "合同编号");
...@@ -315,7 +323,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -315,7 +323,7 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
} }
if (!SETAGREEMENT_TYPE_NAME.containsKey(contract.getAgreementTypeName())) { if (!SETAGREEMENT_TYPE_NAME.containsKey(contract.getAgreementTypeName())) {
return erroValueTip(i, "业务类型"); return erroValueTip(i, "协议类型");
} else { } else {
contract.setAgreementType(Integer.parseInt(SETAGREEMENT_TYPE_NAME.get(contract.getAgreementTypeName()))); contract.setAgreementType(Integer.parseInt(SETAGREEMENT_TYPE_NAME.get(contract.getAgreementTypeName())));
} }
...@@ -436,20 +444,15 @@ public class DmpIncomeServiceImpl implements DmpIncomeService { ...@@ -436,20 +444,15 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if (StringUtils.isEmpty(income.getContractCode())) { if (StringUtils.isEmpty(income.getContractCode())) {
return null; return null;
} }
//保留小数
income.setConfirmSettlement(new BigDecimal(income.getConfirmSettlement()).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
//
income.setTaxRate(Double.parseDouble(income.getTaxRate()) * 100 + "%"); income.setTaxRate(Double.parseDouble(income.getTaxRate()) * 100 + "%");
if (StringUtils.isEmpty(income.getSysSettlement())) { if (StringUtils.isEmpty(income.getSysSettlement())) {
income.setSysSettlement("0"); income.setSysSettlement("0");
} }
DmpIncome one = dmpIncomeRepository.findByCodeMonth(income.getContractCode(), income.getIncomeMonth()); DmpIncome one = dmpIncomeRepository.findByCodeMonth(income.getContractCode(), income.getIncomeMonth());
if (one != null) { if (one != null) {
// 同一合同同一月份不重复保存 // 同一合同同一月份不重复保存
return null; return null;
} }
dmpIncomeRepository.save(income);
return income; return income;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment