Jelajahi Sumber

soc分析数据源

Zimo 1 hari lalu
induk
melakukan
e9979091cd
13 mengubah file dengan 598 tambahan dan 12 penghapusan
  1. 3 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/vo/IotMeasureCertRespVO.java
  2. 7 4
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/vo/IotMeasureBookRespVO.java
  3. 93 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/IotSocSourceController.java
  4. 40 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSourcePageReqVO.java
  5. 47 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSourceRespVO.java
  6. 36 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSourceSaveReqVO.java
  7. 4 1
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/cert/IotMeasureCertDO.java
  8. 8 7
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/measure/IotMeasureBookDO.java
  9. 54 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/soc/IotSocSourceDO.java
  10. 43 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/soc/IotSocSourceMapper.java
  11. 52 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/qhse/CertJob.java
  12. 56 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/soc/IotSocSourceService.java
  13. 155 0
      yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/soc/IotSocSourceServiceImpl.java

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/vo/IotMeasureCertRespVO.java

@@ -75,4 +75,7 @@ public class IotMeasureCertRespVO {
     @ExcelProperty("用户名称")
     private String userName;
 
+    @Schema(description = "是否到期")
+    private Boolean expired;
+
 }

+ 7 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/vo/IotMeasureBookRespVO.java

@@ -1,11 +1,11 @@
 package cn.iocoder.yudao.module.pms.controller.admin.qhse.measure.vo;
 
+import com.alibaba.excel.annotation.ExcelIgnoreUnannotated;
+import com.alibaba.excel.annotation.ExcelProperty;
 import io.swagger.v3.oas.annotations.media.Schema;
-import lombok.*;
-import java.util.*;
-import org.springframework.format.annotation.DateTimeFormat;
+import lombok.Data;
+
 import java.time.LocalDateTime;
-import com.alibaba.excel.annotation.*;
 
 @Schema(description = "管理后台 - 计量器具台账 Response VO")
 @Data
@@ -71,4 +71,7 @@ public class IotMeasureBookRespVO {
     @Schema(description = "部门id", example = "26945")
     @ExcelProperty("部门id")
     private Long deptId;
+
+    @Schema(description = "检测是否到期")
+    private Boolean expired;
 }

+ 93 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/IotSocSourceController.java

@@ -0,0 +1,93 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc;
+
+import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
+import cn.iocoder.yudao.framework.common.pojo.CommonResult;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourceRespVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourceSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
+import cn.iocoder.yudao.module.pms.service.qhse.soc.IotSocSourceService;
+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.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import javax.validation.Valid;
+import java.io.IOException;
+import java.util.List;
+
+import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
+import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
+
+
+@Tag(name = "管理后台 - SOC卡分析数据源")
+@RestController
+@RequestMapping("/rq/iot-soc-source")
+@Validated
+public class IotSocSourceController {
+
+    @Resource
+    private IotSocSourceService iotSocSourceService;
+
+    @PostMapping("/create")
+    @Operation(summary = "创建SOC卡分析数据源")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-source:create')")
+    public CommonResult<Long> createIotSocSource(@Valid @RequestBody IotSocSourceSaveReqVO createReqVO) {
+        return success(iotSocSourceService.createIotSocSource(createReqVO));
+    }
+
+    @PutMapping("/update")
+    @Operation(summary = "更新SOC卡分析数据源")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-source:update')")
+    public CommonResult<Boolean> updateIotSocSource(@Valid @RequestBody IotSocSourceSaveReqVO updateReqVO) {
+        iotSocSourceService.updateIotSocSource(updateReqVO);
+        return success(true);
+    }
+
+    @DeleteMapping("/delete")
+    @Operation(summary = "删除SOC卡分析数据源")
+    @Parameter(name = "id", description = "编号", required = true)
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-source:delete')")
+    public CommonResult<Boolean> deleteIotSocSource(@RequestParam("id") Long id) {
+        iotSocSourceService.deleteIotSocSource(id);
+        return success(true);
+    }
+
+    @GetMapping("/get")
+    @Operation(summary = "获得SOC卡分析数据源")
+    @Parameter(name = "id", description = "编号", required = true, example = "1024")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-source:query')")
+    public CommonResult<IotSocSourceRespVO> getIotSocSource(@RequestParam("id") Long id) {
+        IotSocSourceDO iotSocSource = iotSocSourceService.getIotSocSource(id);
+        return success(BeanUtils.toBean(iotSocSource, IotSocSourceRespVO.class));
+    }
+
+    @GetMapping("/page")
+    @Operation(summary = "获得SOC卡分析数据源分页")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-source:query')")
+    public CommonResult<List<IotSocSourceRespVO>> getIotSocSourcePage(@Valid IotSocSourcePageReqVO pageReqVO) {
+        List<IotSocSourceDO> list = iotSocSourceService.getSocList(pageReqVO);
+        return success(BeanUtils.toBean(list, IotSocSourceRespVO.class));
+    }
+
+    @GetMapping("/export-excel")
+    @Operation(summary = "导出SOC卡分析数据源 Excel")
+    @PreAuthorize("@ss.hasPermission('rq:iot-soc-source:export')")
+    @ApiAccessLog(operateType = EXPORT)
+    public void exportIotSocSourceExcel(@Valid IotSocSourcePageReqVO pageReqVO,
+              HttpServletResponse response) throws IOException {
+        pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
+        List<IotSocSourceDO> list = iotSocSourceService.getIotSocSourcePage(pageReqVO).getList();
+        // 导出 Excel
+        ExcelUtils.write(response, "SOC卡分析数据源.xls", "数据", IotSocSourceRespVO.class,
+                        BeanUtils.toBean(list, IotSocSourceRespVO.class));
+    }
+
+}

