package com.yuchen.saas.park.service.controller.meifeng;

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.toolkit.Wrappers;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.google.protobuf.ServiceException;
import com.yuchen.saas.integration.feign.api.feign.CameraClient;
import com.yuchen.saas.park.api.constant.CommonConstant;
import com.yuchen.saas.park.api.entity.device.PmgBatSmartEquipment;
import com.yuchen.saas.park.api.entity.park.*;
import com.yuchen.saas.park.api.vo.park.*;
import com.yuchen.saas.park.service.config.PeopleConfig;
import com.yuchen.saas.park.service.service.*;
import com.yuchen.saas.park.service.util.VideoEventsUtils;
import com.yuchen.saas.parking.api.entity.IotBatIntegratedDevice;
import com.yuchen.saas.parking.api.feign.IntegratedClient;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.nest.springwrap.core.mp.support.Condition;
import org.nest.springwrap.core.mp.support.Query;
import org.nest.springwrap.core.redis.cache.NestRedis;
import org.nest.springwrap.core.tool.api.R;
import org.nest.springwrap.core.tool.utils.Func;
import org.nest.springwrap.core.tool.utils.StringUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.*;
import java.util.stream.Collectors;

/**
 * @ClassName ScreenController
 * @Description
 * @author 吕海泉
 * @Date 2021/5/12 10:18
 * @Version 1.0
 **/


@RestController
@AllArgsConstructor
@RequestMapping("/screen")
@Api(value = "大屏接口", tags = "大屏接口")
public class ParkScreenController {


    /**
     * 四联水表
     */
    public static final String WATERPK = "g0saEDt5mJRvyF3T";
    /**
     * 四联电表
     */
    public static final String AMMETERPK = "H4a2K382Ov1Ts5sd";


    /**
     * 土壤酸碱度
     */
    public static final String SOIL_PH = "6oxB340El848W28i";


    /**
     * 土壤温湿度
     */
    public static final String SOIL_TH = "wym24lc94iw0B4zR";

    /**
     * 水质酸碱度
     */
    public static final String WATER = "knXgfFXZ82lmV339";

    /**
     * 温湿度传感器
     */
    public static final String HUMITURE = "WJ5vunLo6tS1MD7k";
    /**
     * 风速传感器
     */
    public static final String WIND_SPEED = "U4jkjZ2ikX1ExUOI";

    /**
     * 风向传感器
     */
    public static final String WIND_DIRECTION = "KYxxq1PyL7obD8nA";


    /**
     * 雨量传感器
     */
    public static final String HYETAL = "BTa863298Bp6R1y4";

    @Resource
    private IPeopleCountService iPeopleCountService;

    @Autowired
    private IWarningInfoService iWarningInfoService;

    @Autowired
    private PmgBatSmartEquipmentService pmgBatSmartEquipmentService;

    @Autowired
    private PmgLogVideoEventsCountService pmgLogVideoEventsCountService;

    @Resource
    private CameraClient cameraClient;

    @Autowired
    private IWarningCategoryService iWarningCategoryService;


    /*@Autowired
    private ParkingVehicleService parkingVehicleService;*/

    @Autowired
    private ParkDeviceDataService parkDeviceDataService;

    @Autowired
    private IHandlerWarningService iHandlerWarningService;

    @Autowired
    private NestRedis nestRedis;

    @Autowired
    private SoundLightService soundLightService;

    @Resource
    private IntegratedClient integratedClient;


   /* @Autowired
    private PushService pushService;*/

    @Autowired
    private PeopleConfig peopleConfig;

    @Autowired
    private VideoEventsUtils videoEventsUtils;
    @Autowired
    private IDeviceType iDeviceType;

    // 园区服务
    @Autowired
    private PmgBatParkInfoService pmgBatParkInfoService;
    // 楼宇服务
    @Autowired
    PmgBatParkBuildingInfoService pmgBatParkBuildingService;
    // 楼层服务
    @Autowired
    PmgBatParkStoreyService pmgBatParkStoreyService;
    // 房间服务
    @Autowired
    private PmgBatParkRoomInfoService pmgBatParkRoomInfoService;
    // 人员服务
    @Autowired
    private PmgBatParkPeopleService pmgBatParkPeopleService;

