增加根据用户获取全部机构树接口,给零售统计增加机构id参数

This commit is contained in:
jishenghua
2024-01-03 23:17:29 +08:00
parent da969b5633
commit 198ca74efa
4 changed files with 58 additions and 8 deletions

View File

@@ -205,6 +205,8 @@ public class BusinessConstants {
public static final String ROLE_TYPE_THIS_ORG = "本机构数据"; public static final String ROLE_TYPE_THIS_ORG = "本机构数据";
public static final String ROLE_TYPE_PUBLIC = "全部数据";
/** /**
* redis相关 * redis相关
* */ * */

View File

@@ -560,6 +560,7 @@ public class DepotItemController {
@RequestParam("endTime") String endTime, @RequestParam("endTime") String endTime,
@RequestParam(value = "organId", required = false) Long organId, @RequestParam(value = "organId", required = false) Long organId,
@RequestParam(value = "depotId", required = false) Long depotId, @RequestParam(value = "depotId", required = false) Long depotId,
@RequestParam(value = "organizationId", required = false) Long organizationId,
@RequestParam("materialParam") String materialParam, @RequestParam("materialParam") String materialParam,
@RequestParam("mpList") String mpList, @RequestParam("mpList") String mpList,
HttpServletRequest request)throws Exception { HttpServletRequest request)throws Exception {
@@ -569,6 +570,9 @@ public class DepotItemController {
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME); endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
try { try {
String [] creatorArray = depotHeadService.getCreatorArray(); String [] creatorArray = depotHeadService.getCreatorArray();
if(creatorArray == null && organizationId != null) {
creatorArray = depotHeadService.getCreatorArrayByOrg(organizationId);
}
String [] organArray = null; String [] organArray = null;
List<Long> depotList = depotService.parseDepotList(depotId); List<Long> depotList = depotService.parseDepotList(depotId);
Boolean forceFlag = systemConfigService.getForceApprovalFlag(); Boolean forceFlag = systemConfigService.getForceApprovalFlag();

View File

@@ -3,13 +3,13 @@ package com.jsh.erp.controller;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.jsh.erp.constants.BusinessConstants;
import com.jsh.erp.constants.ExceptionConstants; import com.jsh.erp.constants.ExceptionConstants;
import com.jsh.erp.datasource.entities.MaterialCategory;
import com.jsh.erp.datasource.entities.Organization; import com.jsh.erp.datasource.entities.Organization;
import com.jsh.erp.datasource.vo.TreeNode; import com.jsh.erp.datasource.vo.TreeNode;
import com.jsh.erp.exception.BusinessRunTimeException; import com.jsh.erp.exception.BusinessRunTimeException;
import com.jsh.erp.service.materialCategory.MaterialCategoryService;
import com.jsh.erp.service.organization.OrganizationService; import com.jsh.erp.service.organization.OrganizationService;
import com.jsh.erp.service.user.UserService;
import com.jsh.erp.utils.BaseResponseInfo; import com.jsh.erp.utils.BaseResponseInfo;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
@@ -36,6 +36,10 @@ public class OrganizationController {
@Resource @Resource
private OrganizationService organizationService; private OrganizationService organizationService;
@Resource
private UserService userService;
/** /**
* 根据id来查询机构信息 * 根据id来查询机构信息
* @param id * @param id
@@ -76,14 +80,11 @@ public class OrganizationController {
} }
/** /**
* create by: cjl
* description:
* 获取机构树数据 * 获取机构树数据
* create time: 2019/2/19 11:49 * @return
* @Param: * @throws Exception
* @return com.alibaba.fastjson.JSONArray
*/ */
@RequestMapping(value = "/getOrganizationTree") @GetMapping(value = "/getOrganizationTree")
@ApiOperation(value = "获取机构树数据") @ApiOperation(value = "获取机构树数据")
public JSONArray getOrganizationTree(@RequestParam("id") Long id) throws Exception{ public JSONArray getOrganizationTree(@RequestParam("id") Long id) throws Exception{
JSONArray arr=new JSONArray(); JSONArray arr=new JSONArray();
@@ -97,6 +98,32 @@ public class OrganizationController {
} }
return arr; return arr;
} }
/**
* 根据用户获取全部机构树
* @param request
* @return
* @throws Exception
*/
@GetMapping(value = "/getAllOrganizationTreeByUser")
@ApiOperation(value = "根据用户获取全部机构树")
public JSONArray getAllOrganizationTreeByUser(HttpServletRequest request) throws Exception{
JSONArray arr = new JSONArray();
Long userId = userService.getUserId(request);
String roleType = userService.getRoleTypeByUserId(userId).getType();
if(BusinessConstants.ROLE_TYPE_PUBLIC.equals(roleType)) {
List<TreeNode> organizationTree = organizationService.getOrganizationTree(null);
if(organizationTree!=null && organizationTree.size()>0){
for(TreeNode node: organizationTree){
String str = JSON.toJSONString(node);
JSONObject obj = JSON.parseObject(str);
arr.add(obj);
}
}
}
return arr;
}
/** /**
* create by: cjl * create by: cjl
* description: * description:

View File

@@ -45,6 +45,7 @@ import java.io.File;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.util.*; import java.util.*;
import java.util.stream.Collectors;
import static com.jsh.erp.utils.Tools.getCenternTime; import static com.jsh.erp.utils.Tools.getCenternTime;
import static com.jsh.erp.utils.Tools.getNow3; import static com.jsh.erp.utils.Tools.getNow3;
@@ -276,6 +277,22 @@ public class DepotHeadService {
return creatorArray; return creatorArray;
} }
/**
* 根据角色类型获取操作员数组
* @param organizationId
* @return
* @throws Exception
*/
public String[] getCreatorArrayByOrg(Long organizationId) throws Exception {
List<Long> userIdList = orgaUserRelService.getUserIdListByOrgId(organizationId);
if(userIdList.size()>0) {
List<String> userIdStrList = userIdList.stream().map(Object::toString).collect(Collectors.toList());
return StringUtil.listToStringArray(userIdStrList);
} else {
return null;
}
}
/** /**
* 获取机构数组 * 获取机构数组
* @return * @return