| | |
| | | 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.db.gen.entity.TransactionEvent; |
| | | import com.dg.core.service.IOrganizationChartService; |
| | | import com.dg.core.service.ITransactionEventService; |
| | | import com.dg.core.util.PermissionUtil; |
| | | import com.dg.core.util.TableDataInfo; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | 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 = {"组织架构接口"}) |
| | |
| | | @Autowired(required = true) |
| | | IOrganizationChartService iOrganizationChartService; |
| | | |
| | | @Autowired(required = true) |
| | | ITransactionEventService iTransactionEventService; |
| | | |
| | | /** |
| | | * 查询机构列表 |
| | | */ |
| | | @ApiOperation("查询机构列表") |
| | | @ApiOperation(value = "查询机构列表",response = OrganizationChartEntity.class) |
| | | @GetMapping("/getList") |
| | | public TableDataInfo selectConfigList() |
| | | { |
| | | return getDataTable(iOrganizationChartService.selectConfigList("","")); |
| | | return getDataTable(iOrganizationChartService.selectConfigList("","",null)); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询机构列表(权限) |
| | | */ |
| | | @ApiOperation(value = "查询机构列表(权限 选择用 ) ",response = OrganizationChartEntity.class) |
| | | @GetMapping("/selectJurisdiction") |
| | | @Authorization |
| | | public TableDataInfo selectJurisdiction(@CurrentUser SysUser sysUser) |
| | | { |
| | | return getDataTable(iOrganizationChartService.selectConfigList(sysUser.getDepartmentId(),"",null)); |
| | | } |
| | | |
| | | /** |
| | | * 新增机构 |
| | | */ |
| | | @ApiOperation("新增机构") |
| | | @ApiOperation(value = "新增机构",response = OrganizationChartEntity.class) |
| | | @PostMapping("/add") |
| | | @Authorization |
| | | public ResultData insertConfig(@RequestBody OrganizationChartEntity entity) |
| | | { |
| | | Assert.notNull(entity.getGrade(), "等级 grade 不能为空"); |
| | |
| | | /** |
| | | * 更新机构 |
| | | */ |
| | | @ApiOperation("更新机构") |
| | | @ApiOperation(value = "更新机构",response = OrganizationChartEntity.class) |
| | | @PostMapping("/update") |
| | | public ResultData updateConfig(@RequestBody OrganizationChartEntity entity) |
| | | @Authorization |
| | | public ResultData updateConfig(@RequestBody OrganizationChartEntity entity,@CurrentUser SysUser sysUser) |
| | | { |
| | | entity.setUpdateTime(LocalDateTime.now()); |
| | | entity.setUpdateUserId(sysUser.getUserId()); |
| | | return toAjax(iOrganizationChartService.updateConfig(entity)); |
| | | } |
| | | |
| | |
| | | */ |
| | | @ApiOperation("删除机构") |
| | | @DeleteMapping("/delete") |
| | | @Authorization |
| | | 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("该机构下存在其他部门!请先删除子部门"); |
| | | } |
| | | |
| | | List<String> ids=new ArrayList<>(); |
| | | ids.add(Id); |
| | | List<TransactionEvent> transactionEvents=iTransactionEventService.selectConfigList(null,null,ids); |
| | | |
| | | if(transactionEvents!=null && transactionEvents.size()>0) |
| | | { |
| | | return ResultData.error("该机构下已绑定办事指南!请解绑办事指南"); |
| | | } |
| | | return toAjax(iOrganizationChartService.deleteConfigById(Id)); |
| | | } |
| | | |
| | |
| | | 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, |
| | | @CurrentUser SysUser sysUser){ |
| | | Assert.notNull(pageNum, "pageNum can not be empty"); |
| | | Assert.notNull(pageSize, "pageSize can not be empty"); |
| | | Page<OrganizationChartEntity> pageParam = new Page<>(pageNum,pageSize); |
| | | List<String> ids= PermissionUtil.getPermission(sysUser,iOrganizationChartService); |
| | | return getDataTable(iOrganizationChartService.queryList(pageParam,pageSize,organizationName,ids), |
| | | iOrganizationChartService.countList(organizationName,ids)); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 通过父级id查询对应机构下的全部部门id |
| | | * @param departmentId |
| | | * @return |
| | | */ |
| | | @ApiOperation(value = "通过父级id查询对应机构下的全部部门") |
| | | @GetMapping("/getdepartment/id") |
| | | public TableDataInfo getOrganizationIds(@RequestParam(value = "department",required = false) String departmentId) |
| | | { |
| | | if(StringUtils.isEmpty(departmentId)) |
| | | { |
| | | return getDataTable("departmentId 不能为空"); |
| | | } |
| | | |
| | | List<String> ids=new ArrayList<>(); |
| | | List<String> getId=iOrganizationChartService.getIds(departmentId); |
| | | ids.addAll(getId); |
| | | return getDataTable(ids); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | /** |
| | | * 通过父级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=null; |
| | | if(StringUtils.isEmpty(departmentId)) |
| | | { |
| | | lists= iOrganizationChartService.selectParentList(null,"1"); |
| | | |
| | | } |
| | | else |
| | | { |
| | | lists= iOrganizationChartService.selectParentList(departmentId,null); |
| | | } |
| | | |
| | | if(lists.size()<1) |
| | | { |
| | | lists.add(iOrganizationChartService.selectConfigById(departmentId)); |
| | | } |
| | | ids=disposestreet(lists); |
| | | if(ids.size()<1) |
| | | { |
| | | return null; |
| | | } |
| | | |
| | | if(!StringUtils.isEmpty(departmentId)) |
| | | { |
| | | 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) |
| | | { |
| | | if(sysStreet.getChild()!=null && sysStreet.getChild().size()>0) |
| | | { |
| | | ids.addAll(disposestreet(sysStreet.getChild())); |
| | | } |
| | | else |
| | | { |
| | | ids.add(sysStreet); |
| | | } |
| | | } |
| | | return ids; |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 查询机构列表 |
| | | */ |
| | | @ApiOperation(value = "查询可切换机构列表",response = OrganizationChartEntity.class) |
| | | @GetMapping("switch/getList") |
| | | @Authorization |
| | | public TableDataInfo switchGetList(@CurrentUser SysUser sysUser) |
| | | { |
| | | List<String> ids=new ArrayList<>(); |
| | | if(!StringUtils.isEmpty(sysUser.getMoreDepartmentIds())) |
| | | { |
| | | if(sysUser.getMoreDepartmentIds().indexOf(",")==-1) |
| | | { |
| | | ids.add(sysUser.getDepartmentId()); |
| | | } |
| | | else |
| | | { |
| | | String[] list=sysUser.getMoreDepartmentIds().split(","); |
| | | for (String id:list) |
| | | { |
| | | ids.add(id); |
| | | } |
| | | } |
| | | } |
| | | else |
| | | { |
| | | ids.add(sysUser.getDepartmentId()); |
| | | } |
| | | |
| | | return getDataTable(iOrganizationChartService.selectConfigList(ids)); |
| | | } |
| | | } |