From 198ca74efae8046bdaf93e9697107edd1bd0ce02 Mon Sep 17 00:00:00 2001 From: jishenghua <752718920@qq.com> Date: Wed, 3 Jan 2024 23:17:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=A0=B9=E6=8D=AE=E7=94=A8?= =?UTF-8?q?=E6=88=B7=E8=8E=B7=E5=8F=96=E5=85=A8=E9=83=A8=E6=9C=BA=E6=9E=84?= =?UTF-8?q?=E6=A0=91=E6=8E=A5=E5=8F=A3=EF=BC=8C=E7=BB=99=E9=9B=B6=E5=94=AE?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E5=A2=9E=E5=8A=A0=E6=9C=BA=E6=9E=84id?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../jsh/erp/constants/BusinessConstants.java | 2 + .../erp/controller/DepotItemController.java | 4 ++ .../controller/OrganizationController.java | 43 +++++++++++++++---- .../service/depotHead/DepotHeadService.java | 17 ++++++++ 4 files changed, 58 insertions(+), 8 deletions(-) diff --git a/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java b/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java index f0436e0b..f6b4d016 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/constants/BusinessConstants.java @@ -205,6 +205,8 @@ public class BusinessConstants { public static final String ROLE_TYPE_THIS_ORG = "本机构数据"; + public static final String ROLE_TYPE_PUBLIC = "全部数据"; + /** * redis相关 * */ diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java index e5714551..422eb6fc 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/DepotItemController.java @@ -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 depotList = depotService.parseDepotList(depotId); Boolean forceFlag = systemConfigService.getForceApprovalFlag(); diff --git a/jshERP-boot/src/main/java/com/jsh/erp/controller/OrganizationController.java b/jshERP-boot/src/main/java/com/jsh/erp/controller/OrganizationController.java index 145f5c1d..2b7a2ffd 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/controller/OrganizationController.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/controller/OrganizationController.java @@ -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 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: diff --git a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java index 0a75cf1c..fb767fed 100644 --- a/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java +++ b/jshERP-boot/src/main/java/com/jsh/erp/service/depotHead/DepotHeadService.java @@ -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 userIdList = orgaUserRelService.getUserIdListByOrgId(organizationId); + if(userIdList.size()>0) { + List userIdStrList = userIdList.stream().map(Object::toString).collect(Collectors.toList()); + return StringUtil.listToStringArray(userIdStrList); + } else { + return null; + } + } + /** * 获取机构数组 * @return