于紫祥_1901
2020-12-02 da0abda12d95d701f8873db506136898e66fef8e
src/main/java/com/moral/service/impl/AccountServiceImpl.java
@@ -11,9 +11,13 @@
import java.util.Set;
import javax.annotation.Resource;
import javax.management.monitor.Monitor;
import com.moral.entity.*;
import com.moral.mapper.DictionaryDataMapper;
import com.moral.mapper.MonitorPointMapper;
import com.moral.service.MonitorPointService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.stereotype.Service;
@@ -55,6 +59,11 @@
    @Resource
    private OrganizationMapper organizationMapper;
    @Resource
    private MonitorPointService monitorPointService;
    @Resource
    private MonitorPointMapper monitorPointMapper;
    @Override
    public Map<String, Object> getAccountInfoById(String accountId) {
@@ -67,12 +76,31 @@
            result.put("accountId", -1);
        } else {
            result = judgeAccountInfo(account);
            String regionCode = getRegionCodeByAccount(account);
            if (!String.valueOf(result.get("accountId")).equals("-1")) {
                List<MonitorPoint> monitorPoints = new ArrayList<>();
                if (account.getOrganizationId().equals(dictionaryDataMapper.selectSupperOrgId())) {
                    Map<String, Object> paramMap = new HashMap<>();
                    paramMap.put("regionCode", regionCode);
                    paramMap.put("organizationId", account.getOrganizationId());
                    monitorPoints = monitorPointService.getMonitorPointsAndDevicesByRegion(paramMap);
                } else {
                    Set<Integer> orgIds = organizationService.getChildOrganizationIds(account.getOrganizationId());
                    orgIds.add(account.getOrganizationId());
                    monitorPoints = monitorPointService.getMonitorPointsByOrganizationIds(orgIds);
                }
                List<Integer> monitorPointIds = new ArrayList<>();
                monitorPoints.forEach(value -> {
                    monitorPointIds.add(value.getId());
                });
                List<Menu> menuList = accountMapper.getScreenMenuListsByAccountName(account.getAccountName());
                result.put("msg", "获取成功!");
                result.put("accountId", account.getId());
                result.put("orgId", account.getOrganizationId());
                result.put("data", menuList);
                result.put("regionCode", regionCode);
                result.put("monitorPointIds", monitorPointIds);
                setOrgIdsByAccount(result);
            }
        }
@@ -396,11 +424,6 @@
            result.put("accountId", -1);
        } else {
            result = judgeAccountInfo(account);
            if (!result.get("accountId").equals(-1)){
                String regionCode = getRegionCodeByAccount(account);
                if(!ObjectUtils.isEmpty(regionCode))
                    result.put("regionCode",regionCode);
            }
        }
        return result;
@@ -409,7 +432,7 @@
    /**
     * @Description: 根据id获取默认显示的地区码
     * @Param: [params]
     * @return: java.util.Map<java.lang.String               ,               java.lang.Object>
     * @return: java.util.Map<java.lang.String                                                                                                                                                                                                                                                               ,                                                                                                                                                                                                                                                               java.lang.Object>
     * @Author: 下雨听风
     * @Date: 2020/11/25
     */
@@ -418,13 +441,13 @@
        organization.setId(account.getOrganizationId());
        organization = organizationMapper.selectOne(organization);
        Map<String, Object> regionCodeAndType = getRegionCodeAndTypeByOrg(organization);
        if(ObjectUtils.isEmpty(regionCodeAndType))
        if (ObjectUtils.isEmpty(regionCodeAndType))
            return null;
        return (String) regionCodeAndType.get("regionCode");
    }
    public static Map<String,Object> getRegionCodeAndTypeByOrg(Organization organization){
        Map<String,Object> result = new HashMap<>();
    public Map<String, Object> getRegionCodeAndTypeByOrg(Organization organization) {
        Map<String, Object> result = new HashMap<>();
        String regionCode = "";
        String regionType = "";
        Long villageCode = organization.getVillageCode();
@@ -433,26 +456,26 @@
        Integer cityCode = organization.getCityCode();
        Integer provinceCode = organization.getProvinceCode();
        if(!ObjectUtils.isEmpty(villageCode)){
        if (!ObjectUtils.isEmpty(villageCode)) {
            regionCode = String.valueOf(villageCode);
            regionType = "village";
        }else if(!ObjectUtils.isEmpty(townCode)){
        } else if (!ObjectUtils.isEmpty(townCode)) {
            regionCode = String.valueOf(townCode);
            regionType = "town";
        }else if(!ObjectUtils.isEmpty(areaCode)){
        } else if (!ObjectUtils.isEmpty(areaCode)) {
            regionCode = String.valueOf(areaCode);
            regionType = "area";
        }else if(!ObjectUtils.isEmpty(cityCode)){
        } else if (!ObjectUtils.isEmpty(cityCode)) {
            regionCode = String.valueOf(cityCode);
            regionType = "city";
        }else if(!ObjectUtils.isEmpty(provinceCode)){
        } else if (!ObjectUtils.isEmpty(provinceCode)) {
            regionCode = String.valueOf(provinceCode);
            regionType = "province";
        }else{
        } else {
            return null;
        }
        result.put("regionCode",regionCode);
        result.put("regionType",regionType);
        result.put("regionCode", regionCode);
        result.put("regionType", regionType);
        return result;
    }
}