This commit is contained in:
zhouwentao 2024-03-31 12:19:01 +08:00
parent cb541e2508
commit 1953f50c5c
10 changed files with 140 additions and 96 deletions

View File

@ -91,36 +91,22 @@ public class ArtRecommendMajorController {
@ApiOperation(value = "投档分测算")
@GetMapping("/calculateInvestment")
public Result<?> calculateInvestment(QueryCalculateInvestmentVO queryCalculateInvestmentVO) {
/*List<YxHistoryMajorEnroll> list = yxHistoryMajorEnrollService.list(new LambdaQueryWrapper<YxHistoryMajorEnroll>().eq(YxHistoryMajorEnroll::getYear,"2020"));
Map<String,YxHistoryMajorEnroll> maps1=new LinkedHashMap<>();
String key = null;
for (YxHistoryMajorEnroll yxHistoryMajorEnroll : list) {
key = yxHistoryMajorEnroll.getMajorType()+"_"+yxHistoryMajorEnroll.getCategory()+"_"+yxHistoryMajorEnroll.getSchoolCode()+"_"+yxHistoryMajorEnroll.getMajorName()+"_"+yxHistoryMajorEnroll.getBatch();
maps1.put(key,yxHistoryMajorEnroll);
}*/
//List<YxSchoolMajor> yxSchoolMajorList = yxSchoolMajorService.list(new LambdaQueryWrapper<YxSchoolMajor>().isNotNull(YxSchoolMajor::getRulesEnrollProbability).like(YxSchoolMajor::getRulesEnrollProbability,"").notLike(YxSchoolMajor::getRulesEnrollProbability,"+"));
/*YxHistoryMajorEnroll yxHistoryMajorEnroll = null;
for (YxSchoolMajor yxSchoolMajor : yxSchoolMajorList) {
*//*key = yxSchoolMajor.getMajorType()+"_"+yxSchoolMajor.getCategory()+"_"+yxSchoolMajor.getSchoolCode()+"_"+yxSchoolMajor.getMajorName()+"_"+yxSchoolMajor.getBatch();
yxHistoryMajorEnroll = maps1.get(key);*//*
*//*if (yxHistoryMajorEnroll!=null) {
yxSchoolMajor.setRulesEnrollProbability(ScoreUtil.replaceLastZeroChar(yxHistoryMajorEnroll.getRulesEnrollProbability()));
yxSchoolMajor.setProbabilityOperator(ScoreUtil.replaceLastZeroChar(yxHistoryMajorEnroll.getProbabilityOperator()));
}*//*
String rulesEnrollProbability = yxSchoolMajor.getRulesEnrollProbability();
*//*yxSchoolMajor.setRulesEnrollProbability(ScoreUtil.replaceLastZeroChar(yxSchoolMajor.getRulesEnrollProbability()));
yxSchoolMajor.setProbabilityOperator(ScoreUtil.replaceLastZeroChar(yxSchoolMajor.getProbabilityOperator()));*//*
}*/
//yxSchoolMajorService.updateBatchById(yxSchoolMajorList);
//获取 院校专业信息列表,录取方式notnull
LambdaQueryWrapper<YxSchoolMajor> yxSchoolMajorLambdaQueryWrapper = new LambdaQueryWrapper<>();
yxSchoolMajorLambdaQueryWrapper.isNotNull(YxSchoolMajor::getRulesEnrollProbability);
//字段匹配: batch 批次,category 文理分科,majorType 专业类型
yxSchoolMajorLambdaQueryWrapper.eq(StringUtils.isNotBlank(queryCalculateInvestmentVO.getBatch()), YxSchoolMajor::getBatch, queryCalculateInvestmentVO.getBatch());
if (!"高职高专".equals(queryCalculateInvestmentVO.getBatch())) {
yxSchoolMajorLambdaQueryWrapper.ne(YxSchoolMajor::getBatch, "高职高专");
}else{
yxSchoolMajorLambdaQueryWrapper.eq(YxSchoolMajor::getBatch, queryCalculateInvestmentVO.getBatch());
}
yxSchoolMajorLambdaQueryWrapper.eq(StringUtils.isNotBlank(queryCalculateInvestmentVO.getCategory()), YxSchoolMajor::getCategory, queryCalculateInvestmentVO.getCategory());
yxSchoolMajorLambdaQueryWrapper.eq(StringUtils.isNotBlank(queryCalculateInvestmentVO.getProfessionalCategory()), YxSchoolMajor::getMajorType, queryCalculateInvestmentVO.getProfessionalCategory());
if (!"体育类".equals(queryCalculateInvestmentVO.getProfessionalCategory())) {
List<String> probabilityOperatorList = Arrays.asList("文*0.8+专*0.5","文*0.7+专*0.75","文*0.6+专*1","文*0.5+专*1.25");
yxSchoolMajorLambdaQueryWrapper.in(YxSchoolMajor::getProbabilityOperator,probabilityOperatorList);
}
List<YxSchoolMajor> schooMajorList = yxSchoolMajorService.list(yxSchoolMajorLambdaQueryWrapper);
List<ArtCalculateInvestmentDTO> calculateInvestmentDTOList = new ArrayList<>();
try {

View File

@ -5,6 +5,7 @@ import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.google.gson.Gson;
@ -71,6 +72,10 @@ public class MiniArticleController {
private IYxSchoolResearchTeachingService yxSchoolResearchTeachingService;
@Autowired
private IYxCalculationMajorService yxCalculationMajorService;
@Autowired
private IYxUserScoreService yxUserScoreService;
@Autowired
private IYxVolunteerService yxVolunteerService;
@ApiOperation(value = "文章列表")
@GetMapping(value = "/page")
public Result<?> articlePage(QueryArticleVO queryArticleVO) {
@ -154,8 +159,8 @@ public class MiniArticleController {
return Result.OK();
}
if (false) {
yxSchoolResearchTeachingService.test();
if (true) {
yxVolunteerService.removeOldScore(null);
}
if(false){

View File

@ -62,6 +62,8 @@ public class YxConstant {
public static List<String> defaultRulesEnrollProbabilityList = Arrays.asList("文过专排", "专过文排");
public static List<String> batchList1=Arrays.asList("提前批","本科","本科A段","本科B段");
//当天最多修改成绩次数
public static final Integer todayMaxEditScoreCount = 10;
public static BigDecimal bigDecimal1 = new BigDecimal("1");

View File

@ -60,4 +60,5 @@ public interface IYxCalculationMajorService extends IService<YxCalculationMajor>
* @param newCalculationMajorTableName 新TableName
*/
void copyNew(String oldScoreId, String newScoreId, String oldCalculationMajorTableName, String newCalculationMajorTableName);
}

View File

@ -53,4 +53,5 @@ public interface IYxUserScoreService extends IService<YxUserScore> {
* @param userId
*/
void closeUserScore(String userId);
}

View File

@ -54,4 +54,10 @@ public interface IYxVolunteerService extends IService<YxVolunteer> {
* 关闭当前用户的志愿单
*/
void closeUserVolunteer(String userId);
/**
* 删除用户旧的分数
* @param userId 用户id,不传就是所有用户
*/
void removeOldScore(String userId);
}

View File

@ -39,27 +39,19 @@ import java.util.stream.Collectors;
*/
@Service
public class YxCalculationMajorServiceImpl extends ServiceImpl<YxCalculationMajorMapper, YxCalculationMajor> implements IYxCalculationMajorService {
@Resource
private IYxSchoolMajorService yxSchoolMajorService;
@Resource
private IYxHistoryScoreControlLineService yxHistoryScoreControlLineService;
@Resource
private IYxUserScoreService yxUserScoreService;
@Resource
private ZhuanService zhuanService;
@Resource
private MusicService musicService;
@Resource
private TiyuService tiyuService;
@Resource
private BiaoyanService biaoyanService;
@Resource
private WuDaoService wuDaoService;
@Resource
private BoYinService boYinService;
@Resource
private YxHistoryMajorEnrollMapper yxHistoryMajorEnrollMapper;
@Resource
private IYxHistoryMajorEnrollService yxHistoryMajorEnrollService;
@Resource
private YxSchoolMajorMapper yxSchoolMajorMapper;

View File

@ -8,21 +8,22 @@ import org.apache.shiro.SecurityUtils;
import org.jeecg.common.system.vo.LoginUser;
import org.jeecg.common.util.AssertUtils;
import org.jeecg.modules.yx.dto.ProfessionalCategoryChildrenDTO;
import org.jeecg.modules.yx.entity.YxCalculationMajor;
import org.jeecg.modules.yx.entity.YxUserScore;
import org.jeecg.modules.yx.entity.YxVolunteer;
import org.jeecg.modules.yx.mapper.YxCalculationMajorMapper;
import org.jeecg.modules.yx.mapper.YxUserScoreMapper;
import org.jeecg.modules.yx.service.IYxSchoolMajorService;
import org.jeecg.modules.yx.service.IYxUserScoreService;
import org.jeecg.modules.yx.service.IYxVipCardService;
import org.jeecg.modules.yx.mapper.YxVolunteerMapper;
import org.jeecg.modules.yx.service.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
* @Description: 用户分数信息
@ -161,4 +162,5 @@ public class YxUserScoreServiceImpl extends ServiceImpl<YxUserScoreMapper, YxUse
lambdaUpdateWrapper.set(YxUserScore::getState,"0");
this.update(lambdaUpdateWrapper);
}
}

View File

@ -1,8 +1,10 @@
package org.jeecg.modules.yx.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.apache.commons.collections.CollectionUtils;
import org.jeecg.common.util.AssertUtils;
import org.jeecg.modules.art.vo.SaveVolunteerVO;
import org.jeecg.modules.yx.constant.YxConstant;
import org.jeecg.modules.yx.dto.VolunteerRecordDTO;
import org.jeecg.modules.yx.entity.YxSchoolMajor;
import org.jeecg.modules.yx.entity.YxVolunteerRecord;
@ -27,8 +29,6 @@ import java.util.List;
*/
@Service
public class YxVolunteerRecordServiceImpl extends ServiceImpl<YxVolunteerRecordMapper, YxVolunteerRecord> implements IYxVolunteerRecordService {
@Resource
private IYxMajorService yxMajorService;
@Resource
private IYxSchoolMajorService yxSchoolMajorService;
@ -58,32 +58,50 @@ public class YxVolunteerRecordServiceImpl extends ServiceImpl<YxVolunteerRecordM
String majorCode = yxVolunteerRecord.getMajorCode();//院校代码
String schoolCode = yxVolunteerRecord.getSchoolCode();//专业代码
String enrollmentCode = yxVolunteerRecord.getEnrollmentCode();//招生代码
String category = yxVolunteerRecord.getCategory();
Integer indexs = yxVolunteerRecord.getIndexs();
//获取专业的批次 (根据学校代码+专业代码+招生代码)
//获取专业的批次 (根据学校代码+专业代码+招生代码+文理分科)
LambdaQueryWrapper<YxSchoolMajor> smQueryWrapper = new LambdaQueryWrapper<>();
smQueryWrapper.eq(YxSchoolMajor::getSchoolCode, schoolCode);
smQueryWrapper.eq(YxSchoolMajor::getMajorCode, majorCode);
smQueryWrapper.eq(YxSchoolMajor::getEnrollmentCode,enrollmentCode);
smQueryWrapper.eq(YxSchoolMajor::getCategory,yxVolunteerRecord.getCategory());
smQueryWrapper.eq(YxSchoolMajor::getCategory,category);
YxSchoolMajor schoolMajor = yxSchoolMajorService.getOne(smQueryWrapper);
String batch = schoolMajor.getBatch();
String majorType = schoolMajor.getMajorType();
//未获取到 专业的batch.
AssertUtils.notNull(batch,"该专业暂不可添加!");
//List<VolunteerRecordDTO> list = listDTOByVolunteerId(volunteerId);
//获取当前用户选择的志愿单
List<YxVolunteerRecord> list = this.list(new LambdaQueryWrapper<YxVolunteerRecord>()
.eq(YxVolunteerRecord::getVolunteerId, volunteerId)
.eq(YxVolunteerRecord::getBatch,batch)
.gt(YxVolunteerRecord::getIndexs,0)
.orderByAsc(YxVolunteerRecord::getIndexs));
String key = majorCode+schoolCode+enrollmentCode;
//判断这个批次段的是否已填满
long count = list.stream().filter(l -> !(l.getMajorCode()+l.getSchoolCode()+l.getEnrollmentCode()).equals(key)).count();
if ("提前批".equals(batch)) {
AssertUtils.notTrue(count>=2,"提前批仅可以填报两个志愿");
}else{
AssertUtils.notTrue(count>=12,batch+"仅可以填报十二个志愿");
LambdaQueryWrapper<YxVolunteerRecord> yxVolunteerRecordLambdaQueryWrapper = new LambdaQueryWrapper<>();
yxVolunteerRecordLambdaQueryWrapper.eq(YxVolunteerRecord::getVolunteerId, volunteerId);
yxVolunteerRecordLambdaQueryWrapper.gt(YxVolunteerRecord::getIndexs,0);
yxVolunteerRecordLambdaQueryWrapper.orderByAsc(YxVolunteerRecord::getIndexs);
List<YxVolunteerRecord> list = new ArrayList<>();
if (batch.equals("高职高专")) {
yxVolunteerRecordLambdaQueryWrapper.eq(YxVolunteerRecord::getBatch,batch);
//获取当前用户选择的志愿单
list = this.list(yxVolunteerRecordLambdaQueryWrapper);
String key = majorCode+schoolCode+enrollmentCode+category;
//判断这个批次段的是否已填满
long count = list.stream().filter(l -> !(l.getMajorCode()+l.getSchoolCode()+l.getEnrollmentCode()+l.getCategory()).equals(key)).count();
if ("体育类".equals(majorType)) {
AssertUtils.notTrue(count>=12,batch+"仅可以填报十二个志愿");
}else{
AssertUtils.notTrue(count>=35,batch+"仅可以填报三十五个志愿");
}
}else if(YxConstant.batchList1.contains(batch)){
//本科批
yxVolunteerRecordLambdaQueryWrapper.in(YxVolunteerRecord::getBatch,YxConstant.batchList1);
//获取当前用户选择的志愿单
list = this.list(yxVolunteerRecordLambdaQueryWrapper);
String key = majorCode+schoolCode+enrollmentCode+category;
//判断这个批次段的是否已填满
long count = list.stream().filter(l -> !(l.getMajorCode()+l.getSchoolCode()+l.getEnrollmentCode()+l.getCategory()).equals(key)).count();
if ("体育类".equals(majorType)) {
AssertUtils.notTrue(count>=12,batch+"仅可以填报十二个志愿");
}else{
AssertUtils.notTrue(count>=35,batch+"仅可以填报三十五个志愿");
}
}
//循环已填报专业与当前专业对比是否一致
@ -91,7 +109,9 @@ public class YxVolunteerRecordServiceImpl extends ServiceImpl<YxVolunteerRecordM
//如果 院校编码专业编码招生代码 都一致说明该专业直接已经填报过则移除该填报明细
if (volunteer.getSchoolCode().equals(schoolCode) &&
volunteer.getMajorCode().equals(majorCode) &&
volunteer.getEnrollmentCode().equals(enrollmentCode)) {
volunteer.getEnrollmentCode().equals(enrollmentCode) &&
volunteer.getCategory().equals(category)
) {
//一致代表本次是移除填报
this.removeById(volunteer.getId());
return true;

View File

@ -18,10 +18,7 @@ import org.jeecg.modules.mini.service.MiniUserService;
import org.jeecg.modules.yx.constant.YxConstant;
import org.jeecg.modules.yx.dto.VolunteerDTO;
import org.jeecg.modules.yx.dto.VolunteerRecordDTO;
import org.jeecg.modules.yx.entity.YxHistoryMajorEnroll;
import org.jeecg.modules.yx.entity.YxUserScore;
import org.jeecg.modules.yx.entity.YxVolunteer;
import org.jeecg.modules.yx.entity.YxVolunteerRecord;
import org.jeecg.modules.yx.entity.*;
import org.jeecg.modules.yx.mapper.YxVolunteerMapper;
import org.jeecg.modules.yx.service.*;
import org.jeecg.modules.yx.util.ScoreUtil;
@ -118,27 +115,24 @@ public class YxVolunteerServiceImpl extends ServiceImpl<YxVolunteerMapper, YxVol
historyMajorEnrollList.add(yxHistoryMajorEnroll);
}
}
recommendMajorDTO.setHistoryMajorEnrollMap(yearMajorEnrollMap);
recommendMajorDTO.setHistoryMajorEnrollList(historyMajorEnrollList);
}
}
//计算录取概率
//YxSchoolMajorServiceImpl.volunteerRecordListSetEnrollProbability(recordDTOList, userScore);
//填报志愿明细信息-提前批
/*//填报志愿明细信息-提前批
List<VolunteerRecordDTO> volunteerRecordEarlyAdmissionList = recordDTOList.stream().filter(r -> r.getBatch().equals("提前批")).collect(Collectors.toList());
//填报志愿明细信息-本科A段
List<VolunteerRecordDTO> volunteerRecordUndergraduateAList = recordDTOList.stream().filter(r -> r.getBatch().equals("本科A段")).collect(Collectors.toList());
//填报志愿明细信息-本科B段
List<VolunteerRecordDTO> volunteerRecordUndergraduateBList = recordDTOList.stream().filter(r -> r.getBatch().equals("本科B段")).collect(Collectors.toList());
//填报志愿明细信息-本科
List<VolunteerRecordDTO> volunteerRecordUndergraduateList = recordDTOList.stream().filter(r -> r.getBatch().equals("本科")).collect(Collectors.toList());
//填报志愿明细信息-专科
List<VolunteerRecordDTO> volunteerRecordJuniorCollegeList = recordDTOList.stream().filter(r -> r.getBatch().equals("高职高专")).collect(Collectors.toList());
volunteerDTO.setVolunteerRecordEarlyAdmissionList(volunteerRecordEarlyAdmissionList);
volunteerDTO.setVolunteerRecordUndergraduateAList(volunteerRecordUndergraduateAList);
volunteerDTO.setVolunteerRecordUndergraduateBList(volunteerRecordUndergraduateBList);
volunteerDTO.setVolunteerRecordUndergraduateBList(volunteerRecordUndergraduateBList);*/
volunteerDTO.setVolunteerRecordEarlyAdmissionList(new ArrayList<>());
//填报志愿明细信息-本科
List<VolunteerRecordDTO> volunteerRecordUndergraduateList = recordDTOList.stream().filter(r -> YxConstant.batchList1.contains(r.getBatch())).collect(Collectors.toList());
//填报志愿明细信息-专科
List<VolunteerRecordDTO> volunteerRecordJuniorCollegeList = recordDTOList.stream().filter(r -> r.getBatch().equals("高职高专")).collect(Collectors.toList());
volunteerDTO.setVolunteerRecordUndergraduateList(volunteerRecordUndergraduateList);
volunteerDTO.setVolunteerRecordJuniorCollegeList(volunteerRecordJuniorCollegeList);
return volunteerDTO;
@ -146,7 +140,6 @@ public class YxVolunteerServiceImpl extends ServiceImpl<YxVolunteerMapper, YxVol
@Override
public VolunteerDTO findById(String id) {
List<String> historyYearList = YxConstant.oldYearList;
YxVolunteer volunteer = this.getById(id);
if (volunteer == null) {
return null;
@ -159,7 +152,6 @@ public class YxVolunteerServiceImpl extends ServiceImpl<YxVolunteerMapper, YxVol
}
BeanUtils.copyProperties(volunteer, volunteerDTO);
volunteerDTO.setUserScoreInfo(userScore);
String cognitioPolyclinic = userScore.getCognitioPolyclinic();
//获取已填报的志愿单
List<VolunteerRecordDTO> recordDTOList = yxVolunteerRecordService.listDTOByVolunteerId(userScore.getId(),userScore.getCalculationTableName(),volunteer.getId());
//获取上一年的招生人数
@ -167,21 +159,22 @@ public class YxVolunteerServiceImpl extends ServiceImpl<YxVolunteerMapper, YxVol
if (userVip==null || userVip.getVipLevel()==null || userVip.getVipLevel()<2) {
recordDTOList.forEach(r->r.setEnrollProbability(new BigDecimal(0)));
}
yxHistoryMajorEnrollService.volunteerRecordDTOListSetHistoryInfo(recordDTOList);
//填报志愿明细信息-提前批
/*//填报志愿明细信息-提前批
List<VolunteerRecordDTO> volunteerRecordEarlyAdmissionList = recordDTOList.stream().filter(r -> r.getBatch().equals("提前批")).collect(Collectors.toList());
//填报志愿明细信息-本科A段
List<VolunteerRecordDTO> volunteerRecordUndergraduateAList = recordDTOList.stream().filter(r -> r.getBatch().equals("本科A段")).collect(Collectors.toList());
//填报志愿明细信息-本科B段
List<VolunteerRecordDTO> volunteerRecordUndergraduateBList = recordDTOList.stream().filter(r -> r.getBatch().equals("本科B段")).collect(Collectors.toList());
//填报志愿明细信息-本科
List<VolunteerRecordDTO> volunteerRecordUndergraduateList = recordDTOList.stream().filter(r -> r.getBatch().equals("本科")).collect(Collectors.toList());
//填报志愿明细信息-专科
List<VolunteerRecordDTO> volunteerRecordJuniorCollegeList = recordDTOList.stream().filter(r -> r.getBatch().equals("高职高专")).collect(Collectors.toList());
volunteerDTO.setVolunteerRecordEarlyAdmissionList(volunteerRecordEarlyAdmissionList);
volunteerDTO.setVolunteerRecordUndergraduateAList(volunteerRecordUndergraduateAList);
volunteerDTO.setVolunteerRecordUndergraduateBList(volunteerRecordUndergraduateBList);
volunteerDTO.setVolunteerRecordUndergraduateBList(volunteerRecordUndergraduateBList);*/
volunteerDTO.setVolunteerRecordEarlyAdmissionList(new ArrayList<>());
//填报志愿明细信息-本科
List<VolunteerRecordDTO> volunteerRecordUndergraduateList = recordDTOList.stream().filter(r -> YxConstant.batchList1.contains(r.getBatch())).collect(Collectors.toList());
//填报志愿明细信息-专科
List<VolunteerRecordDTO> volunteerRecordJuniorCollegeList = recordDTOList.stream().filter(r -> r.getBatch().equals("高职高专")).collect(Collectors.toList());
volunteerDTO.setVolunteerRecordUndergraduateList(volunteerRecordUndergraduateList);
volunteerDTO.setVolunteerRecordJuniorCollegeList(volunteerRecordJuniorCollegeList);
return volunteerDTO;
@ -227,21 +220,13 @@ public class YxVolunteerServiceImpl extends ServiceImpl<YxVolunteerMapper, YxVol
lambdaQueryWrapper.orderByAsc(YxVolunteerRecord::getCreateTime);
List<YxVolunteerRecord> volunteerRecordList = yxVolunteerRecordService.list(lambdaQueryWrapper);
if (CollectionUtils.isNotEmpty(volunteerRecordList)) {
int tiqian = 0, bena = 0, benb = 0, ben = 0, zhuan = 0;
int benke = 0;
int zhuan = 0;
for (YxVolunteerRecord yxVolunteerRecord : volunteerRecordList) {
if ("提前批".equals(yxVolunteerRecord.getBatch())) {
tiqian++;
yxVolunteerRecord.setIndexs(tiqian);
} else if ("本科A段".equals(yxVolunteerRecord.getBatch())) {
bena++;
yxVolunteerRecord.setIndexs(bena);
} else if ("本科B段".equals(yxVolunteerRecord.getBatch())) {
benb++;
yxVolunteerRecord.setIndexs(benb);
} else if ("本科".equals(yxVolunteerRecord.getBatch())) {
ben++;
yxVolunteerRecord.setIndexs(ben);
} else if ("高职高专".equals(yxVolunteerRecord.getBatch())) {
if (YxConstant.batchList1.contains(yxVolunteerRecord.getBatch())) {
benke++;
yxVolunteerRecord.setIndexs(benke);
}else if ("高职高专".equals(yxVolunteerRecord.getBatch())) {
zhuan++;
yxVolunteerRecord.setIndexs(zhuan);
}
@ -258,6 +243,7 @@ public class YxVolunteerServiceImpl extends ServiceImpl<YxVolunteerMapper, YxVol
LambdaQueryWrapper<YxVolunteer> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(YxVolunteer::getCreateBy, sysUser.getId());
queryWrapper.orderByDesc(YxVolunteer::getCreateTime);
queryWrapper.ne(YxVolunteer::getState,-1);
queryWrapper.last("limit 0,5");
List<YxVolunteer> volunteerList = this.list(queryWrapper);
List<VolunteerDTO> list = new ArrayList<>();
@ -410,4 +396,47 @@ public class YxVolunteerServiceImpl extends ServiceImpl<YxVolunteerMapper, YxVol
yxVolunteerLambdaUpdateWrapper.set(YxVolunteer::getState,"0");
this.update(yxVolunteerLambdaUpdateWrapper);
}
@Override
public void removeOldScore(String userId) {
LambdaQueryWrapper<YxUserScore> lambdaQueryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(userId)) {
lambdaQueryWrapper.eq(YxUserScore::getCreateBy,userId);
}
lambdaQueryWrapper.ne(YxUserScore::getState,-1);
lambdaQueryWrapper.orderByDesc(YxUserScore::getUpdateTime);
List<YxUserScore> list = yxUserScoreService.list(lambdaQueryWrapper);
//根据 userId 分组组装成 Map<String,List<YxUserScore>>
Set<String> removeScoreIdSet=new HashSet<>();
if (CollectionUtils.isNotEmpty(list)) {
Map<String, List<YxUserScore>> listMap = list.stream().collect(Collectors.groupingBy(YxUserScore::getCreateBy));
List<YxUserScore> yxUserScores= null;
for (String key : listMap.keySet()) {
//遍历每个用户的分数
yxUserScores = listMap.get(key);
if (yxUserScores.size()>5) {
//用户有5个分数以上的删除
removeScoreIdSet.addAll(yxUserScores.subList(5, yxUserScores.size()).stream().map(YxUserScore::getId).collect(Collectors.toSet()));
}
}
}
if (CollectionUtils.isNotEmpty(removeScoreIdSet)) {
//将需要删除的成绩单状态改为-1
LambdaUpdateWrapper<YxUserScore> updateWrapper = new LambdaUpdateWrapper<>();
updateWrapper.in(YxUserScore::getId,removeScoreIdSet);
updateWrapper.set(YxUserScore::getState,-1);
yxUserScoreService.update(updateWrapper);
//删除志愿单,状态改为-1
LambdaUpdateWrapper<YxVolunteer> yxVolunteerLambdaUpdateWrapper = new LambdaUpdateWrapper<>();
yxVolunteerLambdaUpdateWrapper.in(YxVolunteer::getScoreId,removeScoreIdSet);
yxVolunteerLambdaUpdateWrapper.set(YxVolunteer::getState,-1);
super.update(yxVolunteerLambdaUpdateWrapper);
//将计算表里的数据删除
LambdaQueryWrapper<YxCalculationMajor> yxCalculationMajorLambdaQueryWrapper = new LambdaQueryWrapper<>();
yxCalculationMajorLambdaQueryWrapper.in(YxCalculationMajor::getScoreId,removeScoreIdSet);
yxCalculationMajorService.remove(yxCalculationMajorLambdaQueryWrapper);
}
}
}