Эх сурвалжийг харах

Merge remote-tracking branch 'origin/V0.0.2' into V0.0.2

jingyuanchao 2 жил өмнө
parent
commit
941b45fa4e

+ 3 - 10
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ProtectionController.java

@@ -30,7 +30,7 @@ class ProtectionController extends BaseController {
     @ApiOperation(value = "分页")
     @GetMapping(value = "page")
 //    @WebMethodLogDesc("防区状态app")
-    @RequiresPermissions("device:protection")
+    @RequiresPermissions({"device:protection"})
     TableDataInfo page(final ProtectionPageDto request) {
         TableDataInfo data = this.protectionService.pageList(request);
         return data;
@@ -38,7 +38,7 @@ class ProtectionController extends BaseController {
 
     @ApiOperation(value = "分页")
     @GetMapping(value = "log/page")
-    @RequiresPermissions("device:protection")
+    @RequiresPermissions({"device:protection"})
     TableDataInfo LogpageList(final ProtectionLogPageDto request) {
         final TableDataInfo page = this.protectionService.history(request);
         return page;
@@ -53,7 +53,7 @@ class ProtectionController extends BaseController {
 
     @ApiOperation(value = "规范")
     @GetMapping("{id}")
-    @RequiresPermissions("device:protection:query")
+    @RequiresPermissions({"device:protection:query"})
     public AjaxResult get(@PathVariable Long id) {
         Protection r = protectionService.get(id);
         return success(r);
@@ -66,11 +66,4 @@ class ProtectionController extends BaseController {
         boolean r = protectionService.del(id);
         return success(r);
     }
-
-    @ApiOperation(value = "布撤防")
-    @PostMapping("updatestatus/{protectionId}/{status}")
-    @RequiresPermissions("device:protection:maintain")
-    public AjaxResult updateStatus(@PathVariable Long protectionId,@PathVariable String status) {
-        return success(protectionService.updateStatus(protectionId,status));
-    }
 }

+ 61 - 0
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/controller/ProtectionStatusController.java

@@ -0,0 +1,61 @@
+package com.xunmei.core.resumption.controller;
+
+import com.xunmei.common.core.web.controller.BaseController;
+import com.xunmei.common.core.web.domain.AjaxResult;
+import com.xunmei.common.core.web.page.TableDataInfo;
+import com.xunmei.common.security.annotation.RequiresPermissions;
+import com.xunmei.core.resumption.domain.Protection;
+import com.xunmei.core.resumption.dto.protection.ProtectionEditDto;
+import com.xunmei.core.resumption.dto.protection.ProtectionLogPageDto;
+import com.xunmei.core.resumption.dto.protection.ProtectionPageDto;
+import com.xunmei.core.resumption.service.IProtectionService;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+
+/**
+ *
+ */
+@Slf4j
+@Api(description = "中台", tags = "布防")
+@RestController
+@RequestMapping("/resumption/protectionstatus/")
+class ProtectionStatusController extends BaseController {
+    @Resource
+    IProtectionService protectionService;
+
+    @ApiOperation(value = "分页")
+    @GetMapping(value = "page")
+//    @WebMethodLogDesc("防区状态app")
+    @RequiresPermissions({"device:protectionstatus"})
+    TableDataInfo page(final ProtectionPageDto request) {
+        TableDataInfo data = this.protectionService.pageList(request);
+        return data;
+    }
+
+    @ApiOperation(value = "分页")
+    @GetMapping(value = "log/page")
+    @RequiresPermissions({"device:protectionstatus"})
+    TableDataInfo LogpageList(final ProtectionLogPageDto request) {
+        final TableDataInfo page = this.protectionService.history(request);
+        return page;
+    }
+
+    @ApiOperation(value = "详情")
+    @GetMapping("{id}")
+    @RequiresPermissions({"device:protectionstatus:query"})
+    public AjaxResult get(@PathVariable Long id) {
+        Protection r = protectionService.get(id);
+        return success(r);
+    }
+
+    @ApiOperation(value = "布撤防")
+    @PostMapping("updatestatus/{protectionId}/{status}")
+    @RequiresPermissions({"device:protectionstatus:maintain",})
+    public AjaxResult updateStatus(@PathVariable Long protectionId,@PathVariable String status) {
+        return success(protectionService.updateStatus(protectionId,status));
+    }
+}

+ 3 - 3
soc-modules/soc-modules-core/src/main/java/com/xunmei/core/resumption/service/impl/AppRuleItemServiceImpl.java

@@ -189,13 +189,13 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
     public List<RuleTreeItem> getRuleTree(Long orgId) {
         List<RuleTreeItem> tree = new ArrayList<>();
         List<SysOrg> orgs = remoteOrgService
-                .listByTypes(OrgListByTypesConditionEto.builder().orgId(orgId).orgTypes(Arrays.asList("1", "2", "3")).build())
+                .listByTypes(OrgListByTypesConditionEto.builder().orgId(orgId).orgTypes(Arrays.asList("1", "2", "3","11",null)).build())
                 .getData();
         if (ObjectUtil.isEmpty(orgs)) {
             return tree;
         }
         Map<Long, SysOrg> orgMap = orgs.stream().collect(Collectors.toMap(o -> o.getId(), o -> o));
-        List<SysOrg> tops = orgs.stream().filter(o -> !orgMap.containsKey(o.getParentId())).collect(Collectors.toList());
+        List<SysOrg> tops = orgs.stream().filter(o -> !orgMap.containsKey(o.getTreeShowParentId())).collect(Collectors.toList());
         if (CollectionUtil.isEmpty(tops)) {
             return tree;
         }
@@ -215,7 +215,7 @@ public class AppRuleItemServiceImpl extends ServiceImpl<AppRuleItemMapper, AppRu
         item.getChildren().addAll(ruleItems);
 
         List<SysOrg> children = allOrg.stream()
-                .filter(o -> ObjectUtil.equal(o.getParentId(), parent.getId()))
+                .filter(o -> ObjectUtil.equal(o.getTreeShowParentId(), parent.getId()))
                 .collect(Collectors.toList());
         for (SysOrg child : children) {
             item.getChildren().add(generateTree(child, allOrg, allRule));

+ 2 - 2
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysDeptController.java

@@ -135,7 +135,7 @@ public class SysDeptController extends BaseController {
      */
     @GetMapping("/deptTree")
     public AjaxResult deptTree(SysOrg dept) {
-        return success(deptService.selectDeptTreeList(new ArrayList<>()));
+        return success(deptService.selectDeptTreeList());
     }
 
     /**
@@ -143,7 +143,7 @@ public class SysDeptController extends BaseController {
      */
     @GetMapping("/deptTree/hangshe")
     public AjaxResult hangsheDeptTree() {
-        return success(deptService.selectDeptTreeList(Arrays.asList(1, 2, 3)));
+        return success(deptService.selectHangsheTreeList());
     }
 
     /**

+ 6 - 2
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/controller/SysRoleController.java

@@ -141,7 +141,11 @@ public class SysRoleController extends BaseController {
     public AjaxResult optionselect() {
         return success(roleService.selectRoleAll());
     }
-
+    @RequiresPermissions("system:role:query")
+    @GetMapping("/allRole")
+    public AjaxResult allRole() {
+        return success(roleService.allRole());
+    }
     /**
      * 查询已分配用户角色列表
      */
@@ -199,7 +203,7 @@ public class SysRoleController extends BaseController {
     public AjaxResult deptTree(@PathVariable("roleId") Long roleId) {
         AjaxResult ajax = AjaxResult.success();
         ajax.put("checkedKeys", deptService.selectDeptListByRoleId(roleId));
-        ajax.put("depts", deptService.selectDeptTreeList(new ArrayList<>()));
+        ajax.put("depts", deptService.selectDeptTreeList());
         return ajax;
     }
 

+ 1 - 1
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/mapper/SysRoleMapper.java

@@ -23,7 +23,7 @@ public interface SysRoleMapper extends BaseMapper<SysRole>
      * @return 角色数据集合信息
      */
      List<SysRole> selectRoleList(SysRole role);
-
+List<SysRole>allRole();
     /**
      * 根据用户ID查询角色
      * 

+ 7 - 1
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysDeptService.java

@@ -29,7 +29,13 @@ public interface ISysDeptService extends IService<SysDept> {
      * @param dept 部门信息
      * @return 部门树信息集合
      */
-    List<SysOrgVO> selectDeptTreeList(List<Integer> orgTypes);
+    List<SysOrgVO> selectDeptTreeList();
+
+    /**
+     * 返回行社树
+     * @return
+     */
+    List<SysOrgVO> selectHangsheTreeList();
 
     /**
      * 部门管理

+ 1 - 1
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/ISysRoleService.java

@@ -48,7 +48,7 @@ public interface ISysRoleService extends IService<SysRole>
      * @return 角色列表
      */
     List<SysRole> selectRoleAll();
-
+List<SysRole>allRole();
     /**
      * 根据用户ID获取角色选择框列表
      *

+ 48 - 13
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysDeptServiceImpl.java

@@ -108,11 +108,10 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
     /**
      * 查询部门树结构信息
      *
-     * @param orgTypes 机构类型
      * @return 部门树信息集合
      */
     @Override
-    public List<SysOrgVO> selectDeptTreeList(List<Integer> orgTypes) {
+    public List<SysOrgVO> selectDeptTreeList() {
         Long s = System.currentTimeMillis();
         Long userId = SecurityUtils.getUserId();
         SysOrg sysOrg = orgMapper.selectSysOrgByUserId(userId);
@@ -129,36 +128,72 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
         List<SysOrgVO> orgs = new ArrayList<>();
         for (SysOrgVO org : cacheList) {
             String path = org.getPath();
-            if(StringUtils.isEmpty(path) || !path.startsWith(sysOrg.getPath())){
+            if (StringUtils.isEmpty(path) || !path.startsWith(sysOrg.getPath())) {
                 continue;
             }
 
-            if(CollectionUtils.isNotEmpty(orgTypes) && !orgTypes.contains(org.getType())){
-                continue;
-            }
-            if(StringUtils.isEmpty(org.getShortName()))
-            {
+            if (StringUtils.isEmpty(org.getShortName())) {
                 org.setShortName(org.getName());
             }
             orgs.add(org);
         }
+
+        return generateTree(orgs, sysOrg);
+    }
+
+    public List<SysOrgVO> selectHangsheTreeList() {
+        Long userId = SecurityUtils.getUserId();
+        SysOrg sysOrg = orgMapper.selectSysOrgByUserId(userId);
+        if (ObjectUtil.isNull(sysOrg)) {
+            throw new ServiceException("当前用户没有部门信息");
+        }
+
+        List<SysOrgVO> cacheList = null;
+        Boolean isOk = RedisUtils.hasKey(CacheConstants.ORG_CACHE_LIST_KEY);
+        if (!isOk) {
+            cacheList = orgService.loadingOrgCache();
+        } else {
+            cacheList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY);
+        }
+
+        List<SysOrgVO> hangshelist = cacheList.stream().filter(c -> ObjectUtil.equal(c.getType(), 3)
+                        && ObjectUtil.isNotEmpty(c.getPath()) && c.getPath().startsWith(sysOrg.getPath()))
+                .collect(Collectors.toList());
+        Set<Long> hangsheSet=hangshelist.stream().map(o->o.getId()).collect(Collectors.toSet());
+        Set<Long> parentIds = new HashSet<>();
+        hangshelist.forEach(o -> {
+            Arrays.stream(o.getPath().split("-")).map(p -> Long.parseLong(p))
+                    .collect(Collectors.toList())
+                    .forEach(id ->{
+                        if(!hangsheSet.contains(id)){
+                            parentIds.add(id);
+                        }
+                    });
+        });
+        hangshelist.addAll(cacheList.stream().filter(o -> parentIds.contains(o.getId())).collect(Collectors.toList()));
+
+        return generateTree(hangshelist, sysOrg);
+    }
+
+
+
+    private List<SysOrgVO> generateTree(List<SysOrgVO> orgs, SysOrg sysOrg) {
         Long parentId = Constants.TOP_ORG_PARENT_ID;
         if (ObjectUtil.notEqual(Constants.TOP_ORG_PARENT_ID, sysOrg.getParentId())) {
             parentId = sysOrg.getParentId();
         }
 
         final List<Long> parentIds = orgs.stream().filter(x -> !orgs.stream().anyMatch(y -> x.getTreeShowParentId().equals(y.getParentId()))).map(SysOrgVO::getTreeShowParentId).collect(Collectors.toList());
-        if(parentIds.size()==0)
-        {
+        if (parentIds.size() == 0) {
             parentIds.add(parentId);
         }
         final Map<Long, List<SysOrgVO>> collect = orgs.stream().collect(Collectors.groupingBy(SysOrgVO::getTreeShowParentId));
-        List<SysOrgVO> result=new ArrayList<>();
-        parentIds.forEach(pId->{
+        List<SysOrgVO> result = new ArrayList<>();
+        parentIds.forEach(pId -> {
             result.addAll(handleTree(collect, pId));
         });
 
-        return result;
+        return  result;
     }
 
     /**

+ 5 - 0
soc-modules/soc-modules-system/src/main/java/com/xunmei/system/service/impl/SysRoleServiceImpl.java

@@ -130,6 +130,11 @@ public class SysRoleServiceImpl extends ServiceImpl<SysRoleMapper, SysRole> impl
         return roleMapper.selectList(new QueryWrapper<>());
     }
 
+    @Override
+    public List<SysRole> allRole() {
+        return roleMapper.allRole();
+    }
+
     /**
      * 根据用户ID获取角色选择框列表
      *

+ 5 - 0
soc-modules/soc-modules-system/src/main/resources/mapper/system/SysRoleMapper.xml

@@ -115,6 +115,11 @@
                  LEFT JOIN sys_role sr ON sur.role_id = sr.id
         WHERE su.id = #{userId}
     </select>
+    <select id="allRole" resultType="com.xunmei.system.api.domain.SysRole">
+        SELECT *
+        FROM sys_role
+        WHERE role_name !='超级管理员'
+    </select>
 
     <insert id="insertRole" parameterType="com.xunmei.system.api.domain.SysRole" useGeneratedKeys="true"
             keyProperty="id">