diff --git a/ruoyi-admin/src/main/resources/application-hs.yml b/ruoyi-admin/src/main/resources/application-hs.yml
index 2b3426c..712e10b 100644
--- a/ruoyi-admin/src/main/resources/application-hs.yml
+++ b/ruoyi-admin/src/main/resources/application-hs.yml
@@ -6,10 +6,11 @@ spring:
druid:
# 主库数据源
master:
- #url: jdbc:mysql://localhost:3306/ry-vue?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
+ #url: jdbc:mysql://localhost:3307/kaohe?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
url: jdbc:mysql://172.16.9.9:3306/kaohe?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8
username: root
password: ruanfa
+ #password: hs123456
# 从库数据源
slave:
# 从数据源开关/默认关闭
diff --git a/ruoyi-kaohe/pom.xml b/ruoyi-kaohe/pom.xml
index 04677b2..f024544 100644
--- a/ruoyi-kaohe/pom.xml
+++ b/ruoyi-kaohe/pom.xml
@@ -27,6 +27,11 @@
pinyin4j
2.5.0
+
+ org.json
+ json
+ 20210307
+
\ No newline at end of file
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 16b7440..396679f 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
@@ -4,14 +4,15 @@ import java.math.BigDecimal;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
-import com.alibaba.fastjson2.JSONArray;
-import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.core.JsonProcessingException;
import com.ruoyi.kaohe.domain.KhKhrwResult;
-import com.ruoyi.kaohe.domain.KhgatherParam;
import com.ruoyi.kaohe.service.IKhKhrwResultService;
import com.ruoyi.kaohe.service.IKhVoteEmpService;
import com.ruoyi.kaohe.service.IKhVoteService;
+import com.ruoyi.kaohe.util.JsonDeepMerge;
import com.ruoyi.kaohe.util.PinYinUtil;
+import org.json.JSONArray;
+import org.json.JSONObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@@ -54,141 +55,219 @@ public class KhGatherController extends BaseController {
*/
//@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
@PostMapping("/generateSum")
- public AjaxResult generateSum(@RequestBody String json) {
+ public AjaxResult generateSum(@RequestBody String json) throws JsonProcessingException {
// 将String转换为JSONObject
- JSONObject jsonObject = JSONObject.parseObject(json);
+ JSONObject jsonObject = new JSONObject(json);
String hz_name = jsonObject.getString("title");
JSONArray datas = jsonObject.getJSONArray("data");
//拼接表头数据
- JSONArray header = new JSONArray();//存放表头及表格关联数据
+ JSONArray header = new JSONArray();//存放表头的最终数据
//----------------------------------------------------------------------------------------------
//循环主标题下的每一个子节点
- Map nodes = parseJson(datas, hz_name);
- JSONObject btKhdx = (JSONObject)nodes.get("btKhdx");
+ Map nodes = parseJson(datas, hz_name, null);
+ //获取并拼接表头
+ JSONObject btKhdx = (JSONObject) nodes.get("btKhdx");
JSONObject head = (JSONObject) nodes.get("head");
JSONArray oldchildren = head.getJSONArray("children");
JSONArray newChildren = new JSONArray();
- newChildren.add(btKhdx);
+ newChildren.put(btKhdx);
for (Object oldchild : oldchildren) {
- newChildren.add(oldchild);
+ newChildren.put(oldchild);
}
- head.put("children",newChildren);
- header.add(head);
- return AjaxResult.success(header);
+ head.put("children", newChildren);
+ header.put(head);
+
+ //获取并整合数据
+ JSONArray tabledata = new JSONArray((JSONArray) nodes.get("alldatas"));
+ JSONArray erjiTtitle_df = new JSONArray((JSONArray) nodes.get("title_df"));
+ tabledata.putAll(erjiTtitle_df);
+ //根据被考核对象名分组数据到map中 得到表格内容的最终数据
+ JSONArray endTableData = JsonDeepMerge.mergeByKey(tabledata, "khdx");
+
+ KhGather gather = new KhGather();
+ gather.setHzName(hz_name);
+ gather.setTableHeader(header.toString(2));
+ gather.setTableData(endTableData.toString(2));
+ khGatherService.insertKhGather(gather);
+ return AjaxResult.success();
}
- //递归解析json
- private Map parseJson(JSONArray datas, String titleP) {
+ /**
+ * 递归解析json
+ *
+ * @param datas
+ * @param titleP
+ * @param z_zb
+ * @return
+ */
+ private Map parseJson(JSONArray datas, String titleP, BigDecimal z_zb) throws JsonProcessingException {
+
Map result = new HashMap<>();
- //父级表头
- JSONObject btKhdx = new JSONObject();
- JSONObject btTitle = new JSONObject();
- btTitle.put("name", PinYinUtil.getPinyinInitials(titleP));
+ JSONArray endtTitle_df = new JSONArray();//存储标题占比时的得分
+ JSONArray title_df = new JSONArray();//处理标题占比时的得分
+ String pyTitle = PinYinUtil.getPinyinInitials(titleP);//父级表头
+ JSONObject btKhdx = new JSONObject(true); //表头考核对象存储
+ JSONObject btTitle = new JSONObject(true);
+ btTitle.put("name", pyTitle);
btTitle.put("label", titleP);
JSONArray btchildren = new JSONArray();
//---------------------------------------------------------------------
JSONArray bd = new JSONArray();//表数据拼接
- List