|
@@ -1,11 +1,9 @@
|
|
|
package com.om.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
-import com.om.entity.dto.AppBrushFileDTO;
|
|
|
-import com.om.entity.dto.BlushQueryPageDTO;
|
|
|
-import com.om.entity.dto.BrushAddDTO;
|
|
|
-import com.om.entity.dto.GuidDTO;
|
|
|
+import com.om.entity.dto.*;
|
|
|
import com.om.entity.po.*;
|
|
|
import com.om.entity.vo.*;
|
|
|
import com.om.exception.BadReqException;
|
|
@@ -62,6 +60,9 @@ public class BrushFileServiceImpl extends ServiceImpl<BrushFileMapper, BrushFile
|
|
|
@Resource
|
|
|
private IBrandService brandService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private PushUtil pushUtil;
|
|
|
+
|
|
|
@Override
|
|
|
public Result getBrushFileList(AppBrushFileDTO dto) {
|
|
|
if (BeanUtil.isEmpty(dto)){
|
|
@@ -277,4 +278,63 @@ public class BrushFileServiceImpl extends ServiceImpl<BrushFileMapper, BrushFile
|
|
|
brushClientService.saveBatch(clients);
|
|
|
return Result.ok();
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public Result pushBrush(Integer id) {
|
|
|
+ BrushFile brushFile = this.getById(id);
|
|
|
+ if (BeanUtil.isEmpty(brushFile)) {
|
|
|
+ throw new BadReqException("该ECU刷写文件不存在");
|
|
|
+ }
|
|
|
+
|
|
|
+ PushInfo pushInfo = new PushInfo();
|
|
|
+ pushInfo.setPushInfoType(5);
|
|
|
+
|
|
|
+ BrushInfo brushInfo = new BrushInfo();
|
|
|
+ brushInfo.setBrushFileName(brushFile.getBrushFileName());
|
|
|
+ brushInfo.setCreateTime(brushFile.getCreateTime().toInstant(ZoneOffset.of("+8")).toEpochMilli());
|
|
|
+ brushInfo.setUrl(brushFile.getUrl());
|
|
|
+ brushInfo.setFileSize((long) (Double.valueOf(brushFile.getFileSize())*1024*1024));
|
|
|
+
|
|
|
+ List<BrushDescription> brushDescriptions = brushDescriptionService.lambdaQuery()
|
|
|
+ .eq(BrushDescription::getBrushId, brushFile.getId())
|
|
|
+ .list();
|
|
|
+ List<Describe> describeList = new ArrayList<>();
|
|
|
+ if (CollectionUtil.isNotEmpty(brushDescriptions)){
|
|
|
+ for (BrushDescription brushDescription : brushDescriptions) {
|
|
|
+ Describe describe = new Describe();
|
|
|
+ describe.setDescription(brushDescription.getDescription());
|
|
|
+ describe.setLanguage(brushDescription.getLanguage());
|
|
|
+ describeList.add(describe);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ brushInfo.setDescribeList(describeList);
|
|
|
+
|
|
|
+
|
|
|
+ List<BrushClient> brushClientList = brushClientService.lambdaQuery()
|
|
|
+ .eq(BrushClient::getBrushId, brushFile.getId())
|
|
|
+ .list();
|
|
|
+
|
|
|
+ if (CollectionUtil.isNotEmpty(brushClientList)) {
|
|
|
+ List<String> clientNums = brushClientList.stream().map(c -> c.getClientNum()).collect(Collectors.toList());
|
|
|
+ String[] tokens = new String[clientNums.size()];
|
|
|
+ for (String clientNum : clientNums) {
|
|
|
+ int i = 0;
|
|
|
+ Client client = clientService.lambdaQuery()
|
|
|
+ .eq(Client::getNumber, clientNum)
|
|
|
+ .one();
|
|
|
+ if (BeanUtil.isNotEmpty(client)) {
|
|
|
+ tokens[i] = client.getDeviceToken();
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //调用工具类
|
|
|
+ pushInfo.setJson(GsonUtils.toJsonString(brushInfo));
|
|
|
+ try {
|
|
|
+ pushUtil.sendAndroidListcastJSON(tokens,pushInfo);
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw new BizException("推送失败!!!");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Result.ok();
|
|
|
+ }
|
|
|
}
|