Commit 90873ad3 authored by suhuiguang's avatar suhuiguang

1.redis修改

parent d5862f93
...@@ -13,6 +13,7 @@ import org.aspectj.lang.annotation.Before; ...@@ -13,6 +13,7 @@ import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut; import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.web.context.request.RequestContextHolder; import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes; import org.springframework.web.context.request.ServletRequestAttributes;
...@@ -38,6 +39,7 @@ import com.yeejoin.amos.feign.privilege.model.RoleModel; ...@@ -38,6 +39,7 @@ import com.yeejoin.amos.feign.privilege.model.RoleModel;
*/ */
@Aspect @Aspect
@Component @Component
@Order(value = 0)
public class ControllerAop { public class ControllerAop {
/** /**
* saveUserRedis设置过期时间 * saveUserRedis设置过期时间
......
...@@ -17,7 +17,7 @@ public class ReginParams implements Serializable { ...@@ -17,7 +17,7 @@ public class ReginParams implements Serializable {
private AgencyUserModel userModel; private AgencyUserModel userModel;
private PersonIdentity personIdentity; private PersonIdentity personIdentity;
public static class PersonIdentity { public static class PersonIdentity implements Serializable {
private String identityType; private String identityType;
private String personSeq; private String personSeq;
......
...@@ -16,6 +16,7 @@ import com.yeejoin.amos.maintenance.common.enums.*; ...@@ -16,6 +16,7 @@ import com.yeejoin.amos.maintenance.common.enums.*;
import com.yeejoin.amos.maintenance.core.common.request.CommonPageable; import com.yeejoin.amos.maintenance.core.common.request.CommonPageable;
import com.yeejoin.amos.maintenance.core.common.request.CommonRequest; import com.yeejoin.amos.maintenance.core.common.request.CommonRequest;
import com.yeejoin.amos.maintenance.core.common.response.AppPointCheckRespone; import com.yeejoin.amos.maintenance.core.common.response.AppPointCheckRespone;
import com.yeejoin.amos.maintenance.core.framework.PersonIdentify;
import com.yeejoin.amos.maintenance.dao.entity.Point; import com.yeejoin.amos.maintenance.dao.entity.Point;
import com.yeejoin.amos.maintenance.dao.entity.PointClassify; import com.yeejoin.amos.maintenance.dao.entity.PointClassify;
import com.yeejoin.amos.maintenance.exception.YeeException; import com.yeejoin.amos.maintenance.exception.YeeException;
...@@ -458,6 +459,7 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -458,6 +459,7 @@ public class PlanTaskController extends AbstractBaseController {
* @param * @param
* @return * @return
*/ */
@PersonIdentify(isPersonIdentity = true)
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(value = "维保任务查询-mobile", notes = "根据用户条件查询所有计划任务-mobile") @ApiOperation(value = "维保任务查询-mobile", notes = "根据用户条件查询所有计划任务-mobile")
@RequestMapping(value = "/queryPlanTask", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/queryPlanTask", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
......
...@@ -576,6 +576,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService { ...@@ -576,6 +576,8 @@ public class PlanTaskServiceImpl implements IPlanTaskService {
if (total == 0) { if (total == 0) {
return new PageImpl<>(content, pageParam, total); return new PageImpl<>(content, pageParam, total);
} }
params.put("offset",pageParam.getOffset());
params.put("pageSize",pageParam.getPageSize());
content = planTaskMapper.getPlanTasks(params); content = planTaskMapper.getPlanTasks(params);
return new PageImpl<>(content, pageParam, total); return new PageImpl<>(content, pageParam, total);
} }
......
//package com.yeejoin.amos.maintenance.core.framework;
//
//import java.lang.annotation.Documented;
//import java.lang.annotation.ElementType;
//import java.lang.annotation.Retention;
//import java.lang.annotation.RetentionPolicy;
//import java.lang.annotation.Target;
//
///**
// * @author DELL
// */
//@Target(ElementType.METHOD)
//@Retention(RetentionPolicy.RUNTIME)
//@Documented
//public @interface Permission {
// /**
// * value
// * @return
// */
// String value() default "";
//
// /**
// * 是否进行人员校验
// * @return
// */
// boolean isPersonIdentity() default false;
//}
//
//package com.yeejoin.amos.maintenance.core.framework;
//
//
//import com.alibaba.fastjson.JSON;
//import com.alibaba.fastjson.JSONObject;
//import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
//import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
//import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
//import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
//import com.yeejoin.amos.component.feign.config.InnerInvokException;
//import com.yeejoin.amos.component.feign.config.TokenOperation;
//import com.yeejoin.amos.component.feign.model.FeignClientResult;
//import com.yeejoin.amos.feign.privilege.Privilege;
//import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
//import com.yeejoin.amos.feign.privilege.model.CompanyModel;
//import com.yeejoin.amos.feign.privilege.model.DepartmentModel;
//import com.yeejoin.amos.feign.privilege.model.RoleModel;
//import com.yeejoin.amos.maintenance.exception.PermissionException;
//import com.yeejoin.amos.maintenance.feign.RemoteSecurityService;
//import org.aspectj.lang.JoinPoint;
//import org.aspectj.lang.annotation.Aspect;
//import org.aspectj.lang.annotation.Before;
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.beans.BeanUtils;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.stereotype.Component;
//import org.springframework.util.ObjectUtils;
//import org.springframework.web.bind.annotation.ResponseBody;
//import org.springframework.web.context.request.RequestContextHolder;
//import org.springframework.web.context.request.ServletRequestAttributes;
//import org.typroject.tyboot.core.foundation.context.RequestContext;
//
//import javax.servlet.http.HttpServletRequest;
//import java.util.List;
//import java.util.Map;
//
//@Aspect
//@Component
//@ResponseBody
//public class PermissionAspect {
// private static final Logger logger = LoggerFactory.getLogger(PermissionAspect.class);
//
// @Autowired
// private RedisTemplate<String, String> redisTemplate;
//
// @Autowired
// private RemoteSecurityService remoteSecurityService;
//
// @Before(value = "@annotation(Permission) && @annotation(permission)")
// public void PermissionCheck(JoinPoint joinPoint, Permission permission) throws PermissionException {
// HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest();
// logger.info("======开始权限校验======");
// String token = request.getHeader("token");
// token = ObjectUtils.isEmpty(token) ? request.getHeader("X-Access-Token") : token;
// String product = request.getHeader("product");
// String appKey = request.getHeader("appKey");
// RequestContext.setToken(token);
// RequestContext.setProduct(product);
// RequestContext.setAppKey(appKey);
// if (!TokenOperation.refresh(token)) {
// throw new PermissionException("登录信息失效,请重新登录");
// }
// FeignClientResult feignClientResult;
// AgencyUserModel userModel = null;
// try {
// feignClientResult = Privilege.agencyUserClient.getme();
// userModel = (AgencyUserModel) feignClientResult.getResult();
// } catch (InnerInvokException e) {
// throw new PermissionException("用户信息校验失败");
// }
// if (userModel == null) {
// throw new PermissionException("用户信息校验失败");
// }
// String name = "";
// String companyId = "";
// String type = "";
// if (permission.isPersonIdentity()) {
// //调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
// JSONObject result = new JSONObject();
// name = result.get("name").toString();
// companyId = result.get("companyId").toString();
// type = result.get("type").toString();
// }
// ReginParams regionParam = new ReginParams();
// String userId = userModel.getUserId();
// Map<Long, List<RoleModel>> orgRoles = userModel.getOrgRoles();
// ReginParams reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userModel.getUserId(), token)), ReginParams.class);
// if (reginParams == null && userModel.getCompanys().size() > 0) {
// CompanyModel companyModel = userModel.getCompanys().get(0);
// List<DepartmentModel> deptList = remoteSecurityService.getDepartmentTreeByCompanyId(token, product, appKey, companyModel.getSequenceNbr().toString());
// regionParam.setPersonIdentity(new ReginParams.PersonIdentity(type, name, companyId));
// if (deptList.size() > 0) {
// CompanyBo companyBo = convertCompanyModelToBo(companyModel);
// DepartmentBo departmentBo = convertDepartmentModelToBo(deptList.get(0));
// regionParam.setCompany(companyBo);
// regionParam.setDepartment(departmentBo);
// if (!ObjectUtils.isEmpty(orgRoles) && !orgRoles.get(departmentBo.getSequenceNbr()).isEmpty()) {
// regionParam.setRole(convertRoleModelToBo(orgRoles.get(departmentBo.getSequenceNbr()).get(0)));
// }
// } else {
// if (!ObjectUtils.isEmpty(userModel.getOrgRoles()) && !ObjectUtils.isEmpty(companyModel) && userModel.getOrgRoles().get(companyModel.getSequenceNbr()).size() > 0) {
// RoleModel role = userModel.getOrgRoles().get(companyModel.getSequenceNbr()).get(0);
// RoleBo roleBo = new RoleBo();
// BeanUtils.copyProperties(role, roleBo);
// regionParam.setRole(roleBo);
// }
// }
// redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(regionParam));
// }
// }
//
//
// private DepartmentBo convertDepartmentModelToBo(DepartmentModel departmentModel) {
// DepartmentBo departmentBo = new DepartmentBo();
// if (departmentModel != null) {
// departmentBo.setCompanySeq(departmentModel.getCompanySeq());
// departmentBo.setDepartmentDesc(departmentModel.getDepartmentDesc());
// departmentBo.setDepartmentName(departmentModel.getDepartmentName());
// departmentBo.setLevel(departmentModel.getLevel());
// departmentBo.setOrgCode(departmentModel.getOrgCode());
// departmentBo.setParentId(departmentModel.getParentId());
// departmentBo.setDeptOrgCode(departmentModel.getDeptOrgCode());
// departmentBo.setSequenceNbr(departmentModel.getSequenceNbr());
// }
// return departmentBo;
// }
//
// /**
// * Model 转 Bo
// */
// private CompanyBo convertCompanyModelToBo(CompanyModel companyModel) {
//
// CompanyBo companyBo = new CompanyBo();
// if (companyModel != null) {
// companyBo.setAddress(companyModel.getAddress());
// companyBo.setCompanyName(companyModel.getCompanyName());
// companyBo.setCompanyOrgCode(companyModel.getCompanyOrgCode());
// companyBo.setEmail(companyModel.getEmail());
// companyBo.setLandlinePhone(companyModel.getLandlinePhone());
// companyBo.setLongitude(companyModel.getLongitude());
// companyBo.setLatitude(companyModel.getLatitude());
// companyBo.setLevel(companyModel.getLevel());
// companyBo.setOrgCode(companyModel.getOrgCode());
// companyBo.setSequenceNbr(companyModel.getSequenceNbr());
// companyBo.setParentId(companyModel.getParentId());
// }
// return companyBo;
// }
//
// private RoleBo convertRoleModelToBo(RoleModel roleModel) {
// RoleBo roleBo = new RoleBo();
// if (roleModel != null) {
// roleBo.setRoleName(roleModel.getRoleName());
// roleBo.setRoleType(roleModel.getRoleType());
// roleBo.setSequenceNbr(roleModel.getSequenceNbr());
// }
// return roleBo;
// }
//
// /**
// * redis缓存选择的用户信息
// *
// * @param userId userId
// * @param token token
// * @return String
// */
// private String buildKey(String userId, String token) {
// return "region_" + userId + "_" + token;
//
// }
//}
package com.yeejoin.amos.maintenance.core.framework;
import org.springframework.core.annotation.AliasFor;
import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
/**
* @author DELL
*/
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface PersonIdentify {
/**
* 是否进行人员校验
* @return
*/
boolean isPersonIdentity() default false;
}
package com.yeejoin.amos.maintenance.core.framework;
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.RedisUtils;
import com.yeejoin.amos.maintenance.exception.PermissionException;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.springframework.beans.factory.annotation.Autowired;
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 PersonIdentifyAspect {
@Autowired
RedisUtils redisUtils;
@Before(value = "@annotation(com.yeejoin.amos.maintenance.core.framework.PersonIdentify) && @annotation(permission)")
public void personIdentity(JoinPoint joinPoint, PersonIdentify permission) throws PermissionException {
ReginParams reginParam = JSON.parseObject(redisUtils.get(buildKey(RequestContext.getToken())).toString(), ReginParams.class);
if (permission.isPersonIdentity() && reginParam != null) {
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
// JSONObject result = new JSONObject();
// String identityType = result.get("identityType").toString();
// String personSeq = result.get("personSeq").toString();
// String personName = result.get("personName").toString();
// String companyId = result.get("companyId").toString();
String identityType = "1";
String personSeq = "1421016571081420802";
String personName = "SHG";
String companyId = "10";
reginParam.setPersonIdentity(new ReginParams.PersonIdentity(identityType, personSeq, personName, companyId));
redisUtils.set(buildKey(RequestContext.getToken()), JSONObject.toJSONString(reginParam));
}
}
public String buildKey(String token) {
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
//return "region_" + userId + "_" + token;
return "region_" + token;
}
}
...@@ -19,7 +19,7 @@ public class LatentDanerScheduled { ...@@ -19,7 +19,7 @@ public class LatentDanerScheduled {
* 每1分钟执行一次:查询逾期的隐患,修改状态 * 每1分钟执行一次:查询逾期的隐患,修改状态
*/ */
@Scheduled(cron = "0 0/1 * * * ?") // @Scheduled(cron = "0 0/1 * * * ?")
public void updateDangerStateOfOvertime() { public void updateDangerStateOfOvertime() {
iLatentDangerService.updateDangerStateOfOvertime(); iLatentDangerService.updateDangerStateOfOvertime();
} }
......
...@@ -207,6 +207,7 @@ ...@@ -207,6 +207,7 @@
INNER JOIN p_route r on r.id = pt.route_id INNER JOIN p_route r on r.id = pt.route_id
) a ) a
<include refid="mobile-plan-task-where" /> <include refid="mobile-plan-task-where" />
<if test="orderBy != null and orderBy != ''"> order by ${orderBy}</if>
limit #{offset},#{pageSize} limit #{offset},#{pageSize}
</select> </select>
<sql id="mobile-plan-task-where"> <sql id="mobile-plan-task-where">
...@@ -243,7 +244,6 @@ ...@@ -243,7 +244,6 @@
</when> </when>
</choose> </choose>
</where> </where>
<if test="orderBy != null and orderBy != ''"> order by ${orderBy} </if>
</sql> </sql>
<select id="getPlanTasksCount" resultType="long"> <select id="getPlanTasksCount" resultType="long">
......
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