From 6e0e417c0805c5b94ad83556728d46e3615f678f Mon Sep 17 00:00:00 2001 From: 15036302109 Date: Wed, 13 Mar 2024 17:07:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B9=A1=E9=95=87=E6=B7=BB=E5=8A=A0=E9=9A=90?= =?UTF-8?q?=E6=82=A3=E6=97=B6=EF=BC=8C=E5=9C=B0=E5=9D=80=E9=BB=98=E8=AE=A4?= =?UTF-8?q?=E6=9C=AC=E4=B9=A1=E9=95=87=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../system/SysDictDataController.java | 9 +++ .../system/service/ISysDictTypeService.java | 5 ++ .../service/impl/SysDictTypeServiceImpl.java | 66 ++++++++++++++----- ruoyi-ui/src/api/ehs/ehsHiddenDanger.js | 7 ++ .../src/views/ehs/ehsHiddenDanger/index.vue | 21 ++++-- 5 files changed, 85 insertions(+), 23 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java index 59becaf..ed59cdc 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/system/SysDictDataController.java @@ -83,6 +83,15 @@ public class SysDictDataController extends BaseController return success(data); } + /** + * 添加隐患时,若当前账号是乡镇街道,那么企业地址为本乡镇街道 + */ + @GetMapping(value = "/areaId") + public AjaxResult getAdminArea() { + List data = dictTypeService.getAdminArea(); + return success(data); + } + /** * 新增字典类型 */ diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java index 01c1c1d..66736c0 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/ISysDictTypeService.java @@ -95,4 +95,9 @@ public interface ISysDictTypeService * @return 结果 */ public boolean checkDictTypeUnique(SysDictType dictType); + + /** + * 添加隐患时,若当前账号是乡镇街道,那么企业地址为本乡镇街道 + */ + public List getAdminArea(); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java index 7fd9654..5398f13 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/SysDictTypeServiceImpl.java @@ -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 getAdminArea() { + // 获取登录账号部门名称 + Long deptId = SecurityUtils.getLoginUser().getDeptId(); + String deptName = deptService.selectDeptById(deptId).getDeptName(); + // 获取乡镇街道名称集合 + String dictType = "area_id"; + List dictDatas = dictDataMapper.selectDictDataByType(dictType); + List deptNameList = dictDatas.stream().map(SysDictData::getDictLabel).collect(Collectors.toList()); + // 如果当前登录账号是乡镇街道的话 + if (deptNameList.contains(deptName)) { + List 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; } + } diff --git a/ruoyi-ui/src/api/ehs/ehsHiddenDanger.js b/ruoyi-ui/src/api/ehs/ehsHiddenDanger.js index 13b7233..62f476d 100644 --- a/ruoyi-ui/src/api/ehs/ehsHiddenDanger.js +++ b/ruoyi-ui/src/api/ehs/ehsHiddenDanger.js @@ -66,3 +66,10 @@ export function getOverTimeId() { method: 'get' }) } + +export function getAdminArea() { + return request({ + url: '/system/dict/data/areaId', + method: 'get' + }) +} diff --git a/ruoyi-ui/src/views/ehs/ehsHiddenDanger/index.vue b/ruoyi-ui/src/views/ehs/ehsHiddenDanger/index.vue index 2b3fed8..ae35927 100644 --- a/ruoyi-ui/src/views/ehs/ehsHiddenDanger/index.vue +++ b/ruoyi-ui/src/views/ehs/ehsHiddenDanger/index.vue @@ -477,10 +477,10 @@ @@ -685,7 +685,7 @@