|
|
@ -1,6 +1,5 @@ |
|
|
|
package org.jeecg.modules.system.controller; |
|
|
|
package org.jeecg.modules.system.controller; |
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
|
|
@ -17,7 +16,6 @@ import org.jeecg.common.system.query.QueryGenerator; |
|
|
|
import org.jeecg.common.system.util.JwtUtil; |
|
|
|
import org.jeecg.common.system.util.JwtUtil; |
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
import org.jeecg.common.system.vo.LoginUser; |
|
|
|
import org.jeecg.common.util.ImportExcelUtil; |
|
|
|
import org.jeecg.common.util.ImportExcelUtil; |
|
|
|
import org.jeecg.common.util.YouBianCodeUtil; |
|
|
|
|
|
|
|
import org.jeecg.common.util.oConvertUtils; |
|
|
|
import org.jeecg.common.util.oConvertUtils; |
|
|
|
import org.jeecg.config.mybatis.MybatisPlusSaasConfig; |
|
|
|
import org.jeecg.config.mybatis.MybatisPlusSaasConfig; |
|
|
|
import org.jeecg.modules.system.entity.SysDepart; |
|
|
|
import org.jeecg.modules.system.entity.SysDepart; |
|
|
@ -67,6 +65,7 @@ public class SysDepartController { |
|
|
|
private ISysUserService sysUserService; |
|
|
|
private ISysUserService sysUserService; |
|
|
|
@Autowired |
|
|
|
@Autowired |
|
|
|
private ISysUserDepartService sysUserDepartService; |
|
|
|
private ISysUserDepartService sysUserDepartService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 查询数据 查出我的部门,并以树结构数据格式响应给前端 |
|
|
|
* 查询数据 查出我的部门,并以树结构数据格式响应给前端 |
|
|
|
* |
|
|
|
* |
|
|
@ -77,22 +76,22 @@ public class SysDepartController { |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<>(); |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<>(); |
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){ |
|
|
|
if (oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals(CommonConstant.USER_IDENTITY_2)) { |
|
|
|
//update-begin--Author:liusq Date:20210624 for:部门查询ids为空后的前端显示问题 issues/I3UD06
|
|
|
|
//update-begin--Author:liusq Date:20210624 for:部门查询ids为空后的前端显示问题 issues/I3UD06
|
|
|
|
String departIds = user.getDepartIds(); |
|
|
|
String departIds = user.getDepartIds(); |
|
|
|
if(StringUtils.isNotBlank(departIds)){ |
|
|
|
if (StringUtils.isNotBlank(departIds)) { |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(departIds); |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryMyDeptTreeList(departIds); |
|
|
|
result.setResult(list); |
|
|
|
result.setResult(list); |
|
|
|
} |
|
|
|
} |
|
|
|
//update-end--Author:liusq Date:20210624 for:部门查询ids为空后的前端显示问题 issues/I3UD06
|
|
|
|
//update-end--Author:liusq Date:20210624 for:部门查询ids为空后的前端显示问题 issues/I3UD06
|
|
|
|
result.setMessage(CommonConstant.USER_IDENTITY_2.toString()); |
|
|
|
result.setMessage(CommonConstant.USER_IDENTITY_2.toString()); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
result.setMessage(CommonConstant.USER_IDENTITY_1.toString()); |
|
|
|
result.setMessage(CommonConstant.USER_IDENTITY_1.toString()); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -111,36 +110,60 @@ public class SysDepartController { |
|
|
|
// if (CollectionUtils.isEmpty(list)) {
|
|
|
|
// if (CollectionUtils.isEmpty(list)) {
|
|
|
|
// list = sysDepartService.queryTreeList();
|
|
|
|
// list = sysDepartService.queryTreeList();
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
if(oConvertUtils.isNotEmpty(ids)){ |
|
|
|
if (oConvertUtils.isNotEmpty(ids)) { |
|
|
|
List<SysDepartTreeModel> departList = sysDepartService.queryTreeList(ids); |
|
|
|
List<SysDepartTreeModel> departList = sysDepartService.queryTreeList(ids); |
|
|
|
result.setResult(departList); |
|
|
|
result.setResult(departList); |
|
|
|
}else{ |
|
|
|
} else { |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryTreeList(); |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryTreeList(); |
|
|
|
result.setResult(list); |
|
|
|
result.setResult(list); |
|
|
|
} |
|
|
|
} |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 异步查询部门list |
|
|
|
* 异步查询部门list |
|
|
|
|
|
|
|
* |
|
|
|
* @param parentId 父节点 异步加载时传递 |
|
|
|
* @param parentId 父节点 异步加载时传递 |
|
|
|
* @param ids 前端回显是传递 |
|
|
|
* @param ids 前端回显是传递 |
|
|
|
* @param primaryKey 主键字段(id或者orgCode) |
|
|
|
* @param primaryKey 主键字段(id或者orgCode) |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/queryDepartTreeSync", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/queryDepartTreeSync", method = RequestMethod.GET) |
|
|
|
public Result<List<SysDepartTreeModel>> queryDepartTreeSync(@RequestParam(name = "pid", required = false) String parentId,@RequestParam(name = "ids", required = false) String ids, @RequestParam(name = "primaryKey", required = false) String primaryKey) { |
|
|
|
public Result<List<SysDepartTreeModel>> queryDepartTreeSync(@RequestParam(name = "pid", required = false) String parentId, @RequestParam(name = "ids", required = false) String ids, @RequestParam(name = "primaryKey", required = false) String primaryKey) { |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<>(); |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<>(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryTreeListByPid(parentId,ids, primaryKey); |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryTreeListByPid(parentId, ids, primaryKey); |
|
|
|
result.setResult(list); |
|
|
|
result.setResult(list); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
|
|
|
|
result.setSuccess(false); |
|
|
|
|
|
|
|
result.setMessage("查询失败"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @description: 根据当前登录角色查询 下级部门数据 |
|
|
|
|
|
|
|
* @param: [parentId, ids, primaryKey] |
|
|
|
|
|
|
|
* @return: org.jeecg.common.api.vo.Result<java.util.List<org.jeecg.modules.system.model.SysDepartTreeModel>> |
|
|
|
|
|
|
|
* @author: z.h.c |
|
|
|
|
|
|
|
* @date: 24/11/9 16:07 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@RequestMapping(value = "/queryDepartTreeSync4ZhuGuanBuMen", method = RequestMethod.GET) |
|
|
|
|
|
|
|
public Result<List<SysDepartTreeModel>> queryDepartTreeSync4ZhuGuanBuMen(@RequestParam(name = "parentOrgCode", required = false) String parentOrgCode, @RequestParam(name = "ids", required = false) String ids, @RequestParam(name = "primaryKey", required = false) String primaryKey) { |
|
|
|
|
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<>(); |
|
|
|
|
|
|
|
SysDepart sysDepart = sysDepartService.getOne(new LambdaQueryWrapper<SysDepart>().eq(SysDepart::getOrgCode, parentOrgCode)); |
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryTreeListByPid(sysDepart.getId(), ids, primaryKey); |
|
|
|
|
|
|
|
result.setResult(list); |
|
|
|
|
|
|
|
result.setSuccess(true); |
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
|
|
|
|
|
log.error(e.getMessage(), e); |
|
|
|
result.setSuccess(false); |
|
|
|
result.setSuccess(false); |
|
|
|
result.setMessage("查询失败"); |
|
|
|
result.setMessage("查询失败"); |
|
|
|
} |
|
|
|
} |
|
|
@ -189,7 +212,13 @@ public class SysDepartController { |
|
|
|
// List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>()
|
|
|
|
// List<SysDepart> departList = sysDepartService.list(new LambdaQueryWrapper<SysDepart>()
|
|
|
|
QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(depart, req.getParameterMap()); |
|
|
|
QueryWrapper<SysDepart> queryWrapper = QueryGenerator.initQueryWrapper(depart, req.getParameterMap()); |
|
|
|
queryWrapper.eq("del_flag", 0); |
|
|
|
queryWrapper.eq("del_flag", 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//单位法人角色时,只查询自己部门
|
|
|
|
|
|
|
|
if ("faren_admin".equals(user.getRoleCode())) { |
|
|
|
|
|
|
|
queryWrapper.eq("id", user.getOrgId()); |
|
|
|
|
|
|
|
} else { // 查询下级部门
|
|
|
|
queryWrapper.eq("parent_id", user.getOrgId()); |
|
|
|
queryWrapper.eq("parent_id", user.getOrgId()); |
|
|
|
|
|
|
|
} |
|
|
|
return sysDepartService.queryPageList(req, queryWrapper, pageSize, pageNo); |
|
|
|
return sysDepartService.queryPageList(req, queryWrapper, pageSize, pageNo); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
@ -211,7 +240,7 @@ public class SysDepartController { |
|
|
|
String[] arr = ids.split(","); |
|
|
|
String[] arr = ids.split(","); |
|
|
|
for (String id : arr) { |
|
|
|
for (String id : arr) { |
|
|
|
if (oConvertUtils.isNotEmpty(id)) { |
|
|
|
if (oConvertUtils.isNotEmpty(id)) { |
|
|
|
sysDepartService.lambdaUpdate().eq(SysDepart::getId,id).set(SysDepart::getStatus,status).update(); |
|
|
|
sysDepartService.lambdaUpdate().eq(SysDepart::getId, id).set(SysDepart::getStatus, status).update(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
@ -229,9 +258,9 @@ public class SysDepartController { |
|
|
|
* @param sysDepart |
|
|
|
* @param sysDepart |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:depart:add") |
|
|
|
// @RequiresPermissions("system:depart:add")
|
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/add", method = RequestMethod.POST) |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true) |
|
|
|
public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) { |
|
|
|
public Result<SysDepart> add(@RequestBody SysDepart sysDepart, HttpServletRequest request) { |
|
|
|
Result<SysDepart> result = new Result<SysDepart>(); |
|
|
|
Result<SysDepart> result = new Result<SysDepart>(); |
|
|
|
String username = JwtUtil.getUserNameByToken(request); |
|
|
|
String username = JwtUtil.getUserNameByToken(request); |
|
|
@ -243,7 +272,7 @@ public class SysDepartController { |
|
|
|
// FindsDepartsChildrenUtil.clearDepartIdModel();
|
|
|
|
// FindsDepartsChildrenUtil.clearDepartIdModel();
|
|
|
|
result.success("添加成功!"); |
|
|
|
result.success("添加成功!"); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
result.error500("操作失败"); |
|
|
|
result.error500("操作失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
@ -255,9 +284,9 @@ public class SysDepartController { |
|
|
|
* @param sysDepart |
|
|
|
* @param sysDepart |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:depart:edit") |
|
|
|
// @RequiresPermissions("system:depart:edit")
|
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST}) |
|
|
|
@RequestMapping(value = "/edit", method = {RequestMethod.PUT, RequestMethod.POST}) |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true) |
|
|
|
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) { |
|
|
|
public Result<SysDepart> edit(@RequestBody SysDepart sysDepart, HttpServletRequest request) { |
|
|
|
String username = JwtUtil.getUserNameByToken(request); |
|
|
|
String username = JwtUtil.getUserNameByToken(request); |
|
|
|
sysDepart.setUpdateBy(username); |
|
|
|
sysDepart.setUpdateBy(username); |
|
|
@ -280,19 +309,20 @@ public class SysDepartController { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 通过id删除 |
|
|
|
* 通过id删除 |
|
|
|
|
|
|
|
* |
|
|
|
* @param id |
|
|
|
* @param id |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:depart:delete") |
|
|
|
@RequiresPermissions("system:depart:delete") |
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.DELETE) |
|
|
|
@RequestMapping(value = "/delete", method = RequestMethod.DELETE) |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true) |
|
|
|
public Result<SysDepart> delete(@RequestParam(name="id",required=true) String id) { |
|
|
|
public Result<SysDepart> delete(@RequestParam(name = "id", required = true) String id) { |
|
|
|
|
|
|
|
|
|
|
|
Result<SysDepart> result = new Result<SysDepart>(); |
|
|
|
Result<SysDepart> result = new Result<SysDepart>(); |
|
|
|
SysDepart sysDepart = sysDepartService.getById(id); |
|
|
|
SysDepart sysDepart = sysDepartService.getById(id); |
|
|
|
if(sysDepart==null) { |
|
|
|
if (sysDepart == null) { |
|
|
|
result.error500("未找到对应实体"); |
|
|
|
result.error500("未找到对应实体"); |
|
|
|
}else { |
|
|
|
} else { |
|
|
|
sysDepartService.deleteDepart(id); |
|
|
|
sysDepartService.deleteDepart(id); |
|
|
|
//清除部门树内存
|
|
|
|
//清除部门树内存
|
|
|
|
//FindsDepartsChildrenUtil.clearSysDepartTreeList();
|
|
|
|
//FindsDepartsChildrenUtil.clearSysDepartTreeList();
|
|
|
@ -311,7 +341,7 @@ public class SysDepartController { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:depart:deleteBatch") |
|
|
|
@RequiresPermissions("system:depart:deleteBatch") |
|
|
|
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE) |
|
|
|
@RequestMapping(value = "/deleteBatch", method = RequestMethod.DELETE) |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true) |
|
|
|
public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
|
|
|
public Result<SysDepart> deleteBatch(@RequestParam(name = "ids", required = true) String ids) { |
|
|
|
|
|
|
|
|
|
|
|
Result<SysDepart> result = new Result<SysDepart>(); |
|
|
|
Result<SysDepart> result = new Result<SysDepart>(); |
|
|
@ -356,7 +386,7 @@ public class SysDepartController { |
|
|
|
result.setResult(list); |
|
|
|
result.setResult(list); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -370,15 +400,15 @@ public class SysDepartController { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/searchBy", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/searchBy", method = RequestMethod.GET) |
|
|
|
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord,@RequestParam(name = "myDeptSearch", required = false) String myDeptSearch) { |
|
|
|
public Result<List<SysDepartTreeModel>> searchBy(@RequestParam(name = "keyWord", required = true) String keyWord, @RequestParam(name = "myDeptSearch", required = false) String myDeptSearch) { |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>(); |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<List<SysDepartTreeModel>>(); |
|
|
|
//部门查询,myDeptSearch为1时为我的部门查询,登录用户为上级时查只查负责部门下数据
|
|
|
|
//部门查询,myDeptSearch为1时为我的部门查询,登录用户为上级时查只查负责部门下数据
|
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
String departIds = null; |
|
|
|
String departIds = null; |
|
|
|
if(oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals( CommonConstant.USER_IDENTITY_2 )){ |
|
|
|
if (oConvertUtils.isNotEmpty(user.getUserIdentity()) && user.getUserIdentity().equals(CommonConstant.USER_IDENTITY_2)) { |
|
|
|
departIds = user.getDepartIds(); |
|
|
|
departIds = user.getDepartIds(); |
|
|
|
} |
|
|
|
} |
|
|
|
List<SysDepartTreeModel> treeList = this.sysDepartService.searchByKeyWord(keyWord,myDeptSearch,departIds); |
|
|
|
List<SysDepartTreeModel> treeList = this.sysDepartService.searchByKeyWord(keyWord, myDeptSearch, departIds); |
|
|
|
if (treeList == null || treeList.size() == 0) { |
|
|
|
if (treeList == null || treeList.size() == 0) { |
|
|
|
result.setSuccess(false); |
|
|
|
result.setSuccess(false); |
|
|
|
result.setMessage("未查询匹配数据!"); |
|
|
|
result.setMessage("未查询匹配数据!"); |
|
|
@ -395,10 +425,10 @@ public class SysDepartController { |
|
|
|
* @param request |
|
|
|
* @param request |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/exportXls") |
|
|
|
@RequestMapping(value = "/exportXls") |
|
|
|
public ModelAndView exportXls(SysDepart sysDepart,HttpServletRequest request) { |
|
|
|
public ModelAndView exportXls(SysDepart sysDepart, HttpServletRequest request) { |
|
|
|
//------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------
|
|
|
|
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
|
|
|
//是否开启系统管理模块的多租户数据隔离【SAAS多租户模式】
|
|
|
|
if(MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL){ |
|
|
|
if (MybatisPlusSaasConfig.OPEN_SYSTEM_TENANT_CONTROL) { |
|
|
|
sysDepart.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0)); |
|
|
|
sysDepart.setTenantId(oConvertUtils.getInt(TenantContext.getTenant(), 0)); |
|
|
|
} |
|
|
|
} |
|
|
|
//------------------------------------------------------------------------------------------------
|
|
|
|
//------------------------------------------------------------------------------------------------
|
|
|
@ -425,7 +455,7 @@ public class SysDepartController { |
|
|
|
//step.2 组装导出数据
|
|
|
|
//step.2 组装导出数据
|
|
|
|
Integer tenantId = sysDepart == null ? null : sysDepart.getTenantId(); |
|
|
|
Integer tenantId = sysDepart == null ? null : sysDepart.getTenantId(); |
|
|
|
//update-begin---author:wangshuai---date:2024-07-05---for:【TV360X-1671】部门管理不支持选中的记录导出---
|
|
|
|
//update-begin---author:wangshuai---date:2024-07-05---for:【TV360X-1671】部门管理不支持选中的记录导出---
|
|
|
|
List<SysDepartExportVo> sysDepartExportVos = sysDepartService.getExportDepart(tenantId,idList); |
|
|
|
List<SysDepartExportVo> sysDepartExportVos = sysDepartService.getExportDepart(tenantId, idList); |
|
|
|
//update-end---author:wangshuai---date:2024-07-05---for:【TV360X-1671】部门管理不支持选中的记录导出---
|
|
|
|
//update-end---author:wangshuai---date:2024-07-05---for:【TV360X-1671】部门管理不支持选中的记录导出---
|
|
|
|
//导出文件名称
|
|
|
|
//导出文件名称
|
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表"); |
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表"); |
|
|
@ -435,7 +465,7 @@ public class SysDepartController { |
|
|
|
"1、标题为第三行,部门路径和部门名称的标题不允许修改,否则会匹配失败;第四行为数据填写范围;\n" + |
|
|
|
"1、标题为第三行,部门路径和部门名称的标题不允许修改,否则会匹配失败;第四行为数据填写范围;\n" + |
|
|
|
"2、部门路径用英文字符/分割,部门名称为部门路径的最后一位;\n" + |
|
|
|
"2、部门路径用英文字符/分割,部门名称为部门路径的最后一位;\n" + |
|
|
|
"3、部门从一级名称开始创建,如果有同级就需要多添加一行,如研发部/研发一部;研发部/研发二部;\n" + |
|
|
|
"3、部门从一级名称开始创建,如果有同级就需要多添加一行,如研发部/研发一部;研发部/研发二部;\n" + |
|
|
|
"4、自定义的部门编码需要满足规则才能导入。如一级部门编码为A01,那么子部门为A01A01,同级子部门为A01A02,编码固定为三位,首字母为A-Z,后两位为数字0-99,依次递增;", "导出人:"+user.getRealname(), "导出信息")); |
|
|
|
"4、自定义的部门编码需要满足规则才能导入。如一级部门编码为A01,那么子部门为A01A01,同级子部门为A01A02,编码固定为三位,首字母为A-Z,后两位为数字0-99,依次递增;", "导出人:" + user.getRealname(), "导出信息")); |
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, sysDepartExportVos); |
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, sysDepartExportVos); |
|
|
|
//update-end---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
|
|
|
|
//update-end---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
|
|
|
|
|
|
|
|
|
|
|
@ -453,7 +483,7 @@ public class SysDepartController { |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequiresPermissions("system:depart:importExcel") |
|
|
|
@RequiresPermissions("system:depart:importExcel") |
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/importExcel", method = RequestMethod.POST) |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true) |
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
|
|
|
List<String> errorMessageList = new ArrayList<>(); |
|
|
|
List<String> errorMessageList = new ArrayList<>(); |
|
|
@ -518,7 +548,7 @@ public class SysDepartController { |
|
|
|
|
|
|
|
|
|
|
|
//update-begin---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
|
|
|
|
//update-begin---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
|
|
|
|
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepartExportVo.class, params); |
|
|
|
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), SysDepartExportVo.class, params); |
|
|
|
sysDepartService.importSysDepart(listSysDeparts,errorMessageList); |
|
|
|
sysDepartService.importSysDepart(listSysDeparts, errorMessageList); |
|
|
|
//update-end---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
|
|
|
|
//update-end---author:wangshuai---date:2023-10-19---for:【QQYUN-5482】系统的部门导入导出也可以改成敲敲云模式的部门路径---
|
|
|
|
|
|
|
|
|
|
|
|
//清空部门缓存
|
|
|
|
//清空部门缓存
|
|
|
@ -528,8 +558,8 @@ public class SysDepartController { |
|
|
|
redisTemplate.delete(keys4); |
|
|
|
redisTemplate.delete(keys4); |
|
|
|
return ImportExcelUtil.imporReturnRes(errorMessageList.size(), listSysDeparts.size() - errorMessageList.size(), errorMessageList); |
|
|
|
return ImportExcelUtil.imporReturnRes(errorMessageList.size(), listSysDeparts.size() - errorMessageList.size(), errorMessageList); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return Result.error("文件导入失败:"+e.getMessage()); |
|
|
|
return Result.error("文件导入失败:" + e.getMessage()); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
try { |
|
|
|
file.getInputStream().close(); |
|
|
|
file.getInputStream().close(); |
|
|
@ -544,6 +574,7 @@ public class SysDepartController { |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 查询所有部门信息 |
|
|
|
* 查询所有部门信息 |
|
|
|
|
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@GetMapping("listAll") |
|
|
|
@GetMapping("listAll") |
|
|
@ -551,37 +582,38 @@ public class SysDepartController { |
|
|
|
Result<List<SysDepart>> result = new Result<>(); |
|
|
|
Result<List<SysDepart>> result = new Result<>(); |
|
|
|
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>(); |
|
|
|
LambdaQueryWrapper<SysDepart> query = new LambdaQueryWrapper<SysDepart>(); |
|
|
|
query.orderByAsc(SysDepart::getOrgCode); |
|
|
|
query.orderByAsc(SysDepart::getOrgCode); |
|
|
|
if(oConvertUtils.isNotEmpty(id)){ |
|
|
|
if (oConvertUtils.isNotEmpty(id)) { |
|
|
|
String[] arr = id.split(","); |
|
|
|
String[] arr = id.split(","); |
|
|
|
query.in(SysDepart::getId,arr); |
|
|
|
query.in(SysDepart::getId, arr); |
|
|
|
} |
|
|
|
} |
|
|
|
List<SysDepart> ls = this.sysDepartService.list(query); |
|
|
|
List<SysDepart> ls = this.sysDepartService.list(query); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setResult(ls); |
|
|
|
result.setResult(ls); |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 查询数据 查出所有部门,并以树结构数据格式响应给前端 |
|
|
|
* 查询数据 查出所有部门,并以树结构数据格式响应给前端 |
|
|
|
* |
|
|
|
* |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/queryTreeByKeyWord", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/queryTreeByKeyWord", method = RequestMethod.GET) |
|
|
|
public Result<Map<String,Object>> queryTreeByKeyWord(@RequestParam(name = "keyWord", required = false) String keyWord) { |
|
|
|
public Result<Map<String, Object>> queryTreeByKeyWord(@RequestParam(name = "keyWord", required = false) String keyWord) { |
|
|
|
Result<Map<String,Object>> result = new Result<>(); |
|
|
|
Result<Map<String, Object>> result = new Result<>(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
Map<String,Object> map=new HashMap(5); |
|
|
|
Map<String, Object> map = new HashMap(5); |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryTreeByKeyWord(keyWord); |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryTreeByKeyWord(keyWord); |
|
|
|
//根据keyWord获取用户信息
|
|
|
|
//根据keyWord获取用户信息
|
|
|
|
LambdaQueryWrapper<SysUser> queryUser = new LambdaQueryWrapper<SysUser>(); |
|
|
|
LambdaQueryWrapper<SysUser> queryUser = new LambdaQueryWrapper<SysUser>(); |
|
|
|
queryUser.eq(SysUser::getDelFlag,CommonConstant.DEL_FLAG_0); |
|
|
|
queryUser.eq(SysUser::getDelFlag, CommonConstant.DEL_FLAG_0); |
|
|
|
queryUser.and(i -> i.like(SysUser::getUsername, keyWord).or().like(SysUser::getRealname, keyWord)); |
|
|
|
queryUser.and(i -> i.like(SysUser::getUsername, keyWord).or().like(SysUser::getRealname, keyWord)); |
|
|
|
List<SysUser> sysUsers = this.sysUserService.list(queryUser); |
|
|
|
List<SysUser> sysUsers = this.sysUserService.list(queryUser); |
|
|
|
map.put("userList",sysUsers); |
|
|
|
map.put("userList", sysUsers); |
|
|
|
map.put("departList",list); |
|
|
|
map.put("departList", list); |
|
|
|
result.setResult(map); |
|
|
|
result.setResult(map); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
@ -619,9 +651,9 @@ public class SysDepartController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @功能:根据id 批量查询 |
|
|
|
|
|
|
|
* @param deptIds |
|
|
|
* @param deptIds |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
|
|
|
|
* @功能:根据id 批量查询 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/queryByIds", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/queryByIds", method = RequestMethod.GET) |
|
|
|
public Result<Collection<SysDepart>> queryByIds(@RequestParam(name = "deptIds") String deptIds) { |
|
|
|
public Result<Collection<SysDepart>> queryByIds(@RequestParam(name = "deptIds") String deptIds) { |
|
|
@ -635,40 +667,42 @@ public class SysDepartController { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@GetMapping("/getMyDepartList") |
|
|
|
@GetMapping("/getMyDepartList") |
|
|
|
public Result<List<SysDepart>> getMyDepartList(){ |
|
|
|
public Result<List<SysDepart>> getMyDepartList() { |
|
|
|
List<SysDepart> list = sysDepartService.getMyDepartList(); |
|
|
|
List<SysDepart> list = sysDepartService.getMyDepartList(); |
|
|
|
return Result.ok(list); |
|
|
|
return Result.ok(list); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 异步查询部门list |
|
|
|
* 异步查询部门list |
|
|
|
|
|
|
|
* |
|
|
|
* @param parentId 父节点 异步加载时传递 |
|
|
|
* @param parentId 父节点 异步加载时传递 |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/queryBookDepTreeSync", method = RequestMethod.GET) |
|
|
|
@RequestMapping(value = "/queryBookDepTreeSync", method = RequestMethod.GET) |
|
|
|
public Result<List<SysDepartTreeModel>> queryBookDepTreeSync(@RequestParam(name = "pid", required = false) String parentId, |
|
|
|
public Result<List<SysDepartTreeModel>> queryBookDepTreeSync(@RequestParam(name = "pid", required = false) String parentId, |
|
|
|
@RequestParam(name = "tenantId") Integer tenantId, |
|
|
|
@RequestParam(name = "tenantId") Integer tenantId, |
|
|
|
@RequestParam(name = "departName",required = false) String departName) { |
|
|
|
@RequestParam(name = "departName", required = false) String departName) { |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<>(); |
|
|
|
Result<List<SysDepartTreeModel>> result = new Result<>(); |
|
|
|
try { |
|
|
|
try { |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryBookDepTreeSync(parentId, tenantId, departName); |
|
|
|
List<SysDepartTreeModel> list = sysDepartService.queryBookDepTreeSync(parentId, tenantId, departName); |
|
|
|
result.setResult(list); |
|
|
|
result.setResult(list); |
|
|
|
result.setSuccess(true); |
|
|
|
result.setSuccess(true); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
} |
|
|
|
} |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 通过部门id和租户id获取用户 【低代码应用: 用于选择部门负责人】 |
|
|
|
* 通过部门id和租户id获取用户 【低代码应用: 用于选择部门负责人】 |
|
|
|
|
|
|
|
* |
|
|
|
* @param departId |
|
|
|
* @param departId |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@GetMapping("/getUsersByDepartTenantId") |
|
|
|
@GetMapping("/getUsersByDepartTenantId") |
|
|
|
public Result<List<SysUser>> getUsersByDepartTenantId(@RequestParam("departId") String departId){ |
|
|
|
public Result<List<SysUser>> getUsersByDepartTenantId(@RequestParam("departId") String departId) { |
|
|
|
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0); |
|
|
|
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0); |
|
|
|
List<SysUser> sysUserList = sysUserDepartService.getUsersByDepartTenantId(departId,tenantId); |
|
|
|
List<SysUser> sysUserList = sysUserDepartService.getUsersByDepartTenantId(departId, tenantId); |
|
|
|
return Result.ok(sysUserList); |
|
|
|
return Result.ok(sysUserList); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -678,7 +712,7 @@ public class SysDepartController { |
|
|
|
* @param request |
|
|
|
* @param request |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/appExportXls") |
|
|
|
@RequestMapping(value = "/appExportXls") |
|
|
|
public ModelAndView appExportXls(SysDepart sysDepart,HttpServletRequest request) { |
|
|
|
public ModelAndView appExportXls(SysDepart sysDepart, HttpServletRequest request) { |
|
|
|
// Step.1 组装查询条件
|
|
|
|
// Step.1 组装查询条件
|
|
|
|
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0); |
|
|
|
int tenantId = oConvertUtils.getInt(TenantContext.getTenant(), 0); |
|
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
|
|
|
ModelAndView mv = new ModelAndView(new JeecgEntityExcelView()); |
|
|
@ -688,7 +722,7 @@ public class SysDepartController { |
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表"); |
|
|
|
mv.addObject(NormalExcelConstants.FILE_NAME, "部门列表"); |
|
|
|
mv.addObject(NormalExcelConstants.CLASS, ExportDepartVo.class); |
|
|
|
mv.addObject(NormalExcelConstants.CLASS, ExportDepartVo.class); |
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
LoginUser user = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
|
|
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:"+user.getRealname(), "导出信息")); |
|
|
|
mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("部门列表数据", "导出人:" + user.getRealname(), "导出信息")); |
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList); |
|
|
|
mv.addObject(NormalExcelConstants.DATA_LIST, pageList); |
|
|
|
return mv; |
|
|
|
return mv; |
|
|
|
} |
|
|
|
} |
|
|
@ -699,7 +733,7 @@ public class SysDepartController { |
|
|
|
* @param request |
|
|
|
* @param request |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@RequestMapping(value = "/appImportExcel", method = RequestMethod.POST) |
|
|
|
@RequestMapping(value = "/appImportExcel", method = RequestMethod.POST) |
|
|
|
@CacheEvict(value= {CacheConstant.SYS_DEPARTS_CACHE,CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries=true) |
|
|
|
@CacheEvict(value = {CacheConstant.SYS_DEPARTS_CACHE, CacheConstant.SYS_DEPART_IDS_CACHE}, allEntries = true) |
|
|
|
public Result<?> appImportExcel(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
public Result<?> appImportExcel(HttpServletRequest request, HttpServletResponse response) { |
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
|
|
|
MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request; |
|
|
|
List<String> errorMessageList = new ArrayList<>(); |
|
|
|
List<String> errorMessageList = new ArrayList<>(); |
|
|
@ -714,7 +748,7 @@ public class SysDepartController { |
|
|
|
params.setNeedSave(true); |
|
|
|
params.setNeedSave(true); |
|
|
|
try { |
|
|
|
try { |
|
|
|
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), ExportDepartVo.class, params); |
|
|
|
listSysDeparts = ExcelImportUtil.importExcel(file.getInputStream(), ExportDepartVo.class, params); |
|
|
|
sysDepartService.importExcel(listSysDeparts,errorMessageList); |
|
|
|
sysDepartService.importExcel(listSysDeparts, errorMessageList); |
|
|
|
//清空部门缓存
|
|
|
|
//清空部门缓存
|
|
|
|
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*"); |
|
|
|
Set keys3 = redisTemplate.keys(CacheConstant.SYS_DEPARTS_CACHE + "*"); |
|
|
|
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*"); |
|
|
|
Set keys4 = redisTemplate.keys(CacheConstant.SYS_DEPART_IDS_CACHE + "*"); |
|
|
@ -722,8 +756,8 @@ public class SysDepartController { |
|
|
|
redisTemplate.delete(keys4); |
|
|
|
redisTemplate.delete(keys4); |
|
|
|
return ImportExcelUtil.imporReturnRes(errorMessageList.size(), listSysDeparts.size() - errorMessageList.size(), errorMessageList); |
|
|
|
return ImportExcelUtil.imporReturnRes(errorMessageList.size(), listSysDeparts.size() - errorMessageList.size(), errorMessageList); |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
log.error(e.getMessage(),e); |
|
|
|
log.error(e.getMessage(), e); |
|
|
|
return Result.error("文件导入失败:"+e.getMessage()); |
|
|
|
return Result.error("文件导入失败:" + e.getMessage()); |
|
|
|
} finally { |
|
|
|
} finally { |
|
|
|
try { |
|
|
|
try { |
|
|
|
file.getInputStream().close(); |
|
|
|
file.getInputStream().close(); |
|
|
|