增加根据用户获取全部机构树接口,给零售统计增加机构id参数
This commit is contained in:
@@ -205,6 +205,8 @@ public class BusinessConstants {
|
||||
|
||||
public static final String ROLE_TYPE_THIS_ORG = "本机构数据";
|
||||
|
||||
public static final String ROLE_TYPE_PUBLIC = "全部数据";
|
||||
|
||||
/**
|
||||
* redis相关
|
||||
* */
|
||||
|
||||
@@ -560,6 +560,7 @@ public class DepotItemController {
|
||||
@RequestParam("endTime") String endTime,
|
||||
@RequestParam(value = "organId", required = false) Long organId,
|
||||
@RequestParam(value = "depotId", required = false) Long depotId,
|
||||
@RequestParam(value = "organizationId", required = false) Long organizationId,
|
||||
@RequestParam("materialParam") String materialParam,
|
||||
@RequestParam("mpList") String mpList,
|
||||
HttpServletRequest request)throws Exception {
|
||||
@@ -569,6 +570,9 @@ public class DepotItemController {
|
||||
endTime = Tools.parseDayToTime(endTime,BusinessConstants.DAY_LAST_TIME);
|
||||
try {
|
||||
String [] creatorArray = depotHeadService.getCreatorArray();
|
||||
if(creatorArray == null && organizationId != null) {
|
||||
creatorArray = depotHeadService.getCreatorArrayByOrg(organizationId);
|
||||
}
|
||||
String [] organArray = null;
|
||||
List<Long> depotList = depotService.parseDepotList(depotId);
|
||||
Boolean forceFlag = systemConfigService.getForceApprovalFlag();
|
||||
|
||||
@@ -3,13 +3,13 @@ package com.jsh.erp.controller;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.jsh.erp.constants.BusinessConstants;
|
||||
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.vo.TreeNode;
|
||||
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.user.UserService;
|
||||
import com.jsh.erp.utils.BaseResponseInfo;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -36,6 +36,10 @@ public class OrganizationController {
|
||||
|
||||
@Resource
|
||||
private OrganizationService organizationService;
|
||||
|
||||
@Resource
|
||||
private UserService userService;
|
||||
|
||||
/**
|
||||
* 根据id来查询机构信息
|
||||
* @param id
|
||||
@@ -76,14 +80,11 @@ public class OrganizationController {
|
||||
}
|
||||
|
||||
/**
|
||||
* create by: cjl
|
||||
* description:
|
||||
* 获取机构树数据
|
||||
* create time: 2019/2/19 11:49
|
||||
* @Param:
|
||||
* @return com.alibaba.fastjson.JSONArray
|
||||
* @return
|
||||
* @throws Exception
|
||||
*/
|
||||
@RequestMapping(value = "/getOrganizationTree")
|
||||
@GetMapping(value = "/getOrganizationTree")
|
||||
@ApiOperation(value = "获取机构树数据")
|
||||
public JSONArray getOrganizationTree(@RequestParam("id") Long id) throws Exception{
|
||||
JSONArray arr=new JSONArray();
|
||||
@@ -97,6 +98,32 @@ public class OrganizationController {
|
||||
}
|
||||
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
|
||||
* description:
|
||||
|
||||
@@ -45,6 +45,7 @@ import java.io.File;
|
||||
import java.math.BigDecimal;
|
||||
import java.sql.Timestamp;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.jsh.erp.utils.Tools.getCenternTime;
|
||||
import static com.jsh.erp.utils.Tools.getNow3;
|
||||
@@ -276,6 +277,22 @@ public class DepotHeadService {
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user