    /**
     * 首页-根据园区ID查询-人员图像接口返回数据
     *
     * @param parkId 园区ID
     * @return
     */
    @GetMapping("/analysis/getPersonImage")
    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "")
    public R<Map<String, Long>> getPersonImage(@RequestParam String parkId) {
        return R.data(iPeopleCountService.getPersonImage(parkId));
    }


    /**
     * 首页-根据园区ID查询-统计已处理和未处理
     *
     * @param parkId 园区ID
     * @return
     */
    @GetMapping("/analysis/getWarningHandlerResult")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "")
    public R<Map<String, Long>> getWarningHandlerResult(@RequestParam String parkId) {
        return R.data(iWarningInfoService.getWarningHandlerResult(parkId));
    }

    /**
     * 物管设备列表
     *
     * @param parkId 园区ID
     * @return
     */
    @GetMapping("/smartEquipment/getAll")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "", notes = "")
    public R<List<PmgBatSmartEquipment>> list(@RequestParam String parkId) {
        LambdaQueryWrapper<PmgBatSmartEquipment> smartEquipmentWrapper = Wrappers.lambdaQuery();
        List<PmgBatSmartEquipment> allList = pmgBatSmartEquipmentService.list(smartEquipmentWrapper.eq(PmgBatSmartEquipment::getParkId, parkId));
       /* LambdaQueryWrapper<PmgBatSmartEquipmentVo> smartEquipmentVoLambdaQueryWrapper = Wrappers.lambdaQuery();
        List<PmgBatSmartEquipmentVo> allList = pmgBatSmartEquipmentService.getDetailAll();
        List<PmgBatSmartEquipmentVo> list  = allList.stream().filter(pmgBatSmartEquipmentVo -> pmgBatSmartEquipmentVo.getParkId() != null && pmgBatSmartEquipmentVo.getParkId().equals(Long.valueOf(parkId))).collect(Collectors.toList());*/
        return R.data(allList);
    }

    /**
     * 首页-根据园区ID查询-行为事件、测温事件、异常事件（陌生人和高频人员） 的总数、已处理、未处理
     *
     * @param parkId 园区ID
     * @return
     */
    @GetMapping("/category/getStatistics")
    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "获取统计数据", notes = "获取统计数据")
    public R<Map<String, Object>> getStatistics(@RequestParam String parkId) {
        // 声明返回集合
        Map<String, Object> map = new HashMap<>();
        // 1、行为事件的总数、已处理，未处理
        HandleStatisticsVo handleStatisticsVo = pmgLogVideoEventsCountService.getStatistics(parkId);
        map.put("behavior", handleStatisticsVo);
        // 2、测温事件的总数、已处理、未处理
        QueryWrapper<PmgLogPeopleCount> queryWrapper = new QueryWrapper<>();
        queryWrapper.isNotNull("temperature").gt("temperature", peopleConfig.getTemperature());
        queryWrapper.eq("park_id", parkId);
        map.put("temperature", iPeopleCountService.count(queryWrapper));
        // 3、异常事件的总数、已处理、未处理
        queryWrapper = new QueryWrapper<>();
        queryWrapper.in("code", peopleConfig.getCode10003(), peopleConfig.getCode10004());
        queryWrapper.eq("park_id", parkId);
        map.put("abnormal", iPeopleCountService.count(queryWrapper));
        return R.data(map);
    }


    /**
     * 各类人员统计结果
     *
     * @param parkId
     * @return
     */
    @GetMapping("/analysis/person/count")
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "")
    public R<Map<String, Long>> getPersonResult(String parkId) {
        return R.data(iPeopleCountService.getPersonResult(parkId));
    }


    /**
     * 根据园区ID 查询 统计监控点在线状态
     *
     * @param parkId
     * @return onlineY 在线数量
     * onlineN 离线数量
     * cameraCount 总数
     */
    @GetMapping("/camera/getCountOnlineCamera")
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "get", notes = "none")
    public Map<String, Object> getCountOnlineCamera(@RequestParam String parkId) {
        return cameraClient.getCountOnlineCamera(parkId);
    }


    /**
     * 获取车位信息
     *
     * @return
     */
    @PostMapping("/hikCommon/getPlaceInfo")
    @ApiOperationSupport(order = 6)
    @ApiOperation(value = "get", notes = "none")
    public R<Map<String, Object>> getPlaceInfo(@RequestBody Map<String, Object> reqBody) {
        return R.data(null);
    }

    /**
     * 查询行为预警趋势
     *
     * @param pmgLogVideoEventsCount
     * @return
     */
    @GetMapping("/video_events/getCountTime24")
    @ApiOperationSupport(order = 7)
    @ApiOperation(value = "行为预警趋势", notes = "行为预警趋势")
    public R<Map<String, Object>> getCountTime24(PmgLogVideoEventsCount pmgLogVideoEventsCount) {
        return R.data(pmgLogVideoEventsCountService.getCountTime24(pmgLogVideoEventsCount.getParkId(), pmgLogVideoEventsCount.getBuildingId(),
                pmgLogVideoEventsCount.getFloorId(), pmgLogVideoEventsCount.getRoomId()));
    }


    /**
     * 获取停车场所有车道列表
     */
    @PostMapping("/hikCommon/getAllRoadwayList")
    @ApiOperationSupport(order = 8)
    @ApiOperation(value = "get", notes = "none")
    public R<List<Map<String, Object>>> getAllRoadwayList(@RequestBody Map<String, Object> reqBody) {
        return R.data(null);
    }

    /**
     * 查询停车库剩余车位数
     *
     * @return
     */
    @PostMapping("/hikCommon/getRemainSpaceNum")
    @ApiOperationSupport(order = 9)
    @ApiOperation(value = "get", notes = "none")
    public R<Map<String, Object>> getRemainSpaceNum(@RequestBody Map<String, Object> reqBody) {
        return R.data(null);
    }

    /**
     * 通过监控点唯一标识获取流
     * @param cameraIndexCode 监控点ID
     * @param streamType 码流类型：0主码流、1子码、2第三方码流
     * @return
     */
    @GetMapping("/getPreviewUrlByCode")
    @ApiOperationSupport(order = 10)
    @ApiOperation(value = "通过监控点唯一标识获取流", notes = "通过监控点唯一标识获取流")
    public R<Map<String, Object>> getPreviewUrlByCode(@RequestParam String cameraIndexCode,@RequestParam(required = false) String streamType) {
        return R.data(cameraClient.getPreviewUrlByCode(cameraIndexCode,streamType));
    }

    /**
     * 获取所有监控点信息及其视频流url
     *
     * @return
     */
    @PostMapping("/camera/getPreviewUrl")
    @ApiOperationSupport(order = 11)
    @ApiOperation(value = "get", notes = "none")
    public R<List<Map<String, Object>>> getResgions() {
        return cameraClient.getPreviewUrl();
    }

    /**
     * 获取所有监控点信息及其视频流url
     *
     * @return
     */

    @PostMapping("/camera/getAllMonitor")
    @ApiOperationSupport(order = 12)
    @ApiOperation(value = "get", notes = "none")
    public R<List<CameraMonitoringPoint>> getResgions(@RequestParam String parkId) throws ServiceException {

        List<CameraMonitoringPoint> ca = new ArrayList<>();
        R<List<IotBatIntegratedDevice>> listR = integratedClient.getAllDevices(CommonConstant.PRODUCT_CAMERA_POINT);
        List<PmgBatSmartEquipment> pmgBatSmartEquipmentList = pmgBatSmartEquipmentService.list(Wrappers.<PmgBatSmartEquipment>query().lambda().eq(PmgBatSmartEquipment::getProductKey, CommonConstant.PRODUCT_CAMERA_POINT));
        if (listR.isSuccess()) {
            ca = listR.getData().stream().flatMap(iotBatIntegratedDevice -> pmgBatSmartEquipmentList.stream()
                    .filter(pmgBatSmartEquipment ->
                            iotBatIntegratedDevice.getDeviceName() != null
                                    && pmgBatSmartEquipment.getDeviceName() != null
                                    && pmgBatSmartEquipment.getParkId() != null
                                    && iotBatIntegratedDevice.getDeviceName().equals(pmgBatSmartEquipment.getDeviceName())
                                    && pmgBatSmartEquipment.getParkId().equals(Long.valueOf(parkId))
                    )
                    .map(r -> new CameraMonitoringPoint(iotBatIntegratedDevice.getSn(), r.getName(),iotBatIntegratedDevice.getVideoId()))).collect(Collectors.toList());
        }
        return R.data(ca);
    }

    /**
     * 人员进入统计 24小时入园统计
     *
     * @param pmgLogPeopleCount
     * @return
     */
    @GetMapping("/analysis/getCountTime24")
    @ApiOperationSupport(order = 13)
    @ApiOperation(value = "统计近24小时每小时的入园人数")
    public R<Map<String, Object>> getEnterParkPeopleCount(PmgLogPeopleCount pmgLogPeopleCount) {
        return R.data(iPeopleCountService.getCountTime24(pmgLogPeopleCount.getParkId(),
                pmgLogPeopleCount.getBuildingId(), pmgLogPeopleCount.getFloorId(), pmgLogPeopleCount.getRoomId()));
    }


    /**
     * 站点信息表
     */
    @GetMapping("/list")
    @ApiOperationSupport(order = 14)
    @ApiOperation(value = "分页", notes = "传入parkCompany")
    public R<IPage<PmgLogPeopleCount>> list(Long timeStamp, Query query) {
        LambdaQueryWrapper<PmgLogPeopleCount> peopleCountWrapper = Wrappers.lambdaQuery();
        IPage<PmgLogPeopleCount> pages = iPeopleCountService.page(Condition.getPage(query),
                peopleCountWrapper.gt(PmgLogPeopleCount::getTimeStamp, timeStamp).orderByDesc(PmgLogPeopleCount::getTimeStamp));
        return R.data(pages);
    }


    /**
     * 查询历史异常人员和陌生人
     */
    @GetMapping("/analysis/getListAbnormalAndStranger")
    @ApiOperationSupport(order = 15)
    @ApiOperation(value = "")
    public R<IPage<PmgLogPeopleCount>> getListAbnormalAndStranger(PmgLogPeopleCount pmgLogPeopleCount, Query query) {
        LambdaQueryWrapper<PmgLogPeopleCount> peopleWrapper = Wrappers.lambdaQuery();
        IPage<PmgLogPeopleCount> pages = iPeopleCountService.page(Condition.getPage(query),
                peopleWrapper.like(StringUtils.isNotBlank(pmgLogPeopleCount.getEquipmentName()),
                        PmgLogPeopleCount::getEquipmentName, pmgLogPeopleCount.getEquipmentName())
                        .and(pmgLogPeopleCount.getTemperature() != null && pmgLogPeopleCount.getTemperature() > 0,
                                wrapper -> wrapper.likeRight(PmgLogPeopleCount::getTemperature, pmgLogPeopleCount.getTemperature())
                                        .or().eq(PmgLogPeopleCount::getTemperature, pmgLogPeopleCount.getTemperature()))
                        .and(wrapper -> wrapper.gt(PmgLogPeopleCount::getTemperature, peopleConfig.getTemperature())
                                .or().eq(PmgLogPeopleCount::getCode, peopleConfig.getCode10003())).orderByDesc(PmgLogPeopleCount::getTimeStamp)
                        .and(wrapper -> wrapper.eq(PmgLogPeopleCount::getParkId, pmgLogPeopleCount.getParkId()))
        );
        return R.data(pages);
    }

    /**
     * 根据园区ID 查询 设备总数、在线设备数、告警设备数
     *
     * @param parkId 园区ID
     * @return
     */
    @GetMapping("/analysis/device/count")
    @ApiOperationSupport(order = 16)
    @ApiOperation(value = "")
    public R<DeviceOnLineCountVo> getDeviceAnalysis(@RequestParam String parkId) {
        /*List<PmgBatSmartEquipmentVo> pmgBatSmartEquipmentVos =  pmgBatSmartEquipmentService.getDetailAll();
        long deviceCount = pmgBatSmartEquipmentVos.size();
        int onlineDevice = pmgBatSmartEquipmentService.getAllDevice();

        List<WarningDeviceVo> list = iWarningInfoService.getWarningDevice();
        int warningDevice = list.size();
        Map<String,Long> map = new HashMap<>(3);
        map.put("deviceCount",deviceCount);
        map.put("onlineDevice", (long) onlineDevice);
        map.put("warningDevice", (long) warningDevice);
        */
        return R.data(pmgBatSmartEquipmentService.getOnLineCount(parkId));
    }


    /**
     * 查询行为预警分页列表
     * 今天
     *
     * @param pmgLogVideoEventsCount 需要查询的条件数据
     * @param query                  分页数据
     * @return
     */
    @GetMapping("/video_events/getPage")
    @ApiOperationSupport(order = 17)
    @ApiOperation(value = "查询行为预警分页列表", notes = "查询行为预警分页列表")
    public R<IPage<PmgLogVideoEventsCount>> getPage(PmgLogVideoEventsCount pmgLogVideoEventsCount, Query query) {
        return R.data(pmgLogVideoEventsCountService.getListAbnormalBehavior(pmgLogVideoEventsCount, query));
    }

    /**
     * 查询行为预警分页列表
     * 全部
     *
     * @param pmgLogVideoEventsCount 需要查询的条件数据
     * @param query                  分页数据
     * @return
     */
    @GetMapping("/video_events/getAllPage")
    @ApiOperationSupport(order = 18)
    @ApiOperation(value = "查询行为预警分页列表", notes = "查询行为预警分页列表")
    public R<IPage<PmgLogVideoEventsCount>> getAllPage(PmgLogVideoEventsCount pmgLogVideoEventsCount, Query query) {
        LambdaQueryWrapper<PmgLogVideoEventsCount> queryWrapper = Wrappers.lambdaQuery();
        IPage<PmgLogVideoEventsCount> pages = pmgLogVideoEventsCountService.page(Condition.getPage(query),
                         queryWrapper.like(Func.isNotEmpty(pmgLogVideoEventsCount.getEquipmentName()),
                                 PmgLogVideoEventsCount::getEquipmentName,pmgLogVideoEventsCount.getEquipmentName())
                        .eq(PmgLogVideoEventsCount::getParkId,pmgLogVideoEventsCount.getParkId())
                        .orderByDesc(PmgLogVideoEventsCount::getTimeStamp));
        return R.data(pages);
    }