+ 40 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSourcePageReqVO.java

@@ -0,0 +1,40 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo;
+
+import lombok.*;
+import java.util.*;
+import io.swagger.v3.oas.annotations.media.Schema;
+import cn.iocoder.yudao.framework.common.pojo.PageParam;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+
+import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
+
+@Schema(description = "管理后台 - SOC卡分析数据源分页 Request VO")
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+public class IotSocSourcePageReqVO extends PageParam {
+
+    @Schema(description = "父类别id", example = "12171")
+    private Long parentId;
+
+    @Schema(description = "类别名称", example = "张三")
+    private String name;
+
+    @Schema(description = "类别编码")
+    private String code;
+
+    @Schema(description = "分类排序")
+    private Integer sort;
+
+    @Schema(description = "开启状态", example = "2")
+    private Integer status;
+
+    @Schema(description = "创建时间")
+    @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
+    private LocalDateTime[] createTime;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+}

+ 47 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSourceRespVO.java

@@ -0,0 +1,47 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.*;
+import java.util.*;
+import org.springframework.format.annotation.DateTimeFormat;
+import java.time.LocalDateTime;
+import com.alibaba.excel.annotation.*;
+
+@Schema(description = "管理后台 - SOC卡分析数据源 Response VO")
+@Data
+@ExcelIgnoreUnannotated
+public class IotSocSourceRespVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10674")
+    @ExcelProperty("主键id")
+    private Long id;
+
+    @Schema(description = "父类别id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12171")
+    @ExcelProperty("父类别id")
+    private Long parentId;
+
+    @Schema(description = "类别名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
+    @ExcelProperty("类别名称")
+    private String name;
+
+    @Schema(description = "类别编码")
+    @ExcelProperty("类别编码")
+    private String code;
+
+    @Schema(description = "分类排序")
+    @ExcelProperty("分类排序")
+    private Integer sort;
+
+    @Schema(description = "开启状态", example = "2")
+    @ExcelProperty("开启状态")
+    private Integer status;
+
+    @Schema(description = "创建时间")
+    @ExcelProperty("创建时间")
+    private LocalDateTime createTime;
+
+    @Schema(description = "备注", example = "随便")
+    @ExcelProperty("备注")
+    private String remark;
+
+}

+ 36 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/soc/vo/IotSocSourceSaveReqVO.java

