TRX vor 1 Jahr
Ursprung
Commit
52a151e8d4

+ 23 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceAboutInfo.java

@@ -0,0 +1,23 @@
+package com.zhongshu.card.client.model.devices;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+/**
+ * 设备扩展信息
+ *
+ * @author TRX
+ * @date 2024/12/9
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class DeviceAboutInfo {
+
+    @Schema(description = "设备ID")
+    private String deviceId;
+
+
+}

+ 3 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceBindAreaParam.java

@@ -28,4 +28,7 @@ public class DeviceBindAreaParam {
     @Schema(description = "所属机构信息")
     private String beLongOid;
 
+    @Schema(description = "设备关联的扩展信息")
+    private DeviceAboutInfo aboutInfo;
+
 }

+ 2 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceInfoModel.java

@@ -129,4 +129,6 @@ public class DeviceInfoModel extends SuperModel {
 
     private String areaAllName = "";
 
+    @Schema(description = "设备关联的扩展信息")
+    private DeviceAboutInfo aboutInfo;
 }

+ 2 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/DeviceInfoParam.java

@@ -35,4 +35,6 @@ public class DeviceInfoParam extends SuperParam {
 
     @Schema(description = "设备IP地址")
     private String ip;
+
+
 }

+ 4 - 8
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/DeviceInfoController.java

@@ -2,9 +2,9 @@ package com.zhongshu.card.server.core.controller.devices;
 
 import com.github.microservice.auth.security.annotations.ResourceAuth;
 import com.github.microservice.auth.security.type.AuthType;
+import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.model.base.IDParam;
 import com.zhongshu.card.client.model.devices.*;
-import com.github.microservice.net.ResultContent;
 import com.zhongshu.card.client.service.school.DeviceInfoService;
 import io.swagger.v3.oas.annotations.Operation;
 import io.swagger.v3.oas.annotations.Parameter;
@@ -73,9 +73,7 @@ public class DeviceInfoController {
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "设备列表-分页查询", description = "设备列表-分页查询")
     @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
-    public ResultContent<Page<DeviceInfoModel>> page(
-            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
-            @Parameter(required = false) DeviceInfoSearch param) {
+    public ResultContent<Page<DeviceInfoModel>> page(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, @Parameter(required = false) DeviceInfoSearch param) {
         Assert.hasText(param.getProjectOid(), "projectOid不能为空");
         return deviceInfoService.page(param, pageable);
     }
@@ -83,14 +81,12 @@ public class DeviceInfoController {
     @ResourceAuth(value = "user", type = AuthType.User)
     @Operation(summary = "设备列表-分页查询(商户小程序用)", description = "设备列表-分页查询")
     @RequestMapping(value = {"busPage"}, method = {RequestMethod.POST})
-    public ResultContent<Page<DeviceInfoModel>> busPage(
-            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
-            @Parameter(required = false) DeviceInfoSearch param) {
+    public ResultContent<Page<DeviceInfoModel>> busPage(@Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable, @Parameter(required = false) DeviceInfoSearch param) {
         return deviceInfoService.busPage(param, pageable);
     }
 
     @ResourceAuth(value = "user", type = AuthType.User)
-    @Operation(summary = "修改设备信息", description = "修改设备信息")
+    @Operation(summary = "编辑设备信息", description = "编辑设备信息")
     @RequestMapping(value = "updateDevice", method = {RequestMethod.POST})
     public ResultContent updateDevice(@RequestBody @Valid DeviceBindAreaParam param) {
         return this.deviceInfoService.updateDevice(param);

+ 14 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dataConfig/DeviceConfig.java

@@ -0,0 +1,14 @@
+package com.zhongshu.card.server.core.dataConfig;
+
+/**
+ * @author TRX
+ * @date 2024/12/9
+ */
+public class DeviceConfig {
+
+    /**
+     *服务启动时,检查设备是否在线的 最大判断时间
+     */
+    public final static Long maxInitCheckDeviceLineStateTime = 24 * 60 * 60 * 1000l;
+
+}

+ 5 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/DeviceInfo.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.server.core.domain.devices;
 
 import com.github.microservice.models.type.DeviceType;
+import com.zhongshu.card.client.model.devices.DeviceAboutInfo;
 import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.client.type.OnLineState;
 import com.zhongshu.card.server.core.domain.base.SuperMain;
@@ -79,4 +80,8 @@ public class DeviceInfo extends SuperMain {
 
     @Schema(description = "是否开放使用")
     private Boolean isOpenUse = Boolean.FALSE;
+
+    @Schema(description = "设备关联的扩展信息")
+    private DeviceAboutInfo aboutInfo;
+
 }

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

@@ -13,6 +13,7 @@ import com.zhongshu.card.client.type.OnLineState;
 import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.dao.school.AreaDao;
