|
@@ -6,7 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.qmth.distributed.print.business.bean.dto.CardRuleDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.BasicCardRuleDto;
|
|
|
import com.qmth.distributed.print.business.entity.BasicCardRule;
|
|
|
import com.qmth.distributed.print.business.entity.BasicExamRule;
|
|
|
import com.qmth.distributed.print.business.entity.ExamCard;
|
|
@@ -59,11 +59,11 @@ public class BasicCardRuleServiceImpl extends ServiceImpl<BasicCardRuleMapper, B
|
|
|
BasicExamRuleService basicExamRuleService;
|
|
|
|
|
|
@Override
|
|
|
- public IPage<CardRuleDto> list(Boolean enable, String name, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize) {
|
|
|
+ public IPage<BasicCardRuleDto> list(Boolean enable, String name, Long createStartTime, Long createEndTime, Integer pageNumber, Integer pageSize) {
|
|
|
SysUser requestUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
DataPermissionRule dpr = basicRoleDataPermissionService.findDataPermission(schoolId, requestUser.getId(), ServletUtil.getRequest().getServletPath());
|
|
|
- IPage<CardRuleDto> cardRuleDtoIPage = this.baseMapper.listPage(new Page<>(pageNumber, pageSize), schoolId, enable, SystemConstant.translateSpecificSign(name), createStartTime, createEndTime, dpr);
|
|
|
+ IPage<BasicCardRuleDto> cardRuleDtoIPage = this.baseMapper.listPage(new Page<>(pageNumber, pageSize), schoolId, enable, SystemConstant.translateSpecificSign(name), createStartTime, createEndTime, dpr);
|
|
|
|
|
|
BasicExamRule basicExamRule = basicExamRuleService.getBySchoolId();
|
|
|
List<JSONObject> examRuleRequiredFieldList = JSONObject.parseArray(basicExamRule.getRequiredFields(), JSONObject.class);
|
|
@@ -93,7 +93,7 @@ public class BasicCardRuleServiceImpl extends ServiceImpl<BasicCardRuleMapper, B
|
|
|
allExamRuleFieldList.removeAll(removeJsonObject);
|
|
|
}
|
|
|
|
|
|
- for (CardRuleDto record : cardRuleDtoIPage.getRecords()) {
|
|
|
+ for (BasicCardRuleDto record : cardRuleDtoIPage.getRecords()) {
|
|
|
List<JSONObject> cardRuleExtendFieldList = JSONObject.parseArray(record.getExtendFields(), JSONObject.class);
|
|
|
for (JSONObject jsonObject : allExamRuleFieldList) {
|
|
|
Optional<JSONObject> objectOptional = cardRuleExtendFieldList.stream().filter(m -> m.getString("code").equals(jsonObject.getString("code"))).findFirst();
|
|
@@ -117,78 +117,69 @@ public class BasicCardRuleServiceImpl extends ServiceImpl<BasicCardRuleMapper, B
|
|
|
|
|
|
@Override
|
|
|
public boolean delete(BasicCardRule cardRule) {
|
|
|
+ // 考试绑定的题卡规则数据
|
|
|
QueryWrapper<BasicPrintConfig> basicPrintConfigQueryWrapper = new QueryWrapper<>();
|
|
|
basicPrintConfigQueryWrapper.lambda().eq(BasicPrintConfig::getCardRuleId, cardRule.getId());
|
|
|
int basicPrintConfigCount = basicPrintConfigService.count(basicPrintConfigQueryWrapper);
|
|
|
+ if (basicPrintConfigCount > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡规则已绑定考试,不能删除");
|
|
|
+ }
|
|
|
|
|
|
+ // 题卡绑定的题卡规则数据
|
|
|
QueryWrapper<ExamCard> examCardQueryWrapper = new QueryWrapper<>();
|
|
|
examCardQueryWrapper.lambda().eq(ExamCard::getCardRuleId, cardRule.getId());
|
|
|
int examCardCount = examCardService.count(examCardQueryWrapper);
|
|
|
+ if (examCardCount > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡规则已绑定题卡,不能删除");
|
|
|
+ }
|
|
|
|
|
|
+ // 命题任务绑定的题卡规则数据
|
|
|
QueryWrapper<ExamTask> examTaskQueryWrapper = new QueryWrapper<>();
|
|
|
examTaskQueryWrapper.lambda().eq(ExamTask::getCardRuleId, cardRule.getId());
|
|
|
int examTaskCount = examTaskService.count(examTaskQueryWrapper);
|
|
|
-
|
|
|
- if (basicPrintConfigCount == 0 && examCardCount == 0 && examTaskCount == 0) {
|
|
|
- this.removeById(cardRule.getId());
|
|
|
- } else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡规则已绑定数据,不能删除");
|
|
|
+ if (examTaskCount > 0) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡规则已绑定命题任务,不能删除");
|
|
|
}
|
|
|
- return true;
|
|
|
+
|
|
|
+ return this.removeById(cardRule.getId());
|
|
|
}
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public boolean saveCardRule(BasicCardRule cardRule) {
|
|
|
Long schoolId = Long.valueOf(ServletUtil.getRequestHeaderSchoolId().toString());
|
|
|
- cardRule.setSchoolId(schoolId);
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
|
|
|
- if (cardRule.getTitleRule().length() > 200) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡标题规则长度不能超过200字符");
|
|
|
- }
|
|
|
-
|
|
|
QueryWrapper<BasicCardRule> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda().eq(BasicCardRule::getSchoolId, cardRule.getSchoolId()).eq(BasicCardRule::getName, cardRule.getName());
|
|
|
+ queryWrapper.lambda().eq(BasicCardRule::getSchoolId, schoolId)
|
|
|
+ .eq(BasicCardRule::getName, cardRule.getName());
|
|
|
BasicCardRule basicCardRule = this.getOne(queryWrapper);
|
|
|
boolean isSuccess;
|
|
|
// 新增
|
|
|
if (Objects.isNull(cardRule.getId())) {
|
|
|
if (basicCardRule != null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡规则名称已存在");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡规则名称已使用");
|
|
|
}
|
|
|
cardRule.setId(SystemConstant.getDbUuid());
|
|
|
+ cardRule.setSchoolId(schoolId);
|
|
|
cardRule.setOrgId(sysUser.getOrgId());
|
|
|
cardRule.setCreateId(sysUser.getId());
|
|
|
cardRule.setCreateTime(System.currentTimeMillis());
|
|
|
- isSuccess = this.save(cardRule);
|
|
|
}
|
|
|
// 修改
|
|
|
else {
|
|
|
if (basicCardRule != null && basicCardRule.getId().longValue() != cardRule.getId().longValue()) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡规则名称已存在");
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("题卡规则名称已使用");
|
|
|
}
|
|
|
-
|
|
|
cardRule.setOrgId(sysUser.getOrgId());
|
|
|
cardRule.setUpdateId(sysUser.getId());
|
|
|
cardRule.setUpdateTime(System.currentTimeMillis());
|
|
|
-
|
|
|
- //删除权限
|
|
|
-// basicTemplateOrgService.removeByRuleId(cardRule.getId());
|
|
|
- isSuccess = this.updateById(cardRule);
|
|
|
}
|
|
|
-
|
|
|
-// 新增权限
|
|
|
-// basicTemplateOrgService.saveBatch(schoolId, TemplateTypeEnum.CARD_RULE, cardRule.getId(), cardRule.getOrgIds(), cardRule.getCreateId());
|
|
|
- return isSuccess;
|
|
|
+ return this.saveOrUpdate(cardRule);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public boolean enable(Long id, Boolean enable) {
|
|
|
- BasicCardRule basicCardRule = this.getById(id);
|
|
|
- if (basicCardRule == null) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("题卡规则不存在");
|
|
|
- }
|
|
|
UpdateWrapper<BasicCardRule> updateWrapper = new UpdateWrapper<>();
|
|
|
updateWrapper.lambda().set(BasicCardRule::getEnable, enable)
|
|
|
.eq(BasicCardRule::getId, id);
|