Commit 8f0f9ab0 authored by licc's avatar licc

修改获取专业列表接口

parent 791fbad4
......@@ -16,5 +16,5 @@ public interface ProfessionService {
* 获取专业树结构
* @return 树列表
*/
R<List<Profession>> getTree(Integer type);
R<List<Profession>> getTree(Integer type,Integer userId);
}
package cn.wisenergy.service.app.impl;
import cn.wisenergy.common.utils.R;
import cn.wisenergy.mapper.AdmissionRuleMapper;
import cn.wisenergy.mapper.ProfessionMapper;
import cn.wisenergy.mapper.ScoreInfoMapper;
import cn.wisenergy.model.app.AdmissionRule;
import cn.wisenergy.model.app.Profession;
import cn.wisenergy.model.app.ScoreInfo;
import cn.wisenergy.model.enums.SchemeTypeEnums;
import cn.wisenergy.model.enums.StudentType;
import cn.wisenergy.service.app.ProfessionService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
......@@ -13,10 +19,10 @@ import java.util.ArrayList;
import java.util.List;
/**
* @author 86187
* @ Description: 专业接口实现
* @ Author : 86187
* @ Date : 2021/1/13 10:52
* @author 86187
*/
@Service
@Slf4j
......@@ -25,13 +31,27 @@ public class ProfessionServiceImpl extends ServiceImpl<ProfessionMapper, Profess
@Autowired
private ProfessionMapper professionMapper;
@Autowired
private ScoreInfoMapper scoreInfoMapper;
@Autowired
private AdmissionRuleMapper admissionRuleMapper;
@Override
public R<List<Profession>> getTree(Integer type) {
public R<List<Profession>> getTree(Integer type, Integer userId) {
log.info("volunteer-service[]ProfessionServiceImpl[]getTree[]input.method");
if (null == type || null == userId) {
return R.error("入参为空!");
}
//获取所有专业
//获取方案类型
Integer schemeType = getSchemeType(type, userId);
if (null == schemeType) {
return R.error("考生成绩信息不存在!");
}
List<Profession> rootList = professionMapper.getList(type);
//获取所有专业
List<Profession> rootList = professionMapper.getList(schemeType);
//构造树形接口:递归
List<Profession> streetList = getStreetList(rootList);
......@@ -75,4 +95,78 @@ public class ProfessionServiceImpl extends ServiceImpl<ProfessionMapper, Profess
}
return children;
}
private Integer getSchemeType(Integer type, Integer userId) {
//获取用户成绩
ScoreInfo scoreInfo = scoreInfoMapper.getById(userId);
if (null == scoreInfo) {
return null;
}
//type==1 文化生
if (StudentType.CULTURE_STUDENT.getCode().equals(type)) {
//获取文化课本科一批规则
AdmissionRule firstRule = admissionRuleMapper.getByType(SchemeTypeEnums.UNDERGRADUATE_CULTURE.getCode());
if (null == firstRule) {
return null;
}
if (scoreInfo.getCultureGrade() >= firstRule.getCultureMin()) {
return SchemeTypeEnums.UNDERGRADUATE_CULTURE.getCode();
}
return 0;
}
//type == 2 美术考生
if (StudentType.ART_STUDENT.getCode().equals(type)) {
//获取美术本科一批录取规则
AdmissionRule firstRule = admissionRuleMapper.getByType(SchemeTypeEnums.UNDERGRADUATE_ARTS.getCode());
if (null == firstRule) {
return null;
}
if (scoreInfo.getCultureGrade() >= firstRule.getCultureMin() &&
scoreInfo.getMajorGrade() >= firstRule.getProfessionMin()) {
return SchemeTypeEnums.UNDERGRADUATE_ARTS.getCode();
}
return SchemeTypeEnums.JUNIOR_COLLEGE_ARTS.getCode();
}
//3 体育考生
if (StudentType.SPORTS_STUDENT.getCode().equals(type)) {
//获取体育本科一批录取规则
AdmissionRule firstRule = admissionRuleMapper.getByType(SchemeTypeEnums.UNDERGRADUATE_SPORTS.getCode());
if (null == firstRule) {
return null;
}
//计算综合成绩
double total = scoreInfo.getMajorGrade() * 750 / 100 * 0.7 + scoreInfo.getCultureGrade() * 0.3;
if (total >= firstRule.getCultureMin()) {
return SchemeTypeEnums.UNDERGRADUATE_SPORTS.getCode();
}
return SchemeTypeEnums.JUNIOR_COLLEGE_SPORTS.getCode();
}
//type == 4 体育考生
if (StudentType.LITERATURE_STUDENT.getCode().equals(type)) {
//获取文学编导本科一批录取规则
AdmissionRule firstRule = admissionRuleMapper.getByType(SchemeTypeEnums.UNDERGRADUATE_LITERATURE.getCode());
if (null == firstRule) {
return null;
}
if (scoreInfo.getCultureGrade() >= firstRule.getCultureMin() &&
scoreInfo.getMajorGrade() >= firstRule.getProfessionMin()) {
return SchemeTypeEnums.UNDERGRADUATE_LITERATURE.getCode();
}
return SchemeTypeEnums.JUNIOR_COLLEGE_LITERATURE.getCode();
}
return null;
}
}
......@@ -85,7 +85,7 @@ public class UserLimitServiceImpl extends ServiceImpl<UserLimitMapper, UserLimit
}
if (cardInfo.getStatus().equals(CardStatus.ALREADY_USED.getCode())) {
return R.error(0,"充值卡已使用,请购买新卡!",false);
return R.error(1,"充值卡已使用,请购买新卡!",false);
}
//获取主卡信息
......
......@@ -6,6 +6,7 @@ import cn.wisenergy.model.app.Profession;
import cn.wisenergy.service.app.ProfessionService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -29,12 +30,15 @@ public class ProfessionController {
private ProfessionService professionService;
@ApiOperation(value = "获取专业树结构", notes = "获取专业树结构", httpMethod = "GET")
@ApiImplicitParam(name = "type", value = "考生类型 1:文化考生 2:美术考生 3:体育生 4:文学编导", dataType = "int")
@ApiImplicitParams({
@ApiImplicitParam(name = "type", value = "考生类型 1:文化考生 2:美术考生 3:体育生 4:文学编导", dataType = "int"),
@ApiImplicitParam(name = "userId", value = "考生id", dataType = "int")
})
@GetMapping("/getTree")
public R<List<Profession>> getTree(Integer type) {
if (null == type) {
public R<List<Profession>> getTree(Integer type,Integer userId) {
if (null == type || null == userId) {
return R.error("入参为空!");
}
return professionService.getTree(type);
return professionService.getTree(type,userId);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment