Merge remote-tracking branch 'origin/main'

main
wanglei 5 months ago
commit 729b15128a

@ -1,11 +1,17 @@
package com.ruoyi.kaohe.controller;
import java.util.List;
import java.math.BigDecimal;
import java.util.*;
import javax.servlet.http.HttpServletResponse;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
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.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
@ -33,66 +39,155 @@ import com.ruoyi.common.core.page.TableDataInfo;
*/
@RestController
@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
private IKhGatherService khGatherService;
/**
*
*
*/
@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
//@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
@PostMapping("/generateSum")
public AjaxResult generateSum(JSONObject json)
{
String hz_name = json.getString("title");
JSONArray data = json.getJSONArray("data");
public AjaxResult generateSum(@RequestBody String json) {
// 将String转换为JSONObject
JSONObject jsonObject = JSONObject.parseObject(json);
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);
String type1 = jsonObject.getString("type");
if(type1.equals("0")){
JSONArray data1 = jsonObject.getJSONArray("data");
}else{
//循环主标题下的每一个子节点
Map<String, Object> nodes = parseJson(datas, hz_name);
JSONObject btKhdx = (JSONObject)nodes.get("btKhdx");
JSONObject head = (JSONObject) nodes.get("head");
JSONArray oldchildren = head.getJSONArray("children");
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": "教学单位领导班子考核总分",
"data": [{
"type": 0,
"title": "教学单位领导班子考核总分",
"data": [
{
"type": "0",
"title": "二级单位目标管理与绩效考核成绩",
"zb": 0.7
"data": [{
"data": [
{
"type": 1,
"title": "党建与行政目标任务",
"id": 1,
"zb": 0.1
},
{
"type": 1,
"type": "1",
"title": "事业发展",
"id": 3,
"id": 4,
"zb": 0.9
}
]
},
{
"type": 1,
"type": "1",
"title": "民主测评",
"id": 2,
"zb": 0.3
},
{
"type": 1,
"type": "1",
"title": "创新",
"id": 3
"id": 5
}
]
}*/
return AjaxResult.success();
}
/**
@ -100,8 +195,7 @@ public class KhGatherController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('kaohe:gather:list')")
@GetMapping("/list")
public TableDataInfo list(KhGather khGather)
{
public TableDataInfo list(KhGather khGather) {
startPage();
List<KhGather> list = khGatherService.selectKhGatherList(khGather);
return getDataTable(list);
@ -113,8 +207,7 @@ public class KhGatherController extends BaseController
@PreAuthorize("@ss.hasPermi('kaohe:gather:export')")
@Log(title = "生成汇总", businessType = BusinessType.EXPORT)
@PostMapping("/export")
public void export(HttpServletResponse response, KhGather khGather)
{
public void export(HttpServletResponse response, KhGather khGather) {
List<KhGather> list = khGatherService.selectKhGatherList(khGather);
ExcelUtil<KhGather> util = new ExcelUtil<KhGather>(KhGather.class);
util.exportExcel(response, list, "生成汇总数据");
@ -125,8 +218,7 @@ public class KhGatherController extends BaseController
*/
@PreAuthorize("@ss.hasPermi('kaohe:gather:query')")
@GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") Long id)
{
public AjaxResult getInfo(@PathVariable("id") Long id) {
return success(khGatherService.selectKhGatherById(id));
}
@ -136,8 +228,7 @@ public class KhGatherController extends BaseController
@PreAuthorize("@ss.hasPermi('kaohe:gather:add')")
@Log(title = "生成汇总", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody KhGather khGather)
{
public AjaxResult add(@RequestBody KhGather khGather) {
return toAjax(khGatherService.insertKhGather(khGather));
}
@ -147,8 +238,7 @@ public class KhGatherController extends BaseController
@PreAuthorize("@ss.hasPermi('kaohe:gather:edit')")
@Log(title = "生成汇总", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody KhGather khGather)
{
public AjaxResult edit(@RequestBody KhGather khGather) {
return toAjax(khGatherService.updateKhGather(khGather));
}
@ -158,8 +248,7 @@ public class KhGatherController extends BaseController
@PreAuthorize("@ss.hasPermi('kaohe:gather:remove')")
@Log(title = "生成汇总", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
public AjaxResult remove(@PathVariable Long[] ids) {
return toAjax(khGatherService.deleteKhGatherByIds(ids));
}
}

@ -175,17 +175,18 @@ public class KhKhrwResultController extends BaseController {
children2.add(tabledata2);
}
} else {//单独评分
if (index1 == 1) {
sumScore = sumScore.add(voteEmp.getAvgScore());
votesDatas.put("khx"+index2, voteEmp.getAvgScore());
if (index1 == 1) {
children2.add(tabledata);
}
sumScore = sumScore.add(voteEmp.getAvgScore());
}
}
pcdata.put("khdx", key);
pcdata.put(pyPCtitle, votesDatas);
pcdata.put("df", sumScore);
endData.add(pcdata);
if (index1 == 1) {
tableColumn2.put("children", children2);
}

@ -0,0 +1,53 @@
package com.ruoyi.kaohe.domain;
import java.math.BigDecimal;
import java.util.List;
public class KhgatherParam {
private String title;
private String type;
private BigDecimal zb;
private Long id;
private List<KhgatherParam> data;
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public BigDecimal getZb() {
return zb;
}
public void setZb(BigDecimal zb) {
this.zb = zb;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
public List<KhgatherParam> getData() {
return data;
}
public void setData(List<KhgatherParam> data) {
this.data = data;
}
}
Loading…
Cancel
Save