@@ -0,0 +1,36 @@
+package cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo;
+
+import io.swagger.v3.oas.annotations.media.Schema;
+import lombok.Data;
+
+import javax.validation.constraints.NotEmpty;
+import javax.validation.constraints.NotNull;
+
+@Schema(description = "管理后台 - SOC卡分析数据源新增/修改 Request VO")
+@Data
+public class IotSocSourceSaveReqVO {
+
+    @Schema(description = "主键id", requiredMode = Schema.RequiredMode.REQUIRED, example = "10674")
+    private Long id;
+
+    @Schema(description = "父类别id", requiredMode = Schema.RequiredMode.REQUIRED, example = "12171")
+    @NotNull(message = "父类别id不能为空")
+    private Long parentId;
+
+    @Schema(description = "类别名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "张三")
+    @NotEmpty(message = "类别名称不能为空")
+    private String name;
+
+    @Schema(description = "类别编码")
+    private String code;
+
+    @Schema(description = "分类排序")
+    private Integer sort;
+
+    @Schema(description = "开启状态", example = "2")
+    private Integer status;
+
+    @Schema(description = "备注", example = "随便")
+    private String remark;
+
+}

+ 4 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/cert/IotMeasureCertDO.java

@@ -80,5 +80,8 @@ public class IotMeasureCertDO extends BaseDO {
      * 备注
      */
     private String remark;
-
+    /**
+     * 是否国企
+     */
+    private Boolean expired;
 }

+ 8 - 7
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/measure/IotMeasureBookDO.java

@@ -1,12 +1,10 @@
 package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure;
 
-import lombok.*;
-import java.util.*;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
-import java.time.LocalDateTime;
-import com.baomidou.mybatisplus.annotation.*;
 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
 
 /**
  * 计量器具台账 DO
@@ -81,5 +79,8 @@ public class IotMeasureBookDO extends BaseDO {
      * 部门id
      */
     private Long deptId;
-
+    /**
+     * 检测是否到期
+     */
+    private Boolean expired;
 }

+ 54 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/soc/IotSocSourceDO.java

