ソースを参照

专家抽取逻辑优化

suntianwu 2 年 前
コミット
4b788a66e5

+ 23 - 10
purchase-system/src/main/java/com/ozs/pm/service/impl/PmDemandServiceImpl.java

@@ -1138,32 +1138,42 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                     continue;
                 }
             }
-
         }
 
         //从子列表中随机抽取符合数据量的
 
         List<BaseExpert> alltExpertList = new ArrayList<>();
-
+        if(technicalExpertNumber > 0 && technicalExpertList.size() < technicalExpertNumber){
+            throw new Exception("抽取到符合条件的技术专家数量不够");
+        }
         if (!ObjectUtils.isEmpty(technicalExpertList)) {
             alltExpertList.addAll(RandomUtil.getRandomList(technicalExpertList, technicalExpertNumber));
         }
+
+        if(economicExpertNumber > 0 && economicExpertList.size() < economicExpertNumber){
+            throw new Exception("抽取到符合条件的经济专家数量不够");
+        }
         if (!ObjectUtils.isEmpty(economicExpertList)) {
             alltExpertList.addAll(RandomUtil.getRandomList(economicExpertList, economicExpertNumber));
         }
+
+        if(legalAffairsExpertNumber > 0 && legalAffairsExpertList.size() < legalAffairsExpertNumber){
+            throw new Exception("抽取到符合条件的法务专家数量不够");
+        }
         if (!ObjectUtils.isEmpty(legalAffairsExpertList)) {
             alltExpertList.addAll(RandomUtil.getRandomList(legalAffairsExpertList, legalAffairsExpertNumber));
         }
 
-        List<Integer> allExpertIdList = new ArrayList<>();
-        if (!ObjectUtils.isEmpty(alltExpertList)) {
-            for (BaseExpert baseExpert : alltExpertList) {
-                allExpertIdList.add(baseExpert.getId());
-            }
-        }
-
+        List<BaseExpert> spareExpertListNew = new ArrayList<>();
         if (!ObjectUtils.isEmpty(spareExpertList)) {
-            List<BaseExpert> spareExpertListNew = new ArrayList<>();
+            //获取全部IDlist
+            List<Integer> allExpertIdList = new ArrayList<>();
+            if (!ObjectUtils.isEmpty(alltExpertList)) {
+                for (BaseExpert baseExpert : alltExpertList) {
+                    allExpertIdList.add(baseExpert.getId());
+                }
+            }
+            //遍历全部IDlist
             if (!ObjectUtils.isEmpty(allExpertIdList)) { //去重
                 for (BaseExpert baseExpert : spareExpertList) {
                     if (!allExpertIdList.contains(baseExpert.getId())) {
@@ -1177,6 +1187,9 @@ public class PmDemandServiceImpl extends ServiceImpl<PmDemandMapper, PmDemand> i
                 alltExpertList.addAll(RandomUtil.getRandomList(spareExpertListNew, spareExpertNumber));
             }
         }
+        if(spareExpertNumber > 0 && spareExpertListNew.size() < spareExpertNumber){
+            throw new Exception("抽取到符合条件的备用专家数量不够");
+        }
 
         if (ObjectUtils.isEmpty(alltExpertList)) {
             throw new Exception("没抽取到符合条件的专家");