Browse Source

多块牌子人员权限调整

songwb 1 year ago
parent
commit
b7f0e21a5a

+ 70 - 16
ims-service/ims-eval/src/main/java/com/ims/eval/cache/CacheContext.java

@@ -1,5 +1,6 @@
 package com.ims.eval.cache;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.ims.eval.entity.*;
 import com.ims.eval.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -7,7 +8,9 @@ import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
 
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 /**
  * 初始化缓存类
@@ -31,13 +34,26 @@ public class CacheContext implements CommandLineRunner {
 	private IOrganizationEvaluationRuleService organizationEvaluationRuleService;
 
 
+	@Autowired
+	private IMultipleBrandService multipleBrandService;
+
+	//按公司
+	//public static Map<String, OrganizationStructure> brandMap = new HashMap<>();
+
+	//按单位营业收入配置
+	public static Map<String, MultipleBrand> brandMap = new HashMap<>();
+
+//	public static final ThreadLocal<List<String>> childCompany = new ThreadLocal<>();
+	public static final Map<String, String> childCompanyId = new LinkedHashMap<>();
+
+
 
 	//初始化字典表
 	public static List<DataDictionary> ddList = new ArrayList<>();
 	public static Map<String, DataDictionary> ddMap = new HashMap<>();
 	public static Map<String, String> ddNameMap = new HashMap<>();
 	public static Map<String, String> ddValueMap = new HashMap<>();
-	public static Map<String, List<DataDictionary>> ddSuperKeyMap  = new HashMap<>();
+	public static Map<String, List<DataDictionary>> ddSuperKeyMap = new HashMap<>();
 
 
 	//指标分类
@@ -50,7 +66,6 @@ public class CacheContext implements CommandLineRunner {
 	public static Map<String, BinStage> bseCodeObject = new HashMap<>();
 
 
-
 	//生产经营业务分类
 	public static List<BinSection> bsnList = new ArrayList<>();
 	public static Map<String, BinSection> bsnIdObject = new HashMap<>();
@@ -60,8 +75,7 @@ public class CacheContext implements CommandLineRunner {
 
 	//权重
 	public static Map<String, List<OrganizationEvaluationRule>> ruleMap = new HashMap();
-	public static  List<OrganizationEvaluationRule> ruleList = new ArrayList<>();
-
+	public static List<OrganizationEvaluationRule> ruleList = new ArrayList<>();
 
 	@Override
 	public void run(String... args) throws Exception {
@@ -70,14 +84,56 @@ public class CacheContext implements CommandLineRunner {
 		initBinStage();
 		initBinSection();
 		initOrganizationEvaluationRule();
+		initTree();
+	}
+
+
+	private void initTree() {
+		//按照单位营业收入配置
+		IPage<MultipleBrand> tree = multipleBrandService.getMultipleBranTree(1, 1000, null, null, "", "", "", null);
+		List<MultipleBrand> records = tree.getRecords();
+
+		for (MultipleBrand record : records) {
+			brandMap.put(record.getOrganizationId(), record);
+			if (record.getChildren()==null) continue;
+			for (MultipleBrand child : record.getChildren()) {
+				brandMap.put(child.getOrganizationId(), child);
+			}
+		}
 
+		/*
+		//按照公司
+		List<OrganizationStructure> loss = organizationStructureService.getList2(null, null, null);
+		brandMap = loss.stream().collect(Collectors.toMap(OrganizationStructure::getId, Function.identity()));*/
+	}
+
+	public static List<String> getChildList(String id) {
+		MultipleBrand brand = brandMap.get(id);
+		List<String> zgs = new ArrayList<>();
+		if (brand==null){
+			return zgs;
+		}
+		zgs.add(brand.getOrganizationId());
+		if(brand.getChildren() == null) return zgs;
+		for (MultipleBrand child : brand.getChildren()) {
+			List<String> childList = getChildList(child.getOrganizationId());
+			zgs.addAll(childList);
+		}
+		return zgs;
+		/*
+		//按公司
+		List<String> ids = new ArrayList<>();
+		ids.add(id);
+		List<String> collects = brandMap.values().stream().filter(i -> id.equals(i.getParentId())).map(OrganizationStructure::getId).collect(Collectors.toList());
+		ids.addAll(collects);
+		return ids;*/
 	}
 
 
 	/**
 	 * 初始化数据字典表
 	 */
