|
|
|
@ -1,11 +1,17 @@
|
|
|
|
package com.ruoyi.kaohe.controller;
|
|
|
|
package com.ruoyi.kaohe.controller;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
import java.math.BigDecimal;
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSON;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
import com.alibaba.fastjson2.JSONArray;
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
import com.alibaba.fastjson2.JSONObject;
|
|
|
|
|
|
|
|
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.PinYinUtil;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.security.access.prepost.PreAuthorize;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
|
@ -27,72 +33,161 @@ import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 生成汇总Controller
|
|
|
|
* 生成汇总Controller
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author hs
|
|
|
|
* @author hs
|
|
|
|
* @date 2025-07-10
|
|
|
|
* @date 2025-07-10
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@RestController
|
|
|
|
@RestController
|
|
|
|
@RequestMapping("/kaohe/gather")
|
|
|
|
@RequestMapping("/kaohe/gather")
|
|
|
|
public class KhGatherController extends BaseController
|
|
|
|
public class KhGatherController extends BaseController {
|
|
|
|
{
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IKhKhrwResultService khKhrwResultService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IKhVoteEmpService voteEmpService;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private IKhVoteService khVoteService;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private IKhGatherService khGatherService;
|
|
|
|
private IKhGatherService khGatherService;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询生成汇总列表
|
|
|
|
* 生成汇总列表
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
|
|
|
|
//@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
|
|
|
|
@PostMapping("/generateSum")
|
|
|
|
@PostMapping("/generateSum")
|
|
|
|
public AjaxResult generateSum(JSONObject json)
|
|
|
|
public AjaxResult generateSum(@RequestBody String json) {
|
|
|
|
{
|
|
|
|
// 将String转换为JSONObject
|
|
|
|
String hz_name = json.getString("title");
|
|
|
|
JSONObject jsonObject = JSONObject.parseObject(json);
|
|
|
|
JSONArray data = json.getJSONArray("data");
|
|
|
|
String hz_name = jsonObject.getString("title");
|
|
|
|
|
|
|
|
JSONArray datas = jsonObject.getJSONArray("data");
|
|
|
|
|
|
|
|
//拼接表头数据
|
|
|
|
|
|
|
|
JSONArray header = new JSONArray();//存放表头及表格关联数据
|
|
|
|
//----------------------------------------------------------------------------------------------
|
|
|
|
//----------------------------------------------------------------------------------------------
|
|
|
|
for (int i = 0; i < data.size(); i++) {
|
|
|
|
//循环主标题下的每一个子节点
|
|
|
|
JSONObject jsonObject = data.getJSONObject(i);
|
|
|
|
Map<String, Object> nodes = parseJson(datas, hz_name);
|
|
|
|
String type1 = jsonObject.getString("type");
|
|
|
|
JSONObject btKhdx = (JSONObject)nodes.get("btKhdx");
|
|
|
|
if(type1.equals("0")){
|
|
|
|
JSONObject head = (JSONObject) nodes.get("head");
|
|
|
|
JSONArray data1 = jsonObject.getJSONArray("data");
|
|
|
|
JSONArray oldchildren = head.getJSONArray("children");
|
|
|
|
}else{
|
|
|
|
JSONArray newChildren = new JSONArray();
|
|
|
|
|
|
|
|
newChildren.add(btKhdx);
|
|
|
|
|
|
|
|
for (Object oldchild : oldchildren) {
|
|
|
|
|
|
|
|
newChildren.add(oldchild);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
head.put("children",newChildren);
|
|
|
|
|
|
|
|
header.add(head);
|
|
|
|
|
|
|
|
return AjaxResult.success(header);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//递归解析json
|
|
|
|
|
|
|
|
private Map<String, Object> parseJson(JSONArray datas, String titleP) {
|
|
|
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
|
|
|
//父级表头
|
|
|
|
|
|
|
|
JSONObject btKhdx = new JSONObject();
|
|
|
|
|
|
|
|
JSONObject btTitle = new JSONObject();
|
|
|
|
|
|
|
|
btTitle.put("name", PinYinUtil.getPinyinInitials(titleP));
|
|
|
|
|
|
|
|
btTitle.put("label", titleP);
|
|
|
|
|
|
|
|
JSONArray btchildren = new JSONArray();
|
|
|
|
|
|
|
|
//---------------------------------------------------------------------
|
|
|
|
|
|
|
|
JSONArray bd = new JSONArray();//表数据拼接
|
|
|
|
|
|
|
|
List<Object> alldatas = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < datas.size(); i++) {
|
|
|
|
|
|
|
|
JSONObject jobj = (JSONObject) datas.get(i);
|
|
|
|
|
|
|
|
String type = jobj.getString("type");
|
|
|
|
|
|
|
|
String title = jobj.getString("title");
|
|
|
|
|
|
|
|
//如果有子集就遍历
|
|
|
|
|
|
|
|
if (type.equals("0")) {
|
|
|
|
|
|
|
|
JSONArray data2 = jobj.getJSONArray("data");
|
|
|
|
|
|
|
|
BigDecimal zb = jobj.getBigDecimal("zb");
|
|
|
|
|
|
|
|
Map<String, Object> childmap = parseJson(data2,title);
|
|
|
|
|
|
|
|
JSONObject head= (JSONObject)childmap.get("head");
|
|
|
|
|
|
|
|
btchildren.add(head);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (type.equals("1")) { //引用占比考核任务
|
|
|
|
|
|
|
|
Long pcId = jobj.getLong("id");
|
|
|
|
|
|
|
|
BigDecimal zb = jobj.getBigDecimal("zb");
|
|
|
|
|
|
|
|
KhKhrwResult khrwResult = new KhKhrwResult();
|
|
|
|
|
|
|
|
khrwResult.setPcId(pcId);
|
|
|
|
|
|
|
|
//获取考核任务结果
|
|
|
|
|
|
|
|
List<KhKhrwResult> khrw = khKhrwResultService.selectKhKhrwResultList(khrwResult);
|
|
|
|
|
|
|
|
if(khrw!=null&&khrw.size()>0){
|
|
|
|
|
|
|
|
JSONArray tableHeader = JSONArray.parse(khrw.get(0).getTableHeader());
|
|
|
|
|
|
|
|
JSONObject head1 = new JSONObject();
|
|
|
|
|
|
|
|
JSONObject head2 = new JSONObject();
|
|
|
|
|
|
|
|
btKhdx=tableHeader.getJSONObject(0);//下标0 单位/姓名
|
|
|
|
|
|
|
|
head1=tableHeader.getJSONObject(1); //整体数据
|
|
|
|
|
|
|
|
head2=tableHeader.getJSONObject(2);//得分
|
|
|
|
|
|
|
|
btchildren.add(head1);
|
|
|
|
|
|
|
|
btchildren.add(head2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
JSONArray tabledata = JSONArray.parse(khrw.get(0).getTableData());
|
|
|
|
|
|
|
|
alldatas.addAll(tabledata);
|
|
|
|
|
|
|
|
} else { //引用不占比考核任务
|
|
|
|
|
|
|
|
Long pcId = jobj.getLong("id");
|
|
|
|
|
|
|
|
KhKhrwResult khrwResult = new KhKhrwResult();
|
|
|
|
|
|
|
|
khrwResult.setPcId(pcId);
|
|
|
|
|
|
|
|
List<KhKhrwResult> khrw = khKhrwResultService.selectKhKhrwResultList(khrwResult);
|
|
|
|
|
|
|
|
if(khrw!=null&&khrw.size()>0){
|
|
|
|
|
|
|
|
JSONArray tableHeader = JSONArray.parse(khrw.get(0).getTableHeader());
|
|
|
|
|
|
|
|
JSONObject head1 = new JSONObject();
|
|
|
|
|
|
|
|
JSONObject head2 = new JSONObject();
|
|
|
|
|
|
|
|
btKhdx=tableHeader.getJSONObject(0);//下标0 单位/姓名
|
|
|
|
|
|
|
|
head1=tableHeader.getJSONObject(1); //整体数据
|
|
|
|
|
|
|
|
head2=tableHeader.getJSONObject(2);//得分
|
|
|
|
|
|
|
|
btchildren.add(head1);
|
|
|
|
|
|
|
|
btchildren.add(head2);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------------------
|
|
|
|
|
|
|
|
JSONArray tabledata = JSONArray.parse(khrw.get(0).getTableData());
|
|
|
|
|
|
|
|
alldatas.addAll(tabledata);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
btTitle.put("children",btchildren);
|
|
|
|
|
|
|
|
result.put("head", btTitle);
|
|
|
|
|
|
|
|
result.put("data", bd);
|
|
|
|
|
|
|
|
result.put("btKhdx", btKhdx);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*{
|
|
|
|
/*{
|
|
|
|
"hz_name": "教学单位领导班子考核总分",
|
|
|
|
"title": "教学单位领导班子考核总分",
|
|
|
|
"data": [{
|
|
|
|
"data": [
|
|
|
|
"type": 0,
|
|
|
|
{
|
|
|
|
"title": "二级单位目标管理与绩效考核成绩",
|
|
|
|
"type": "0",
|
|
|
|
"zb": 0.7,
|
|
|
|
"title": "二级单位目标管理与绩效考核成绩",
|
|
|
|
"data": [{
|
|
|
|
"data": [
|
|
|
|
"type": 1,
|
|
|
|
{
|
|
|
|
"title": "党建与行政目标任务",
|
|
|
|
"type": 1,
|
|
|
|
"id": 1,
|
|
|
|
"title": "党建与行政目标任务",
|
|
|
|
"zb": 0.1
|
|
|
|
"id": 1,
|
|
|
|
},
|
|
|
|
"zb": 0.1
|
|
|
|
{
|
|
|
|
},
|
|
|
|
"type": 1,
|
|
|
|
{
|
|
|
|
"title": "事业发展",
|
|
|
|
"type": "1",
|
|
|
|
"id": 3,
|
|
|
|
"title": "事业发展",
|
|
|
|
"zb": 0.9
|
|
|
|
"id": 4,
|
|
|
|
}
|
|
|
|
"zb": 0.9
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
{
|
|
|
|
},
|
|
|
|
"type": 1,
|
|
|
|
{
|
|
|
|
"title": "民主测评",
|
|
|
|
"type": "1",
|
|
|
|
"id": 2,
|
|
|
|
"title": "民主测评",
|
|
|
|
"zb": 0.3
|
|
|
|
"id": 2,
|
|
|
|
},
|
|
|
|
"zb": 0.3
|
|
|
|
{
|
|
|
|
},
|
|
|
|
"type": 1,
|
|
|
|
{
|
|
|
|
"title": "创新",
|
|
|
|
"type": "1",
|
|
|
|
"id": 3
|
|
|
|
"title": "创新",
|
|
|
|
}
|
|
|
|
"id": 5
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
]
|
|
|
|
}*/
|
|
|
|
}*/
|
|
|
|
return AjaxResult.success();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
@ -100,8 +195,7 @@ public class KhGatherController extends BaseController
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
|
|
|
|
@GetMapping("/list")
|
|
|
|
@GetMapping("/list")
|
|
|
|
public TableDataInfo list(KhGather khGather)
|
|
|
|
public TableDataInfo list(KhGather khGather) {
|
|
|
|
{
|
|
|
|
|
|
|
|
startPage();
|
|
|
|
startPage();
|
|
|
|
List<KhGather> list = khGatherService.selectKhGatherList(khGather);
|
|
|
|
List<KhGather> list = khGatherService.selectKhGatherList(khGather);
|
|
|
|
return getDataTable(list);
|
|
|
|
return getDataTable(list);
|
|
|
|
@ -113,8 +207,7 @@ public class KhGatherController extends BaseController
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:export')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:export')")
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.EXPORT)
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.EXPORT)
|
|
|
|
@PostMapping("/export")
|
|
|
|
@PostMapping("/export")
|
|
|
|
public void export(HttpServletResponse response, KhGather khGather)
|
|
|
|
public void export(HttpServletResponse response, KhGather khGather) {
|
|
|
|
{
|
|
|
|
|
|
|
|
List<KhGather> list = khGatherService.selectKhGatherList(khGather);
|
|
|
|
List<KhGather> list = khGatherService.selectKhGatherList(khGather);
|
|
|
|
ExcelUtil<KhGather> util = new ExcelUtil<KhGather>(KhGather.class);
|
|
|
|
ExcelUtil<KhGather> util = new ExcelUtil<KhGather>(KhGather.class);
|
|
|
|
util.exportExcel(response, list, "生成汇总数据");
|
|
|
|
util.exportExcel(response, list, "生成汇总数据");
|
|
|
|
@ -125,8 +218,7 @@ public class KhGatherController extends BaseController
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:query')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:query')")
|
|
|
|
@GetMapping(value = "/{id}")
|
|
|
|
@GetMapping(value = "/{id}")
|
|
|
|
public AjaxResult getInfo(@PathVariable("id") Long id)
|
|
|
|
public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return success(khGatherService.selectKhGatherById(id));
|
|
|
|
return success(khGatherService.selectKhGatherById(id));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -136,8 +228,7 @@ public class KhGatherController extends BaseController
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:add')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:add')")
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.INSERT)
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.INSERT)
|
|
|
|
@PostMapping
|
|
|
|
@PostMapping
|
|
|
|
public AjaxResult add(@RequestBody KhGather khGather)
|
|
|
|
public AjaxResult add(@RequestBody KhGather khGather) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return toAjax(khGatherService.insertKhGather(khGather));
|
|
|
|
return toAjax(khGatherService.insertKhGather(khGather));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -147,8 +238,7 @@ public class KhGatherController extends BaseController
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:edit')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:edit')")
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.UPDATE)
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.UPDATE)
|
|
|
|
@PutMapping
|
|
|
|
@PutMapping
|
|
|
|
public AjaxResult edit(@RequestBody KhGather khGather)
|
|
|
|
public AjaxResult edit(@RequestBody KhGather khGather) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return toAjax(khGatherService.updateKhGather(khGather));
|
|
|
|
return toAjax(khGatherService.updateKhGather(khGather));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -157,9 +247,8 @@ public class KhGatherController extends BaseController
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:remove')")
|
|
|
|
@PreAuthorize("@ss.hasPermi('kaohe:gather:remove')")
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.DELETE)
|
|
|
|
@Log(title = "生成汇总", businessType = BusinessType.DELETE)
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
@DeleteMapping("/{ids}")
|
|
|
|
public AjaxResult remove(@PathVariable Long[] ids)
|
|
|
|
public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return toAjax(khGatherService.deleteKhGatherByIds(ids));
|
|
|
|
return toAjax(khGatherService.deleteKhGatherByIds(ids));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|