Ver Fonte

提交修改pom

chenxiaofei há 3 meses atrás
pai
commit
f095c4d3d2

+ 10 - 5
iot-platform-common/src/main/java/com/platform/request/PageRequest.java

@@ -2,16 +2,21 @@ package com.platform.request;
 
 import lombok.Data;
 
+import java.io.Serial;
+import java.io.Serializable;
+
 
 /**
  * @author PC
  */
 @Data
-public class PageRequest {
-	/**
-	 * 当前页码
-	 */
-	private int page = 1;
+public class PageRequest implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 1513010094486554750L;
+    /**
+     * 当前页码
+     */
+    private int current = 1;
 	/**
 	 * 每页数量
 	 */

+ 64 - 0
iot-platform-manager/src/main/java/com/platform/controller/IotDeviceGroupController.java

@@ -0,0 +1,64 @@
+package com.platform.controller;
+
+import com.platform.manage.IotDeviceGroupManage;
+import com.platform.request.device.DeviceGroupDetailReq;
+import com.platform.request.deviceGroup.IotDeviceGroupRequest;
+import com.platform.response.deviceGroup.DeviceGroupPageResp;
+import com.platform.response.deviceGroup.DeviceGroupDetailResp;
+import com.platform.result.HttpResult;
+import lombok.RequiredArgsConstructor;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+/**
+ * 物联网设备管理控制器
+ * @author PC
+ */
+@RestController
+@RequestMapping("/iot/device/group")
+@RequiredArgsConstructor
+@Validated
+public class IotDeviceGroupController {
+
+    private final IotDeviceGroupManage iotDeviceGroupManage;
+
+    /**
+     * 添加物联网设备
+     */
+    @PostMapping("/addDeviceGroup")
+    public HttpResult<Boolean> addDeviceGroup(@RequestBody IotDeviceGroupRequest request) {
+        return HttpResult.success(iotDeviceGroupManage.addDeviceGroup(request));
+    }
+
+    /**
+     * 修改物联网设备
+     */
+    @PostMapping("/updateDeviceGroup")
+    public HttpResult<Boolean> updateDeviceGroup(@RequestBody IotDeviceGroupRequest request) {
+        return HttpResult.success(iotDeviceGroupManage.updateDeviceGroup(request));
+    }
+
+    /**
+     * 删除物联网设备
+     */
+    @GetMapping("/delDeviceGroup")
+    public HttpResult<Boolean> delDeviceGroup(@RequestParam("deviceGroupCode") String deviceGroupCode) {
+        return HttpResult.success(iotDeviceGroupManage.delDeviceGroup(deviceGroupCode));
+    }
+
+
+    /**
+     * 物联设备详情查询
+     */
+    @PostMapping("/getDeviceGroupDetail")
+    public HttpResult<DeviceGroupDetailResp> getDeviceGroupDetail(@RequestBody DeviceGroupDetailReq req) {
+        return HttpResult.success(iotDeviceGroupManage.getDeviceGroupDetail(req));
+    }
+    /**
+     * 分页查询物联设备
+     */
+    @PostMapping("/pageGroupDevice")
+    public HttpResult<DeviceGroupPageResp> pageGroupDevice(@RequestBody DeviceGroupDetailReq req) {
+        return HttpResult.success(iotDeviceGroupManage.pageGroupDevice(req));
+    }
+}

+ 15 - 0
iot-platform-manager/src/main/java/com/platform/entity/IotDeviceGroup.java

@@ -1,6 +1,7 @@
 package com.platform.entity;
 
 import com.baomidou.mybatisplus.annotation.*;
+import com.platform.request.deviceGroup.IotDeviceGroupRequest;
 import lombok.Data;
 import java.time.LocalDateTime;
 
@@ -77,4 +78,18 @@ public class IotDeviceGroup {
      */
     @TableField("update_user")
     private String updateUser;
+
+    public static IotDeviceGroup getInstance(){
+        return new IotDeviceGroup();
+    }
+    public static IotDeviceGroup toIotDeviceGroup(IotDeviceGroupRequest request){
+        IotDeviceGroup instance = IotDeviceGroup.getInstance();
+        instance.setId(request.getId());
+        instance.setDeviceGroupCode(request.getDeviceGroupCode());
+        instance.setTenantId(request.getTenantId());
+        instance.setCompanyId(request.getCompanyId());
+        instance.setTitle(request.getTitle());
+        instance.setLargeType(request.getLargeType());
+        return instance;
+    }
 }

+ 65 - 0
iot-platform-manager/src/main/java/com/platform/manage/IotDeviceGroupManage.java

@@ -0,0 +1,65 @@
+package com.platform.manage;
+
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.platform.entity.IotDeviceGroup;
+import com.platform.exception.BusinessException;
+import com.platform.request.device.DeviceGroupDetailReq;
+import com.platform.request.deviceGroup.IotDeviceGroupRequest;
+import com.platform.response.deviceGroup.DeviceGroupPageResp;
+import com.platform.response.deviceGroup.DeviceGroupDetailResp;
+import com.platform.service.IotDeviceGroupService;
+import lombok.RequiredArgsConstructor;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.Objects;
+
+
+/**
+ * @author PC
+ */
+@Service
+@RequiredArgsConstructor
+public class IotDeviceGroupManage {
+    private final IotDeviceGroupService iotDeviceGroupService;
+    public Boolean addDeviceGroup(IotDeviceGroupRequest request) {
+        IotDeviceGroup oneByName = iotDeviceGroupService.getOneByTitle(request.getTitle());
+        if (Objects.nonNull(oneByName)){
+            throw new BusinessException("设备分组名称已存在");
+        }
+        IotDeviceGroup iotDeviceGroup = IotDeviceGroup.toIotDeviceGroup(request);
+        return iotDeviceGroupService.addDeviceGroup(iotDeviceGroup);
+    }
+
+    public Boolean updateDeviceGroup(IotDeviceGroupRequest request) {
+        if (StringUtils.isBlank(request.getDeviceGroupCode())){
+            throw new BusinessException("设备分组码值不能为空");
+        }
+        IotDeviceGroup iotDeviceGroup = IotDeviceGroup.toIotDeviceGroup(request);
+        return iotDeviceGroupService.updateDeviceGroup(iotDeviceGroup);
+    }
+
+    public Boolean delDeviceGroup(String deviceGroupCode) {
+        if (StringUtils.isBlank(deviceGroupCode)){
+            throw new BusinessException("设备分组码值不能为空");
+        }
+        return iotDeviceGroupService.delDeviceGroup(deviceGroupCode);
+    }
+
+    public DeviceGroupDetailResp getDeviceGroupDetail(DeviceGroupDetailReq req) {
+        //todo 设置参数
+        IotDeviceGroup iotDeviceGroup = new IotDeviceGroup();
+        IotDeviceGroup iotGroupDetail= iotDeviceGroupService.getDeviceGroupDetail(iotDeviceGroup);
+        if (Objects.nonNull(iotGroupDetail)){
+            return DeviceGroupDetailResp.toDeviceGroupDetailResp(iotGroupDetail);
+        }
+        return DeviceGroupDetailResp.getInstance();
+    }
+
+    public DeviceGroupPageResp pageGroupDevice(DeviceGroupDetailReq req) {
+        //todo 设置参数
+        IotDeviceGroup iotDeviceGroup = new IotDeviceGroup();
+        Page page = iotDeviceGroupService.pageGroupDevice(req.getCurrent(),req.getPageSize(),iotDeviceGroup);
+        return null;
+    }
+}

+ 0 - 12
iot-platform-manager/src/main/java/com/platform/request/Demo.java

@@ -1,12 +0,0 @@
-package com.platform.request;
-
-/**
- * @Author: 马超伟
- * @CreateTime: 2025-10-09
- * @Description:
- * @Version: 1.0
- */
-
-
-public class Demo {
-}

+ 26 - 0
iot-platform-manager/src/main/java/com/platform/request/device/DeviceGroupDetailReq.java

@@ -0,0 +1,26 @@
+package com.platform.request.device;
+
+import com.platform.request.PageRequest;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+
+/**
+ * @Author: 马超伟
+ * @CreateTime: 2025-10-09
+ * @Description:
+ * @Version: 1.0
+ */
+
+
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class DeviceGroupDetailReq extends PageRequest {
+    @Serial
+    private static final long serialVersionUID = -4283288286780625958L;
+    /**
+     * 设备分组码值
+     */
+    private String deviceGroupCode;
+}

+ 84 - 0
iot-platform-manager/src/main/java/com/platform/request/deviceGroup/IotDeviceGroupRequest.java

@@ -0,0 +1,84 @@
+package com.platform.request.deviceGroup;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+/**
+ * 设备分组表实体类
+ * @author cxf
+ */
+@Data
+public class IotDeviceGroupRequest implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 5529931062653486264L;
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 设备分组码值
+     */
+
+    private String deviceGroupCode;
+
+    /**
+     * 租户id
+     */
+
+    private String tenantId;
+
+    /**
+     * 所属客户id
+     */
+
+    private Long companyId;
+
+    /**
+     * 设备分组名称
+     */
+
+    private String title;
+
+    /**
+     * [有点晕?]1-12(车辆、装载机、矿卡、人员、水表、电表、边坡监控、视频监控、皮带称重、环境监测、无人地磅、排放监测)
+     */
+
+    private Integer largeType;
+
+    /**
+     * 0-未删除,1-删除
+     */
+
+    private Integer delFlag;
+
+    /**
+     * 创建时间
+     */
+
+    private LocalDateTime createTime;
+
+    /**
+     * 更新时间
+     */
+
+    private LocalDateTime updateTime;
+
+    /**
+     * 创建人
+     */
+
+    private String createUser;
+
+    /**
+     * 更新人
+     */
+    private String updateUser;
+}

