From da7a4d799034ca244467665827bae91ca3c0252c Mon Sep 17 00:00:00 2001
From: 龚焕茏 <2842157468@qq.com>
Date: 星期五, 16 八月 2024 10:31:55 +0800
Subject: [PATCH] feat:数据中心展示
---
ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java | 17 +++++++++++++++--
1 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java
index cd1fed3..8020953 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/CalculateReportServiceImpl.java
@@ -29,6 +29,7 @@
import java.math.BigDecimal;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
+import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -54,6 +55,9 @@
@Override
public Result add(CalculateReportForm form) {
CalculateReport entity = CalculateReportForm.getEntityByForm(form, null);
+ Date now = new Date();
+ entity.setCreateTime(now);
+ entity.setUpdateTime(now);
if(baseMapper.insert(entity) > 0) {
return Result.ok("娣诲姞鎴愬姛");
}
@@ -69,10 +73,11 @@
public Result update(CalculateReportForm form) {
CalculateReport entity = baseMapper.selectById(form.getId());
-
// 涓虹┖鎶汭llegalArgumentException锛屽仛鍏ㄥ眬寮傚父澶勭悊
Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
BeanUtils.copyProperties(form, entity);
+ Date now = new Date();
+ entity.setUpdateTime(now);
if (baseMapper.updateById(entity) > 0) {
return Result.ok("淇敼鎴愬姛");
}
@@ -199,12 +204,20 @@
@Override
@SneakyThrows
public void export(Integer contractId, HttpServletResponse response) {
+ // 鑾峰彇鏁版嵁
+ List<CalculateExport> list = baseMapper.exportData(contractId);
+ CalculateExport calculateExport = new CalculateExport();
+ calculateExport.setRuleName("鍚堣");
+ calculateExport.setNum(list.stream().mapToInt(CalculateExport::getNum).sum());
+ calculateExport.setScore(100 + list.stream().mapToInt(CalculateExport::getScore).sum());
+ list.add(calculateExport);
+ // 杈撳嚭鏂囦欢
response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
response.setCharacterEncoding("utf-8");
String fileName = URLEncoder.encode("鏍哥畻鎶ュ憡", StandardCharsets.UTF_8).replace("\\+", "%20");
response.setHeader("Content-disposition", "attachment;filename*=utf-8''" + fileName + ".xlsx");
EasyExcel.write(response.getOutputStream(), CalculateExport.class)
.sheet("鏍哥畻鎶ュ憡")
- .doWrite(baseMapper.exportData(contractId));
+ .doWrite(list);
}
}
--
Gitblit v1.8.0