Browse Source

基层单位权重重构

全业务考评 1 year ago
parent
commit
c4fd9fbad0

+ 19 - 8
ims-service/ims-eval/src/main/java/com/ims/eval/cache/CacheContext.java

@@ -1,13 +1,7 @@
 package com.ims.eval.cache;
 
-import com.ims.eval.entity.BinSection;
-import com.ims.eval.entity.BinStage;
-import com.ims.eval.entity.DataDictionary;
-import com.ims.eval.entity.IndicatorType;
-import com.ims.eval.service.IBinSectionService;
-import com.ims.eval.service.IBinStageService;
-import com.ims.eval.service.IDataDictionaryService;
-import com.ims.eval.service.IIndicatorTypeService;
+import com.ims.eval.entity.*;
+import com.ims.eval.service.*;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.stereotype.Component;
@@ -33,6 +27,10 @@ public class CacheContext implements CommandLineRunner {
 	@Autowired
 	private IBinStageService binStageService;
 
+	@Autowired
+	private IOrganizationEvaluationRuleService organizationEvaluationRuleService;
+
+
 
 	//初始化字典表
 	public static List<DataDictionary> ddList = new ArrayList<>();
@@ -60,6 +58,10 @@ public class CacheContext implements CommandLineRunner {
 	public static Map<String, String> bsnIdName = new HashMap<>();
 
 
+	//权重
+	public static Map<String, List<OrganizationEvaluationRule>> ruleMap = new HashMap();
+	public static  List<OrganizationEvaluationRule> ruleList = new ArrayList<>();
+
 
 	@Override
 	public void run(String... args) throws Exception {
@@ -67,6 +69,7 @@ public class CacheContext implements CommandLineRunner {
 		initIndicatorType();
 		initBinStage();
 		initBinSection();
+		initOrganizationEvaluationRule();
 
 	}
 
@@ -149,6 +152,14 @@ public class CacheContext implements CommandLineRunner {
 		});
 	}
 
+	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));
+	}
 
 
 

+ 10 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/config/permission/DataPermission.java

@@ -18,7 +18,15 @@ public @interface DataPermission {
 	/**
 	 * 是否要进行数据权限隔离
 	 */
-	boolean isPermission() default true;
+	boolean isPermission() default true;//true-部门数据
+
+	boolean type() default false;//true-基层单位;
+
+
+	boolean zbtype() default false;//ture-所有部门
+
+	boolean jbtype() default false;//ture-单位;false-部门
+
+	boolean bktype() default false;//ture-筛选板块;false-不筛选
 
-	boolean type() default false;
 }

+ 48 - 9
ims-service/ims-eval/src/main/java/com/ims/eval/config/permission/PermissionAspect.java

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.PluginUtils;
 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.custom.PostUser;
 import com.ims.eval.entity.dto.response.MyuserResDTO;
 import com.ims.eval.entity.dto.result.PagResult;
@@ -38,7 +39,6 @@ import org.springframework.web.context.request.RequestContextHolder;
 import org.springframework.web.context.request.ServletRequestAttributes;
 
 import javax.servlet.http.HttpServletRequest;
-import javax.sound.midi.Soundbank;
 import java.lang.reflect.Method;
 import java.sql.Connection;
 import java.util.*;
@@ -55,17 +55,18 @@ public class PermissionAspect implements Interceptor {
 
 	@Autowired
 	private RemoteServiceBuilder serviceBuilder;
-
-
 	@Autowired
 	private HttpServletRequest request;
 	@Autowired
 	private PostUserService postUserService;
 
+
 	//扫描的包路径,需要权限的加在mapper类及方法上
 	private String packagePath = "com.ims.eval.dao";
 	private final static String DEPT_ID = "dept_id";
 	private final static String ORGANIZATION_ID = "organization_id";
+
+	private final static String BIN_SECTION = "bin_section";
 	private final static String DEPT_MARK = "BM0001";//部门
 	private final static String POS_MARK = "GW0001";//岗位
 
@@ -190,10 +191,16 @@ public class PermissionAspect implements Interceptor {
 							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());
 							}
 						} 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);
 						}
 					}
 				}
