TRX 1 an în urmă
părinte
comite
a51bc72739

+ 14 - 13
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/iot/openAPI/IotThingOpenAPIController.java → OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/controller/openAPi/iotThing/IotThingOpenApiController.java

@@ -1,4 +1,4 @@
-package com.zhongshu.iot.server.core.controller.iot.openAPI;
+package com.zhongshu.iot.server.core.controller.openAPi.iotThing;
 
 import com.github.microservice.busInfoModel.thing.IotThing2DeviceModel;
 import com.github.microservice.busInfoModel.thing.IotThing2DeviceSearch;
@@ -10,12 +10,11 @@ import com.github.microservice.staticVariable.OpenApiMark;
 import com.zhongshu.iot.server.core.service.iot.IotThing2DeviceService;
 import com.zhongshu.iot.server.core.service.iot.IotThingService;
 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.PageRequest;
 import org.springframework.data.domain.Pageable;
-import org.springframework.data.web.PageableDefault;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -23,16 +22,16 @@ import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
 /**
- * 物模型管理
+ * 物模型相关的 openApi 接口
  *
  * @author TRX
- * @date 2024/3/21
+ * @date 2024/11/11
  */
-@RequestMapping("/" + OpenApiMark.iotOpenAPI + "/manager/v1/thing")
+@RequestMapping("/" + OpenApiMark.iotOpenAPI + "/manager/v1/iotThing")
 @RestController
 @Validated
-@Tag(name = "openAPI-物模型-物模型管理")
-public class IotThingOpenAPIController {
+@Tag(name = "openAPI-物模型")
+public class IotThingOpenApiController {
 
     @Autowired
     private IotThingService iotThingService;
@@ -43,8 +42,8 @@ public class IotThingOpenAPIController {
     @Operation(summary = "物模型列表-分页查询")
     @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
     public ResultContent<Page<IotThingModel>> page(
-            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
-            @Parameter(required = false) IotThingSearch param) {
+            @RequestBody IotThingSearch param) {
+        Pageable pageable = PageRequest.of(param.getNumber(), param.getSize());
         return iotThingService.page(pageable, param);
     }
 
@@ -54,13 +53,15 @@ public class IotThingOpenAPIController {
         return iotThingService.getDetail(param.getId());
     }
 
-    //--------------------------------物模型设备信息 start-----------------
+    //---------------------------物模型设备信息 start---------------
 
     @Operation(summary = "物模型设备列表-分页查询")
     @RequestMapping(value = {"pageDevice"}, method = {RequestMethod.POST})
     public ResultContent<Page<IotThing2DeviceModel>> pageDevice(
-            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
-            @Parameter(required = false) IotThing2DeviceSearch param) {
+            @RequestBody IotThing2DeviceSearch param) {
+        Pageable pageable = PageRequest.of(param.getNumber(), param.getSize());
         return iotThing2DeviceService.page(pageable, param);
     }
+
+
 }

+ 14 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/dao/iot/impl/IotThingDaoImpl.java

@@ -36,6 +36,7 @@ public class IotThingDaoImpl extends BaseImpl implements IotThingDaoExtend {
     @Override
     public Page<IotThing> page(Pageable pageable, IotThingSearch param) {
         Criteria criteria = buildFilterCriteria(param);
+
         Sort sort = buildSort(param);
         Query query = Query.query(criteria);
         query.with(sort);
@@ -45,6 +46,7 @@ public class IotThingDaoImpl extends BaseImpl implements IotThingDaoExtend {
     private Criteria buildFilterCriteria(IotThingSearch param) {
         Criteria criteria = buildCriteriaAboutTime(param);
 
+        // 自动、手动创建
         if (param.getThingType() != null) {
             criteria.and("thingType").is(param.getThingType());
         }
@@ -54,6 +56,7 @@ public class IotThingDaoImpl extends BaseImpl implements IotThingDaoExtend {
             criteria.and("projectCode").is(param.getProjectCode());
         }
 
+        // 所属模版id
         if (StringUtils.isNotEmpty(param.getIotTemplateId())) {
             criteria.and("iotTemplateId").is(param.getIotTemplateId());
         }
@@ -68,6 +71,17 @@ public class IotThingDaoImpl extends BaseImpl implements IotThingDaoExtend {
             criteria.and("productCode").is(param.getProductCode());
         }
 
+        // 产品分类
+        if (param.getDeviceType() != null) {
+            criteria.and("deviceTypes").is(List.of(param.getDeviceType()));
+        }
+
+        // 产品品类
+        if (param.getDeviceCategory() != null) {
+            criteria.and("deviceCategory").is(param.getDeviceCategory());
+        }
+
+        // 更新时间
         if (!CommonUtil.longIsEmpty(param.getStartUpdateTime()) && !CommonUtil.longIsEmpty(param.getEndUpdateTime())) {
             criteria.and("updateTime").gte(param.getStartUpdateTime()).lt(param.getEndUpdateTime());
         } else if (!CommonUtil.longIsEmpty(param.getStartUpdateTime()) && CommonUtil.longIsEmpty(param.getEndUpdateTime())) {

+ 1 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotPropertyService.java

@@ -53,6 +53,7 @@ public class IotPropertyService extends SuperService {
         PropertyResult result = new PropertyResult();
         result.setTime(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.FORMAT_LONG));
         PostPropertyParam param = JSONUtil.toBean(dataStr, PostPropertyParam.class);
+
         List<DevicePropertyParam> list = param.getList();
         if (ObjectUtils.isNotEmpty(list)) {
             for (DevicePropertyParam devicePropertyParam : list) {

+ 1 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/iot/IotThingService.java

@@ -194,6 +194,7 @@ public class IotThingService extends SuperService {
             param.setStartUpdateTime(startUpdateTime);
             param.setEndUpdateTime(endUpdateTime);
         }
+
         Page<IotThing> page = iotThingDao.page(pageable, param);
         return ResultContent.buildSuccess(PageEntityUtil.toPageModel(page, this::toModel));
     }

+ 21 - 0
OneCardIotServer/src/main/java/com/zhongshu/iot/server/core/service/openApi/iotThing/IotThingOpenService.java

@@ -0,0 +1,21 @@
+package com.zhongshu.iot.server.core.service.openApi.iotThing;
+
+import com.zhongshu.iot.server.core.dao.iot.IotThingDao;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+/**
+ *
+ * @author TRX
+ * @date 2025/3/13
+ */
+@Slf4j
+@Service
+public class IotThingOpenService {
+
+    @Autowired
+    private IotThingDao iotThingDao;
+
+
+}