1、个人年度积分功能开发

dev
zhc077 1 year ago
parent 9fd85881c7
commit ad6d1df069
  1. 1
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/controller/PersonalCompScoreController.java
  2. 163
      jeecg-boot-master/jeecg-module-demo/src/main/java/org/jeecg/modules/demo/annualScore/service/impl/PersonalCompScoreServiceImpl.java
  3. 17
      jeecgboot-vue3-master/src/views/annualCompPoint/committee/AnnualCompPoint.api.ts
  4. 21
      jeecgboot-vue3-master/src/views/annualCompPoint/committee/AnnualCompPointList.vue

@ -45,6 +45,7 @@ public class PersonalCompScoreController extends JeecgController<PersonalCompSco
@ApiOperation(value = "个人比赛积分-统计汇总", notes = "个人比赛积分-统计汇总") @ApiOperation(value = "个人比赛积分-统计汇总", notes = "个人比赛积分-统计汇总")
@PostMapping(value = "/collectScore") @PostMapping(value = "/collectScore")
public Result<String> collectScore4Person(@RequestBody PersonalCompScore personalCompScore) { public Result<String> collectScore4Person(@RequestBody PersonalCompScore personalCompScore) {
log.info("个人积分汇总 params:{}--", personalCompScore);
personalCompScoreService.collectScore(personalCompScore); personalCompScoreService.collectScore(personalCompScore);
return Result.OK("操作成功!"); return Result.OK("操作成功!");
} }

@ -1,23 +1,182 @@
package org.jeecg.modules.demo.annualScore.service.impl; package org.jeecg.modules.demo.annualScore.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.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.entity.PersonalCompScore;
import org.jeecg.modules.demo.annualScore.mapper.PersonalCompScoreMapper; import org.jeecg.modules.demo.annualScore.mapper.PersonalCompScoreMapper;
import org.jeecg.modules.demo.annualScore.service.IPersonalCompScoreService; 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.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.comp.entity.Comp;
import org.jeecg.modules.demo.comp.service.ICompService;
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.stereotype.Service;
import org.springframework.util.ObjectUtils;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.atomic.AtomicReference;
/** /**
* @Description: 个人比赛积分 * @Description: 个人比赛积分
* @Author: jeecg-boot * @Author: jeecg-boot
* @Date: 2023-10-30 * @Date: 2023-10-30
* @Version: V1.0 * @Version: V1.0
*/ */
@Service @Service
public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreMapper, PersonalCompScore> implements IPersonalCompScoreService { public class PersonalCompScoreServiceImpl extends ServiceImpl<PersonalCompScoreMapper, PersonalCompScore> implements IPersonalCompScoreService {
@Autowired
private IAnnualCompService iAnnualCompService;
@Autowired
private IAnnualCompPointService iAnnualCompPointService;
@Autowired
private ICompService iCompService;
@Autowired
private IAnnualCompAwardService iAnnualCompAwardService;
@Autowired
private ITeamManagementService iTeamManagementService;
@Autowired
private ISysDepartService iSysDepartService;
@Autowired
private ISysUserService iSysUserService;
@Override @Override
public void collectScore(PersonalCompScore personalCompScore) { public void collectScore(PersonalCompScore personalCompScore) {
//年度比赛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;
//项目分值
Integer compweight = comp.getCompweight();
double compweight_val = compweight.doubleValue();
//年度比赛项目,只有isPj为1时才能触发个人比赛积分汇总
AnnualCompPoint annualCompPoint = iAnnualCompPointService.getOne(new LambdaQueryWrapper<AnnualCompPoint>()
.eq(AnnualCompPoint::getAnnualCompId, annualCompId)
.eq(AnnualCompPoint::getIsPj, new Integer(1))
);
List<PersonalCompScore> saveList = new LinkedList<>();
if (!ObjectUtils.isEmpty(annualCompPoint)) {
//TODO
//1、根据年度比赛项目id,查询获取管理(award_persion)列表,即参赛人员及获取奖项顺序号
//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 = mul(compweight_val, new Double(weightVal));
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(mul(baseScore, new Double(0.5)));
} else {
score.set(mul(baseScore, new Double(0.2)));
}
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(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);
iAnnualCompPointService.lambdaUpdate()
.eq(AnnualCompPoint::getId,personalCompScore.getId())
.eq(AnnualCompPoint::getIsPj,1)
.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();
} }
} }

@ -12,6 +12,7 @@ enum Api {
importExcel = '/AnnualCompPoint/annualCompPoint/importExcel', importExcel = '/AnnualCompPoint/annualCompPoint/importExcel',
exportXls = '/AnnualCompPoint/annualCompPoint/exportXls', exportXls = '/AnnualCompPoint/annualCompPoint/exportXls',
updateApply = '/AnnualCompPoint/annualCompPoint/updateApply', updateApply = '/AnnualCompPoint/annualCompPoint/updateApply',
collectScore = '/annualScore/personalCompScore/collectScore',
} }
/** /**
@ -91,3 +92,19 @@ export const updateApply = (params,handleSuccess) => {
} }
}); });
} }
// 个人积分汇总
export const collectScore = (params,handleSuccess) => {
createConfirm({
iconType: 'warning',
title: '确认操作',
content: '确认发送请求吗',
okText: '确认',
cancelText: '取消',
onOk: () => {
return defHttp.post({url: Api.collectScore,params}, {joinParamsToUrl: true}).then(() => {
handleSuccess();
});
}
});
}

@ -69,7 +69,8 @@ import {
batchDelete, batchDelete,
getImportUrl, getImportUrl,
getExportUrl, getExportUrl,
updateApply updateApply,
collectScore
} from './AnnualCompPoint.api'; } from './AnnualCompPoint.api';
import {downloadFile} from '/@/utils/common/renderUtils'; import {downloadFile} from '/@/utils/common/renderUtils';
import AnnualCompPointModal from './components/AnnualCompPointModal.vue' import AnnualCompPointModal from './components/AnnualCompPointModal.vue'
@ -92,7 +93,7 @@ const {prefixCls, tableContext, onExportXls, onImportXls} = useListPage({
canResize: false, canResize: false,
useSearchForm: false, useSearchForm: false,
actionColumn: { actionColumn: {
width: 200, width: 330,
fixed: 'right', fixed: 'right',
}, },
beforeFetch: (params) => { beforeFetch: (params) => {
@ -177,6 +178,10 @@ function handleSubmitandApply(record: Recordable) {
updateApply({id: record.id, annualCompState: record.annualCompState}, handleSuccess); updateApply({id: record.id, annualCompState: record.annualCompState}, handleSuccess);
} }
function handleCollectScoreApply(record: Recordable) {
collectScore({id: record.id, annualCompId: record.annualCompId}, handleSuccess);
}
/** /**
* 删除事件 * 删除事件
*/ */
@ -251,6 +256,18 @@ function getTableAction(record) {
onClick: pingjiang.bind(null, record), onClick: pingjiang.bind(null, record),
}); });
} }
/**
是否已凭奖为1且未汇总过时可以积分汇总操作
* 状态0待提交1已提交(待审核)2已审核(已通过)3待驳回4已驳回5-已报名6-已选题7-已上传作品8-已评分9-已评奖,10-积分已汇总
*/
if (record.isPj == 1 && record.annualCompState != "10") {
actions.unshift({
label: '个人积分汇总',
onClick: handleCollectScoreApply.bind(null, record),
});
}
actions.unshift({ actions.unshift({
label: '作品管理', label: '作品管理',
onClick: workManage.bind(null, record), onClick: workManage.bind(null, record),

Loading…
Cancel
Save