Commit 1b084492 by kangxiaoshan

修改提示

parent 174f5525
......@@ -47,8 +47,7 @@ public class DmpIncomeController {
@PostMapping("/upload")
public ResultModel uploadList(@RequestParam("file") MultipartFile file, @CurrentAccount User loginAccount) {
//上传收入数据
dmpIncomeService.uploadFile(file, "dmp", loginAccount);
return ResultModel.OK();
return dmpIncomeService.uploadFile(file, "dmp", loginAccount);
}
......
......@@ -201,30 +201,37 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
Sheet sheet = workbook.getSheetAt(0);
DecimalFormat df = new DecimalFormat("##,##0.00");
CompletableFuture.runAsync(() -> {
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ExecutorService executorService = Executors.newFixedThreadPool(30);
CompletableFuture[] futures = Stream.iterate(1, n -> n + 1).limit(rowNumber - 1).map(index ->
CompletableFuture.runAsync(
() -> {
DmpIncome income = saveDmpIncomeItem(sheet, index, loginAccount);
if (income != null) {
StringBuffer erroMessage = new StringBuffer();
StopWatch stopWatch = new StopWatch();
stopWatch.start();
ExecutorService executorService = Executors.newFixedThreadPool(30);
CompletableFuture[] futures = Stream.iterate(1, n -> n + 1).limit(rowNumber - 1).map(index ->
CompletableFuture.runAsync(
() -> {
DmpIncome income = saveDmpIncomeItem(sheet, index, loginAccount);
if (income != null) {
if ("erro".equals(income.getIncomeMonth())) {
erroMessage.append(index).append(" 行 收入月份错误").append(";\n");
} else {
income.setConfirmSettlement(new BigDecimal(income.getConfirmSettlement()).setScale(2, BigDecimal.ROUND_HALF_UP).toString());
dmpIncomeRepository.save(income);
}
}, executorService)
.exceptionally((t) -> {
logger.error("the line " + index, t);
return null;
})
).toArray(size -> new CompletableFuture[size]);
CompletableFuture.allOf(futures).join();
executorService.shutdownNow();
stopWatch.stop();
logger.info("dmp income upload {} line data use all {}s ", rowNumber - 1, stopWatch.getTotalTimeSeconds());
});
}
}, executorService)
.exceptionally((t) -> {
erroMessage.append(index).append(" 行 错误").append(t.getMessage()).append(";\n");
logger.error("the line " + index, t);
return null;
})
).toArray(size -> new CompletableFuture[size]);
CompletableFuture.allOf(futures).join();
executorService.shutdownNow();
stopWatch.stop();
logger.info("dmp income upload {} line data use all {}s ", rowNumber - 1, stopWatch.getTotalTimeSeconds());
if (erroMessage.length() > 0) {
return ResultModel.ERROR(erroMessage.toString());
}
return ResultModel.OK();
}
......@@ -488,13 +495,11 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
private String getCellDateValue(Row row, int index, String fm) {
Cell cell = row.getCell(index);
if (cell == null) {
return "erro";
}
String dfmate = cell.getCellStyle().getDataFormatString();
if (!"yyyy/mm;@".equals(dfmate) && !"m/d/yy".equals(dfmate) && !"yy/m/d".equals(dfmate) && !"mm/dd/yy".equals(dfmate) && !"dd-mmm-yy".equals(dfmate) && !"yyyy/m/d".equals(dfmate) && !"yyyy/m/d;@".equals(dfmate) && !"yyyy\"年\"m\"月\";@".equals(dfmate)) {
return "erro";
}
......@@ -506,7 +511,6 @@ public class DmpIncomeServiceImpl implements DmpIncomeService {
if (org.apache.poi.ss.usermodel.DateUtil.isCellDateFormatted(cell)) {
// 用于转化为日期格式
Date d = cell.getDateCellValue();
DateFormat formater = new SimpleDateFormat(fm);
return formater.format(d);
}
......
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