|
@@ -1,25 +1,27 @@
|
|
package com.om.service.impl;
|
|
package com.om.service.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
|
+import cn.hutool.json.JSONUtil;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
-import com.om.entity.dto.AppDTO;
|
|
|
|
-import com.om.entity.dto.GuidDTO;
|
|
|
|
|
|
+import com.om.entity.dto.*;
|
|
import com.om.entity.po.Apps;
|
|
import com.om.entity.po.Apps;
|
|
import com.om.entity.po.AppsClients;
|
|
import com.om.entity.po.AppsClients;
|
|
import com.om.entity.po.AppsDesc;
|
|
import com.om.entity.po.AppsDesc;
|
|
|
|
+import com.om.entity.po.Client;
|
|
import com.om.entity.vo.AppUpdateVO;
|
|
import com.om.entity.vo.AppUpdateVO;
|
|
|
|
+import com.om.exception.BadReqException;
|
|
|
|
+import com.om.exception.BizException;
|
|
import com.om.mapper.AppsMapper;
|
|
import com.om.mapper.AppsMapper;
|
|
import com.om.service.IAppsClientsService;
|
|
import com.om.service.IAppsClientsService;
|
|
import com.om.service.IAppsDescService;
|
|
import com.om.service.IAppsDescService;
|
|
import com.om.service.IAppsService;
|
|
import com.om.service.IAppsService;
|
|
-import com.om.utils.AesUtil;
|
|
|
|
-import com.om.utils.HuaweiObsUtil;
|
|
|
|
-import com.om.utils.Result;
|
|
|
|
-import com.om.utils.VersionComparator;
|
|
|
|
|
|
+import com.om.service.IClientService;
|
|
|
|
+import com.om.utils.*;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Comparator;
|
|
import java.util.Comparator;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Optional;
|
|
import java.util.Optional;
|
|
@@ -51,6 +53,11 @@ public class AppsServiceImpl extends ServiceImpl<AppsMapper, Apps> implements IA
|
|
@Resource
|
|
@Resource
|
|
private HuaweiObsUtil obsUtil;
|
|
private HuaweiObsUtil obsUtil;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private IClientService clientService;
|
|
|
|
+ @Resource
|
|
|
|
+ private PushUtil pushUtil;
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public Page<Apps> findApps(Page<Apps> objectPage, String code, String title) {
|
|
public Page<Apps> findApps(Page<Apps> objectPage, String code, String title) {
|
|
return appsMapper.findApps(objectPage, code, title);
|
|
return appsMapper.findApps(objectPage, code, title);
|
|
@@ -77,7 +84,7 @@ public class AppsServiceImpl extends ServiceImpl<AppsMapper, Apps> implements IA
|
|
|
|
|
|
int result = VersionComparator.compareVersions(version, apps1.getVersion());
|
|
int result = VersionComparator.compareVersions(version, apps1.getVersion());
|
|
if (result >= 0 ){
|
|
if (result >= 0 ){
|
|
- return Result.error().message("没有APP更新").result(24001);
|
|
|
|
|
|
+ return Result.ok().message("没有APP更新").result(24001);
|
|
}
|
|
}
|
|
vo.setFileName(apps1.getFileName());
|
|
vo.setFileName(apps1.getFileName());
|
|
vo.setFileSize((long) (Double.valueOf(apps1.getFileSize()) * 1024 * 1024));
|
|
vo.setFileSize((long) (Double.valueOf(apps1.getFileSize()) * 1024 * 1024));
|
|
@@ -95,8 +102,70 @@ public class AppsServiceImpl extends ServiceImpl<AppsMapper, Apps> implements IA
|
|
vo.setUrl(uploadUrl);
|
|
vo.setUrl(uploadUrl);
|
|
vo.setIsUpdate("1");
|
|
vo.setIsUpdate("1");
|
|
}
|
|
}
|
|
|
|
+ return Result.ok(vo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return Result.ok().message("没有APP更新").result(24001);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public Result push(Integer id) {
|
|
|
|
+ //根据id查询
|
|
|
|
+ Apps apps = this.getById(id);
|
|
|
|
+ if (BeanUtil.isEmpty(apps)) {
|
|
|
|
+ throw new BadReqException("该应用软件不存在");
|
|
|
|
+ }
|
|
|
|
+ PushInfo pushInfo = new PushInfo();
|
|
|
|
+ pushInfo.setPushInfoType(1);
|
|
|
|
+
|
|
|
|
+ AppInfo appInfo = new AppInfo();
|
|
|
|
+ appInfo.setFileName(apps.getFileName());
|
|
|
|
+ appInfo.setVersion(apps.getVersion());
|
|
|
|
+ appInfo.setFileSize((long) (Double.valueOf(apps.getFileName())*1024*1024));
|
|
|
|
+ appInfo.setUrl(apps.getSavePath());
|
|
|
|
+
|
|
|
|
+ List<Describe> describeList = new ArrayList<>();
|
|
|
|
+
|
|
|
|
+ List<AppsDesc> appsDescList = appsDescService.lambdaQuery()
|
|
|
|
+ .eq(AppsDesc::getAppId, id)
|
|
|
|
+ .list();
|
|
|
|
+ if (!appsDescList.isEmpty()){
|
|
|
|
+ for (AppsDesc appsDesc : appsDescList) {
|
|
|
|
+ Describe describe = new Describe();
|
|
|
|
+ describe.setLanguage(appsDesc.getLanguage());
|
|
|
|
+ describe.setDescription(appsDesc.getDescription());
|
|
|
|
+ describeList.add(describe);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ appInfo.setDescribeList(describeList);
|
|
|
|
+
|
|
|
|
+ List<AppsClients> appsClientsList = appsClientsService.lambdaQuery()
|
|
|
|
+ .eq(AppsClients::getAppId, id)
|
|
|
|
+ .list();
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (!appsClientsList.isEmpty()) {
|
|
|
|
+ List<String> clientNums = appsClientsList.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(JSONUtil.parseObj(appInfo));
|
|
|
|
+ try {
|
|
|
|
+ pushUtil.sendAndroidListcastJSON(tokens,pushInfo);
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new BizException("推送失败!!!");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
- return Result.ok(vo);
|
|
|
|
|
|
+ return Result.ok();
|
|
}
|
|
}
|
|
}
|
|
}
|