+ 0 - 12
iot-platform-manager/src/main/java/com/platform/response/Demo.java

@@ -1,12 +0,0 @@
-package com.platform.response;
-
-/**
- * @Author: 马超伟
- * @CreateTime: 2025-10-09
- * @Description:
- * @Version: 1.0
- */
-
-
-public class Demo {
-}

+ 103 - 0
iot-platform-manager/src/main/java/com/platform/response/deviceGroup/DeviceGroupDetailResp.java

@@ -0,0 +1,103 @@
+package com.platform.response.deviceGroup;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.platform.entity.IotDevice;
+import com.platform.entity.IotDeviceGroup;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.time.LocalDateTime;
+
+
+
+
+/**
+ * @author PC
+ */
+@Data
+public class DeviceGroupDetailResp implements Serializable {
+
+
+    @Serial
+    private static final long serialVersionUID = -3891584296778137376L;
+    /**
+     * 主键ID
+     */
+    private Long id;
+
+    /**
+     * 设备分组码值
+     */
+    private String deviceGroupCode;
+
+    /**
+     * 租户id
+     */
+    private String tenantId;
+
+    /**
+     * 所属客户id
+     */
+
+    private Long companyId;
+
+    /**
+     * 设备分组名称
+     */
+
+    private String title;
+
+    /**
+     * [有点晕?]1-12(车辆、装载机、矿卡、人员、水表、电表、边坡监控、视频监控、皮带称重、环境监测、无人地磅、排放监测)
+     */
+    private Integer largeType;
+
+    /**
+     * 0-未删除,1-删除
+     */
+    private Integer delFlag;
+
+    /**
+     * 创建时间
+     */
+    private String createTime;
+
+    /**
+     * 更新时间
+     */
+
+    private String updateTime;
+
+    /**
+     * 创建人
+     */
+    private String createUser;
+
+    /**
+     * 更新人
+     */
+    private String updateUser;
+
+    public static DeviceGroupDetailResp getInstance(){
+        return new DeviceGroupDetailResp();
+    }
+
+    public static DeviceGroupDetailResp toDeviceGroupDetailResp(IotDeviceGroup iotDeviceGroup) {
+        DeviceGroupDetailResp instance = DeviceGroupDetailResp.getInstance();
+        instance.setId(iotDeviceGroup.getId());
+        instance.setDeviceGroupCode(iotDeviceGroup.getDeviceGroupCode());
+        instance.setTenantId(iotDeviceGroup.getTenantId());
+        instance.setCompanyId(iotDeviceGroup.getCompanyId());
+        instance.setTitle(iotDeviceGroup.getTitle());
+        instance.setLargeType(iotDeviceGroup.getLargeType());
+        instance.setDelFlag(iotDeviceGroup.getDelFlag());
+        instance.setCreateTime("");
+        instance.setUpdateTime("");
+        instance.setCreateUser(iotDeviceGroup.getCreateUser());
+        instance.setUpdateUser(iotDeviceGroup.getUpdateUser());
+        return instance;
+    }
+}

