package com.newfiber.api.pc.service.impl; import com.baomidou.mybatisplus.mapper.EntityWrapper; import com.baomidou.mybatisplus.plugins.Page; import com.baomidou.mybatisplus.service.impl.ServiceImpl; import com.newfiber.api.core.commons.CustomException; import com.newfiber.api.core.commons.PageRequestObject; import com.newfiber.api.core.commons.PageResultObject; import com.newfiber.api.core.commons.ResultCode; import com.newfiber.api.pc.dao.MeetAreaMapper; import com.newfiber.api.pc.dao.MeetAreaSiteMapper; import com.newfiber.api.pc.dao.monitoring.ProSiteInfoDao; import com.newfiber.api.pc.dto.SiteDTO; import com.newfiber.api.pc.model.entity.ProSiteInfoEntity; import com.newfiber.api.pc.model.meet.MeetArea; import com.newfiber.api.pc.model.meet.MeetAreaSite; import com.newfiber.api.pc.model.vo.MeetAreaSiteVo; import com.newfiber.api.pc.service.MeetAreaSiteService; import com.newfiber.api.pc.service.impl.monitoring.ProSiteInfoService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.StringUtils; import java.util.List; import java.util.stream.Collectors; /** * @description: 区域站点配置业务层实现类 * @author: 张鸿志 * @date: 2020/12/15 16:52 * @version: v1.0 */ @Service @Transactional(rollbackFor = Exception.class) public class MeetAreaSiteServiceImpl extends ServiceImpl<MeetAreaSiteMapper, MeetAreaSite> implements MeetAreaSiteService { @Autowired private ProSiteInfoService proSiteInfoService; @Autowired private MeetAreaMapper meetAreaMapper; @Override public PageResultObject<ProSiteInfoEntity> queryNoAreaSite(PageRequestObject<String> pageRequestObject) { Page<ProSiteInfoEntity> objectPage = new Page<>(pageRequestObject.getCurrent(), pageRequestObject.getSize()); List<MeetAreaSite> meetAreaSites = this.selectList(null); List<Integer> collect = meetAreaSites.stream().map(MeetAreaSite::getSiteId).collect(Collectors.toList()); EntityWrapper<ProSiteInfoEntity> wrapper = new EntityWrapper<>(); wrapper.notIn("site_no",collect); if(!StringUtils.isEmpty(pageRequestObject.getObject())){ wrapper.like("site_name",pageRequestObject.getObject()); } int count = proSiteInfoService.selectCount(wrapper); Page<ProSiteInfoEntity> infoEntityPage = proSiteInfoService.selectPage(objectPage, wrapper); return new PageResultObject<>(pageRequestObject.getCurrent(), pageRequestObject.getSize(),(long)count,infoEntityPage.getRecords()); } @Override public MeetArea queryAreaBySite(String siteNo) { if(StringUtils.isEmpty(siteNo)){ throw new CustomException(ResultCode.PARAM_NULL); } return meetAreaMapper.selectAreaBySiteNo(siteNo); } @Override public PageResultObject<ProSiteInfoEntity> queryPage(PageRequestObject<SiteDTO> pageRequestObject) { int current = (pageRequestObject.getCurrent() - 1) * pageRequestObject.getSize(); int size = pageRequestObject.getSize(); SiteDTO object = pageRequestObject.getObject(); if(StringUtils.isEmpty(object.getAreaId())){ throw new CustomException(ResultCode.PARAM_NULL); } int count = meetAreaMapper.queryAreaSiteCount(object.getAreaId(),object.getSiteName()); MeetAreaSiteVo vo = meetAreaMapper.queryAreaSitePage(object.getAreaId(),object.getSiteName(),current,size); return new PageResultObject<ProSiteInfoEntity>(current,size,(long)count,vo.getSiteInfos()); } @Override public List<MeetAreaSiteVo> queryAreaSite(String areaId) { if(StringUtils.isEmpty(areaId)){ throw new CustomException(ResultCode.PARAM_NULL); } return meetAreaMapper.queryAreaSite(areaId); } }