change 4 жил өмнө
parent
commit
ae0251bfce

+ 2 - 0
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/mapper/ExamApplyMapper.java

@@ -33,4 +33,6 @@ public interface ExamApplyMapper extends BaseMapper<ExamApply> {
     ExamApplyVo selectByApply(Long applyId);
 
     List<ExamApplyVo> queryExam(ExamApplyQueryBo bo);
+
+    List<Long> countGoodsHold(Long applyId);
 }

+ 6 - 4
zhongzheng-system/src/main/java/com/zhongzheng/modules/exam/service/impl/ExamApplyServiceImpl.java

@@ -98,21 +98,23 @@ public class ExamApplyServiceImpl extends ServiceImpl<ExamApplyMapper, ExamApply
         ExamApply update = BeanUtil.toBean(bo, ExamApply.class);
         if (bo.getStatus() == 1){
             List<Long> contGoodsId = baseMapper.countGoods(bo.getApplyId());
+            if (CollectionUtils.isEmpty(contGoodsId)){
+                throw new RuntimeException("请先设置适用商品");
+            }
             List<ExamApplySiteVo> examApplySite = baseMapper.addressExam(bo.getApplyId(),1L);
             if (CollectionUtils.isEmpty(examApplySite)){
                 throw new RuntimeException("请先设置考试地点和时间");
             }
-            if (CollectionUtils.isNotEmpty(contGoodsId)){
+            List<Long> contGoods = baseMapper.countGoodsHold(bo.getApplyId());
+            if (CollectionUtils.isNotEmpty(contGoods)){
                 String goodsName ="";
-                for (Long goodsId : contGoodsId) {
+                for (Long goodsId : contGoods) {
                     ExamNumberGoodsQueryBo examNumberGoodsQueryBo = new ExamNumberGoodsQueryBo();
                     examNumberGoodsQueryBo.setGoodsId(goodsId);
                     List<ExamNumberGoodsVo> examNumberGoodsVos = this.listGoods(examNumberGoodsQueryBo);
                     goodsName.concat(examNumberGoodsVos.get(0).getGoodsName()+",");
                 }
                 throw new RuntimeException(goodsName+"已被其他进行中的考试计划使用,请修改,再启用");
-            }else {
-                throw new RuntimeException("请先设置适用商品");
             }
         }
         validEntityBeforeSave(update);

+ 18 - 1
zhongzheng-system/src/main/resources/mapper/modules/exam/ExamApplyMapper.xml

@@ -101,9 +101,26 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
                 LEFT JOIN exam_apply_goods eags ON eay.apply_id = eags.apply_id
         WHERE
             eags.goods_id = eag.goods_id
-          AND eags.apply_id != eag.apply_id and eay.status = 1 ) > 0
+          AND eags.apply_id != eag.apply_id) > 0
 	</select>
 
+    <select id="countGoodsHold" parameterType="long" resultType="long">
+        SELECT
+            eag.goods_id
+        FROM
+            exam_apply ea
+                LEFT JOIN exam_apply_goods eag ON ea.apply_id = eag.apply_id where ea.apply_id =#{applyId}
+                                                                               and (
+                SELECT
+                    COUNT( eay.apply_id )
+                FROM
+                    exam_apply eay
+                        LEFT JOIN exam_apply_goods eags ON eay.apply_id = eags.apply_id
+                WHERE
+                    eags.goods_id = eag.goods_id
+                  AND eags.apply_id != eag.apply_id and eay.status = 1) > 0
+    </select>
+
     <select id="examNumberGoodsVos" parameterType="long" resultMap="ExamNumberGoodsVoResult">
         SELECT
             g.goods_id,