|
@@ -2,7 +2,11 @@ package com.zhongzheng.modules.exam.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
+import com.zhongzheng.common.utils.ServletUtils;
|
|
|
+import com.zhongzheng.modules.exam.bo.ExamNumberGoodsQueryBo;
|
|
|
+import com.zhongzheng.modules.exam.vo.ExamNumberGoodsVo;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
@@ -31,9 +35,11 @@ import java.util.stream.Collectors;
|
|
|
public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply> implements IExamApplyService {
|
|
|
|
|
|
@Override
|
|
|
- public ExamApplyVo queryById(Long examApplyId){
|
|
|
- ExamApply db = this.baseMapper.selectById(examApplyId);
|
|
|
- return BeanUtil.toBean(db, ExamApplyVo.class);
|
|
|
+ public ExamApplyVo queryById(Long applyId){
|
|
|
+ ExamApply db = this.baseMapper.selectById(applyId);
|
|
|
+ ExamApplyVo examApplyVo = BeanUtil.toBean(db, ExamApplyVo.class);
|
|
|
+ List<ExamNumberGoodsVo> examNumberGoodsVos = baseMapper.examNumberGoodsVos(applyId);
|
|
|
+ return examApplyVo;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -73,6 +79,7 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
public Boolean insertByAddBo(ExamApplyAddBo bo) {
|
|
|
ExamApply add = BeanUtil.toBean(bo, ExamApply.class);
|
|
|
validEntityBeforeSave(add);
|
|
|
+ add.setCode(ServletUtils.getEncoded("KSAP"));
|
|
|
add.setCreateTime(DateUtils.getNowTime());
|
|
|
add.setUpdateTime(DateUtils.getNowTime());
|
|
|
return this.save(add);
|
|
@@ -81,6 +88,19 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
@Override
|
|
|
public Boolean updateByEditBo(ExamApplyEditBo bo) {
|
|
|
ExamApply update = BeanUtil.toBean(bo, ExamApply.class);
|
|
|
+ if (bo.getStatus() == 1){
|
|
|
+ List<Long> contGoodsId = baseMapper.countGoods(bo.getApplyId());
|
|
|
+ if (CollectionUtils.isNotEmpty(contGoodsId)){
|
|
|
+ String goodsName ="";
|
|
|
+ for (Long goodsId : contGoodsId) {
|
|
|
+ ExamNumberGoodsQueryBo examNumberGoodsQueryBo = new ExamNumberGoodsQueryBo();
|
|
|
+ examNumberGoodsQueryBo.setGoodsId(goodsId);
|
|
|
+ List<ExamNumberGoodsVo> examNumberGoodsVos = this.listGoods(examNumberGoodsQueryBo);
|
|
|
+ goodsName.concat(examNumberGoodsVos.get(0).getGoodsName()+",");
|
|
|
+ }
|
|
|
+ throw new RuntimeException(goodsName+"已被其他进行中的考试计划使用,请修改,再启用");
|
|
|
+ }
|
|
|
+ }
|
|
|
validEntityBeforeSave(update);
|
|
|
update.setUpdateTime(DateUtils.getNowTime());
|
|
|
return this.updateById(update);
|
|
@@ -102,4 +122,9 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
|
|
|
}
|
|
|
return this.removeByIds(ids);
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public List<ExamNumberGoodsVo> listGoods(ExamNumberGoodsQueryBo bo) {
|
|
|
+ return baseMapper.listGoods(bo);
|
|
|
+ }
|
|
|
}
|