|  |  |  | 
|---|
|  |  |  | import com.doumee.core.utils.Constants; | 
|---|
|  |  |  | import com.doumee.core.utils.Utils; | 
|---|
|  |  |  | import com.doumee.dao.business.YwBuildingMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.YwFloorMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.YwProjectMapper; | 
|---|
|  |  |  | import com.doumee.dao.business.model.YwBuilding; | 
|---|
|  |  |  | import com.doumee.dao.business.model.YwFloor; | 
|---|
|  |  |  | import com.doumee.dao.business.model.YwProject; | 
|---|
|  |  |  | import com.doumee.service.business.YwBuildingService; | 
|---|
|  |  |  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | 
|---|
|  |  |  | 
|---|
|  |  |  | private YwBuildingMapper ywBuildingMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private YwProjectMapper ywProjectMapper; | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private YwFloorMapper ywFloorMapper; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public Integer create(YwBuilding model) { | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void deleteById(Integer id, LoginUserInfo user) { | 
|---|
|  |  |  | //查询楼宇下的数据 | 
|---|
|  |  |  | if(ywFloorMapper.selectCount(new QueryWrapper<YwFloor>().lambda().eq(YwFloor::getIsdeleted,Constants.ZERO) | 
|---|
|  |  |  | .eq(YwFloor::getBuildingId,id))>Constants.ZERO){ | 
|---|
|  |  |  | throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"楼宇中存在楼层数据!"); | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | YwBuilding model = new YwBuilding(); | 
|---|
|  |  |  | model.setId(id); | 
|---|
|  |  |  | model.setEditDate(new Date()); | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public YwBuilding findById(Integer id) { | 
|---|
|  |  |  | return ywBuildingMapper.selectById(id); | 
|---|
|  |  |  | MPJLambdaWrapper<YwBuilding> queryWrapper = new MPJLambdaWrapper<>(); | 
|---|
|  |  |  | queryWrapper.selectAll(YwBuilding.class ) | 
|---|
|  |  |  | .selectAs(YwProject::getName,YwBuilding::getProjectName) | 
|---|
|  |  |  | .select(" (select ifnull(sum(y.FEE_AREA),0) from yw_room y where y.ISDELETED = 0 and y.status = 0 and y.IS_INVESTMENT = 1 and y.BUILDING_ID = t.id ) ",YwBuilding::getRoomFeeArea) | 
|---|
|  |  |  | .select(" (select ifnull(sum(y.RENT_AREA),0) from yw_room y where y.ISDELETED = 0 and y.status = 0 and y.IS_INVESTMENT = 1 and y.BUILDING_ID = t.id ) ",YwBuilding::getRoomRentArea) | 
|---|
|  |  |  | .select("",YwBuilding::getRoomFeeArea) | 
|---|
|  |  |  | .leftJoin(YwProject.class,YwProject::getId,YwBuilding::getProjectId) | 
|---|
|  |  |  | .eq(YwBuilding::getId,id) | 
|---|
|  |  |  | .last(" limit 1 ") | 
|---|
|  |  |  | ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return ywBuildingMapper.selectJoinOne(YwBuilding.class, queryWrapper); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | 
|---|
|  |  |  | .leftJoin(YwProject.class,YwProject::getId,YwBuilding::getProjectId); | 
|---|
|  |  |  | Utils.MP.blankToNull(pageWrap.getModel()); | 
|---|
|  |  |  | pageWrap.getModel().setIsdeleted(Constants.ZERO); | 
|---|
|  |  |  | queryWrapper.select("*,(select count(1) from yw_room a where a.isdeleted=0 and a.BUILDING_ID=t.id) as roomNum"+ | 
|---|
|  |  |  | ",(select count(1) from yw_room a where a.isdeleted=0 and a.BUILDING_ID=t.id and a.IS_INVESTMENT=1) as roomRentNum"); | 
|---|
|  |  |  | queryWrapper.select(" (select count(1) from yw_room a where a.isdeleted=0 and a.BUILDING_ID=t.id) as roomNum "+ | 
|---|
|  |  |  | ",(select count(1) from yw_room a where a.isdeleted=0 and a.BUILDING_ID=t.id and a.IS_INVESTMENT=1) as roomRentNum " + | 
|---|
|  |  |  | ", ( select ifnull(sum(a.RENT_AREA),0) from  yw_room a where a.isdeleted=0 and a.BUILDING_ID=t.id ) as manageArea"); | 
|---|
|  |  |  | if (pageWrap.getModel().getId() != null) { | 
|---|
|  |  |  | queryWrapper.eq(YwBuilding::getId, pageWrap.getModel().getId()); | 
|---|
|  |  |  | } | 
|---|