浏览代码

更新!

TRX 1 年之前
父节点
当前提交
35f2e3d477

+ 0 - 32
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/DeviceUseRecordController.java

@@ -38,14 +38,6 @@ public class DeviceUseRecordController {
     @Autowired
     private DeviceUseRecordService deviceUseRecordService;
 
-
-    @Operation(summary = "物联网添加设备使用日志(通用不带复杂的业务)", description = "物联网添加设备使用日志")
-    @RequestMapping(value = "saveDeviceLogs", method = {RequestMethod.POST})
-    public ResultContent saveDeviceLogs(@RequestBody GateDoorUseParam param) {
-        return this.deviceUseRecordService.saveDeviceLogs(param);
-    }
-
-
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "根据设备数据ID 设备详情", description = "根据设备数据ID 设备详情")
     @RequestMapping(value = "getDeviceById", method = {RequestMethod.POST})
@@ -53,21 +45,6 @@ public class DeviceUseRecordController {
         return this.deviceInfoService.getDeviceDetail(param.getId());
     }
 
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "根据设备ID 设备详情(精确匹配)", description = "根据设备ID 设备详情(精确匹配)")
-    @RequestMapping(value = "getDeviceByDeviceId", method = {RequestMethod.GET})
-    public ResultContent<DeviceInfoMoreModel> getDeviceByDeviceId(@RequestParam(name = "deviceId") String deviceId) {
-        return this.deviceInfoService.getDeviceDetailByDeviceId(deviceId);
-    }
-
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "根据设备ID 设备列表(模糊匹配)", description = "根据设备ID 设备列表(模糊匹配)")
-    @RequestMapping(value = "getDeviceDetailByDeviceIdLike", method = {RequestMethod.GET})
-    public ResultContent<List<DeviceInfoMoreModel>> getDeviceDetailByDeviceIdLike(@RequestParam(name = "deviceId") String deviceId) {
-        return this.deviceInfoService.getDeviceDetailByDeviceIdLike(deviceId);
-    }
-
-
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "删除设备", description = "删除设备")
     @RequestMapping(value = "deleteDeviceInfo", method = {RequestMethod.POST})
@@ -85,13 +62,4 @@ public class DeviceUseRecordController {
         return deviceInfoService.page(param, pageable);
     }
 
-    @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "修改设备信息", description = "修改设备信息")
-    @RequestMapping(value = "updateDevice", method = {RequestMethod.POST})
-    public ResultContent updateDevice(@RequestBody @Valid DeviceBindAreaParam param) {
-        return this.deviceInfoService.updateDevice(param);
-    }
-
-    //----------------------------设备基础信息 end--------------------------
-
 }

+ 0 - 67
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/OpenApiSuperController.java

@@ -1,67 +0,0 @@
-//package com.zhongshu.card.server.core.controller.openAPI;
-//
-//import com.github.microservice.components.data.base.util.PageEntityUtil;
-//import com.zhongshu.card.server.core.dao.org.OrganizationDao;
-//import com.zhongshu.opengateway.client.model.OpenApiModel;
-//import com.zhongshu.opengateway.client.model.param.LimitParam;
-//import com.zhongshu.opengateway.client.model.param.OpenApiSearchParam;
-//import com.zhongshu.opengateway.client.model.ret.ResultContent;
-//import com.zhongshu.opengateway.client.service.OpenApiService;
-//import com.zhongshu.opengateway.client.service.SignService;
-//import io.swagger.v3.oas.annotations.Operation;
-//import io.swagger.v3.oas.annotations.Parameter;
-//import io.swagger.v3.oas.annotations.tags.Tag;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.data.domain.Page;
-//import org.springframework.data.domain.Pageable;
-//import org.springframework.web.bind.annotation.*;
-//
-//@RestController
-//@RequestMapping("/openApi/super/api")
-//@Tag(name = "OpenApi超管--接口管理")
-//public class OpenApiSuperController {
-//
-//    @Autowired
-//    OpenApiService openApiService;
-//
-//    @Autowired
-//    SignService signService;
-//
-//    @Autowired
-//    OrganizationDao organizationDao;
-//
-//    @Operation(summary = "分页查询openApi", description = "分页查询openApi")
-////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-//    @RequestMapping(value = "page", method = RequestMethod.POST)
-//    public ResultContent page(@Parameter(hidden = true) Pageable pageable, OpenApiSearchParam param){
-//        param.setPageNumber(pageable.getPageNumber());
-//        param.setPageSize(pageable.getPageSize());
-//        return openApiService.page(param);
-//    }
-//
-//    @Operation(summary = "禁用/启用", description = "禁用/启用")
-////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-//    @RequestMapping(value = "disable", method = RequestMethod.GET)
-//    public ResultContent disable(@Parameter(name = "id", description = "接口id") String id){
-//        return openApiService.disable(id);
-//    }
-//
-//    @Operation(summary = "删除", description = "删除")
-////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-//    @RequestMapping(value = "delete", method = RequestMethod.GET)
-//    public ResultContent delete(@Parameter(name = "id", description = "接口id") String id){
-//        return openApiService.delete(id);
-//    }
-//
-//
-//    @Operation(summary = "设置规则", description = "设置规则")
-////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-//    @RequestMapping(value = "setLimit", method = RequestMethod.POST)
-//    public ResultContent setLimit(@RequestBody LimitParam limitParam){
-//        return openApiService.setLimit(limitParam);
-//    }
-//
-//
-//
-//
-//}

