|
|
|
@ -1,26 +1,30 @@
|
|
|
|
|
package com.ruoyi.system.service.impl;
|
|
|
|
|
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import com.ruoyi.common.constant.UserConstants;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictData;
|
|
|
|
|
import com.ruoyi.common.core.domain.entity.SysDictType;
|
|
|
|
|
import com.ruoyi.common.exception.ServiceException;
|
|
|
|
|
import com.ruoyi.common.utils.DictUtils;
|
|
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
|
|
import com.ruoyi.system.mapper.SysDictDataMapper;
|
|
|
|
|
import com.ruoyi.system.mapper.SysDictTypeMapper;
|
|
|
|
|
import com.ruoyi.system.service.ISysDeptService;
|
|
|
|
|
import com.ruoyi.system.service.ISysDictTypeService;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
|
|
|
import java.util.Comparator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.Objects;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 字典 业务层处理
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @author ruoyi
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
@ -32,6 +36,9 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
@Autowired
|
|
|
|
|
private SysDictDataMapper dictDataMapper;
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
private ISysDeptService deptService;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 项目启动时,初始化字典到缓存
|
|
|
|
|
*/
|
|
|
|
@ -43,7 +50,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据条件分页查询字典类型
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dictType 字典类型信息
|
|
|
|
|
* @return 字典类型集合信息
|
|
|
|
|
*/
|
|
|
|
@ -55,7 +62,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据所有字典类型
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @return 字典类型集合信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
@ -66,7 +73,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据字典类型查询字典数据
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dictType 字典类型
|
|
|
|
|
* @return 字典数据集合信息
|
|
|
|
|
*/
|
|
|
|
@ -89,7 +96,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据字典类型ID查询信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dictId 字典类型ID
|
|
|
|
|
* @return 字典类型
|
|
|
|
|
*/
|
|
|
|
@ -101,7 +108,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 根据字典类型查询信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dictType 字典类型
|
|
|
|
|
* @return 字典类型
|
|
|
|
|
*/
|
|
|
|
@ -111,9 +118,31 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
return dictTypeMapper.selectDictTypeByType(dictType);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 添加隐患时,若当前账号是乡镇街道,那么企业地址为本乡镇街道
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public List<SysDictData> getAdminArea() {
|
|
|
|
|
// 获取登录账号部门名称
|
|
|
|
|
Long deptId = SecurityUtils.getLoginUser().getDeptId();
|
|
|
|
|
String deptName = deptService.selectDeptById(deptId).getDeptName();
|
|
|
|
|
// 获取乡镇街道名称集合
|
|
|
|
|
String dictType = "area_id";
|
|
|
|
|
List<SysDictData> dictDatas = dictDataMapper.selectDictDataByType(dictType);
|
|
|
|
|
List<String> deptNameList = dictDatas.stream().map(SysDictData::getDictLabel).collect(Collectors.toList());
|
|
|
|
|
// 如果当前登录账号是乡镇街道的话
|
|
|
|
|
if (deptNameList.contains(deptName)) {
|
|
|
|
|
List<SysDictData> collect = dictDatas.stream()
|
|
|
|
|
.filter(item -> Objects.equals(item.getDictLabel(), deptName))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
return collect;
|
|
|
|
|
}
|
|
|
|
|
return dictDatas;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量删除字典类型信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dictIds 需要删除的字典ID
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
@ -167,7 +196,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 新增保存字典类型信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dict 字典类型信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -184,7 +213,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 修改保存字典类型信息
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dict 字典类型信息
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -205,7 +234,7 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 校验字典类型称是否唯一
|
|
|
|
|
*
|
|
|
|
|
*
|
|
|
|
|
* @param dict 字典类型
|
|
|
|
|
* @return 结果
|
|
|
|
|
*/
|
|
|
|
@ -220,4 +249,5 @@ public class SysDictTypeServiceImpl implements ISysDictTypeService
|
|
|
|
|
}
|
|
|
|
|
return UserConstants.UNIQUE;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|