+import com.zhongshu.card.server.core.dataConfig.DeviceConfig;
 import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
 import com.zhongshu.card.server.core.domain.devices.DevicePermiss;
 import com.zhongshu.card.server.core.domain.org.Organization;
@@ -275,26 +276,35 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
         }
         deviceInfo.setArea(area);
         deviceInfo.setAreaPaths(String.join("/", strings));
+        deviceInfo.setDeviceName(param.getDeviceName());
 
         // 设备所属机构
         Organization organization = null;
         if (StringUtils.isNotEmpty(param.getBeLongOid())) {
             organization = organizationDao.findTopByOid(param.getBeLongOid());
+            if (ObjectUtils.isEmpty(organization)) {
+                return ResultContent.buildFail("所属机构不存在");
+            }
+            deviceInfo.setBeLongName(organization.getName());
         }
         deviceInfo.setOrganization(organization);
         deviceInfo.setBeLongOid(param.getBeLongOid());
-        deviceInfo.setBeLongName(organization.getName());
+
         if (StringUtils.isEmpty(deviceInfo.getProjectOid())) {
             Organization project = organizationDao.findTopByCode(deviceInfo.getProjectInfoCode());
             if (ObjectUtils.isNotEmpty(project)) {
                 deviceInfo.setProjectOid(project.getOid());
             }
         }
-        // 检查设备关联的结构,是否可以收款
-        ResultContent resultContent = orgPaySettingJudgmentService.checkOrgPaySetting(deviceInfo.getProjectOid(), deviceInfo.getBeLongOid());
-        if (resultContent.isFailed()) {
-            return ResultContent.buildFail(resultContent.getMsg());
+
+        if(ObjectUtils.isNotEmpty(organization)) {
+            // 检查设备关联的机构,是否可以收款
+            ResultContent resultContent = orgPaySettingJudgmentService.checkOrgPaySetting(deviceInfo.getProjectOid(), deviceInfo.getBeLongOid());
+            if (resultContent.isFailed()) {
+                return ResultContent.buildFail(resultContent.getMsg());
+            }
         }
+
         deviceInfoDao.save(deviceInfo);
         return ResultContent.buildSuccess();
     }
@@ -322,7 +332,7 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
     public void initCheckDeviceOnLine() {
         List<DeviceInfo> list = deviceInfoDao.findAll();
         if (ObjectUtils.isNotEmpty(list)) {
-            long maxTime = 24 * 60 * 60 * 1000;
+            long maxTime = DeviceConfig.maxInitCheckDeviceLineStateTime;
             List<DeviceInfo> deviceInfos = new ArrayList<>();
             for (DeviceInfo deviceInfo : list) {
                 if (deviceInfo.getLastOnlineTime() == null || (System.currentTimeMillis() - deviceInfo.getLastOnlineTime()) > maxTime) {
@@ -336,6 +346,18 @@ public class DeviceInfoServiceImpl extends SuperService implements DeviceInfoSer
         }
     }
 
+    /**
+     * 得到、封装设备的扩展信息
+     *
+     * @param deviceId
+     */
+    public void getDeviceAboutInfo(String deviceId) {
+        DeviceInfo deviceInfo = deviceInfoDao.findTopById(deviceId);
+        if (ObjectUtils.isNotEmpty(deviceInfo)) {
+
+        }
+    }
+
     /**
      * 设备基础信息
      *

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/scene/RoleSceneInfoService.java

@@ -177,7 +177,7 @@ public class RoleSceneInfoService extends SuperService {
                 List<String> roleIds = roles.stream().map(it -> it.getId()).collect(Collectors.toUnmodifiableList());
                 List<RoleSceneInfo> list = roleSceneInfoDao.findByRoleIdInOrderBySortAsc(roleIds);
                 if (ObjectUtils.isNotEmpty(list)) {
-                    list.stream().forEach(it -> {
+                    list.parallelStream().forEach(it -> {
                         SceneInfo sceneInfo = it.getSceneInfo();
                         ProjectSceneInfo projectSceneInfo = it.getProjectSceneInfo();
                         if (ObjectUtils.isNotEmpty(projectSceneInfo) && ObjectUtils.isNotEmpty(sceneInfo)) {

+ 3 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/scene/SceneInfoService.java

@@ -80,6 +80,8 @@ public class SceneInfoService extends SuperService {
         if (!isAdd) {
             projectSceneInfoService.updateAllSceneInfo(entity);
         }
+
+        // 保存场景包含的组件
         saveComponents(entity, param.getComponents());
         return ResultContent.buildSuccess();
     }
@@ -189,6 +191,7 @@ public class SceneInfoService extends SuperService {
         SceneInfoAboutComModel model = new SceneInfoAboutComModel();
         if (ObjectUtils.isNotEmpty(entity)) {
             BeanUtils.copyProperties(entity, model);
+            // 场景包含的组件
             model.setComponents(getSceneAllComponents(entity.getId()));
         }
         return model;