diff --git a/ruoyi-admin/src/main/resources/logback.xml b/ruoyi-admin/src/main/resources/logback.xml index a360583..0ccb46f 100644 --- a/ruoyi-admin/src/main/resources/logback.xml +++ b/ruoyi-admin/src/main/resources/logback.xml @@ -1,7 +1,8 @@ - + + diff --git a/ruoyi-kaohe/pom.xml b/ruoyi-kaohe/pom.xml index 97fb6e1..04677b2 100644 --- a/ruoyi-kaohe/pom.xml +++ b/ruoyi-kaohe/pom.xml @@ -22,6 +22,11 @@ ruoyi-common ${ruoyi.version} + + com.belerweb + pinyin4j + 2.5.0 + \ No newline at end of file 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 bb733fe..17187e4 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 @@ -1,7 +1,16 @@ package com.ruoyi.kaohe.controller; -import java.util.List; +import java.math.BigDecimal; +import java.util.*; +import java.util.stream.Collectors; import javax.servlet.http.HttpServletResponse; + +import com.alibaba.fastjson2.JSONArray; +import com.alibaba.fastjson2.JSONObject; +import com.ruoyi.kaohe.domain.*; +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; @@ -16,7 +25,6 @@ import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; import com.ruoyi.common.core.domain.AjaxResult; import com.ruoyi.common.enums.BusinessType; -import com.ruoyi.kaohe.domain.KhKhrwResult; import com.ruoyi.kaohe.service.IKhKhrwResultService; import com.ruoyi.common.utils.poi.ExcelUtil; import com.ruoyi.common.core.page.TableDataInfo; @@ -33,6 +41,184 @@ public class KhKhrwResultController extends BaseController { @Autowired private IKhKhrwResultService khKhrwResultService; + @Autowired + private IKhVoteEmpService voteEmpService; + @Autowired + private IKhVoteService khVoteService; + + /** + * 生成考核结果 + */ + //@PreAuthorize("@ss.hasPermi('kaohe:kh_result:add')") + @GetMapping("/generateResult") + public AjaxResult generateResult(KhPingce pc) { //传递参数 id、pc_title、bkhdxtype + JSONArray header = new JSONArray();//存放表头及表格关联数据 + JSONObject headerData = new JSONObject(); + headerData.put("name", null); + headerData.put("label", pc.getPcTitle()); + List children = new ArrayList<>(); + JSONObject tableColumn = new JSONObject(); + tableColumn.put("name", "khdxName"); + 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); + + // votesMap.put(vote.getVoteTitle(),khVoteEmps); + 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(); + for (Map.Entry> entry : entries) { + BigDecimal sumScore=BigDecimal.ZERO; + String key = entry.getKey(); + //获取表头数据 + List children2 = new ArrayList<>(); + List children3 = new ArrayList<>(); + JSONObject child1 = new JSONObject(); + JSONObject child2 = new JSONObject(); + JSONObject child3 = new JSONObject(); + JSONObject child4 = new JSONObject(); + JSONObject child5 = new JSONObject(); + JSONObject child6 = new JSONObject(); +//------------------------------------------------------------------------------------------------------ + + //获取表数据 + JSONObject pcdata = new JSONObject(); + List value = entry.getValue(); + JSONObject votesDatas = new JSONObject(); + Integer index=0; + for (KhVoteEmp voteEmp : value) { + index++; + String pyVoteTitle = PinYinUtil.getPinyinInitials(voteEmp.getVoteTitle()); + JSONObject tabledata = new JSONObject(); + tabledata.put("name", pyVoteTitle); + tabledata.put("label", voteEmp.getVoteTitle()); + + Object objectData; + //根据考核类型存储不同数据 + if (voteEmp.getKhitemTypeid().equals(1L)) { //评分选项 + KhXxpf xxpf = new KhXxpf(); + xxpf.setOptionA(voteEmp.getOptionA()); + xxpf.setOptionB(voteEmp.getOptionB()); + xxpf.setOptionC(voteEmp.getOptionC()); + xxpf.setOptionD(voteEmp.getOptionD()); + xxpf.setAvgScore(voteEmp.getAvgScore()); + xxpf.setPercentage(voteEmp.getPercentage()); + objectData = xxpf; + sumScore=sumScore.add(voteEmp.getEndScore()); + if(index==1){ + child1.put("name","optionA"); + child1.put("label","优秀"); + child2.put("name","optionB"); + child2.put("label","合格"); + child3.put("name","optionC"); + child3.put("label","基本合格"); + child4.put("name","optionD"); + child4.put("label","不合格"); + child5.put("name","avgScore"); + child5.put("label","得分"); + child6.put("name","percentage"); + child6.put("label","占比"); + children3.add(child1); + children3.add(child2); + children3.add(child3); + children3.add(child4); + children3.add(child5); + children3.add(child6); + } + + + + } else if (voteEmp.getKhitemTypeid().equals(2L)) {//评分占比 + KhPfzb pfzb = new KhPfzb(); + pfzb.setAvgScore(voteEmp.getAvgScore()); + pfzb.setPercentage(voteEmp.getPercentage()); + objectData = pfzb; + sumScore=sumScore.add(voteEmp.getEndScore()); + + + if(index==1){ + child1.put("name","avgScore"); + child1.put("label","得分"); + child2.put("name","percentage"); + child2.put("label","占比"); + children3.add(child2); + children3.add(child1); + } + + + } else {//单独评分 + KhDdpf ddpf = new KhDdpf(); + ddpf.setAvgScore(voteEmp.getAvgScore()); + objectData = ddpf; + sumScore=sumScore.add(voteEmp.getAvgScore()); + + + if(index==1){{ + child1.put("name","avgScore"); + child1.put("label","得分"); + children3.add(child1); + }} + } + votesDatas.put(pyVoteTitle, objectData); + + tabledata.put("children",children3); + children2.add(tabledata); + } + pcdata.put("khdxName", key); + pcdata.put(pyPCtitle, votesDatas); + pcdata.put("df",sumScore); + endData.add(pcdata); + + tableColumn2.put("children",children2); + } + + children.add(tableColumn2); + JSONObject tableColumn3 = new JSONObject(); + tableColumn3.put("name", "df"); + tableColumn3.put("label", "得分"); + children.add(tableColumn3); + headerData.put("children",children); + header.add(headerData); + + + KhKhrwResult pcResult = new KhKhrwResult(); + pcResult.setPcId(pc.getId()); + pcResult.setPcName(pc.getPcTitle()); + pcResult.setTableHeader(header.toJSONString()); + pcResult.setTableData(endData.toJSONString()); + khKhrwResultService.insertKhKhrwResult(pcResult); + return AjaxResult.success(); + + } /** * 查询考核结果列表 diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java index efdfc9f..6a29314 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhPingceController.java @@ -1,13 +1,17 @@ package com.ruoyi.kaohe.controller; -import java.util.List; +import java.math.BigDecimal; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; import javax.servlet.http.HttpServletResponse; +import com.alibaba.fastjson2.JSONObject; import com.ruoyi.kaohe.domain.*; import com.ruoyi.kaohe.service.IKhPcEmpService; 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.transaction.annotation.Transactional; @@ -40,39 +44,6 @@ public class KhPingceController extends BaseController { private IKhPingceService khPingceService; @Autowired private IKhPcEmpService pcEmpService; - @Autowired - private IKhVoteEmpService voteEmpService; - @Autowired - private IKhVoteService khVoteService; - - /** - * 生成考核结果 - */ - // @PreAuthorize("@ss.hasPermi('kaohe:pingce:list')") - @GetMapping("/generateResult") - public TableDataInfo generateResult(Long id) { - KhVote khVote = new KhVote(); - khVote.setPingceId(id); - //查询该考核任务下的所有评分任务 - List votes = khVoteService.selectKhVoteList(khVote); - for (KhVote vote : votes) { - KhVoteEmp khVoteEmp = new KhVoteEmp(); - khVoteEmp.setVoteId(vote.getId()); - //查询该评分任务对应的所有被考核对象详情 - List khVoteEmps = voteEmpService.selectKhVoteEmpList(khVoteEmp); - for (KhVoteEmp voteEmp : khVoteEmps) { - //根据考核类型存储不同数据 - if(vote.getKhitemTypeid().equals(1L)){ - - }else if(vote.getKhitemTypeid().equals(2L)) { - - }else{ - - } - } - } - return getDataTable(null); - } /** * 查询考核评测列表 diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteController.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteController.java index 113bc73..4a585a0 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteController.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/controller/KhVoteController.java @@ -152,8 +152,19 @@ public class KhVoteController extends BaseController { @PreAuthorize("@ss.hasPermi('kaohe:vote:edit')") @Log(title = "投票评测", businessType = BusinessType.UPDATE) @PutMapping + @Transactional public AjaxResult edit(@RequestBody KhVote khVote) { - return toAjax(khVoteService.updateKhVote(khVote)); + //voteid查询职工评分修改对应值 + KhVoteEmp query = new KhVoteEmp(); + query.setVoteId(khVote.getId()); + List khVoteEmps = voteEmpService.selectKhVoteEmpList(query); + for (KhVoteEmp khVoteEmp : khVoteEmps) { + khVoteEmp.setPercentage(khVote.getPercentage()); + khVoteEmp.setVoteTitle(khVote.getVoteTitle()); + voteEmpService.updateKhVoteEmp(khVoteEmp); + } + khVoteService.updateKhVote(khVote); + return AjaxResult.success(); } /** diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhDdpf.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhDdpf.java new file mode 100644 index 0000000..4920fb6 --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhDdpf.java @@ -0,0 +1,29 @@ +package com.ruoyi.kaohe.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; + +import java.math.BigDecimal; + +/** + * 单独评分 + * + * @author hs + * @date 2025-06-23 + */ +public class KhDdpf extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + /** 最终分数 */ + @Excel(name = "得分") + private BigDecimal avgScore; + + public BigDecimal getAvgScore() { + return avgScore; + } + + public void setAvgScore(BigDecimal avgScore) { + this.avgScore = avgScore; + } +} diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhKhrwResult.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhKhrwResult.java index ae57b4d..d118fdd 100644 --- a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhKhrwResult.java +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhKhrwResult.java @@ -1,6 +1,5 @@ package com.ruoyi.kaohe.domain; -import java.math.BigDecimal; import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringStyle; import com.ruoyi.common.annotation.Excel; @@ -8,9 +7,9 @@ import com.ruoyi.common.core.domain.BaseEntity; /** * 考核结果对象 kh_khrw_result - * + * * @author hs - * @date 2025-07-05 + * @date 2025-07-09 */ public class KhKhrwResult extends BaseEntity { @@ -19,13 +18,13 @@ public class KhKhrwResult extends BaseEntity /** 主键 */ private Long id; - /** 考核任务id */ - @Excel(name = "考核任务id") - private Long khrwId; + /** 考核id */ + @Excel(name = "考核id") + private Long pcId; - /** 考核任务名称 */ - @Excel(name = "考核任务名称") - private String khrwName; + /** 考核名称 */ + @Excel(name = "考核名称") + private String pcName; /** 表头 */ @Excel(name = "表头") @@ -35,84 +34,69 @@ public class KhKhrwResult extends BaseEntity @Excel(name = "表数据") private String tableData; - /** 得分 */ - @Excel(name = "得分") - private BigDecimal endScore; - - public void setId(Long id) + public void setId(Long id) { this.id = id; } - public Long getId() + public Long getId() { return id; } - public void setKhrwId(Long khrwId) + public void setPcId(Long pcId) { - this.khrwId = khrwId; + this.pcId = pcId; } - public Long getKhrwId() + public Long getPcId() { - return khrwId; + return pcId; } - public void setKhrwName(String khrwName) + public void setPcName(String pcName) { - this.khrwName = khrwName; + this.pcName = pcName; } - public String getKhrwName() + public String getPcName() { - return khrwName; + return pcName; } - public void setTableHeader(String tableHeader) + public void setTableHeader(String tableHeader) { this.tableHeader = tableHeader; } - public String getTableHeader() + public String getTableHeader() { return tableHeader; } - public void setTableData(String tableData) + public void setTableData(String tableData) { this.tableData = tableData; } - public String getTableData() + public String getTableData() { return tableData; } - public void setEndScore(BigDecimal endScore) - { - this.endScore = endScore; - } - - public BigDecimal getEndScore() - { - return endScore; - } - @Override public String toString() { return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) - .append("id", getId()) - .append("khrwId", getKhrwId()) - .append("khrwName", getKhrwName()) - .append("tableHeader", getTableHeader()) - .append("tableData", getTableData()) - .append("endScore", getEndScore()) - .append("createBy", getCreateBy()) - .append("createTime", getCreateTime()) - .append("updateBy", getUpdateBy()) - .append("updateTime", getUpdateTime()) - .append("remark", getRemark()) - .toString(); + .append("id", getId()) + .append("pcId", getPcId()) + .append("pcName", getPcName()) + .append("tableHeader", getTableHeader()) + .append("tableData", getTableData()) + .append("createBy", getCreateBy()) + .append("createTime", getCreateTime()) + .append("updateBy", getUpdateBy()) + .append("updateTime", getUpdateTime()) + .append("remark", getRemark()) + .toString(); } } diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhPfzb.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhPfzb.java new file mode 100644 index 0000000..cecddba --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhPfzb.java @@ -0,0 +1,45 @@ +package com.ruoyi.kaohe.domain; + +import com.ruoyi.common.annotation.Excel; +import com.ruoyi.common.core.domain.BaseEntity; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +import java.math.BigDecimal; + +/** + * 评分占比 + * + * @author hs + * @date 2025-06-23 + */ +public class KhPfzb extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + /** 最终分数 */ + @Excel(name = "得分") + private BigDecimal avgScore; + + /** 评分占比(0-1之间) */ + @Excel(name = "评分占比(0-1之间)") + private BigDecimal percentage; + + + public BigDecimal getPercentage() { + return percentage; + } + + public void setPercentage(BigDecimal percentage) { + this.percentage = percentage; + } + + public BigDecimal getAvgScore() { + return avgScore; + } + + public void setAvgScore(BigDecimal avgScore) { + this.avgScore = avgScore; + } +} diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhXxpf.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhXxpf.java new file mode 100644 index 0000000..fe85310 --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/domain/KhXxpf.java @@ -0,0 +1,88 @@ +package com.ruoyi.kaohe.domain; + +import com.ruoyi.common.annotation.Excel; + +import java.math.BigDecimal; + +/** + * 选项评分 + */ +public class KhXxpf { + private static final long serialVersionUID = 1L; + + /** 优秀 */ + @Excel(name = "优秀") + private BigDecimal optionA; + + /** 合格 */ + @Excel(name = "合格") + private BigDecimal optionB; + + /** 基本合格 */ + @Excel(name = "基本合格") + private BigDecimal optionC; + + /** 不合格 */ + @Excel(name = "不合格") + private BigDecimal optionD; + +/* *//** 平均分数 *//* + @Excel(name = "平均分数") + private BigDecimal avgScore;*/ + + /** 最终分数 */ + @Excel(name = "得分") + private BigDecimal avgScore; + + /** 评分占比(0-1之间) */ + @Excel(name = "评分占比(0-1之间)") + private BigDecimal percentage; + + public BigDecimal getOptionA() { + return optionA; + } + + public void setOptionA(BigDecimal optionA) { + this.optionA = optionA; + } + + public BigDecimal getOptionB() { + return optionB; + } + + public void setOptionB(BigDecimal optionB) { + this.optionB = optionB; + } + + public BigDecimal getOptionC() { + return optionC; + } + + public void setOptionC(BigDecimal optionC) { + this.optionC = optionC; + } + + public BigDecimal getOptionD() { + return optionD; + } + + public void setOptionD(BigDecimal optionD) { + this.optionD = optionD; + } + + public BigDecimal getPercentage() { + return percentage; + } + + public void setPercentage(BigDecimal percentage) { + this.percentage = percentage; + } + + public BigDecimal getAvgScore() { + return avgScore; + } + + public void setAvgScore(BigDecimal avgScore) { + this.avgScore = avgScore; + } +} diff --git a/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/util/PinYinUtil.java b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/util/PinYinUtil.java new file mode 100644 index 0000000..4f42863 --- /dev/null +++ b/ruoyi-kaohe/src/main/java/com/ruoyi/kaohe/util/PinYinUtil.java @@ -0,0 +1,25 @@ +package com.ruoyi.kaohe.util; + +import net.sourceforge.pinyin4j.PinyinHelper; +import org.springframework.stereotype.Component; + +@Component +public class PinYinUtil { + + // 判断是否为中文字符 + public static String getPinyinInitials(String chinese) { + StringBuilder pinyinInitial = new StringBuilder(); + for (char c : chinese.toCharArray()) { + String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c); + if (pinyinArray != null && pinyinArray.length > 0) { + // 取拼音的首字母并转换为大写 + pinyinInitial.append(pinyinArray[0].charAt(0)); + } else { + // 如果无法转换,可以添加其他处理,例如跳过或替换为特定字符 + pinyinInitial.append(c); + } + } + return pinyinInitial.toString().toLowerCase(); // 可以选择转换为大写或小写 + } + +} diff --git a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhKhrwResultMapper.xml b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhKhrwResultMapper.xml index 887021b..93cfb80 100644 --- a/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhKhrwResultMapper.xml +++ b/ruoyi-kaohe/src/main/resources/mapper/kaohe/KhKhrwResultMapper.xml @@ -1,16 +1,15 @@ + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> - + - - + + - @@ -19,20 +18,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - select id, khrw_id, khrw_name, table_header, table_data, end_score, create_by, create_time, update_by, update_time, remark from kh_khrw_result + select id, pc_id, pc_name, table_header, table_data, create_by, create_time, update_by, update_time, remark from kh_khrw_result - +