Commit be739e04 authored by 韩桐桐's avatar 韩桐桐

fix(两个规定):接口中查询不到当前单位orgCode问题

parent eaa93019
//package com.yeejoin.amos.patrol.config;
//
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
//import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
//import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
//import com.yeejoin.amos.component.feign.model.FeignClientResult;
//import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
//import com.yeejoin.amos.patrol.exception.PermissionException;
//import org.apache.commons.lang3.StringUtils;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.aspectj.lang.annotation.Pointcut;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.beans.factory.annotation.Value;
//import org.springframework.core.annotation.Order;
//import org.springframework.http.HttpStatus;
//import org.springframework.stereotype.Component;
//import org.springframework.util.ObjectUtils;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.typroject.tyboot.core.foundation.context.RequestContext;
//
///**
// * @author DELL
// */
//@Aspect
//@Component
//@ResponseBody
//@Order(value = 1)
//public class PersonIdentifyTzsAspect {
//
// @Autowired
// RedisUtils redisUtils;
// @Autowired
// private JcsFeignClient jcsFeignClient;
//
// @Value("${logic}")
// Boolean logic;
//
// @Pointcut("execution(public * com.yeejoin.amos.*.business.controller..*(..))")
// public void userDate() {
//
package com.yeejoin.amos.patrol.config;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.patrol.business.feign.JcsFeignClient;
import com.yeejoin.amos.patrol.exception.PermissionException;
import org.apache.commons.lang3.StringUtils;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ResponseBody;
import org.typroject.tyboot.core.foundation.context.RequestContext;
/**
* @author DELL
*/
@Aspect
@Component
@ResponseBody
@Order(value = 1)
public class PersonIdentifyTzsAspect {
@Autowired
RedisUtils redisUtils;
@Autowired
private JcsFeignClient jcsFeignClient;
@Value("${logic}")
Boolean logic;
@Pointcut("execution(public * com.yeejoin.amos.*.business.controller..*(..))")
public void userDate() {
}
@Before("userDate()")
public void personIdentity(JoinPoint joinPoint) throws PermissionException {
//定时任务没有token
if(RequestContext.getExeUserId()==null|| RequestContext.getToken()==null){
}else {
ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (reginParam != null ) {
if (reginParam.getPersonIdentity() == null || StringUtils.isEmpty(reginParam.getPersonIdentity().getBizOrgCode()) ) {
String userId = reginParam.getUserModel().getUserId();
if (userId != null) {
// FeignClientResult responseModel = jcsFeignClient.selectById(userId);
//
//
// if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HttpStatus.OK.value()) {
// throw new RuntimeException(responseModel.getDevMessage());
// }
//
//
// @Before("userDate()")
// public void personIdentity(JoinPoint joinPoint) throws PermissionException {
//
//
// //定时任务没有token
// if(RequestContext.getExeUserId()==null|| RequestContext.getToken()==null){
//
// }else {
// ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
// if (reginParam != null ) {
// if (reginParam.getPersonIdentity() == null || StringUtils.isEmpty(reginParam.getPersonIdentity().getBizOrgCode()) ) {
// String userId = reginParam.getUserModel().getUserId();
//
// if (userId != null) {
//// FeignClientResult responseModel = jcsFeignClient.selectById(userId);
////
////
//// if (ObjectUtils.isEmpty(responseModel.getResult()) || responseModel.getStatus() != HttpStatus.OK.value()) {
//// throw new RuntimeException(responseModel.getDevMessage());
//// }
//// String s = JSONObject.toJSONString(responseModel.getResult());
//// ReginParams.PersonIdentity personIdentity = JSONObject.parseObject(s, ReginParams.PersonIdentity.class);
// ReginParams.PersonIdentity personIdentity = new ReginParams.PersonIdentity();
// // ReginParams.PersonIdentity personIdentity = (ReginParams.PersonIdentity) Bean.mapToBean((Map<String, Object>) responseModel.getResult(), ReginParams.PersonIdentity.class);
// //电力默认走公司权限
// if (!logic) {
// personIdentity.setBizOrgCode(StringUtils.isEmpty(reginParam.getCompany().getOrgCode()) ? "-1" : reginParam.getCompany().getOrgCode());
// }
//
// reginParam.setPersonIdentity(personIdentity);
// redisUtils.set(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()), JSONObject.toJSONString(reginParam));
//
// }
// }
// }
// }
// }
//
//}
//
// String s = JSONObject.toJSONString(responseModel.getResult());
// ReginParams.PersonIdentity personIdentity = JSONObject.parseObject(s, ReginParams.PersonIdentity.class);
ReginParams.PersonIdentity personIdentity = new ReginParams.PersonIdentity();
// ReginParams.PersonIdentity personIdentity = (ReginParams.PersonIdentity) Bean.mapToBean((Map<String, Object>) responseModel.getResult(), ReginParams.PersonIdentity.class);
//电力默认走公司权限
// if (!logic) {
personIdentity.setBizOrgCode(StringUtils.isEmpty(reginParam.getCompany().getOrgCode()) ? "-1" : reginParam.getCompany().getOrgCode());
// }
reginParam.setPersonIdentity(personIdentity);
redisUtils.set(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()), JSONObject.toJSONString(reginParam));
}
}
}
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment