|
@@ -15,6 +15,7 @@ import cn.com.qmth.scancentral.service.StudentPaperService;
|
|
import cn.com.qmth.scancentral.service.SubjectService;
|
|
import cn.com.qmth.scancentral.service.SubjectService;
|
|
import cn.com.qmth.scancentral.util.BatchSetDataUtil;
|
|
import cn.com.qmth.scancentral.util.BatchSetDataUtil;
|
|
import cn.com.qmth.scancentral.vo.OmrConditionVo;
|
|
import cn.com.qmth.scancentral.vo.OmrConditionVo;
|
|
|
|
+import cn.com.qmth.scancentral.vo.OmrGroupUpdateVo;
|
|
import cn.com.qmth.scancentral.vo.OmrGroupVo;
|
|
import cn.com.qmth.scancentral.vo.OmrGroupVo;
|
|
import cn.com.qmth.scancentral.vo.omr.OmrGroupQuery;
|
|
import cn.com.qmth.scancentral.vo.omr.OmrGroupQuery;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -206,17 +207,22 @@ public class OmrGroupServiceImpl extends ServiceImpl<OmrGroupDao, OmrGroupEntity
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public OmrGroupEntity save(Long id, Long examId, List<OmrCondition> conditions, Long userId) {
|
|
|
|
- if (examId == null) {
|
|
|
|
|
|
+ public void save(OmrGroupUpdateVo vo) {
|
|
|
|
+ if (vo.getExamId() == null) {
|
|
throw new ParameterException("examId不能为空");
|
|
throw new ParameterException("examId不能为空");
|
|
}
|
|
}
|
|
- if (conditions == null || conditions.isEmpty()) {
|
|
|
|
|
|
+ if (StringUtils.isBlank(vo.getSubjectCode())) {
|
|
|
|
+ throw new ParameterException("subjectCode不能为空");
|
|
|
|
+ }
|
|
|
|
+ List<OmrCondition> conditions = vo.getConditionList();
|
|
|
|
+ if (CollectionUtils.isEmpty(conditions)) {
|
|
throw new ParameterException("识别对照条件不能为空");
|
|
throw new ParameterException("识别对照条件不能为空");
|
|
}
|
|
}
|
|
|
|
+
|
|
for (OmrCondition omrCondition : conditions) {
|
|
for (OmrCondition omrCondition : conditions) {
|
|
- if (ConditionType.FILL_SUSPECT.equals(omrCondition.getCode())) {
|
|
|
|
- throw new ParameterException("识别对照条件不能重复");
|
|
|
|
- }
|
|
|
|
|
|
+ // if (ConditionType.FILL_SUSPECT.equals(omrCondition.getCode())) {
|
|
|
|
+ // throw new ParameterException("识别对照条件不能重复");
|
|
|
|
+ // }
|
|
if (ConditionType.QUESTION_SINGLE_BLANK.equals(omrCondition.getCode())
|
|
if (ConditionType.QUESTION_SINGLE_BLANK.equals(omrCondition.getCode())
|
|
|| ConditionType.QUESTION_MULTI_BLANK.equals(omrCondition.getCode())
|
|
|| ConditionType.QUESTION_MULTI_BLANK.equals(omrCondition.getCode())
|
|
|| ConditionType.SELECTIVE_EXCEED.equals(omrCondition.getCode())
|
|
|| ConditionType.SELECTIVE_EXCEED.equals(omrCondition.getCode())
|
|
@@ -229,37 +235,42 @@ public class OmrGroupServiceImpl extends ServiceImpl<OmrGroupDao, OmrGroupEntity
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- checkOmrCondition(id, examId, conditions);
|
|
|
|
- if (id != null) {
|
|
|
|
- OmrGroupEntity group = this.getById(id);
|
|
|
|
|
|
+
|
|
|
|
+ this.checkOmrCondition(vo.getId(), vo.getExamId(), vo.getSubjectCode(), conditions);
|
|
|
|
+
|
|
|
|
+ if (vo.getId() != null) {
|
|
|
|
+ OmrGroupEntity group = this.getById(vo.getId());
|
|
if (group.getFixed()) {
|
|
if (group.getFixed()) {
|
|
throw new ParameterException("默认分组不能修改");
|
|
throw new ParameterException("默认分组不能修改");
|
|
}
|
|
}
|
|
if (group.getTotalCount() != null && group.getTotalCount() > 0) {
|
|
if (group.getTotalCount() != null && group.getTotalCount() > 0) {
|
|
throw new ParameterException("已生成任务的分组不能修改");
|
|
throw new ParameterException("已生成任务的分组不能修改");
|
|
}
|
|
}
|
|
- if (concurrentService.getLock(LockType.OMR_GROUP + "-" + id).tryLock()) {
|
|
|
|
|
|
+
|
|
|
|
+ if (concurrentService.getLock(LockType.OMR_GROUP + "-" + vo.getId()).tryLock()) {
|
|
group.setConditions(conditions);
|
|
group.setConditions(conditions);
|
|
- group.setUpdaterId(userId);
|
|
|
|
|
|
+ group.setUpdaterId(vo.getUserId());
|
|
group.setUpdateTime(System.currentTimeMillis());
|
|
group.setUpdateTime(System.currentTimeMillis());
|
|
this.saveOrUpdate(group);
|
|
this.saveOrUpdate(group);
|
|
- concurrentService.getLock(LockType.OMR_GROUP + "-" + id).unlock();
|
|
|
|
- return group;
|
|
|
|
|
|
+
|
|
|
|
+ log.info("修改识别对照任务分组!examId:{} subjectCode:{} id:{}", group.getExamId(), group.getSubjectCode(), group.getId());
|
|
|
|
+ concurrentService.getLock(LockType.OMR_GROUP + "-" + vo.getId()).unlock();
|
|
} else {
|
|
} else {
|
|
throw new ReentrantException("该分组数据操作繁忙,请稍后重试");
|
|
throw new ReentrantException("该分组数据操作繁忙,请稍后重试");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
OmrGroupEntity group = new OmrGroupEntity();
|
|
OmrGroupEntity group = new OmrGroupEntity();
|
|
- group.setExamId(examId);
|
|
|
|
|
|
+ group.setExamId(vo.getExamId());
|
|
|
|
+ group.setSubjectCode(vo.getSubjectCode());
|
|
group.setConditions(conditions);
|
|
group.setConditions(conditions);
|
|
- group.setCreateTime(System.currentTimeMillis());
|
|
|
|
group.setFixed(false);
|
|
group.setFixed(false);
|
|
group.setStage(Stage.FIRST);
|
|
group.setStage(Stage.FIRST);
|
|
group.setTotalCount(0);
|
|
group.setTotalCount(0);
|
|
- group.setCreatorId(userId);
|
|
|
|
|
|
+ group.setCreatorId(vo.getUserId());
|
|
group.setCreateTime(System.currentTimeMillis());
|
|
group.setCreateTime(System.currentTimeMillis());
|
|
|
|
+ group.setUpdateTime(System.currentTimeMillis());
|
|
this.save(group);
|
|
this.save(group);
|
|
- return group;
|
|
|
|
|
|
+ log.info("新增识别对照任务分组!examId:{} subjectCode:{} id:{}", group.getExamId(), group.getSubjectCode(), group.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -272,15 +283,17 @@ public class OmrGroupServiceImpl extends ServiceImpl<OmrGroupDao, OmrGroupEntity
|
|
return baseMapper.selectList(wrapper);
|
|
return baseMapper.selectList(wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
- private void checkOmrCondition(Long id, Long examId, List<OmrCondition> conditions) {
|
|
|
|
- List<OmrGroupEntity> list = findByExamId(examId);
|
|
|
|
|
|
+ private void checkOmrCondition(Long id, Long examId, String subjectCode, List<OmrCondition> conditions) {
|
|
|
|
+ List<OmrGroupEntity> list = findByExamId(examId, subjectCode);
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
if (CollectionUtils.isEmpty(list)) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
Set<String> codes = new HashSet<>();
|
|
Set<String> codes = new HashSet<>();
|
|
for (OmrCondition oc : conditions) {
|
|
for (OmrCondition oc : conditions) {
|
|
codes.add(oc.getCode().name());
|
|
codes.add(oc.getCode().name());
|
|
}
|
|
}
|
|
|
|
+
|
|
for (OmrGroupEntity g : list) {
|
|
for (OmrGroupEntity g : list) {
|
|
for (OmrCondition oc : g.getConditions()) {
|
|
for (OmrCondition oc : g.getConditions()) {
|
|
if (codes.contains(oc.getCode().name()) && (id == null || g.getId().longValue() != id.longValue())) {
|
|
if (codes.contains(oc.getCode().name()) && (id == null || g.getId().longValue() != id.longValue())) {
|
|
@@ -290,10 +303,10 @@ public class OmrGroupServiceImpl extends ServiceImpl<OmrGroupDao, OmrGroupEntity
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- private List<OmrGroupEntity> findByExamId(Long examId) {
|
|
|
|
- QueryWrapper<OmrGroupEntity> wrapper = new QueryWrapper<>();
|
|
|
|
- LambdaQueryWrapper<OmrGroupEntity> lw = wrapper.lambda();
|
|
|
|
- lw.eq(OmrGroupEntity::getExamId, examId);
|
|
|
|
|
|
+ private List<OmrGroupEntity> findByExamId(Long examId, String subjectCode) {
|
|
|
|
+ LambdaQueryWrapper<OmrGroupEntity> wrapper = new LambdaQueryWrapper<>();
|
|
|
|
+ wrapper.eq(OmrGroupEntity::getExamId, examId);
|
|
|
|
+ wrapper.eq(OmrGroupEntity::getSubjectCode, subjectCode);
|
|
return baseMapper.selectList(wrapper);
|
|
return baseMapper.selectList(wrapper);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -326,8 +339,8 @@ public class OmrGroupServiceImpl extends ServiceImpl<OmrGroupDao, OmrGroupEntity
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
- public void updateTotalCountByExamId(Long examId) {
|
|
|
|
- List<OmrGroupEntity> list = this.findByExamId(examId);
|
|
|
|
|
|
+ public void updateTotalCountByExamId(Long examId, String subjectCode) {
|
|
|
|
+ List<OmrGroupEntity> list = this.findByExamId(examId, subjectCode);
|
|
for (OmrGroupEntity omrGroupEntity : list) {
|
|
for (OmrGroupEntity omrGroupEntity : list) {
|
|
this.updateTotalCount(omrGroupEntity.getId());
|
|
this.updateTotalCount(omrGroupEntity.getId());
|
|
}
|
|
}
|