cjl
2023-12-25 2ab4d484c09bf29d5f63dafb0fec3eda23bc4b4e
screen-api/src/main/java/com/moral/api/service/impl/OrganizationServiceImpl.java
@@ -1,17 +1,27 @@
package com.moral.api.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.moral.api.config.Interceptor.UserHelper;
import com.moral.api.entity.MonitorPoint;
import com.moral.api.entity.Organization;
import com.moral.api.mapper.MonitorPointMapper;
import com.moral.api.mapper.OrganizationMapper;
import com.moral.api.pojo.vo.user.QxUser;
import com.moral.api.service.DeviceService;
import com.moral.api.service.MonitorPointService;
import com.moral.api.service.OrganizationService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.moral.constant.Constants;
import com.moral.util.TokenUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
 * <p>
@@ -28,6 +38,7 @@
    OrganizationMapper organizationMapper;
    @Override
    public List<Organization> getChildrenOrganizationsById(Integer id) {
        List<Organization> childrenOrganization = new ArrayList<>();
@@ -36,14 +47,11 @@
    }
    @Override
    public Organization getStateControlStation() {
        QueryWrapper<Organization> wrapper = new QueryWrapper<>();
        wrapper.select("id");
        wrapper.eq("name","国控站");
        wrapper.eq("is_delete",Constants.NOT_DELETE);
        Organization organization = organizationMapper.selectOne(wrapper);
        return organization;
    public Organization getOrganizationById(Integer id) {
        return organizationMapper.selectById(id);
    }
    /**
    * @Description: 通过父组织查询下面所有的子组织放到children中
@@ -67,4 +75,35 @@
            return;
        }
    }
    @Override
    public List<Integer> orgIdList(Integer organizationId) {
        return this.baseMapper.orgIdList(organizationId);
    }
    /**
     * 根据id获取组织信息
     *
     * @param
     * @return
     */
    @Override
    public List<Organization> getOrganizationId() {
        //获取用户信息
        Map<String, Object> userInfo = (Map<String, Object>) TokenUtils.getUserInfo();
        Map<String, Object> orgInfo = (Map<String, Object>) userInfo.get("organization");
        Integer organizationId = (Integer) orgInfo.get("id");
         ArrayList<Organization> rsList = new ArrayList<>();
        if (organizationId==24){
            LambdaQueryWrapper<Organization> wrapper = new LambdaQueryWrapper<>();
            wrapper.eq(Organization::getParentId,organizationId);
            wrapper.eq(Organization::getIsDelete,Constants.NOT_DELETE);
            List<Organization> organizations = organizationMapper.selectList(wrapper);
            rsList.addAll(organizations);
        }else {
            Organization organizationById = this.getOrganizationById(organizationId);
            rsList.add(organizationById);
        }
        return rsList;
    }
}