+ 0 - 66
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/OpenAppSuperController.java

@@ -1,66 +0,0 @@
-//package com.zhongshu.card.server.core.controller.openAPI;
-//
-//import com.zhongshu.card.client.model.openApi.AppParam;
-//import com.zhongshu.card.server.core.service.openAPI.OpenAppManagerService;
-//import com.zhongshu.opengateway.client.model.param.SignParam;
-//import com.zhongshu.opengateway.client.service.OpenApiConfigService;
-//import com.zhongshu.opengateway.client.type.AppState;
-//import com.zhongshu.opengateway.client.type.AppType;
-//import io.swagger.v3.oas.annotations.Operation;
-//import io.swagger.v3.oas.annotations.Parameter;
-//import io.swagger.v3.oas.annotations.tags.Tag;
-//import org.springframework.beans.factory.annotation.Autowired;
-//import org.springframework.data.domain.Pageable;
-//import org.springframework.data.web.PageableDefault;
-//import org.springframework.web.bind.annotation.*;
-//
-//@RestController
-//@RequestMapping("/openApi/super/app")
-//@Tag(name = "OpenApi超管--应用管理")
-//public class OpenAppSuperController {
-//
-//    @Autowired
-//    OpenAppManagerService openAppManagerService;
-//
-//    @Autowired
-//    OpenApiConfigService openApiConfigService;
-//
-//    @Operation(summary = "添加应用", description = "添加应用")
-//    @RequestMapping(value = "add", method = {RequestMethod.POST})
-////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
-//    public Object add(@RequestBody SignParam param){
-//        return openAppManagerService.add(param);
-//    }
-//
-//    @Operation(summary = "删除应用", description = "删除应用")
-//    @RequestMapping(value = "delete", method = {RequestMethod.GET})
-////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
-//    public Object delete(@Parameter(name = "appId", description = "应用id") @RequestParam(name = "appId") String appId){
-//        return openAppManagerService.delete(appId);
-//    }
-//
-//
-//    @Operation(summary = "禁用/启用", description = "禁用/启用")
-////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
-//    @RequestMapping(value = "disable", method = {RequestMethod.GET})
-//    public Object disable(@Parameter(name = "appId", description = "应用id")@RequestParam(name = "appId")String appId,
-//                          @Parameter(name = "appState", description = "应用状态")@RequestParam(name = "appState") AppState appState){
-//        return openAppManagerService.disable(appId, appState);
-//    }
-//
-////    /**
-////     * 分页获取该项目下的app列表
-////     */
-////    @Operation(summary = "分页获取该项目下的app列表", description = "分页获取该项目下的app列表")
-//////    @ResourceAuth(value = AuthConstant.SuperAdmin, type = AuthType.Platform, remark = "")
-//////    @ResourceAuth(value = AuthConstant.Admin, type = AuthType.Project, remark = "")
-////    @RequestMapping(value = "page", method = {RequestMethod.POST})
-////    public Object page(@Parameter(hidden = true)  Pageable pageable,
-////                       AppParam param){
-////        return openAppManagerService.page(param, pageable);
-////    }
-//
-//}

+ 12 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/openAPI/ProjectOpenAPIController.java

@@ -2,12 +2,14 @@ package com.zhongshu.card.server.core.controller.openAPI;
 
 import com.github.microservice.models.device.DevicePerQuery;
 import com.github.microservice.models.device.UserPerQuery;
+import com.github.microservice.models.gateDoor.use.GateDoorUseParam;
 import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.project.ProjectSaveParam;
 import com.zhongshu.card.client.model.school.BookInfoAddParam;
 import com.zhongshu.card.client.model.school.BookInfoModel;
 import com.zhongshu.card.client.service.school.BookInfoService;
 import com.zhongshu.card.server.core.service.devices.DevicePermissIotService;
+import com.zhongshu.card.server.core.service.devices.DeviceUseRecordService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.tags.Tag;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -28,7 +30,10 @@ import javax.validation.Valid;
 public class ProjectOpenAPIController {
 
     @Autowired
-    DevicePermissIotService devicePermissIotService;
+    private DevicePermissIotService devicePermissIotService;
+
+    @Autowired
+    private DeviceUseRecordService deviceUseRecordService;
 
     @Operation(summary = "查询设备权限", description = "查询设备权限")
     @RequestMapping(value = "queryDeviceBindUsers", method = {RequestMethod.POST})
@@ -48,4 +53,10 @@ public class ProjectOpenAPIController {
         return devicePermissIotService.getDeviceAboutUserInfos(param);
     }
 
+    @Operation(summary = "物联网添加设备使用日志(通用不带复杂的业务)", description = "物联网添加设备使用日志")
+    @RequestMapping(value = "saveDeviceLogs", method = {RequestMethod.POST})
+    public ResultContent saveDeviceLogs(@RequestBody GateDoorUseParam param) {
+        return this.deviceUseRecordService.saveDeviceLogs(param);
+    }
+
 }

