|  | @@ -1,6 +1,8 @@
 | 
											
												
													
														|  |  package com.usky.iot.service.impl;
 |  |  package com.usky.iot.service.impl;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  | 
 |  | +import cn.hutool.core.collection.CollectionUtil;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 |  |  import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 | 
											
												
													
														|  | 
 |  | +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 |  |  import com.baomidou.mybatisplus.core.metadata.IPage;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 |  |  import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 | 
											
												
													
														|  |  import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 |  |  import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 | 
											
										
											
												
													
														|  | @@ -18,6 +20,7 @@ import com.usky.iot.service.BaseFacilityDeviceService;
 | 
											
												
													
														|  |  import com.usky.iot.service.BaseGgpFacilityService;
 |  |  import com.usky.iot.service.BaseGgpFacilityService;
 | 
											
												
													
														|  |  import com.usky.iot.service.vo.*;
 |  |  import com.usky.iot.service.vo.*;
 | 
											
												
													
														|  |  import com.usky.system.model.LoginUser;
 |  |  import com.usky.system.model.LoginUser;
 | 
											
												
													
														|  | 
 |  | +import org.apache.commons.lang3.ObjectUtils;
 | 
											
												
													
														|  |  import org.springframework.beans.factory.annotation.Autowired;
 |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
											
												
													
														|  |  import org.springframework.stereotype.Service;
 |  |  import org.springframework.stereotype.Service;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
										
											
												
													
														|  | @@ -46,6 +49,8 @@ public class BaseGgpFacilityServiceImpl extends AbstractCrudService<BaseGgpFacil
 | 
											
												
													
														|  |      private BaseBuildService baseBuildService;
 |  |      private BaseBuildService baseBuildService;
 | 
											
												
													
														|  |      @Autowired
 |  |      @Autowired
 | 
											
												
													
														|  |      private BaseFacilityTypeMapper baseFacilityTypeMapper;
 |  |      private BaseFacilityTypeMapper baseFacilityTypeMapper;
 | 
											
												
													
														|  | 
 |  | +    @Autowired
 | 
											
												
													
														|  | 
 |  | +    private DmpProductInfoService dmpProductInfoService;
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  |      public boolean add(BaseGgpFacility baseGgpFacility) {
 |  |      public boolean add(BaseGgpFacility baseGgpFacility) {
 | 
											
										
											
												
													
														|  | @@ -197,7 +202,8 @@ public class BaseGgpFacilityServiceImpl extends AbstractCrudService<BaseGgpFacil
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  |  
 |  |  
 | 
											
												
													
														|  |      @Override
 |  |      @Override
 | 
											
												
													
														|  | -    public CommonPage<Object> deviceBindInfo(String deviceId,Integer id,Integer current,Integer size) {
 |  | 
 | 
											
												
													
														|  | 
 |  | +    public CommonPage<Object> deviceBindInfo(Integer deviceType,String deviceId,Integer id,Integer current,
 | 
											
												
													
														|  | 
 |  | +                                             Integer size) {
 | 
											
												
													
														|  |          List<Object> list = new ArrayList<>();
 |  |          List<Object> list = new ArrayList<>();
 | 
											
												
													
														|  |          IPage<DmpDeviceInfo> page = new Page<>(current, size);
 |  |          IPage<DmpDeviceInfo> page = new Page<>(current, size);
 | 
											
												
													
														|  |          LambdaQueryWrapper<BaseFacilityDevice> lambdaQuery = Wrappers.lambdaQuery();
 |  |          LambdaQueryWrapper<BaseFacilityDevice> lambdaQuery = Wrappers.lambdaQuery();
 | 
											
										
											
												
													
														|  | @@ -205,8 +211,10 @@ public class BaseGgpFacilityServiceImpl extends AbstractCrudService<BaseGgpFacil
 | 
											
												
													
														|  |          List<BaseFacilityDevice> baseFacilityDeviceList = baseFacilityDeviceService.list(lambdaQuery);
 |  |          List<BaseFacilityDevice> baseFacilityDeviceList = baseFacilityDeviceService.list(lambdaQuery);
 | 
											
												
													
														|  |          LambdaQueryWrapper<DmpDeviceInfo> queryWrapper1 = Wrappers.lambdaQuery();
 |  |          LambdaQueryWrapper<DmpDeviceInfo> queryWrapper1 = Wrappers.lambdaQuery();
 | 
											
												
													
														|  |          queryWrapper1.select(DmpDeviceInfo::getId, DmpDeviceInfo::getDeviceId,
 |  |          queryWrapper1.select(DmpDeviceInfo::getId, DmpDeviceInfo::getDeviceId,
 | 
											
												
													
														|  | -                DmpDeviceInfo::getDeviceName, DmpDeviceInfo::getInstallAddress)
 |  | 
 | 
											
												
													
														|  | 
 |  | +                DmpDeviceInfo::getDeviceName, DmpDeviceInfo::getInstallAddress,DmpDeviceInfo::getDeviceType)
 | 
											
												
													
														|  |                  .eq(StringUtils.isNotBlank(deviceId),DmpDeviceInfo::getDeviceId, deviceId)
 |  |                  .eq(StringUtils.isNotBlank(deviceId),DmpDeviceInfo::getDeviceId, deviceId)
 | 
											
												
													
														|  | 
 |  | +                .eq(ObjectUtils.isNotEmpty(deviceType),DmpDeviceInfo::getDeviceType,deviceType)
 | 
											
												
													
														|  | 
 |  | +                .eq(DmpDeviceInfo::getTenantId,SecurityUtils.getTenantId())
 | 
											
												
													
														|  |                  .eq(DmpDeviceInfo::getDeleteFlag,0);
 |  |                  .eq(DmpDeviceInfo::getDeleteFlag,0);
 | 
											
												
													
														|  |          page = dmpDeviceInfoService.page(page,queryWrapper1);
 |  |          page = dmpDeviceInfoService.page(page,queryWrapper1);
 | 
											
												
													
														|  |          if (CollectionUtils.isNotEmpty(page.getRecords())) {
 |  |          if (CollectionUtils.isNotEmpty(page.getRecords())) {
 | 
											
										
											
												
													
														|  | @@ -215,6 +223,7 @@ public class BaseGgpFacilityServiceImpl extends AbstractCrudService<BaseGgpFacil
 | 
											
												
													
														|  |                  map.put("id", page.getRecords().get(i).getId());
 |  |                  map.put("id", page.getRecords().get(i).getId());
 | 
											
												
													
														|  |                  map.put("deviceId", page.getRecords().get(i).getDeviceId());
 |  |                  map.put("deviceId", page.getRecords().get(i).getDeviceId());
 | 
											
												
													
														|  |                  map.put("deviceName", page.getRecords().get(i).getDeviceName());
 |  |                  map.put("deviceName", page.getRecords().get(i).getDeviceName());
 | 
											
												
													
														|  | 
 |  | +                map.put("deviceType", page.getRecords().get(i).getDeviceType());
 | 
											
												
													
														|  |                  map.put("installAddress", page.getRecords().get(i).getInstallAddress());
 |  |                  map.put("installAddress", page.getRecords().get(i).getInstallAddress());
 | 
											
												
													
														|  |                  map.put("bindStatus", 0);
 |  |                  map.put("bindStatus", 0);
 | 
											
												
													
														|  |                  map.put("bindId", 0);
 |  |                  map.put("bindId", 0);
 | 
											
										
											
												
													
														|  | @@ -275,4 +284,51 @@ public class BaseGgpFacilityServiceImpl extends AbstractCrudService<BaseGgpFacil
 | 
											
												
													
														|  |          List<BaseGgpFacility> list = this.list(query);
 |  |          List<BaseGgpFacility> list = this.list(query);
 | 
											
												
													
														|  |          return list;
 |  |          return list;
 | 
											
												
													
														|  |      }
 |  |      }
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +    @Override
 | 
											
												
													
														|  | 
 |  | +    public List<Object> facilityPopInfo(Integer id) {
 | 
											
												
													
														|  | 
 |  | +        List<Object> list = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +        LambdaQueryWrapper<BaseGgpFacility> queryWrapper = Wrappers.lambdaQuery();
 | 
											
												
													
														|  | 
 |  | +        queryWrapper.eq(BaseGgpFacility::getId, id);
 | 
											
												
													
														|  | 
 |  | +        List<BaseGgpFacility> baseGgpFacilityList = this.list(queryWrapper);
 | 
											
												
													
														|  | 
 |  | +        LambdaQueryWrapper<BaseFacilityDevice> lambdaQuery = Wrappers.lambdaQuery();
 | 
											
												
													
														|  | 
 |  | +        lambdaQuery.eq(BaseFacilityDevice::getFacilityId,id);
 | 
											
												
													
														|  | 
 |  | +        List<BaseFacilityDevice> baseFacilityDeviceList = baseFacilityDeviceService.list(lambdaQuery);
 | 
											
												
													
														|  | 
 |  | +        Map<String, Object> map = new HashMap<>();
 | 
											
												
													
														|  | 
 |  | +        map.put("id", baseGgpFacilityList.get(0).getId());
 | 
											
												
													
														|  | 
 |  | +        map.put("facilityName", baseGgpFacilityList.get(0).getFacilityName());
 | 
											
												
													
														|  | 
 |  | +        map.put("facilityAddress", baseGgpFacilityList.get(0).getFacilityAddress());
 | 
											
												
													
														|  | 
 |  | +        map.put("contact", baseGgpFacilityList.get(0).getContact());
 | 
											
												
													
														|  | 
 |  | +        map.put("contactPhone", baseGgpFacilityList.get(0).getContactPhone());
 | 
											
												
													
														|  | 
 |  | +        if (CollectionUtils.isNotEmpty(baseFacilityDeviceList)) {
 | 
											
												
													
														|  | 
 |  | +            List<String> deviceIdList = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +            for (int i = 0; i < baseFacilityDeviceList.size(); i++) {
 | 
											
												
													
														|  | 
 |  | +                deviceIdList.add(baseFacilityDeviceList.get(i).getDeviceId());
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +            QueryWrapper<DmpDeviceInfo> query1 = Wrappers.query();
 | 
											
												
													
														|  | 
 |  | +            query1.select("product_code as productCode","count(id) as count")
 | 
											
												
													
														|  | 
 |  | +                    .in("device_id",deviceIdList)
 | 
											
												
													
														|  | 
 |  | +                    .eq("delete_flag",0)
 | 
											
												
													
														|  | 
 |  | +                    .groupBy("product_code");
 | 
											
												
													
														|  | 
 |  | +            List<DmpDeviceInfo> dmpDeviceInfoList1 = dmpDeviceInfoService.list(query1);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            QueryWrapper<DmpDeviceInfo> query = Wrappers.query();
 | 
											
												
													
														|  | 
 |  | +            query.select("product_code as productCode","count(id) as count")
 | 
											
												
													
														|  | 
 |  | +                    .in("device_id",deviceIdList)
 | 
											
												
													
														|  | 
 |  | +                    .eq("delete_flag",0)
 | 
											
												
													
														|  | 
 |  | +                    .groupBy("product_code");
 | 
											
												
													
														|  | 
 |  | +            List<DmpDeviceInfo> dmpDeviceInfoList = dmpDeviceInfoService.list(query);
 | 
											
												
													
														|  | 
 |  | +            if (CollectionUtils.isNotEmpty(dmpDeviceInfoList)){
 | 
											
												
													
														|  | 
 |  | +                List<String> productCodeList = new ArrayList<>();
 | 
											
												
													
														|  | 
 |  | +                for (int j = 0; j < dmpDeviceInfoList.size(); j++) {
 | 
											
												
													
														|  | 
 |  | +                    productCodeList.add(dmpDeviceInfoList.get(j).getProductCode());
 | 
											
												
													
														|  | 
 |  | +                }
 | 
											
												
													
														|  | 
 |  | +                LambdaQueryWrapper<DmpProductInfo> queryWrapper2 = Wrappers.lambdaQuery();
 | 
											
												
													
														|  | 
 |  | +                queryWrapper2.in(DmpProductInfo::getProductCode, productCodeList);
 | 
											
												
													
														|  | 
 |  | +                List<DmpProductInfo> dmpProductInfoList = dmpProductInfoService.list(queryWrapper2);
 | 
											
												
													
														|  | 
 |  | +
 | 
											
												
													
														|  | 
 |  | +            }
 | 
											
												
													
														|  | 
 |  | +        }
 | 
											
												
													
														|  | 
 |  | +        return list;
 | 
											
												
													
														|  | 
 |  | +    }
 | 
											
												
													
														|  |  }
 |  |  }
 |