|
@@ -3,7 +3,10 @@ package com.szwl.controller;
|
|
|
|
|
|
import cn.hutool.http.HttpRequest;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
+import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.szwl.constant.ResponseCodesEnum;
|
|
|
import com.szwl.model.bo.R;
|
|
|
import com.szwl.model.bo.ResponseModel;
|
|
@@ -15,7 +18,9 @@ import com.szwl.service.TEquipmentService;
|
|
|
import com.szwl.service.THotUpdateService;
|
|
|
import com.szwl.util.IDGenerator;
|
|
|
import io.swagger.annotations.ApiOperation;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.commons.math3.linear.QRDecomposition;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import java.util.*;
|
|
@@ -28,7 +33,7 @@ import java.util.stream.Stream;
|
|
|
* </p>
|
|
|
*
|
|
|
* @author wuhs
|
|
|
- * @since 2024-01-16
|
|
|
+ * @since 2024-01-24
|
|
|
*/
|
|
|
@RestController
|
|
|
@RequestMapping("/tHotUpdate")
|
|
@@ -46,41 +51,370 @@ public class THotUpdateController {
|
|
|
this.adminService = adminService;
|
|
|
}
|
|
|
|
|
|
- @ApiOperation(value = "获取补丁信息")
|
|
|
- @GetMapping("/getPatchUrl")
|
|
|
- public ResponseModel<?> getPatchUrl(String clientId, String isForeign) {
|
|
|
- if (StringUtils.isEmpty(clientId) || StringUtils.isEmpty(isForeign)) {
|
|
|
- return R.fail(ResponseCodesEnum.B0001, "参数不能为空");
|
|
|
+ @ApiOperation(value = "设备热更新+1")
|
|
|
+ @PostMapping("/upPatchNum")
|
|
|
+ public ResponseModel<?> upPatchNum(String patchVersion) {
|
|
|
+// Long patchId = hotUpdateService.lambdaQuery().eq(THotUpdate::getPatchVersion, patchVersion).one().getId();
|
|
|
+// TEquipment equipment = equipmentService.lambdaQuery().eq(TEquipment::getClientId, clientId).one();
|
|
|
+// Long equipmentId = equipment.getId();
|
|
|
+// TEquipmentDesc equipmentDesc = equipmentDescService.lambdaQuery().eq(TEquipmentDesc::getEquipmentId, equipmentId).one();
|
|
|
+// equipmentDesc.setPatchId(patchId);
|
|
|
+// equipmentDescService.saveOrUpdate(equipmentDesc);
|
|
|
+
|
|
|
+// UpdateWrapper<THotUpdate> uw = new UpdateWrapper<>();
|
|
|
+// uw.eq("patch_version", patchVersion)
|
|
|
+// .setSql("have_update_num = have_update_num + 1, modify_time = NOW()");
|
|
|
+// hotUpdateService.update(uw);
|
|
|
+
|
|
|
+ THotUpdate hotUpdate = hotUpdateService.lambdaQuery().eq(THotUpdate::getPatchVersion, patchVersion).one();
|
|
|
+ hotUpdate.setModifyTime(new Date());
|
|
|
+
|
|
|
+ Integer haveUpdateNum = Optional.ofNullable(hotUpdate.getHaveUpdateNum()).orElse(0);
|
|
|
+ hotUpdate.setHaveUpdateNum(haveUpdateNum + 1);
|
|
|
+ hotUpdateService.saveOrUpdate(hotUpdate);
|
|
|
+ return R.ok();
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取所有热更新数据")
|
|
|
+ @GetMapping("/getPatchPage")
|
|
|
+ public ResponseModel<IPage<?>> getPatchPage(long current, long size) {
|
|
|
+
|
|
|
+ LambdaQueryWrapper<THotUpdate> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.orderByDesc(THotUpdate::getCreateTime);
|
|
|
+ Page<THotUpdate> page = new Page<>(current, size, true);
|
|
|
+ IPage<THotUpdate> iPage = hotUpdateService.page(page, queryWrapper);
|
|
|
+ return R.ok(iPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取热更新补丁信息列表")
|
|
|
+ @GetMapping("/getPatchList")
|
|
|
+ public ResponseModel<?> getPatchList(String ifForeign, String patchVersion) {
|
|
|
+ if (StringUtils.isNotEmpty(patchVersion)) {
|
|
|
+ // 获取特定补丁信息
|
|
|
+ THotUpdate tHotUpdate = hotUpdateService.lambdaQuery().eq(THotUpdate::getPatchVersion, patchVersion).one();
|
|
|
+ if (tHotUpdate == null) {
|
|
|
+ return R.fail(ResponseCodesEnum.A0001, "补丁版本号不存在");
|
|
|
+ }
|
|
|
+ return R.ok(tHotUpdate);
|
|
|
+ } else {
|
|
|
+ // 获取热更新补丁列表
|
|
|
+ String area;
|
|
|
+ if ("0".equals(ifForeign)) {
|
|
|
+ // 国内 targetAreas = 1
|
|
|
+ area = "1";
|
|
|
+ } else if ("1".equals(ifForeign)) {
|
|
|
+ // 海外 targetAreas = 2
|
|
|
+ area = "2";
|
|
|
+ } else {
|
|
|
+ // 直接获取所有的
|
|
|
+ area = "4";
|
|
|
+ }
|
|
|
+ List<THotUpdate> lastTen = hotUpdateService.getLastTen(area);
|
|
|
+ return R.ok(lastTen);
|
|
|
}
|
|
|
- LambdaQueryWrapper<TEquipment> wrapper = Wrappers.lambdaQuery();
|
|
|
- wrapper.eq(TEquipment::getClientId, clientId);
|
|
|
- TEquipment equipment = equipmentService.getOne(wrapper);
|
|
|
- Long adminId = equipment.getAdminId();
|
|
|
- TAdmin admin = adminService.getById(adminId);
|
|
|
- String ifForeign = admin.getIfForeign();
|
|
|
- if (!isForeign.equals(ifForeign)) {
|
|
|
- return R.fail(ResponseCodesEnum.B0001, "海外内不匹配");
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "获取补丁信息")
|
|
|
+ @GetMapping("/getPatchInfo")
|
|
|
+ public ResponseModel<?> getPatchInfo(String patchVersion) {
|
|
|
+
|
|
|
+ assert StringUtils.isNotEmpty(patchVersion) : R.fail(ResponseCodesEnum.A0001, "补丁版本号不能为空");
|
|
|
+
|
|
|
+ THotUpdate tHotUpdate = hotUpdateService.lambdaQuery().eq(THotUpdate::getPatchVersion, patchVersion).one();
|
|
|
+ return R.ok(tHotUpdate);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ @ApiOperation(value = "设备获取热更新补丁信息")
|
|
|
+ @GetMapping("/getPatchList1")
|
|
|
+ public ResponseModel<?> getPatchList1(String clientId, String ifForeign) {
|
|
|
+ List<THotUpdate> lastTen = new ArrayList<THotUpdate>();
|
|
|
+ String area;
|
|
|
+// if (StringUtils.isNotEmpty(clientId)) {
|
|
|
+// // 部分设备 targetAreas = 0
|
|
|
+// area = "0";
|
|
|
+// } else
|
|
|
+ if ("0".equals(ifForeign)) {
|
|
|
+ // 国内 targetAreas = 1
|
|
|
+ area = "1";
|
|
|
+ } else if ("1".equals(ifForeign)) {
|
|
|
+ // 海外 targetAreas = 2
|
|
|
+ area = "2";
|
|
|
+ } else {
|
|
|
+ // 直接获取所有的
|
|
|
+ area = "4";
|
|
|
}
|
|
|
- Long equipmentId = equipment.getId();
|
|
|
- LambdaQueryWrapper<TEquipmentDesc> lqw = Wrappers.lambdaQuery();
|
|
|
- lqw.eq(TEquipmentDesc::getEquipmentId, equipmentId);
|
|
|
- TEquipmentDesc equipmentDesc = equipmentDescService.getOne(lqw);
|
|
|
- Long patchId = equipmentDesc.getPatchId();
|
|
|
-
|
|
|
- LambdaQueryWrapper<THotUpdate> qw = Wrappers.lambdaQuery();
|
|
|
- qw.eq(THotUpdate::getId, patchId);
|
|
|
- THotUpdate hotUpdate = hotUpdateService.getOne(qw);
|
|
|
- return R.ok(hotUpdate);
|
|
|
+ lastTen = hotUpdateService.getLastTen(area);
|
|
|
+ return R.ok(lastTen);
|
|
|
}
|
|
|
|
|
|
+// @ApiOperation(value = "获取补丁下载链接")
|
|
|
+// @GetMapping("/getPatchUrl")
|
|
|
+// public ResponseModel<?> getPatchUrl(String clientId, String isForeign) {
|
|
|
+//
|
|
|
+// if (StringUtils.isEmpty(clientId) || StringUtils.isEmpty(isForeign)) {
|
|
|
+// return R.fail(ResponseCodesEnum.B0001, "参数不能为空");
|
|
|
+// }
|
|
|
+// LambdaQueryWrapper<TEquipment> wrapper = Wrappers.lambdaQuery();
|
|
|
+// wrapper.eq(TEquipment::getClientId, clientId);
|
|
|
+// TEquipment equipment = equipmentService.getOne(wrapper);
|
|
|
+// Long adminId = equipment.getAdminId();
|
|
|
+// TAdmin admin = adminService.getById(adminId);
|
|
|
+// String ifForeign = admin.getIfForeign();
|
|
|
+// if (!isForeign.equals(ifForeign)) {
|
|
|
+// return R.fail(ResponseCodesEnum.B0001, "海外内不匹配");
|
|
|
+// }
|
|
|
+// Long equipmentId = equipment.getId();
|
|
|
+// LambdaQueryWrapper<TEquipmentDesc> lqw = Wrappers.lambdaQuery();
|
|
|
+// lqw.eq(TEquipmentDesc::getEquipmentId, equipmentId);
|
|
|
+// TEquipmentDesc equipmentDesc = equipmentDescService.getOne(lqw);
|
|
|
+// Long patchId = equipmentDesc.getPatchId();
|
|
|
+//
|
|
|
+// LambdaQueryWrapper<THotUpdate> qw = Wrappers.lambdaQuery();
|
|
|
+// qw.eq(THotUpdate::getId, patchId);
|
|
|
+// THotUpdate hotUpdate = hotUpdateService.getOne(qw);
|
|
|
+// return R.ok(hotUpdate);
|
|
|
+// }
|
|
|
|
|
|
+// @ApiOperation(value = "测试")
|
|
|
+// @PostMapping("/test")
|
|
|
+// public ResponseModel<?> test() {
|
|
|
+// // 遍历所有设备的apk_version,看多少台设备的apk_version = patch_veriosn
|
|
|
+// // 获取热更新表中所有的 patch_version 信息
|
|
|
+// List<String> patchVersions = hotUpdateService.list().stream().map(THotUpdate::getPatchVersion).collect(Collectors.toList());
|
|
|
+// for (String patchVersion : patchVersions) {
|
|
|
+// // 查询所有设备表中的的 apk_version 等于 patch_version的
|
|
|
+// List<TEquipment> equipmentList = equipmentService.lambdaQuery().eq(TEquipment::getApkVersion, patchVersion).list();
|
|
|
+// // 计算当前的 patch_version = apk_version 的设备数量
|
|
|
+// int count = equipmentList.size();
|
|
|
+// System.out.println("count 》》》" + count);
|
|
|
+// THotUpdate hotUpdate = hotUpdateService.lambdaQuery().eq(THotUpdate::getPatchVersion, patchVersion).one();
|
|
|
+// if (hotUpdate != null) {
|
|
|
+// hotUpdate.setHaveUpdateNum(count);
|
|
|
+// hotUpdateService.updateById(hotUpdate);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// return R.ok();
|
|
|
+// }
|
|
|
|
|
|
- @ApiOperation(value = "录入热更新补丁信息")
|
|
|
+ @ApiOperation(value = "添加热更新信息")
|
|
|
@PostMapping("/postPatchInfo")
|
|
|
public ResponseModel<?> postPatchInfo(@RequestBody THotUpdate hotUpdate) {
|
|
|
+ String originalVersion = hotUpdate.getOriginalVersion(); // 原版本号
|
|
|
+ String patchVersion = hotUpdate.getPatchVersion(); // 目标补丁版本号
|
|
|
+ String patchStatus = hotUpdate.getPatchStatus(); // 补丁状态,0停止,1发布
|
|
|
+ String targetAreas = hotUpdate.getTargetAreas(); // 目标区域,0部分设备,1国内,2海外,3全球
|
|
|
+ String patchLink = hotUpdate.getPatchLink(); // 补丁外链
|
|
|
+ String clientIds = hotUpdate.getClientId(); // 设备编号
|
|
|
+ String note = hotUpdate.getNote(); // 更新内容
|
|
|
+
|
|
|
+ assert StringUtils.isNotEmpty(originalVersion) : R.fail(ResponseCodesEnum.B0001, "原版本号不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(patchVersion) : R.fail(ResponseCodesEnum.B0001, "目标补丁版本号不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(patchStatus) : R.fail(ResponseCodesEnum.B0001, "补丁状态不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(patchLink) : R.fail(ResponseCodesEnum.B0001, "补丁外链不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(note) : R.fail(ResponseCodesEnum.B0001, "更新内容不能为空");
|
|
|
+
|
|
|
+ THotUpdate tHotUpdate;
|
|
|
+ // 目标补丁号是否已经存在
|
|
|
+ LambdaQueryWrapper<THotUpdate> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(THotUpdate::getPatchVersion, patchVersion);
|
|
|
+ List<THotUpdate> hotUpdates = hotUpdateService.list(lqw);
|
|
|
+ long hotUpdateId;
|
|
|
+ if (hotUpdates.size() > 0) {
|
|
|
+ // 目标补丁号是可以被修改的
|
|
|
+ tHotUpdate = hotUpdates.get(0);
|
|
|
+ hotUpdateId = tHotUpdate.getId();
|
|
|
+ } else {
|
|
|
+ tHotUpdate = new THotUpdate();
|
|
|
+ hotUpdateId = IDGenerator.commonID();
|
|
|
+ tHotUpdate.setId(hotUpdateId);
|
|
|
+ tHotUpdate.setCreateTime(new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+ tHotUpdate.setModifyTime(new Date());
|
|
|
+ tHotUpdate.setOriginalVersion(originalVersion);
|
|
|
+ tHotUpdate.setPatchVersion(patchVersion);
|
|
|
+ tHotUpdate.setPatchStatus(patchStatus);
|
|
|
+ tHotUpdate.setPatchLink(patchLink);
|
|
|
+ tHotUpdate.setTargetAreas(targetAreas);
|
|
|
+ tHotUpdate.setNote(note);
|
|
|
+ tHotUpdate.setHaveUpdateNum(0);
|
|
|
+
|
|
|
+ switch (targetAreas) {
|
|
|
+ case "0":
|
|
|
+ // 推送指定设备
|
|
|
+ if (StringUtils.isEmpty(clientIds)) { // 查看clientIds是否为空
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "推送区域为空时,需要填写设备编号");
|
|
|
+ }
|
|
|
+ List<String> clientIdList = Arrays.asList(clientIds.split(","));
|
|
|
+ LambdaQueryWrapper<TEquipment> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.in(TEquipment::getClientId, clientIdList);
|
|
|
+ List<TEquipment> equipmentList = equipmentService.list(queryWrapper);
|
|
|
+ int size = equipmentList.size();
|
|
|
+ tHotUpdate.setShouldUpdateNum(size);
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ // 推送国内
|
|
|
+ int count1 = equipmentService.getForeignEquipmentCount("0");
|
|
|
+ tHotUpdate.setShouldUpdateNum(count1);
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ // 推送海外
|
|
|
+ int count2 = equipmentService.getForeignEquipmentCount("1");
|
|
|
+ tHotUpdate.setShouldUpdateNum(count2);
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ // 推送全球
|
|
|
+ int count3 = equipmentService.getForeignEquipmentCount("2");
|
|
|
+ tHotUpdate.setShouldUpdateNum(count3);
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return R.fail("不支持的推送区域参数:" + targetAreas);
|
|
|
+ }
|
|
|
+ hotUpdateService.saveOrUpdate(tHotUpdate);
|
|
|
+
|
|
|
+ return R.ok("录入成功");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @ApiOperation(value = "添加热更新信息1")
|
|
|
+ @PostMapping("/postPatchInfo1")
|
|
|
+ public ResponseModel<?> postPatchInfo1(@RequestBody THotUpdate hotUpdate) {
|
|
|
+ String originalVersion = hotUpdate.getOriginalVersion(); // 原版本号
|
|
|
+ String patchVersion = hotUpdate.getPatchVersion(); // 目标补丁版本号
|
|
|
+ String patchStatus = hotUpdate.getPatchStatus(); // 补丁状态,0停止,1发布
|
|
|
+ String targetAreas = hotUpdate.getTargetAreas(); // 目标区域,0部分设备,1国内,2海外,3全球
|
|
|
+ String patchLink = hotUpdate.getPatchLink(); // 补丁外链
|
|
|
+ String clientIds = hotUpdate.getClientId(); // 设备编号
|
|
|
+ String note = hotUpdate.getNote(); // 更新内容
|
|
|
+
|
|
|
+ assert StringUtils.isNotEmpty(originalVersion) : R.fail(ResponseCodesEnum.B0001, "原版本号不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(patchVersion) : R.fail(ResponseCodesEnum.B0001, "目标补丁版本号不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(patchStatus) : R.fail(ResponseCodesEnum.B0001, "补丁状态不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(patchLink) : R.fail(ResponseCodesEnum.B0001, "补丁外链不能为空");
|
|
|
+ assert StringUtils.isNotEmpty(note) : R.fail(ResponseCodesEnum.B0001, "更新内容不能为空");
|
|
|
+
|
|
|
+ THotUpdate tHotUpdate;
|
|
|
+ // 目标补丁号是否已经存在
|
|
|
+ LambdaQueryWrapper<THotUpdate> lqw = Wrappers.lambdaQuery();
|
|
|
+ lqw.eq(THotUpdate::getPatchVersion, patchVersion);
|
|
|
+ List<THotUpdate> hotUpdates = hotUpdateService.list(lqw);
|
|
|
+ long hotUpdateId;
|
|
|
+ if (hotUpdates.size() > 0) {
|
|
|
+ // 目标补丁号是可以被修改的
|
|
|
+ tHotUpdate = hotUpdates.get(0);
|
|
|
+ hotUpdateId = tHotUpdate.getId();
|
|
|
+ } else {
|
|
|
+ tHotUpdate = new THotUpdate();
|
|
|
+ hotUpdateId = IDGenerator.commonID();
|
|
|
+ tHotUpdate.setId(hotUpdateId);
|
|
|
+ tHotUpdate.setCreateTime(new Date());
|
|
|
+ }
|
|
|
+
|
|
|
+ tHotUpdate.setModifyTime(new Date());
|
|
|
+ tHotUpdate.setOriginalVersion(originalVersion);
|
|
|
+ tHotUpdate.setPatchVersion(patchVersion);
|
|
|
+ tHotUpdate.setPatchStatus(patchStatus);
|
|
|
+ tHotUpdate.setPatchLink(patchLink);
|
|
|
+ tHotUpdate.setTargetAreas(targetAreas);
|
|
|
+ tHotUpdate.setNote(note);
|
|
|
+ tHotUpdate.setHaveUpdateNum(0);
|
|
|
+
|
|
|
+ switch (targetAreas) {
|
|
|
+ case "0":
|
|
|
+ // 推送指定设备
|
|
|
+ if (StringUtils.isEmpty(clientIds)) { // 查看clientIds是否为空
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "推送区域为空时,需要填写设备编号");
|
|
|
+ }
|
|
|
+ // 查询这些设备信息
|
|
|
+ List<String> clientIdList = Arrays.asList(clientIds.split(","));
|
|
|
+ LambdaQueryWrapper<TEquipment> wrapper = Wrappers.lambdaQuery();
|
|
|
+ wrapper.in(TEquipment::getClientId, clientIdList);
|
|
|
+ List<TEquipment> equipmentList0 = equipmentService.list(wrapper);
|
|
|
+ if (equipmentList0.isEmpty()) {
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "设备信息不存在");
|
|
|
+ }
|
|
|
+ // 查询这些设备的所有id
|
|
|
+ List<Long> equipmentIdList = equipmentList0.stream().map(TEquipment::getId).collect(Collectors.toList());
|
|
|
+ if (equipmentIdList.isEmpty()) {
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
|
|
|
+ }
|
|
|
+// if (CollectionUtils.isEmpty(equipmentIdList)) {
|
|
|
+// return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
|
|
|
+// }
|
|
|
+// equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList, hotUpdateId);
|
|
|
+ tHotUpdate.setShouldUpdateNum(equipmentIdList.size());
|
|
|
+ break;
|
|
|
+ case "1":
|
|
|
+ // 推送国内
|
|
|
+ // 查询所有的国内用户
|
|
|
+// LambdaQueryWrapper<TAdmin> wrapper1 = Wrappers.lambdaQuery();
|
|
|
+// wrapper1.eq(TAdmin::getIfForeign, "0");
|
|
|
+// List<TAdmin> domesticAdminList = adminService.list(wrapper1);
|
|
|
+ List<TAdmin> domesticAdminList = adminService.lambdaQuery().eq(TAdmin::getIfForeign, "0").list();
|
|
|
+
|
|
|
+ ArrayList<Long> equipmentIdList1 = new ArrayList<>();
|
|
|
+
|
|
|
+ // 批量查询国内用户的设备信息
|
|
|
+ LambdaQueryWrapper<TEquipment> queryWrapper = Wrappers.lambdaQuery();
|
|
|
+ queryWrapper.in(TEquipment::getAdminId, domesticAdminList.stream().map(TAdmin::getId).collect(Collectors.toList()));
|
|
|
+ List<TEquipment> equipmentList = equipmentService.list(queryWrapper);
|
|
|
+
|
|
|
+ // 将equipmentId添加到list
|
|
|
+ equipmentIdList1.addAll(equipmentList.stream().map(TEquipment::getId).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ if (equipmentIdList1.isEmpty()) {
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
|
|
|
+ }
|
|
|
+// if (!equipmentIdList1.isEmpty()) {
|
|
|
+// equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList1, hotUpdateId);
|
|
|
+// }
|
|
|
+ tHotUpdate.setShouldUpdateNum(equipmentIdList1.size());
|
|
|
+
|
|
|
+ break;
|
|
|
+ case "2":
|
|
|
+ // 推送海外
|
|
|
+ // 查询所有海外用户信息
|
|
|
+ List<TAdmin> foreignAdminList = adminService.lambdaQuery().eq(TAdmin::getIfForeign, "1").list();
|
|
|
+ // 查询海外用户的所有设备的id
|
|
|
+ List<Long> equipmentIdList2 = foreignAdminList.stream().flatMap(admin -> equipmentService.lambdaQuery().eq(TEquipment::getAdminId, admin.getId()).list().stream()).map(TEquipment::getId).collect(Collectors.toList());
|
|
|
+ if (equipmentIdList2.isEmpty()) {
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
|
|
|
+ }
|
|
|
+// if (!equipmentIdList2.isEmpty()) {
|
|
|
+// equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList2, hotUpdateId);
|
|
|
+// }
|
|
|
+ tHotUpdate.setShouldUpdateNum(equipmentIdList2.size());
|
|
|
+ break;
|
|
|
+ case "3":
|
|
|
+ // 推送全球
|
|
|
+ // 所有设备id
|
|
|
+ List<Long> equipmentIdList3 = equipmentService.list().stream().map(TEquipment::getId).collect(Collectors.toList());
|
|
|
+ if (equipmentIdList3.isEmpty()) {
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "没有符合要求的设备");
|
|
|
+ }
|
|
|
+// equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList3, hotUpdateId);
|
|
|
+
|
|
|
+// List<TEquipmentDesc> equipmentDescList = equipmentDescService.list();
|
|
|
+// equipmentDescList.forEach(d -> d.setPatchId(hotUpdateId));
|
|
|
+// equipmentDescService.saveOrUpdateBatch(equipmentDescList);
|
|
|
+ tHotUpdate.setShouldUpdateNum(equipmentIdList3.size());
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ return R.fail("不支持的推送区域参数:" + targetAreas);
|
|
|
+ }
|
|
|
+ hotUpdateService.save(tHotUpdate);
|
|
|
+
|
|
|
+ return R.ok("录入成功");
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
+ @ApiOperation(value = "录入热更新补丁信息0")
|
|
|
+ @PostMapping("/postPatchInfo0")
|
|
|
+ public ResponseModel<?> postPatchInfo0(@RequestBody THotUpdate hotUpdate) {
|
|
|
|
|
|
- String patchVersion = hotUpdate.getPatchVersion(); // 补丁版本号
|
|
|
+ String originalVersion = hotUpdate.getOriginalVersion(); // 原版本号
|
|
|
+ String patchVersion = hotUpdate.getPatchVersion(); // 目标补丁版本号
|
|
|
String patchStatus = hotUpdate.getPatchStatus(); // 补丁状态,0停止,1发布
|
|
|
String targetAreas = hotUpdate.getTargetAreas(); // 目标区域,0部分设备,1国内,2海外,3全球
|
|
|
String patchLink = hotUpdate.getPatchLink(); // 补丁外链
|
|
@@ -112,6 +446,9 @@ public class THotUpdateController {
|
|
|
tHotUpdate.setPatchLink(patchLink);
|
|
|
tHotUpdate.setTargetAreas(targetAreas);
|
|
|
tHotUpdate.setNote(note);
|
|
|
+ tHotUpdate.setOriginalVersion(originalVersion);
|
|
|
+ tHotUpdate.setHaveUpdateNum(0);
|
|
|
+// tHotUpdate.setShouldUpdateNum(0);
|
|
|
|
|
|
switch (targetAreas) {
|
|
|
case "0":
|
|
@@ -147,10 +484,10 @@ public class THotUpdateController {
|
|
|
wrapper1.in(TEquipment::getClientId, clientIdList);
|
|
|
List<TEquipment> equipmentList1 = equipmentService.list(wrapper1);
|
|
|
if (equipmentList1.isEmpty()) {
|
|
|
- return R.fail(ResponseCodesEnum.B0001,"设备信息不存在");
|
|
|
+ return R.fail(ResponseCodesEnum.B0001, "设备信息不存在");
|
|
|
}
|
|
|
List<Long> equipmentIdList = equipmentList1.stream().map(TEquipment::getId).collect(Collectors.toList());
|
|
|
- hotUpdateService.saveOrUpdateEquipmentDescBatch(equipmentIdList, hotUpdateId);
|
|
|
+ equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList, hotUpdateId);
|
|
|
break;
|
|
|
case "1":
|
|
|
// 推送国内
|
|
@@ -171,7 +508,7 @@ public class THotUpdateController {
|
|
|
}
|
|
|
if (!equipmentIdList1.isEmpty()) {
|
|
|
// saveOrUpdateEquipmentDescBatch(equipmentIdList1, hotUpdateId);
|
|
|
- hotUpdateService.saveOrUpdateEquipmentDescBatch(equipmentIdList1, hotUpdateId);
|
|
|
+ equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList1, hotUpdateId);
|
|
|
}
|
|
|
|
|
|
break;
|
|
@@ -201,7 +538,7 @@ public class THotUpdateController {
|
|
|
List<Long> equipmentIdList3 = adminList.stream().flatMap(admin -> equipmentService.lambdaQuery().eq(TEquipment::getAdminId, admin.getId()).list().stream()).map(TEquipment::getId).collect(Collectors.toList());
|
|
|
if (!equipmentIdList3.isEmpty()) {
|
|
|
// saveOrUpdateEquipmentDescBatch(equipmentIdList3, hotUpdateId);
|
|
|
- hotUpdateService.saveOrUpdateEquipmentDescBatch(equipmentIdList3, hotUpdateId);
|
|
|
+ equipmentDescService.saveOrUpdateEquipmentDescBatch(equipmentIdList3, hotUpdateId);
|
|
|
}
|
|
|
|
|
|
break;
|