Commit baaf0445 authored by 赵啸非's avatar 赵啸非

修改部分一键部署功能

parent c52ebdc3
......@@ -36,7 +36,7 @@ public class RedisKey {
/**
* 缓存过期时间(秒)
*/
public static final Long KEY_SEARCH_TIMEOUTT_CACHE = 3600L;
public static final Long KEY_SEARCH_TIMEOUTT_CACHE = 1800L;
/**
......
package com.mortals.xhx.module.window.service.impl;
import cn.hutool.core.collection.ListUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.alibaba.fastjson.serializer.SerializerFeature;
......@@ -165,25 +166,28 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
*/
@Override
protected void removeBefore(Long[] ids, Context context) throws AppException {
/* Arrays.asList(ids).forEach(id -> {
Arrays.asList(ids).forEach(id -> {
WindowBusinessEntity windowBusinessEntity = this.get(id, context);
pushChangeMsg(windowBusinessEntity);
});*/
//更新站点业务缓存 SiteBusinessId
updateWindowBusinessCacheResult(windowBusinessEntity, context);
// pushChangeMsg(windowBusinessEntity);
});
super.removeBefore(ids, context);
}
/* *//**
/**
* @param entity
* @param context
* @throws AppException
*//*
*/
@Override
protected void saveAfter(WindowBusinessEntity entity, Context context) throws AppException {
//通知php更新
pushChangeMsg(entity);
//更新站点业务缓存 SiteBusinessId
updateWindowBusinessCacheResult(entity, context);
super.saveAfter(entity, context);
}*/
}
/* */
......@@ -192,12 +196,76 @@ public class WindowBusinessServiceImpl extends AbstractCRUDServiceImpl<WindowBus
* @param entity
* @param context
* @throws AppException
*//*
*/
@Override
protected void updateAfter(WindowBusinessEntity entity, Context context) throws AppException {
pushChangeMsg(entity);
//pushChangeMsg(entity);
//更新站点业务缓存 SiteBusinessId
updateWindowBusinessCacheResult(entity, context);
super.updateAfter(entity, context);
}*/
}
private void updateWindowBusinessCacheResult(WindowBusinessEntity entity, Context context) {
Long siteBusinessId = entity.getSiteBusinessId();
String cacheResult = cacheService.get(KEY_SEARCH_SITEBUSINESSID_CACHE + siteBusinessId, String.class);
if (!ObjectUtils.isEmpty(cacheResult)) {
//更新查询结果
//查询数据库
PageInfo pageInfo = new PageInfo();
pageInfo.setPrePageResult(-1);
Result<WindowBusinessEntity> result = this.dao.getList(new WindowBusinessQuery().siteBusinessId(siteBusinessId), pageInfo);
this.findAfter(entity, pageInfo, context, result.getList());
if (!ObjectUtils.isEmpty(result.getList())) {
cacheService.set(KEY_SEARCH_SITEBUSINESSID_CACHE + siteBusinessId, JSON.toJSONString(result), KEY_SEARCH_TIMEOUTT_CACHE);
}
}
Long windowId = entity.getWindowId();
cacheResult = cacheService.get(KEY_SEARCH_WINDOWID_CACHE + windowId, String.class);
if (!ObjectUtils.isEmpty(cacheResult)) {
//查询数据库
PageInfo pageInfo = new PageInfo();
pageInfo.setPrePageResult(-1);
Result<WindowBusinessEntity> result = this.dao.getList(new WindowBusinessQuery().siteBusinessId(siteBusinessId), pageInfo);
this.findAfter(entity, pageInfo, context, result.getList());
//无查询结果的不做保存
if (!ObjectUtils.isEmpty(result.getList())) {
cacheService.set(KEY_SEARCH_WINDOWID_CACHE + windowId, JSON.toJSONString(result), KEY_SEARCH_TIMEOUTT_CACHE);
}
}
//窗口列表更新
Set<String> scanKeys = cacheService.scan(KEY_SEARCH_WINDOWID_LIST_CACHE);
for (String scanKey : scanKeys) {
log.info("scanKey:{}", scanKey);
List<String> split = StrUtil.split(scanKey, "#");
List<Long> windowIdlist = split.stream().map(m -> Long.parseLong(m)).collect(Collectors.toList());
if (windowIdlist.contains(windowId)) {
//更新窗口列表缓存
WindowBusinessQuery windowBusinessQuery = new WindowBusinessQuery();
windowBusinessQuery.setWindowIdList(windowIdlist);
//查询数据库
PageInfo pageInfo = new PageInfo();
pageInfo.setPrePageResult(-1);
Result<WindowBusinessEntity> result = this.dao.getList(windowBusinessQuery, pageInfo);
this.findAfter(entity, pageInfo, context, result.getList());
if (!ObjectUtils.isEmpty(result.getList())) {
String windowIdlistStr = windowIdlist.stream().map(String::valueOf).collect(Collectors.joining("#"));
cacheService.set(KEY_SEARCH_WINDOWID_LIST_CACHE + windowIdlistStr, JSON.toJSONString(result), KEY_SEARCH_TIMEOUTT_CACHE);
}
}
}
}
private void pushChangeMsg(WindowBusinessEntity entity) {
String phpUrl = GlobalSysInfo.getParamValue(PARAM_SERVER_PHP_HTTP_URL, "http://127.0.0.1:11078/zwfw_api");
phpUrl += "/api/window/winNameChange";
......
......@@ -17,7 +17,7 @@ Content-Type: application/json
POST {{baseUrl}}/window/business/interlist
Content-Type: application/json
{"siteBusinessId":212,"searchCache": 1}
{"siteBusinessId":43,"searchCache": 1}
###窗口业务列表缓存2
POST {{baseUrl}}/window/business/interlist
......
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