소스 검색

更新!

TRX 1 년 전
부모
커밋
866dbc3c04
18개의 변경된 파일728개의 추가작업 그리고 7개의 파일을 삭제
  1. 2 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductBindDeviceBind.java
  2. 1 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductBindDeviceSearch.java
  3. 4 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductProvideServeModel.java
  4. 4 0
      FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductProvideServeParam.java
  5. 13 1
      FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductProvideServeSearch.java
  6. 70 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/deviceProduct/DeviceProductBindDeviceController.java
  7. 97 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/deviceProduct/DeviceProductController.java
  8. 70 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/deviceProduct/DeviceProductProvideServeController.java
  9. 13 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/DeviceProductBindDeviceDao.java
  10. 2 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/DeviceProductDao.java
  11. 7 2
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/DeviceProductProvideServeDao.java
  12. 21 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/extend/DeviceProductProvideServeDaoExtend.java
  13. 5 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/impl/DeviceProductBindDeviceDaoImpl.java
  14. 82 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/impl/DeviceProductProvideServeDaoImpl.java
  15. 4 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/devices/DeviceProductProvideServe.java
  16. 115 0
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/deviceProduct/DeviceProductBindDeviceService.java
  17. 98 2
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/deviceProduct/DeviceProductProvideServeService.java
  18. 120 1
      FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/deviceProduct/DeviceProductService.java

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

@@ -1,5 +1,6 @@
 package com.zhongshu.card.client.model.devices.deviceProduct;
 
+import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
 import lombok.Data;
 import lombok.NoArgsConstructor;
