jiangping
2025-06-06 a2299a6d4a6f99e9c11132138f5d3e9ec68f03ea
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwDeviceServiceImpl.java
@@ -1,20 +1,40 @@
package com.doumee.service.business.impl;
import com.doumee.biz.system.SystemDictDataBiz;
import com.doumee.core.constants.ResponseStatus;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.LoginUserInfo;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Constants;
import com.doumee.core.utils.DateUtil;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.YwDeviceMapper;
import com.doumee.dao.business.model.YwDevice;
import com.doumee.dao.business.YwDeviceRecordMapper;
import com.doumee.dao.business.model.*;
import com.doumee.dao.business.vo.YwDeviceCateDataVO;
import com.doumee.dao.business.vo.YwDeviceDataVO;
import com.doumee.dao.business.vo.YwDeviceParentCateDataVO;
import com.doumee.dao.business.vo.YwDeviceStatusDataVO;
import com.doumee.dao.system.MultifileMapper;
import com.doumee.dao.system.model.Multifile;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.YwDeviceRecordService;
import com.doumee.service.business.YwDeviceService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import lombok.extern.java.Log;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
import java.util.List;
import java.util.*;
import java.util.stream.Collectors;
/**
 * 运维设备信息表Service实现
@@ -27,15 +47,87 @@
    @Autowired
    private YwDeviceMapper ywDeviceMapper;
    @Autowired
    private SystemDictDataBiz systemDictDataBiz;
    @Autowired
    private MultifileMapper multifileMapper;
    @Autowired
    private YwDeviceRecordMapper ywDeviceRecordMapper;
    @Autowired
    private RedisTemplate<String,Object> redisTemplate;
    @Override
    public Integer create(YwDevice ywDevice) {
        if(Objects.isNull(ywDevice)
            || StringUtils.isBlank(ywDevice.getName())
            || StringUtils.isBlank(ywDevice.getCode())
            || Objects.isNull(ywDevice.getStatus())
            || Objects.isNull(ywDevice.getProjectId())
            || Objects.isNull(ywDevice.getFloorId())
            || Objects.isNull(ywDevice.getBuildingId())
            || Objects.isNull(ywDevice.getRoomId())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo loginUserInfo = ywDevice.getLoginUserInfo();
        if(ywDeviceMapper.selectCount(new QueryWrapper<YwDevice>().lambda().eq(YwDevice::getIsdeleted,Constants.ZERO).eq(YwDevice::getCode,ywDevice.getCode()))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"设备编号重复!");
        }
        ywDevice.setCreateDate(new Date());
        ywDevice.setCreator(loginUserInfo.getId());
        ywDevice.setIsdeleted(Constants.ZERO);
        ywDeviceMapper.insert(ywDevice);
        if(Objects.nonNull(ywDevice.getFileUrl())){
            Multifile multifile = new Multifile();
            multifile.setCreator(loginUserInfo.getId());
            multifile.setCreateDate(new Date());
            multifile.setIsdeleted(Constants.ZERO);
            multifile.setObjType(Constants.MultiFile.FN_DEVICE_FILE.getKey());
            multifile.setObjId(ywDevice.getId());
            multifile.setFileurl(ywDevice.getFileUrl());
            multifileMapper.insert(multifile);
        }
        List<Multifile> fileList = new ArrayList<>();
        if(ywDevice.getMultifileList()!=null && ywDevice.getMultifileList().size()>0){
            for (int i = 0; i <  ywDevice.getMultifileList().size(); i++) {
                Multifile multifile =  ywDevice.getMultifileList().get(i);
                if(StringUtils.isBlank(multifile.getFileurl())){
                    continue;
                }
                multifile.setCreateDate(ywDevice.getCreateDate());
                multifile.setEditDate(ywDevice.getCreateDate());
                multifile.setCreator(ywDevice.getCreator());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(ywDevice.getId());
                multifile.setEditor(ywDevice.getCreator());
                multifile.setObjType(Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey());
                multifile.setSortnum(i+1);
                fileList.add(multifile);
            }
        }
        if(fileList.size()>0){
            multifileMapper.insert(fileList);
        }
        return ywDevice.getId();
    }
    @Override
    public void deleteById(Integer id) {
        ywDeviceMapper.deleteById(id);
    public void deleteById(Integer id, LoginUserInfo user) {
        //查询设备是否存在运维记录
        if(ywDeviceRecordMapper.selectCount(new QueryWrapper<YwDeviceRecord>().lambda().eq(YwDeviceRecord::getDeviceId,id).eq(YwDeviceRecord::getIsdeleted,Constants.ZERO))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"当前设备存在运维记录,无法删除");
        };
        ywDeviceMapper.update(new UpdateWrapper<YwDevice>()
                .lambda().set(YwDevice::getIsdeleted,Constants.ONE)
                .set(YwDevice::getEditDate, DateUtil.getCurrDateTime())
                .set(YwDevice::getEditor,user.getId())
                .eq(YwDevice::getId,id)
        );
    }
    @Override
@@ -45,7 +137,7 @@
    }
    @Override
    public void deleteByIdInBatch(List<Integer> ids) {
    public void deleteByIdInBatch(List<Integer> ids, LoginUserInfo user) {
        if (CollectionUtils.isEmpty(ids)) {
            return;
        }
@@ -54,7 +146,64 @@
    @Override
    public void updateById(YwDevice ywDevice) {
        if(Objects.isNull(ywDevice)
                || StringUtils.isBlank(ywDevice.getName())
                || StringUtils.isBlank(ywDevice.getCode())
                || Objects.isNull(ywDevice.getStatus())
                || Objects.isNull(ywDevice.getProjectId())
                || Objects.isNull(ywDevice.getFloorId())
                || Objects.isNull(ywDevice.getBuildingId())
                || Objects.isNull(ywDevice.getRoomId())
        ){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        LoginUserInfo loginUserInfo = ywDevice.getLoginUserInfo();
        if(ywDeviceMapper.selectCount(new QueryWrapper<YwDevice>().lambda().eq(YwDevice::getIsdeleted,Constants.ZERO)
                .eq(YwDevice::getCode,ywDevice.getCode())
                .ne(YwDevice::getId,ywDevice.getId()))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"设备编号重复!");
        }
        ywDevice.setEditDate(new Date());
        ywDevice.setEditor(loginUserInfo.getId());
        ywDeviceMapper.updateById(ywDevice);
        multifileMapper.delete(new QueryWrapper<Multifile>().lambda()
                .eq(Multifile::getObjId,ywDevice.getId())
                .in(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_FILE.getKey(),Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey())
        );
        if(Objects.nonNull(ywDevice.getFileUrl())){
            Multifile multifile = new Multifile();
            multifile.setCreator(loginUserInfo.getId());
            multifile.setCreateDate(new Date());
            multifile.setIsdeleted(Constants.ZERO);
            multifile.setObjType(Constants.MultiFile.FN_DEVICE_FILE.getKey());
            multifile.setObjId(ywDevice.getId());
            multifile.setFileurl(ywDevice.getFileUrl());
            multifileMapper.insert(multifile);
        }
        List<Multifile> fileList = new ArrayList<>();
        if(ywDevice.getMultifileList()!=null && ywDevice.getMultifileList().size()>0){
            for (int i = 0; i <  ywDevice.getMultifileList().size(); i++) {
                Multifile multifile =  ywDevice.getMultifileList().get(i);
                if(StringUtils.isBlank(multifile.getFileurl())){
                    continue;
                }
                multifile.setCreateDate(ywDevice.getCreateDate());
                multifile.setEditDate(ywDevice.getCreateDate());
                multifile.setCreator(ywDevice.getEditor());
                multifile.setIsdeleted(Constants.ZERO);
                multifile.setObjId(ywDevice.getId());
                multifile.setEditor(ywDevice.getCreator());
                multifile.setObjType(Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey());
                multifile.setSortnum(i+1);
                fileList.add(multifile);
            }
        }
        if(fileList.size()>0){
            multifileMapper.insert(fileList);
        }
    }
    @Override
@@ -73,6 +222,85 @@
    }
    @Override
    public YwDevice getDetail(Integer id) {
        YwDevice ywDevice = ywDeviceMapper.selectJoinOne(YwDevice.class,
                new MPJLambdaWrapper<YwDevice>()
                .selectAll(YwDevice.class)
                        .select("c.name",YwDevice::getCategoryName)
                        .select("c1.name",YwDevice::getCategoryParentName)
                        .select("s.realname",YwDevice::getRealName)
                        .select("s1.realname",YwDevice::getMaintenanceUserName)
                        .selectAs(YwProject::getName,YwDevice::getProjectName)
                        .selectAs(YwFloor::getName,YwDevice::getFloorName)
                        .selectAs(YwBuilding::getName,YwDevice::getBuildingName)
                        .selectAs(YwRoom::getCode,YwDevice::getRoomName)
                        .leftJoin(YwRoom.class,YwRoom::getId,YwDevice::getRoomId)
                        .leftJoin(YwFloor.class,YwFloor::getId,YwRoom::getFloor)
                        .leftJoin(YwProject.class,YwProject::getId,YwRoom::getProjectId)
                        .leftJoin(YwBuilding.class,YwBuilding::getId,YwRoom::getBuildingId)
                        .leftJoin("category c on t.CATE_ID = c.id")
                        .leftJoin("category c1 on c.PARENT_ID = c1.id")
                        .leftJoin("system_user s on t.user_id = s.id")
                        .leftJoin("system_user s1 on t.MAINTENANCE_USER_ID = s1.id")
                        .eq(YwDevice::getId,id)
                        .last(" limit 1 ")
        );
        Multifile multifile = multifileMapper.selectOne(new QueryWrapper<Multifile>().lambda()
                .eq(Multifile::getObjId,id).eq(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_FILE.getKey()).last(" limit 1"));
        if(Objects.nonNull(multifile)){
            String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode()
                    +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_DEVICE).getCode();
            ywDevice.setFileFullUrl(path + multifile.getFileurl());
        }
        //附件数据
        List<Multifile> multifileList = multifileMapper.selectJoinList(Multifile.class,new MPJLambdaWrapper<Multifile>()
                .selectAll(Multifile.class)
                .selectAs(SystemUser::getRealname,Multifile::getUserName)
                .leftJoin(SystemUser.class,SystemUser::getId,Multifile::getCreator)
                .eq(Multifile::getObjId,ywDevice.getId())
                .eq(Multifile::getIsdeleted,Constants.ZERO)
                .eq(Multifile::getObjType,Constants.MultiFile.FN_DEVICE_MAINTENANCE_FILE.getKey()));
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(multifileList)){
            String path = systemDictDataBiz.queryByCode(Constants.FTP,Constants.FTP_RESOURCE_PATH).getCode()
                    +systemDictDataBiz.queryByCode(Constants.FTP,Constants.YW_PATROL).getCode();
            for (Multifile m:multifileList) {
                if(StringUtils.isNotBlank(m.getFileurl())){
                    m.setFileurlFull(path + m.getFileurl());
                }
            }
            ywDevice.setMultifileList(multifileList);
        }
        return ywDevice;
    }
    /**
     * 根据编码查询
     * @param deviceCode
     * @return
     */
    @Override
    public YwDevice findByCode(String deviceCode) {
        YwDevice ywDevice =  ywDeviceMapper.selectOne(
                new QueryWrapper<YwDevice>()
                        .lambda()
                        .eq(YwDevice::getIsdeleted,Constants.ZERO)
                        .eq(YwDevice::getCode,deviceCode)
                        .last(" limit  1 ")
        );
        if(Objects.isNull(ywDevice)){
            throw new BusinessException(ResponseStatus.DATA_EMPTY);
        }
        return ywDevice;
    }
    @Override
    public YwDevice findOne(YwDevice ywDevice) {
        QueryWrapper<YwDevice> wrapper = new QueryWrapper<>(ywDevice);
        return ywDeviceMapper.selectOne(wrapper);
@@ -87,70 +315,29 @@
    @Override
    public PageData<YwDevice> findPage(PageWrap<YwDevice> pageWrap) {
        IPage<YwDevice> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        QueryWrapper<YwDevice> queryWrapper = new QueryWrapper<>();
        MPJLambdaWrapper<YwDevice> queryWrapper = new MPJLambdaWrapper<YwDevice>();
        Utils.MP.blankToNull(pageWrap.getModel());
        if (pageWrap.getModel().getId() != null) {
            queryWrapper.lambda().eq(YwDevice::getId, pageWrap.getModel().getId());
        }
        if (pageWrap.getModel().getCreator() != null) {
            queryWrapper.lambda().eq(YwDevice::getCreator, pageWrap.getModel().getCreator());
        }
        if (pageWrap.getModel().getCreateDate() != null) {
            queryWrapper.lambda().ge(YwDevice::getCreateDate, Utils.Date.getStart(pageWrap.getModel().getCreateDate()));
            queryWrapper.lambda().le(YwDevice::getCreateDate, Utils.Date.getEnd(pageWrap.getModel().getCreateDate()));
        }
        if (pageWrap.getModel().getEditor() != null) {
            queryWrapper.lambda().eq(YwDevice::getEditor, pageWrap.getModel().getEditor());
        }
        if (pageWrap.getModel().getEditDate() != null) {
            queryWrapper.lambda().ge(YwDevice::getEditDate, Utils.Date.getStart(pageWrap.getModel().getEditDate()));
            queryWrapper.lambda().le(YwDevice::getEditDate, Utils.Date.getEnd(pageWrap.getModel().getEditDate()));
        }
        if (pageWrap.getModel().getIsdeleted() != null) {
            queryWrapper.lambda().eq(YwDevice::getIsdeleted, pageWrap.getModel().getIsdeleted());
        }
        if (pageWrap.getModel().getName() != null) {
            queryWrapper.lambda().eq(YwDevice::getName, pageWrap.getModel().getName());
        }
        if (pageWrap.getModel().getRemark() != null) {
            queryWrapper.lambda().eq(YwDevice::getRemark, pageWrap.getModel().getRemark());
        }
        if (pageWrap.getModel().getStatus() != null) {
            queryWrapper.lambda().eq(YwDevice::getStatus, pageWrap.getModel().getStatus());
        }
        if (pageWrap.getModel().getSortnum() != null) {
            queryWrapper.lambda().eq(YwDevice::getSortnum, pageWrap.getModel().getSortnum());
        }
        if (pageWrap.getModel().getModelNo() != null) {
            queryWrapper.lambda().eq(YwDevice::getModelNo, pageWrap.getModel().getModelNo());
        }
        if (pageWrap.getModel().getCateId() != null) {
            queryWrapper.lambda().eq(YwDevice::getCateId, pageWrap.getModel().getCateId());
        }
        if (pageWrap.getModel().getUserId() != null) {
            queryWrapper.lambda().eq(YwDevice::getUserId, pageWrap.getModel().getUserId());
        }
        if (pageWrap.getModel().getCompany() != null) {
            queryWrapper.lambda().ge(YwDevice::getCompany, Utils.Date.getStart(pageWrap.getModel().getCompany()));
            queryWrapper.lambda().le(YwDevice::getCompany, Utils.Date.getEnd(pageWrap.getModel().getCompany()));
        }
        if (pageWrap.getModel().getContent() != null) {
            queryWrapper.lambda().eq(YwDevice::getContent, pageWrap.getModel().getContent());
        }
        if (pageWrap.getModel().getCode() != null) {
            queryWrapper.lambda().eq(YwDevice::getCode, pageWrap.getModel().getCode());
        }
        if (pageWrap.getModel().getAddr() != null) {
            queryWrapper.lambda().eq(YwDevice::getAddr, pageWrap.getModel().getAddr());
        }
        for(PageWrap.SortData sortData: pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        return PageData.from(ywDeviceMapper.selectPage(page, queryWrapper));
        YwDevice model = pageWrap.getModel();
        queryWrapper.selectAll(YwDevice.class)
                .select("c.name",YwDevice::getCategoryName)
                .select("c1.name",YwDevice::getCategoryParentName)
                .select("s.realname",YwDevice::getRealName)
                .select("s1.realname",YwDevice::getMaintenanceUserName)
                .leftJoin("category c on t.CATE_ID = c.id")
                .leftJoin("category c1 on c.PARENT_ID = c1.id")
                .leftJoin("system_user s on t.user_id = s.id")
                .leftJoin("system_user s1 on t.MAINTENANCE_USER_ID = s1.id")
                .and(Objects.nonNull(model)&&StringUtils.isNotBlank(model.getName()),i->i.like(YwDevice::getName,model.getName()).or().like(YwDevice::getCode,model.getName()))
                .eq(Objects.nonNull(model.getStatus()),YwDevice::getStatus,model.getStatus())
                .eq(Objects.nonNull(model.getRoomId()),YwDevice::getRoomId,model.getRoomId())
                .eq(Objects.nonNull(model.getFloorId()),YwDevice::getFloorId,model.getFloorId())
                .eq(Objects.nonNull(model.getProjectId()),YwDevice::getProjectId,model.getProjectId())
                .eq(Objects.nonNull(model.getBuildingId()),YwDevice::getBuildingId,model.getBuildingId())
                .eq(YwDevice::getIsdeleted,Constants.ZERO)
                .orderByDesc(YwDevice::getCreateDate)
        ;
        IPage iPage = ywDeviceMapper.selectJoinPage(page,YwDevice.class,queryWrapper);
        return PageData.from(iPage);
    }
    @Override
@@ -158,4 +345,101 @@
        QueryWrapper<YwDevice> wrapper = new QueryWrapper<>(ywDevice);
        return ywDeviceMapper.selectCount(wrapper);
    }
    @Override
    public YwDeviceDataVO getYwDeviceData(){
        YwDeviceDataVO ywDeviceDataVO = new YwDeviceDataVO();
        List<YwDevice> ywDeviceList = ywDeviceMapper.selectList(new QueryWrapper<YwDevice>().lambda().eq(YwDevice::getIsdeleted,Constants.ZERO));
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(ywDeviceList)){
            ywDeviceDataVO.setQualityNum(ywDeviceList.size());
            ywDeviceDataVO.setTotalNum(ywDeviceList.size());
            ywDeviceDataVO.setNormalNum(ywDeviceList.stream().filter(i->Constants.equalsInteger(i.getStatus(),Constants.ZERO)).collect(Collectors.toList()).size());
            ywDeviceDataVO.setAbnormalNum(ywDeviceList.stream().filter(i->Constants.equalsInteger(i.getStatus(),Constants.ONE)).collect(Collectors.toList()).size());
            ywDeviceDataVO.setScrapNum(ywDeviceList.stream().filter(i->Constants.equalsInteger(i.getStatus(),Constants.TWO)).collect(Collectors.toList()).size());
        }
        return ywDeviceDataVO;
    }
    @Override
    public Set<YwDeviceParentCateDataVO> getDeviceCateData(YwDevice model){
        MPJLambdaWrapper<YwDevice> queryWrapper = new MPJLambdaWrapper<YwDevice>();
        queryWrapper.selectAll(YwDevice.class)
                .select("c.name",YwDevice::getCategoryName)
                .select("c1.name",YwDevice::getCategoryParentName)
                .select("c1.id",YwDevice::getCateParentId)
                .selectAs(SystemUser::getRealname,YwDevice::getRealName)
                .leftJoin(SystemUser.class,SystemUser::getId,YwDevice::getUserId)
                .leftJoin("category c on t.CATE_ID = c.id")
                .leftJoin("category c1 on c.PARENT_ID = c1.id")
                .eq(Objects.nonNull(model.getRoomId()),YwDevice::getRoomId,model.getRoomId())
                .eq(Objects.nonNull(model.getFloorId()),YwDevice::getFloorId,model.getFloorId())
                .eq(Objects.nonNull(model.getProjectId()),YwDevice::getProjectId,model.getProjectId())
                .eq(Objects.nonNull(model.getBuildingId()),YwDevice::getBuildingId,model.getBuildingId())
                .eq(YwDevice::getIsdeleted,Constants.ZERO)
                .isNotNull(YwDevice::getCateId)
                .orderByDesc(YwDevice::getCreateDate)
        ;
        List<YwDevice> ywDeviceList = ywDeviceMapper.selectJoinList(YwDevice.class,queryWrapper);
        Set<YwDeviceCateDataVO> ywDeviceCateDataVOSet = new HashSet<>();
        Set<YwDeviceParentCateDataVO> ywDeviceParentCateDataVOSet = new HashSet<>();
        for (YwDevice y: ywDeviceList) {
            YwDeviceCateDataVO ywDeviceCateDataVO = new YwDeviceCateDataVO();
            ywDeviceCateDataVO.setCateId(y.getCateId());
            ywDeviceCateDataVO.setCateName(y.getCategoryName());
            ywDeviceCateDataVO.setCateParentId(y.getCateParentId());
            ywDeviceCateDataVOSet.add(ywDeviceCateDataVO);
            YwDeviceParentCateDataVO ywDeviceParentCateDataVO = new YwDeviceParentCateDataVO();
            ywDeviceParentCateDataVO.setCateId(y.getCateParentId());
            ywDeviceParentCateDataVO.setCateName(y.getCategoryParentName());
            ywDeviceParentCateDataVOSet.add(ywDeviceParentCateDataVO);
        }
        for (YwDeviceCateDataVO ywDeviceCateDataVO:ywDeviceCateDataVOSet) {
            ywDeviceCateDataVO.setDeviceAmount(
                    ywDeviceList.stream().filter(i->Objects.nonNull(i.getCateId()) && Constants.equalsInteger(i.getCateId(),ywDeviceCateDataVO.getCateId())).collect(Collectors.toList()).size()
            );
        }
        for (YwDeviceParentCateDataVO ywDeviceParentCateDataVO:ywDeviceParentCateDataVOSet) {
            ywDeviceParentCateDataVO.setDeviceAmount(
                    ywDeviceList.stream().filter(i->Objects.nonNull(i.getCateParentId()) && Constants.equalsInteger(i.getCateParentId(),ywDeviceParentCateDataVO.getCateId())).collect(Collectors.toList()).size()
            );
            ywDeviceParentCateDataVO.setYwDeviceCateDataVOList(
                    ywDeviceCateDataVOSet.stream().filter(i->Constants.equalsInteger(i.getCateParentId(),ywDeviceParentCateDataVO.getCateId())).collect(Collectors.toList())
            );
        }
        return ywDeviceParentCateDataVOSet;
    }
    @Override
    public YwDeviceStatusDataVO getDeviceStatus(YwDevice model){
        YwDeviceStatusDataVO ywDeviceStatusDataVO = new YwDeviceStatusDataVO();
        MPJLambdaWrapper<YwDevice> queryWrapper = new MPJLambdaWrapper<YwDevice>();
        queryWrapper.selectAll(YwDevice.class)
                .eq(Objects.nonNull(model.getRoomId()),YwDevice::getRoomId,model.getRoomId())
                .eq(Objects.nonNull(model.getFloorId()),YwDevice::getFloorId,model.getFloorId())
                .eq(Objects.nonNull(model.getProjectId()),YwDevice::getProjectId,model.getProjectId())
                .eq(Objects.nonNull(model.getBuildingId()),YwDevice::getBuildingId,model.getBuildingId())
                .eq(YwDevice::getIsdeleted,Constants.ZERO)
        ;
        List<YwDevice> ywDeviceList = ywDeviceMapper.selectJoinList(YwDevice.class,queryWrapper);
        ywDeviceStatusDataVO.setAmount(ywDeviceList.size());
        ywDeviceStatusDataVO.setWorkAmount(ywDeviceList.stream().filter(i->Objects.nonNull(i.getStatus())&&Constants.equalsInteger(i.getStatus(),Constants.ZERO)).collect(Collectors.toList()).size());
        ywDeviceStatusDataVO.setExceptionAmount(ywDeviceList.stream().filter(i->Objects.nonNull(i.getStatus())&&Constants.equalsInteger(i.getStatus(),Constants.ONE)).collect(Collectors.toList()).size());
        ywDeviceStatusDataVO.setErrAmount(ywDeviceList.stream().filter(i->Objects.nonNull(i.getStatus())&&Constants.equalsInteger(i.getStatus(),Constants.TWO)).collect(Collectors.toList()).size());
        return ywDeviceStatusDataVO;
    }
}