@@ -0,0 +1,54 @@
+package cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc;
+
+import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
+import com.baomidou.mybatisplus.annotation.KeySequence;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.*;
+
+/**
+ * SOC卡分析数据源 DO
+ *
+ * @author 超级管理员
+ */
+@TableName("rq_iot_soc_source")
+@KeySequence("rq_iot_soc_source_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
+@Data
+@EqualsAndHashCode(callSuper = true)
+@ToString(callSuper = true)
+@Builder
+@NoArgsConstructor
+@AllArgsConstructor
+public class IotSocSourceDO extends BaseDO {
+
+    /**
+     * 主键id
+     */
+    @TableId
+    private Long id;
+    /**
+     * 父类别id
+     */
+    private Long parentId;
+    /**
+     * 类别名称
+     */
+    private String name;
+    /**
+     * 类别编码
+     */
+    private String code;
+    /**
+     * 分类排序
+     */
+    private Integer sort;
+    /**
+     * 开启状态
+     */
+    private Integer status;
+    /**
+     * 备注
+     */
+    private String remark;
+
+}

+ 43 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/mysql/qhse/soc/IotSocSourceMapper.java

@@ -0,0 +1,43 @@
+package cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
+import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
+import org.apache.ibatis.annotations.Mapper;
+
+import java.util.List;
+
+/**
+ * SOC卡分析数据源 Mapper
+ *
+ * @author 超级管理员
+ */
+@Mapper
+public interface IotSocSourceMapper extends BaseMapperX<IotSocSourceDO> {
+
+    default PageResult<IotSocSourceDO> selectPage(IotSocSourcePageReqVO reqVO) {
+        return selectPage(reqVO, new LambdaQueryWrapperX<IotSocSourceDO>()
+                .eqIfPresent(IotSocSourceDO::getParentId, reqVO.getParentId())
+                .likeIfPresent(IotSocSourceDO::getName, reqVO.getName())
+                .eqIfPresent(IotSocSourceDO::getCode, reqVO.getCode())
+                .eqIfPresent(IotSocSourceDO::getSort, reqVO.getSort())
+                .eqIfPresent(IotSocSourceDO::getStatus, reqVO.getStatus())
+                .betweenIfPresent(IotSocSourceDO::getCreateTime, reqVO.getCreateTime())
+                .eqIfPresent(IotSocSourceDO::getRemark, reqVO.getRemark())
+                .orderByDesc(IotSocSourceDO::getId));
+    }
+    default IotSocSourceDO selectByParentIdAndName(Long parentId, String name) {
+        return selectOne(IotSocSourceDO::getParentId, parentId, IotSocSourceDO::getName, name);
+    }
+    default Long selectCountByParentId(Long parentId) {
+        return selectCount(IotSocSourceDO::getParentId, parentId);
+    }
+    default List<IotSocSourceDO> selectList(IotSocSourcePageReqVO reqVO) {
+        return selectList(new LambdaQueryWrapperX<IotSocSourceDO>()
+                .likeIfPresent(IotSocSourceDO::getName, reqVO.getName())
+                .likeIfPresent(IotSocSourceDO::getRemark, reqVO.getRemark())
+                .eqIfPresent(IotSocSourceDO::getStatus, reqVO.getStatus()));
+    }
+}

+ 52 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/job/qhse/CertJob.java

@@ -0,0 +1,52 @@
+package cn.iocoder.yudao.module.pms.job.qhse;
+
+import cn.hutool.core.collection.CollUtil;
+import cn.iocoder.yudao.framework.quartz.core.handler.JobHandler;
+import cn.iocoder.yudao.framework.tenant.core.aop.TenantIgnore;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.cert.IotMeasureCertDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureBookDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.measure.IotMeasureDetectDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.cert.IotMeasureCertMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.measure.IotMeasureBookMapper;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.measure.IotMeasureDetectMapper;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.time.LocalDateTime;
+import java.util.List;
+import java.util.Objects;
+import java.util.Set;
+import java.util.stream.Collectors;
+
+@Component
+public class CertJob implements JobHandler {
+    @Resource
+    private IotMeasureCertMapper iotMeasureCertMapper;
+    @Resource
+    private IotMeasureBookMapper iotMeasureBookMapper;
+    @Resource
+    private IotMeasureDetectMapper iotMeasureDetectMapper;
+
+    @Override
+    @TenantIgnore
+    public String execute(String param) throws Exception {
+        List<IotMeasureCertDO> iotMeasureCertDOS = iotMeasureCertMapper.selectList();
+        iotMeasureCertDOS.forEach(item -> {
+            LocalDateTime certExpire = item.getCertExpire();
+            if (certExpire.isBefore(LocalDateTime.now())) {
+                //证书已过期的话,更新expired为true
+                item.setExpired(true);
+            }
+        });
+        iotMeasureCertMapper.updateBatch(iotMeasureCertDOS);
+        //处理计量器具的检测是否过期
+        List<IotMeasureDetectDO> collect = iotMeasureDetectMapper.selectList().stream().filter(e -> Objects.nonNull(e.getValidityPeriod()) && (e.getValidityPeriod().isBefore(LocalDateTime.now()))).collect(Collectors.toList());
+        if (CollUtil.isNotEmpty(collect)) {
+            Set<Long> collect1 = collect.stream().map(IotMeasureDetectDO::getMeasureId).collect(Collectors.toSet());
+            List<IotMeasureBookDO> iotMeasureBookDOS = iotMeasureBookMapper.selectByIds(collect1);
+            iotMeasureBookDOS.forEach(item -> item.setExpired(true));
+            iotMeasureBookMapper.updateBatch(iotMeasureBookDOS);
+        }
+        return "执行成功";
+    }
+}

+ 56 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/soc/IotSocSourceService.java

@@ -0,0 +1,56 @@
+package cn.iocoder.yudao.module.pms.service.qhse.soc;
+
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourceSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
+
+import javax.validation.Valid;
+import java.util.List;
+
+/**
+ * SOC卡分析数据源 Service 接口
+ *
+ * @author 超级管理员
+ */
+public interface IotSocSourceService {
+    List<IotSocSourceDO> getSocList(IotSocSourcePageReqVO pageReqVO);
+    /**
+     * 创建SOC卡分析数据源
+     *
+     * @param createReqVO 创建信息
+     * @return 编号
+     */
+    Long createIotSocSource(@Valid IotSocSourceSaveReqVO createReqVO);
+
+    /**
+     * 更新SOC卡分析数据源
+     *
+     * @param updateReqVO 更新信息
+     */
+    void updateIotSocSource(@Valid IotSocSourceSaveReqVO updateReqVO);
+
+    /**
+     * 删除SOC卡分析数据源
+     *
+     * @param id 编号
+     */
+    void deleteIotSocSource(Long id);
+
+    /**
+     * 获得SOC卡分析数据源
+     *
+     * @param id 编号
+     * @return SOC卡分析数据源
+     */
+    IotSocSourceDO getIotSocSource(Long id);
+
+    /**
+     * 获得SOC卡分析数据源分页
+     *
+     * @param pageReqVO 分页查询
+     * @return SOC卡分析数据源分页
+     */
+    PageResult<IotSocSourceDO> getIotSocSourcePage(IotSocSourcePageReqVO pageReqVO);
+
+}

+ 155 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/soc/IotSocSourceServiceImpl.java

@@ -0,0 +1,155 @@
+package cn.iocoder.yudao.module.pms.service.qhse.soc;
+
+import cn.hutool.core.util.ObjectUtil;
+import cn.iocoder.yudao.framework.common.exception.ErrorCode;
+import cn.iocoder.yudao.framework.common.pojo.PageResult;
+import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourcePageReqVO;
+import cn.iocoder.yudao.module.pms.controller.admin.qhse.soc.vo.IotSocSourceSaveReqVO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.IotProductClassifyDO;
+import cn.iocoder.yudao.module.pms.dal.dataobject.qhse.soc.IotSocSourceDO;
+import cn.iocoder.yudao.module.pms.dal.mysql.qhse.soc.IotSocSourceMapper;
+import cn.iocoder.yudao.module.pms.enums.ErrorCodeConstant;
+import com.google.common.annotations.VisibleForTesting;
+import org.springframework.stereotype.Service;
+import org.springframework.validation.annotation.Validated;
+
+import javax.annotation.Resource;
+import java.util.Comparator;
+import java.util.List;
+import java.util.Objects;
+
+import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
+import static cn.iocoder.yudao.module.system.enums.ErrorCodeConstants.*;
+
+/**
+ * SOC卡分析数据源 Service 实现类
+ *
+ * @author 超级管理员
+ */
+@Service
+@Validated
+public class IotSocSourceServiceImpl implements IotSocSourceService {
+
+    @Resource
+    private IotSocSourceMapper iotSocSourceMapper;
+
+    @Override
+    public Long createIotSocSource(IotSocSourceSaveReqVO createReqVO) {
+        if (createReqVO.getParentId() == null) {
+            createReqVO.setParentId(IotProductClassifyDO.PARENT_ID_ROOT);
+        }
+        // 校验父产品分类的有效性
+        validateParentSoc(null, createReqVO.getParentId());
+        // 校验产品分类名的唯一性
+        validateSocNameUnique(null, createReqVO.getParentId(), createReqVO.getName());
+        // 插入
+        IotSocSourceDO iotSocSource = BeanUtils.toBean(createReqVO, IotSocSourceDO.class);
+        iotSocSource.setDeleted(false);
+        iotSocSourceMapper.insert(iotSocSource);
+        // 返回
+        return iotSocSource.getId();
+    }
+
+    @Override
+    public void updateIotSocSource(IotSocSourceSaveReqVO updateReqVO) {
+        if (updateReqVO.getParentId() == null) {
+            updateReqVO.setParentId(IotProductClassifyDO.PARENT_ID_ROOT);
+        }
+        // 校验存在
+        validateIotSocSourceExists(updateReqVO.getId());
+        // 校验父产品分类的有效性
+        validateParentSoc(updateReqVO.getId(), updateReqVO.getParentId());
+        // 校验产品分类名的唯一性
+        validateSocNameUnique(updateReqVO.getId(), updateReqVO.getParentId(), updateReqVO.getName());
+        // 更新
+        IotSocSourceDO updateObj = BeanUtils.toBean(updateReqVO, IotSocSourceDO.class);
+        iotSocSourceMapper.updateById(updateObj);
+    }
+
+    @Override
+    public void deleteIotSocSource(Long id) {
+        // 校验存在
+        validateIotSocSourceExists(id);
+        // 校验是否有子产品分类
+        if (iotSocSourceMapper.selectCountByParentId(id) > 0) {
+            throw exception(ErrorCodeConstant.PRODUCT_EXITS_CHILDREN);
+        }
+        // 删除
+        iotSocSourceMapper.deleteById(id);
+    }
+
+    private void validateIotSocSourceExists(Long id) {
+        if (iotSocSourceMapper.selectById(id) == null) {
+            throw exception(new ErrorCode(1,"不存在"));
+        }
+    }
+
+    @Override
+    public IotSocSourceDO getIotSocSource(Long id) {
+        return iotSocSourceMapper.selectById(id);
+    }
+
+    @Override
+    public PageResult<IotSocSourceDO> getIotSocSourcePage(IotSocSourcePageReqVO pageReqVO) {
+        return iotSocSourceMapper.selectPage(pageReqVO);
+    }
+
+    @Override
+    public List<IotSocSourceDO> getSocList(IotSocSourcePageReqVO reqVO) {
+        List<IotSocSourceDO> list = iotSocSourceMapper.selectList(reqVO);
+        list.sort(Comparator.comparing(IotSocSourceDO::getSort));
+        return list;
+    }
+
+    @VisibleForTesting
+    void validateParentSoc(Long id, Long parentId) {
+        if (parentId == null || IotProductClassifyDO.PARENT_ID_ROOT.equals(parentId)) {
+            return;
+        }
+        // 1. 不能设置自己为父产品分类
+        if (Objects.equals(id, parentId)) {
+            throw exception(DEPT_PARENT_ERROR);
+        }
+        // 2. 父产品分类不存在
+        IotSocSourceDO parentDept = iotSocSourceMapper.selectById(parentId);
+        if (parentDept == null) {
+            throw exception(DEPT_PARENT_NOT_EXITS);
+        }
+        // 3. 递归校验父产品分类,如果父产品分类是自己的子产品分类,则报错,避免形成环路
+        if (id == null) { // id 为空,说明新增,不需要考虑环路
+            return;
+        }
+        for (int i = 0; i < Short.MAX_VALUE; i++) {
+            // 3.1 校验环路
+            parentId = parentDept.getParentId();
+            if (Objects.equals(id, parentId)) {
+                throw exception(DEPT_PARENT_IS_CHILD);
+            }
+            // 3.2 继续递归下一级父产品分类
+            if (parentId == null || IotProductClassifyDO.PARENT_ID_ROOT.equals(parentId)) {
+                break;
+            }
+            parentDept = iotSocSourceMapper.selectById(parentId);
+            if (parentDept == null) {
+                break;
+            }
+        }
+    }
+
+    @VisibleForTesting
+    void validateSocNameUnique(Long id, Long parentId, String name) {
+        IotSocSourceDO dept = iotSocSourceMapper.selectByParentIdAndName(parentId, name);
+        if (dept == null) {
+            return;
+        }
+        // 如果 id 为空,说明不用比较是否为相同 id 的产品分类
+        if (id == null) {
+            throw exception(DEPT_NAME_DUPLICATE);
+        }
+        if (ObjectUtil.notEqual(dept.getId(), id)) {
+            throw exception(DEPT_NAME_DUPLICATE);
+        }
+    }
+
+}