|
|
@@ -3,29 +3,23 @@ package com.inspur.source.service.impl;
|
|
|
import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
-import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.inspur.device.domain.constants.ResultCodeEnum;
|
|
|
import com.inspur.device.domain.vo.SmsbDeviceVo;
|
|
|
import com.inspur.device.service.ISmsbDeviceService;
|
|
|
import com.inspur.netty.message.push.PushMessageType;
|
|
|
import com.inspur.netty.util.PushMsgUtil;
|
|
|
-import com.inspur.source.domain.SmsbItemPushDevice;
|
|
|
+import com.inspur.source.domain.SmsbItemPush;
|
|
|
+import com.inspur.source.domain.SmsbItemPushPlaylist;
|
|
|
import com.inspur.source.domain.bo.SmsbItemPushDeviceBo;
|
|
|
import com.inspur.source.domain.bo.SmsbItemPushPlaylistBo;
|
|
|
-import com.inspur.source.domain.vo.SmsbItemPushDeviceVo;
|
|
|
import com.inspur.source.domain.vo.SmsbItemPushPlaylistVo;
|
|
|
-import com.inspur.source.mapper.SmsbItemPushDeviceMapper;
|
|
|
+import com.inspur.source.mapper.SmsbItemPushMapper;
|
|
|
+import com.inspur.source.mapper.SmsbItemPushPlaylineMapper;
|
|
|
import com.inspur.source.mapper.SmsbItemPushPlaylistMapper;
|
|
|
import com.inspur.source.service.ISmsbItemPushDeviceService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.dromara.common.core.domain.R;
|
|
|
-import org.dromara.common.core.utils.DateUtils;
|
|
|
-import org.dromara.common.core.utils.MapstructUtils;
|
|
|
-import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
-import org.dromara.common.mybatis.core.page.TableDataInfo;
|
|
|
-import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
@@ -44,6 +38,12 @@ public class SmsbItemPushDeviceServiceImpl implements ISmsbItemPushDeviceService
|
|
|
|
|
|
private final SmsbItemPushPlaylistMapper smsbItemPushPlaylistMapper;
|
|
|
|
|
|
+ private final ISmsbDeviceService smsbDeviceService;
|
|
|
+
|
|
|
+ private final SmsbItemPushMapper smsbItemPushMapper;
|
|
|
+
|
|
|
+ private final SmsbItemPushPlaylineMapper smsbItemPushPlaylineMapper;
|
|
|
+
|
|
|
/**
|
|
|
* 查询内容发布设备
|
|
|
*
|
|
|
@@ -145,8 +145,6 @@ public class SmsbItemPushDeviceServiceImpl implements ISmsbItemPushDeviceService
|
|
|
/**
|
|
|
* 校验并批量删除内容发布设备信息
|
|
|
*
|
|
|
- * @param ids 待删除的主键集合
|
|
|
- * @param isValid 是否进行有效性校验
|
|
|
* @return 是否删除成功
|
|
|
*/
|
|
|
/*@Override
|
|
|
@@ -157,32 +155,49 @@ public class SmsbItemPushDeviceServiceImpl implements ISmsbItemPushDeviceService
|
|
|
return baseMapper.deleteByIds(ids) > 0;
|
|
|
}*/
|
|
|
|
|
|
- /*@Override
|
|
|
+ @Override
|
|
|
public R<Void> pushRemoveDevice(SmsbItemPushDeviceBo bo) {
|
|
|
if (CollectionUtil.isEmpty(bo.getDeviceIds())) {
|
|
|
return R.fail(Integer.parseInt(ResultCodeEnum.DEVICE_IDS_IS_NULL.getValue()), ResultCodeEnum.DEVICE_IDS_IS_NULL.getMessage());
|
|
|
}
|
|
|
Integer pushState = 4;
|
|
|
+ Long pushId = bo.getPushId();
|
|
|
+ // 1 更新播单设备状态为 4
|
|
|
for (Long deviceId : bo.getDeviceIds()) {
|
|
|
- baseMapper.update(new LambdaUpdateWrapper<SmsbItemPushDevice>()
|
|
|
- .set(SmsbItemPushDevice::getPushState, pushState)
|
|
|
- .set(SmsbItemPushDevice::getUpdateTime, DateUtils.getNowDate())
|
|
|
- .eq(SmsbItemPushDevice::getDeviceId, deviceId)
|
|
|
- .eq(SmsbItemPushDevice::getPushId, bo.getPushId()));
|
|
|
- // 发送长连接消息给设备
|
|
|
- pushRemoveMessage(deviceId, bo.getPushId());
|
|
|
+ smsbItemPushPlaylistMapper.update(new LambdaUpdateWrapper<SmsbItemPushPlaylist>()
|
|
|
+ .set(SmsbItemPushPlaylist::getPushState, pushState)
|
|
|
+ .eq(SmsbItemPushPlaylist::getDeviceId, deviceId)
|
|
|
+ .eq(SmsbItemPushPlaylist::getPushId, bo.getPushId()));
|
|
|
+ }
|
|
|
+ // 2 查询全部设备是否已下架
|
|
|
+ List<SmsbItemPushPlaylistVo> isUsePlaylist = smsbItemPushPlaylistMapper.selectVoList(new LambdaQueryWrapper<SmsbItemPushPlaylist>()
|
|
|
+ .eq(SmsbItemPushPlaylist::getPushId, pushId)
|
|
|
+ .ne(SmsbItemPushPlaylist::getPushState,4));
|
|
|
+ if (CollectionUtil.isEmpty(isUsePlaylist)) {
|
|
|
+ // 3 更新播单状态为 0
|
|
|
+ SmsbItemPush pushUpdate = new SmsbItemPush();
|
|
|
+ pushUpdate.setId(pushId);
|
|
|
+ pushUpdate.setIsUse(0);
|
|
|
+ smsbItemPushMapper.updateById(pushUpdate);
|
|
|
}
|
|
|
+ // 4 时序更新
|
|
|
+ smsbItemPushPlaylineMapper.deleteByPushIdAndDeviceIds(pushId,bo.getDeviceIds());
|
|
|
+
|
|
|
+ // 5 发送长连接消息给设备
|
|
|
+ pushRemoveMessage(bo.getDeviceIds(), bo.getPushId());
|
|
|
return R.ok();
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
- /*private void pushRemoveMessage(Long deviceId, Long pushId) {
|
|
|
- SmsbDeviceVo deviceVo = smsbDeviceService.getDeviceCacheById(deviceId);
|
|
|
- if (null == deviceVo) {
|
|
|
- return;
|
|
|
+ private void pushRemoveMessage(List<Long> deviceIds, Long pushId) {
|
|
|
+ for (Long deviceId : deviceIds) {
|
|
|
+ SmsbDeviceVo deviceVo = smsbDeviceService.getDeviceCacheById(deviceId);
|
|
|
+ if (null == deviceVo) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ String identifier = deviceVo.getIdentifier();
|
|
|
+ String nettyMessage = PushMessageType.CONTENT_REMOVE.getValue() + "/" + pushId;
|
|
|
+ boolean pushResult = PushMsgUtil.sendV2(identifier, nettyMessage);
|
|
|
+ log.info("push content remove identifier: {}, result:{}", identifier, pushResult);
|
|
|
}
|
|
|
- String identifier = deviceVo.getIdentifier();
|
|
|
- String nettyMessage = PushMessageType.CONTENT_REMOVE.getValue() + "/" + pushId;
|
|
|
- boolean pushResult = PushMsgUtil.sendV2(identifier, nettyMessage);
|
|
|
- log.info("push content remove identifier: {}, result:{}", identifier, pushResult);
|
|
|
- }*/
|
|
|
+ }
|
|
|
}
|