From ad2edd5d6eb291fdb8e3c2dc2292dcea6cb9bdb5 Mon Sep 17 00:00:00 2001 From: zhc077 <565291854> Date: Fri, 3 Nov 2023 16:50:18 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E9=99=A2=E7=B3=BB=E6=80=BB=E7=A7=AF?= =?UTF-8?q?=E5=88=86=E5=8A=9F=E8=83=BD=E5=BC=80=E5=8F=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../impl/DepartCompTotalScoreServiceImpl.java | 7 +- .../impl/PersonalCompScoreServiceImpl.java | 170 ++++++++---------- 2 files changed, 80 insertions(+), 97 deletions(-) diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/DepartCompTotalScoreServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/DepartCompTotalScoreServiceImpl.java index b60e7a7b0..d5e4b4823 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/DepartCompTotalScoreServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/DepartCompTotalScoreServiceImpl.java @@ -40,12 +40,11 @@ public class DepartCompTotalScoreServiceImpl extends ServiceImpl personalCompScoreList = iPersonalCompScoreService.list(new LambdaQueryWrapper() .eq(PersonalCompScore::getAnnualId, departCompTotalScore.getAnnualId()) - .eq(PersonalCompScore::getDepet, departCompTotalScore.getDepet())); + .eq(PersonalCompScore::getDepet, departCompTotalScore.getDepet()) + ); double totalScore = 0; - if (ObjectUtils.isEmpty(personalCompScoreList)) { - totalScore = 0; - } else { + if (!ObjectUtils.isEmpty(personalCompScoreList)) { totalScore = personalCompScoreList.stream().mapToDouble(PersonalCompScore::getScore).sum(); } departCompTotalScore.setScore(totalScore); diff --git a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/PersonalCompScoreServiceImpl.java b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/PersonalCompScoreServiceImpl.java index e298bc4d5..1bf8364a0 100644 --- a/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/PersonalCompScoreServiceImpl.java +++ b/jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/PersonalCompScoreServiceImpl.java @@ -16,6 +16,8 @@ import org.jeecg.modules.demo.annualcompaward.entity.AnnualCompAward; import org.jeecg.modules.demo.annualcompaward.service.IAnnualCompAwardService; 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.comp.entity.Comp; import org.jeecg.modules.demo.comp.service.ICompService; import org.jeecg.modules.system.entity.SysDepart; @@ -62,6 +64,9 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl saveList = new LinkedList<>(); if (!ObjectUtils.isEmpty(annualCompPoint)) { - //TODO //1、根据年度比赛项目id,查询获取管理(award_persion)列表,即参赛人员及获取奖项顺序号 + List awardPersionList = iAwardPersionService.list(new LambdaQueryWrapper() + .eq(AwardPersion::getAnnualCompP, annualCompPoint.getId())); //2、遍历获奖理理(award_persion)列表,根据奖项id查询比赛奖项设置表(annual_comp_award) - //2.1、比赛奖项设置 根据awardsort奖项顺序,获取对应的奖项权重值 - //奖项顺序与交期权重值映射关系: wardsort(1:first_weight,2:second_weight,3:third_weight,4:fourth_weight,5:fifth_weight - - - AnnualCompAward annualCompAward = iAnnualCompAwardService.getById("获奖理理表id"); - if (ObjectUtils.isEmpty(annualCompAward)) return; - Integer wardsort = 0; - //权重 百分比 - String weightVal; - switch (wardsort) { - case 1: - weightVal = annualCompAward.getFifthWeight(); - break; - case 2: - weightVal = annualCompAward.getSecondWeight(); - break; - case 3: - weightVal = annualCompAward.getThirdWeight(); - break; - case 4: - weightVal = annualCompAward.getFourthWeight(); - break; - case 5: - weightVal = annualCompAward.getFifthWeight(); - break; - default: - weightVal = "1"; - } - String entryForm = annualCompPoint.getEntryForm(); - List managementList = iTeamManagementService.list(new LambdaQueryWrapper() - .eq(TeamManagement::getEnrollCode, "获奖管理表enroll_code") - ); - //参与形式 个人、团队,键值对 N-个人 Y-团队 - //3、计算积分 - double baseScore = ComputeUtils.mul(compweight_val, ComputeUtils.div2(new Double(weightVal), ONE_HUNDRED)); - AtomicReference score = new AtomicReference<>((double) 0); - if (StringUtils.equals("Y", entryForm)) { //团队赛 - Optional.ofNullable(managementList).orElse(new ArrayList<>()).forEach(e -> { - // 参与形式是团队时,队长积分*0.5,职员积分*0.2 - //captain 是否队长,自关联表如果是队长则是为0.如果不是存储队长学号 - if (StringUtils.equals("0", e.getCaptain())) { - score.set(ComputeUtils.mul(baseScore, ZERO_POINT_FIVE)); - } else { - score.set(ComputeUtils.mul(baseScore, ZERO_POINT_TWO)); - } - + Optional.ofNullable(awardPersionList).orElse(new LinkedList<>()).forEach(en -> { + + //2.1、比赛奖项设置 根据awardsort奖项顺序,获取对应的奖项权重值 + //奖项顺序与奖项权重值映射关系: wardsort(1:first_weight,2:second_weight,3:third_weight,4:fourth_weight,5:fifth_weight + AnnualCompAward annualCompAward = iAnnualCompAwardService.getById(en.getId()); + if (ObjectUtils.isEmpty(annualCompAward)) return; + //奖项权重值 百分比 + String weightVal; + switch (en.getAwardsort()) { + case 1: + weightVal = annualCompAward.getFifthWeight(); + break; + case 2: + weightVal = annualCompAward.getSecondWeight(); + break; + case 3: + weightVal = annualCompAward.getThirdWeight(); + break; + case 4: + weightVal = annualCompAward.getFourthWeight(); + break; + case 5: + weightVal = annualCompAward.getFifthWeight(); + break; + default: + weightVal = "100"; + } + //参与形式 个人、团队,键值对 N-个人 Y-团队 + String entryForm = annualCompPoint.getEntryForm(); + + //2.2 根据报名编号查询参赛者信息 + List managementList = iTeamManagementService.list(new LambdaQueryWrapper() + .eq(TeamManagement::getEnrollCode, en.getEnrollCode()) + ); + if (ObjectUtils.isEmpty(managementList)) return; + + //3、计算积分 项目分值*项目奖项权重值/100 + double baseScore = ComputeUtils.mul(compweight_val, ComputeUtils.div2(new Double(weightVal), ONE_HUNDRED)); + AtomicReference score = new AtomicReference<>((double) 0); + if (StringUtils.equals("Y", entryForm)) { //团队赛 + Optional.ofNullable(managementList).orElse(new ArrayList<>()).forEach(e -> { + // 参与形式是团队时,队长积分*0.5,职员积分*0.2 + //captain 是否队长 + if (StringUtils.equals("0", e.getCaptain())) { + score.set(ComputeUtils.mul(baseScore, ZERO_POINT_FIVE)); + } else { + score.set(ComputeUtils.mul(baseScore, ZERO_POINT_TWO)); + } + + PersonalCompScore bean = new PersonalCompScore(); + bean.setAnnualCompId(annualCompId); + bean.setAnnualCompP(annualCompPoint.getId()); + bean.setAnnualId(annualComp.getAnnualid()); + SysUser sysUser = iSysUserService.getById(e.getUserId()); + bean.setWorkOn(sysUser.getWorkNo()); + bean.setName(sysUser.getRealname()); + SysDepart sysDepart = iSysDepartService.getById(sysUser.getOrgCode()); + bean.setDepet(sysDepart.getId()); + bean.setScore(score.get()); + saveList.add(bean); + }); + } else { //个人赛 + score.set(baseScore); + TeamManagement teamManagement = managementList.get(0); PersonalCompScore bean = new PersonalCompScore(); bean.setAnnualCompId(annualCompId); bean.setAnnualCompP(annualCompPoint.getId()); bean.setAnnualId(annualComp.getAnnualid()); - SysUser sysUser = iSysUserService.getById(e.getUserId()); + SysUser sysUser = iSysUserService.getById(teamManagement.getUserId()); bean.setWorkOn(sysUser.getWorkNo()); bean.setName(sysUser.getRealname()); SysDepart sysDepart = iSysDepartService.getById(sysUser.getOrgCode()); bean.setDepet(sysDepart.getId()); bean.setScore(score.get()); saveList.add(bean); - }); - } else { //个人赛 - score.set(baseScore); - TeamManagement teamManagement = managementList.get(0); - PersonalCompScore bean = new PersonalCompScore(); - bean.setAnnualCompId(annualCompId); - bean.setAnnualCompP(annualCompPoint.getId()); - bean.setAnnualId(annualComp.getAnnualid()); - SysUser sysUser = iSysUserService.getById(teamManagement.getUserId()); - bean.setWorkOn(sysUser.getWorkNo()); - bean.setName(sysUser.getRealname()); - SysDepart sysDepart = iSysDepartService.getById(sysUser.getOrgCode()); - bean.setDepet(sysDepart.getId()); - bean.setScore(score.get()); - saveList.add(bean); - } - + } + }); } this.saveBatch(saveList); - //个人比赛积分汇总完成,汇总个人总积分 + //个人比赛积分汇总完成后,汇总个人总积分 this.iPersonalCompTotalScoreService.saveOrUpdateTotalScore(saveList); //更新状态为积分已汇总 @@ -183,31 +194,4 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl