|
@@ -1,17 +1,21 @@
|
|
|
package com.om.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
+import com.om.entity.dto.PushInfo;
|
|
|
import com.om.entity.po.*;
|
|
|
import com.om.entity.vo.AppVO;
|
|
|
import com.om.entity.vo.DignosisPageVO;
|
|
|
import com.om.entity.vo.PcbInfoVO;
|
|
|
+import com.om.exception.BadReqException;
|
|
|
import com.om.mapper.AppMapper;
|
|
|
import com.om.mapper.ClientMapper;
|
|
|
import com.om.service.*;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.om.utils.CommonUtil;
|
|
|
+import com.om.utils.PushUtil;
|
|
|
import com.om.utils.Result;
|
|
|
import com.om.utils.UserContext;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
@@ -46,6 +50,9 @@ public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements IAppS
|
|
|
@Resource
|
|
|
private ClientMapper clientMapper;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PushUtil pushUtil;
|
|
|
+
|
|
|
@Override
|
|
|
public Result add(AppVO appVO) {
|
|
|
App app = new App();
|
|
@@ -200,4 +207,33 @@ public class AppServiceImpl extends ServiceImpl<AppMapper, App> implements IAppS
|
|
|
|
|
|
return Result.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result pushVCI(Integer id) {
|
|
|
+
|
|
|
+ App byId = this.getById(id);
|
|
|
+ if(BeanUtil.isEmpty(byId)){
|
|
|
+ throw new BadReqException("该app版本不存在");
|
|
|
+ }
|
|
|
+ PushInfo pushInfo = new PushInfo();
|
|
|
+ pushInfo.setPushInfoType(3);
|
|
|
+ pushInfo.setJson(JSONUtil.createObj().append("message","有VCI固件更新"));
|
|
|
+
|
|
|
+ String clientNums = byId.getClientNums();
|
|
|
+ String[] clientNumList = clientNums.substring(1, clientNums.length() - 1).split(",");
|
|
|
+ String[] tokens = new String[clientNumList.length];
|
|
|
+ for (int i = 0; i < clientNumList.length; i++) {
|
|
|
+ LambdaQueryWrapper<Client> clientLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
+ clientLambdaQueryWrapper.eq(Client::getNumber,clientNumList[i]);
|
|
|
+ Client client = clientMapper.selectOne(clientLambdaQueryWrapper);
|
|
|
+ tokens[i] = client.getDeviceToken();
|
|
|
+ }
|
|
|
+
|
|
|
+ try {
|
|
|
+ pushUtil.sendAndroidListcastJSON(tokens,pushInfo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BadReqException("推送失败!");
|
|
|
+ }
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
}
|