Browse Source

修改得分

wangchangsheng 1 year ago
parent
commit
6464d3b528

+ 13 - 57
ims-service/ims-eval/src/main/java/com/ims/eval/config/permission/PermissionAspect.java

@@ -90,6 +90,9 @@ public class PermissionAspect implements Interceptor {
 	public void pointcut() {
 	}
 
+
+	Map<String,JSONObject> userIdMap = new HashMap<>();
+
 	//前置通知
 	@Before("pointcut()")
 	public void beforeMethod(JoinPoint joinPoint) {
@@ -130,66 +133,12 @@ public class PermissionAspect implements Interceptor {
 
 
 		//人员和部门数据为空
-		if (user == null || dept == null ) {
+		if ( user == null || dept == null ||null == post) {
 			try {
-				//反射扫包会比较慢,这里做了个懒加载
-				if (classNames == null) {
-					//扫描指定包路径下所有包含指定注解的类
-					Set<Class<?>> classSet = ClassUtil.scanPackageByAnnotation(packagePath, DataPermission.class);
-					if (classSet == null && classSet.size() == 0) {
-						classNames = new ArrayList<>();
-					} else {
-						//取得类全名
-						classNames = classSet.stream().map(Class::getName).collect(Collectors.toList());
-					}
-				}
-
-				// 拿到mybatis的一些对象
-				StatementHandler statementHandler = PluginUtils.realTarget(invocation.getTarget());
-				MetaObject metaObject = SystemMetaObject.forObject(statementHandler);
-				MappedStatement mappedStatement = (MappedStatement) metaObject.getValue("delegate.mappedStatement");
-
-				// mappedStatement.getId()为执行的mapper方法的全路径名,newId为执行的mapper方法的类全名
-				String newId = mappedStatement.getId().substring(0, mappedStatement.getId().lastIndexOf("."));
-				// 如果不是指定的方法,直接结束拦截
-				if (!classNames.contains(newId)) {
-					return invocation.proceed();
-				}
-				String newName = mappedStatement.getId().substring(mappedStatement.getId().lastIndexOf(".") + 1, mappedStatement.getId().length());
-				Class<?> clazz = Class.forName(newId);
-
-				if (!methodNames.containsKey(newId + "-" + newName)){
-					for (Method method : clazz.getDeclaredMethods()) {
-						//方法是否含有DataPermission注解,如果含有注解则将数据结果过滤
-						if (method.isAnnotationPresent(DataPermission.class)) {
-							DataPermission dataPermission = method.getAnnotation(DataPermission.class);
-							if (dataPermission != null) {
-								methodNames.put(newId + "-" + method.getName(), dataPermission.isPermission());
-							}
-						} else {
-							methodNames.put(newId + "-" + method.getName(), true);
-						}
-					}
-				}
-
-				//是否开启数据权限
-				boolean isPermission = true;
-				isPermission = null != methodNames.get(newId + "-" + newName) ?methodNames.get(newId + "-" + newName) :false;
-				if (isPermission) {
-					// 获取到原始sql语句
-					String sql = statementHandler.getBoundSql().getSql();
-					// 解析并返回新的SQL语句,只处理查询sql
-					if (mappedStatement.getSqlCommandType().toString().equals("SELECT")) {
-						sql = getSql(sql, "");
-					}
-					// 修改sql
-					metaObject.setValue("delegate.boundSql.sql", sql);
-				}
+				return invocation.proceed();
 			} catch (Exception e) {
 				log.error("数据权限隔离异常:", e);
 			}
-
-
 			return invocation.proceed();
 		}
 
@@ -315,7 +264,14 @@ public class PermissionAspect implements Interceptor {
 
 	@Cacheable(cacheNames = "user_id",key= "#userId")
 	public List<PostUser> getUserPostList(String userId) {
-		JSONObject postuserjson  = (JSONObject)postUserService.getUserPostList(null,null,userId,request);
+		JSONObject postuserjson = null;
+		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);
 			List<PostUser> list = pagResult.getRecords().toJavaList(PostUser.class);

+ 3 - 0
ims-service/ims-eval/src/main/java/com/ims/eval/dao/CalculateIndicatorItemInfoMapper.java

@@ -1,6 +1,7 @@
 package com.ims.eval.dao;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.ims.eval.config.permission.DataPermission;
 import com.ims.eval.entity.CalculateIndicatorItemInfo;
 import org.apache.ibatis.annotations.Param;
 
@@ -14,8 +15,10 @@ import java.util.List;
  * @author xugp
  * @since 2023-03-26
  */
+@DataPermission(isPermission = false)
 public interface CalculateIndicatorItemInfoMapper extends BaseMapper<CalculateIndicatorItemInfo> {
 
+
 	List<CalculateIndicatorItemInfo> selectList(String organizationType, String checkCycle, String year, String month,String indicatorId,String organizationEvaluationId,String childCode);
 
 

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

@@ -65,7 +65,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 	private IUserService userService;
 
 	@Autowired
-	private IEvaluationScoreCountService iEvaluatioinScoreCountService;
+	private IEvaluationScoreCountService evaluatioinScoreCountService;
 
 
 	@Resource
@@ -392,12 +392,12 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 									scoreCount.setObversionScore(totalScore);
 									scoreCount.setIsQuantified("1");
 
-									List<EvaluationScoreCount>  listcount = iEvaluatioinScoreCountService.getEvaluationScoreCountList(scoreCount.getOrganizationEvaluationId(),scoreCount.getOrganizationEvaluationRuleId(),scoreCount.getIndicatorId(),scoreCount.getBinSection());
+									List<EvaluationScoreCount>  listcount = evaluatioinScoreCountService.getEvaluationScoreCountList(scoreCount.getOrganizationEvaluationId(),scoreCount.getOrganizationEvaluationRuleId(),scoreCount.getIndicatorId(),scoreCount.getBinSection());
 									if(null  != listcount && listcount.size() >0){
 										List<String> ids = listcount.stream().map(EvaluationScoreCount::getId).collect(Collectors.toList());
-										boolean cod = iEvaluatioinScoreCountService.removeByIds(ids);
+										boolean cod = evaluatioinScoreCountService.removeByIds(ids);
 									}
-									iEvaluatioinScoreCountService.save(scoreCount);
+									evaluatioinScoreCountService.save(scoreCount);
 								}
 							}
 						}
@@ -915,6 +915,7 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 			}
 
 			List<OrganizationEvaluationInfo> evaluationInfos =new ArrayList<>();
+			double score = 0.00;
 			for (Map.Entry<String,Object > entry : idMap.entrySet()) {
 				OrganizationEvaluationInfo info = new OrganizationEvaluationInfo();
 				info.setId(entry.getValue().toString());
@@ -924,13 +925,18 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 
 					if (MathCalculatorUtil.isNumber(String.valueOf(valueMap.get(entry.getKey().replace("ID_", "")).toString()))) {
 						info.setQuantifiedValue(Double.valueOf(valueMap.get(entry.getKey().replace("ID_", "")).toString()));
+
+						//得分
+						if (entry.getKey().endsWith("_DF") || entry.getKey().endsWith("_DF2")|| entry.getKey().endsWith("_JHDF")) {
+							score = score + info.getQuantifiedValue();
+						}
+
+
+
 					} else {
 						info.setQuantifiedValue(0);
 					}
 
-
-					//得分
-
 				}
 
 				info.setNonQuantifiedValue(valueMap.get(entry.getKey().replace("ID_","")).toString());
@@ -941,8 +947,18 @@ public class OrganizationEvaluationInfoServiceImpl extends ServiceImpl<Organizat
 				info.setState(valueMap.get("state").toString());//
 				evaluationInfos.add(info);
 			}
-			this.saveOrUpdateBatch(evaluationInfos);
 
+			boolean b = this.saveOrUpdateBatch(evaluationInfos);
+			if(b && null !=evaluationInfos && evaluationInfos.size()>0){
+				OrganizationEvaluationInfo info = this.getById(evaluationInfos.get(0).getId());
+				List<EvaluationScoreCount>  listcount = evaluatioinScoreCountService.getEvaluationScoreCountList(info.getOrganizationEvaluationId(),info.getOrganizationEvaluationRuleId(),info.getIndicatorId(),"");
+				if(null != listcount && listcount.size()>0){
+					EvaluationScoreCount count = listcount.get(0);
+					count.setScore(score);
+					count.setObversionScore(score);
+					evaluatioinScoreCountService.saveOrUpdate(count);
+				}
+			}
 		}
 		return true;
 	}