renkang
2024-12-03 b81c72d58016bb15d2d47331da258e621245cfb5
server/visits/dmvisit_service/src/main/java/com/doumee/service/business/impl/YwProjectServiceImpl.java
@@ -1,5 +1,7 @@
package com.doumee.service.business.impl;
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;
@@ -19,6 +21,7 @@
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.apache.commons.lang3.StringUtils;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
@@ -28,6 +31,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
/**
 * 运维项目信息表Service实现
@@ -53,6 +57,15 @@
    @Override
    public Integer create(YwProject  model) {
        if(Objects.isNull(model)
        || StringUtils.isBlank(model.getName())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        if(ywProjectMapper.selectCount(new QueryWrapper<YwProject>().lambda()
                .eq(YwProject::getName,model.getName())
                .eq(YwProject::getIsdeleted,Constants.ZERO))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+model.getName()+"】已存在!");
        }
        model.setCreator(model.getLoginUserInfo().getId());
        model.setIsdeleted(Constants.ZERO);
        model.setCreateDate(new Date());
@@ -65,6 +78,11 @@
    @Override
    public void deleteById(Integer id, LoginUserInfo user) {
        //查询项目下的数据
        if(ywBuildingMapper.selectCount(new QueryWrapper<YwBuilding>().lambda().eq(YwBuilding::getIsdeleted,Constants.ZERO)
                .eq(YwBuilding::getProjectId,id))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"项目下存在楼宇数据!");
        };
        YwProject model = new YwProject();
        model.setId(id);
        model.setEditDate(new Date());
@@ -91,6 +109,17 @@
    @Override
    public void updateById(YwProject model) {
        if(Objects.isNull(model)
                || Objects.isNull(model.getId())
                || StringUtils.isBlank(model.getName())){
            throw new BusinessException(ResponseStatus.BAD_REQUEST);
        }
        if(ywProjectMapper.selectCount(new QueryWrapper<YwProject>().lambda()
                .eq(YwProject::getName,model.getName())
                .ne(YwProject::getId,model.getId())
                .eq(YwProject::getIsdeleted,Constants.ZERO))>Constants.ZERO){
            throw new BusinessException(ResponseStatus.NOT_ALLOWED.getCode(),"【"+model.getName()+"】已存在!");
        }
        model.setEditDate(new Date());
        model.setEditor(model.getLoginUserInfo().getId());
        ywProjectMapper.updateById(model);
@@ -131,7 +160,8 @@
        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.PROJECT_ID=yw_project.id) as roomNum"+
                ",(select count(1) from yw_room a where a.isdeleted=0 and a.PROJECT_ID=yw_project.id and a.IS_INVESTMENT=1) as roomRentNum");
                ",(select count(1) from yw_room a where a.isdeleted=0 and a.PROJECT_ID=yw_project.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.PROJECT_ID=yw_project.id ) as area");
        if (pageWrap.getModel().getId() != null) {
            queryWrapper.lambda().eq(YwProject::getId, pageWrap.getModel().getId());
        }