+ 127 - 0
iot-platform-manager/src/main/java/com/platform/response/deviceGroup/DeviceGroupPageResp.java

@@ -0,0 +1,127 @@
+package com.platform.response.deviceGroup;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * @Author: 马超伟
+ * @CreateTime: 2025-10-09
+ * @Description:
+ * @Version: 1.0
+ */
+
+
+@Data
+public class DeviceGroupPageResp implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 4129323442919345144L;
+
+
+    private Long id;
+
+    /**
+     * 租户id
+     */
+    private String tenantId;
+
+    /**
+     * 所属客户id
+     */
+    private Long companyId;
+
+    /**
+     * 唯一标识[暂时保留]
+     */
+    private String guid;
+
+    /**
+     * 设备编号
+     */
+    private String deviceCode;
+
+    /**
+     * sn通常是:IMEI
+     */
+    private String sn;
+
+    /**
+     * 物联网模型码值
+     */
+    private String modCode;
+
+    /**
+     * 物联网模型名称
+     */
+    private String modName;
+
+    /**
+     * 设备名称[旧系统的title]
+     */
+    private String deviceName;
+
+    /**
+     * 设备品牌名称
+     */
+
+    private String brand;
+
+    /**
+     * 型号
+     */
+
+    private String modelCode;
+
+    /**
+     * 最后一次设备更新信息值[旧系统的desc]
+     */
+    private String description;
+
+    /**
+     * 备注
+     */
+    private String remarks;
+
+    /**
+     * 1在线2离线3异常
+     */
+    private Integer status;
+
+    /**
+     * 经度[lng]
+     */
+    private String longitude;
+
+    /**
+     * 纬度[lat]
+     */
+    private String latitude;
+
+    /**
+     * 高度
+     */
+    private String high;
+
+
+    /**
+     * 创建人
+     */
+    private String createUser;
+
+    /**
+     * 更新人
+     */
+    private String updateUser;
+
+    /**
+     * 0-未删除,1-删除
+     */
+    private Integer delFlag;
+
+    /**
+     * 设备类别
+     */
+    private Long egId;
+}