@@ -16,6 +17,7 @@ import java.util.List;
 @NoArgsConstructor
 public class DeviceProductBindDeviceBind {
 
+    @Schema(description = "产品名称")
     private String deviceProductId;
 
     private List<String> deviceIds = new ArrayList<>();

+ 1 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductBindDeviceSearch.java

@@ -16,6 +16,7 @@ import lombok.NoArgsConstructor;
 @AllArgsConstructor
 @NoArgsConstructor
 public class DeviceProductBindDeviceSearch extends SuperSearch {
+
     @Schema(description = "所属产品")
     private String deviceProductId;
 

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductProvideServeModel.java

@@ -8,6 +8,8 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author TRX
@@ -23,6 +25,8 @@ public class DeviceProductProvideServeModel extends SuperModel {
     @Schema(description = "服务名称")
     private String name;
 
+    private List<String> images = new ArrayList<>();
+
     @Schema(description = "价格")
     private BigDecimal price = BigDecimal.ZERO;
 

+ 4 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductProvideServeParam.java

@@ -8,6 +8,8 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author TRX
@@ -23,6 +25,8 @@ public class DeviceProductProvideServeParam extends SuperParam {
     @Schema(description = "服务名称")
     private String name;
 
+    private List<String> images = new ArrayList<>();
+
     @Schema(description = "价格")
     private BigDecimal price = BigDecimal.ZERO;
 

+ 13 - 1
FullCardClient/src/main/java/com/zhongshu/card/client/model/devices/deviceProduct/DeviceProductProvideServeSearch.java

@@ -1,6 +1,7 @@
 package com.zhongshu.card.client.model.devices.deviceProduct;
 
 import com.zhongshu.card.client.model.base.SuperParam;
+import com.zhongshu.card.client.model.base.SuperSearch;
 import com.zhongshu.card.client.type.DataState;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.AllArgsConstructor;
@@ -8,6 +9,8 @@ import lombok.Data;
 import lombok.NoArgsConstructor;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * @author TRX
@@ -16,8 +19,17 @@ import java.math.BigDecimal;
 @Data
 @AllArgsConstructor
 @NoArgsConstructor
-public class DeviceProductProvideServeSearch {
+public class DeviceProductProvideServeSearch extends SuperSearch {
 
     private String deviceProductId;
 
+    @Schema(description = "服务名称")
+    private String name;
+
+    @Schema(description = "价格")
+    private BigDecimal price;
+
+    @Schema(description = "状态")
+    private DataState state;
+
 }

+ 70 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/deviceProduct/DeviceProductBindDeviceController.java

@@ -0,0 +1,70 @@
+package com.zhongshu.card.server.core.controller.devices.deviceProduct;
+
+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.base.IDsParam;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductBindDeviceBind;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductBindDeviceModel;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductBindDeviceSearch;
+import com.zhongshu.card.server.core.service.devices.deviceProduct.DeviceProductBindDeviceService;
+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.data.web.PageableDefault;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 产品 绑定设备
+ *
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("/deviceProductBindDevice")
+@Tag(name = "产品管理-设备绑定")
+public class DeviceProductBindDeviceController {
+
+    @Autowired
+    private DeviceProductBindDeviceService deviceProductBindDeviceService;
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "绑定设备", description = "绑定设备")
+    @RequestMapping(value = "bindDevices", method = {RequestMethod.POST})
+    public ResultContent bindDevices(@RequestBody DeviceProductBindDeviceBind param) {
+        return this.deviceProductBindDeviceService.bindDevices(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除设备", description = "删除设备")
+    @RequestMapping(value = "deleteDeviceInfo", method = {RequestMethod.POST})
+    public ResultContent deleteDeviceInfo(@RequestBody IDParam param) {
+        return this.deviceProductBindDeviceService.deleteDeviceInfo(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除设备(多个)", description = "删除设备(多个)")
+    @RequestMapping(value = "deleteDevicesInfo", method = {RequestMethod.POST})
+    public ResultContent deleteDevicesInfo(@RequestBody IDsParam param) {
+        return this.deviceProductBindDeviceService.deleteDevicesInfo(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "设备数据列表-分页查询", description = "设备数据列表-分页查询")
+    @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
+    public ResultContent<Page<DeviceProductBindDeviceModel>> page(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) DeviceProductBindDeviceSearch param) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        return deviceProductBindDeviceService.page(param, pageable);
+    }
+
+}

+ 97 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/deviceProduct/DeviceProductController.java

@@ -0,0 +1,97 @@
+package com.zhongshu.card.server.core.controller.devices.deviceProduct;
+
+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.zhongshu.card.client.service.school.DeviceInfoService;
+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.data.web.PageableDefault;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.*;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * 项目 产品管理 (设备用的)
+ *
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("/deviceProduct")
+@Tag(name = "平台-设备的产品管理")
+public class DeviceProductController {
+
+    @Autowired
+    private DeviceInfoService deviceInfoService;
+
+    //----------------------------设备基础信息 start------------------------
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "根据设备数据ID 设备详情", description = "根据设备数据ID 设备详情")
+    @RequestMapping(value = "getDeviceById", method = {RequestMethod.POST})
+    public ResultContent<DeviceInfoMoreModel> getDeviceById(@RequestBody IDParam param) {
+        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 = "addDeviceInfo", method = {RequestMethod.POST})
+    public ResultContent addDeviceInfo(@RequestBody DeviceInfoParam param) {
+        return this.deviceInfoService.addDeviceInfo(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除设备", description = "删除设备")
+    @RequestMapping(value = "deleteDeviceInfo", method = {RequestMethod.POST})
+    public ResultContent deleteDeviceInfo(@RequestBody IDParam param) {
+        return this.deviceInfoService.deleteDeviceInfo(param.getId());
+    }
+
+    @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) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        return deviceInfoService.page(param, pageable);
+    }
+
+    @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) {
+        return deviceInfoService.busPage(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--------------------------
+
+}

+ 70 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/devices/deviceProduct/DeviceProductProvideServeController.java

@@ -0,0 +1,70 @@
+package com.zhongshu.card.server.core.controller.devices.deviceProduct;
+
+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.deviceProduct.DeviceProductProvideServeModel;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductProvideServeParam;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductProvideServeSearch;
+import com.zhongshu.card.server.core.service.devices.deviceProduct.DeviceProductProvideServeService;
+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.data.web.PageableDefault;
+import org.springframework.util.Assert;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * 产品  产品服务
+ *
+ * @author TRX
+ * @date 2024/6/5
+ */
+@RestController
+@RequestMapping("/deviceProductProvideServe")
+@Tag(name = "产品管理-产品服务")
+public class DeviceProductProvideServeController {
+
+    @Autowired
+    private DeviceProductProvideServeService deviceProductProvideServeService;
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "保存数据", description = "保存数据")
+    @RequestMapping(value = "saveInfo", method = {RequestMethod.POST})
+    public ResultContent saveInfo(@RequestBody DeviceProductProvideServeParam param) {
+        return this.deviceProductProvideServeService.saveInfo(param);
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "删除服务", description = "删除服务")
+    @RequestMapping(value = "deleteInfo", method = {RequestMethod.POST})
+    public ResultContent deleteInfo(@RequestBody IDParam param) {
+        return this.deviceProductProvideServeService.deleteInfo(param.getId());
+    }
+
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "服务数据列表-分页查询", description = "服务数据列表-分页查询")
+    @RequestMapping(value = {"page"}, method = {RequestMethod.POST})
+    public ResultContent<Page<DeviceProductProvideServeModel>> page(
+            @Parameter(hidden = true) @PageableDefault(page = 0, size = 10) Pageable pageable,
+            @Parameter(required = false) DeviceProductProvideServeSearch param) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        Assert.hasText(param.getDeviceProductId(), "deviceProductId不能为空");
+        return deviceProductProvideServeService.page(param, pageable);
+    }
+    
+    @ResourceAuth(value = "user", type = AuthType.User)
+    @Operation(summary = "服务详情", description = "服务详情")
+    @RequestMapping(value = "getDetailInfo", method = {RequestMethod.POST})
+    public ResultContent getDetailInfo(@RequestBody IDParam param) {
+        return this.deviceProductProvideServeService.getDetailInfo(param.getId());
+    }
+
+}

+ 13 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/DeviceProductBindDeviceDao.java

@@ -2,8 +2,11 @@ package com.zhongshu.card.server.core.dao.devices;
 
 import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
 import com.zhongshu.card.server.core.dao.devices.extend.DeviceProductBindDeviceDaoExtend;
+import com.zhongshu.card.server.core.domain.devices.DeviceProduct;
 import com.zhongshu.card.server.core.domain.devices.DeviceProductBindDevice;
 
+import java.util.List;
+
 /**
  * 设备Dao
  *
@@ -14,4 +17,14 @@ public interface DeviceProductBindDeviceDao extends MongoDao<DeviceProductBindDe
 
     DeviceProductBindDevice findTopById(String id);
 
+    DeviceProductBindDevice findTopByDeviceProductAndDeviceId(DeviceProduct deviceProduct, String deviceId);
+
+    List<DeviceProductBindDevice> findByIdIn(List<String> ids);
+
+    void deleteByDeviceProductId(String deviceProductId);
+
+    long countByDeviceProductId(String deviceProductId);
+
+    void deleteByDeviceProduct(DeviceProduct deviceProduct);
+
 }

+ 2 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/DeviceProductDao.java

@@ -1,7 +1,6 @@
 package com.zhongshu.card.server.core.dao.devices;
 
 import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
-import com.zhongshu.card.server.core.dao.devices.extend.DeviceInfoDaoExtend;
 import com.zhongshu.card.server.core.dao.devices.extend.DeviceProductDaoExtend;
 import com.zhongshu.card.server.core.domain.devices.DeviceProduct;
 
@@ -15,4 +14,6 @@ public interface DeviceProductDao extends MongoDao<DeviceProduct>, DeviceProduct
 
     DeviceProduct findTopById(String id);
 
+    DeviceProduct findTopByNameAndProjectOid(String name, String projectOid);
+
 }

+ 7 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/DeviceProductProvideServeDao.java

@@ -1,6 +1,8 @@
 package com.zhongshu.card.server.core.dao.devices;
 
 import com.github.microservice.components.data.mongo.mongo.dao.MongoDao;
+import com.zhongshu.card.server.core.dao.devices.extend.DeviceProductProvideServeDaoExtend;
+import com.zhongshu.card.server.core.domain.devices.DeviceProduct;
 import com.zhongshu.card.server.core.domain.devices.DeviceProductProvideServe;
 
 import java.util.List;
@@ -9,10 +11,13 @@ import java.util.List;
  * @author TRX
  * @date 2024/3/21
  */
-public interface DeviceProductProvideServeDao extends MongoDao<DeviceProductProvideServe> {
+public interface DeviceProductProvideServeDao extends MongoDao<DeviceProductProvideServe>, DeviceProductProvideServeDaoExtend {
 
     DeviceProductProvideServe findTopById(String id);
 
-    List<DeviceProductProvideServe> findByDeviceProductIdOrderBySortAsc(String deviceProductId);
+    void deleteByDeviceProductId(String deviceProductId);
 
+    long countByDeviceProductId(String deviceProductId);
+
+    void deleteByDeviceProduct(DeviceProduct deviceProduct);
 }

+ 21 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/extend/DeviceProductProvideServeDaoExtend.java

@@ -0,0 +1,21 @@
+package com.zhongshu.card.server.core.dao.devices.extend;
+
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductProvideServeSearch;
+import com.zhongshu.card.server.core.domain.devices.DeviceProductProvideServe;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+
+/**
+ * 设备管理
+ *
+ * @Author TRX
+ * @CreateDate: 2023/7/7
+ * @Version: 1.0
+ */
+public interface DeviceProductProvideServeDaoExtend {
+
+    Page<DeviceProductProvideServe> page(Pageable pageable, DeviceProductProvideServeSearch param);
+
+    long count(DeviceProductProvideServeSearch param);
+
+}

+ 5 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/impl/DeviceProductBindDeviceDaoImpl.java

@@ -13,6 +13,7 @@ import org.springframework.data.domain.Sort;
 import org.springframework.data.mongodb.core.MongoTemplate;
 import org.springframework.data.mongodb.core.query.Criteria;
 import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.util.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -84,6 +85,10 @@ public class DeviceProductBindDeviceDaoImpl extends BaseImpl implements DevicePr
             Pattern pattern = Pattern.compile("^.*" + param.getDeviceName() + ".*$");
             criterias.add(Criteria.where("deviceName").is(pattern));
         }
+
+        if (!CollectionUtils.isEmpty(criterias)) {
+            criteria.andOperator(criterias.toArray(new Criteria[]{}));
+        }
         return criteria;
     }
 

+ 82 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/dao/devices/impl/DeviceProductProvideServeDaoImpl.java

@@ -0,0 +1,82 @@
+package com.zhongshu.card.server.core.dao.devices.impl;
+
+import com.github.microservice.components.data.mongo.mongo.helper.DBHelper;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductProvideServeSearch;
+import com.zhongshu.card.server.core.dao.BaseImpl;
+import com.zhongshu.card.server.core.dao.devices.extend.DeviceProductProvideServeDaoExtend;
+import com.zhongshu.card.server.core.domain.devices.DeviceProductProvideServe;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
+import org.springframework.data.domain.Sort;
+import org.springframework.data.mongodb.core.MongoTemplate;
+import org.springframework.data.mongodb.core.query.Criteria;
+import org.springframework.data.mongodb.core.query.Query;
+import org.springframework.util.CollectionUtils;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * @Author TRX
+ * @CreateDate: 2023/4/12
+ * @Version: 1.0
+ */
+public class DeviceProductProvideServeDaoImpl extends BaseImpl implements DeviceProductProvideServeDaoExtend {
+
+    @Autowired
+    private MongoTemplate mongoTemplate;
+
+    @Autowired
+    private DBHelper dbHelper;
+
+    @Override
+    public Page<DeviceProductProvideServe> page(Pageable pageable, DeviceProductProvideServeSearch param) {
+        Criteria criteria = buildFilterCriteria(param);
+
+        Sort sort = buildSort(param);
+        Query query = Query.query(criteria);
+        query.with(sort);
+        return dbHelper.pages(query, pageable, DeviceProductProvideServe.class);
+    }
+
+    @Override
+    public long count(DeviceProductProvideServeSearch param) {
+        Criteria criteria = buildFilterCriteria(param);
+
+        Query query = Query.query(criteria);
+        return mongoTemplate.count(query, DeviceProductProvideServe.class);
+    }
+
+    public Criteria buildFilterCriteria(DeviceProductProvideServeSearch param) {
+        param.setOid("");
+        Criteria criteria = buildCriteria(param);
+        // 项目oid
+        if (StringUtils.isNotEmpty(param.getProjectOid())) {
+            criteria.and("projectOid").is(param.getProjectOid());
+        }
+
+        if (StringUtils.isNotEmpty(param.getDeviceProductId())) {
+            criteria.and("deviceProductId").is(param.getDeviceProductId());
+        }
+
+        if (param.getState() != null) {
+            criteria.and("state").is(param.getState());
+        }
+
+        // 模糊搜索
+        List<Criteria> criterias = new ArrayList<>();
+
+        if (StringUtils.isNotEmpty(param.getName())) {
+            Pattern pattern = Pattern.compile("^.*" + param.getName() + ".*$");
+            criterias.add(Criteria.where("name").is(pattern));
+        }
+        if (!CollectionUtils.isEmpty(criterias)) {
+            criteria.andOperator(criterias.toArray(new Criteria[]{}));
+        }
+        return criteria;
+    }
+
+}

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

@@ -10,6 +10,8 @@ import org.springframework.data.mongodb.core.mapping.DBRef;
 import org.springframework.data.mongodb.core.mapping.Document;
 
 import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.List;
 
 /**
  * 产品可提供的服务
@@ -33,6 +35,8 @@ public class DeviceProductProvideServe extends SuperMain {
     @Schema(description = "服务名称")
     private String name;
 
+    private List<String> images = new ArrayList<>();
+
     @Schema(description = "价格")
     private BigDecimal price = BigDecimal.ZERO;
 

+ 115 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/deviceProduct/DeviceProductBindDeviceService.java

@@ -1,14 +1,33 @@
 package com.zhongshu.card.server.core.service.devices.deviceProduct;
 
+import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.github.microservice.net.ResultContent;
+import com.github.microservice.net.ResultMessage;
+import com.zhongshu.card.client.model.base.IDsParam;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductBindDeviceBind;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductBindDeviceModel;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductBindDeviceSearch;
 import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
 import com.zhongshu.card.server.core.dao.devices.DeviceProductBindDeviceDao;
 import com.zhongshu.card.server.core.dao.devices.DeviceProductDao;
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.domain.devices.DeviceInfo;
+import com.zhongshu.card.server.core.domain.devices.DeviceProduct;
+import com.zhongshu.card.server.core.domain.devices.DeviceProductBindDevice;
+import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.devices.DeviceInfoServiceImpl;
+import com.zhongshu.card.server.core.util.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
+import java.util.ArrayList;
+import java.util.List;
+
 /**
  * @author TRX
  * @date 2025/1/8
@@ -26,4 +45,100 @@ public class DeviceProductBindDeviceService extends SuperService {
     @Autowired
     private DeviceInfoDao deviceInfoDao;
 
+    @Autowired
+    private DeviceProductService deviceProductService;
+
+    @Autowired
+    private OrganizationDao organizationDao;
+
+    @Autowired
+    private DeviceInfoServiceImpl deviceInfoService;
+
+    public ResultContent bindDevices(DeviceProductBindDeviceBind param) {
+        DeviceProduct deviceProduct = deviceProductDao.findTopById(param.getDeviceProductId());
+        if (ObjectUtils.isEmpty(deviceProduct)) {
+            return ResultContent.buildFail("产品不存在");
+        }
+        if (ObjectUtils.isEmpty(param.getDeviceIds())) {
+            return ResultContent.buildFail("设备信息为空");
+        }
+        List<DeviceInfo> list = deviceInfoDao.findByDeviceIdIn(param.getDeviceIds());
+        if (ObjectUtils.isEmpty(list)) {
+            return ResultContent.buildFail("未查询到设备");
+        }
+        if (ObjectUtils.isNotEmpty(list)) {
+            List<DeviceProductBindDevice> saveList = new ArrayList<>();
+            for (DeviceInfo deviceInfo : list) {
+                DeviceProductBindDevice deviceProductBindDevice = deviceProductBindDeviceDao.findTopByDeviceProductAndDeviceId(deviceProduct, deviceInfo.getDeviceId());
+                if (ObjectUtils.isEmpty(deviceProductBindDevice)) {
+                    deviceProductBindDevice = new DeviceProductBindDevice();
+                    deviceProductBindDevice.setDeviceProduct(deviceProduct);
+                    deviceProductBindDevice.setDeviceProductId(deviceProduct.getId());
+                    deviceProductBindDevice.setDeviceInfo(deviceInfo);
+
+                    deviceProductBindDevice.setProjectOid(deviceProduct.getProjectOid());
+                    deviceProductBindDevice.setDeviceId(deviceInfo.getDeviceId());
+                    initEntity(deviceProductBindDevice);
+                } else {
+                    deviceProductBindDevice.setDeviceName(deviceInfo.getDeviceName());
+                    deviceProductBindDevice.setDeviceType(deviceInfo.getDeviceType());
+                    deviceProductBindDevice.setDeviceModel(deviceInfo.getDeviceModel());
+                }
+                saveList.add(deviceProductBindDevice);
+            }
+            if (ObjectUtils.isNotEmpty(saveList)) {
+                deviceProductBindDeviceDao.saveAll(saveList);
+                deviceProductService.updateNumber(deviceProduct);
+            }
+        }
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent deleteDeviceInfo(String id) {
+        DeviceProductBindDevice entity = deviceProductBindDeviceDao.findTopById(id);
+        if (ObjectUtils.isEmpty(entity)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        deviceProductBindDeviceDao.delete(entity);
+        deviceProductService.updateNumber(entity.getDeviceProduct());
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent deleteDevicesInfo(IDsParam param) {
+        if (ObjectUtils.isEmpty(param.getIds())) {
+            return ResultContent.buildFail("ids不能为空");
+        }
+        List<DeviceProductBindDevice> list = deviceProductBindDeviceDao.findByIdIn(param.getIds());
+        if (ObjectUtils.isEmpty(list)) {
+            return ResultContent.buildFail("数据不存在");
+        }
+        deviceProductBindDeviceDao.deleteAllById(param.getIds());
+        List<DeviceProduct> deviceProducts = new ArrayList<>();
+        list.stream().forEach(it -> {
+            deviceProducts.add(it.getDeviceProduct());
+        });
+        deviceProducts.stream().forEach(it -> {
+            deviceProductService.updateNumber(it);
+        });
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent<Page<DeviceProductBindDeviceModel>> page(DeviceProductBindDeviceSearch param, Pageable pageable) {
+        String projectOid = param.getProjectOid();
+        Organization organization = organizationDao.findTopByOid(projectOid);
+        if (ObjectUtils.isEmpty(organization)) {
+            return ResultContent.buildFail("projectOid不存在");
+        }
+        Page<DeviceProductBindDevice> page = deviceProductBindDeviceDao.page(pageable, param);
+        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
+
+    private DeviceProductBindDeviceModel toModel(DeviceProductBindDevice entity) {
+        DeviceProductBindDeviceModel model = new DeviceProductBindDeviceModel();
+        if (ObjectUtils.isNotEmpty(entity)) {
+            BeanUtils.copyProperties(entity, model);
+            model.setDeviceInfo(deviceInfoService.toModel(entity.getDeviceInfo()));
+        }
+        return model;
+    }
 }

+ 98 - 2
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/devices/deviceProduct/DeviceProductProvideServeService.java

@@ -1,12 +1,29 @@
 package com.zhongshu.card.server.core.service.devices.deviceProduct;
 
-import com.zhongshu.card.server.core.dao.devices.DeviceInfoDao;
+import com.github.microservice.components.data.base.util.PageEntityUtil;
+import com.github.microservice.net.ResultContent;
+import com.github.microservice.net.ResultMessage;
+import com.zhongshu.card.client.model.devices.deviceGroup.DeviceGroupModel;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductProvideServeModel;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductProvideServeParam;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductProvideServeSearch;
+import com.zhongshu.card.client.type.DataState;
 import com.zhongshu.card.server.core.dao.devices.DeviceProductDao;
 import com.zhongshu.card.server.core.dao.devices.DeviceProductProvideServeDao;
+import com.zhongshu.card.server.core.dao.org.OrganizationDao;
+import com.zhongshu.card.server.core.domain.devices.DeviceProduct;
+import com.zhongshu.card.server.core.domain.devices.DeviceProductProvideServe;
+import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.util.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
 
 /**
  * @author TRX
@@ -23,7 +40,86 @@ public class DeviceProductProvideServeService extends SuperService {
     private DeviceProductProvideServeDao deviceProductProvideServeDao;
 
     @Autowired
-    private DeviceInfoDao deviceInfoDao;
+    private OrganizationDao organizationDao;
 
+    @Autowired
+    private DeviceProductService deviceProductService;
+
+    public ResultContent saveInfo(DeviceProductProvideServeParam param) {
+        Assert.hasText(param.getProjectOid(), "projectOid不能为空");
+        DeviceProduct deviceProduct = deviceProductDao.findTopById(param.getDeviceProductId());
+        if (ObjectUtils.isEmpty(deviceProduct)) {
+            return ResultContent.buildFail("产品不存在");
+        }
+
+        DeviceProductProvideServe entity = null;
+        if (StringUtils.isNotEmpty(param.getId())) {
+            entity = deviceProductProvideServeDao.findTopById(param.getId());
+            if (ObjectUtils.isEmpty(entity)) {
+                return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, param.getId()));
+            }
+            initUpdateEntity(entity);
+        } else {
+            entity = new DeviceProductProvideServe();
+            initEntityNoCheckOid(entity);
+        }
+        BeanUtils.copyProperties(param, entity);
+        entity.setDeviceProduct(deviceProduct);
+        entity.setDeviceProductId(deviceProduct.getId());
+        deviceProductProvideServeDao.save(entity);
+        deviceProductService.updateNumber(deviceProduct);
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent<Page<DeviceProductProvideServeModel>> page(DeviceProductProvideServeSearch param, Pageable pageable) {
+        String projectOid = param.getProjectOid();
+        Organization organization = organizationDao.findTopByOid(projectOid);
+        if (ObjectUtils.isEmpty(organization)) {
+            return ResultContent.buildFail("projectOid不存在");
+        }
+        Page<DeviceProductProvideServe> page = deviceProductProvideServeDao.page(pageable, param);
+        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
+
+    /**
+     * 删除服务
+     *
+     * @param id
+     * @return
+     */
+    public ResultContent deleteInfo(String id) {
+        DeviceProductProvideServe entity = deviceProductProvideServeDao.findTopById(id);
+        if (ObjectUtils.isEmpty(entity)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        deviceProductProvideServeDao.delete(entity);
+        deviceProductService.updateNumber(entity.getDeviceProduct());
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent<DeviceGroupModel> getDetailInfo(String id) {
+        DeviceProductProvideServe entity = deviceProductProvideServeDao.findTopById(id);
+        if (ObjectUtils.isEmpty(entity)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        return ResultContent.buildSuccess(toModel(entity));
+    }
+
+    public ResultContent changeState(String id, DataState state) {
+        DeviceProductProvideServe entity = deviceProductProvideServeDao.findTopById(id);
+        if (ObjectUtils.isEmpty(entity)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        entity.setState(state);
+        deviceProductProvideServeDao.save(entity);
+        return ResultContent.buildSuccess();
+    }
 
+    public DeviceProductProvideServeModel toModel(DeviceProductProvideServe entity) {
+        DeviceProductProvideServeModel model = new DeviceProductProvideServeModel();
+        if (ObjectUtils.isNotEmpty(entity)) {
+            BeanUtils.copyProperties(entity, model);
+        }
+        return model;
+    }
 }

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

@@ -1,16 +1,27 @@
 package com.zhongshu.card.server.core.service.devices.deviceProduct;
 
+import com.github.microservice.components.data.base.util.PageEntityUtil;
 import com.github.microservice.net.ResultContent;
+import com.github.microservice.net.ResultMessage;
 import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductModel;
 import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductParam;
+import com.zhongshu.card.client.model.devices.deviceProduct.DeviceProductSearch;
+import com.zhongshu.card.client.model.org.OrganizationSimpleModel;
+import com.zhongshu.card.server.core.dao.devices.DeviceProductBindDeviceDao;
 import com.zhongshu.card.server.core.dao.devices.DeviceProductDao;
+import com.zhongshu.card.server.core.dao.devices.DeviceProductProvideServeDao;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
 import com.zhongshu.card.server.core.domain.devices.DeviceProduct;
+import com.zhongshu.card.server.core.domain.org.Organization;
 import com.zhongshu.card.server.core.service.base.SuperService;
+import com.zhongshu.card.server.core.service.org.OrganizationServiceImpl;
 import com.zhongshu.card.server.core.util.BeanUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.data.domain.Page;
+import org.springframework.data.domain.Pageable;
 import org.springframework.stereotype.Service;
 
 /**
@@ -24,12 +35,115 @@ public class DeviceProductService extends SuperService {
     @Autowired
     private DeviceProductDao deviceProductDao;
 
+    @Autowired
+    private DeviceProductBindDeviceDao deviceProductBindDeviceDao;
+
+    @Autowired
+    private DeviceProductProvideServeDao deviceProductProvideServeDao;
+
     @Autowired
     private OrganizationDao organizationDao;
 
+    @Autowired
+    private OrganizationServiceImpl organizationService;
+
     public ResultContent saveInfo(DeviceProductParam param) {
+        if (StringUtils.isNotEmpty(param.getProjectOid())) {
+            return ResultContent.buildFail("projectOid不能为空");
+        }
+
+        Organization organization = null;
+        if (StringUtils.isNotEmpty(param.getBeLongOid())) {
+            organization = organizationDao.findTopByOid(param.getBeLongOid());
+            if (ObjectUtils.isEmpty(organization)) {
+                return ResultContent.buildFail("所属机构不存在");
+            }
+        }
+
+        DeviceProduct product = null;
+        DeviceProduct nameTemp = deviceProductDao.findTopByNameAndProjectOid(param.getName(), param.getProjectOid());
+        if (StringUtils.isNotEmpty(param.getId())) {
+            product = deviceProductDao.findTopById(param.getId());
+            if (ObjectUtils.isEmpty(product)) {
+                return ResultContent.buildFail("数据不存在");
+            }
+            if (ObjectUtils.isNotEmpty(nameTemp) && !nameTemp.getId().equals(product.getId())) {
+                return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, product.getName()));
+            }
+            initUpdateEntity(product);
+        } else {
+            if (ObjectUtils.isNotEmpty(nameTemp)) {
+                return ResultContent.buildFail(String.format(ResultMessage.NAME_EXIST, product.getName()));
+            }
+            product = new DeviceProduct();
+            initEntityNoCheckOid(product);
+        }
+        BeanUtils.copyProperties(param, product);
+        product.setOid(param.getProjectOid());
+
+        product.setOrganization(organization);
+        product.setBeLongOid(organization.getOid());
+        product.setBeLongName(organization.getName());
+        deviceProductDao.save(product);
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent<Page<DeviceProductModel>> page(DeviceProductSearch param, Pageable pageable) {
+        // 完善所属项目
+        String projectOid = param.getProjectOid();
+        if (StringUtils.isNotEmpty(projectOid)) {
+            Organization organization = organizationDao.findTopByOid(projectOid);
+            if (ObjectUtils.isEmpty(organization)) {
+                return ResultContent.buildFail("projectOid不存在");
+            }
+        }
+        Page<DeviceProduct> page = deviceProductDao.page(pageable, param);
+        return ResultContent.buildSuccess(PageEntityUtil.concurrent2PageModel(page, this::toModel));
+    }
 
+    public ResultContent<DeviceProductModel> getInfo(String id) {
+        DeviceProduct entity = deviceProductDao.findTopById(id);
+        if (ObjectUtils.isEmpty(entity)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        DeviceProductModel model = toModel(entity);
+        return ResultContent.buildSuccess(model);
+    }
 
+    public ResultContent deleteInfo(String id) {
+        DeviceProduct entity = deviceProductDao.findTopById(id);
+        if (ObjectUtils.isEmpty(entity)) {
+            return ResultContent.buildFail(String.format(ResultMessage.DATA_NOT_EXIST, id));
+        }
+        deviceProductDao.delete(entity);
+        deviceProductBindDeviceDao.deleteByDeviceProductId(id);
+        deviceProductProvideServeDao.deleteByDeviceProductId(id);
+        return ResultContent.buildSuccess();
+    }
+
+    /**
+     * 更新数量
+     *
+     * @param id
+     * @return
+     */
+    public ResultContent updateNumber(String id) {
+        if (StringUtils.isNotEmpty(id)) {
+            DeviceProduct entity = deviceProductDao.findTopById(id);
+            updateNumber(entity);
+        }
+        return ResultContent.buildSuccess();
+    }
+
+    public ResultContent updateNumber(DeviceProduct entity) {
+        if (ObjectUtils.isNotEmpty(entity)) {
+            String id = entity.getId();
+            Long number = deviceProductBindDeviceDao.countByDeviceProductId(id);
+            Long serviceNumber = deviceProductProvideServeDao.countByDeviceProductId(id);
+            entity.setNumber(number);
+            entity.setServiceNumber(serviceNumber);
+            deviceProductDao.save(entity);
+        }
         return ResultContent.buildSuccess();
     }
 
@@ -38,7 +152,12 @@ public class DeviceProductService extends SuperService {
         if (ObjectUtils.isNotEmpty(entity)) {
             BeanUtils.copyProperties(entity, model);
 
-
+            OrganizationSimpleModel simpleModel = organizationService.toSimpleModel(entity.getOrganization());
+            if (ObjectUtils.isNotEmpty(simpleModel)) {
+                model.setBeLongOid(simpleModel.getOid());
+                model.setBeLongName(simpleModel.getName());
+            }
+            model.setOrganization(simpleModel);
         }
         return model;
     }