1、院系总积分功能开发

dev
zhc077 1 year ago
parent 56b31b5863
commit ad2edd5d6e
  1. 7
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/DepartCompTotalScoreServiceImpl.java
  2. 68
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/PersonalCompScoreServiceImpl.java

@ -40,12 +40,11 @@ public class DepartCompTotalScoreServiceImpl extends ServiceImpl<DepartCompTotal
List<PersonalCompScore> personalCompScoreList = iPersonalCompScoreService.list(new LambdaQueryWrapper<PersonalCompScore>()
.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);

@ -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<PersonalCompScoreM
@Autowired
private IPersonalCompTotalScoreService iPersonalCompTotalScoreService;
@Autowired
private IAwardPersionService iAwardPersionService;
private static final Integer ONE_HUNDRED = 100;
private static final Double ZERO_POINT_FIVE = 0.5;
private static final Double ZERO_POINT_TWO = 0.2;
@ -74,9 +79,11 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreM
//年度比赛id
String annualCompId = personalCompScore.getAnnualCompId();
//年度比赛
AnnualComp annualComp = iAnnualCompService.getById(annualCompId);
if (ObjectUtils.isEmpty(annualComp)) return;
//比赛
Comp comp = iCompService.getById(annualComp.getCompid());
if (ObjectUtils.isEmpty(comp)) return;
//项目分值
@ -91,20 +98,20 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreM
List<PersonalCompScore> saveList = new LinkedList<>();
if (!ObjectUtils.isEmpty(annualCompPoint)) {
//TODO
//1、根据年度比赛项目id,查询获取管理(award_persion)列表,即参赛人员及获取奖项顺序号
List<AwardPersion> awardPersionList = iAwardPersionService.list(new LambdaQueryWrapper<AwardPersion>()
.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
Optional.ofNullable(awardPersionList).orElse(new LinkedList<>()).forEach(en -> {
AnnualCompAward annualCompAward = iAnnualCompAwardService.getById("获奖理理表id");
//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;
Integer wardsort = 0;
//权重 百分比
//奖项权重值 百分比
String weightVal;
switch (wardsort) {
switch (en.getAwardsort()) {
case 1:
weightVal = annualCompAward.getFifthWeight();
break;
@ -121,20 +128,24 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreM
weightVal = annualCompAward.getFifthWeight();
break;
default:
weightVal = "1";
weightVal = "100";
}
//参与形式 个人、团队,键值对 N-个人 Y-团队
String entryForm = annualCompPoint.getEntryForm();
//2.2 根据报名编号查询参赛者信息
List<TeamManagement> managementList = iTeamManagementService.list(new LambdaQueryWrapper<TeamManagement>()
.eq(TeamManagement::getEnrollCode, "获奖管理表enroll_code")
.eq(TeamManagement::getEnrollCode, en.getEnrollCode())
);
//参与形式 个人、团队,键值对 N-个人 Y-团队
//3、计算积分
if (ObjectUtils.isEmpty(managementList)) return;
//3、计算积分 项目分值*项目奖项权重值/100
double baseScore = ComputeUtils.mul(compweight_val, ComputeUtils.div2(new Double(weightVal), ONE_HUNDRED));
AtomicReference<Double> score = new AtomicReference<>((double) 0);
if (StringUtils.equals("Y", entryForm)) { //团队赛
Optional.ofNullable(managementList).orElse(new ArrayList<>()).forEach(e -> {
// 参与形式是团队时,队长积分*0.5,职员积分*0.2
//captain 是否队长,自关联表如果是队长则是为0.如果不是存储队长学号
//captain 是否队长
if (StringUtils.equals("0", e.getCaptain())) {
score.set(ComputeUtils.mul(baseScore, ZERO_POINT_FIVE));
} else {
@ -168,12 +179,12 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreM
bean.setScore(score.get());
saveList.add(bean);
}
});
}
this.saveBatch(saveList);
//个人比赛积分汇总完成,汇总个人总积分
//个人比赛积分汇总完成,汇总个人总积分
this.iPersonalCompTotalScoreService.saveOrUpdateTotalScore(saveList);
//更新状态为积分已汇总
@ -183,31 +194,4 @@ public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreM
.set(AnnualCompPoint::getAnnualCompState, 10)
.update();
}
/**
* 精确的乘法运算
*
* @param v1
* @param v2
* @return
*/
// public static double mul(double v1, double v2) {
// BigDecimal b1 = BigDecimal.valueOf(v1);
// BigDecimal b2 = BigDecimal.valueOf(v2);
// return b1.multiply(b2).doubleValue();
// }
//
// /**
// * @description: 提供(相对)精确的除法运算,当发生除不尽的情况时
// * 精确到小数点后10位的数字四舍五入
// * @param: [v1, v2]
// * @return: double
// * @author: z.h.c
// * @date: 23/11/1 08:41
// */
// public static double div(double v1, double v2) {
// BigDecimal b1 = BigDecimal.valueOf(v1);
// BigDecimal b2 = BigDecimal.valueOf(v2);
// return b1.divide(b2, 2, BigDecimal.ROUND_HALF_UP).doubleValue();
// }
}

Loading…
Cancel
Save