@@ -208,15 +215,42 @@ public class PermissionAspect implements Interceptor {
 					if (mappedStatement.getSqlCommandType().toString().equals("SELECT")) {
 
 
-						if(null != post && post.getKeyValue().equals("JCDW")){
+//						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;
+
+						if (null != post && post.getKeyValue().equals("JCDW")) {
 
-							 boolean type = null != methodNames.get(newId + "-" + newName+"type") ?methodNames.get(newId + "-" + newName+"type") :false;
 							if (type) {
-								sql = getSql(sql, organizationId,"JCDW");
+								sql = getSql(sql, organizationId, "JCDW");
+							}
+
+							if (zbtype) {
+								sql = getSql(sql, "", "JCDW");
+							}
+
+							if (bktype) {
+
+								List<OrganizationEvaluationRule> list = CacheContext.ruleMap.get(organizationId);
+								StringBuilder bis = new StringBuilder("(");
+								for (OrganizationEvaluationRule rule : list) {
+									rule.getBinSection();
+									for (String bi : rule.getBinSection().split(",")) {
+										bis.append("'").append(bi).append("',");
+									}
+								}
+								bis.append(")");
+
+								System.out.println("查询条件:"+bis.toString().replace(",)",")"));
+								sql = getSql(sql, bis.toString().replace(",)",")"), "bktype");
+							}
+
+						} else {
+							if (!type) {
+								sql = getSql(sql, deptId, "");
 							}
 
-						}else {
-							sql = getSql(sql, deptId,"");
 						}
 
 						// 修改sql
@@ -247,7 +281,12 @@ public class PermissionAspect implements Interceptor {
 			if (table.getAlias() != null) {
 				if (unitFlag.equals("JCDW")) {
 
-					condition = table.getAlias().getName() + "." + ORGANIZATION_ID + "='" + deptId + "'";;
+					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')";;
 				}

+ 6 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/controller/OrganizationEvaluationRuleController.java

@@ -3,9 +3,9 @@ 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.OrganizationEvaluationRule;
-import com.ims.eval.entity.dto.request.OrganizationEvaluationRuleDTO;
 import com.ims.eval.entity.dto.result.R;
 import com.ims.eval.service.IOrganizationEvaluationRuleService;
 import io.swagger.annotations.ApiOperation;
@@ -14,7 +14,6 @@ import org.springframework.web.bind.annotation.*;
 
 import java.util.Arrays;
 import java.util.List;
-import java.util.Map;
 
 /**
  * <p>
@@ -33,6 +32,9 @@ public class OrganizationEvaluationRuleController {
 	private IOrganizationEvaluationRuleService organizationEvaluationRuleService;
 
 
+	@Autowired
+	private CacheContext cacheContext;
+
 	/**
 	 * @param pageNum          当前页数
 	 * @param pageSize         当前页大小
@@ -119,6 +121,7 @@ public class OrganizationEvaluationRuleController {
 		try {
 			boolean b = organizationEvaluationRuleService.saveOrUpdate(evaluationRule);
 			if (b) {
+				cacheContext.initOrganizationEvaluationRule();
 				return R.ok().data(b);
 			} else {
 				return R.error().data("保存失败!");
@@ -142,6 +145,7 @@ public class OrganizationEvaluationRuleController {
 		String[] strings = ids.split(",");
 		boolean b = organizationEvaluationRuleService.removeByIds(Arrays.asList(strings));
 		if (b) {
+			cacheContext.initOrganizationEvaluationRule();
 			return R.ok().data(b);
 		} else {
 			return R.error().data("删除失败!");

+ 4 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/EvaluateReportInfoMapper.java

@@ -1,5 +1,6 @@
 package com.ims.eval.dao;
 
+import com.ims.eval.config.permission.DataPermission;
 import com.ims.eval.entity.EvaluateReportInfo;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 
@@ -15,8 +16,11 @@ import java.util.List;
  * @author wang
  * @since 2023-03-25
  */
+@DataPermission
 public interface EvaluateReportInfoMapper extends BaseMapper<EvaluateReportInfo> {
 
+
+	@DataPermission(type = true,jbtype=true)
 	List<EvaluateReportInfo> selectListByReportId(String evaluateReportId);
 
 }

+ 6 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/dao/EvaluateReportMapper.java

@@ -2,9 +2,9 @@ package com.ims.eval.dao;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.ims.eval.config.permission.DataPermission;
 import com.ims.eval.entity.EvaluateReport;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
-import com.ims.eval.entity.Indicator;
 import com.ims.eval.entity.dto.response.EvaluateReportInfoResDTO;
 import org.apache.ibatis.annotations.Param;
 
@@ -18,8 +18,11 @@ import java.util.List;
  * @author wang
  * @since 2023-03-25
  */
+@DataPermission
 public interface EvaluateReportMapper extends BaseMapper<EvaluateReport> {
 
+
+	@DataPermission(bktype=true)
 	IPage<EvaluateReport>  selectListPage(Page page, @Param("id") String id,
 		 @Param("evaluateReportName")String evaluateReportName,
 		 @Param("binSection")String binSection,
@@ -31,6 +34,7 @@ public interface EvaluateReportMapper extends BaseMapper<EvaluateReport> {
 
 
 
+	@DataPermission(isPermission = false)
 	 List<EvaluateReportInfoResDTO> selectList(@Param("binSection")String binSection,
 											   @Param("organizationEvaluationId") String organizationEvaluationId,
 											   @Param("checkCycle")String checkCycle,
@@ -38,7 +42,7 @@ public interface EvaluateReportMapper extends BaseMapper<EvaluateReport> {
 											   @Param("month")String month);
 
 
-
+	@DataPermission(isPermission = false)
 	List<EvaluateReport> selectListAll(@Param("organizationEvaluationId") String organizationEvaluationId,
 									   @Param("binSection")String binSection);
 

+ 2 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/dao/OrganizationEvaluationInfoMapper.java

@@ -53,12 +53,13 @@ public interface OrganizationEvaluationInfoMapper extends BaseMapper<Organizatio
 																   @Param("organizationEvaluationId") String organizationEvaluationId,
 																   @Param("optionCode") String optionCode);
 
+	@DataPermission(isPermission = true,zbtype = true,jbtype=true)
 	List<Map> selectEvaluationIndicatorList(@Param("organizationEvaluationId") String organizationEvaluationId,
 											@Param("binSection") String binSection,
 											@Param("binStage") String binStage);
 
 
-	@DataPermission(type = true,isPermission = true)
+	@DataPermission(type = true,isPermission = true,jbtype=true)
 	List<OrganizationEvaluationInfoResDTO> selectEvaluationInfoList(@Param("organizationEvaluationId") String organizationEvaluationId,
 											@Param("organizationShortName") String organizationShortName,
 											@Param("indicatorId") String indicatorId,

+ 5 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/OrganizationEvaluationMapper.java

@@ -1,5 +1,6 @@
 package com.ims.eval.dao;
 
+import com.ims.eval.config.permission.DataPermission;
 import com.ims.eval.entity.OrganizationEvaluation;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.ims.eval.entity.dto.response.EvaluationScoreInfoResDTO;
@@ -17,14 +18,18 @@ import java.util.Map;
  * @author wang
  * @since 2023-03-16
  */
+@DataPermission
 public interface OrganizationEvaluationMapper extends BaseMapper<OrganizationEvaluation> {
 
+	@DataPermission(isPermission = false)
 	OrganizationEvaluationResDTO selectById(@Param("id")String id);
 
 
+	@DataPermission(isPermission = false)
 	List<Map<String, Object>> selectCompanyActualValue(String binSection, String indicatorId, String evaluationType);
 
 
+	@DataPermission(isPermission = true,type = true,jbtype=true)
 	List<EvaluationScoreInfoResDTO> selectEvaluationScoreInfoList(@Param("id") String id,
 																  @Param("binSection") String binSection,
 																  @Param("indicatorId") String indicatorId,

+ 3 - 2
ims-service/ims-eval/src/main/java/com/ims/eval/dao/ResponsibilityIndicatorInfoMapper.java

@@ -27,18 +27,19 @@ public interface ResponsibilityIndicatorInfoMapper extends BaseMapper<Responsibi
 																   @Param("optionCode") String optionCode,
 																   @Param("organizationId") String organizationId);
 
-	@DataPermission(isPermission = true,type = true)
+	@DataPermission(isPermission = true,type = true,jbtype=true)
 	List<ResponsibilityIndicatorInfoResDTO> selectResponsibilityIndicatorInfoList(@Param("deptResponsibilityId") String deptResponsibilityId,
 																				  @Param("isQuantified") String isQuantified,
 																				  @Param("dataState") String dataState);
 
 
+	@DataPermission(type = true,jbtype=true)
 	List<Map> selectResponsibilityIndicatorList(@Param("responsibilityId") String responsibilityId,
 												@Param("binSection") String binSection,
 												@Param("binStage") String binStage,
 												@Param("reviseId") String reviseId);
 
-	@DataPermission(isPermission = true,type = true)
+	@DataPermission(isPermission = true,type = true,jbtype=true)
 	List<ResponsibilityIndicatorInfoResDTO> getResponsibilityInfoList(@Param("responsibilityId") String responsibilityId,
 																	  @Param("indicatorId") String indicatorId,
 																	  @Param("organizationShortName") String organizationShortName,

+ 1 - 1
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/EvaluateReportInfoServiceImpl.java

@@ -52,7 +52,7 @@ public class EvaluateReportInfoServiceImpl extends ServiceImpl<EvaluateReportInf
 		title.put("n-gjyjXs","关键业绩得分");
 		title.put("n-djkhCs","党建考核乘数");
 		title.put("n-score","最终得分");
-		title.put("p-remark","备注");
+//		title.put("p-remark","备注");
 
 		EvaluateReport evaluateReport = 	evaluateReportService.getById(evaluateReportId);
 

+ 7 - 7
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationInfoServiceImpl.java

@@ -1020,13 +1020,13 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 				if(null != valueMap.get(entry.getKey().replace("ID_", ""))) {
 
 //					//加分 扣分 加扣分原因
-//					if (entry.getKey().endsWith("_JFYY")) {
-//						jfRemark = valueMap.get(entry.getKey().replace("ID_", "")).toString();
-//					}
-//
-//					if (entry.getKey().endsWith("_KFYY")) {
-//						kfRemark = valueMap.get(entry.getKey().replace("ID_", "")).toString();
-//					}
+					if (entry.getKey().endsWith("_JFYY")) {
+						jfRemark = valueMap.get(entry.getKey().replace("ID_", "")).toString();
+					}
+
+					if (entry.getKey().endsWith("_KFYY")) {
+						kfRemark = valueMap.get(entry.getKey().replace("ID_", "")).toString();
+					}
 
 
 					if ("1".equals(quantified)) {

+ 4 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/service/impl/OrganizationEvaluationServiceImpl.java

@@ -13,6 +13,7 @@ import com.ims.eval.dao.OrganizationEvaluationMapper;
 import com.ims.eval.entity.dto.request.IndicatorDTO;
 import com.ims.eval.entity.dto.request.IndicatorDictionaryDTO;
 import com.ims.eval.entity.dto.response.*;
+import com.ims.eval.feign.RemoteServiceBuilder;
 import com.ims.eval.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -96,6 +97,9 @@ public class OrganizationEvaluationServiceImpl extends ServiceImpl<OrganizationE
 	@Autowired
 	private IMultipleBrandService multipleBrandService;
 
+	@Autowired
+	private RemoteServiceBuilder serviceBuilder;
+
 
 	@Override
 	public IPage<OrganizationEvaluation> list(Integer pageNum, Integer pageSize, String id, String organizationEvaluationCode, List<String> checkCycle, String beginDate, String endDate, String stage, String createBy, String year, String month, String des) {

+ 1 - 1
ims-service/ims-eval/src/main/resources/mappers/EvaluateReportMapper.xml

@@ -31,7 +31,7 @@
         INNER JOIN bin_section b on r.bin_section = b.id
         <where>
 
-
+             1=1
             <if test="id !=null and id !=''">
                 AND r.id = #{id}
             </if>

+ 3 - 3
ims-service/ims-eval/src/main/resources/mappers/OrganizationEvaluationMapper.xml

@@ -104,8 +104,8 @@
         ei.evaluate_rule_id,
         oi.evaluate_rule_info_id
 
-    from organization_evaluation oe
-    left join organization_evaluation_info oi on oe.id = oi.organization_evaluation_id
+    from organization_evaluation_info oi
+    left join organization_evaluation oe on oe.id = oi.organization_evaluation_id
     left join indicator_dictionary d on oi.indicator_id = d.indicator_id and oi.indicator_dictionary_id = d.id
     inner join organization_evaluation_rule er on er.id = oi.organization_evaluation_rule_id
     inner join evaluate_rule_info ei on ei.id = oi.evaluate_rule_info_id
@@ -115,7 +115,7 @@
     <where>
 
         <if test="id !=null and id !=''">
-            oe.id  = #{id}
+            oi.organization_evaluation_id  = #{id}
         </if>
 
         <if test="binSection !=null and binSection !=''">