|
|
|
@ -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,89 +98,93 @@ 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
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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<TeamManagement> managementList = iTeamManagementService.list(new LambdaQueryWrapper<TeamManagement>() |
|
|
|
|
.eq(TeamManagement::getEnrollCode, "获奖管理表enroll_code") |
|
|
|
|
); |
|
|
|
|
//参与形式 个人、团队,键值对 N-个人 Y-团队
|
|
|
|
|
//3、计算积分
|
|
|
|
|
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.如果不是存储队长学号
|
|
|
|
|
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<TeamManagement> managementList = iTeamManagementService.list(new LambdaQueryWrapper<TeamManagement>() |
|
|
|
|
.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<Double> 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<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();
|
|
|
|
|
// }
|
|
|
|
|
} |
|
|
|
|