+ 39 - 0
iot-platform-manager/src/main/java/com/platform/service/IotDeviceGroupService.java

@@ -1,5 +1,6 @@
 package com.platform.service;
 
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.platform.entity.IotDeviceGroup;
 
@@ -12,4 +13,42 @@ import com.platform.entity.IotDeviceGroup;
 
 
 public interface IotDeviceGroupService extends IService<IotDeviceGroup> {
+    IotDeviceGroup getOneByTitle(String title);
+
+    /**
+     *  添加物联设备分组
+     * @param iotDeviceGroup 设备分组信息
+     * @return 结果
+     */
+    Boolean addDeviceGroup(IotDeviceGroup iotDeviceGroup);
+
+    /**
+     *  修改物联设备分组
+     * @param iotDeviceGroup 设备分组信息
+     * @return 修改结果
+     */
+    Boolean updateDeviceGroup(IotDeviceGroup iotDeviceGroup);
+
+    /**
+     * 删除设备分组
+     * @param deviceGroupCode 设备分组码值
+     * @return 删除结果
+     */
+    Boolean delDeviceGroup(String deviceGroupCode);
+
+    /**
+     *  设备分组详情查询
+     * @param iotDeviceGroup 设备分组信息
+     * @return  设备分组详情
+     */
+    IotDeviceGroup getDeviceGroupDetail(IotDeviceGroup iotDeviceGroup);
+
+    /**
+     * 分页查询设备分组
+     * @param current 当前页
+     * @param pageSize 每页数量
+     * @param iotDeviceGroup 设备分组信息
+     * @return 分页结果
+     */
+    Page pageGroupDevice(Integer current ,Integer pageSize,IotDeviceGroup iotDeviceGroup);
 }

