Merge remote-tracking branch 'origin/main'

main
wanglei 5 months ago
commit 8b81383ca3

@ -59,6 +59,7 @@ public class KhGatherController extends BaseController {
// 将String转换为JSONObject
JSONObject jsonObject = new JSONObject(json);
String hz_name = jsonObject.getString("title");
String pyhz_name = PinYinUtil.getPinyinInitials(hz_name);
JSONArray datas = jsonObject.getJSONArray("data");
//拼接表头数据
JSONArray header = new JSONArray();//存放表头的最终数据
@ -75,23 +76,32 @@ public class KhGatherController extends BaseController {
newChildren.put(oldchild);
}
JSONObject zongfen = new JSONObject();
zongfen.put("name",PinYinUtil.getPinyinInitials(hz_name)+"_zf");
zongfen.put("label","总分");
zongfen.put("name", pyhz_name + "_df");
zongfen.put("label", "总分");
newChildren.put(zongfen);
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);
JSONArray hz_df = new JSONArray((JSONArray) nodes.get("title_df"));
for (Object zf : hz_df) {
JSONObject chulizf = (JSONObject) zf;
BigDecimal yijidf = chulizf.getBigDecimal(pyhz_name + "_df");
JSONObject newDf = new JSONObject();
newDf.put(pyhz_name + "_df", yijidf);
chulizf.put(pyhz_name, newDf);
chulizf.remove(pyhz_name + "_df");
zf = chulizf;
}
tabledata.putAll(hz_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));
gather.setTableHeader(header.toString());
gather.setTableData(endTableData.toString());
khGatherService.insertKhGather(gather);
return AjaxResult.success();
}
@ -107,7 +117,7 @@ public class KhGatherController extends BaseController {
private Map<String, Object> parseJson(JSONArray datas, String titleP, BigDecimal z_zb) throws JsonProcessingException {
Map<String, Object> result = new HashMap<>();
JSONArray endtTitle_df = new JSONArray();//存储标题占比时的得分
JSONArray hz_df = new JSONArray();//存储标题占比时的得分
JSONArray title_df = new JSONArray();//处理标题占比时的得分
String pyTitle = PinYinUtil.getPinyinInitials(titleP);//父级表头
JSONObject btKhdx = new JSONObject(true); //表头考核对象存储
@ -129,7 +139,7 @@ public class KhGatherController extends BaseController {
if (jobj.has("zb")) {
zb = jobj.getBigDecimal("zb");
}
//如果有子集就遍历
//标题--------------------------------------------------------------
if (type.equals("0")) {
JSONArray data2 = jobj.getJSONArray("data");
//递归获取下一级数据
@ -152,36 +162,51 @@ public class KhGatherController extends BaseController {
JSONArray alldatas1 = (JSONArray) childmap.get("alldatas");
JSONArray title_df1 = (JSONArray) childmap.get("title_df");
/*if(title_df1==null){//代表它下面还是标题,没有数据 多级标题的
btKhdx = (JSONObject) childmap.get("btKhdx");
if (title_df1 == null) {//代表它下面还是标题,没有数据 多级标题的
BigDecimal erjidf = BigDecimal.ZERO;
JSONObject outsideTitle = new JSONObject();
JSONObject newDf = new JSONObject();
newDf.put(erjiPyTitle+"_df", erjidf);
newDf.put(erjiPyTitle + "_df", erjidf);
if (z_zb != null) { //如果传递过来的标题占比不为null
BigDecimal erjizsfs = z_zb.multiply(erjidf);
newDf.put(erjiPyTitle + "_zb", z_zb);
newDf.put(erjiPyTitle + "_zsfs", erjizsfs);
}
outsideTitle.put(pyTitle,newDf);
title_df.put(outsideTitle);
}else{*/
JSONArray title_df_cl = new JSONArray(JsonDeepMerge.jsonGroupSum(title_df1, "khdx", erjiPyTitle + "_df"));
//循环处理后的标题得分 加上层级及 占比、折算分数
for (Object df : title_df_cl) {
JSONObject dfobj = (JSONObject) df;
BigDecimal erjidf = dfobj.getBigDecimal(erjiPyTitle + "_df");
JSONObject newDf = new JSONObject();
newDf.put(erjiPyTitle + "_df", erjidf);
if (zb != null) { //如果传递过来的标题占比不为null
BigDecimal erjizsfs = zb.multiply(erjidf);
newDf.put(erjiPyTitle + "_zb", zb);
newDf.put(erjiPyTitle + "_zsfs", erjizsfs);
outsideTitle.put(pyTitle, newDf);
title_df1.put(outsideTitle);
} else {
//循环处理后的标题得分 加上层级及 占比、折算分数
for (Object df : title_df1) {
JSONObject dfobj = (JSONObject) df;
BigDecimal erjidf = dfobj.getBigDecimal(erjiPyTitle + "_df");
JSONObject newDf = new JSONObject();
newDf.put(erjiPyTitle + "_df", erjidf);
BigDecimal erjizsfs = BigDecimal.ZERO;
if (zb != null) { //如果标题占比不为null
erjizsfs = zb.multiply(erjidf);
newDf.put(erjiPyTitle + "_zb", zb);
newDf.put(erjiPyTitle + "_zsfs", erjizsfs);
}
//标题递归来得分数据按格式 //{"khdx":"",pyTitle _df:defen}存储到title_df中
JSONObject hzdf = new JSONObject();
hzdf.put("khdx", dfobj.get("khdx"));
if (zb != null) {
hzdf.put(pyTitle + "_df", erjizsfs);
} else {
hzdf.put(pyTitle + "_df", erjidf);
}
title_df.put(hzdf);
dfobj.remove(erjiPyTitle + "_df");//删除原来的数据项
dfobj.put(pyTitle, newDf);//删除原来的数据项
df = dfobj;//更改df结构添加外层主题嵌套 如:{"khdx":"",pyTitle:{erjiPyTitle_df:defen}}
}
dfobj.remove(erjiPyTitle + "_df");//删除原来的数据项
dfobj.put(pyTitle, newDf);//删除原来的数据项
df = dfobj;
alldatas.putAll(title_df1);
}
title_df=title_df_cl;
//循环改变内部层级关系
for (Object tabledatum : alldatas1) {
@ -234,20 +259,19 @@ public class KhGatherController extends BaseController {
BigDecimal zsfs = zb.multiply((BigDecimal) obj.get(pinyinKhrw + "_df"));
erji.put(pinyinKhrw + "_zb", zb);
erji.put(pinyinKhrw + "_zsfs", zsfs);
if (z_zb != null) {//代表上一级标题有占比
JSONObject khdx = new JSONObject();
khdx.put("khdx", obj.get("khdx"));//存储当前考核对象名称
khdx.put(pyTitle + "_df", zsfs);//存储当前考核对象最后折算分数
title_df.put(khdx);
}
} else {
if (z_zb != null) {//代表上一级标题有占比
title_df.put(obj.getJSONObject("khdx"));//
JSONObject khdx = new JSONObject();
khdx.put("khdx", obj.get("khdx"));//存储当前考核对象名称
khdx.put(pyTitle + "_df", obj.get(pinyinKhrw + "_df"));///存储当前考核对象最后折算分数
title_df.put(khdx);
}
//获取上一级标题得分数组
JSONObject khdx = new JSONObject();
khdx.put("khdx", obj.get("khdx"));//存储当前考核对象名称
khdx.put(pyTitle + "_df", zsfs);//存储当前考核对象最后折算分数
title_df.put(khdx); //{"khdx":"",pyTitle _df:defen}
} else { //当前考核任务无占比 上面只存储了得分
//获取上一级标题得分数组
JSONObject khdx = new JSONObject();
khdx.put("khdx", obj.get("khdx"));//存储当前考核对象名称
khdx.put(pyTitle + "_df", obj.get(pinyinKhrw + "_df"));///存储当前考核对象最后得分
title_df.put(khdx); //{"khdx":"",pyTitle _df:defen}
}
obj.remove(pinyinKhrw);//删除原来的数据项
obj.remove(pinyinKhrw + "_df");//删除原来的得分
@ -258,14 +282,14 @@ public class KhGatherController extends BaseController {
}
}
}
title_df = new JSONArray(JsonDeepMerge.jsonGroupSum(title_df, "khdx", pyTitle + "_df"));
btTitle.put("children", btchildren);
result.put("head", btTitle);
result.put("data", bd);
result.put("alldatas", alldatas);
result.put("btKhdx", btKhdx);
result.put("title_df", title_df);
result.put("btKhdx", btKhdx);
return result;
}

@ -64,7 +64,7 @@ public class JsonDeepMerge {
public static String jsonGroupSum(JSONArray jsonInput,String groupKey,String sumKey) throws JsonProcessingException {
ObjectMapper mapper = new ObjectMapper();
// 解析JSON数组为List<Map>
List<Map<String, Object>> inputList = mapper.readValue(jsonInput.toString(2), List.class);
List<Map<String, Object>> inputList = mapper.readValue(jsonInput.toString(), List.class);
// 使用Map按khdx分组并累加值
Map<String, BigDecimal> sumMap = new HashMap<>();

@ -27,6 +27,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="tableHeader != null and tableHeader != ''"> and table_header = #{tableHeader}</if>
<if test="tableData != null and tableData != ''"> and table_data = #{tableData}</if>
</where>
ORDER BY id DESC
</select>
<select id="selectKhGatherById" parameterType="Long" resultMap="KhGatherResult">

@ -40,7 +40,6 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<select id="selectKhPingceList" parameterType="KhPingce" resultMap="KhPingceResult">
<include refid="selectKhPingceVo"></include>
/*select p.*, emp_id,emp_name,dept_id,dept_name from kh_pingce p left join kh_pc_emp pe on p.id=pe.pc_id*/
<where>
<if test="pcTitle != null and pcTitle != ''"> and pc_title = #{pcTitle}</if>
<if test="pcDescription != null and pcDescription != ''"> and pc_description = #{pcDescription}</if>
@ -49,6 +48,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="pcResultId != null "> and pc_result_id = #{pcResultId}</if>
<if test="state != null and state != ''"> and state = #{state}</if>
</where>
ORDER BY id DESC
</select>
<select id="getBkhdxs" resultMap="BkhdxsResult">

@ -1,6 +1,8 @@
package com.ruoyi.quartz.task;
import com.ruoyi.kaohe.domain.KhPingce;
import com.ruoyi.kaohe.domain.KhVote;
import com.ruoyi.kaohe.service.IKhPingceService;
import com.ruoyi.kaohe.service.IKhVoteService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
@ -19,11 +21,14 @@ public class RyTask
{
@Autowired
private IKhVoteService khVoteService;
@Autowired
private IKhPingceService khPingceService;
public void performTask() {
System.out.println("进入定时任务-------------------------------------------------------------");
//获取所有未完成的评分任务
List<KhVote> list = khVoteService.selectUnfinishedVote();
//根据时间自动修改评分任务状态
for (KhVote vote : list) {
Date sTime = vote.getsTime();
Date eTime = vote.geteTime();
@ -42,6 +47,27 @@ public class RyTask
System.out.println("执行定时任务: " + System.currentTimeMillis() + " 修改评分任务: " + vote.getVoteTitle() + " 状态为已完成");
}
}
//修改考核任务状态,当考核任务下的所有评分任务状态为已完成时 考核任务状态进行中修改为已完成
KhPingce param = new KhPingce();
param.setState("1");
List<KhPingce> khPingces = khPingceService.selectKhPingceList(param);
for (KhPingce khPingce : khPingces) {
KhVote vote = new KhVote();
vote.setPingceId(khPingce.getId());
List<KhVote> khVotes = khVoteService.selectKhVoteList(vote);
boolean finished = true;
for (KhVote khVote : khVotes) {
if( khVote.getState().equals("0")|| khVote.getState().equals("1")){
finished=false;
break;
}
}
if(finished){
khPingce.setState("2");
}
}
}
public void ryMultipleParams(String s, Boolean b, Long l, Double d, Integer i)

@ -92,7 +92,7 @@ public abstract class AbstractQuartzJob implements Job
}
// 写入数据库当中
SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
// SpringUtils.getBean(ISysJobLogService.class).addJobLog(sysJobLog);
}
/**

Loading…
Cancel
Save