Commit 29ff6d88 authored by 赵啸非's avatar 赵啸非

修正redis 最大连接数

parent c9ef8c1c
......@@ -14,8 +14,8 @@ public final class RedisCacheKeys {
return "params:file:upload";
}
public static String getCoopsDistributedLockKey() {
return "coops:distributed:lock";
public static String getDeviceStatLockKey() {
return "device:stat:lock";
}
}
......@@ -43,7 +43,7 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
@Override
public void excuteTask(ITask task) throws AppException {
log.info("设备统计任务,生成当天统计数据");
log.info("设备统计任务,生成当天统计数据开始");
if (platFormType.equalsIgnoreCase(PlatformTypeEnum.CLOUD.getValue())) {
//统计所有站点
SitePdu sitePdu = new SitePdu();
......@@ -57,10 +57,10 @@ public class DeviceTotalStatTaskImpl implements ITaskExcuteService {
//判断如果当前节点无设备 则不统计
deviceStatService.deviceStat(siteEntity.getId(), null);
}
}
log.info("设备统计任务,生成当天统计数据结束");
}
......
......@@ -296,7 +296,7 @@ public class DeviceController extends BaseCRUDJsonBodyMappingController<DeviceSe
model.put("totalCount", deviceEntityList.size());
model.put("onlineCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.在线.getValue()).count());
model.put("offlineCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.离线.getValue()).count());
model.put("stopCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() != DeviceStatusEnum.未激活.getValue() && f.getEnabled() == YesNoEnum.NO.getValue()).count());
model.put("stopCount", deviceEntityList.stream().filter(f -> f.getEnabled() == YesNoEnum.NO.getValue()).count());
model.put("unActiveCount", deviceEntityList.stream().filter(f -> f.getDeviceStatus() == DeviceStatusEnum.未激活.getValue()).count());
}
}
......
......@@ -4,9 +4,11 @@ import cn.hutool.core.date.DateUtil;
import com.mortals.framework.common.Rest;
import com.mortals.framework.exception.AppException;
import com.mortals.framework.model.Context;
import com.mortals.framework.service.ICacheService;
import com.mortals.framework.util.DateUtils;
import com.mortals.framework.web.BaseCRUDJsonBodyMappingController;
import com.mortals.xhx.common.code.DaySelectEnum;
import com.mortals.xhx.common.keys.RedisCacheKeys;
import com.mortals.xhx.module.device.model.DeviceQuery;
import com.mortals.xhx.module.device.model.DeviceStatEntity;
import com.mortals.xhx.module.device.model.DeviceStatQuery;
......@@ -35,6 +37,8 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
@Autowired
private DeviceService deviceService;
@Autowired
private ICacheService cacheService;
public DeviceStatController() {
......@@ -84,6 +88,11 @@ public class DeviceStatController extends BaseCRUDJsonBodyMappingController<Devi
try {
if (ObjectUtils.isEmpty(deviceQuery) || ObjectUtils.isEmpty(deviceQuery.getSiteId()))
throw new AppException("请求站点Id不能为空!");
boolean bool = cacheService.setnx(RedisCacheKeys.getDeviceStatLockKey() + deviceQuery.getSiteId(), deviceQuery.getSiteId(), 300L);
if (!bool) {
throw new AppException("同步统计设备中,请稍后再统计!");
}
//刷新成功,返回列
this.service.deviceStat(deviceQuery.getSiteId(),getContext());
DeviceStatQuery deviceStatQuery = new DeviceStatQuery();
......
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