|
|
@@ -60,6 +60,8 @@ import org.flowable.task.api.TaskQuery;
|
|
|
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.cache.annotation.CachePut;
|
|
|
+import org.springframework.cache.annotation.Cacheable;
|
|
|
import org.springframework.context.event.EventListener;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -292,9 +294,12 @@ public class SmsbItemPushServiceImpl implements ISmsbItemPushService {
|
|
|
private void pushNettyMsg(List<String> deviceIds, Long pushId) {
|
|
|
List<SmsbDevice> smsbDevices = smsbDeviceMapper.selectByIds(deviceIds);
|
|
|
for (SmsbDevice smsbDevice : smsbDevices) {
|
|
|
+ // 1 发送长连接消息
|
|
|
String nettyMessage = PushMessageType.CONTENT_UPDATE.getValue() + "/" + pushId;
|
|
|
boolean pushResult = PushMsgUtil.sendV2(smsbDevice.getIdentifier(), nettyMessage);
|
|
|
log.info("push content update identifier: {}, result:{}", smsbDevice.getIdentifier(), pushResult);
|
|
|
+ // 2 redis 缓存预加载
|
|
|
+ cachePushInfo(smsbDevice.getIdentifier());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -407,20 +412,31 @@ public class SmsbItemPushServiceImpl implements ISmsbItemPushService {
|
|
|
|
|
|
@Override
|
|
|
public R<FrontPushInfoVo> getItemPushInfo(String identifier) {
|
|
|
- FrontPushInfoVo result = new FrontPushInfoVo();
|
|
|
if (StringUtils.isEmpty(identifier)) {
|
|
|
return R.fail(HttpApiResult.PARAM_IS_NULL.getCode(), HttpApiResult.PARAM_IS_NULL.getInfo());
|
|
|
}
|
|
|
+ FrontPushInfoVo result = getItemPushInfoByCache(identifier);
|
|
|
+ return R.ok(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Cacheable(cacheNames = "global:msr:device:identifier", key = "#identifier")
|
|
|
+ public FrontPushInfoVo getItemPushInfoByCache(String identifier) {
|
|
|
+ return generatePushInfo(identifier);
|
|
|
+ }
|
|
|
+
|
|
|
+ @CachePut(cacheNames = "global:msr:device:identifier", key = "#identifier")
|
|
|
+ public FrontPushInfoVo cachePushInfo(String identifier) {
|
|
|
+ return generatePushInfo(identifier);
|
|
|
+ }
|
|
|
+
|
|
|
+ public FrontPushInfoVo generatePushInfo(String identifier) {
|
|
|
+ FrontPushInfoVo result = new FrontPushInfoVo();
|
|
|
SmsbDeviceVo deviceVo = smsbDeviceService.getDeviceByIdentifier(identifier);
|
|
|
- if (deviceVo == null) {
|
|
|
- return R.fail(HttpApiResult.DEVICE_NOT_EXIST.getCode(), HttpApiResult.DEVICE_NOT_EXIST.getInfo());
|
|
|
- }
|
|
|
// 根据设备ID查询当前设备最新的内容下发
|
|
|
Long deviceId = deviceVo.getId();
|
|
|
result.setDeviceId(deviceId);
|
|
|
result.setWidth(deviceVo.getWidth());
|
|
|
result.setHeight(deviceVo.getHeight());
|
|
|
-
|
|
|
// 查询不同等级的节目发布 100垫片 200常规 300紧急
|
|
|
List<SmsbItemPushVo> smsbItemPushVoLevel1 = baseMapper.selectFrontOnePushByDeviceId(deviceId, 100);
|
|
|
buildPushItemInfo(result, smsbItemPushVoLevel1);
|
|
|
@@ -428,8 +444,7 @@ public class SmsbItemPushServiceImpl implements ISmsbItemPushService {
|
|
|
buildPushItemInfo(result, smsbItemPushVoLevel2);
|
|
|
List<SmsbItemPushVo> smsbItemPushVoLevel3 = baseMapper.selectFrontOnePushByDeviceId(deviceId, 300);
|
|
|
buildPushItemInfo(result, smsbItemPushVoLevel3);
|
|
|
-
|
|
|
- return R.ok(result);
|
|
|
+ return result;
|
|
|
}
|
|
|
|
|
|
private void buildPushItemInfo(FrontPushInfoVo result, List<SmsbItemPushVo> smsbItemPushVoList) {
|