From 94e3a209bb9a31c4ddbd31494bb1628f6fe2e96e Mon Sep 17 00:00:00 2001 From: lidongdong <1459917685@qq.com> Date: 星期三, 12 十月 2022 17:54:49 +0800 Subject: [PATCH] 新增首页工单 办事指南排行榜接口 导办人员排行榜接口 组织排行榜接口 新增办事指南统计接口 导办人员统计接口 组织胖行榜统计接口 --- flower_city/src/main/java/com/dg/core/controller/OrganizationController.java | 83 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 79 insertions(+), 4 deletions(-) diff --git a/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java b/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java index 80534dd..38e281d 100644 --- a/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java +++ b/flower_city/src/main/java/com/dg/core/controller/OrganizationController.java @@ -1,8 +1,11 @@ package com.dg.core.controller; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.dg.core.ResultData; import com.dg.core.annotation.Authorization; +import com.dg.core.annotation.CurrentUser; import com.dg.core.db.gen.entity.OrganizationChartEntity; +import com.dg.core.db.gen.entity.SysUser; import com.dg.core.service.IOrganizationChartService; import com.dg.core.util.TableDataInfo; import io.swagger.annotations.Api; @@ -11,6 +14,10 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.*; + +import java.time.LocalDateTime; +import java.util.ArrayList; +import java.util.List; @Api(tags = {"组织架构接口"}) @@ -25,7 +32,7 @@ /** * 查询机构列表 */ - @ApiOperation("查询机构列表") + @ApiOperation(value = "查询机构列表",response = OrganizationChartEntity.class) @GetMapping("/getList") public TableDataInfo selectConfigList() { @@ -35,7 +42,7 @@ /** * 新增机构 */ - @ApiOperation("新增机构") + @ApiOperation(value = "新增机构",response = OrganizationChartEntity.class) @PostMapping("/add") @Authorization public ResultData insertConfig(@RequestBody OrganizationChartEntity entity) @@ -62,11 +69,13 @@ /** * 更新机构 */ - @ApiOperation("更新机构") + @ApiOperation(value = "更新机构",response = OrganizationChartEntity.class) @PostMapping("/update") @Authorization - public ResultData updateConfig(@RequestBody OrganizationChartEntity entity) + public ResultData updateConfig(@RequestBody OrganizationChartEntity entity,@CurrentUser SysUser sysUser) { + entity.setUpdateTime(LocalDateTime.now()); + entity.setUpdateUserId(Integer.parseInt(String.valueOf(sysUser.getUserId()))); return toAjax(iOrganizationChartService.updateConfig(entity)); } @@ -79,6 +88,12 @@ public ResultData deleteConfigById(@RequestParam(value = "Id",required = false) String Id) { Assert.notNull(Id, "Id 不能为空"); + List<OrganizationChartEntity> list=iOrganizationChartService.selectParentList(Id,""); + + if(list!=null && list.size()>0) + { + return ResultData.error("该机构下存在其他部门!请先删除子部门"); + } return toAjax(iOrganizationChartService.deleteConfigById(Id)); } @@ -100,4 +115,64 @@ return ResultData.success(iOrganizationChartService.selectConfigById(id)); } + + /** + * 查询机构列表(分页) + */ + @ApiOperation(value = "查询机构列表(分页)(部门应用)",response = OrganizationChartEntity.class) + @GetMapping("/queryList") + @Authorization + public TableDataInfo queryList(@RequestParam(value = "pageNum",required = false) Integer pageNum, + @RequestParam(value = "pageSize",required = false) Integer pageSize, + @RequestParam(value = "organizationName",required = false)String organizationName){ + Assert.notNull(pageNum, "pageNum can not be empty"); + Assert.notNull(pageSize, "pageSize can not be empty"); + Page<OrganizationChartEntity> pageParam = new Page<>(pageNum,pageSize); + return getDataTable(iOrganizationChartService.queryList(pageParam,pageSize,organizationName),iOrganizationChartService.countList(organizationName)); + } + + + /** + * 通过父级id查询对应机构下的全部部门id + * @param departmentId + * @return + */ + @ApiOperation(value = "通过父级id查询对应机构下的全部部门",response = OrganizationChartEntity.class) + @GetMapping("/getdepartment") + public TableDataInfo getOrganizations(@RequestParam(value = "department",required = false) String departmentId) + { + List<OrganizationChartEntity> ids=new ArrayList<>(); + List<OrganizationChartEntity> lists = iOrganizationChartService.selectParentList(departmentId,""); + if(lists.size()<1) + { + lists.add(iOrganizationChartService.selectConfigById(departmentId)); + } + ids=disposestreet(lists); + if(ids.size()<1) + { + return null; + } + ids.add(iOrganizationChartService.selectConfigById(departmentId)); + return getDataTable(ids); + } + + //递归取id + private List<OrganizationChartEntity> disposestreet(List<OrganizationChartEntity> lists) + { + List<OrganizationChartEntity> ids=new ArrayList<>(); + for (OrganizationChartEntity sysStreet:lists) + { + ids.add(sysStreet); + if(sysStreet.getChild()!=null && sysStreet.getChild().size()>0) + { + ids.addAll(disposestreet(sysStreet.getChild())); + } + else + { + ids.add(sysStreet); + } + } + return ids; + } + } -- Gitblit v1.7.1