updates
This commit is contained in:
parent
850caa7547
commit
ea7bffc60c
|
|
@ -260,7 +260,172 @@ public class YxSchoolMajorController extends JeecgController<YxSchoolMajor, IYxS
|
||||||
@RequiresPermissions("yx:yx_school_major:importExcel")
|
@RequiresPermissions("yx:yx_school_major:importExcel")
|
||||||
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST)
|
||||||
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
|
||||||
return super.importExcel(request, response, YxSchoolMajor.class);
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
|
||||||
|
Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
|
||||||
|
for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
|
||||||
|
// 获取上传文件对象
|
||||||
|
MultipartFile file = entity.getValue();
|
||||||
|
ImportParams params = new ImportParams();
|
||||||
|
params.setTitleRows(2);
|
||||||
|
params.setHeadRows(1);
|
||||||
|
params.setNeedSave(true);
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
int index = 3;
|
||||||
|
try {
|
||||||
|
//加载省控线
|
||||||
|
List<YxSchoolMajor> list = ExcelImportUtil.importExcel(file.getInputStream(), YxSchoolMajor.class, params);
|
||||||
|
String a="_";
|
||||||
|
String key;
|
||||||
|
List<YxSchoolMajor> yxSchoolMajorList =yxSchoolMajorService.list();
|
||||||
|
Map<String,YxSchoolMajor> schoolMajorMap = new HashMap<>();
|
||||||
|
for (YxSchoolMajor item : yxSchoolMajorList) {
|
||||||
|
key = item.getSchoolCode()+a+item.getBatch()+a+item.getMajorName()+a+item.getCategory();
|
||||||
|
schoolMajorMap.put(key,item);
|
||||||
|
}
|
||||||
|
Map<String, YxMajor> majorMap = yxMajorService.mapsForMajorName();
|
||||||
|
List<YxSchoolMajor> updatesList = new ArrayList<>();
|
||||||
|
YxMajor major = null;
|
||||||
|
String majorName = null;
|
||||||
|
String mn = null;
|
||||||
|
String majorType = null;
|
||||||
|
String mainSubjects = null;
|
||||||
|
String majorTypeChild = null;
|
||||||
|
List<String> batchList = Arrays.asList("提前批", "本科A段", "本科B段", "本科", "高职高专");
|
||||||
|
for (YxSchoolMajor item : list) {
|
||||||
|
index++;
|
||||||
|
if (org.apache.commons.lang.StringUtils.isBlank(item.getSchoolCode()) && org.apache.commons.lang.StringUtils.isBlank(item.getMajorName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
majorType = item.getMajorType();
|
||||||
|
mainSubjects = item.getMainSubjects();
|
||||||
|
majorTypeChild = item.getMajorTypeChild();
|
||||||
|
AssertUtils.notEmpty(item.getSchoolCode(), String.format("行[%s],请输入学校代码", index));
|
||||||
|
AssertUtils.notEmpty(item.getBatch(), String.format("行[%s],请输入批次", index));
|
||||||
|
AssertUtils.notEmpty(item.getEnrollmentCode(), String.format("行[%s],请输入专业代码", index));
|
||||||
|
AssertUtils.notEmpty(item.getMajorName(), String.format("行[%s],请输入专业名称", index));
|
||||||
|
AssertUtils.notEmpty(item.getMajorType(), String.format("行[%s],请输入专业类型", index));
|
||||||
|
AssertUtils.notEmpty(item.getCategory(), String.format("行[%s],请输入科类", index));
|
||||||
|
/*AssertUtils.notEmpty(item.getRulesEnrollProbabilitySx(), String.format("行[%s],请输入录取方式缩写", index));
|
||||||
|
AssertUtils.notEmpty(item.getRulesEnrollProbability(), String.format("行[%s],请输入对外录取方式", index));
|
||||||
|
AssertUtils.notEmpty(item.getProbabilityOperator(), String.format("行[%s],请输入对外录取方式运算符", index));
|
||||||
|
AssertUtils.notEmpty(item.getPrivateRulesEnrollProbability(), String.format("行[%s],请输入内部录取方式", index));
|
||||||
|
AssertUtils.notEmpty(item.getPrivateProbabilityOperator(), String.format("行[%s],请输入内部录取方式运算符", index));*/
|
||||||
|
|
||||||
|
majorName = item.getMajorName().replace("(", "(").replace(")", ")");
|
||||||
|
item.setMajorName(majorName);
|
||||||
|
//从库中找专业代码
|
||||||
|
int i = majorName.indexOf("(");
|
||||||
|
mn = majorName;
|
||||||
|
if (i != -1) {
|
||||||
|
mn = majorName.substring(0, i);
|
||||||
|
}
|
||||||
|
major = majorMap.get(mn);
|
||||||
|
AssertUtils.notNull(major, String.format("行[%s],专业未在系统中找到", index));
|
||||||
|
item.setMajorCode(major.getMajorCode());
|
||||||
|
|
||||||
|
//判断批次是否有效
|
||||||
|
AssertUtils.isTrue(batchList.contains(item.getBatch()), String.format("行[%s],批次 无效", index));
|
||||||
|
//判断专业类型
|
||||||
|
if ("舞蹈类".equals(majorType)) {
|
||||||
|
AssertUtils.notEmpty(mainSubjects, String.format("行[%s],未识别到舞蹈类型-主考科目", index));
|
||||||
|
if (mainSubjects.contains("艺术舞蹈")) {
|
||||||
|
item.setMainSubjects("艺术舞蹈");
|
||||||
|
}else if (mainSubjects.contains("国际标准")) {
|
||||||
|
item.setMainSubjects("国际标准");
|
||||||
|
}else {
|
||||||
|
throw new JeecgBootException(String.format("行[%s],未识别到舞蹈类型-主考科目", index));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else if(majorType.contains("音乐类")){
|
||||||
|
//主考科目
|
||||||
|
if (mainSubjects.contains("器乐")&&mainSubjects.contains("声乐")) {
|
||||||
|
item.setMainSubjects("器乐,声乐");
|
||||||
|
} else if (mainSubjects.contains("器乐")) {
|
||||||
|
item.setMainSubjects("器乐");
|
||||||
|
}else if (mainSubjects.contains("声乐")) {
|
||||||
|
item.setMainSubjects("声乐");
|
||||||
|
}else {
|
||||||
|
throw new JeecgBootException(String.format("行[%s],未识别到音乐类型-主考科目", index));
|
||||||
|
}
|
||||||
|
//专业子类
|
||||||
|
if (mainSubjects.contains("音乐表演")) {
|
||||||
|
item.setMainSubjects("音乐表演");
|
||||||
|
}else if (mainSubjects.contains("音乐教育")) {
|
||||||
|
item.setMainSubjects("音乐教育");
|
||||||
|
}else {
|
||||||
|
throw new JeecgBootException(String.format("行[%s],未识别到音乐类型-专业子级类别", index));
|
||||||
|
}
|
||||||
|
}else if ("表演类".equals(majorType)) {
|
||||||
|
AssertUtils.notEmpty(mainSubjects, String.format("行[%s],未识别到表演类型-主考科目", index));
|
||||||
|
if (mainSubjects.contains("服装表演")) {
|
||||||
|
item.setMainSubjects("服装表演");
|
||||||
|
}else if (mainSubjects.contains("戏剧影视表演")) {
|
||||||
|
item.setMainSubjects("戏剧影视表演");
|
||||||
|
}else if (mainSubjects.contains("戏剧影视导演")) {
|
||||||
|
item.setMainSubjects("戏剧影视导演");
|
||||||
|
}else if (mainSubjects.contains("兼报")) {
|
||||||
|
item.setMainSubjects("兼报");
|
||||||
|
}else {
|
||||||
|
throw new JeecgBootException(String.format("行[%s],未识别到表演类型-主考科目", index));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
index=3;
|
||||||
|
YxSchoolMajor yxSchoolMajor;
|
||||||
|
String probabilityOperator ="";
|
||||||
|
for (YxSchoolMajor item : list) {
|
||||||
|
index++;
|
||||||
|
if (org.apache.commons.lang.StringUtils.isBlank(item.getSchoolCode()) && org.apache.commons.lang.StringUtils.isBlank(item.getMajorName())) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
key = item.getSchoolCode()+a+item.getBatch()+a+item.getMajorName()+a+item.getCategory();
|
||||||
|
|
||||||
|
yxSchoolMajor = schoolMajorMap.get(key);
|
||||||
|
yxSchoolMajor.setRulesEnrollProbabilitySx(item.getRulesEnrollProbabilitySx());
|
||||||
|
yxSchoolMajor.setRulesEnrollProbability(item.getRulesEnrollProbability());
|
||||||
|
yxSchoolMajor.setProbabilityOperator(item.getProbabilityOperator());
|
||||||
|
yxSchoolMajor.setPrivateRulesEnrollProbability(item.getPrivateRulesEnrollProbability());
|
||||||
|
yxSchoolMajor.setPrivateProbabilityOperator(item.getPrivateRulesEnrollProbability());
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(item.getDetail())) {
|
||||||
|
yxSchoolMajor.setDetail(item.getDetail());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setChineseScoreLimitation(item.getChineseScoreLimitation());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setEnglishScoreLimitation(item.getEnglishScoreLimitation());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setCulturalScoreLimitation(item.getCulturalScoreLimitation());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setProfessionalScoreLimitation(item.getProfessionalScoreLimitation());
|
||||||
|
}
|
||||||
|
updatesList.add(yxSchoolMajor);
|
||||||
|
}
|
||||||
|
service.saveOrUpdateBatch(updatesList);
|
||||||
|
log.info("消耗时间" + (System.currentTimeMillis() - start) + "毫秒");
|
||||||
|
return Result.ok("文件导入成功!数据行数:" + list.size());
|
||||||
|
} catch (Exception e) {
|
||||||
|
System.out.println("索引:"+index);
|
||||||
|
String msg = e.getMessage();
|
||||||
|
log.error(msg, e);
|
||||||
|
if (msg != null && msg.indexOf("Duplicate entry") >= 0) {
|
||||||
|
return Result.error("文件导入失败:有重复数据!");
|
||||||
|
} else {
|
||||||
|
return Result.error("文件导入失败:" + e.getMessage() + ",行:" + index);
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
file.getInputStream().close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Result.error("文件导入失败!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -291,10 +456,15 @@ public class YxSchoolMajorController extends JeecgController<YxSchoolMajor, IYxS
|
||||||
List<YxSchoolMajor> updatesList = new ArrayList<>();
|
List<YxSchoolMajor> updatesList = new ArrayList<>();
|
||||||
for (YxSchoolMajor item : yxSchoolMajorList) {
|
for (YxSchoolMajor item : yxSchoolMajorList) {
|
||||||
index++;
|
index++;
|
||||||
|
AssertUtils.notEmpty(item.getSchoolCode(), String.format("行[%s],请输入学校代码", index));
|
||||||
|
AssertUtils.notEmpty(item.getBatch(), String.format("行[%s],请输入批次", index));
|
||||||
|
AssertUtils.notEmpty(item.getMajorName(), String.format("行[%s],请输入专业名称", index));
|
||||||
|
AssertUtils.notEmpty(item.getCategory(), String.format("行[%s],请输入科类", index));
|
||||||
key = item.getSchoolCode()+a+item.getBatch()+a+item.getMajorName()+a+item.getCategory();
|
key = item.getSchoolCode()+a+item.getBatch()+a+item.getMajorName()+a+item.getCategory();
|
||||||
schoolMajorMap.put(key,item);
|
schoolMajorMap.put(key,item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
index=3;
|
||||||
YxSchoolMajor yxSchoolMajor;
|
YxSchoolMajor yxSchoolMajor;
|
||||||
String probabilityOperator ="";
|
String probabilityOperator ="";
|
||||||
for (SchoolMajorLqfsDTO item : list) {
|
for (SchoolMajorLqfsDTO item : list) {
|
||||||
|
|
@ -318,6 +488,21 @@ public class YxSchoolMajorController extends JeecgController<YxSchoolMajor, IYxS
|
||||||
yxSchoolMajor.setRulesEnrollProbabilitySx(item.getRulesEnrollProbabilitySx());
|
yxSchoolMajor.setRulesEnrollProbabilitySx(item.getRulesEnrollProbabilitySx());
|
||||||
yxSchoolMajor.setRulesEnrollProbability(probabilityOperator);
|
yxSchoolMajor.setRulesEnrollProbability(probabilityOperator);
|
||||||
yxSchoolMajor.setProbabilityOperator(probabilityOperator);
|
yxSchoolMajor.setProbabilityOperator(probabilityOperator);
|
||||||
|
if (StringUtils.isNotBlank(item.getDetail())) {
|
||||||
|
yxSchoolMajor.setDetail(item.getDetail());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setChineseScoreLimitation(item.getChineseScoreLimitation());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setEnglishScoreLimitation(item.getEnglishScoreLimitation());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setCulturalScoreLimitation(item.getCulturalScoreLimitation());
|
||||||
|
}
|
||||||
|
if (item.getChineseScoreLimitation()!=null) {
|
||||||
|
yxSchoolMajor.setProfessionalScoreLimitation(item.getProfessionalScoreLimitation());
|
||||||
|
}
|
||||||
updatesList.add(yxSchoolMajor);
|
updatesList.add(yxSchoolMajor);
|
||||||
}
|
}
|
||||||
service.updateBatchById(updatesList);
|
service.updateBatchById(updatesList);
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ import lombok.Data;
|
||||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author ZhouWenTao
|
* @author ZhouWenTao
|
||||||
|
|
@ -62,4 +63,36 @@ public class SchoolMajorLqfsDTO implements Serializable {
|
||||||
@Excel(name = "内部录取方式", width = 15)
|
@Excel(name = "内部录取方式", width = 15)
|
||||||
@ApiModelProperty(value = "内部录取方式")
|
@ApiModelProperty(value = "内部录取方式")
|
||||||
private java.lang.String privateRulesEnrollProbability;
|
private java.lang.String privateRulesEnrollProbability;
|
||||||
|
|
||||||
|
/**备注*/
|
||||||
|
@Excel(name = "备注", width = 15)
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private java.lang.String detail;
|
||||||
|
/**
|
||||||
|
* 文化分限制
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "文化成绩限制")
|
||||||
|
@Excel(name = "文化成绩限制", width = 15)
|
||||||
|
private BigDecimal culturalScoreLimitation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 专业分限制
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "专业成绩限制")
|
||||||
|
@Excel(name = "专业成绩限制", width = 15)
|
||||||
|
private BigDecimal professionalScoreLimitation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 语文分限制
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "语文成绩限制")
|
||||||
|
@Excel(name = "语文成绩限制", width = 15)
|
||||||
|
private BigDecimal chineseScoreLimitation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 外语成绩限制
|
||||||
|
*/
|
||||||
|
@ApiModelProperty(value = "外语成绩限制")
|
||||||
|
@Excel(name = "外语成绩限制", width = 15)
|
||||||
|
private BigDecimal englishScoreLimitation;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue