From a1f2eefe4641764955c846ad58ebdbcedd96699d Mon Sep 17 00:00:00 2001
From: yxh <172933527@qq.com>
Date: 星期三, 28 十月 2026 17:31:58 +0800
Subject: [PATCH] 修改了统计
---
ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/SpStatExpenseController.java | 91 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 88 insertions(+), 3 deletions(-)
diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/SpStatExpenseController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/SpStatExpenseController.java
index 2098f7c..112822e 100644
--- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/SpStatExpenseController.java
+++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/project/SpStatExpenseController.java
@@ -1,19 +1,30 @@
package com.ruoyi.web.controller.project;
+import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
-import com.ruoyi.project.domain.SpStatCaseReq;
+import com.ruoyi.common.enums.BusinessType;
+import com.ruoyi.common.utils.poi.ExcelUtil;
+import com.ruoyi.project.domain.SpStatExpense;
+import com.ruoyi.project.domain.SpStatExpenseDept;
import com.ruoyi.project.domain.SpStatExpenseReq;
-import com.ruoyi.project.service.SpstatCaseService;
import com.ruoyi.project.service.SpstatExpenseService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+import java.util.List;
+import java.util.Map;
/**
* 鎶ラ攢缁熻
@@ -31,7 +42,7 @@
SpstatExpenseService spstatExpenseService;
/**
- * 鏌ヨ妗堜緥缁熻
+ * 鏌ヨ璐圭敤缁熻
*/
@ApiOperation("鏌ヨ鎶ラ攢缁熻")
@PostMapping("/spStatExpenselist")
@@ -40,5 +51,79 @@
return getDataTable(spstatExpenseService.getListBySpstatExpense(spStatExpenseReq));
}
+ /**
+ * 瀵煎嚭璐圭敤缁熻
+ */
+ @ApiOperation("瀵煎嚭璐圭敤缁熻")
+ @Log(title = "璐圭敤缁熻", businessType = BusinessType.EXPORT)
+ @GetMapping("/export")
+ public AjaxResult export(SpStatExpenseReq spStatExpenseReq) {
+ List<SpStatExpense> list = spstatExpenseService.getListBySpstatExpense(spStatExpenseReq);
+ // 閲戦淇濈暀 2 浣嶅皬鏁帮紱0.00 涓嶆樉绀猴紙缃┖锛�
+ for (SpStatExpense row : list) {
+ row.setAmount(blankZero(row.getAmount()));
+ row.setExpertfee(blankZero(row.getExpertfee()));
+ row.setEthicalistfee(blankZero(row.getEthicalistfee()));
+ row.setMedicalcost(blankZero(row.getMedicalcost()));
+ row.setOfficecost(blankZero(row.getOfficecost()));
+ row.setReimcost(blankZero(row.getReimcost()));
+ }
+ ExcelUtil<SpStatExpense> util = new ExcelUtil<SpStatExpense>(SpStatExpense.class);
+ return util.exportExcel(list, "璐圭敤缁熻鏁版嵁");
+ }
+
+ /**
+ * 瀵煎嚭璐圭敤缁熻锛堟寜涓氬姟缁勶級
+ */
+ @ApiOperation("瀵煎嚭璐圭敤缁熻锛堟寜涓氬姟缁勶級")
+ @Log(title = "璐圭敤缁熻", businessType = BusinessType.EXPORT)
+ @GetMapping("/exportDept")
+ public AjaxResult exportDept(SpStatExpenseReq spStatExpenseReq) {
+ List<SpStatExpense> list = spstatExpenseService.getListBySpstatExpense(spStatExpenseReq);
+ Map<String, SpStatExpenseDept> grouped = new LinkedHashMap<String, SpStatExpenseDept>();
+ for (SpStatExpense row : list) {
+ String key = row.getDeptmentno() != null ? row.getDeptmentno() : row.getDeptmentName();
+ if (key == null) {
+ key = "";
+ }
+ SpStatExpenseDept dept = grouped.get(key);
+ if (dept == null) {
+ dept = new SpStatExpenseDept();
+ dept.setDeptname(row.getDeptmentName() == null ? "鏈垎缁�" : row.getDeptmentName());
+ dept.setAmount(BigDecimal.ZERO);
+ dept.setExpertfee(BigDecimal.ZERO);
+ dept.setEthicalistfee(BigDecimal.ZERO);
+ dept.setMedicalcost(BigDecimal.ZERO);
+ dept.setOfficecost(BigDecimal.ZERO);
+ dept.setReimcost(BigDecimal.ZERO);
+ grouped.put(key, dept);
+ }
+ dept.setAmount(dept.getAmount().add(nz(row.getAmount())));
+ dept.setExpertfee(dept.getExpertfee().add(nz(row.getExpertfee())));
+ dept.setEthicalistfee(dept.getEthicalistfee().add(nz(row.getEthicalistfee())));
+ dept.setMedicalcost(dept.getMedicalcost().add(nz(row.getMedicalcost())));
+ dept.setOfficecost(dept.getOfficecost().add(nz(row.getOfficecost())));
+ dept.setReimcost(dept.getReimcost().add(nz(row.getReimcost())));
+ }
+ List<SpStatExpenseDept> result = new ArrayList<SpStatExpenseDept>(grouped.values());
+ for (SpStatExpenseDept dept : result) {
+ dept.setAmount(blankZero(dept.getAmount()));
+ dept.setExpertfee(blankZero(dept.getExpertfee()));
+ dept.setEthicalistfee(blankZero(dept.getEthicalistfee()));
+ dept.setMedicalcost(blankZero(dept.getMedicalcost()));
+ dept.setOfficecost(blankZero(dept.getOfficecost()));
+ dept.setReimcost(blankZero(dept.getReimcost()));
+ }
+ ExcelUtil<SpStatExpenseDept> util = new ExcelUtil<SpStatExpenseDept>(SpStatExpenseDept.class);
+ return util.exportExcel(result, "璐圭敤缁熻锛堟寜涓氬姟缁勶級");
+ }
+
+ private BigDecimal nz(BigDecimal value) {
+ return value == null ? BigDecimal.ZERO : value;
+ }
+
+ private BigDecimal blankZero(BigDecimal value) {
+ return (value == null || value.compareTo(BigDecimal.ZERO) == 0) ? null : value;
+ }
}
--
Gitblit v1.9.3