-	public void initDataDictionary(){
+	public void initDataDictionary() {
 		//清理集合中的数据
 		ddList.clear();
 		ddMap.clear();
@@ -98,27 +154,26 @@ public class CacheContext implements CommandLineRunner {
 	/**
 	 * 初始化指标分类
 	 */
-	public void initIndicatorType(){
+	public void initIndicatorType() {
 		//清理集合中的数据
 		itList.clear();
 
-		itList = iIndicatorTypeService.list().stream().filter(t->!t.getDelFlag()).collect(Collectors.toList());
+		itList = iIndicatorTypeService.list().stream().filter(t -> !t.getDelFlag()).collect(Collectors.toList());
 		itList.sort(Comparator.comparing(IndicatorType::getOrderNum));
 	}
 
 
-
 	/**
 	 * 初始化经营阶段分类
 	 */
-	public void initBinStage(){
+	public void initBinStage() {
 		//清理集合中的数据
 		bseList.clear();
 		bseIdMap.clear();
 		bseIdObject.clear();
 		bseCodeObject.clear();
 
-		bseList = binStageService.list().stream().filter(t->!t.getDelFlag()).collect(Collectors.toList());
+		bseList = binStageService.list().stream().filter(t -> !t.getDelFlag()).collect(Collectors.toList());
 		bseList.sort(Comparator.comparing(BinStage::getOrderNum));
 		bseList.stream().forEach(d -> {
 			bseIdMap.put(d.getId(), d.getStageName());
@@ -132,14 +187,14 @@ public class CacheContext implements CommandLineRunner {
 	/**
 	 * 初始化生产经营业务分类
 	 */
-	public void initBinSection(){
+	public void initBinSection() {
 		//清理集合中的数据
 		bsnList.clear();
 		bsnIdObject.clear();
 		bsnCodeObject.clear();
 
 
-		bsnList = binSectionService.list().stream().filter(t->!t.getDelFlag()).collect(Collectors.toList());
+		bsnList = binSectionService.list().stream().filter(t -> !t.getDelFlag()).collect(Collectors.toList());
 		bsnList.sort(Comparator.comparing(BinSection::getOrderNum));
 		bsnList.stream().forEach(d -> {
 			bsnIdObject.put(d.getId(), d);
@@ -152,15 +207,14 @@ public class CacheContext implements CommandLineRunner {
 		});
 	}
 
-	public  void initOrganizationEvaluationRule(){
+	public void initOrganizationEvaluationRule() {
 		ruleList.clear();
 		ruleMap.clear();
 		ruleList = organizationEvaluationRuleService.list();
 
-		ruleList = ruleList.stream().filter(t->!t.getDelFlag() && t.getIsCheck()).collect(Collectors.toList());
-		ruleMap  = ruleList.stream().collect(Collectors.groupingBy(OrganizationEvaluationRule::getOrganizationId));
+		ruleList = ruleList.stream().filter(t -> !t.getDelFlag() && t.getIsCheck()).collect(Collectors.toList());
+		ruleMap = ruleList.stream().collect(Collectors.groupingBy(OrganizationEvaluationRule::getOrganizationId));
 	}
 
 
-
 }

+ 84 - 65
ims-service/ims-eval/src/main/java/com/ims/eval/config/permission/PermissionAspect.java

@@ -7,10 +7,12 @@ import com.baomidou.mybatisplus.core.toolkit.StringUtils;
 import com.ims.eval.cache.CacheContext;
 import com.ims.eval.entity.DataDictionary;
 import com.ims.eval.entity.OrganizationEvaluationRule;
+import com.ims.eval.entity.OrganizationStructure;
 import com.ims.eval.entity.custom.PostUser;
 import com.ims.eval.entity.dto.response.MyuserResDTO;
 import com.ims.eval.entity.dto.result.PagResult;
 import com.ims.eval.feign.RemoteServiceBuilder;
+import com.ims.eval.service.IOrganizationStructureService;
 import com.ims.eval.service.custom.PostUserService;
 import lombok.extern.slf4j.Slf4j;
 import net.sf.jsqlparser.JSQLParserException;
@@ -38,6 +40,7 @@ import org.springframework.stereotype.Component;
 import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
+import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.lang.reflect.Method;
 import java.sql.Connection;
@@ -59,6 +62,8 @@ public class PermissionAspect implements Interceptor {
 	private HttpServletRequest request;
 	@Autowired
 	private PostUserService postUserService;
+//	@Resource
+//	private IOrganizationStructureService organizationStructureService;
 
 ////	@Resource
 //	private IUserService userService;
@@ -73,14 +78,18 @@ public class PermissionAspect implements Interceptor {
 	private final static String DEPT_MARK = "BM0001";//部门
 	private final static String POS_MARK = "GW0001";//岗位
 
-	/**  start  以下定义的数据需要和部门表一致       **/
+	/**
+	 * start  以下定义的数据需要和部门表一致
+	 **/
 	//全部数据权限
 	private static final Integer DATA_SCOPE_ALL = 1;
 	//部门数据权限
 	private static final Integer DATA_SCOPE_DEPT = 2;
 	//个人数据权限
 	private static final Integer DATA_SCOPE_CUSTOM = 3;
-	/**  end  以下定义的数据需要和部门表一致       **/
+	/**
+	 * end  以下定义的数据需要和部门表一致
+	 **/
 
 	//请求头code
 	private String code;
@@ -98,33 +107,34 @@ public class PermissionAspect implements Interceptor {
 	}
 
 
-	Map<String,JSONObject> userIdMap = new HashMap<>();
+	Map<String, JSONObject> userIdMap = new HashMap<>();
 
 	//前置通知
 	@Before("pointcut()")
 	public void beforeMethod(JoinPoint joinPoint) {
-			ServletRequestAttributes attributes =
-				(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
-			HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
-			code =  request.getHeader("code");
-			bladeAuth = request.getHeader("Blade-Auth");
+		ServletRequestAttributes attributes =
+			(ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+		HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
+		code = request.getHeader("code");
+		bladeAuth = request.getHeader("Blade-Auth");
 	}
 
 	@Override
 	public Object intercept(Invocation invocation) throws Throwable {
 
 		//部门权限
-		MyuserResDTO user = getSysUser(code,bladeAuth);
+		MyuserResDTO user = getSysUser(code, bladeAuth);
 		DataDictionary dept = getSysDept(user);
 
+
 		//岗位权限
 		DataDictionary post = null;
 		// 比较Scope字段并取最大值
 		Integer scope = 2;//1:全部;2部门;3个人
 		String organizationId = "";//组织id
-		if(null !=user){
+		if (null != user) {
 			organizationId = user.getUnitId();
-			if(null != dept){
+			if (null != dept) {
 				scope = dept.getScope();
 			}
 
@@ -132,10 +142,10 @@ public class PermissionAspect implements Interceptor {
 			post = getSysPost(postUserList);
 
 			// 比较Scope字段并取最大值
-			if(null != post ){
-				if("JCDW".equals(post.getKeyValue())){
+			if (null != post) {
+				if ("JCDW".equals(post.getKeyValue())) {
 					scope = post.getScope();
-				}else {
+				} else {
 					scope = Integer.min(scope, post.getScope());
 				}
 
@@ -144,13 +154,13 @@ public class PermissionAspect implements Interceptor {
 
 
 		//权限最大值不需要后续处理
-		if (scope.equals(DATA_SCOPE_ALL)){
+		if (scope.equals(DATA_SCOPE_ALL)) {
 			return invocation.proceed();
 		}
 
 
 		//人员和部门数据为空
-		if ( user == null || (dept == null && null == post)) {
+		if (user == null || (dept == null && null == post)) {
 //			try {
 //				return invocation.proceed();
 //			} catch (Exception e) {
@@ -161,9 +171,12 @@ public class PermissionAspect implements Interceptor {
 		}
 
 		if (scope.equals(DATA_SCOPE_DEPT)) {
+			List<String> childList = CacheContext.getChildList(user.getUnitId());
+			CacheContext.childCompanyId.put(user.getId(),user.getUnitId());
+
 			String deptId = "";
-			if(null != dept){
-				 deptId = dept.getDataKey();
+			if (null != dept) {
+				deptId = dept.getDataKey();
 			}
 
 			try {
@@ -193,31 +206,31 @@ public class PermissionAspect implements Interceptor {
 				String newName = mappedStatement.getId().substring(mappedStatement.getId().lastIndexOf(".") + 1, mappedStatement.getId().length());
 				Class<?> clazz = Class.forName(newId);
 				DataPermission dataPermission = null;
-				if (!methodNames.containsKey(newId + "-" + newName)){
+				if (!methodNames.containsKey(newId + "-" + newName)) {
 					for (Method method : clazz.getDeclaredMethods()) {
 						//方法是否含有DataPermission注解,如果含有注解则将数据结果过滤
 						if (method.isAnnotationPresent(DataPermission.class)) {
 							dataPermission = method.getAnnotation(DataPermission.class);
 							if (dataPermission != null) {
 								methodNames.put(newId + "-" + method.getName(), dataPermission.isPermission());
-								methodNames.put(newId + "-" + method.getName()+"type", dataPermission.type());
-								methodNames.put(newId + "-" + method.getName()+"zbtype", dataPermission.zbtype());
-								methodNames.put(newId + "-" + method.getName()+"jbtype", dataPermission.jbtype());
-								methodNames.put(newId + "-" + method.getName()+"bktype", dataPermission.bktype());
+								methodNames.put(newId + "-" + method.getName() + "type", dataPermission.type());
+								methodNames.put(newId + "-" + method.getName() + "zbtype", dataPermission.zbtype());
+								methodNames.put(newId + "-" + method.getName() + "jbtype", dataPermission.jbtype());
+								methodNames.put(newId + "-" + method.getName() + "bktype", dataPermission.bktype());
 							}
 						} else {
 							methodNames.put(newId + "-" + method.getName(), true);
-							methodNames.put(newId + "-" + method.getName()+"type", false);
-							methodNames.put(newId + "-" + method.getName()+"zbtype", false);
-							methodNames.put(newId + "-" + method.getName()+"jbtype", false);
-							methodNames.put(newId + "-" + method.getName()+"bktype", false);
+							methodNames.put(newId + "-" + method.getName() + "type", false);
+							methodNames.put(newId + "-" + method.getName() + "zbtype", false);
+							methodNames.put(newId + "-" + method.getName() + "jbtype", false);
+							methodNames.put(newId + "-" + method.getName() + "bktype", false);
 						}
 					}
 				}
 
 				//是否开启数据权限
 				boolean isPermission = true;
-				isPermission = null != methodNames.get(newId + "-" + newName) ?methodNames.get(newId + "-" + newName) :false;
+				isPermission = null != methodNames.get(newId + "-" + newName) ? methodNames.get(newId + "-" + newName) : false;
 				if (isPermission) {
 					// 获取到原始sql语句
 					String sql = statementHandler.getBoundSql().getSql();
@@ -227,15 +240,15 @@ public class PermissionAspect implements Interceptor {
 
 //						boolean jbtype = null != methodNames.get(newId + "-" + newName+"jbtype") ?methodNames.get(newId + "-" + newName+"jbtype") :false;
 						boolean type = null != methodNames.get(newId + "-" + newName + "type") ? methodNames.get(newId + "-" + newName + "type") : false;
-						boolean zbtype = null != methodNames.get(newId + "-" + newName+"zbtype") ?methodNames.get(newId + "-" + newName+"zbtype") :false;
-						boolean bktype = null != methodNames.get(newId + "-" + newName+"bktype") ?methodNames.get(newId + "-" + newName+"bktype") :false;
+						boolean zbtype = null != methodNames.get(newId + "-" + newName + "zbtype") ? methodNames.get(newId + "-" + newName + "zbtype") : false;
+						boolean bktype = null != methodNames.get(newId + "-" + newName + "bktype") ? methodNames.get(newId + "-" + newName + "bktype") : false;
 
 
-						System.out.println("==========type="+type+";zbtype"+zbtype+";bktype"+bktype);
+						System.out.println("==========type=" + type + ";zbtype" + zbtype + ";bktype" + bktype);
 
 
 						if (null != post && post.getKeyValue().equals("JCDW")) {
-							System.out.println("==========post.getKeyValue()="+post.getKeyValue());
+							System.out.println("==========post.getKeyValue()=" + post.getKeyValue());
 							if (type) {
 								sql = getSql(sql, organizationId, "JCDW");
 							}
@@ -248,7 +261,7 @@ public class PermissionAspect implements Interceptor {
 
 								List<OrganizationEvaluationRule> list = CacheContext.ruleMap.get(organizationId);
 								StringBuilder bis = new StringBuilder();
-								if(null !=list && list.size()>0){
+								if (null != list && list.size() > 0) {
 									bis.append("(");
 									for (OrganizationEvaluationRule rule : list) {
 										rule.getBinSection();
@@ -258,11 +271,11 @@ public class PermissionAspect implements Interceptor {
 									}
 									bis.append(")");
 								}
-								System.out.println("查询条件:"+bis.toString().replace(",)",")"));
-								if(bis.toString().length()<=0){
-									sql = getSql(sql,"('')", "bktype");
-								}else {
-									sql = getSql(sql, bis.toString().replace(",)",")"), "bktype");
+								System.out.println("查询条件:" + bis.toString().replace(",)", ")"));
+								if (bis.toString().length() <= 0) {
+									sql = getSql(sql, "('')", "bktype");
+								} else {
+									sql = getSql(sql, bis.toString().replace(",)", ")"), "bktype");
 								}
 
 							}
@@ -292,37 +305,42 @@ public class PermissionAspect implements Interceptor {
 	 * @param sql 原SQL
 	 * @return 新SQL
 	 */
-	private String getSql(String sql, String deptId,String unitFlag) {
+	private String getSql(String sql, String deptId, String unitFlag) {
 		try {
 			// 修改原语句
-			String condition ="";
+			String condition = "";
 			Select select = (Select) CCJSqlParserUtil.parse(sql);
-			PlainSelect plainSelect = (PlainSelect)select.getSelectBody();
-			Table table = (Table)plainSelect.getFromItem();
+			PlainSelect plainSelect = (PlainSelect) select.getSelectBody();
+			Table table = (Table) plainSelect.getFromItem();
 			if (table.getAlias() != null) {
 				if (unitFlag.equals("JCDW")) {
 
-					if(!"".equals(deptId.trim())){
+					if (!"".equals(deptId.trim())) {
 						condition = table.getAlias().getName() + "." + ORGANIZATION_ID + "='" + deptId + "'";
 					}
 
 				} else if (unitFlag.equals("bktype")) {
 					condition = table.getAlias().getName() + "." + BIN_SECTION + " in " + deptId;
 				} else {
-					condition = "("+table.getAlias().getName() + "." + DEPT_ID + "='" + deptId + "' or "+table.getAlias().getName() + "." + DEPT_ID + "='PUBLIC')";;
+					condition = "(" + table.getAlias().getName() + "." + DEPT_ID + "='" + deptId + "' or " + table.getAlias().getName() + "." + DEPT_ID + "='PUBLIC')";
+					;
 				}
 
 			} else {
 				condition = table.getAlias().getName() + "." + DEPT_ID + "=''";
 			}
 
+			/*if("".equals(condition)){
+				return plainSelect.toString();
+			}*/
+
 			//取得原SQL的where条件
 			final Expression expression = plainSelect.getWhere();
 			//增加新的where条件
 			final Expression envCondition = CCJSqlParserUtil.parseCondExpression(condition);
 			//envCondition.toString().contains(envCondition.toString());
 			System.out.println();
-			if(StringUtils.isNotBlank(envCondition.toString()) && !expression.toString().contains(envCondition.toString())){
+			if (StringUtils.isNotBlank(envCondition.toString()) && !expression.toString().contains(envCondition.toString())) {
 				if (expression == null) {
 					plainSelect.setWhere(envCondition);
 				} else {
@@ -349,52 +367,53 @@ public class PermissionAspect implements Interceptor {
 	}
 
 	@Cacheable(value = "user_code")
-	public MyuserResDTO getSysUser(String code,String bladeAuth) {
-		if (StringUtils.isBlank(code) || code.toLowerCase().equals("null")){
+	public MyuserResDTO getSysUser(String code, String bladeAuth) {
+		if (StringUtils.isBlank(code) || code.toLowerCase().equals("null")) {
 			return null;
 		}
-		JSONObject json = postUserService.getSysUser(code,bladeAuth,request);
+		JSONObject json = postUserService.getSysUser(code, bladeAuth, request);
 		MyuserResDTO user = JSONObject.parseObject(json.getJSONObject("data").toJSONString(), MyuserResDTO.class);
 		return user;
 	}
 
-	@Cacheable(cacheNames = "user_id",key= "#userId")
+	@Cacheable(cacheNames = "user_id", key = "#userId")
 	public List<PostUser> getUserPostList(String userId) {
 		JSONObject postuserjson = null;
-		if(null == userIdMap.get(userId)){
-			postuserjson  = (JSONObject)postUserService.getUserPostList(null,null,userId,request);
-			userIdMap.put(userId,postuserjson);
-		}else {
+		if (null == userIdMap.get(userId)) {
+			postuserjson = (JSONObject) postUserService.getUserPostList(null, null, userId, request);
+			userIdMap.put(userId, postuserjson);
+		} else {
 			postuserjson = userIdMap.get(userId);
 		}
 
-		if(null !=postuserjson){
-			PagResult pagResult =	JSONObject.parseObject(postuserjson.toJSONString(), PagResult.class);
+		if (null != postuserjson) {
+			PagResult pagResult = JSONObject.parseObject(postuserjson.toJSONString(), PagResult.class);
 			List<PostUser> list = pagResult.getRecords().toJavaList(PostUser.class);
 			return list;
 		}
 		return null;
 	}
 
-	@Cacheable(cacheNames = "user_code_dept",key="#user.id")
-	public DataDictionary getSysDept(MyuserResDTO user){
-		if (user != null && CacheContext.ddSuperKeyMap.containsKey(DEPT_MARK)){
-			Optional<DataDictionary> any = CacheContext.ddSuperKeyMap.get(DEPT_MARK).stream().filter(t -> t.getKeyName().equals(user.getDeptName())).findAny();
-			return any.isPresent() ?  any.get() : CacheContext.ddMap.get("LSBM");//如果没有匹配上部门,赋予零时部门权限
+	@Cacheable(cacheNames = "user_code_dept", key = "#user.id")
+	public DataDictionary getSysDept(MyuserResDTO user) {
+		if (user != null && CacheContext.ddSuperKeyMap.containsKey(DEPT_MARK)) {
+//			Optional<DataDictionary> any = CacheContext.ddSuperKeyMap.get(DEPT_MARK).stream().filter(t -> t.getKeyName().equals(user.getDeptName())).findAny();
+			Optional<DataDictionary> any = CacheContext.ddSuperKeyMap.get(DEPT_MARK).stream().filter(t -> user.getDeptName().contains(t.getKeyName())).findAny();
+			return any.isPresent() ? any.get() : CacheContext.ddMap.get("LSBM");//如果没有匹配上部门,赋予零时部门权限
 		}
 		return null;
 	}
 
 
 	@Cacheable(value = "user_id_post")
-	public DataDictionary getSysPost(List<PostUser> postUsers){
-		if (postUsers != null  && postUsers.size()>0 && CacheContext.ddSuperKeyMap.containsKey(POS_MARK)){
-			List<DataDictionary> list  = CacheContext.ddSuperKeyMap.get(POS_MARK).stream()
+	public DataDictionary getSysPost(List<PostUser> postUsers) {
+		if (postUsers != null && postUsers.size() > 0 && CacheContext.ddSuperKeyMap.containsKey(POS_MARK)) {
+			List<DataDictionary> list = CacheContext.ddSuperKeyMap.get(POS_MARK).stream()
 				.filter(data -> postUsers.stream().anyMatch(user -> user.getPosCode().equals(data.getDataKey()))).collect(Collectors.toList());
-				DataDictionary maxScopeData =  list.stream().min(Comparator.comparing(DataDictionary::getScope))
+			DataDictionary maxScopeData = list.stream().min(Comparator.comparing(DataDictionary::getScope))
 				.orElse(null);
 			return maxScopeData;
-		}else {
+		} else {
 			//没有查到对应的岗位,赋值一般用户岗位
 			return CacheContext.ddMap.get("61138");
 		}

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/controller/MultipleBrandController.java

@@ -2,6 +2,7 @@ package com.ims.eval.controller;
 
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ims.eval.cache.CacheContext;
 import com.ims.eval.config.CustomException;
 import com.ims.eval.entity.MultipleBrand;
 import com.ims.eval.entity.dto.result.R;
@@ -95,6 +96,7 @@ public class MultipleBrandController {
 		try {
 			boolean b = multipleBrandService.saveOrUpdate(multipleBrand);
 			if (b) {
+				multipleBrandService.initData();
 				return R.ok().data(b);
 			} else {
 				return R.error().data("保存失败!");

+ 31 - 3
ims-service/ims-eval/src/main/java/com/ims/eval/controller/OrganizationEvaluationInfoController.java

@@ -2,11 +2,17 @@ package com.ims.eval.controller;
 
 
 import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.ims.eval.cache.CacheContext;
+import com.ims.eval.entity.MultipleBrand;
 import com.ims.eval.entity.OrganizationEvaluationInfo;
 import com.ims.eval.entity.dto.request.AddEvaluationInfoDTO;
+import com.ims.eval.entity.dto.response.MyuserResDTO;
 import com.ims.eval.entity.dto.response.OrganizationEvaluationInfoResDTO;
 import com.ims.eval.entity.dto.result.R;
+import com.ims.eval.service.IMultipleBrandService;
 import com.ims.eval.service.IOrganizationEvaluationInfoService;
+import com.ims.eval.service.custom.PostUserService;
 import com.ims.eval.util.ExcelUtil;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -15,13 +21,15 @@ import org.springframework.http.HttpHeaders;
 import org.springframework.http.MediaType;
 import org.springframework.http.ResponseEntity;
 import org.springframework.web.bind.annotation.*;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
 import org.springframework.web.multipart.MultipartFile;
 
 import javax.servlet.http.HttpServletRequest;
 import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 /**
  * <p>
@@ -45,6 +53,9 @@ public class OrganizationEvaluationInfoController {
 
 	@Autowired
 	private HttpServletRequest request;
+	@Autowired
+	private PostUserService postUserService;
+
 
 
 	/**
@@ -92,10 +103,27 @@ public class OrganizationEvaluationInfoController {
 		@RequestParam(value = "indicatorId", required = false) String indicatorId,
 		@RequestParam(value = "binSection", required = false) String binSection,
 		@RequestParam(value = "binStage", required = false) String binStage) {
+		ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
+		HttpServletRequest request = Objects.requireNonNull(attributes).getRequest();
+		JSONObject json = postUserService.getSysUser(request.getHeader("code"), request.getHeader("Blade-Auth"), request);
+		MyuserResDTO user = JSONObject.parseObject(json.getJSONObject("data").toJSONString(), MyuserResDTO.class);
+
 		Map list = organizationEvaluationInfoService.getEvaluationInfoList(organizationEvaluationId,organizationShortName, indicatorId,binSection,binStage, request);
+		List<Map> value2 = (List<Map>)list.get("value");
+		String s = CacheContext.childCompanyId.get(user.getId());
+		if (s!=null){
+			List<String> childList = CacheContext.getChildList(s);
+			List<Map> value1 = value2.stream().filter(a -> childList.contains(a.get("organizationId"))).collect(Collectors.toList());
+			list.put("value",value1);
+		}
+
 		return R.ok().data(list);
 	}
 
+
+
+
+
 	@GetMapping("/download-excel")
 	public ResponseEntity<byte[]> downloadExcel(
 		@RequestParam(value = "organizationEvaluationId", required = false) String organizationEvaluationId,

+ 2 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/IMultipleBrandService.java

@@ -33,4 +33,6 @@ public interface IMultipleBrandService extends IService<MultipleBrand> {
 	R importExcel(MultipartFile file);
 
 	MultipleBrand checkForExistence(String organizationName, String checkCycle, String binSection, String year, String month);
+
+	void initData();
 }

+ 17 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/MultipleBrandServiceImpl.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ims.common.utils.StringUtils;
+import com.ims.eval.cache.CacheContext;
 import com.ims.eval.dao.MultipleBrandMapper;
 import com.ims.eval.entity.*;
 import com.ims.eval.entity.dto.result.R;
@@ -29,6 +30,7 @@ import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.Arrays;
 import java.util.List;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -49,6 +51,21 @@ public class MultipleBrandServiceImpl extends ServiceImpl<MultipleBrandMapper, M
 	private IBinSectionService binSectionService;
 
 	@Override
+	public void  initData(){
+		//按照单位营业收入配置
+		IPage<MultipleBrand> tree = getMultipleBranTree(1, 1000, null, null, "", "", "", null);
+		List<MultipleBrand> records = tree.getRecords();
+		for (MultipleBrand record : records) {
+			CacheContext.brandMap.put(record.getOrganizationId(), record);
+			if (record.getChildren()==null) continue;
+			for (MultipleBrand child : record.getChildren()) {
+				CacheContext.brandMap.put(child.getOrganizationId(), child);
+			}
+		}
+	}
+
+
+	@Override
 	public IPage<MultipleBrand> getMultipleBranTree(Integer pageNum, Integer pageSize, String id, String parentId, String binSection, String checkCycle, String year, String month) {
 		Page<Indicator> page = new Page<>(pageNum, pageSize);
 		IPage<MultipleBrand> list = baseMapper.selectMultipleBranTree(page, id, "0", binSection, checkCycle, year, month);