diff --git a/ruoyi-common/pom.xml b/ruoyi-common/pom.xml
index 72d888f..b266507 100644
--- a/ruoyi-common/pom.xml
+++ b/ruoyi-common/pom.xml
@@ -118,6 +118,16 @@
javax.servlet
javax.servlet-api
+
diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhGatherController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhGatherController.java
index 20060cb..526f60d 100644
--- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhGatherController.java
+++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhGatherController.java
@@ -1,6 +1,8 @@
package com.ruoyi.kaohe.controller;
+import java.io.IOException;
import java.math.BigDecimal;
+import java.net.URLEncoder;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
@@ -9,6 +11,7 @@ import com.ruoyi.kaohe.domain.KhKhrwResult;
import com.ruoyi.kaohe.service.IKhKhrwResultService;
import com.ruoyi.kaohe.service.IKhVoteEmpService;
import com.ruoyi.kaohe.service.IKhVoteService;
+import com.ruoyi.kaohe.util.EnhancedJsonExporter;
import com.ruoyi.kaohe.util.JsonDeepMerge;
import com.ruoyi.kaohe.util.PinYinUtil;
import org.json.JSONArray;
@@ -97,6 +100,16 @@ public class KhGatherController extends BaseController {
tabledata.putAll(hz_df);
//根据被考核对象名分组数据到map中 得到表格内容的最终数据
JSONArray endTableData = JsonDeepMerge.mergeByKey(tabledata, "khdx");
+ //把数据结果中的khdx这个键值对———放到汇总主题拼音的key值里面
+ for (Object endData : endTableData) {
+ JSONObject jsonData = (JSONObject) endData;
+ String khdx = jsonData.getString("khdx");
+ JSONObject hzData = jsonData.getJSONObject(pyhz_name);
+ hzData.put("khdx",khdx);
+ jsonData.remove("khdx");
+ jsonData.put(pyhz_name,hzData);
+ endData=jsonData;
+ }
KhGather gather = new KhGather();
gather.setHzName(hz_name);
@@ -117,7 +130,6 @@ public class KhGatherController extends BaseController {
private Map parseJson(JSONArray datas, String titleP, BigDecimal z_zb) throws JsonProcessingException {
Map result = new HashMap<>();
- JSONArray hz_df = new JSONArray();//存储标题占比时的得分
JSONArray title_df = new JSONArray();//处理标题占比时的得分
String pyTitle = PinYinUtil.getPinyinInitials(titleP);//父级表头
JSONObject btKhdx = new JSONObject(true); //表头考核对象存储
@@ -311,13 +323,24 @@ public class KhGatherController extends BaseController {
/**
* 导出生成汇总列表
*/
- @PreAuthorize("@ss.hasPermi('kaohe:gather:export')")
+ /*@PreAuthorize("@ss.hasPermi('kaohe:gather:export')")
@Log(title = "生成汇总", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, KhGather khGather) {
List list = khGatherService.selectKhGatherList(khGather);
ExcelUtil util = new ExcelUtil(KhGather.class);
util.exportExcel(response, list, "生成汇总数据");
+ }*/
+ @PreAuthorize("@ss.hasPermi('kaohe:gather:export')")
+ @Log(title = "生成汇总", businessType = BusinessType.EXPORT)
+ @PostMapping("/export")
+ public void export(HttpServletResponse response, Long id) throws Exception {
+ response.setContentType("application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");
+ response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("汇总数据.xlsx", "UTF-8"));
+ KhGather gather = khGatherService.selectKhGatherById(id);
+ String tableHeader = gather.getTableHeader();
+ String tableData = gather.getTableData();
+ EnhancedJsonExporter.exportWithMergedHeader(tableHeader,tableData,response);
}
/**
diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhKhrwResultController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhKhrwResultController.java
index 623c28c..aed4af2 100644
--- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhKhrwResultController.java
+++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhKhrwResultController.java
@@ -58,155 +58,7 @@ public class KhKhrwResultController extends BaseController {
if(khKhrwResults!=null&&khKhrwResults.size()>0){
return AjaxResult.error("该考核任务已有生成结果!");
}
-
- /* JSONArray header = new JSONArray();//存放表头及表格关联数据
- JSONObject headerData = new JSONObject();
- headerData.put("name", null);
- headerData.put("label", pc.getPcTitle());*/
- JSONArray children = new JSONArray();
- JSONObject tableColumn = new JSONObject();
- tableColumn.put("name", "khdx");
- if (pc.getBkhdxType().equals("0")) {
- tableColumn.put("label", "单位");
- } else {
- tableColumn.put("label", "姓名");
- }
- children.add(tableColumn);
-
- JSONObject tableColumn2 = new JSONObject();
- String pyPCtitle = PinYinUtil.getPinyinInitials(pc.getPcTitle());
- tableColumn2.put("name", pyPCtitle);
- tableColumn2.put("label", pc.getPcTitle());
-
-//-----------------------------------------------------------------------------------------
-
- JSONArray endData = new JSONArray(); //存放表格数据
- List lists = new ArrayList<>();
-
- KhVote khVote = new KhVote();
- khVote.setPingceId(pc.getId());
- //查询该考核任务下的所有评分任务
- List votes = khVoteService.selectKhVoteList(khVote);
- for (KhVote vote : votes) {
- KhVoteEmp khVoteEmp = new KhVoteEmp();
- khVoteEmp.setVoteId(vote.getId());
- //查询该评分任务对应的所有被考核对象详情
- List khVoteEmps = voteEmpService.selectKhVoteEmpList(khVoteEmp);
- lists.addAll(khVoteEmps);
- }
- //根据被考核对象名分组数据到map中
- Map> khdxMap = lists.stream()
- .collect(Collectors.groupingBy(KhVoteEmp::getBkhdxName,
- LinkedHashMap::new, // 使用LinkedHashMap保持插入顺序(这对于键很重要)
- Collectors.toList())); // 根据getBkhdxName分组*/lists.stream().
- //循环map得到对应数据
- Set>> entries = khdxMap.entrySet();
- Integer index1=0;
- for (Map.Entry> entry : entries) {
- index1++;
- BigDecimal sumScore = BigDecimal.ZERO;
- String key = entry.getKey();
- //获取表头数据
- List