|
|
@@ -14,9 +14,12 @@ import com.ruoyi.common.core.content.VistorContextHolder;
|
|
|
import com.ruoyi.common.core.domain.R;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
import com.ruoyi.common.core.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.enums.ExamType;
|
|
|
+import com.ruoyi.common.enums.SubjectType;
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
+import com.ruoyi.common.utils.dz.SubjectScore;
|
|
|
import com.ruoyi.ie.domain.*;
|
|
|
import com.ruoyi.ie.mapper.*;
|
|
|
import com.ruoyi.system.service.ISysConfigService;
|
|
|
@@ -29,6 +32,7 @@ import com.ruoyi.syzy.mapper.BBusiWishUniversitiesProfessionMapper;
|
|
|
import com.ruoyi.util.PageUtil;
|
|
|
import com.ruoyi.web.domain.Constant;
|
|
|
import com.ruoyi.web.domain.VoluntaryDto;
|
|
|
+import io.swagger.annotations.ApiModelProperty;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
@@ -43,6 +47,7 @@ import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
@Service
|
|
|
public class VoluntaryService {
|
|
|
@@ -50,6 +55,7 @@ public class VoluntaryService {
|
|
|
private static TypeReference<List<VoluntaryDto.SingleResponse>> wishDetailsTypeReference = new TypeReference<List<VoluntaryDto.SingleResponse>>() { };
|
|
|
private static TypeReference<List<VoluntaryDto.AIResponse>> wishAiDetailsTypeReference = new TypeReference<List<VoluntaryDto.AIResponse>>() { };
|
|
|
Set<String> NumberTypeSet = Sets.newHashSet(VoluntaryDto.EnumInputType.Number.name(), VoluntaryDto.EnumInputType.Eyesight.name(), VoluntaryDto.EnumInputType.Score.name());
|
|
|
+ private static VoluntaryRuleHelper voluntaryRuleHelper = new VoluntaryRuleHelper();
|
|
|
|
|
|
private final AWishRecordMapper aWishRecordMapper;
|
|
|
private final AEnrollScoreMapper aEnrollScoreMapper;
|
|
|
@@ -152,6 +158,255 @@ public class VoluntaryService {
|
|
|
return 2025;
|
|
|
}
|
|
|
|
|
|
+ public R<VoluntaryDto.RenderMajorResult> postRenderResult(VoluntaryDto.SingleRequest req, Boolean isScoreOnly) {
|
|
|
+ Integer planYear = getPlanYear(SecurityUtils.getLoginUser().getUser());
|
|
|
+ Integer submitYear = getSubmitYear();
|
|
|
+ String examType = VistorContextHolder.getExamType().title(); // TODO MF
|
|
|
+ String gender = "0".equals(SecurityUtils.getLoginUser().getUser().getSex()) ? "男生" : "女生";
|
|
|
+ Map cond = new HashMap();
|
|
|
+ cond.put("universityCode", req.getUniversityCode());
|
|
|
+ cond.put("examineeType", examType);
|
|
|
+ Map<Long, List<AMarjorPlan>> currUniversityMajorPlansMap = Maps.newHashMap();
|
|
|
+ Map<Long, List<AMarjorPlan>> historyUniversityMajorPlansMap = Maps.newHashMap();
|
|
|
+ List<Map<Long, List<AMarjorPlan>>> bothPlanList = Lists.newArrayList(currUniversityMajorPlansMap, historyUniversityMajorPlansMap);
|
|
|
+ Set<String> existSet = Sets.newHashSet();
|
|
|
+ Long planId = NumberUtils.toLong(req.getMajorEnrollCode(), 0L);
|
|
|
+ for (AMarjorPlan mp : aMarjorPlanMapper.selectListByRuleCond(cond)) {
|
|
|
+ String key = mp.getUniversityId() + mp.getMajorName() + StringUtils.trimToEmpty(mp.getMajorDirection()) + mp.getYear(); // TODO 考虑为什么会重的问题 examType ?
|
|
|
+ if (!existSet.add(key)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ for(Map<Long, List<AMarjorPlan>> tmpMap : bothPlanList) {
|
|
|
+ boolean isCurrYear = mp.getYear().equals(planYear);
|
|
|
+ if (tmpMap == currUniversityMajorPlansMap) {
|
|
|
+ if(!isCurrYear || !mp.getId().equals(planId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ } else if(mp.getYear() > submitYear) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<AMarjorPlan> tmpMpList = tmpMap.get(mp.getUniversityId());
|
|
|
+ if (null == tmpMpList) {
|
|
|
+ tmpMpList = Lists.newArrayList(mp);
|
|
|
+ tmpMap.put(mp.getUniversityId(), tmpMpList);
|
|
|
+ } else {
|
|
|
+ tmpMpList.add(mp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Map<Long, List<BBusiWishUniversitiesProfession>> universityMajorsMap = Maps.newHashMap();
|
|
|
+ // 有计划以计划为准的输出,无计划时则以所有专业输出为准
|
|
|
+ Map<Long, BBusiWishUniversities> universitiesMap = null;
|
|
|
+ if (MapUtils.isEmpty(currUniversityMajorPlansMap)) {
|
|
|
+ Map<String, List<BBusiWishUniversitiesProfession>> tmpUniversityMajorsMap = bBusiWishUniversitiesProfessionMapper.selectListByRuleCond(cond).stream().collect(Collectors.groupingBy(BBusiWishUniversitiesProfession::getCollegeCode));
|
|
|
+ if (MapUtils.isNotEmpty(tmpUniversityMajorsMap)) {
|
|
|
+ Map uCond = Maps.newHashMap();
|
|
|
+ uCond.put("codes", tmpUniversityMajorsMap.keySet());
|
|
|
+ universitiesMap = Maps.newHashMap();
|
|
|
+ for (BBusiWishUniversities u : bBusiWishUniversitiesMapper.selectBBusiWishUniversitiesListSimpleByMap(uCond)) {
|
|
|
+ universitiesMap.put(u.getId(), u);
|
|
|
+ universityMajorsMap.put(u.getId(), tmpUniversityMajorsMap.get(u.getCode()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ cond.put("universityIds", currUniversityMajorPlansMap.keySet());
|
|
|
+ cond.put("examType", Constant.EXAM_TYPE_PG);
|
|
|
+ Map<String, List<BBusiWishUniversitiesProfession>> tmpUniversityMajorsMap = bBusiWishUniversitiesProfessionMapper.selectListByRuleCond(cond).stream().collect(Collectors.groupingBy(BBusiWishUniversitiesProfession::getCollegeCode));
|
|
|
+ cond.remove("universityIds");
|
|
|
+
|
|
|
+ if (MapUtils.isNotEmpty(tmpUniversityMajorsMap)) {
|
|
|
+ Map uCond = new HashMap();
|
|
|
+ uCond.put("ids", currUniversityMajorPlansMap.keySet());
|
|
|
+ universitiesMap = Maps.newHashMap();
|
|
|
+ for (BBusiWishUniversities u : bBusiWishUniversitiesMapper.selectBBusiWishUniversitiesListSimpleByIds(uCond)) {
|
|
|
+ universitiesMap.put(u.getId(), u);
|
|
|
+ universityMajorsMap.put(u.getId(), tmpUniversityMajorsMap.get(u.getCode()));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // 无计划,也无院校专业
|
|
|
+ if(MapUtils.isEmpty(universitiesMap)) {
|
|
|
+ return R.fail("无计划院校专业");
|
|
|
+ }
|
|
|
+ // 查询涉及的规则
|
|
|
+ cond.put("year", planYear);
|
|
|
+ cond.put("universityIds", universitiesMap.keySet());
|
|
|
+ Map<Long, List<AEnrollScore>> universityScoreListMap = aEnrollScoreMapper.selectListByRuleCond(cond).stream().collect(Collectors.groupingBy(AEnrollScore::getUniversityId));
|
|
|
+ cond.remove("universityIds");
|
|
|
+ cond.remove("year");
|
|
|
+
|
|
|
+ Map<String, String> mutexOptionMap = getMutexOptionMap();
|
|
|
+ for (Long universityId : universitiesMap.keySet()) {
|
|
|
+ List<AEnrollScore> scoreList = universityScoreListMap.get(universityId); // 分数条件
|
|
|
+ List<AMarjorPlan> currPlanList = currUniversityMajorPlansMap.get(universityId);// 当年计划
|
|
|
+ List<AMarjorPlan> historyPlanList = historyUniversityMajorPlansMap.get(universityId);// 历年计划
|
|
|
+ BBusiWishUniversities u = universitiesMap.get(universityId);// 院校
|
|
|
+ List<BBusiWishUniversitiesProfession> professionList = universityMajorsMap.get(u.getId()); // 所有专业
|
|
|
+ // 院校变更标志
|
|
|
+ AEnrollUniversity euCond = new AEnrollUniversity();
|
|
|
+ euCond.setUniversityId(u.getId());
|
|
|
+ euCond.setYear(planYear);
|
|
|
+ List<AEnrollUniversity> enrollUniversityList = aEnrollUniversityMapper.selectAEnrollUniversityList(euCond);
|
|
|
+ // 院校历史情况
|
|
|
+ AMarjorSubmit submitCond = new AMarjorSubmit();
|
|
|
+ submitCond.setExamineeType(examType);
|
|
|
+ submitCond.setUniversityId(universityId);
|
|
|
+ List<AMarjorSubmit> submitList = aMarjorSubmitMapper.selectAMarjorSubmitList(submitCond);
|
|
|
+
|
|
|
+ VoluntaryDto.RenderMajorResult sr;
|
|
|
+ if (CollectionUtils.isNotEmpty(currPlanList)) {
|
|
|
+ Map<String, BBusiWishUniversitiesProfession> professionMap = null == professionList ? Maps.newHashMap() : professionList.stream().collect(Collectors.toMap(BBusiWishUniversitiesProfession::getName, Function.identity()));
|
|
|
+ for (AMarjorPlan mp : currPlanList) { // 只有一个
|
|
|
+ if (null != (sr = buildRenderResponse(submitYear, planYear, gender, mp, professionMap.get(mp.getMajorName()), enrollUniversityList, req.getForm(), u,
|
|
|
+ historyPlanList, submitList, scoreList, mutexOptionMap, isScoreOnly))) {
|
|
|
+ sr.setUniversityId(universityId);
|
|
|
+ sr.setMajorId(planId);
|
|
|
+ return R.ok(sr);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.fail("无计划院校专业");
|
|
|
+ }
|
|
|
+
|
|
|
+ private VoluntaryDto.RenderMajorResult buildRenderResponse(Integer submitYear, Integer planYear, String gender, AMarjorPlan currPlan, BBusiWishUniversitiesProfession prof,
|
|
|
+ List<AEnrollUniversity> enrollUniversityList, Map<String, String> paramMap, BBusiWishUniversities u,
|
|
|
+ List<AMarjorPlan> historyPlanList, List<AMarjorSubmit> submitList,
|
|
|
+ List<AEnrollScore> scoreList, Map<String,String> mutexOptionMap, boolean isScoreOnly) {
|
|
|
+ submitList = voluntaryRuleHelper.sortSubmits(submitList);
|
|
|
+ historyPlanList = voluntaryRuleHelper.sortPlans(historyPlanList);
|
|
|
+
|
|
|
+ Boolean typeChange = false;
|
|
|
+ VoluntaryDto.FormulaScoreStat formulaScoreStat = new VoluntaryDto.FormulaScoreStat();
|
|
|
+ String needGroup = StringUtils.trimToEmpty(null != currPlan && null != currPlan.getMajorGroup() ? currPlan.getMajorGroup() : "");
|
|
|
+ String needMajor = StringUtils.trimToEmpty(null != currPlan ? currPlan.getMajorName() : (null != prof ? prof.getName() : ""));
|
|
|
+ String needDirect = StringUtils.trimToEmpty(null != currPlan ? currPlan.getMajorDirection() : "");
|
|
|
+ String needMajorDirect = needMajor + needDirect;
|
|
|
+
|
|
|
+ // 判断是否政策变化情况
|
|
|
+ List<AEnrollUniversity> validEuList = enrollUniversityList.stream()
|
|
|
+ .filter(t -> needGroup.equals(StringUtils.trimToEmpty(t.getMajorGroups())) && t.getMajorNames().contains(needMajor))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ typeChange = CollectionUtils.isNotEmpty(validEuList) && new Integer(1).equals(validEuList.get(0).getTypeChange());
|
|
|
+
|
|
|
+ Set<String> existSet = Sets.newHashSet();
|
|
|
+ List<AMarjorSubmit> validSubmitList = voluntaryRuleHelper.filtValidSubmits(needMajorDirect, submitList, existSet);
|
|
|
+
|
|
|
+ // 录取线
|
|
|
+ List<VoluntaryDto.RenderMajorHistory> histories = Lists.newArrayList(); // 历史录取情况
|
|
|
+ VoluntaryDto.RenderMajorResult sr = new VoluntaryDto.RenderMajorResult();
|
|
|
+ sr.setHistories(histories);
|
|
|
+
|
|
|
+ if (null == scoreList) {
|
|
|
+ throw new RuntimeException("无分数规则");
|
|
|
+ }
|
|
|
+ Map<Boolean, List<AEnrollScore>> majorEnrollScoresMap = voluntaryRuleHelper.buildMajorEnrollScoresMap(scoreList, needGroup);
|
|
|
+ existSet.clear();
|
|
|
+ List<AEnrollScore> fEnrollScoreList = Lists.newArrayList();
|
|
|
+ Double inputScoreRate = NumberUtils.toInt(paramMap.get("ScoreRate"), 0) / 100.0;
|
|
|
+ String inclMajorDirection = needMajor + "(" + needDirect + ")";
|
|
|
+ String exclMajorDirection = needMajor + "(";
|
|
|
+ List<AEnrollScore> tmpEnrollScoreList = majorEnrollScoresMap.get(Boolean.TRUE);
|
|
|
+ if (null != tmpEnrollScoreList) {
|
|
|
+ for (AEnrollScore r : tmpEnrollScoreList) {
|
|
|
+ if(!voluntaryRuleHelper.isMatchMajor(r, needMajor, needMajorDirect, inclMajorDirection, exclMajorDirection)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ Boolean isSkillScore = isScoreOnly && r.getItemType().equals("ScoreSkill");
|
|
|
+ appendScoreRule(formulaScoreStat, existSet, r, fEnrollScoreList, false, paramMap, inputScoreRate, isSkillScore);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (fEnrollScoreList.size() == 0 && null != (tmpEnrollScoreList = majorEnrollScoresMap.get(Boolean.FALSE))) {
|
|
|
+ for (AEnrollScore r : tmpEnrollScoreList) {
|
|
|
+ Boolean isSkillScore = isScoreOnly && r.getItemType().equals("ScoreSkill");
|
|
|
+ appendScoreRule(formulaScoreStat, existSet, r, fEnrollScoreList, false, paramMap, inputScoreRate, isSkillScore);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Double currTotal = formulaScoreStat.getTypeValue("StatRateScore", "", false);
|
|
|
+ existSet.clear();
|
|
|
+ Map<String, AMarjorPlan> historyPlanMap = historyPlanList.stream().collect(Collectors.toMap(t -> t.getYear() + t.getMajorName() + StringUtils.trimToEmpty(t.getMajorDirection()), Function.identity()));
|
|
|
+ AMarjorSubmit lastSubmit1 = null, lastSubmit2 = null;
|
|
|
+ for (AMarjorSubmit s : validSubmitList) {
|
|
|
+ if (s.getYear().equals(submitYear)) {
|
|
|
+ if(s.getEnrollType().equals("初录")) {
|
|
|
+ lastSubmit1 = s;
|
|
|
+ } else {
|
|
|
+ lastSubmit2 = s;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ VoluntaryDto.RenderMajorHistory h = new VoluntaryDto.RenderMajorHistory();
|
|
|
+ h.setYear(s.getYear());
|
|
|
+ AMarjorPlan p = historyPlanMap.get(s.getYear() + s.getMajorName() + StringUtils.trimToEmpty(s.getMajorDirection()));
|
|
|
+ if(null != p) {
|
|
|
+ h.setPlan(p.getPlanTotal());
|
|
|
+ } else {
|
|
|
+ // System.out.println(s.getId());
|
|
|
+ }
|
|
|
+ h.setEnroll(s.getEnrollTotal());
|
|
|
+ if(null != s.getScore()) {
|
|
|
+ h.setScore(String.valueOf(s.getScore()));
|
|
|
+ h.setDiff((int) Math.round(currTotal - s.getScore()));
|
|
|
+ } else {
|
|
|
+ h.setScore("");
|
|
|
+ h.setDiff(null);
|
|
|
+ }
|
|
|
+ h.setRuleContent(s.getEnrollFormula());
|
|
|
+ h.setApplication("");
|
|
|
+ h.setAdmission("");
|
|
|
+ histories.add(h);
|
|
|
+ }
|
|
|
+
|
|
|
+ AMarjorSubmit lastSubmit = null == lastSubmit1 ? lastSubmit2 : lastSubmit1;
|
|
|
+ Double cultureScore = formulaScoreStat.getTypeValue("StatCategoryScore", "ScoreBase", false);
|
|
|
+
|
|
|
+ VoluntaryDto.RenderMajorSkill skill = new VoluntaryDto.RenderMajorSkill();
|
|
|
+ skill.setYear(currPlan.getYear());
|
|
|
+ skill.setCultureScore(toString(cultureScore));
|
|
|
+ String[] formulas = fEnrollScoreList.get(0).getEnrollFormula().split("\\+职业技能");
|
|
|
+ if(formulas.length != 2) {
|
|
|
+ throw new RuntimeException("错误定义考试规则" + fEnrollScoreList.get(0).getEnrollFormula());
|
|
|
+ }
|
|
|
+ skill.setCultureRule(formulas[0]); // 拆分公式
|
|
|
+ skill.setEnrollScore(toString(lastSubmit.getScore()));
|
|
|
+
|
|
|
+ // 计算概念或反算技能分
|
|
|
+ boolean isSameYear = planYear.equals(submitYear);
|
|
|
+ Integer validScoreTotal = isSameYear ? formulaScoreStat.getAllTotal() : lastSubmit.getScoreTotal();
|
|
|
+ Double currScoreRate = isSameYear ? 1.0 : formulaScoreStat.getAllTotal() * 1.0 / lastSubmit.getScoreTotal();
|
|
|
+ Double needSkillScore = lastSubmit.getScore() * currScoreRate - cultureScore;
|
|
|
+ if(isScoreOnly) {
|
|
|
+ skill.setSkillScore(toString(needSkillScore));
|
|
|
+ } else {
|
|
|
+ Double skillScore = formulaScoreStat.getTypeValue("StatCategoryScore", "ScoreSkill", true);
|
|
|
+ skill.setSkillScore(toString(needSkillScore));
|
|
|
+ skill.setDiff(toString(skillScore - needSkillScore));
|
|
|
+ EnrollRateCalculator.RateLevel rl;
|
|
|
+ if (currTotal != null && null != (rl = enrollRateCalculator.calSchoolEnrollRate(validScoreTotal, lastSubmit.getScore(), currTotal / currScoreRate))) { // 按去年标准算概率
|
|
|
+ sr.setEnrollRate(rl.rate);
|
|
|
+ sr.setEnrollRateText(rl.typeLabel);
|
|
|
+ sr.setEnumPickType(rl.type);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ sr.setSkill(skill);
|
|
|
+ return sr;
|
|
|
+ }
|
|
|
+
|
|
|
+ public String toString(Double v) {
|
|
|
+ return String.valueOf(v);
|
|
|
+ }
|
|
|
+
|
|
|
+ public R<List<VoluntaryDto.RenderRule>> getRenderRules(VoluntaryDto.RenderRequest req) {
|
|
|
+ Map cond = new HashMap();
|
|
|
+ Integer planYear = getPlanYear(SecurityUtils.getLoginUser().getUser());
|
|
|
+ cond.put("year", planYear);
|
|
|
+ AMarjorPlan plan = aMarjorPlanMapper.selectAMarjorPlanById(req.getMajorId());
|
|
|
+ cond.put("majorGroup", StringUtils.trimToEmpty(plan.getMajorGroup()));
|
|
|
+ cond.put("majorGroupCodes", plan.getMajorCode());
|
|
|
+ cond.put("universityCode", req.getUniversityId());
|
|
|
+ return R.ok(findMatchRenderRules(cond, req.getRenderType() == 2));
|
|
|
+ }
|
|
|
+
|
|
|
public R<List<VoluntaryDto.AIRenderRule>> getAIRenderRules(VoluntaryDto.AIRenderRequest req) {
|
|
|
Map cond = new HashMap();
|
|
|
Integer planYear = getPlanYear(SecurityUtils.getLoginUser().getUser());
|
|
|
@@ -263,6 +518,70 @@ public class VoluntaryService {
|
|
|
return tableDataInfo;
|
|
|
}
|
|
|
|
|
|
+ private List<VoluntaryDto.RenderRule> findMatchRenderRules(Map cond, boolean isScore) {
|
|
|
+ String examType = VistorContextHolder.getExamType().title(); // TODO MF
|
|
|
+ // String gender = "0".equals(SecurityUtils.getLoginUser().getUser().getSex()) ? "男生" : "女生";
|
|
|
+ cond.put("examineeType", examType);
|
|
|
+
|
|
|
+ List<VoluntaryDto.AIRenderRule> cultureRuleList = Lists.newArrayList();
|
|
|
+ List<VoluntaryDto.AIRenderRule> skillRuleList = Lists.newArrayList();
|
|
|
+
|
|
|
+ List<AEnrollScore> enrollScoreList = aEnrollScoreMapper.selectListByRuleCond(cond);
|
|
|
+ if (CollectionUtils.isEmpty(enrollScoreList) && cond.containsKey("majorGroup")) {
|
|
|
+ cond.put("majorGroup", "");
|
|
|
+ enrollScoreList = aEnrollScoreMapper.selectListByRuleCond(cond);
|
|
|
+ }
|
|
|
+ Set<String> existItemSet = Sets.newHashSet();
|
|
|
+ String vt;
|
|
|
+ SysUser sysUser = SecurityUtils.getLoginUser().getUser();;
|
|
|
+ boolean isOHS = ExamType.OHS.equals(sysUser.getExamType());
|
|
|
+ SubjectScore subjectScore = sysUser.getScores();
|
|
|
+ for (AEnrollScore s : enrollScoreList) { // 跳过统计类和提示类的规则
|
|
|
+ boolean isSkill = "职业技能测试".equals(s.getItemCategory());
|
|
|
+ if (null == (vt = s.getValueType()) || vt.startsWith("Stat") || vt.equals("Notice")) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<VoluntaryDto.AIRenderRule> ruleList = isSkill ? skillRuleList : cultureRuleList ;
|
|
|
+ if (!existItemSet.add(s.getItemField())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ VoluntaryDto.AIRenderRule r = new VoluntaryDto.AIRenderRule();
|
|
|
+ r.setEnumRuleCategory(VoluntaryDto.EnumRuleCategory.Enroll);
|
|
|
+ if (isOHS && "Score".equals(s.getValueType()) && !isSkill) {
|
|
|
+ r.setReadonly(true);
|
|
|
+ Double score = subjectScore.getSelectScore(s.getItemField());
|
|
|
+ if (null == score && SubjectType.Foreign.name().equals(s.getItemField())) {
|
|
|
+ score = subjectScore.getSelectScore(SubjectType.English.name());
|
|
|
+ }
|
|
|
+ r.setDefaultValue(null != score ? String.valueOf(score) : "0");
|
|
|
+ } else {
|
|
|
+ r.setReadonly(false);
|
|
|
+ r.setDefaultValue(s.getDefaultValue());
|
|
|
+ }
|
|
|
+ r.setFieldName(s.getItemField());
|
|
|
+ setOptionValue(r, vt, s.getValueRule(), s.getValueOptional(), s.getCorrectType(), s.getCorrectValue(), s.getScoreTotal());
|
|
|
+ r.setRegex(s.getRegex());
|
|
|
+ r.setLabel(s.getItemName());
|
|
|
+ r.setDescription(s.getDescription());
|
|
|
+ r.setPlaceholder(s.getPlaceholder());
|
|
|
+ r.setTips(s.getTips());
|
|
|
+ r.setDotDisable(null != s.getDotDisable() && s.getDotDisable() > 0);
|
|
|
+ r.setKeyboardMode(s.getKeyboardMode()); // number card car,默认number
|
|
|
+ ruleList.add(r);
|
|
|
+ }
|
|
|
+ if(CollectionUtils.isEmpty(enrollScoreList)) {
|
|
|
+ throw new RuntimeException("未定义考试规则" + StringUtils.join(cond.values(), ","));
|
|
|
+ }
|
|
|
+ String[] formulas = enrollScoreList.get(0).getEnrollFormula().split("\\+职业技能");
|
|
|
+ if(formulas.length != 2) {
|
|
|
+ throw new RuntimeException("错误定义考试规则" + enrollScoreList.get(0).getEnrollFormula());
|
|
|
+ }
|
|
|
+ List<VoluntaryDto.RenderRule> allRenderRuleList = Lists.newArrayList();
|
|
|
+ allRenderRuleList.add(new VoluntaryDto.RenderRule("文化素质", formulas[0], cultureRuleList));
|
|
|
+ allRenderRuleList.add(new VoluntaryDto.RenderRule("职业技能", "职业技能" + formulas[1], isScore ? null : skillRuleList));
|
|
|
+ return allRenderRuleList;
|
|
|
+ }
|
|
|
+
|
|
|
private List<VoluntaryDto.AIRenderRule> findMatchRules(Map cond, boolean isAi, boolean isScore) {
|
|
|
String examType = VistorContextHolder.getExamType().title(); // TODO MF
|
|
|
String gender = "0".equals(SecurityUtils.getLoginUser().getUser().getSex()) ? "男生" : "女生";
|
|
|
@@ -1191,4 +1510,158 @@ public class VoluntaryService {
|
|
|
}
|
|
|
return VoluntaryDto.EnumRuleType.valueOf(itemType);
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ public List<VoluntaryDto.VoluntaryRecord> getVoluntaryList2() { // 我的志愿表 // 后台填充快照缺省
|
|
|
+ AWishRecord cond = new AWishRecord();
|
|
|
+ cond.setUserId(SecurityUtils.getLoginUser().getUserId());
|
|
|
+ cond.setStatus(1);
|
|
|
+ List<AWishRecord> aWishRecordList = aWishRecordMapper.selectAWishRecordList(cond);
|
|
|
+ if(CollectionUtils.isEmpty(aWishRecordList)) {
|
|
|
+ return Collections.emptyList();
|
|
|
+ }
|
|
|
+ return JSONArray.parseArray(aWishRecordList.get(0).getDetails(), VoluntaryDto.VoluntaryRecord.class);
|
|
|
+ }
|
|
|
+
|
|
|
+ public R<Long> addVoluntary2(JSONObject model) { // 填报 // 前端+后台按需要剔除一些不需快照的信息(目前主要是院校信息)
|
|
|
+ SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+
|
|
|
+ AWishRecord wishRecord = getWishRecord(user.getUserId());
|
|
|
+ List<VoluntaryDto.VoluntaryRecord> voluntaryRecordList = (null == wishRecord.getId()) ? Lists.newArrayList()
|
|
|
+ : JSONArray.parseArray(wishRecord.getDetails(), VoluntaryDto.VoluntaryRecord.class);
|
|
|
+
|
|
|
+ Long universityId = model.getLong("universityId");
|
|
|
+ Long majorId = model.getLong("majorId");
|
|
|
+ Optional<VoluntaryDto.VoluntaryRecord> optionalVoluntary = voluntaryRecordList.stream().filter(t -> t.getUniversityId().equals(universityId)).findFirst();
|
|
|
+ VoluntaryDto.VoluntaryRecord voluntaryRecord;
|
|
|
+ if(optionalVoluntary.isPresent()) {
|
|
|
+ voluntaryRecord = optionalVoluntary.get();
|
|
|
+ if(null == voluntaryRecord.getMajors()) {
|
|
|
+ voluntaryRecord.setMajors(Lists.newArrayList());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ BBusiWishUniversities u = bBusiWishUniversitiesMapper.selectBBusiWishUniversitiesById(universityId);
|
|
|
+ voluntaryRecord = new VoluntaryDto.VoluntaryRecord();
|
|
|
+ voluntaryRecord.setUniversityLogo(u.getLogo());
|
|
|
+ voluntaryRecord.setUniversityName(u.getName());
|
|
|
+ voluntaryRecord.setUniversityId(u.getId());
|
|
|
+ voluntaryRecord.setMajors(Lists.newArrayList());
|
|
|
+ voluntaryRecord.setRank(voluntaryRecordList.size() + 1);
|
|
|
+ voluntaryRecordList.add(voluntaryRecord);
|
|
|
+ }
|
|
|
+ Optional<VoluntaryDto.VoluntaryMajorRecord> optionalMajor = voluntaryRecord.getMajors().stream().filter( t -> t.getMajorId().equals(majorId)).findFirst();
|
|
|
+ if(!optionalMajor.isPresent()) {
|
|
|
+ AMarjorPlan p = aMarjorPlanMapper.selectAMarjorPlanById(majorId);
|
|
|
+ VoluntaryDto.VoluntaryMajorRecord major = new VoluntaryDto.VoluntaryMajorRecord();
|
|
|
+ major.setMajorId(p.getId());
|
|
|
+ major.setMajorGroup(p.getMajorGroup());
|
|
|
+ major.setMajorName(p.getMajorName());
|
|
|
+ major.setMajorAncestors("");
|
|
|
+ major.setRank(voluntaryRecord.getMajors().size() + 1);
|
|
|
+ voluntaryRecord.getMajors().add(major);
|
|
|
+ }
|
|
|
+
|
|
|
+ wishRecord.setDetails(JSONArray.toJSONString(voluntaryRecordList));
|
|
|
+
|
|
|
+ wishRecord.setYear(getPlanYear(user));
|
|
|
+ if (null != wishRecord.getId()) {
|
|
|
+ wishRecord.setUpdateTime(new Date());
|
|
|
+ wishRecord.setUpdateTime(new Date());
|
|
|
+ aWishRecordMapper.updateAWishRecord(wishRecord);
|
|
|
+ } else {
|
|
|
+ wishRecord.setCreateTime(new Date());
|
|
|
+ wishRecord.setUserId(user.getUserId());
|
|
|
+ wishRecord.setStatus(1);
|
|
|
+ aWishRecordMapper.insertAWishRecord(wishRecord);
|
|
|
+ }
|
|
|
+ return R.ok(wishRecord.getId());
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean removeVoluntaryByUniversity(Long userId, Long universityId) {
|
|
|
+ AWishRecord wishRecord = getWishRecord(userId);
|
|
|
+ List<VoluntaryDto.VoluntaryRecord> voluntaryRecordList = JSONArray.parseArray(wishRecord.getDetails(), VoluntaryDto.VoluntaryRecord.class);
|
|
|
+
|
|
|
+ List<VoluntaryDto.VoluntaryRecord> newRecordList = Lists.newArrayList();
|
|
|
+ for(VoluntaryDto.VoluntaryRecord r : voluntaryRecordList) {
|
|
|
+ if(r.getUniversityId().equals(universityId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ r.setRank(newRecordList.size());
|
|
|
+ newRecordList.add(r);
|
|
|
+ }
|
|
|
+ updateWishRecord(wishRecord, newRecordList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public Boolean removeVoluntaryByMajor(Long userId, Long majorId) {
|
|
|
+ AMarjorPlan plan = aMarjorPlanMapper.selectAMarjorPlanById(majorId);
|
|
|
+ if(null == plan) {
|
|
|
+ throw new RuntimeException("错误的专业计划ID");
|
|
|
+ }
|
|
|
+ AWishRecord wishRecord = getWishRecord(userId);
|
|
|
+ List<VoluntaryDto.VoluntaryRecord> voluntaryRecordList = JSONArray.parseArray(wishRecord.getDetails(), VoluntaryDto.VoluntaryRecord.class);
|
|
|
+ Optional<VoluntaryDto.VoluntaryRecord> optionalVoluntary = voluntaryRecordList.stream().filter(t -> t.getUniversityId().equals(plan.getUniversityId())).findFirst();
|
|
|
+ if(!optionalVoluntary.isPresent()) {
|
|
|
+ throw new RuntimeException("错误的院校ID");
|
|
|
+ }
|
|
|
+ VoluntaryDto.VoluntaryRecord voluntaryRecord = optionalVoluntary.get();
|
|
|
+ List<VoluntaryDto.VoluntaryMajorRecord> newRecordList = Lists.newArrayList();
|
|
|
+ voluntaryRecord.setMajors(newRecordList);
|
|
|
+ for(VoluntaryDto.VoluntaryMajorRecord r : voluntaryRecord.getMajors()) {
|
|
|
+ if(r.getMajorId().equals(majorId)) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ r.setRank(newRecordList.size());
|
|
|
+ newRecordList.add(r);
|
|
|
+ }
|
|
|
+ updateWishRecord(wishRecord, voluntaryRecordList);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sortVoluntaryByMajor(Long userId, Long universityId, Map<Long, Integer> majorRankMap) {
|
|
|
+ AWishRecord wishRecord = getWishRecord(userId);
|
|
|
+ List<VoluntaryDto.VoluntaryRecord> voluntaryRecordList = JSONArray.parseArray(wishRecord.getDetails(), VoluntaryDto.VoluntaryRecord.class);
|
|
|
+ Optional<VoluntaryDto.VoluntaryRecord> optionalVoluntary = voluntaryRecordList.stream().filter(t -> t.getUniversityId().equals(universityId)).findFirst();
|
|
|
+ VoluntaryDto.VoluntaryRecord voluntaryRecord;
|
|
|
+ if(!optionalVoluntary.isPresent()) {
|
|
|
+ throw new RuntimeException("错误的院校ID");
|
|
|
+ }
|
|
|
+ voluntaryRecord = optionalVoluntary.get();
|
|
|
+ Integer rank;
|
|
|
+ for(VoluntaryDto.VoluntaryMajorRecord record : voluntaryRecord.getMajors()) {
|
|
|
+ if(null == (rank = majorRankMap.remove(record.getUniversityId()))) {
|
|
|
+ throw new RuntimeException("错误的专业计划ID");
|
|
|
+ }
|
|
|
+ record.setRank(rank);
|
|
|
+ }
|
|
|
+ updateWishRecord(wishRecord, voluntaryRecordList);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void sortVoluntaryByUniversity(Long userId, Map<Long, Integer> universityRankMap) {
|
|
|
+ AWishRecord wishRecord = getWishRecord(userId);
|
|
|
+ List<VoluntaryDto.VoluntaryRecord> voluntaryRecordList = JSONArray.parseArray(wishRecord.getDetails(), VoluntaryDto.VoluntaryRecord.class);
|
|
|
+ Integer rank;
|
|
|
+ for(VoluntaryDto.VoluntaryRecord record : voluntaryRecordList) {
|
|
|
+ if(null == (rank = universityRankMap.remove(record.getUniversityId()))) {
|
|
|
+ throw new RuntimeException("错误的院校ID");
|
|
|
+ }
|
|
|
+ record.setRank(rank);
|
|
|
+ }
|
|
|
+ updateWishRecord(wishRecord, voluntaryRecordList);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void updateWishRecord(AWishRecord wishRecord, List<VoluntaryDto.VoluntaryRecord> voluntaryRecordList) {
|
|
|
+ wishRecord.setUpdateTime(new Date());
|
|
|
+ wishRecord.setUpdateTime(new Date());
|
|
|
+ wishRecord.setDetails(JSONArray.toJSONString(voluntaryRecordList));
|
|
|
+ aWishRecordMapper.updateAWishRecord(wishRecord);
|
|
|
+ }
|
|
|
+ private AWishRecord getWishRecord(Long userId) {
|
|
|
+ AWishRecord wrCond = new AWishRecord();
|
|
|
+ wrCond.setId(userId);
|
|
|
+ wrCond.setStatus(1);
|
|
|
+ List<AWishRecord> wishList = aWishRecordMapper.selectAWishRecordList(wrCond);
|
|
|
+ return wishList.isEmpty() ? new AWishRecord() : wishList.get(0);
|
|
|
+ }
|
|
|
}
|