+ 50 - 0
iot-platform-manager/src/main/java/com/platform/service/impl/IotDeviceGroupServiceImpl.java

@@ -1,9 +1,12 @@
 package com.platform.service.impl;
 
+import com.baomidou.mybatisplus.core.toolkit.Wrappers;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.platform.entity.IotDeviceGroup;
 import com.platform.mapper.IotDeviceGroupMapper;
 import com.platform.service.IotDeviceGroupService;
+import org.checkerframework.common.returnsreceiver.qual.This;
 import org.springframework.stereotype.Service;
 
 /**
@@ -15,4 +18,51 @@ import org.springframework.stereotype.Service;
 
 @Service
 public class IotDeviceGroupServiceImpl extends ServiceImpl<IotDeviceGroupMapper, IotDeviceGroup> implements IotDeviceGroupService {
+    @Override
+    public IotDeviceGroup getOneByTitle(String title) {
+        return getOne( Wrappers.<IotDeviceGroup>lambdaQuery()
+                .eq(IotDeviceGroup::getTitle,title)
+                .eq(IotDeviceGroup::getDelFlag,0)
+                .last("limit 1"));
+    }
+
+    @Override
+    public Boolean addDeviceGroup(IotDeviceGroup iotDeviceGroup) {
+        return save(iotDeviceGroup);
+    }
+
+    @Override
+    public Boolean updateDeviceGroup(IotDeviceGroup iotDeviceGroup) {
+
+        return update(iotDeviceGroup,Wrappers.<IotDeviceGroup>lambdaUpdate()
+                .eq(IotDeviceGroup::getDeviceGroupCode,iotDeviceGroup.getDeviceGroupCode())
+                .eq(IotDeviceGroup::getDelFlag,0));
+    }
+
+    @Override
+    public Boolean delDeviceGroup(String deviceGroupCode) {
+        IotDeviceGroup iotDeviceGroup = new IotDeviceGroup();
+        iotDeviceGroup.setDelFlag(1);
+        return update(iotDeviceGroup,Wrappers.<IotDeviceGroup>lambdaUpdate()
+                .eq(IotDeviceGroup::getDeviceGroupCode,deviceGroupCode));
+    }
+
+    @Override
+    public IotDeviceGroup getDeviceGroupDetail(IotDeviceGroup iotDeviceGroup) {
+        return getOne(Wrappers.<IotDeviceGroup>lambdaQuery()
+                .eq(IotDeviceGroup::getDeviceGroupCode,iotDeviceGroup.getDeviceGroupCode())
+                .eq(IotDeviceGroup::getDelFlag,0)
+                .last("limit 1"));
+    }
+
+    @Override
+    public Page pageGroupDevice(Integer current, Integer pageSize, IotDeviceGroup iotDeviceGroup) {
+        Page<IotDeviceGroup> page = new Page<>(current, pageSize);
+        return page(page,Wrappers.<IotDeviceGroup>lambdaQuery()
+                .eq(IotDeviceGroup::getDelFlag,0)
+                .orderByDesc(IotDeviceGroup::getCreateTime)
+                .orderByDesc(IotDeviceGroup::getId));
+    }
+
+
 }