package com.consum.base.controller;
|
|
import com.alibaba.excel.EasyExcel;
|
import com.alibaba.excel.context.AnalysisContext;
|
import com.alibaba.excel.event.AnalysisEventListener;
|
import com.alibaba.excel.exception.ExcelDataConvertException;
|
import com.consum.base.BaseController;
|
import com.consum.base.core.utils.FinSysTenantUtils;
|
import com.consum.base.pojo.FinSysTenantParam;
|
import com.consum.base.pojo.FinSysTenantSearchParam;
|
import com.consum.base.service.FinSysTenantServiceImpl;
|
import com.consum.base.service.FinSysTenantUserServiceImpl;
|
import com.consum.model.po.FinSysTenant;
|
import com.consum.model.po.FinSysTenantUser;
|
import com.consum.model.vo.FinSysTenantUserResult;
|
import com.walker.db.page.GenericPager;
|
import com.walker.infrastructure.tree.TreeNode;
|
import com.walker.infrastructure.utils.StringUtils;
|
import com.walker.web.ResponseValue;
|
import io.swagger.annotations.ApiImplicitParam;
|
import io.swagger.annotations.ApiImplicitParams;
|
import io.swagger.annotations.ApiOperation;
|
import java.io.IOException;
|
import java.io.InputStream;
|
import java.net.URLEncoder;
|
import java.util.ArrayList;
|
import java.util.HashMap;
|
import java.util.Iterator;
|
import java.util.LinkedList;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.TreeMap;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.core.io.ClassPathResource;
|
import org.springframework.core.io.InputStreamResource;
|
import org.springframework.core.io.Resource;
|
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpStatus;
|
import org.springframework.http.MediaType;
|
import org.springframework.http.ResponseEntity;
|
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestParam;
|
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.multipart.MultipartFile;
|
|
/**
|
* @Description 区划
|
* @Author wh
|
* @Date 2023/7/13 19:51
|
*/
|
@RestController
|
@RequestMapping("/pc/fin/sys/tenant")
|
public class FinSysTenantController extends BaseController {
|
|
private FinSysTenantServiceImpl finSysTenantService;
|
|
@Autowired
|
private FinSysTenantUserServiceImpl finSysTenantUserService;
|
|
@Autowired
|
public FinSysTenantController(FinSysTenantServiceImpl finSysTenantService) {
|
this.finSysTenantService = finSysTenantService;
|
}
|
|
@Value("${iplatform.file.file-root}")
|
private String filePath;
|
|
private boolean multiRoot = true;
|
private TreeNode dummyRoot = null;
|
private Map<Long, TreeNode> rootMap = new TreeMap();
|
private Map<Long, TreeNode> childMap = new TreeMap();
|
private long defaultParentId = 0L;
|
|
/**
|
* @Description 获取区划树
|
* @Author wh
|
* @Date 2023/7/11 11:15
|
*/
|
@GetMapping("/select/tree_fin_tenant")
|
public ResponseValue listOrgRootTree() {
|
List<FinSysTenant> finSysTenantList = null;
|
FinSysTenantUser finSysTenantUser = new FinSysTenantUser();
|
finSysTenantUser.setSysUserId(this.getCurrentUser().getId());
|
List<FinSysTenantUser> finSysTenantUserList = finSysTenantUserService.select(finSysTenantUser);
|
FinSysTenantUser user = null; // 系统用户
|
FinSysTenant finSysTenant1 = null;
|
List<TreeNode> treeRootList = null; // 数列表
|
FinSysTenant finSysTenant = new FinSysTenant();
|
// 获取地区父级
|
finSysTenantList = this.finSysTenantService.queryForTree();
|
// 根据登陆人id获取系统用户,如果有系统用户时
|
if (finSysTenantUserList.size() > 0) {
|
// 获取当前用户信息
|
user = finSysTenantUserList.get(0);
|
String tenantId = user.getTenantId();
|
finSysTenant.setId(new Long(tenantId));
|
// 查询区域
|
List<FinSysTenant> select = finSysTenantService.select(finSysTenant);
|
if (select.size() > 0) {
|
finSysTenant1 = select.get(0);
|
}
|
}
|
if (finSysTenant1 != null) {
|
if (finSysTenant1.getLv() != 1 && finSysTenant1.getParentId() != 0 && user != null) {
|
rootMap.clear();
|
this.childMap.clear();
|
this.defaultParentId = new Long(user.getTenantId());
|
// 根据父级获取子集
|
setEntityList(finSysTenantList);
|
treeRootList = getTreeRootList();
|
} else {
|
treeRootList = FinSysTenantUtils.getFinSysTenantTree(finSysTenantList);
|
}
|
} else {
|
treeRootList = FinSysTenantUtils.getFinSysTenantTree(finSysTenantList);
|
}
|
|
if (StringUtils.isEmptyList(treeRootList)) {
|
logger.error("未找到任何顶级区划树列表: treeNodeList = null");
|
} else {
|
logger.debug(treeRootList.toString());
|
}
|
return ResponseValue.success(treeRootList);
|
}
|
|
/**
|
* @Description 分页列表查询
|
* @Author llb
|
* @Date 2023/7/14 13:59
|
*/
|
@RequestMapping("/select/list")
|
public ResponseValue allocatedList(FinSysTenantSearchParam param) {
|
FinSysTenantUser sysInfo = getSysInfo();
|
if (sysInfo == null) {
|
return ResponseValue.error("登录用户信息不存在");
|
}
|
GenericPager<FinSysTenant> pager = null;
|
StringBuilder whStr = new StringBuilder("where 1=1 and is_delete = 0 ");
|
HashMap<String, Object> paramts = new HashMap<>();
|
if (param.getTenantId() == null) {
|
if (sysInfo.getLv() != 1) {
|
whStr.append(" and parent_id=:parent_id");
|
paramts.put("parent_id", sysInfo.getTenantId());
|
}
|
}
|
if (param.getStatus() != null) {
|
whStr.append(" and status = :status");
|
paramts.put("status", param.getStatus());
|
}
|
if (param.getTenantId() != null && param.getTenantId() != 0) {
|
whStr.append(" and parent_id=:parent_id");
|
paramts.put("parent_id", param.getTenantId());
|
}
|
if (param.getName() != null && !param.getName().equals("")) {
|
whStr.append(" and name like:name");
|
paramts.put("name", "%" + param.getName() + "%");
|
}
|
if (param.getCode() != null && !param.getCode().equals("")) {
|
whStr.append(" and code=:code");
|
paramts.put("code", param.getCode());
|
}
|
whStr.append(" order by code ASC ");
|
pager = this.finSysTenantService.selectSplit(new FinSysTenant(), whStr.toString(), paramts);
|
return ResponseValue.success(pager);
|
}
|
|
/**
|
* @Author :power
|
* @Date : 2023/7/20 10:58 查询项目配置中 参与范围 (省/地市;地市) 该方法应是全局可见
|
*/
|
@GetMapping("/project/selectTreeServingByProject")
|
public ResponseValue selectTreeServingByProject() {
|
// 省进入 查询 省和地市 ;地市进入 查询自己地市
|
// TODO Long.valueOf(getSysInfo().getTenantId())
|
FinSysTenant finSysTenant =
|
this.finSysTenantService.get(new FinSysTenant(Long.valueOf(getSysInfo().getTenantId())));
|
if (finSysTenant.getLv() == 3) {
|
return ResponseValue.error("县区级别无法查看");
|
}
|
List<FinSysTenant> finSysTenantList =
|
this.finSysTenantService.queryTreeById(finSysTenant.getId(), finSysTenant.getLv());
|
List<TreeNode> treeNodeList = new ArrayList<>();
|
// 省查本身及以下 市查本级 县无权查看
|
if (finSysTenant.getLv() == 1) {
|
treeNodeList = FinSysTenantUtils.getFinSysTenantTree(finSysTenantList);
|
if (StringUtils.isEmptyList(treeNodeList)) {
|
logger.error("未找到任何顶级区划树列表: treeNodeList = null");
|
} else {
|
logger.debug(treeNodeList.toString());
|
}
|
} else {
|
TreeNode treeNode = new TreeNode(finSysTenantList.get(0).getId(), finSysTenantList.get(0).getName(),
|
new ArrayList<>(), finSysTenantList.get(0).getParentId(), finSysTenantList.get(0).getCode());
|
treeNodeList.add(treeNode);
|
}
|
return ResponseValue.success(treeNodeList);
|
}
|
|
/**
|
* @Author :power
|
* @Date : 2023/7/20 16:33 项目配置 - 范围 - 查询县区 (省查询所有 地市查询自己管辖)
|
*/
|
@GetMapping("/project/selectCounty")
|
public ResponseValue selectCounty() {
|
// 省进入 查询 省和地市 ;地市进入 查询自己地市
|
// TODO Long.valueOf(getSysInfo().getTenantId())
|
FinSysTenant finSysTenant =
|
this.finSysTenantService.get(new FinSysTenant(Long.valueOf(getSysInfo().getTenantId())));
|
if (finSysTenant.getLv() == 3) {
|
return ResponseValue.error("县区级别无法查看");
|
}
|
Map<Long, List<FinSysTenant>> finSysTenantList =
|
this.finSysTenantService.queryCountyByCityCode(finSysTenant.getId(), finSysTenant.getLv());
|
return ResponseValue.success(finSysTenantList);
|
}
|
|
public void setEntityList(List<FinSysTenant> datas) {
|
|
if (!StringUtils.isEmptyList(datas)) {
|
TreeNode node = null;
|
Iterator var3 = datas.iterator();
|
|
while (var3.hasNext()) {
|
Object obj = var3.next();
|
node = this.toTreeNode((FinSysTenant) obj);
|
|
if (node.getId() == this.defaultParentId) {
|
this.rootMap.put(node.getId(), node);
|
} else if (node.getParentId() == this.defaultParentId) {
|
this.childMap.put(node.getId(), node);
|
}
|
}
|
|
if (this.rootMap.size() == 0) {
|
throw new IllegalArgumentException("未找到根节点。");
|
} else {
|
if (this.childMap != null && this.childMap.size() > 0) {
|
this.mountTree(this.childMap);
|
}
|
|
if (this.dummyRoot != null) {
|
var3 = this.rootMap.values().iterator();
|
|
while (var3.hasNext()) {
|
TreeNode n = (TreeNode) var3.next();
|
n.setParentId(this.defaultParentId);
|
this.dummyRoot.addChild(n);
|
}
|
}
|
|
}
|
}
|
}
|
|
private void mountTree(Map<Long, TreeNode> childMap) {
|
TreeNode _node = null;
|
Iterator i = childMap.values().iterator();
|
|
while (i.hasNext()) {
|
_node = (TreeNode) i.next();
|
this.mountMiddleNode(_node, childMap);
|
}
|
|
}
|
|
private void mountMiddleNode(TreeNode currentNode, Map<Long, TreeNode> childMap) {
|
TreeNode _parentNode = (TreeNode) this.rootMap.get(currentNode.getParentId());
|
if (_parentNode == null) {
|
_parentNode = (TreeNode) childMap.get(currentNode.getId());
|
if (_parentNode == null) {
|
throw new NullPointerException("parent node not found, current: " + currentNode);
|
}
|
|
_parentNode.addChild(currentNode);
|
this.mountMiddleNode(_parentNode, childMap);
|
} else if (_parentNode.getId() == this.defaultParentId) {
|
_parentNode.addChild(currentNode);
|
}
|
|
}
|
|
protected TreeNode toTreeNode(FinSysTenant entity) {
|
TreeNode treeNode =
|
new TreeNode(entity.getId(), entity.getName(), (List) null, entity.getParentId(), entity.getCode());
|
return treeNode;
|
}
|
|
public List<TreeNode> getTreeRootList() {
|
if (!this.multiRoot) {
|
throw new IllegalStateException("存在多个根节点,请调用方法:getTreeRoot().");
|
} else {
|
List<TreeNode> list = new ArrayList();
|
Iterator var2 = this.rootMap.values().iterator();
|
|
while (var2.hasNext()) {
|
TreeNode node = (TreeNode) var2.next();
|
list.add(node);
|
}
|
return list;
|
}
|
}
|
|
/**
|
* @Description 不分页查询
|
*/
|
@RequestMapping("/select/allList")
|
public ResponseValue allList(FinSysTenantSearchParam param) {
|
StringBuilder whStr = new StringBuilder("where 1=1 and status = 1 and is_delete = 0 ");
|
HashMap parameter = new HashMap<>();
|
if (param.getFirstZmS() != null && !param.getFirstZmS().equals("")) {
|
whStr.append(" and name is not null and(");
|
String upperCase = param.getFirstZmS().toUpperCase();
|
whStr.append("instr(:upperFirstZmS,F_PINYIN( SUBSTR(name, 1, 1)))>0 or instr(:upperFirstZmS2,SUBSTR(name, 1, 1))>0");
|
parameter.put("upperFirstZmS", upperCase);
|
parameter.put("upperFirstZmS2", upperCase);
|
whStr.append(")");
|
}
|
whStr.append(" order by lv asc, F_PINYIN( SUBSTR(name, 1, 1)) ASC ");
|
List<FinSysTenant> select = this.finSysTenantService.select(new FinSysTenant(), whStr.toString(), parameter);
|
return ResponseValue.success(select);
|
}
|
|
|
/**
|
* 删除
|
*
|
* @author 卢庆阳
|
* @date 2023/10/4
|
*/
|
@PostMapping("/del")
|
public ResponseValue del(@RequestBody FinSysTenantParam param) {
|
if (param.getId() == null) {
|
return ResponseValue.error("机构id为空");
|
}
|
int num = this.finSysTenantService.updateById(param, this.getSysInfo());
|
return num > 0 ? ResponseValue.success(1) : ResponseValue.error("删除失败!");
|
}
|
|
/**
|
* 添加机构
|
*
|
* @author 卢庆阳
|
* @date 2023/10/4
|
*/
|
@PostMapping("/add")
|
public ResponseValue add(@RequestBody FinSysTenantParam param) {
|
if (param == null) {
|
return ResponseValue.error("参数为空");
|
}
|
if (StringUtils.isEmpty(param.getCode())) {
|
return ResponseValue.error("机构编号为空");
|
}
|
if (StringUtils.isEmpty(param.getName())) {
|
return ResponseValue.error("机构名称为空");
|
}
|
FinSysTenant finSysTenant = this.finSysTenantService.selectByTenantId(param.getCode());
|
if (finSysTenant != null) {
|
return ResponseValue.error("机构编号已存在");
|
}
|
String parentIdStr = param.getParentId() + "";
|
int lv = parentIdStr.length() / 3 + 1;
|
if (lv > 4) {
|
return ResponseValue.error("不能创建支局以下机构");
|
}
|
int num = this.finSysTenantService.addFinSysTenant(param, this.getSysInfo(), lv);
|
if (num > 0) {
|
return ResponseValue.success(1);
|
}
|
return ResponseValue.error("插入失败!");
|
}
|
|
@GetMapping("getImportTemplate")
|
public ResponseEntity<InputStreamResource> getImportTemplate() throws IOException {
|
// 从当前项目资源目录获取文件
|
Resource resource = new ClassPathResource("import/机构导入模板.xls");
|
// 获取文件输入流
|
InputStream inputStream = resource.getInputStream();
|
// 设置HTTP响应头
|
HttpHeaders headers = new HttpHeaders();
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
String encodedFilename = URLEncoder.encode("机构导入模板.xls", "UTF-8");
|
headers.setContentDispositionFormData("attachment", encodedFilename);
|
// 创建InputStreamResource对象,将文件输入流包装起来
|
InputStreamResource resourceToDownload = new InputStreamResource(inputStream);
|
// 返回带有文件输入流的ResponseEntity对象
|
return ResponseEntity
|
.status(HttpStatus.OK)
|
.headers(headers)
|
.body(resourceToDownload);
|
}
|
|
|
/**
|
* @return 获取项目导入的模板
|
* @throws IOException
|
*/
|
@GetMapping("getProjectImportTemplate")
|
public ResponseEntity<InputStreamResource> getProjectImportTemplate() throws IOException {
|
// 从当前项目资源目录获取文件
|
Resource resource = new ClassPathResource("import/项目导入模板.xls");
|
// 获取文件输入流
|
InputStream inputStream = resource.getInputStream();
|
// 设置HTTP响应头
|
HttpHeaders headers = new HttpHeaders();
|
headers.setContentType(MediaType.APPLICATION_OCTET_STREAM);
|
String encodedFilename = URLEncoder.encode("项目导入模板.xls", "UTF-8");
|
headers.setContentDispositionFormData("attachment", encodedFilename);
|
// 创建InputStreamResource对象,将文件输入流包装起来
|
InputStreamResource resourceToDownload = new InputStreamResource(inputStream);
|
// 返回带有文件输入流的ResponseEntity对象
|
return ResponseEntity
|
.status(HttpStatus.OK)
|
.headers(headers)
|
.body(resourceToDownload);
|
}
|
|
|
@PostMapping("import")
|
public ResponseValue upload(@RequestParam Long pid, MultipartFile file) throws IOException {
|
String originalFilename = file.getOriginalFilename();
|
if (!"xls".equals(originalFilename.substring(originalFilename.lastIndexOf(".") + 1))) {
|
return ResponseValue.error("文件格式有误!");
|
}
|
FinSysTenantUser sysInfo = this.getSysInfo();
|
if (sysInfo == null) {
|
return ResponseValue.error("当前登录用户为空");
|
}
|
String parentIdStr = pid + "";
|
int lv = parentIdStr.length() / 3 + 1;
|
if (lv > 3) {
|
return ResponseValue.error("不能创建县(区)级以下机构");
|
}
|
|
EasyExcel.read(file.getInputStream(), FinSysTenantParam.class, new AnalysisEventListener<FinSysTenantParam>() {
|
LinkedList<FinSysTenantParam> finSysTenantParams = new LinkedList<>();
|
|
@Override
|
public void invoke(FinSysTenantParam finSysTenantParam, AnalysisContext analysisContext) {
|
if (StringUtils.isEmpty(finSysTenantParam.getCode()) || finSysTenantParam.getCode().length() > 20) {
|
IllegalStateException exception = new IllegalStateException(
|
"第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构编号不能为空或长度大于20");
|
throw exception;
|
}
|
if (null != finSysTenantService.selectByTenantId(finSysTenantParam.getCode())) {
|
throw new IllegalStateException("第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构编号已存在");
|
}
|
if (StringUtils.isEmpty(finSysTenantParam.getName()) || finSysTenantParam.getName().length() > 100) {
|
IllegalStateException exception = new IllegalStateException(
|
"第" + analysisContext.readSheetHolder().getRowIndex() + "行,机构名称不能为空或长度大于100");
|
throw exception;
|
}
|
finSysTenantParam.setParentId(pid);
|
finSysTenantParam.setStatus(1);
|
finSysTenantParam.setSummary("系统导入");
|
finSysTenantParams.add(finSysTenantParam);
|
}
|
|
@Override
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
finSysTenantService.insertFinSysTenantBatch(finSysTenantParams, sysInfo, lv);
|
}
|
|
@Override
|
public void onException(Exception exception, AnalysisContext context) {
|
// 如果是某一个单元格的转换异常 能获取到具体行号
|
if (exception instanceof ExcelDataConvertException) {
|
ExcelDataConvertException excelDataConvertException = (ExcelDataConvertException) exception;
|
logger.error("第{}行,第{}列解析异常,数据为:{}", excelDataConvertException.getRowIndex(),
|
excelDataConvertException.getColumnIndex() + 1, excelDataConvertException.getCellData().getStringValue());
|
throw new IllegalStateException(
|
"第" + (excelDataConvertException.getRowIndex() + 1) + "行,第" + (excelDataConvertException.getColumnIndex() + 1) + "列解析异常,异常数据为:[ "
|
+ excelDataConvertException.getCellData().getStringValue() + " ]");
|
}
|
if (exception instanceof IllegalStateException) {
|
throw (IllegalStateException) exception;
|
}
|
|
}
|
|
}).doReadAll();
|
|
return ResponseValue.success("导入成功!", 1);
|
}
|
|
/**
|
* 编辑
|
*
|
* @author 卢庆阳
|
* @date 2023/10/6
|
*/
|
@PostMapping("/edit")
|
public ResponseValue edit(@RequestBody FinSysTenant finSysTenant) {
|
Long id = finSysTenant.getId();
|
if (id == null || id.longValue() <= 0) {
|
return ResponseValue.error("编辑的机构不存在");
|
}
|
FinSysTenantUser sysInfo = getSysInfo();
|
if (sysInfo == null) {
|
return ResponseValue.error("登录用户信息不存在");
|
}
|
// FinSysTenant finSysTenant1 = this.finSysTenantService.selectByTenantId(sysInfo.getTenantCode());
|
// if (finSysTenant1.getLv() != 1) {
|
// return ResponseValue.error("暂无修改权限");
|
// }
|
int num = this.finSysTenantService.updateFinSysTenant(finSysTenant, this.getSysInfo());
|
return num > 0 ? ResponseValue.success(1) : ResponseValue.error("编辑失败!");
|
}
|
|
/**
|
* @Description 根据OrgCode获取上级及本级人员ID。可能是省市县
|
* @Author wh
|
* @Date 2023/10/4 15:37
|
*/
|
@GetMapping("getUserByOrgId")
|
public ResponseValue getUserByOrgCode(Long orgId) {
|
if (orgId == null) {
|
return ResponseValue.error("机构不能为空");
|
}
|
ArrayList<FinSysTenantUserResult> finSysTenantUserResults = new ArrayList<>();
|
// 本级
|
FinSysTenant finSysTenant = this.finSysTenantService.get(new FinSysTenant(orgId));
|
if (finSysTenant.getLv() == 1) {
|
// 省
|
List<FinSysTenantUser> finSysTenantUserList = this.finSysTenantUserService.getByOrgId(orgId);
|
if (!StringUtils.isEmptyList(finSysTenantUserList)) {
|
FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
|
finSysTenantUserResult.setOrgId(finSysTenant.getId());
|
finSysTenantUserResult.setOrgName(finSysTenant.getName());
|
finSysTenantUserResult.setUserList(finSysTenantUserList);
|
finSysTenantUserResults.add(finSysTenantUserResult);
|
}
|
}
|
if (finSysTenant.getLv() == 2) {
|
// 市
|
List<FinSysTenantUser> finSysTenantUserList2 = this.finSysTenantUserService.getByOrgId(orgId);
|
if (!StringUtils.isEmptyList(finSysTenantUserList2)) {
|
FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
|
finSysTenantUserResult.setOrgId(finSysTenant.getId());
|
finSysTenantUserResult.setOrgName(finSysTenant.getName());
|
finSysTenantUserResult.setUserList(finSysTenantUserList2);
|
finSysTenantUserResults.add(finSysTenantUserResult);
|
}
|
// 省
|
FinSysTenant finSysTenant1 = this.finSysTenantService.get(new FinSysTenant(finSysTenant.getParentId()));
|
List<FinSysTenantUser> finSysTenantUserList = this.finSysTenantUserService.getByOrgId(finSysTenant1.getId());
|
if (!StringUtils.isEmptyList(finSysTenantUserList)) {
|
FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
|
finSysTenantUserResult.setOrgId(finSysTenant1.getId());
|
finSysTenantUserResult.setOrgName(finSysTenant1.getName());
|
finSysTenantUserResult.setUserList(finSysTenantUserList);
|
finSysTenantUserResults.add(finSysTenantUserResult);
|
}
|
}
|
if (finSysTenant.getLv() == 3) {
|
// 县
|
List<FinSysTenantUser> finSysTenantUserList3 = this.finSysTenantUserService.getByOrgId(orgId);
|
if (!StringUtils.isEmptyList(finSysTenantUserList3)) {
|
FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
|
finSysTenantUserResult.setOrgId(finSysTenant.getId());
|
finSysTenantUserResult.setOrgName(finSysTenant.getName());
|
finSysTenantUserResult.setUserList(finSysTenantUserList3);
|
finSysTenantUserResults.add(finSysTenantUserResult);
|
}
|
// 市
|
FinSysTenant finSysTenant2 = this.finSysTenantService.get(new FinSysTenant(finSysTenant.getParentId()));
|
List<FinSysTenantUser> finSysTenantUserList2 = this.finSysTenantUserService.getByOrgId(finSysTenant2.getId());
|
if (!StringUtils.isEmptyList(finSysTenantUserList2)) {
|
FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
|
finSysTenantUserResult.setOrgId(finSysTenant2.getId());
|
finSysTenantUserResult.setOrgName(finSysTenant2.getName());
|
finSysTenantUserResult.setUserList(finSysTenantUserList2);
|
finSysTenantUserResults.add(finSysTenantUserResult);
|
}
|
// 省
|
FinSysTenant finSysTenant1 = this.finSysTenantService.get(new FinSysTenant(finSysTenant2.getParentId()));
|
List<FinSysTenantUser> finSysTenantUserList = this.finSysTenantUserService.getByOrgId(finSysTenant1.getId());
|
if (!StringUtils.isEmptyList(finSysTenantUserList)) {
|
FinSysTenantUserResult finSysTenantUserResult = new FinSysTenantUserResult();
|
finSysTenantUserResult.setOrgId(finSysTenant1.getId());
|
finSysTenantUserResult.setOrgName(finSysTenant1.getName());
|
finSysTenantUserResult.setUserList(finSysTenantUserList);
|
finSysTenantUserResults.add(finSysTenantUserResult);
|
}
|
}
|
return ResponseValue.success(finSysTenantUserResults);
|
}
|
|
@ApiOperation(value = "获取父级机构", notes = "获取父级机构")
|
@ApiImplicitParams({
|
@ApiImplicitParam(name = "Authorization", value = "token", dataType = "String", paramType = "header"),
|
})
|
@GetMapping("/get/parent/tenant")
|
public ResponseValue getParentTenant() {
|
FinSysTenantUser sysInfo = getSysInfo();
|
if (sysInfo == null) {
|
return ResponseValue.error("登录用户信息不存在");
|
}
|
String tenantId = sysInfo.getTenantId();
|
FinSysTenant finSysTenant = new FinSysTenant();
|
finSysTenant.setTempId(Long.valueOf(tenantId));
|
FinSysTenant userTenant = this.finSysTenantService.get(finSysTenant);
|
Long parentId = userTenant.getParentId();
|
//第一级
|
if (parentId == 0) {
|
return ResponseValue.success(userTenant);
|
} else {
|
FinSysTenant param = new FinSysTenant();
|
param.setTempId(Long.valueOf(parentId));
|
FinSysTenant result = this.finSysTenantService.get(param);
|
return ResponseValue.success(result);
|
}
|
}
|
}
|