| | |
| | | package com.ruoyi.device.radar.service.impl; |
| | | |
| | | import java.util.List; |
| | | import java.util.*; |
| | | |
| | | import com.ruoyi.common.annotation.DataScope; |
| | | import com.ruoyi.common.core.domain.entity.SysDept; |
| | | import com.ruoyi.common.utils.DateUtils; |
| | | import com.ruoyi.common.utils.SecurityUtils; |
| | | import com.ruoyi.common.utils.uuid.IdUtils; |
| | | import com.ruoyi.device.camera.domain.ArdCameras; |
| | | import com.ruoyi.device.channel.domain.ArdChannel; |
| | | import com.ruoyi.system.mapper.SysDeptMapper; |
| | | import com.ruoyi.utils.tools.ArdTool; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import com.ruoyi.device.radar.mapper.ArdEquipRadarMapper; |
| | | import com.ruoyi.device.radar.domain.ArdEquipRadar; |
| | | import com.ruoyi.device.radar.service.IArdEquipRadarService; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | /** |
| | | * radarService业务层处理 |
| | |
| | | @Service |
| | | public class ArdEquipRadarServiceImpl implements IArdEquipRadarService |
| | | { |
| | | @Autowired |
| | | @Resource |
| | | private ArdEquipRadarMapper ardEquipRadarMapper; |
| | | |
| | | @Resource |
| | | private SysDeptMapper sysDeptMapper; |
| | | /** |
| | | * 查询radar |
| | | * |
| | |
| | | @Override |
| | | public int insertArdEquipRadar(ArdEquipRadar ardEquipRadar) |
| | | { |
| | | ardEquipRadar.setId(IdUtils.simpleUUID()); |
| | | ardEquipRadar.setCreateTime(DateUtils.getNowDate()); |
| | | ardEquipRadar.setCreateBy(SecurityUtils.getUsername()); |
| | | ardEquipRadar.setUserId(SecurityUtils.getUserId()); |
| | |
| | | { |
| | | return ardEquipRadarMapper.deleteArdEquipRadarById(id); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @描述 获取本部门以下的所有雷达和部门 |
| | | * @参数 [] |
| | | * @返回值 java.util.Map |
| | | * @创建人 刘苏义 |
| | | * @创建时间 2023/6/2 10:58 |
| | | * @修改人和其它信息 |
| | | */ |
| | | |
| | | @Override |
| | | public Map getChildDeptAndRadar(Boolean disabled) { |
| | | Long deptId = SecurityUtils.getDeptId(); |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | Map<String, Object> map = fetchChildDepartments(sysDept, disabled); |
| | | return map; |
| | | } |
| | | |
| | | @Override |
| | | public List<Map<String, Object>> getChildDeptAndRadarOwn(Boolean disabled) { |
| | | Long deptId = SecurityUtils.getDeptId(); |
| | | SysDept sysDept = sysDeptMapper.selectDeptById(deptId); |
| | | List<Long> ownDeptIdList = sysDeptMapper.selectRoleDeptIdByUsersId(SecurityUtils.getUserId());//自定义权限主键查询 |
| | | ownDeptIdList.remove(SecurityUtils.getDeptId());//若自定义权限包含本级权限,则移除 |
| | | Map<String, Object> map = fetchChildDepartments(sysDept, disabled, ownDeptIdList);//查询本权限及下属权限设备并在自定义权限中移除下属部门主键 |
| | | Set<Long> pIdSet = new HashSet();//自定义权限主键的最高权限 |
| | | for(Long deptIdn : ownDeptIdList){ |
| | | List<SysDept> pSysDeptList = sysDeptMapper.getParentsDeptListByDeptId(deptIdn); |
| | | pIdSet.add(pSysDeptList.get(pSysDeptList.size() - 1).getDeptId());//获取 |
| | | } |
| | | List<Map<String, Object>> result = new ArrayList(); |
| | | result.add(map); |
| | | for(Long pId : pIdSet){ |
| | | SysDept pSysDept = sysDeptMapper.selectDeptById(pId); |
| | | Map<String, Object> mapO = fetchChildDepartments(ownDeptIdList, pSysDept, disabled); |
| | | result.add(mapO); |
| | | } |
| | | return result; |
| | | } |
| | | |
| | | /** |
| | | * @描述 递归查询 |
| | | * @参数 [sysDept] |
| | | * @返回值 java.util.Map<java.lang.String, java.lang.Object> |
| | | * @创建人 刘苏义 |
| | | * @创建时间 2023/6/2 14:38 |
| | | * @修改人和其它信息 |
| | | */ |
| | | public Map<String, Object> fetchChildDepartments(SysDept sysDept, Boolean disabled) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", sysDept.getDeptName()); |
| | | map.put("deptId", sysDept.getDeptId()); |
| | | map.put("disabled", disabled); |
| | | List<SysDept> sysDepts = sysDeptMapper.selectNextChildrenDeptById(sysDept.getDeptId()); |
| | | List<ArdEquipRadar> ardRadars = ardEquipRadarMapper.selectArdRadarsByDeptId(sysDept.getDeptId()); |
| | | List<Object> childList = new ArrayList<>(); |
| | | for (SysDept childDept : sysDepts) { |
| | | Map<String, Object> childMap = new HashMap<>(); |
| | | childMap.put("name", childDept.getDeptName()); |
| | | childMap.put("deptId", childDept.getDeptId()); |
| | | childMap.put("disabled", disabled); |
| | | Map<String, Object> map1 = fetchChildDepartments(childDept, disabled); |
| | | childMap.putAll(map1); |
| | | childList.add(childMap); |
| | | } |
| | | if (ardRadars.size() > 0) { |
| | | for (ArdEquipRadar radar : ardRadars) { |
| | | Map<String, Object> cameraMap = ArdTool.convertEntityToMap(radar); |
| | | childList.add(cameraMap); |
| | | } |
| | | } |
| | | map.put("children", childList); |
| | | return map; |
| | | |
| | | } |
| | | |
| | | /** |
| | | * zns |
| | | * |
| | | * */ |
| | | public Map<String, Object> fetchChildDepartments(SysDept sysDept, Boolean disabled, List<Long> ownDeptIdList) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", sysDept.getDeptName()); |
| | | map.put("deptId", sysDept.getDeptId()); |
| | | map.put("disabled", disabled); |
| | | List<SysDept> sysDepts = sysDeptMapper.selectNextChildrenDeptById(sysDept.getDeptId()); |
| | | for(SysDept sysDeptC : sysDepts){//若自定义权限包含下级权限,则移除 |
| | | if(ownDeptIdList.contains(sysDeptC.getDeptId())){ |
| | | ownDeptIdList.remove(sysDeptC.getDeptId()); |
| | | } |
| | | } |
| | | List<ArdEquipRadar> ardRadars = ardEquipRadarMapper.selectArdRadarsByDeptId(sysDept.getDeptId()); |
| | | List<Object> childList = new ArrayList<>(); |
| | | for (SysDept childDept : sysDepts) { |
| | | Map<String, Object> childMap = new HashMap<>(); |
| | | childMap.put("name", childDept.getDeptName()); |
| | | childMap.put("deptId", childDept.getDeptId()); |
| | | childMap.put("disabled", disabled); |
| | | Map<String, Object> map1 = fetchChildDepartments(childDept, disabled); |
| | | childMap.putAll(map1); |
| | | childList.add(childMap); |
| | | } |
| | | if (ardRadars.size() > 0) { |
| | | for (ArdEquipRadar radar : ardRadars) { |
| | | Map<String, Object> cameraMap = ArdTool.convertEntityToMap(radar); |
| | | childList.add(cameraMap); |
| | | } |
| | | } |
| | | map.put("children", childList); |
| | | return map; |
| | | } |
| | | |
| | | public Map<String, Object> fetchChildDepartments(List<Long> ownDeptIdList, SysDept sysDept, Boolean disabled) { |
| | | Map<String, Object> map = new HashMap<>(); |
| | | map.put("name", sysDept.getDeptName()); |
| | | map.put("deptId", sysDept.getDeptId()); |
| | | map.put("disabled", disabled); |
| | | List<SysDept> sysDepts = sysDeptMapper.selectNextChildrenDeptByIdAndInList(sysDept.getDeptId(),ownDeptIdList); |
| | | List<ArdEquipRadar> ardRadars = ardEquipRadarMapper.selectArdRadarsByDeptId(sysDept.getDeptId()); |
| | | List<Object> childList = new ArrayList<>(); |
| | | for (SysDept childDept : sysDepts) { |
| | | Map<String, Object> childMap = new HashMap<>(); |
| | | childMap.put("name", childDept.getDeptName()); |
| | | childMap.put("deptId", childDept.getDeptId()); |
| | | childMap.put("disabled", disabled); |
| | | //Map<String, Object> map1 = fetchChildDepartments(childDept, disabled); |
| | | Map<String, Object> map1 = fetchChildDepartments(ownDeptIdList,childDept, disabled); |
| | | childMap.putAll(map1); |
| | | childList.add(childMap); |
| | | } |
| | | if (ardRadars.size() > 0) { |
| | | for (ArdEquipRadar radar : ardRadars) { |
| | | Map<String, Object> cameraMap = ArdTool.convertEntityToMap(radar); |
| | | childList.add(cameraMap); |
| | | } |
| | | } |
| | | map.put("children", childList); |
| | | return map; |
| | | } |
| | | |
| | | } |