|
@@ -0,0 +1,177 @@
|
|
|
+package cn.hmsoft.art.service.score;
|
|
|
+
|
|
|
+import cn.hmsoft.art.constants.ArtOptrLogType;
|
|
|
+import cn.hmsoft.art.data.dao.ly.LyStdTicketDao;
|
|
|
+import cn.hmsoft.art.data.dao.sc.ScScoreYmViolationDao;
|
|
|
+import cn.hmsoft.art.data.dao.std.StdEnrolDao;
|
|
|
+import cn.hmsoft.art.data.dao.std.StdRegDao;
|
|
|
+import cn.hmsoft.art.data.model.ly.LyStdTicket;
|
|
|
+import cn.hmsoft.art.data.model.sc.ScScoreYmViolation;
|
|
|
+import cn.hmsoft.art.data.model.std.StdEnrol;
|
|
|
+import cn.hmsoft.art.data.model.std.StdReg;
|
|
|
+import cn.hmsoft.art.service.ArtService;
|
|
|
+import cn.hmsoft.frame.data.model.FrameOptr;
|
|
|
+import cn.hmsoft.frame.exception.BusinessException;
|
|
|
+import cn.hmsoft.helper.CollectionHelper;
|
|
|
+import cn.hmsoft.helper.LocalDateHelper;
|
|
|
+import cn.hmsoft.helper.StringHelper;
|
|
|
+import cn.hmsoft.jdbc.entity.Pager;
|
|
|
+import cn.hmsoft.jdbc.entity.QueryOrder;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.time.LocalDate;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class ScScoreYmViolationService extends ArtService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ScScoreYmViolationDao scScoreYmViolationDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StdRegDao stdRegDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private StdEnrolDao stdEnrolDao;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private LyStdTicketDao stdTicketDao;
|
|
|
+
|
|
|
+ public Pager page(String query, Integer start, Integer limit, QueryOrder queryOrder) {
|
|
|
+ return scScoreYmViolationDao.pageViolation(query, start, limit, queryOrder);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void upload(List<List<String>> values, FrameOptr optr) {
|
|
|
+ int row = 2;
|
|
|
+ for (List<String> list : values) {
|
|
|
+ String std_name = list.get(0) == null ? null : list.get(0).trim();
|
|
|
+ String cert_id = list.get(1) == null ? null : list.get(1).trim();
|
|
|
+ String aspect_name = list.get(2) == null ? null : list.get(2).trim();
|
|
|
+ String ticket_no = list.get(3) == null ? null : list.get(3).trim();
|
|
|
+ String violation_no = list.get(4) == null ? null : list.get(4).trim();
|
|
|
+ String exam_date = list.get(5) == null ? null : list.get(5).trim();
|
|
|
+ String exam_subject = list.get(6) == null ? null : list.get(6).trim();
|
|
|
+ String violation_remark = list.get(7) == null ? null : list.get(7).trim();
|
|
|
+ String country_rule = list.get(8) == null ? null : list.get(8).trim();
|
|
|
+ String school_rule = list.get(9) == null ? null : list.get(9).trim();
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(std_name)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生姓名不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(cert_id)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生证件号码不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //考生是否存在
|
|
|
+ StdReg stdReg = stdRegDao.findStdRegByCertAndName(cert_id, std_name);
|
|
|
+ if (stdReg == null) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,找不到该考生");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(aspect_name)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生报考专业不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StdEnrol> stdEnrolList = stdEnrolDao.list("std_id", stdReg.getStd_id());
|
|
|
+ if (CollectionHelper.isEmpty(stdEnrolList)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生未参加考试");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<StdEnrol> filterEnrolList = stdEnrolList.stream()
|
|
|
+ .filter(item -> item.getAspect_name().equals(aspect_name))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionHelper.isEmpty(filterEnrolList)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生未报考该专业");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(ticket_no)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生准考证号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ List<LyStdTicket> stdTicketList = stdTicketDao.list("std_id", stdReg.getStd_id());
|
|
|
+ if (CollectionHelper.isEmpty(stdTicketList)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生准考证号不存在");
|
|
|
+ }
|
|
|
+ List<LyStdTicket> filterTicketList = stdTicketList.stream()
|
|
|
+ .filter(item -> item.getTicket_no().equals(ticket_no))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ if (CollectionHelper.isEmpty(filterTicketList)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生准考证号错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(violation_no)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生违规编号不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(exam_date)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考试日期不能为空");
|
|
|
+ }
|
|
|
+ String[] dates = exam_date.split("-");
|
|
|
+ if (dates.length != 3) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,日期格式错误");
|
|
|
+ }
|
|
|
+ if (dates[1].length() == 1) {
|
|
|
+ dates[1] = "0" + dates[1];
|
|
|
+ exam_date = String.join("-", dates);
|
|
|
+ }
|
|
|
+ if (dates[2].length() == 1) {
|
|
|
+ dates[2] = "0" + dates[2];
|
|
|
+ exam_date = String.join("-", dates);
|
|
|
+ }
|
|
|
+ LocalDate localDate = LocalDateHelper.parseDate(exam_date);
|
|
|
+ if (localDate == null) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,日期格式错误");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(exam_subject)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生考试科目不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(violation_remark)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,考生违规行为不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(country_rule)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,国家处理办法不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringHelper.isEmpty(school_rule)) {
|
|
|
+ throw new BusinessException("第【" + row + "】行,学校处理办法不能为空");
|
|
|
+ }
|
|
|
+
|
|
|
+ //判断是否已经存在
|
|
|
+ ScScoreYmViolation existViolation = scScoreYmViolationDao.findByCertAndAspect(cert_id, aspect_name);
|
|
|
+ if (existViolation != null) {
|
|
|
+ existViolation.setTicket_no(ticket_no);
|
|
|
+ existViolation.setViolation_no(violation_no);
|
|
|
+ existViolation.setExam_date(exam_date);
|
|
|
+ existViolation.setExam_subject(exam_subject);
|
|
|
+ existViolation.setViolation_remark(violation_remark);
|
|
|
+ existViolation.setCountry_rule(country_rule);
|
|
|
+ existViolation.setSchool_rule(school_rule);
|
|
|
+ scScoreYmViolationDao.update(existViolation);
|
|
|
+ } else {
|
|
|
+ ScScoreYmViolation violation = new ScScoreYmViolation();
|
|
|
+ violation.setStd_name(std_name);
|
|
|
+ violation.setCert_id(cert_id);
|
|
|
+ violation.setAspect_name(aspect_name);
|
|
|
+ violation.setTicket_no(ticket_no);
|
|
|
+ violation.setViolation_no(violation_no);
|
|
|
+ violation.setExam_date(exam_date);
|
|
|
+ violation.setExam_subject(exam_subject);
|
|
|
+ violation.setViolation_remark(violation_remark);
|
|
|
+ violation.setCountry_rule(country_rule);
|
|
|
+ violation.setSchool_rule(school_rule);
|
|
|
+ scScoreYmViolationDao.insert(violation);
|
|
|
+ }
|
|
|
+ row++;
|
|
|
+ }
|
|
|
+
|
|
|
+ this.log(optr, ArtOptrLogType.VIOLATION_IMPORT.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+}
|