//    /**
//     * 查询行为预警分页列表
//     * 全部
//     *
//     * @param pmgLogVideoEventsCount 需要查询的条件数据
//     * @return
//     */
//    @GetMapping("/video_events/getAllPage")
//    @ApiOperationSupport(order = 18)
//    @ApiOperation(value = "查询行为预警分页列表", notes = "查询行为预警分页列表")
//    public R<List<PmgLogVideoEventsCount>> getAllPage(PmgLogVideoEventsCount pmgLogVideoEventsCount) {
//        List<PmgLogVideoEventsCount> list = pmgLogVideoEventsCountService.list(Condition.getQueryWrapper(pmgLogVideoEventsCount)
//                .orderByDesc("time_stamp").last("limit 30"));
//        return R.data(list);
//    }


    /**
     * 通过人员类型获取相关人员所属楼宇分布
     *
     * @param code
     * @param parkId
     * @return
     */
    @GetMapping("/analysis/visitorBuildingSpread")
    @ApiOperationSupport(order = 19)
    @ApiOperation(value = "")
    public R<List<Map<String, Object>>> visitorBuildingSpread(String code, String parkId) {
        return R.data(iPeopleCountService.visitorBuildingSpread(code, parkId));
    }

    /**
     * 通过停车场唯一编号获取停车场出入口
     */
    @PostMapping("/hikCommon/getParkingDeviceControl")
    @ApiOperationSupport(order = 20)
    @ApiOperation(value = "get", notes = "none")
    public R<List<Map<String, Object>>> getParkingDeviceControl(@RequestBody Map<String, Object> reqBody) {
        return R.data(null);
    }

    /**
     * 分页 报警信息
     */
    @GetMapping("/info/list")
    @ApiOperationSupport(order = 21)
    @ApiOperation(value = "分页", notes = "传入parkCompany")
    public R<IPage<PmgBatWarningInfo>> list(PmgBatWarningInfo pmgBatWarningInfo, Query query) {
        String name = pmgBatWarningInfo.getName();
        pmgBatWarningInfo.setName(null);
        LambdaQueryWrapper<PmgBatWarningInfo> wrapper = Wrappers.lambdaQuery(pmgBatWarningInfo);
        wrapper.like(StringUtil.isNotBlank(name), PmgBatWarningInfo::getName, name);
        wrapper.orderByDesc(PmgBatWarningInfo::getEventTime);
        IPage<PmgBatWarningInfo> pages = iWarningInfoService.page(Condition.getPage(query), wrapper);
        return R.data(pages);
    }

    /**
     * 统计
     *
     * @return
     */
    @GetMapping("/statistics")
    @ApiOperationSupport(order = 22)
    @ApiOperation(value = "")
    public R<Map<String, Object>> getStatisticsime() {
        return R.data(iWarningInfoService.getTotal());
    }


    /**
     * 安防告警事件趋势
     * 一级、二级、三级、四级
     *
     * @return
     */
    @GetMapping("/analysis/device/warning/count")
    @ApiOperationSupport(order = 24)
    @ApiOperation(value = "")
    public R<Map<String, Object>> getWarningByLevel(@RequestParam String parkId) {
        return R.data(iWarningInfoService.getWarningByLevel(parkId));
    }

    /**
     * 异常事件近一周的统计
     */
    @GetMapping("/category/abnormal/count")
    @ApiOperationSupport(order = 25)
    @ApiOperation(value = "异常事件趋势", notes = "异常事件趋势")
    public R abnormalCount(@RequestParam String parkId) {
        StringBuilder operateDate = new StringBuilder();
        StringBuilder resultDate = new StringBuilder();
        SimpleDateFormat ymd = new SimpleDateFormat("yyyy-MM-dd");
        SimpleDateFormat md = new SimpleDateFormat("MM-dd");

        Calendar calendar = Calendar.getInstance();
        for (int i = 6; i >= 0; i--) {
            calendar.setTime(new Date());
            calendar.add(Calendar.DATE, -i);
            operateDate.append(ymd.format(calendar.getTime())).append(",");
            resultDate.append(md.format(calendar.getTime())).append(",");
        }
        Map<String, Object> map = new HashMap<>();
        map.put("data", iWarningCategoryService.getAbnormalCount(operateDate.toString(), parkId));
        map.put("date", Arrays.asList(resultDate.toString().split(",")));
        return R.data(map);
    }


    /**
     * 分页 站点信息表
     */
    @GetMapping("/analysis/people/list")
    @ApiOperationSupport(order = 26)
    @ApiOperation(value = "分页", notes = "传入parkCompany")
    public R<IPage<PmgLogPeopleCount>> list(PmgLogPeopleCount pmgLogPeopleCount, Query query) {

        return R.data(iPeopleCountService.pagePeople(pmgLogPeopleCount, query));
    }


    /**
     * 各分类车辆总数
     *
     * @return
     */
    /*@GetMapping("/carController/getCountByCode")
    @ApiOperationSupport(order = 27)
    @ApiOperation(value = "", notes = "")
    public R<Map<String, Object>> getCountByCode(@RequestParam String parkId) {
        return R.data(parkingVehicleService.getCountByCode(parkId));
    }*/


    /**
     * 获取车道列表
     */
    @PostMapping("/hikCommon/getRoadwayList")
    @ApiOperationSupport(order = 28)
    @ApiOperation(value = "get", notes = "none")
    public R<List<Map<String, Object>>> getRoadwayList(@RequestBody Map<String, Object> reqBody) {
        return R.data(null);
    }


    /**
     * 分页 园区空间主题类型信息
     */
    @GetMapping("/smartEquipment/list")
    @ApiOperationSupport(order = 29)
    @ApiOperation(value = "分页", notes = "园区空间主题类型信息")
    public R<IPage<PmgBatSmartEquipment>> list(PmgBatSmartEquipment pmgBatSmartEquipment, Query query) {
        IPage<PmgBatSmartEquipment> pages = pmgBatSmartEquipmentService.page(Condition.getPage(query),
                new LambdaQueryWrapper<PmgBatSmartEquipment>()
                        .eq(Func.isNotEmpty(pmgBatSmartEquipment.getParkId()), PmgBatSmartEquipment::getParkId,
                                pmgBatSmartEquipment.getParkId())
                        .eq(Func.isNotEmpty(pmgBatSmartEquipment.getCategoryName()),
                                PmgBatSmartEquipment::getCategoryName, pmgBatSmartEquipment.getCategoryName())
                        .eq(Func.isNotEmpty(pmgBatSmartEquipment.getIsOnline()), PmgBatSmartEquipment::getIsOnline,
                                pmgBatSmartEquipment.getIsOnline())
                        .like(Func.isNotEmpty(pmgBatSmartEquipment.getName()), PmgBatSmartEquipment::getName,
                                pmgBatSmartEquipment.getName())
                        .orderByAsc(PmgBatSmartEquipment::getIsOnline)
                        .orderByDesc(PmgBatSmartEquipment::getCreateTime)
                );
        return R.data(pages);
    }

    /**
     * 分页查询历史温度异常人员
     */
    @GetMapping("/analysis/getListAbnormal")
    @ApiOperationSupport(order = 30)
    @ApiOperation(value = "")
    public R<IPage<PmgLogPeopleCount>> getListAbnormal(PmgLogPeopleCount pmgLogPeopleCount, Query query) {

        return R.data(iPeopleCountService.pagePeopleAbnormal(pmgLogPeopleCount, query));
    }


    /**
     * 查询陌生人和高频人员列表
     */
    @GetMapping("/analysis/getHighFrequencyAndStranger")
    @ApiOperationSupport(order = 31)
    @ApiOperation(value = "")
    public R<IPage<PmgLogPeopleCount>> getHighFrequencyAndStranger(PmgLogPeopleCount pmgLogPeopleCount, Query query) {
        return R.data(iPeopleCountService.getHighFrequencyAndStranger(pmgLogPeopleCount, query));
    }


    /**
     * 今日体温正常人员分页查询
     *
     * @param pmgLogPeopleCount 人员信息
     * @param query             分页信息
     * @return
     */
    @GetMapping("/analysis/getNormalDayPage")
    @ApiOperationSupport(order = 32)
    @ApiOperation(value = "")
    public R<IPage<PmgLogPeopleCount>> getNormalDayPage(PmgLogPeopleCount pmgLogPeopleCount, Query query) {
        return R.data(iPeopleCountService.getNormalDayPage(pmgLogPeopleCount, query));
    }


    /**
     * 今日体温异常人员分页查询
     *
     * @param pmgLogPeopleCount 人员信息
     * @param query             分页信息
     * @return
     */
    @GetMapping("/analysis/getAbnormalDayPage")
    @ApiOperationSupport(order = 33)
    @ApiOperation(value = "")
    public R<IPage<PmgLogPeopleCount>> getAbnormalDayPage(@RequestParam String parkId, PmgLogPeopleCount pmgLogPeopleCount, Query query) {
        return R.data(iPeopleCountService.getAbnormalDayPage(parkId, pmgLogPeopleCount, query));
    }

    /**
     * 今日陌生人分页查询
     *
     * @param pmgLogPeopleCount 人员信息
     * @param query             分页信息
     * @return
     */
    @GetMapping("/analysis/getStrangerDayPage")
    @ApiOperationSupport(order = 34)
    @ApiOperation(value = "")
    public R<IPage<PmgLogPeopleCount>> getStrangerDayPage(PmgLogPeopleCount pmgLogPeopleCount, Query query) {

        return R.data(iPeopleCountService.getStrangerDayPage(pmgLogPeopleCount, query));
    }

    /**
     * 车牌更新  车牌矫正
     */
    @PostMapping("/hikCommon/changeCrossRecord")
    @ApiOperationSupport(order = 35)
    @ApiOperation(value = "get", notes = "none")
    public R changeCrossRecord(@RequestBody Map<String, Object> reqBody) {
        return R.status(false);
    }

    /**
     * 获取停车场车辆信息
     *
     * @return
     */
    @PostMapping("/hikCommon/getTempCarInRecords")
    @ApiOperationSupport(order = 36)
    @ApiOperation(value = "get", notes = "none")
    public R<Map<String, Object>> getTempCarInRecords(@RequestBody Map<String, Object> reqBody) {
        return R.data(null);
    }

    @GetMapping("/device/monitor-data")
    public R getMonitorData(@RequestParam String parkId) {
        // List<DeviceShadow> data = iDeviceDataService.queryDeviceStateDataList(parkId);
        return R.data(null);
    }

    @GetMapping("/getPersonVideoEvents")
    public R getPersonVideoEvents(@RequestParam String parkId) {
        Object data = videoEventsUtils.findMonitorData(parkId);
        return R.data(data);
    }

    /**
     * 新增 告警事件处理表
     */
    @PostMapping("/handler/save")
    @ApiOperationSupport(order = 38)
    @ApiOperation(value = "新增", notes = "传入pmgBatHandlerWarning")
    public R save(@Valid @RequestBody PmgBatHandlerWarning pmgBatHandlerWarning) {
        long id = System.currentTimeMillis() / 1000L;
        // 根据pk、dn、eventTime查询该时间正负两分钟的数据
        if (Integer.valueOf(pmgBatHandlerWarning.getHandlerModel()) == 1) {
            LambdaQueryWrapper<PmgBatWarningInfo> pmgBatWarningInfoLambdaQueryWrapper = new LambdaQueryWrapper<>();
            pmgBatWarningInfoLambdaQueryWrapper.eq(PmgBatWarningInfo::getProductKey, pmgBatHandlerWarning.getProductKey())
                    .eq(PmgBatWarningInfo::getDeviceName, pmgBatHandlerWarning.getProductName())
                    .between(PmgBatWarningInfo::getEventTime, pmgBatHandlerWarning.getEventTime() - 120, pmgBatHandlerWarning.getEventTime() + 120);
            List<PmgBatWarningInfo> pmgBatWarningInfoList = iWarningInfoService.list(pmgBatWarningInfoLambdaQueryWrapper);

            for (PmgBatWarningInfo pmgBatWarningInfo : pmgBatWarningInfoList) {
                pmgBatWarningInfo.setIsHandling("1");
                iWarningInfoService.updateById(pmgBatWarningInfo);
            }
            String key = "event" + ":" + id;
            long time = pmgBatHandlerWarning.getEndTime() - pmgBatHandlerWarning.getStartTime();
            if (time > 0 && (pmgBatHandlerWarning.getEndTime() > System.currentTimeMillis() / 1000L)) {
                nestRedis.setEx(key, key, time);
            }
        }
        pmgBatHandlerWarning.setId(id);
        return R.status(iHandlerWarningService.save(pmgBatHandlerWarning));
    }


    /**
     * 详情
     */
    /*@PostMapping("/soundLight/soundLightOpenOrClose")
    @ApiOperationSupport(order = 39)
    @ApiOperation(value = "详情", notes = "传入电话号码信息")
    public R<ResponseVo> soundLightOpenOrClose(@RequestParam String parkId, @RequestBody Map<String, Object> body) {
        ResponseVo responseVo = soundLightService.soundLightOpenOrClose(body);
        if ("10000".equals(responseVo.getCode())) {
            Map<String, Object> respData = (Map<String, Object>) responseVo.getData();
            if (Func.isNotEmpty(respData)
                    && "200".equals(respData.get("code"))) { // 保存成功
                DeviceEventVo deviceEventVo = new DeviceEventVo();
                deviceEventVo.setParkId("5012e");
                deviceEventVo.setEquipmentName("声光报警器");
                deviceEventVo.setProduct("");
                Map<String, Object> value = new HashMap<>();
                value.put("value", "1");
                deviceEventVo.setOut(value);
                deviceEventVo.setPosition("");
                deviceEventVo.setLevel(1);
                deviceEventVo.setLevelName("一级报警");
                deviceEventVo.setRemark("声光报警");
                deviceEventVo.setIdentify("anti_theft_state");
                deviceEventVo.setProductKey("bw63z6jt04p5RRTt");
                deviceEventVo.setDeviceName("abx0cMSr48XTN6w3");
                deviceEventVo.setEventTime(System.currentTimeMillis());
                pushService.postEvent(parkId, JSON.toJSONString(deviceEventVo));
            }
        }
        return R.data(responseVo);
    }*/

    /**
     * 物管界面 分页 设备类型
     */
    @GetMapping("/device/type/list")
    @ApiOperationSupport(order = 40)
    @ApiOperation(value = "分页 设备类型", notes = "分页 设备类型")
    public R<IPage<PmgBatDeviceType>> list(PmgBatDeviceType pmgBatDeviceType, Query query) {
        IPage<PmgBatDeviceType> pages = iDeviceType.page(Condition.getPage(query), Condition.getQueryWrapper(pmgBatDeviceType));
        return R.data(pages);
    }
    /******************************* 园区信息相关开始 ******************************/
    /**
     * 园区信息分页
     */
    @GetMapping("/parkInfo/list")
    @ApiOperationSupport(order = 41)
    @ApiOperation(value = "分页", notes = "传入园区信息")
    public R<IPage<PmgBatParkInfo>> parkInfoList(PmgBatParkInfo pmgBatParkInfo, Query query) {
        IPage<PmgBatParkInfo> pages = pmgBatParkInfoService.page(Condition.getPage(query), Condition.getQueryWrapper(pmgBatParkInfo));
        return R.data(pages);
    }

    /**
     * 园区信息详情
     */
    @GetMapping("/parkInfo/detail")
    @ApiOperationSupport(order = 42)
    @ApiOperation(value = "详情", notes = "传入园区信息")
    public R<PmgBatParkInfo> parkInfoDetail(PmgBatParkInfo pmgBatParkInfo) {
        PmgBatParkInfo detail = pmgBatParkInfoService.getOne(Condition.getQueryWrapper(pmgBatParkInfo));
        return R.data(detail);
    }
    /***************************** 园区信息相关结束 ******************************/

    /******************************* 楼宇信息相关开始 ******************************/
    /**
     * 详情
     */
    @GetMapping("/parkBuilding/detail")
    @ApiOperationSupport(order = 43)
    @ApiOperation(value = "详情", notes = "传入楼宇信息")
    public R<PmgBatParkBuildingInfo> buildingDetail(PmgBatParkBuildingInfo pmgBatParkBuilding) {
        PmgBatParkBuildingInfo detail = pmgBatParkBuildingService.getOne(Condition.getQueryWrapper(pmgBatParkBuilding));
        return R.data(detail);
    }

    /**
     * 分页
     */
    @GetMapping("/parkBuilding/list")
    @ApiOperationSupport(order = 44)
    @ApiOperation(value = "分页", notes = "传入楼宇信息")
    public R<IPage<PmgBatParkBuildingInfo>> buildingList(PmgBatParkBuildingInfo pmgBatParkBuilding, Query query) {
        IPage<PmgBatParkBuildingInfo> pages = pmgBatParkBuildingService.page(Condition.getPage(query),
                Condition.getQueryWrapper(pmgBatParkBuilding));
        return R.data(pages);
    }
    /***************************** 楼宇信息相关结束 ******************************/
    /******************************* 楼层信息相关开始 ******************************/
    /**
     * 查询楼层基本信息
     */
    @GetMapping("/parkStorey/detail")
    @ApiOperationSupport(order = 45)
    @ApiOperation(value = "查询楼层基本信息", notes = "查询楼层基本信息")
    public R<PmgBatParkStorey> storeyDetail(PmgBatParkStorey pmgBatParkStorey) {
        PmgBatParkStorey detail = pmgBatParkStoreyService.getOne(Condition.getQueryWrapper(pmgBatParkStorey));
        return R.data(detail);
    }

    /**
     * 楼层基本信息 分页
     */
    @GetMapping("/parkStorey/list")
    @ApiOperationSupport(order = 46)
    @ApiOperation(value = "楼层基本信息 分页", notes = "楼层基本信息 分页")
    public R<IPage<PmgBatParkStorey>> storeyList(PmgBatParkStorey pmgBatParkStorey, Query query) {
        IPage<PmgBatParkStorey> pages = pmgBatParkStoreyService.page(Condition.getPage(query),
                Condition.getQueryWrapper(pmgBatParkStorey));
        return R.data(pages);
    }
    /***************************** 楼层信息相关结束 ******************************/
    /******************************* 房间信息相关开始 ******************************/
    /**
     * 查询房间基本信息
     */
    @GetMapping("/pmgBatParkRoomInfo/detail")
    @ApiOperationSupport(order = 47)
    @ApiOperation(value = "查询房间基本信息", notes = "查询房间基本信息")
    public R<PmgBatParkRoomInfo> roomInfoDetail(PmgBatParkRoomInfo pmgBatParkRoomInfo) {
        PmgBatParkRoomInfo detail = pmgBatParkRoomInfoService.getOne(Condition.getQueryWrapper(pmgBatParkRoomInfo));
        return R.data(detail);
    }

    /**
     * 房间基本信息 分页
     */
    @GetMapping("/pmgBatParkRoomInfo/list")
    @ApiOperationSupport(order = 48)
    @ApiOperation(value = "房间基本信息 分页", notes = "房间基本信息 分页")
    public R<IPage<PmgBatParkRoomInfo>> roomInfoList(PmgBatParkRoomInfo pmgBatParkRoomInfo, Query query) {
        IPage<PmgBatParkRoomInfo> pages = pmgBatParkRoomInfoService.page(Condition.getPage(query),
                Condition.getQueryWrapper(pmgBatParkRoomInfo));
        return R.data(pages);
    }
    /***************************** 房间信息相关结束 ******************************/
    /**
     * 获取指定园区内部人员总数、VIP人员总数、访客总数
     *
     * @param parkId
     * @return
     */
    @GetMapping("/parkPeoples/getPeopleCount")
    @ApiOperationSupport(order = 49)
    @ApiOperation(value = "获取指定园区内部人员总数、VIP人员总数、访客总数 ")
    public R<PeopleCountVo> getPeopleCount(String parkId) {
        return R.data(null);
    }

    /**
     * 24小时访客(包含陌生人)趋势
     *
     * @param parkId
     * @return
     */
    @GetMapping("/analysis/getVisitorCountTime24")
    @ApiOperationSupport(order = 51)
    @ApiOperation(value = "24小时访客(包含陌生人)趋势")
    public R<Map<String, Object>> getVisitorCountTime24(String parkId) {
        return R.data(iPeopleCountService.getVisitorCountTime24(parkId));
    }

    /**
     * 获取指定园区本月入园人次、本月可疑人员人次、本月外部访客人次
     *
     * @param parkId
     * @return
     */
    @GetMapping("/parkPeoples/getMonthPeopleCount")
    @ApiOperationSupport(order = 52)
    @ApiOperation(value = "获取指定园区本月入园人次、本月可疑人员人次、本月外部访客人次")
    public R<MonthPeopleCountVo> getMonthPeopleCount(String parkId) {
        return R.data(iPeopleCountService.getMonthPeopleCount(parkId));
    }

    /**
     * 近七天入园人次统计
     *
     * @param parkId
     * @return
     */
    @GetMapping("/parkPeoples/getSevenDayPeopleCount")
    @ApiOperationSupport(order = 53)
    @ApiOperation(value = "")
    public R<PieChartVo> getSevenDayPeopleCount(String parkId) {
        return R.data(iPeopleCountService.getSevenDayPeopleCount(parkId));
    }

    /**
     * 近七天访客人次(包含陌生人)
     *
     * @param parkId
     * @return
     */
    @GetMapping("/parkPeoples/getSevenDayVisitorCount")
    @ApiOperationSupport(order = 54)
    @ApiOperation(value = "近七天访客人次(包含陌生人)")
    public R<PieChartVo> getSevenDayVisitorCount(String parkId) {
        return R.data(iPeopleCountService.getSevenDayVisitorCount(parkId));
    }

    /**
     * 近七天园内人员人次
     *
     * @param parkId
     * @return
     */
    @GetMapping("/parkPeoples/getSevenDayInsiderCount")
    @ApiOperationSupport(order = 55)
    @ApiOperation(value = "近七天园内人员人次")
    public R<PieChartVo> getSevenDayInsiderCount(String parkId) {
        return R.data(iPeopleCountService.getSevenDayInsiderCount(parkId));
    }

    /**
     * 近七天VIP人员人次
     *
     * @param parkId
     * @return
     */
    @GetMapping("/parkPeoples/getSevenDayVipCount")
    @ApiOperationSupport(order = 56)
    @ApiOperation(value = "近七天VIP人员人次")
    public R<PieChartVo> getSevenDayVipCount(String parkId) {
        return R.data(iPeopleCountService.getSevenDayVipCount(parkId));
    }


    /**
     * 能耗水电列表
     *
     * @param buildingId 楼栋id
     * @param roomId     房间id
     * @param floorId    楼层id
     * @param type       1水表  2电表
     * @return
     */
    @GetMapping("/smartEquipment/hydropower")
    @ApiOperationSupport(order = 56)
    @ApiOperation(value = "能耗水电列表")
    public R<List<PmgBatSmartEquipment>> hydropower(@RequestParam(required = false) Long buildingId,
                                                    @RequestParam(required = false) Long roomId,
                                                    @RequestParam(required = false) Long floorId,
                                                    @RequestParam(required = false, defaultValue = "1") Integer type,
                                                    @RequestParam Long parkId) {

        return R.data(
                pmgBatSmartEquipmentService.list(Wrappers.<PmgBatSmartEquipment>lambdaQuery()
                        .eq(buildingId != null, PmgBatSmartEquipment::getBuildingId, buildingId)
                        .eq(roomId != null, PmgBatSmartEquipment::getFloorId, floorId)
                        .eq(roomId != null, PmgBatSmartEquipment::getRoomId, roomId)
                        .eq(PmgBatSmartEquipment::getProductKey, type == 1 ? WATERPK : AMMETERPK)
                        .eq(PmgBatSmartEquipment::getParkId, parkId)
                        .orderByDesc(PmgBatSmartEquipment::getCreateTime)

                )
        );
    }

    /**
     * 能耗模糊查询
     *
     * @param name   设备名称
     * @param parkId 园区id
     * @return
     */
    @GetMapping("/smartEquipment/likeHydropower")
    @ApiOperationSupport(order = 56)
    @ApiOperation(value = "能耗模糊查询")
    public R<List<PmgBatSmartEquipment>> likeHydropower(@RequestParam(required = false) String name,
                                                        @RequestParam Long parkId) {

        return R.data(
                pmgBatSmartEquipmentService.list(Wrappers.<PmgBatSmartEquipment>lambdaQuery()
                        .like(name != null, PmgBatSmartEquipment::getName, name)
                        .eq(PmgBatSmartEquipment::getParkId, parkId)
                        .in(PmgBatSmartEquipment::getProductKey, WATERPK, AMMETERPK)
                        .orderByDesc(PmgBatSmartEquipment::getCreateTime)
                )
        );
    }


    /**
     * 环境列表
     *
     * @param buildingId 楼栋id
     * @param roomId     房间id
     * @param floorId    楼层id
     * @param type       1土壤酸碱度  2 土壤温湿度  3 水质酸碱度  4 温度传感器 5风向传感器  6  风速传感器  7雨量传感器
     * @return
     */
    @GetMapping("/smartEquipment/environment")
    @ApiOperationSupport(order = 56)
    @ApiOperation(value = "能耗水电列表")
    public R<List<PmgBatSmartEquipment>> environment(@RequestParam(required = false) Long buildingId,
                                                     @RequestParam(required = false) Long roomId,
                                                     @RequestParam(required = false) Long floorId,
                                                     @RequestParam(required = false, defaultValue = "1") Integer type,
                                                     @RequestParam Long parkId) {
        return R.data(
                pmgBatSmartEquipmentService.list(Wrappers.<PmgBatSmartEquipment>lambdaQuery()
                        .eq(buildingId != null, PmgBatSmartEquipment::getBuildingId, buildingId)
                        .eq(roomId != null, PmgBatSmartEquipment::getFloorId, floorId)
                        .eq(roomId != null, PmgBatSmartEquipment::getRoomId, roomId)
                        .eq(type == 1, PmgBatSmartEquipment::getProductKey, SOIL_PH)
                        .eq(type == 2, PmgBatSmartEquipment::getProductKey, SOIL_TH)
                        .eq(type == 3, PmgBatSmartEquipment::getProductKey, WATER)
                        .eq(type == 4, PmgBatSmartEquipment::getProductKey, HUMITURE)
                        .eq(type == 5, PmgBatSmartEquipment::getProductKey, WIND_DIRECTION)
                        .eq(type == 6, PmgBatSmartEquipment::getProductKey, WIND_SPEED)
                        .eq(type == 7, PmgBatSmartEquipment::getProductKey, HYETAL)
                        .eq(PmgBatSmartEquipment::getParkId, parkId)
                        .orderByDesc(PmgBatSmartEquipment::getCreateTime)

                )
        );
    }

    /**
     * 环境模糊查询
     *
     * @param name   设备名称
     * @param parkId 园区id
     * @return
     */
    @GetMapping("/smartEquipment/likeEnvironment")
    @ApiOperationSupport(order = 56)
    @ApiOperation(value = "能耗模糊查询")
    public R<List<PmgBatSmartEquipment>> likeEnvironment(@RequestParam(required = false) String name,
                                                         @RequestParam Long parkId) {
        return R.data(
                pmgBatSmartEquipmentService.list(Wrappers.<PmgBatSmartEquipment>lambdaQuery()
                        .like(name != null, PmgBatSmartEquipment::getName, name)
                        .eq(PmgBatSmartEquipment::getParkId, parkId)
                        .in(PmgBatSmartEquipment::getProductKey, SOIL_PH, SOIL_TH, WATER, HUMITURE, WIND_DIRECTION, WIND_SPEED, HYETAL)
                        .orderByDesc(PmgBatSmartEquipment::getCreateTime)
                )
        );
    }


    /**
     * 获取今日各类型人员人次
     *
     * @param parkId 园区ID
     * @return
     */
    @GetMapping("/parkPeoples/getTodayPeopleCount")
    @ApiOperationSupport(order = 57)
    public R<PeopleTodayCountVo> getTodayPeopleCount(String parkId) {
        return R.data(iPeopleCountService.getTodayPeopleCount(parkId));
    }


    /**
     * 通过指定参数 分页查询报警信息
     * categoryCode 为空查询所有报警信息
     */
    @GetMapping("/info/getWarningByCategoryCode")
    @ApiOperationSupport(order = 58)
    @ApiOperation(value = "通过指定参数分页查询报警信息", notes = "传入设备类型(模块类型)")
    public R<IPage<PmgBatWarningInfo>> getWarningByCategoryCode(PmgBatSmartEquipment pmgBatSmartEquipment, Query query) {
        // 通过指定参数查询设备的 productKey(去重)
        List<String> productKeyList = pmgBatSmartEquipmentService.getProductKeyByCategoryCode(pmgBatSmartEquipment.getCategoryCode(),
                pmgBatSmartEquipment.getParkId(), pmgBatSmartEquipment.getBuildingId(),
                pmgBatSmartEquipment.getFloorId(), pmgBatSmartEquipment.getRoomId());
        // 通过productKey查询告警
        IPage<PmgBatWarningInfo> pages = iWarningInfoService.page(Condition.getPage(query),
                Wrappers.<PmgBatWarningInfo>lambdaQuery().in(productKeyList != null && productKeyList.size() > 0,
                        PmgBatWarningInfo::getProductKey, productKeyList).eq(PmgBatWarningInfo::getParkId, pmgBatSmartEquipment.getParkId())
                        .orderByDesc(PmgBatWarningInfo::getEventTime));
        return R.data(pages);
    }

    /**
     * 通过指定参数获取设备列表
     * @param pmgBatEquipment 设备对象
     * @return
     */
    @GetMapping("/info/getSmartEquipmentListBySome")
    @ApiOperationSupport(order = 59)
    @ApiOperation(value = "通过指定参数获取设备列表")
    public R<List<PmgBatSmartEquipment>> getSmartEquipmentListBySome(PmgBatSmartEquipment pmgBatEquipment) {
        return R.data(pmgBatSmartEquipmentService.list(Wrappers.<PmgBatSmartEquipment>lambdaQuery()
                .eq(PmgBatSmartEquipment::getParkId, pmgBatEquipment.getParkId())
                .eq(pmgBatEquipment.getBuildingId() != null, PmgBatSmartEquipment::getBuildingId, pmgBatEquipment.getBuildingId())
                .eq(pmgBatEquipment.getFloorId() != null, PmgBatSmartEquipment::getFloorId, pmgBatEquipment.getFloorId())
                .eq(pmgBatEquipment.getCategoryCode() != null, PmgBatSmartEquipment::getCategoryCode, pmgBatEquipment.getCategoryCode())
                .eq(pmgBatEquipment.getRoomId() != null, PmgBatSmartEquipment::getRoomId, pmgBatEquipment.getRoomId())));
    }
}

