Browse Source

巡检计划移动端BUG修复

jichaobo 2 years ago
parent
commit
9878641cbf

+ 2 - 2
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionPlanSonServiceImpl.java

@@ -470,8 +470,8 @@ public class PatrolInspectionPlanSonServiceImpl extends AbstractCrudService<Patr
                     }
                     record.setRecordPictureList(PatrolInspectionRecordPictureList);
                     for (int j = 0; j < dataCountVoList.size(); j++) {
-                        if (recordList.get(i).getSiteId() == dataCountVoList.get(i).getId()) {
-                            record.setContentCount(dataCountVoList.get(i).getListCount());
+                        if (recordList.get(i).getSiteId() == dataCountVoList.get(j).getId()) {
+                            record.setContentCount(dataCountVoList.get(j).getListCount());
                         }
                     }
                     list.add(record);

+ 51 - 28
service-fire/service-fire-biz/src/main/java/com/usky/fire/service/impl/PatrolInspectionRecordServiceImpl.java

@@ -1,5 +1,6 @@
 package com.usky.fire.service.impl;
 
+import cn.hutool.core.collection.CollectionUtil;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
@@ -7,6 +8,7 @@ import com.usky.common.core.bean.CommonPage;
 import com.usky.common.mybatis.core.AbstractCrudService;
 import com.usky.common.security.utils.SecurityUtils;
 import com.usky.fire.domain.*;
+import com.usky.fire.mapper.PatrolInspectionPlanMapper;
 import com.usky.fire.mapper.PatrolInspectionRecordMapper;
 import com.usky.fire.service.*;
 import com.usky.fire.service.util.OnlineMethod;
@@ -51,6 +53,9 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
     @Autowired
     private PatrolInspectionPlanSiteSonService planSiteSonService;
 
+    @Autowired
+    private PatrolInspectionPlanMapper patrolInspectionPlanMapper;
+
     @Override
     public CommonPage<PatrolInspectionRecord> patrolInspectionRecordLsit(String areaName, String siteName, String name,
                                                                          Integer planType, String startDateTime, String endDateTime,
@@ -277,37 +282,55 @@ public class PatrolInspectionRecordServiceImpl extends AbstractCrudService<Patro
         if (loginUser != null && !"".equals(loginUser)) {
             userType = loginUser.getUserType();
         }
-        LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
-        queryWrapper.eq(PatrolInspectionPlanSon::getPlanType, 1)
-                .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
+        LambdaQueryWrapper<PatrolInspectionPlan> queryWrapper1 = Wrappers.lambdaQuery();
+        queryWrapper1.select(PatrolInspectionPlan::getId)
+                .eq(PatrolInspectionPlan::getEnable, 1)
+                .eq(PatrolInspectionPlan::getTenantId, SecurityUtils.getTenantId());
         if ("00".equals(userType)) {
-            queryWrapper.eq(PatrolInspectionPlanSon::getCreator, SecurityUtils.getUsername());
+            queryWrapper1.eq(PatrolInspectionPlan::getCreator, SecurityUtils.getUsername());
         }
-        if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
-            queryWrapper.between(PatrolInspectionPlanSon::getInspectionDate, startDate, endDate);
-        }
-
-        List<PatrolInspectionPlanSon> planCountListOne = patrolInspectionPlanSonService.list(queryWrapper);
+        List<PatrolInspectionPlan> list1 = patrolInspectionPlanMapper.selectList(queryWrapper1);
         List<Integer> planSonidListOne = new ArrayList<>();
-        for (int i = 0; i < planCountListOne.size(); i++) {
-            planSonidListOne.add(planCountListOne.get(i).getId());
-        }
-        LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapperOne = Wrappers.lambdaQuery();
-        queryWrapperOne.eq(PatrolInspectionPlanSon::getPlanType, 2)
-                .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
-        if ("00".equals(userType)) {
-            queryWrapperOne.eq(PatrolInspectionPlanSon::getCreator, SecurityUtils.getUsername());
-        }
-        if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
-            queryWrapperOne.and(wq -> wq
-                    .between(PatrolInspectionPlanSon::getStartDate, startDate, endDate)
-                    .or()
-                    .between(PatrolInspectionPlanSon::getEndDate, startDate, endDate)
-            ).groupBy(PatrolInspectionPlanSon::getId);
-        }
-        List<PatrolInspectionPlanSon> planCountListTwo = patrolInspectionPlanSonService.list(queryWrapperOne);
-        for (int i = 0; i < planCountListTwo.size(); i++) {
-            planSonidListOne.add(planCountListTwo.get(i).getId());
+        if (CollectionUtil.isNotEmpty(list1)) {
+            List<Integer> planIdList = new ArrayList<>();
+            for (int i = 0; i < list1.size(); i++) {
+                planIdList.add(list1.get(i).getId());
+            }
+            LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapper = Wrappers.lambdaQuery();
+            queryWrapper.select(PatrolInspectionPlanSon::getId)
+                    .eq(PatrolInspectionPlanSon::getPlanType, 1)
+                    .in(PatrolInspectionPlanSon::getPlanId, planIdList)
+                    .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
+            if ("00".equals(userType)) {
+                queryWrapper.eq(PatrolInspectionPlanSon::getCreator, SecurityUtils.getUsername());
+            }
+            if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
+                queryWrapper.between(PatrolInspectionPlanSon::getInspectionDate, startDate, endDate);
+            }
+
+            List<PatrolInspectionPlanSon> planCountListOne = patrolInspectionPlanSonService.list(queryWrapper);
+            for (int i = 0; i < planCountListOne.size(); i++) {
+                planSonidListOne.add(planCountListOne.get(i).getId());
+            }
+            LambdaQueryWrapper<PatrolInspectionPlanSon> queryWrapperOne = Wrappers.lambdaQuery();
+            queryWrapperOne.select(PatrolInspectionPlanSon::getId)
+                    .eq(PatrolInspectionPlanSon::getPlanType, 2)
+                    .in(PatrolInspectionPlanSon::getPlanId, planIdList)
+                    .eq(PatrolInspectionPlanSon::getTenantId, SecurityUtils.getTenantId());
+            if ("00".equals(userType)) {
+                queryWrapperOne.eq(PatrolInspectionPlanSon::getCreator, SecurityUtils.getUsername());
+            }
+            if (!"".equals(startDate) && startDate != null && !"".equals(endDate) && endDate != null) {
+                queryWrapperOne.and(wq -> wq
+                        .between(PatrolInspectionPlanSon::getStartDate, startDate, endDate)
+                        .or()
+                        .between(PatrolInspectionPlanSon::getEndDate, startDate, endDate)
+                ).groupBy(PatrolInspectionPlanSon::getId);
+            }
+            List<PatrolInspectionPlanSon> planCountListTwo = patrolInspectionPlanSonService.list(queryWrapperOne);
+            for (int i = 0; i < planCountListTwo.size(); i++) {
+                planSonidListOne.add(planCountListTwo.get(i).getId());
+            }
         }
         return planSonidListOne;
     }