redis调用优化

This commit is contained in:
季圣华
2021-05-31 23:38:51 +08:00
parent 416157d020
commit 84682eef9f
6 changed files with 20 additions and 10 deletions

View File

@@ -325,7 +325,7 @@ public class DepotHeadController {
String beanJson = body.getInfo();
String rows = body.getRows();
Long billsNumLimit = Long.parseLong(redisService.getObjectFromSessionByKey(request,"billsNumLimit").toString());
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
Long count = depotHeadService.countDepotHead(null,null,null,null,null,null,null,null);
if(count>= billsNumLimit) {
throw new BusinessParamCheckingException(ExceptionConstants.DEPOT_HEAD_OVER_LIMIT_FAILED_CODE,
@@ -345,7 +345,7 @@ public class DepotHeadController {
*/
@PutMapping(value = "/updateDepotHeadAndDetail")
public Object updateDepotHeadAndDetail(@RequestBody DepotHeadVo4Body body, HttpServletRequest request) throws Exception{
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
JSONObject result = ExceptionConstants.standardSuccess();
String beanJson = body.getInfo();
String rows = body.getRows();

View File

@@ -120,7 +120,7 @@ public class DepotItemController {
Map<String, Object> map = new HashMap<String, Object>();
try {
BigDecimal stock = BigDecimal.ZERO;
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
List<MaterialVo4Unit> list = materialService.getMaterialByBarCode(barCode);
if(list!=null && list.size()>0) {
MaterialVo4Unit materialVo4Unit = list.get(0);
@@ -154,7 +154,7 @@ public class DepotItemController {
@RequestParam("mpList") String mpList,
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
try {
List<DepotItemVo4WithInfoEx> dataList = new ArrayList<DepotItemVo4WithInfoEx>();
if(headerId != 0) {
@@ -264,7 +264,7 @@ public class DepotItemController {
HttpServletRequest request)throws Exception {
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
String timeA = monthTime+"-01 00:00:00";
String timeB = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try {
@@ -334,7 +334,7 @@ public class DepotItemController {
@RequestParam("monthTime") String monthTime,
@RequestParam("materialParam") String materialParam,
HttpServletRequest request, HttpServletResponse response) throws Exception {
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
String timeA = monthTime+"-01 00:00:00";
String timeB = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try {
@@ -384,7 +384,7 @@ public class DepotItemController {
HttpServletRequest request) throws Exception{
BaseResponseInfo res = new BaseResponseInfo();
Map<String, Object> map = new HashMap<String, Object>();
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
String endTime = Tools.lastDayOfMonth(monthTime)+" 23:59:59";
try {
List<DepotItemVo4WithInfoEx> dataList = depotItemService.findByAll(StringUtil.toNull(materialParam),

View File

@@ -166,7 +166,7 @@ public class MaterialController {
HttpServletRequest request) throws Exception{
JSONObject object = new JSONObject();
try {
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
List<MaterialVo4Unit> dataList = materialService.findBySelectWithBarCode(categoryId, q, (currentPage-1)*pageSize, pageSize);
String[] mpArr = mpList.split(",");
int total = materialService.findBySelectWithBarCodeCount(categoryId, q);

View File

@@ -144,7 +144,9 @@ public class UserController {
data.put("token", token);
data.put("user", user);
//用户的按钮权限
if(!"admin".equals(user.getLoginName())){
data.put("userBtn", btnStrArr);
}
data.put("roleType", roleType);
}
res.code = 200;

View File

@@ -252,7 +252,7 @@ public class DepotHeadService {
//更新当前库存
List<DepotItem> list = depotItemService.getListByHeaderId(id);
for(DepotItem depotItem: list){
Long tenantId = Long.parseLong(redisService.getObjectFromSessionByKey(request,"tenantId").toString());
Long tenantId = redisService.getTenantId(request);
depotItemService.updateCurrentStock(depotItem,tenantId);
}
}catch(Exception e){

View File

@@ -95,4 +95,12 @@ public class RedisService {
}
}
}
public Long getTenantId(HttpServletRequest request) {
if(getObjectFromSessionByKey(request,"tenantId")!=null) {
return Long.parseLong(getObjectFromSessionByKey(request, "tenantId").toString());
} else {
return null;
}
}
}