JensionDzero 1 year ago
parent
commit
46c817826a

+ 2 - 2
pom.xml

@@ -74,7 +74,7 @@
             </properties>
             <activation>
                 <!-- 默认环境 -->
-                <activeByDefault>false</activeByDefault>
+                <activeByDefault>true</activeByDefault>
             </activation>
         </profile>
         <profile>
@@ -85,7 +85,7 @@
             </properties>
             <activation>
                 <!-- 默认环境 -->
-                <activeByDefault>true</activeByDefault>
+                <activeByDefault>false</activeByDefault>
             </activation>
         </profile>
         <profile>

+ 16 - 0
ruoyi-demo/src/main/java/com/ruoyi/demo/service/impl/EquipmentServiceImpl.java

@@ -376,7 +376,23 @@ public class EquipmentServiceImpl implements EquipmentService {
 
     @Override
     public void deleteEquipmentPlan(String[] planItemIds) {
+        //删除设备
         planItemMapper.deleteBatchIds(Arrays.asList(planItemIds));
+
+        //查询已无推广设备广告的计划
+        QueryWrapper<Plan> queryWrapper = new QueryWrapper<>();
+        queryWrapper.select("plan_id");
+        queryWrapper.in("item_id",Arrays.asList(planItemIds));
+        queryWrapper.groupBy("plan_id");
+        queryWrapper.having("count(*) = 0");
+        List<Plan> plans = planMapper.selectList(queryWrapper);
+        if (!plans.isEmpty()){
+            //删除广告计划
+            List<String> collect = plans.stream().map(item -> {
+                return item.getPlanId();
+            }).collect(Collectors.toList());
+            planMapper.deleteBatchIds(collect);
+        }
     }
 
     @Override