Commit 39756c60 authored by chenhao's avatar chenhao

Merge branch 'developer' of http://172.16.10.76/moa/amos-boot-biz into developer

parents 9e000e5c eadf7bde
package com.yeejoin.amos.boot.biz.common.aop; package com.yeejoin.amos.boot.biz.common.aop;
import java.util.Arrays; import com.alibaba.fastjson.JSONObject;
import java.util.List; import com.yeejoin.amos.boot.biz.common.bo.CompanyBo;
import java.util.Map; import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams;
import javax.servlet.http.HttpServletRequest; import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
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.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 org.aspectj.lang.JoinPoint; import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.AfterReturning; import org.aspectj.lang.annotation.AfterReturning;
import org.aspectj.lang.annotation.Aspect; import org.aspectj.lang.annotation.Aspect;
...@@ -17,20 +24,14 @@ import org.springframework.core.annotation.Order; ...@@ -17,20 +24,14 @@ 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;
import org.typroject.tyboot.core.auth.exception.AuthException;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import org.typroject.tyboot.core.foundation.utils.Bean; import org.typroject.tyboot.core.foundation.utils.Bean;
import com.alibaba.fastjson.JSONObject; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.boot.biz.common.bo.CompanyBo; import java.util.Arrays;
import com.yeejoin.amos.boot.biz.common.bo.DepartmentBo; import java.util.List;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; import java.util.Map;
import com.yeejoin.amos.boot.biz.common.bo.RoleBo;
import com.yeejoin.amos.boot.biz.common.utils.RedisUtils;
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;
/** /**
* controller层切面 用于用户数据缓存 供 sql自动填充使用 * controller层切面 用于用户数据缓存 供 sql自动填充使用
...@@ -56,52 +57,47 @@ public class ControllerAop { ...@@ -56,52 +57,47 @@ public class ControllerAop {
} }
@Before("userCache()") @Before("userCache()")
public void doBefore(JoinPoint joinPoint) throws Throwable { public void doBefore(JoinPoint joinPoint) {
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
HttpServletRequest request = attributes.getRequest(); HttpServletRequest request = attributes.getRequest();
String token = request.getHeader("token"); //TODO tyboot 框架拦截器已缓存数据
if (token == null) { String token = RequestContext.getToken();
token = request.getHeader("X-Access-Token"); // 不需要添加请求头的接口
} String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany", "/jcs/command/lookHtmlText"};
String authProduct = request.getHeader("product"); // 获取请求路径
if (authProduct == null) { if (Arrays.asList(url).contains(request.getRequestURI())) {
authProduct = request.getParameter("product"); return;
} }
String authAppKey = request.getHeader("appKey");
if (authAppKey == null) {
authAppKey = request.getParameter("appKey");
}
String authToken = buildKey(token);
if (token != null) { if (token != null) {
//验证token有效性,防止token失效 String pattern = buildPatternKey(token);
AgencyUserModel userModel; //验证token有效性,防止token失效
try { AgencyUserModel userModel;
FeignClientResult<AgencyUserModel> agencyUserModel = Privilege.agencyUserClient.getme(); try {
userModel = agencyUserModel.getResult(); FeignClientResult<AgencyUserModel> agencyUserModel = Privilege.agencyUserClient.getme();
if (userModel == null) { userModel = agencyUserModel.getResult();
throw new Exception("无法获取用户信息"); if (userModel == null) {
} throw new Exception("无法获取用户信息");
} catch (Exception e) {
//删除失效token缓存
redisUtils.del(authToken);
throw new RuntimeException(e.getMessage());
}
// 不需要添加请求头的接口
String[] url = new String[]{"/api/user/selectInfo", "/api/user/save/curCompany", "/jcs/command/lookHtmlText"};
// 获取请求路径
if (Arrays.asList(url).contains(request.getRequestURI())) {
// 暂无需要
} else {
if (!redisUtils.hasKey(authToken)) {
saveUserRedis(userModel, token);
} }
} } catch (Exception e) {
//删除失效token缓存
redisUtils.getAndDeletePatternKeys(pattern);
throw new RuntimeException(e.getMessage());
}
saveUserRedis(userModel, token);
} else {
throw new AuthException("请求未包含认证信息.");
} }
// buildRequestCxt(authToken,authProduct,authAppKey);
System.out.println(redisUtils.get(authToken));
} }
public void saveUserRedis(AgencyUserModel user, String token) { private String buildPatternKey(String token) {
return "region_" + "*" + "_" + token;
}
private void saveUserRedis(AgencyUserModel user, String token) {
String authToken = RedisKey.buildReginKey(user.getUserId(), token);
if (redisUtils.hasKey(authToken)) {
return;
}
CompanyBo company = new CompanyBo(); CompanyBo company = new CompanyBo();
DepartmentBo department = new DepartmentBo(); DepartmentBo department = new DepartmentBo();
RoleBo role = new RoleBo(); RoleBo role = new RoleBo();
...@@ -129,18 +125,12 @@ public class ControllerAop { ...@@ -129,18 +125,12 @@ public class ControllerAop {
reginParams.setRole(role); reginParams.setRole(role);
reginParams.setDepartment(department); reginParams.setDepartment(department);
reginParams.setUserModel(user); reginParams.setUserModel(user);
String authToken = buildKey(token);
redisUtils.set(authToken, JSONObject.toJSONString(reginParams), redisRegionTimeSecond); redisUtils.set(authToken, JSONObject.toJSONString(reginParams), redisRegionTimeSecond);
} }
public String buildKey(String token) {
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时,
//return "region_" + userId + "_" + token;
return "region_"+ token;
}
@AfterReturning(returning = "ret", pointcut = "userCache()") @AfterReturning(returning = "ret", pointcut = "userCache()")
public void doAfterReturning(Object ret) throws Throwable { public void doAfterReturning(Object ret) throws Throwable {
//统一redis管理 //统一redis管理
// ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); // ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
// HttpServletRequest request = attributes.getRequest(); // HttpServletRequest request = attributes.getRequest();
// String token = request.getHeader("token"); // String token = request.getHeader("token");
...@@ -148,9 +138,4 @@ public class ControllerAop { ...@@ -148,9 +138,4 @@ public class ControllerAop {
// GlobalCache.paramMap.remove(token); // GlobalCache.paramMap.remove(token);
// } // }
} }
// public void buildRequestCxt(String token,String product,String appKey){
// RequestContext.setToken(token);
// RequestContext.setProduct(product);
// RequestContext.setAppKey(appKey);
//}
} }
package com.yeejoin.amos.boot.biz.common.controller; package com.yeejoin.amos.boot.biz.common.controller;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; 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.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.feign.privilege.model.AgencyUserModel; import com.yeejoin.amos.feign.privilege.model.AgencyUserModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.typroject.tyboot.core.foundation.context.RequestContext;
import springfox.documentation.annotations.ApiIgnore; import springfox.documentation.annotations.ApiIgnore;
import javax.servlet.http.HttpServletRequest;
/** /**
* 基础控制器 * 基础控制器
* *
...@@ -24,112 +23,108 @@ import springfox.documentation.annotations.ApiIgnore; ...@@ -24,112 +23,108 @@ import springfox.documentation.annotations.ApiIgnore;
@RequestMapping("/base") @RequestMapping("/base")
public class BaseController { public class BaseController {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
@Autowired @Autowired
protected HttpServletRequest request; protected HttpServletRequest request;
/** /**
* 获取token * 获取token
**/ **/
protected String getToken() { protected String getToken() {
return RequestContext.getToken(); return RequestContext.getToken();
} }
public String buildKey(String token) {
//由于用户id 不是接口携带参数,为了避免,公共字段填充时频繁访问平台,缓存用户信息时, /**
//return "region_" + userId + "_" + token; * 用户选择信心redis获取
return "region_"+ token; **/
protected ReginParams getSelectedOrgInfo() {
return JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
}
protected String getOrgCode(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getCompany() != null) {
return reginParams.getCompany().getOrgCode();
}
return null;
}
/**
* 当前登录用户信息
*/
protected AgencyUserModel getUserInfo() {
ReginParams reginParams = getSelectedOrgInfo();
return reginParams.getUserModel();
}
protected String getProduct() {
return RequestContext.getProduct();
}
protected String getAppKey() {
return RequestContext.getAppKey();
}
protected String getUserId() {
String userId = null;
if (getUserInfo() != null) {
userId = getUserInfo().getUserId();
}
return userId;
}
protected String getRoleTypeName(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getRole() != null) {
return reginParams.getRole().getRoleType();
}
return null;
}
protected String getDepartmentId(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getDepartment().getSequenceNbr() != null) {
return reginParams.getDepartment().getSequenceNbr().toString();
}
return null;
}
protected String getDepartmentName(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getDepartment().getDepartmentName() != null) {
return reginParams.getDepartment().getDepartmentName();
}
return null;
}
protected String getCompanyId(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getCompany() != null) {
return reginParams.getCompany().getSequenceNbr().toString();
}
return null;
}
protected String getCompanyName(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getCompany() != null) {
return reginParams.getCompany().getCompanyName();
}
return null;
} }
/**
* 用户选择信心redis获取
**/
protected ReginParams getSelectedOrgInfo() {
return JSONObject.parseObject(redisUtils.get(buildKey(RequestContext.getToken())).toString(), ReginParams.class);
}
protected String getOrgCode(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getCompany() != null) {
return reginParams.getCompany().getOrgCode();
}
return null;
}
/**
* 当前登录用户信息
*/
protected AgencyUserModel getUserInfo() {
ReginParams reginParams = getSelectedOrgInfo();
return reginParams.getUserModel();
}
protected String getProduct() {
return RequestContext.getProduct();
}
protected String getAppKey() {
return RequestContext.getAppKey();
}
protected String getUserId() {
String userId = null;
if (getUserInfo() != null) {
userId = getUserInfo().getUserId();
}
return userId;
}
protected String getRoleTypeName(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getRole() != null) {
return reginParams.getRole().getRoleType();
}
return null;
}
protected String getDepartmentId(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getDepartment().getSequenceNbr() != null) {
return reginParams.getDepartment().getSequenceNbr().toString();
}
return null;
}
protected String getDepartmentName(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getDepartment().getDepartmentName() != null) {
return reginParams.getDepartment().getDepartmentName();
}
return null;
}
protected String getCompanyId(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getCompany() != null) {
return reginParams.getCompany().getSequenceNbr().toString();
}
return null;
}
protected String getCompanyName(ReginParams reginParams) {
if (reginParams == null) {
return null;
}
if (reginParams.getCompany() != null) {
return reginParams.getCompany().getCompanyName();
}
return null;
}
} }
...@@ -31,19 +31,18 @@ public class RedisKey { ...@@ -31,19 +31,18 @@ public class RedisKey {
/**联通CTI token */ /**联通CTI token */
public static final String CTI_TOKEN = "cti_token"; public static final String CTI_TOKEN = "cti_token";
/** 驼峰转下划线(简单写法,效率低于{@link #humpToLine2(String)}) */ /** 驼峰转下划线(简单写法,效率低于 ) */
public static String humpToLine(String str) { public static String humpToLine(String str) {
return str.replaceAll("[A-Z]", "_$0").toLowerCase(); return str.replaceAll("[A-Z]", "_$0").toLowerCase();
} }
/** /**
* 创建redis key * 创建redis key
*
* @param token * @param token
* @return * @return String
*/ */
public static String buildKey(String token) { public static String buildReginKey(String userId, String token) {
return "region_" + token; return "region_" + userId + "_" + token;
} }
/** /**
......
...@@ -442,4 +442,12 @@ public class RedisUtils { ...@@ -442,4 +442,12 @@ public class RedisUtils {
redisTemplate.opsForList().set(key, index, value); redisTemplate.opsForList().set(key, index, value);
return true; return true;
} }
public Long getAndDeletePatternKeys(String pattern) {
Set<String> keys = redisTemplate.keys(pattern);
if (!CollectionUtils.isEmpty(keys)) {
return redisTemplate.delete(keys);
}
return null;
}
} }
...@@ -22,90 +22,85 @@ import java.util.Map; ...@@ -22,90 +22,85 @@ import java.util.Map;
@Component @Component
public class MetaHandler implements MetaObjectHandler { public class MetaHandler implements MetaObjectHandler {
@Autowired @Autowired
private RedisUtils redisUtils; private RedisUtils redisUtils;
protected String getToken() { protected String getToken() {
String authToken = RequestContext.getToken(); String authToken = RequestContext.getToken();
// if (authToken == null) { // if (authToken == null) {
// authToken = request.getHeader("X-Access-Token"); // authToken = request.getHeader("X-Access-Token");
// } // }
return authToken; return authToken;
} }
/**
* 新增数据拦截
*
* @param metaObject
*/
@Override
public void insertFill(MetaObject metaObject) {
autoFillUser(metaObject, metaObject.getOriginalObject());
}
private void autoFillUser(MetaObject metaObject, Object entity) {
//获取用户信息 以及当前用户登录公司部门,角色
ReginParams reginParams =
JSONObject.parseObject(null != redisUtils.get(RedisKey.buildKey(getToken())) ?
redisUtils.get(RedisKey.buildKey(getToken())).toString() : null, ReginParams.class);
if (ObjectUtils.isEmpty(reginParams)) {
return;
}
AgencyUserModel agencyUserModel = reginParams.getUserModel();
if(ObjectUtils.isEmpty(reginParams) || ObjectUtils.isEmpty(agencyUserModel)){
return;
}
// Object entity = metaObject.getOriginalObject();
if (isExistField("recUserId", entity)) {
this.setFieldValByName("recUserId", agencyUserModel.getUserId(), metaObject);
}
if (isExistField("recUserName", entity)) { /**
this.setFieldValByName("recUserName", agencyUserModel.getUserName(), metaObject); * 新增数据拦截
} *
if (isExistField("recDate", entity)) { * @param metaObject
Date currentDate = new Date(); */
this.setFieldValByName("recDate", currentDate, metaObject); @Override
} public void insertFill(MetaObject metaObject) {
if (isExistField("allotmentTime", entity)) { autoFillUser(metaObject, metaObject.getOriginalObject());
Date currentDate = new Date(); }
this.setFieldValByName("recDate", currentDate, metaObject);
}
private void autoFillUser(MetaObject metaObject, Object entity) {
//获取用户信息 以及当前用户登录公司部门,角色
String userId = RequestContext.getExeUserId();
ReginParams reginParams =
JSONObject.parseObject(null != redisUtils.get(RedisKey.buildReginKey(userId, getToken())) ?
redisUtils.get(RedisKey.buildReginKey(userId, getToken())).toString() : null, ReginParams.class);
if (ObjectUtils.isEmpty(reginParams)) {
return;
}
AgencyUserModel agencyUserModel = reginParams.getUserModel();
if (ObjectUtils.isEmpty(reginParams) || ObjectUtils.isEmpty(agencyUserModel)) {
return;
}
if (isExistField("recUserId", entity)) {
this.setFieldValByName("recUserId", agencyUserModel.getUserId(), metaObject);
}
if (isExistField("recUserName", entity)) {
this.setFieldValByName("recUserName", agencyUserModel.getUserName(), metaObject);
}
if (isExistField("recDate", entity)) {
Date currentDate = new Date();
this.setFieldValByName("recDate", currentDate, metaObject);
}
if (isExistField("allotmentTime", entity)) {
Date currentDate = new Date();
this.setFieldValByName("recDate", currentDate, metaObject);
}
// if (isExistField("companyCode", entity)) { // if (isExistField("companyCode", entity)) {
// this.setFieldValByName("companyCode", reginParams.getDepartment().getOrgCode(), metaObject); // this.setFieldValByName("companyCode", reginParams.getDepartment().getOrgCode(), metaObject);
// } // }
// if (isExistField("companyName", entity)) { // if (isExistField("companyName", entity)) {
// this.setFieldValByName("companyName", reginParams.getDepartment().getDepartmentName(), metaObject); // this.setFieldValByName("companyName", reginParams.getDepartment().getDepartmentName(), metaObject);
// } // }
}
}
private Boolean isExistField(String field, Object obj) { private Boolean isExistField(String field, Object obj) {
if (obj == null || StringUtils.isEmpty(field)) { if (obj == null || StringUtils.isEmpty(field)) {
return null; return null;
} }
Object o = JSONObject.toJSON(obj); Object o = JSONObject.toJSON(obj);
JSONObject jsonObj = new JSONObject(); JSONObject jsonObj = new JSONObject();
if (o instanceof JSONObject) { if (o instanceof JSONObject) {
jsonObj = (JSONObject) o; jsonObj = (JSONObject) o;
} }
return jsonObj.containsKey(field); return jsonObj.containsKey(field);
} }
/** /**
* 更新拦截 * 更新拦截
* *
* @param metaObject * @param metaObject
*/ */
@Override @Override
public void updateFill(MetaObject metaObject) { public void updateFill(MetaObject metaObject) {
Object updateEntity = ((Map)metaObject.getOriginalObject()).get("et"); Object updateEntity = ((Map) metaObject.getOriginalObject()).get("et");
autoFillUser(metaObject, updateEntity); autoFillUser(metaObject, updateEntity);
Date currentDate = new Date(); Date currentDate = new Date();
this.setFieldValByName("updateTime", currentDate, metaObject); this.setFieldValByName("updateTime", currentDate, metaObject);
} }
} }
\ No newline at end of file
...@@ -163,7 +163,13 @@ public class FirefightersContractController extends BaseController { ...@@ -163,7 +163,13 @@ public class FirefightersContractController extends BaseController {
firefightersContractQueryWrapper.eq(name, fileValue); firefightersContractQueryWrapper.eq(name, fileValue);
} else if (type.equals(String.class)) { } else if (type.equals(String.class)) {
String fileValue = (String) field.get(firefightersContract); String fileValue = (String) field.get(firefightersContract);
firefightersContractQueryWrapper.eq(name, fileValue); /* BUG 2193 合同名称模糊匹配 start*/
if ("name".equals(name)) {
firefightersContractQueryWrapper.like(name, fileValue);
} else {
firefightersContractQueryWrapper.eq(name, fileValue);
}
/* BUG 2193 合同名称模糊匹配 end*/
}else if (type.equals(Date.class)) { }else if (type.equals(Date.class)) {
Date fileValue = (Date) field.get(firefightersContract); Date fileValue = (Date) field.get(firefightersContract);
firefightersContractQueryWrapper.eq(name, fileValue); firefightersContractQueryWrapper.eq(name, fileValue);
......
...@@ -5,6 +5,7 @@ import java.util.Map; ...@@ -5,6 +5,7 @@ import java.util.Map;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import com.yeejoin.amos.boot.biz.common.utils.RedisKey;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
...@@ -80,7 +81,7 @@ public class LoginController { ...@@ -80,7 +81,7 @@ public class LoginController {
.getRequestAttributes()).getRequest(); .getRequestAttributes()).getRequest();
String token = (String) request.getHeader("token"); String token = (String) request.getHeader("token");
ReginParams reginParams; ReginParams reginParams;
reginParams = JSON.parseObject(redisTemplate.opsForValue().get(buildKey(userId, token)), ReginParams.class); reginParams = JSON.parseObject(redisTemplate.opsForValue().get(RedisKey.buildReginKey(userId, token)), ReginParams.class);
if(reginParams == null){ if(reginParams == null){
reginParams = new ReginParams(); reginParams = new ReginParams();
IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel(); IdPasswordAuthModel dPasswordAuthModel = new IdPasswordAuthModel();
...@@ -109,8 +110,8 @@ public class LoginController { ...@@ -109,8 +110,8 @@ public class LoginController {
} }
reginParams.setToken(amosToken); reginParams.setToken(amosToken);
reginParams.setUserModel(userModel); reginParams.setUserModel(userModel);
redisTemplate.opsForValue().set(buildKey(userId, token), JSONObject.toJSONString(reginParams)); redisTemplate.opsForValue().set(RedisKey.buildReginKey(userId, token), JSONObject.toJSONString(reginParams));
redisTemplate.opsForValue().set(buildKey(userId, amosToken), JSONObject.toJSONString(reginParams)); redisTemplate.opsForValue().set(RedisKey.buildReginKey(userId, amosToken), JSONObject.toJSONString(reginParams));
} }
return reginParams; return reginParams;
} }
...@@ -159,9 +160,4 @@ public class LoginController { ...@@ -159,9 +160,4 @@ public class LoginController {
} }
return roleBo; return roleBo;
} }
private String buildKey(String userId, String token) {
return "region_" + userId + "_" + token;
}
} }
...@@ -210,6 +210,10 @@ public class AircraftController extends BaseController { ...@@ -210,6 +210,10 @@ public class AircraftController extends BaseController {
map1.put("aircraftModel", map.get("aircraftType")); map1.put("aircraftModel", map.get("aircraftType"));
map1.put("dynamicFlightId", map.get("dynamicFlightId")); map1.put("dynamicFlightId", map.get("dynamicFlightId"));
map1.put("landingTime", map.get("sta")); map1.put("landingTime", map.get("sta"));
/* 任务 3488 根据航班号查询航班信息回填 增加跑道,机位字段 start*/
map1.put("runway", map.get("runway"));
map1.put("stand", map.get("stand"));
/* 任务 3488 根据航班号查询航班信息回填 end*/
// map1.put("fuelQuantity", map.get("")); // map1.put("fuelQuantity", map.get(""));
map1.put("passengerCapacity", map.get("psgNumTotal")); map1.put("passengerCapacity", map.get("psgNumTotal"));
} }
......
...@@ -208,7 +208,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al ...@@ -208,7 +208,7 @@ public class AlertSubmittedServiceImpl extends BaseService<AlertSubmittedDto, Al
alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName()); alertSubmitted.setSchedulingType(alertSchedulingTypeEnum.get().getName());
alertSubmitted.setSubmissionContent(JSONObject.toJSONString(objectToMap(calledRo))); alertSubmitted.setSubmissionContent(JSONObject.toJSONString(objectToMap(calledRo)));
String token = RequestContext.getToken(); String token = RequestContext.getToken();
ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildKey(token)).toString(), ReginParams reginParams = JSONObject.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(),token)).toString(),
ReginParams.class); ReginParams.class);
alertSubmitted.setRecUserName(reginParams.getUserModel().getUserName()); alertSubmitted.setRecUserName(reginParams.getUserModel().getUserName());
alertSubmitted.setSender(reginParams.getUserModel().getUserName()); alertSubmitted.setSender(reginParams.getUserModel().getUserName());
......
...@@ -102,11 +102,21 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -102,11 +102,21 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
List<FireTeamCardDto> fireTeamList = fireTeamListPage.getRecords(); List<FireTeamCardDto> fireTeamList = fireTeamListPage.getRecords();
Map<Object, Long> finalTeamCarCountMap = teamCarCountMap; Map<Object, Long> finalTeamCarCountMap = teamCarCountMap;
fireTeamList.forEach(t -> { fireTeamList.forEach(t -> {
if (!ValidationUtil.isEmpty(finalTeamCarCountMap.get(t.getSequenceNbr().toString()))) { //递归返回teamId bug2684 bykongfm
t.setCarNum(finalTeamCarCountMap.get(t.getSequenceNbr().toString()).intValue()); List<Long> teamIds = new ArrayList<Long>();
//递归查找全部战备人数 BUG2217 bykongfm getAllTeamId(teamIds,t.getSequenceNbr());
t.setFighterNum(getFightNumByTeamId(t.getSequenceNbr())); int carNum = 0;
int fighterNum = 0;
for(Long tempId : teamIds ) {
if(finalTeamCarCountMap.get(tempId.toString()) != null) {
carNum += finalTeamCarCountMap.get(tempId.toString()).intValue();
}
fighterNum += fireTeamMapper.getFighterNumByTeamId(tempId);
} }
t.setCarNum(carNum);
t.setFighterNum(fighterNum);
/*//递归查找全部战备人数 BUG2217 bykongfm
t.setFighterNum(getFightNumByTeamId(t.getSequenceNbr()));*/
}); });
fireTeamListPage.setRecords(fireTeamList); fireTeamListPage.setRecords(fireTeamList);
return fireTeamListPage; return fireTeamListPage;
...@@ -316,4 +326,18 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire ...@@ -316,4 +326,18 @@ public class FireTeamServiceImpl extends BaseService<FireTeamDto, FireTeam, Fire
} }
public void getAllTeamId(List<Long> teamIds, Long teamId) {
teamIds.add(teamId);
LambdaQueryWrapper<FireTeam> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(FireTeam::getParent, teamId).eq(FireTeam::getIsDelete, false);
List<FireTeam> fireTeamList = this.list(queryWrapper);
if (fireTeamList.size() == 0) {
// 没有下级单位
} else {
for (FireTeam t : fireTeamList) {
getAllTeamId(teamIds, t.getSequenceNbr());
}
}
}
} }
...@@ -4,6 +4,7 @@ package com.yeejoin.amos.maintenance.core.framework; ...@@ -4,6 +4,7 @@ package com.yeejoin.amos.maintenance.core.framework;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.yeejoin.amos.boot.biz.common.bo.ReginParams; 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.boot.biz.common.utils.RedisUtils;
import com.yeejoin.amos.component.feign.model.FeignClientResult; import com.yeejoin.amos.component.feign.model.FeignClientResult;
import com.yeejoin.amos.maintenance.business.feign.JCSFeignClient; import com.yeejoin.amos.maintenance.business.feign.JCSFeignClient;
...@@ -39,7 +40,7 @@ public class PersonIdentifyAspect { ...@@ -39,7 +40,7 @@ public class PersonIdentifyAspect {
@Before(value = "@annotation(com.yeejoin.amos.maintenance.core.framework.PersonIdentify) && @annotation(permission)") @Before(value = "@annotation(com.yeejoin.amos.maintenance.core.framework.PersonIdentify) && @annotation(permission)")
public void personIdentity(JoinPoint joinPoint, PersonIdentify permission) throws PermissionException { public void personIdentity(JoinPoint joinPoint, PersonIdentify permission) throws PermissionException {
ReginParams reginParam = JSON.parseObject(redisUtils.get(buildKey(RequestContext.getToken())).toString(), ReginParams.class); ReginParams reginParam = JSON.parseObject(redisUtils.get(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken())).toString(), ReginParams.class);
if (permission.isNeedIdentity() && reginParam != null) { if (permission.isNeedIdentity() && reginParam != null) {
//调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员 //调用jcs,进行人员身份判断,是维保公司人员还是业主单位人员
String userId = reginParam.getUserModel().getUserId(); String userId = reginParam.getUserModel().getUserId();
...@@ -49,12 +50,8 @@ public class PersonIdentifyAspect { ...@@ -49,12 +50,8 @@ public class PersonIdentifyAspect {
} }
ReginParams.PersonIdentity personIdentity = (ReginParams.PersonIdentity) Bean.mapToBean((Map<String, Object>) responseModel.getResult(), ReginParams.PersonIdentity.class); ReginParams.PersonIdentity personIdentity = (ReginParams.PersonIdentity) Bean.mapToBean((Map<String, Object>) responseModel.getResult(), ReginParams.PersonIdentity.class);
reginParam.setPersonIdentity(personIdentity); reginParam.setPersonIdentity(personIdentity);
redisUtils.set(buildKey(RequestContext.getToken()), JSONObject.toJSONString(reginParam)); redisUtils.set(RedisKey.buildReginKey(RequestContext.getExeUserId(), RequestContext.getToken()), JSONObject.toJSONString(reginParam));
} }
} }
public String buildKey(String token) {
return "region_" + token;
}
} }
...@@ -99,6 +99,11 @@ ...@@ -99,6 +99,11 @@
<groupId>cn.jpush.api</groupId> <groupId>cn.jpush.api</groupId>
<artifactId>jpush-client</artifactId> <artifactId>jpush-client</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.5.1</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -386,7 +386,7 @@ public class PlanTaskController extends AbstractBaseController { ...@@ -386,7 +386,7 @@ public class PlanTaskController extends AbstractBaseController {
@RequestMapping(value = "/v2/initPlanTask", produces = "application/json;charset=UTF-8", method = RequestMethod.GET) @RequestMapping(value = "/v2/initPlanTask", produces = "application/json;charset=UTF-8", method = RequestMethod.GET)
public CommonResponse qryPlanTaskDetailByIdInVersion2( public CommonResponse qryPlanTaskDetailByIdInVersion2(
@ApiParam(value = "巡检计划任务ID") @RequestParam(required = false) Long planTaskId, @ApiParam(value = "巡检计划任务ID") @RequestParam(required = false) Long planTaskId,
@ApiParam(value = "巡检点id", required = true) @RequestParam(required = true) Long pointId) { @ApiParam(value = "巡检点id", required = true) @RequestParam Long pointId) {
try { try {
Map<String, Object> response = new HashMap<String, Object>(); Map<String, Object> response = new HashMap<String, Object>();
if (planTaskId != null && planTaskId > 0) { if (planTaskId != null && planTaskId > 0) {
......
...@@ -72,7 +72,7 @@ public interface IPlanTaskService { ...@@ -72,7 +72,7 @@ public interface IPlanTaskService {
* @param id * @param id
* @return * @return
*/ */
public Map findPlanTaskByTaskIdAndPointId(long id, long pointId); Map findPlanTaskByTaskIdAndPointId(long id, long pointId);
/** /**
* 天剑查询假话任务信息 * 天剑查询假话任务信息
......
package com.yeejoin.amos.patrol.config;
import cn.hutool.core.date.LocalDateTimeUtil;
import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.JsonDeserializer;
import com.fasterxml.jackson.databind.JsonSerializer;
import com.fasterxml.jackson.databind.SerializerProvider;
import org.springframework.boot.autoconfigure.jackson.Jackson2ObjectMapperBuilderCustomizer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import java.io.IOException;
import java.time.LocalDateTime;
import java.time.ZoneOffset;
/**
* @author DELL
*/
@Configuration
public class JacksonCustomizerConfig {
/**
* description:适配自定义序列化和反序列化策略,返回前端指定数据类型的数据
*/
@Bean
public Jackson2ObjectMapperBuilderCustomizer jackson2ObjectMapperBuilderCustomizer() {
return builder -> {
builder.serializerByType(LocalDateTime.class, new LocalDateTimeSerializer());
builder.deserializerByType(LocalDateTime.class, new LocalDateTimeDeserializer());
};
}
/**
* description:序列化
* LocalDateTime序列化为毫秒级时间戳
*/
public static class LocalDateTimeSerializer extends JsonSerializer<LocalDateTime> {
@Override
public void serialize(LocalDateTime value, JsonGenerator gen, SerializerProvider serializers)
throws IOException {
if (value != null) {
long timestamp = LocalDateTimeUtil.toEpochMilli(value);
gen.writeNumber(timestamp);
}
}
}
/**
* description:反序列化
* 毫秒级时间戳序列化为LocalDateTime
*/
public static class LocalDateTimeDeserializer extends JsonDeserializer<LocalDateTime> {
@Override
public LocalDateTime deserialize(JsonParser p, DeserializationContext deserializationContext)
throws IOException {
long timestamp = p.getValueAsLong();
if (timestamp > 0) {
return LocalDateTimeUtil.of(timestamp, ZoneOffset.of("+8"));
} else {
return null;
}
}
}
}
...@@ -162,6 +162,9 @@ ...@@ -162,6 +162,9 @@
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-1"> <changeSet author="litengwei" id="2021-09-01-litengwei-1">
<preConditions onFail="MARK_RAN">
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>add data cb_data_dictionary</comment> <comment>add data cb_data_dictionary</comment>
<sql> <sql>
INSERT INTO `cb_data_dictionary` VALUES(1152, '1152', '大面积航班延误保障', 'QTZL', NULL, NULL, NULL, NULL, NULL, 0, 1); INSERT INTO `cb_data_dictionary` VALUES(1152, '1152', '大面积航班延误保障', 'QTZL', NULL, NULL, NULL, NULL, NULL, 0, 1);
...@@ -182,6 +185,9 @@ ...@@ -182,6 +185,9 @@
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-2"> <changeSet author="litengwei" id="2021-09-01-litengwei-2">
<preConditions onFail="MARK_RAN">
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>add data jc_alert_form</comment> <comment>add data jc_alert_form</comment>
<sql> <sql>
INSERT INTO `jc_alert_form` VALUES(127, '230', 'HKQJYZL', '航空器救援子类', 'aircraftRescueSub', 'radio', NULL, NULL, NULL, 0, 1, 1, NULL); INSERT INTO `jc_alert_form` VALUES(127, '230', 'HKQJYZL', '航空器救援子类', 'aircraftRescueSub', 'radio', NULL, NULL, NULL, 0, 1, 1, NULL);
...@@ -191,6 +197,9 @@ ...@@ -191,6 +197,9 @@
</sql> </sql>
</changeSet> </changeSet>
<changeSet author="litengwei" id="2021-09-01-litengwei-3"> <changeSet author="litengwei" id="2021-09-01-litengwei-3">
<preConditions onFail="MARK_RAN">
<primaryKeyExists primaryKeyName="sequence_nbr" tableName="cb_data_dictionary"/>
</preConditions>
<comment>update data jc_alert_form</comment> <comment>update data jc_alert_form</comment>
<sql> <sql>
UPDATE `jc_alert_form` SET alert_type_code='230', field_value_code=NULL, field_name='航班号', field_code='flightNumber', field_type='selectDelay', rec_user_name=NULL, rec_user_id=NULL, rec_date=NULL, is_delete=0, block=0, sort_num=2, url='aircraft/getAircraftNum' WHERE sequence_nbr=103; UPDATE `jc_alert_form` SET alert_type_code='230', field_value_code=NULL, field_name='航班号', field_code='flightNumber', field_type='selectDelay', rec_user_name=NULL, rec_user_id=NULL, rec_date=NULL, is_delete=0, block=0, sort_num=2, url='aircraft/getAircraftNum' WHERE sequence_nbr=103;
......
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