+ 9 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/init/DataiInit.java

@@ -1,5 +1,6 @@
 package com.zhongshu.card.server.core.init;
 
+import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
 import com.zhongshu.card.server.core.service.openAPI.OpenAPIRegisterService;
 import com.zhongshu.card.server.core.service.paySetting.ProjectChannelConfigService;
 import lombok.extern.slf4j.Slf4j;
@@ -11,7 +12,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 
 /**
- * 平台用户的初始化
+ * 初始、检查数据
  *
  * @author TRX
  * @date 2024/6/3
@@ -23,12 +24,19 @@ public class DataiInit implements CommandLineRunner {
     @Autowired
     private ProjectChannelConfigService projectChannelConfigService;
 
+    @Autowired
+    private DeviceInfoServiceImpl deviceInfoService;
+
     @Override
     public void run(String... args) throws Exception {
         CompletableFuture.runAsync(() -> {
             try {
                 TimeUnit.SECONDS.sleep(20);
+                // 初始平台的支付产品
                 projectChannelConfigService.initAllChannel();
+
+                // 检查设备的在线状态
+                deviceInfoService.initCheckDeviceOnLine();
             } catch (Exception e) {
                 e.printStackTrace();
             }

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/init/OpenApiInit.java

@@ -11,7 +11,7 @@ import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.TimeUnit;
 
 /**
- * 平台用户的初始化
+ * 注册平台的 openAPI到openAPI网关
  *
  * @author TRX
  * @date 2024/6/3

+ 26 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceInfoServiceImpl.java

@@ -8,12 +8,14 @@ import com.github.microservice.net.ResultMessage;
 import com.zhongshu.card.client.model.org.OrganizationMiniModel;
 import com.zhongshu.card.client.model.school.AreaModel;
 import com.zhongshu.card.client.service.school.DeviceInfoService;
+import com.zhongshu.card.client.type.OnLineState;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.school.AreaDao;
 import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
 import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
 import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.domain.school.Area;
+import com.zhongshu.card.server.core.service.base.CommonService;
 import com.zhongshu.card.server.core.service.base.SuperService;
 import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
 import com.zhongshu.card.server.core.service.orgManager.OrganizationManagerServiceImpl;
@@ -59,6 +61,9 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
     @Autowired
     OrganizationManagerServiceImpl organizationManagerService;
 
+    @Autowired
+    private CommonService commonService;
+
     /**
      * 同步设备 (设备基础信息)
      *
@@ -260,6 +265,27 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
         return organization;
     }
 
+    /**
+     * 启动平台时检查设备 (有些设备没有使用了,没有改变在线状态)
+     */
+    public void initCheckDeviceOnLine() {
+        List<DeviceInfo> list = deviceInfoDao.findAll();
+        if (ObjectUtils.isNotEmpty(list)) {
+            long maxTime = 24 * 60 * 60 * 1000;
+            List<DeviceInfo> deviceInfos = new ArrayList<>();
+            for (DeviceInfo deviceInfo : list) {
+                if (deviceInfo.getLastOnlineTime() == null
+                        || (System.currentTimeMillis() - deviceInfo.getLastOnlineTime()) > maxTime) {
+                    deviceInfo.setOnLineState(OnLineState.OffLine);
+                    deviceInfos.add(deviceInfo);
+                }
+            }
+            if (ObjectUtils.isNotEmpty(deviceInfos)) {
+                deviceInfoDao.saveAll(deviceInfos);
+            }
+        }
+    }
+
     /**
      * 设备基础信息
      *

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceSyncFromIotService.java

@@ -99,8 +99,8 @@ public class DeviceSyncFromIotService {
 
         HashMap<String, Object> map = new HashMap<>();
         map.put("lastOnlineTime", param.getLastOnlineTime());
+        map.put("lastOnlineTimeStr", DateUtils.paresTime(param.getLastOnlineTime(), DateUtils.FORMAT_LONG));
         commonService.updateData(where, map, DeviceInfo.class.getSimpleName());
-        commonService.updateData(where, map, DeviceBind.class.getSimpleName());
         return ResultContent.buildSuccess();
     }
 

+ 12 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/DeviceUseRecordService.java

@@ -134,6 +134,18 @@ public class DeviceUseRecordService extends SuperService {
                     // 在线验证
                     checkUseDeviceData(deviceUseRecord);
                 }
+
+                // 最后的返回判断
+                if (deviceUseRecord.getIsPassed() != null && deviceUseRecord.getIsPassed()) {
+                    // 成功
+                    result.setSuccess();
+                } else {
+                    // 失败
+                    result.setFailed(deviceUseRecord.getMsg());
+                }
+                deviceUseRecordDao.save(deviceUseRecord);
+            } else {
+                result.setFailed("数据已处理");
             }
         } else {
             result.setFailed("mqttDataId为空");