From 42bfd65c20ded4d878b43d437a76961785f669b4 Mon Sep 17 00:00:00 2001 From: nili Date: Sun, 28 Apr 2024 18:12:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E5=A4=87=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../game/service/AdminDeviceService.java | 19 ++++++++++++++++--- .../web/rest/matrix/DeviceController.java | 7 +++++++ 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/game-service/src/main/java/awesome/group/game/service/AdminDeviceService.java b/game-service/src/main/java/awesome/group/game/service/AdminDeviceService.java index efe6db1..bc7d178 100644 --- a/game-service/src/main/java/awesome/group/game/service/AdminDeviceService.java +++ b/game-service/src/main/java/awesome/group/game/service/AdminDeviceService.java @@ -72,9 +72,22 @@ public class AdminDeviceService { mapper.updateStatusByDeviceId(STATUS_OFFLINE, deviceId, adminId); } + public void setStatusOnline(Integer adminId, String deviceId) { + MatrixAdminDevice record = mapper.selectByDeviceId(deviceId); + if (record == null) { + return; + } + MatrixAdmin admin = adminMapper.selectById(record.getAdminId()); + long cnt = queryBindCnt(admin.getId(), record.getAppId()); + if (cnt >= admin.getDeviceCnt()) { + throw new PaganiException(PaganiExceptionCode.GENERAL_ERROR, "绑定设备数已达上限"); + } + mapper.updateStatusByDeviceId(STATUS_DEFAULT, deviceId, adminId); + } + public String bind(String deviceId, String appCode, String adminName) { MatrixAdminDevice device = mapper.selectByDeviceId(deviceId); - if (device != null) { + if (device != null && device.getStatus() != STATUS_OFFLINE) { return "设备已绑定"; } MatrixAdmin admin = adminMapper.query(adminName); @@ -229,11 +242,11 @@ public class AdminDeviceService { query.between(MatrixAdvRecord::getCreatedAt, new Timestamp(dateBegin), new Timestamp(dateEnd)); query.eq(MatrixAdvRecord::getAdvType, 3);//设备主只算激励视频 query.gt(MatrixAdvRecord::getAdminId, 0); - query.groupBy(MatrixAdvRecord::getAdminId,MatrixAdvRecord::getAppId, MatrixAdvRecord::getPlatform); + query.groupBy(MatrixAdvRecord::getAdminId, MatrixAdvRecord::getAppId, MatrixAdvRecord::getPlatform); List records = advRecordMapper.selectList(query); List aggregations = new ArrayList<>(); List adminList = adminMapper.selectList(null); - Map adminMap = adminList.stream().collect(Collectors.toMap(x->x.getId(), x->x)); + Map adminMap = adminList.stream().collect(Collectors.toMap(x -> x.getId(), x -> x)); for (MatrixAdvRecord r : records) { MatrixAdvAggregationSub aggregation = new MatrixAdvAggregationSub(); aggregation.setAdminId(r.getAdminId()); diff --git a/game-web/src/main/java/awesome/group/game/web/rest/matrix/DeviceController.java b/game-web/src/main/java/awesome/group/game/web/rest/matrix/DeviceController.java index e1abc97..e40a2f5 100644 --- a/game-web/src/main/java/awesome/group/game/web/rest/matrix/DeviceController.java +++ b/game-web/src/main/java/awesome/group/game/web/rest/matrix/DeviceController.java @@ -35,6 +35,13 @@ public class DeviceController { return new R<>("ok"); } + @PostMapping("/online") + @RestApi + public R online(@RequestParam String deviceId) { + adminDeviceService.setStatusOnline(RequestContext.getAdminID(), deviceId); + return new R<>("ok"); + } + @GetMapping("/incomeOverview") @RestApi public R incomeOverview(@RequestParam(required = false) String appCode) {