From 10f558d6ad2cfc9caa71ec7bccfd7c132e45a460 Mon Sep 17 00:00:00 2001 From: zhc077 <565291854> Date: Fri, 24 Nov 2023 17:30:23 +0800 Subject: [PATCH] =?UTF-8?q?=E8=83=BD=E5=8A=9B=E9=87=8F=E5=8C=96=E9=97=AE?= =?UTF-8?q?=E9=A2=98=E4=BF=AE=E6=94=B9=E3=80=81=E5=8A=9F=E8=83=BD=E4=BC=98?= =?UTF-8?q?=E5=8C=96=2011.24?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/common/util/ComputeUtils.java | 12 ++ .../entity/DepartAbilityEvaluation.java | 74 ---------- .../PersonalAbilityEvaluationCollect.java | 73 ---------- .../DepartAbilityEvaluationServiceImpl.java | 35 +++-- ...alAbilityEvaluationCollectServiceImpl.java | 55 ++++---- .../PersonalAbilityEvaluationServiceImpl.java | 100 +++++++------- .../depart/DepartAbilityEvaluation.data.ts | 129 ++---------------- .../PersonalAbilityEvaluationCollect.data.ts | 129 ++---------------- .../PersonalAbilityEvaluation.data.ts | 119 ++-------------- 9 files changed, 130 insertions(+), 596 deletions(-) diff --git a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java index 6ef35b4b..42304f42 100644 --- a/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java +++ b/jeecg-boot-master/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/ComputeUtils.java @@ -47,6 +47,18 @@ public class ComputeUtils { return b1.multiply(b2).doubleValue(); } + /** + * 精确的乘法运算 + * @param v1 + * @param v2 + * @return + */ + public static double mul2(double v1, double v2) { + BigDecimal b1 = BigDecimal.valueOf(v1); + BigDecimal b2 = BigDecimal.valueOf(v2); + return b1.multiply(b2).setScale(2,BigDecimal.ROUND_HALF_UP).doubleValue(); + } + /** //提供(相对)精确的除法运算,当发生除不尽的情况时 diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/DepartAbilityEvaluation.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/DepartAbilityEvaluation.java index b898a0ed..52696cf9 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/DepartAbilityEvaluation.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/DepartAbilityEvaluation.java @@ -75,80 +75,6 @@ public class DepartAbilityEvaluation implements Serializable { @ApiModelProperty(value = "年度") private String annualId; - /** - * 能力1 - */ - @Excel(name = "能力1", width = 15) - @ApiModelProperty(value = "能力1") - private Double soc1; - /** - * 能力2 - */ - @Excel(name = "能力2", width = 15) - @ApiModelProperty(value = "能力2") - private Double soc2; - /** - * 能力3 - */ - @Excel(name = "能力3", width = 15) - @ApiModelProperty(value = "能力3") - private Double soc3; - /** - * 能力4 - */ - @Excel(name = "能力4", width = 15) - @ApiModelProperty(value = "能力4") - private Double soc4; - /** - * 能力5 - */ - @Excel(name = "能力5", width = 15) - @ApiModelProperty(value = "能力5") - private Double soc5; - /** - * 能力6 - */ - @Excel(name = "能力6", width = 15) - @ApiModelProperty(value = "能力6") - private Double soc6; - /** - * 能力7 - */ - @Excel(name = "能力7", width = 15) - @ApiModelProperty(value = "能力7") - private Double soc7; - /** - * 能力8 - */ - @Excel(name = "能力8", width = 15) - @ApiModelProperty(value = "能力8") - private Double soc8; - /** - * 能力9 - */ - @Excel(name = "能力9", width = 15) - @ApiModelProperty(value = "能力9") - private Double soc9; - /** - * 能力10 - */ - @Excel(name = "能力10", width = 15) - @ApiModelProperty(value = "能力10") - private Double soc10; - /** - * 能力11 - */ - @Excel(name = "能力11", width = 15) - @ApiModelProperty(value = "能力11") - private Double soc11; - /** - * 能力12 - */ - @Excel(name = "能力12", width = 15) - @ApiModelProperty(value = "能力12") - private Double soc12; - - /** * 基础能力id */ diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/PersonalAbilityEvaluationCollect.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/PersonalAbilityEvaluationCollect.java index 84616454..739f91a2 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/PersonalAbilityEvaluationCollect.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/entity/PersonalAbilityEvaluationCollect.java @@ -87,79 +87,6 @@ public class PersonalAbilityEvaluationCollect implements Serializable { @ApiModelProperty(value = "姓名") private String name; - /** - * 能力1 - */ - @Excel(name = "能力1", width = 15) - @ApiModelProperty(value = "能力1") - private Double soc1; - /** - * 能力2 - */ - @Excel(name = "能力2", width = 15) - @ApiModelProperty(value = "能力2") - private Double soc2; - /** - * 能力3 - */ - @Excel(name = "能力3", width = 15) - @ApiModelProperty(value = "能力3") - private Double soc3; - /** - * 能力4 - */ - @Excel(name = "能力4", width = 15) - @ApiModelProperty(value = "能力4") - private Double soc4; - /** - * 能力5 - */ - @Excel(name = "能力5", width = 15) - @ApiModelProperty(value = "能力5") - private Double soc5; - /** - * 能力6 - */ - @Excel(name = "能力6", width = 15) - @ApiModelProperty(value = "能力6") - private Double soc6; - /** - * 能力7 - */ - @Excel(name = "能力7", width = 15) - @ApiModelProperty(value = "能力7") - private Double soc7; - /** - * 能力8 - */ - @Excel(name = "能力8", width = 15) - @ApiModelProperty(value = "能力8") - private Double soc8; - /** - * 能力9 - */ - @Excel(name = "能力9", width = 15) - @ApiModelProperty(value = "能力9") - private Double soc9; - /** - * 能力10 - */ - @Excel(name = "能力10", width = 15) - @ApiModelProperty(value = "能力10") - private Double soc10; - /** - * 能力11 - */ - @Excel(name = "能力11", width = 15) - @ApiModelProperty(value = "能力11") - private Double soc11; - /** - * 能力12 - */ - @Excel(name = "能力12", width = 15) - @ApiModelProperty(value = "能力12") - private Double soc12; - /** * 基础能力id */ diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/DepartAbilityEvaluationServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/DepartAbilityEvaluationServiceImpl.java index 896a1760..f2d20a61 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/DepartAbilityEvaluationServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/DepartAbilityEvaluationServiceImpl.java @@ -8,15 +8,15 @@ import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluation import org.jeecg.modules.demo.abilityEvaluation.mapper.DepartAbilityEvaluationMapper; import org.jeecg.modules.demo.abilityEvaluation.service.IDepartAbilityEvaluationService; import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluationService; -import org.jeecg.modules.demo.basicsskill.entity.Basicsskill; import org.jeecg.modules.demo.basicsskill.service.IBasicsskillService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; -import org.springframework.util.ObjectUtils; import java.util.Date; import java.util.LinkedList; import java.util.List; +import java.util.Map; +import java.util.stream.Collectors; /** * @Description: 院系年度能力评价 @@ -30,9 +30,6 @@ public class DepartAbilityEvaluationServiceImpl extends ServiceImpl abilityEvaluationList = iPersonalAbilityEvaluationService.list(new LambdaQueryWrapper() + List abilityEvaluationList4Depet = iPersonalAbilityEvaluationService.list(new LambdaQueryWrapper() .eq(PersonalAbilityEvaluation::getAnnualId, departAbilityEvaluation.getAnnualId()) .eq(PersonalAbilityEvaluation::getDepetId, departAbilityEvaluation.getDepetId()) - .groupBy(PersonalAbilityEvaluation::getCapacityId) ); + Map> depetListMap = abilityEvaluationList4Depet.stream() + .collect(Collectors.groupingBy(PersonalAbilityEvaluation::getCapacityId)); + List saveList = new LinkedList<>(); - if (!ObjectUtils.isEmpty(abilityEvaluationList)) { - abilityEvaluationList.stream().forEach(e -> { - DepartAbilityEvaluation bean = new DepartAbilityEvaluation(); - Basicsskill basicsskill = iBasicsskillService.getById(e.getCapacityId()); - bean.setCapacityId(e.getCapacityId()); - bean.setCapacityName(basicsskill.getName()); - bean.setValue(abilityEvaluationList.stream().mapToDouble(b -> b.getValue()).sum()); - bean.setCreateTime(new Date()); - saveList.add(bean); - }); - } + depetListMap.keySet().stream().forEach(k -> { + List evaluationList = depetListMap.get(k); + DepartAbilityEvaluation bean = new DepartAbilityEvaluation(); + bean.setAnnualId(departAbilityEvaluation.getAnnualId()); + bean.setDepetId(departAbilityEvaluation.getDepetId()); + bean.setCapacityId(evaluationList.get(0).getCapacityId()); + bean.setCapacityName(evaluationList.get(0).getCapacityName()); + bean.setValue(evaluationList.stream().mapToDouble(b -> b.getValue()).sum()); + bean.setCreateTime(new Date()); + saveList.add(bean); + }); this.saveBatch(saveList); } } diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationCollectServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationCollectServiceImpl.java index 9ebdbf6c..011b203c 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationCollectServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationCollectServiceImpl.java @@ -7,17 +7,15 @@ import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluation import org.jeecg.modules.demo.abilityEvaluation.mapper.PersonalAbilityEvaluationCollectMapper; import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluationCollectService; import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluationService; -import org.jeecg.modules.demo.annualcompetitionprojectregistration.entity.TeamManagement; -import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.ITeamManagementService; -import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.entity.SysUser; -import org.jeecg.modules.system.service.ISysDepartService; import org.jeecg.modules.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; +import java.math.RoundingMode; +import java.text.DecimalFormat; import java.util.*; import java.util.stream.Collectors; @@ -34,12 +32,6 @@ public class PersonalAbilityEvaluationCollectServiceImpl extends ServiceImpl evaluationCollects = this.list(new LambdaQueryWrapper() - .eq(PersonalAbilityEvaluationCollect::getAnnualCompP, projectId)); + List evaluations = iPersonalAbilityEvaluationService.list(new LambdaQueryWrapper() + .eq(PersonalAbilityEvaluation::getAnnualCompP, projectId)); //该项目下参赛者们学号列表 - Set workNoSet = evaluationCollects.stream().map(en -> en.getWorkOn()).collect(Collectors.toSet()); + Set workNoSet = evaluations.stream().map(en -> en.getWorkOn()).collect(Collectors.toSet()); - //删除该项目下参赛者们的能力量化汇总数据,用于重新汇总 - this.remove(new LambdaQueryWrapper() - .in(PersonalAbilityEvaluationCollect::getWorkOn, workNoSet)); + if (!ObjectUtils.isEmpty(workNoSet)) { + //删除该项目下参赛者们的能力量化汇总数据,用于重新汇总 + this.remove(new LambdaQueryWrapper() + .in(PersonalAbilityEvaluationCollect::getWorkOn, workNoSet)); + } List saveList = new LinkedList<>(); + DecimalFormat decimalFormat = new DecimalFormat(); + decimalFormat.setMaximumFractionDigits(2); // 保留两位小数 + decimalFormat.setRoundingMode(RoundingMode.HALF_UP); // 设置具体的进位机制 + + //根据学号重新汇总 Optional.ofNullable(workNoSet).orElse(new LinkedHashSet<>()).stream().forEach(workNo -> { - -// TeamManagement management = iTeamManagementService.getOne(new LambdaQueryWrapper() -// .eq(TeamManagement::getEnrollCode, enrollCode)); SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper().eq(SysUser::getWorkNo, workNo)); -// SysDepart sysDepart = iSysDepartService.getDepartByOrgCode(sysUser.getOrgCode()); //每个学生同一类型能力指标分组查询 List evaluationList4User = iPersonalAbilityEvaluationService.list(new LambdaQueryWrapper() - .eq(PersonalAbilityEvaluation::getWorkOn, workNo) - .groupBy(PersonalAbilityEvaluation::getCapacityId)); - Optional.ofNullable(evaluationList4User).orElse(new LinkedList<>()).stream().forEach(en -> { + .eq(PersonalAbilityEvaluation::getWorkOn, workNo)); + + Map> capacityListMap = evaluationList4User.stream() + .collect(Collectors.groupingBy(PersonalAbilityEvaluation::getCapacityId)); + + capacityListMap.keySet().stream().forEach(k -> { + List list = capacityListMap.get(k); PersonalAbilityEvaluationCollect person = new PersonalAbilityEvaluationCollect(); person.setAnnualCompP(projectId); person.setDepetId(sysUser.getDepartIds()); person.setWorkOn(workNo); person.setName(sysUser.getRealname()); - double sum = evaluationList4User.stream().mapToDouble(e -> e.getValue()).sum(); - person.setValue(sum); - person.setCapacityId(en.getCapacityId()); - person.setCapacityName(en.getCapacityName()); + person.setCapacityId(list.get(0).getCapacityId()); + person.setCapacityName(list.get(0).getCapacityName()); + double sum = list.stream().mapToDouble(e -> e.getValue()).sum(); + Double aDouble = Double.valueOf(decimalFormat.format(sum)); + + person.setValue(aDouble); saveList.add(person); }); }); diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationServiceImpl.java index df11f183..8445b7da 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/abilityEvaluation/service/impl/PersonalAbilityEvaluationServiceImpl.java @@ -2,7 +2,6 @@ package org.jeecg.modules.demo.abilityEvaluation.service.impl; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import org.apache.commons.lang3.StringUtils; import org.jeecg.common.util.ComputeUtils; import org.jeecg.modules.demo.abilityEvaluation.entity.PersonalAbilityEvaluation; import org.jeecg.modules.demo.abilityEvaluation.mapper.PersonalAbilityEvaluationMapper; @@ -10,27 +9,23 @@ import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluati import org.jeecg.modules.demo.abilityEvaluation.service.IPersonalAbilityEvaluationService; import org.jeecg.modules.demo.annualCompPoint.entity.AnnualCompPoint; import org.jeecg.modules.demo.annualCompPoint.service.IAnnualCompPointService; +import org.jeecg.modules.demo.annualScore.entity.PersonalCompScore; +import org.jeecg.modules.demo.annualScore.service.IPersonalCompScoreService; import org.jeecg.modules.demo.annualcomp.entity.AnnualComp; import org.jeecg.modules.demo.annualcomp.service.IAnnualCompService; -import org.jeecg.modules.demo.annualcompetitionprojectregistration.entity.TeamManagement; -import org.jeecg.modules.demo.annualcompetitionprojectregistration.service.ITeamManagementService; -import org.jeecg.modules.demo.awardpersion.entity.AwardPersion; -import org.jeecg.modules.demo.awardpersion.service.IAwardPersionService; import org.jeecg.modules.demo.basicsskill.entity.Basicsskill; import org.jeecg.modules.demo.basicsskill.service.IBasicsskillService; import org.jeecg.modules.demo.compskill.entity.Compskill; import org.jeecg.modules.demo.compskill.service.ICompskillService; -import org.jeecg.modules.demo.scorepersion.entity.ScorePersion; -import org.jeecg.modules.demo.scorepersion.service.IScorePersionService; -import org.jeecg.modules.system.entity.SysDepart; import org.jeecg.modules.system.entity.SysUser; -import org.jeecg.modules.system.service.ISysDepartService; import org.jeecg.modules.system.service.ISysUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.ObjectUtils; +import java.math.RoundingMode; +import java.text.DecimalFormat; import java.util.LinkedList; import java.util.List; import java.util.Optional; @@ -47,11 +42,11 @@ public class PersonalAbilityEvaluationServiceImpl extends ServiceImpl compskillList = iCompskillService.list(new LambdaQueryWrapper().eq(Compskill::getAnnucompid, projectId)); if (ObjectUtils.isEmpty(compskillList)) return; - //根据年度比赛项目查询个人获奖表 - List awardPersionList = iAwardPersionService.list(new LambdaQueryWrapper().eq(AwardPersion::getAnnualCompP, projectId)); + List personalCompScoreList = iPersonalCompScoreService.list(new LambdaQueryWrapper().eq(PersonalCompScore::getAnnualCompP, projectId)); List saveList = new LinkedList<>(); - Optional.ofNullable(awardPersionList).orElse(new LinkedList<>()).forEach(e -> { - //查询获奖个人对应的分数 - ScorePersion scorePersion = iScorePersionService.getOne(new LambdaQueryWrapper() - .eq(ScorePersion::getEnrollCode, e.getEnrollCode()) - .eq(ScorePersion::getAnnualCompP, projectId) - .last("limit 1")); - - if (!ObjectUtils.isEmpty(scorePersion) && StringUtils.isNotBlank(scorePersion.getScore())) { - - TeamManagement management = iTeamManagementService.getOne(new LambdaQueryWrapper() - .eq(TeamManagement::getEnrollCode, e.getEnrollCode())); - SysUser sysUser = iSysUserService.getById(management.getUserId()); -// SysDepart sysDepart = iSysDepartService.getDepartByOrgCode(sysUser.getOrgCode()); - - //遍历每一类能力指标 - compskillList.forEach(compskill -> { - PersonalAbilityEvaluation person = new PersonalAbilityEvaluation(); - person.setAnnualId(annualComp.getAnnualid()); - person.setAnnualCompId(annualCompPoint.getAnnualCompId()); - person.setAnnualCompP(projectId); - person.setWorkOn(sysUser.getWorkNo()); - person.setName(sysUser.getRealname()); - person.setDepetId(sysUser.getDepartIds()); - - Basicsskill basicsskill = iBasicsskillService.getById(compskill.getCapacityid()); - person.setCapacityId(compskill.getCapacityid()); - person.setCapacityName(basicsskill.getName()); - - //计算能力量化各类指标 能力量化值 = 直接按项目的能力权值和项目奖项得分算 - //能力量化值 = 项目得分*项目的能力权值/100 - this.convertScore(compskill.getWeight(), person, Double.valueOf(scorePersion.getScore())); - saveList.add(person); - }); - } + Optional.ofNullable(personalCompScoreList).orElse(new LinkedList<>()).stream().forEach(en -> { + + //在lambda中,使用return时并不会直接返回,而是进行相当于普通for里的continue操作。所以直接使用return即可。 + //分数为空时,继续下一条 + if (ObjectUtils.isEmpty(en.getScore())) return; + + SysUser sysUser = iSysUserService.getOne(new LambdaQueryWrapper().eq(SysUser::getWorkNo, en.getWorkOn())); + //遍历每一类能力指标 + compskillList.forEach(compskill -> { + PersonalAbilityEvaluation person = new PersonalAbilityEvaluation(); + person.setAnnualId(annualComp.getAnnualid()); + person.setAnnualCompId(annualCompPoint.getAnnualCompId()); + person.setAnnualCompP(projectId); + person.setWorkOn(en.getWorkOn()); + person.setName(sysUser.getRealname()); + person.setDepetId(en.getDepet()); + + Basicsskill basicsskill = iBasicsskillService.getById(compskill.getCapacityid()); + person.setCapacityId(compskill.getCapacityid()); + person.setCapacityName(basicsskill.getName()); + + //计算能力量化各类指标 能力量化值 = 直接按项目的能力权值和项目奖项得分算 + //能力量化值 = 项目得分*项目的能力权值/100 + this.convertScore(compskill.getWeight(), person, en.getScore()); + saveList.add(person); + }); + }); //删除该项目下所有人的能力量化数据 @@ -153,13 +140,18 @@ public class PersonalAbilityEvaluationServiceImpl extends ServiceImpl