From 8c442d889701b45eff21b559a3a886c855221b7e Mon Sep 17 00:00:00 2001 From: xy <748613696@qq.com> Date: Thu, 4 Sep 2025 13:58:30 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E6=96=B0=E5=A2=9E=E4=BA=91=E5=8D=8F?= =?UTF-8?q?=E8=AE=AE=E8=AE=BE=E5=A4=87=E5=8F=B0=E8=B4=A6=E5=BD=95=E5=85=A5?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=EF=BC=9B=202=E3=80=81=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E4=BA=91=E5=8D=8F=E8=AE=AE=E8=AE=BE=E5=A4=87=E5=AE=9E=E6=97=B6?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E8=AF=B7=E6=B1=82=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../njcn/csdevice/api/DataSetFeignClient.java | 7 - .../csdevice/enums/AlgorithmResponseEnum.java | 8 +- .../njcn/csdevice/param/IcdLedgerParam.java | 49 +++ .../com/njcn/csdevice/param/IcdParam.java | 26 ++ .../pojo/param/AppProjectAddParm.java | 5 +- .../param/CsEquipmentDeliveryAddParm.java | 64 +--- .../param/CsEquipmentDeliveryAuditParm.java | 6 + .../njcn/csdevice/pojo/param/CsLineParam.java | 55 ++- .../njcn/csdevice/pojo/param/NodeParam.java | 104 ++++++ .../pojo/po/CsEquipmentDeliveryPO.java | 14 +- .../com/njcn/csdevice/pojo/po/CsLinePO.java | 18 + .../java/com/njcn/csdevice/pojo/po/Node.java | 70 ++++ .../com/njcn/csdevice/pojo/vo/DeviceInfo.java | 70 ++++ .../EquipmentDeliveryController.java | 55 ++- .../controller/icd/IcdController.java | 59 ++++ .../controller/icd/NodeController.java | 163 +++++++++ .../controller/line/CslineController.java | 38 +- .../project/AppProjectController.java | 5 +- .../mapper/CsEquipmentDeliveryMapper.java | 3 + .../com/njcn/csdevice/mapper/NodeMapper.java | 25 ++ .../mapping/CsEquipmentDeliveryMapper.xml | 13 + .../csdevice/mapper/mapping/NodeMapper.xml | 43 +++ .../csdevice/service/AppProjectService.java | 4 +- .../csdevice/service/CsDevModelService.java | 6 + .../service/CsEquipmentDeliveryService.java | 80 +++-- .../csdevice/service/CsLinePOService.java | 3 + .../njcn/csdevice/service/INodeService.java | 79 +++++ .../com/njcn/csdevice/service/IcdService.java | 15 + .../service/impl/AppProjectServiceImpl.java | 42 ++- .../service/impl/CsDevModelServiceImpl.java | 19 + .../impl/CsEquipmentDeliveryServiceImpl.java | 327 ++++++++++++------ .../service/impl/CsLinePOServiceImpl.java | 50 ++- .../csdevice/service/impl/IcdServiceImpl.java | 220 ++++++++++++ .../service/impl/NodeServiceImpl.java | 166 +++++++++ .../enums/CsHarmonicResponseEnum.java | 4 +- .../njcn/csharmonic/param/CldEventParam.java | 38 ++ .../njcn/csharmonic/pojo/po/CsEventPO.java | 6 + .../controller/CsEventController.java | 13 +- .../controller/RealDataController.java | 10 + .../csharmonic/service/CsEventPOService.java | 5 +- .../csharmonic/service/RealDataService.java | 2 + .../service/impl/CsEventPOServiceImpl.java | 76 +++- .../impl/CsEventUserPOServiceImpl.java | 17 +- .../service/impl/RealDataServiceImpl.java | 123 ++++++- 44 files changed, 1938 insertions(+), 267 deletions(-) create mode 100644 cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdLedgerParam.java create mode 100644 cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdParam.java create mode 100644 cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/NodeParam.java create mode 100644 cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Node.java create mode 100644 cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/NodeController.java create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/NodeMapper.java create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/NodeMapper.xml create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/INodeService.java create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java create mode 100644 cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/NodeServiceImpl.java create mode 100644 cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CldEventParam.java diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/DataSetFeignClient.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/DataSetFeignClient.java index 37632ac..c1e08ae 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/DataSetFeignClient.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/api/DataSetFeignClient.java @@ -1,17 +1,10 @@ package com.njcn.csdevice.api; -import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.constant.ServerInfo; -import com.njcn.common.pojo.enums.common.LogEnum; -import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; -import com.njcn.common.utils.HttpResultUtil; import com.njcn.csdevice.api.fallback.DataSetFeignClientFallbackFactory; import com.njcn.csdevice.pojo.po.CsDataSet; import com.njcn.csdevice.pojo.vo.LineTargetVO; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; import org.springframework.cloud.openfeign.FeignClient; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestBody; diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java index 9c58129..6cdcba5 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/enums/AlgorithmResponseEnum.java @@ -35,7 +35,6 @@ public enum AlgorithmResponseEnum { CHIRLDREN2_EXIST("A00514","项目下存在设备,不能删除"), CHIRLDREN3_EXIST("A00516","存在设备使用拓扑图,不能删除"), - DATA_ARRAY_MISSING("A00515","详细数据为空"), UNKNOW_ROLE("A00515","角色无权限操作"), DATA_MISSING("A00516","数据缺失"), @@ -48,6 +47,13 @@ public enum AlgorithmResponseEnum { RECORD_FILE_LOST("A00516","record.bin文件缺失,请检查上传文件夹"), LINE_NUM_MISMATCH("A00516","上传文件的监测点序号和选择的监测点不匹配,请检查"), DEV_OFFLINE("A00516","装置未连接MQTT服务器"), + OVER_MAX_DEV_COUNT("A00517","前置机超出最大支持装置数"), + DEV_OLD_DATA("A00519","进程数修改失败,原进程数下存在装置,请修改装置进程号"), + DEV_EXIST_DATA("A00520","删除失败,前置机下存在装置"), + + CLD_MODEL_MISSING("A00521","云前置模板缺失,请检查模板信息"), + CLD_MODEL_MORE("A00521","存在多个云前置模板,请检查模板信息"), + ; diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdLedgerParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdLedgerParam.java new file mode 100644 index 0000000..5c4e330 --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdLedgerParam.java @@ -0,0 +1,49 @@ +package com.njcn.csdevice.param; + +import com.njcn.csdevice.pojo.param.AppProjectAddParm; +import com.njcn.csdevice.pojo.param.CsEngineeringAddParm; +import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm; +import com.njcn.csdevice.pojo.param.CsLineParam; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.Valid; +import java.io.Serializable; +import java.util.List; +import java.util.Map; + + +/** + * @author xy + */ +@Data +public class IcdLedgerParam implements Serializable { + + @ApiModelProperty("工程索引") + private String engineeringIndex; + + @ApiModelProperty("项目索引") + private String projectIndex; + + @ApiModelProperty("设备id") + private String devIndex; + + @ApiModelProperty("设备和mac关系") + private Map devMacMap; + + @Valid + @ApiModelProperty("工程信息") + private CsEngineeringAddParm engineering; + + @Valid + @ApiModelProperty("项目信息") + private AppProjectAddParm project; + + @Valid + @ApiModelProperty("装置信息") + private List device; + + @Valid + @ApiModelProperty("监测点信息") + private List line; +} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdParam.java new file mode 100644 index 0000000..761e13e --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/param/IcdParam.java @@ -0,0 +1,26 @@ +package com.njcn.csdevice.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.util.List; + +/** + * @author xy + */ +@Data +public class IcdParam implements Serializable { + + @ApiModelProperty("前置ip,不传时查询所有的终端台账信息") + @NotBlank(message = "前置ip不可为空") + private String ip; + + @ApiModelProperty("终端运行状态,不传则查询所有的终端信息 (0:运行;1:检修;2:停运;3:调试;4:退运)") + private List runFlag; + + @ApiModelProperty("终端型号(集合为空查询所有icd模型)") + private List devType; + +} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/AppProjectAddParm.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/AppProjectAddParm.java index d0746bd..2d5fa29 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/AppProjectAddParm.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/AppProjectAddParm.java @@ -5,7 +5,6 @@ import lombok.Data; import org.springframework.web.multipart.MultipartFile; import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; import java.math.BigDecimal; import java.util.List; @@ -20,16 +19,16 @@ import java.util.List; @Data public class AppProjectAddParm { - private String description; @ApiModelProperty(value="项目名称") @NotBlank(message="项目名称不能为空!") private String name; - @NotBlank(message="工程id不能为空!") + //@NotBlank(message="工程id不能为空!") private String engineeringId; + private String icdEngineeringId; /** * 地市Id diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java index 1ed9420..317edaf 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAddParm.java @@ -5,6 +5,7 @@ import lombok.Data; import javax.validation.constraints.NotBlank; import javax.validation.constraints.Pattern; +import java.io.Serializable; /** * @@ -17,8 +18,7 @@ import javax.validation.constraints.Pattern; */ @Data -public class CsEquipmentDeliveryAddParm{ - +public class CsEquipmentDeliveryAddParm implements Serializable { /** * 装置名称 @@ -39,7 +39,6 @@ public class CsEquipmentDeliveryAddParm{ * 装置mac地址 */ @ApiModelProperty(value="装置mac地址") -// @NotBlank(message="装置mac地址不能为空!") private String mac; /** @@ -56,56 +55,12 @@ public class CsEquipmentDeliveryAddParm{ @NotBlank(message="装置型号不能为空!") private String devModel; -// /** -// * 装置程序版本 -// */ -// @ApiModelProperty(value="装置程序版本") -// @NotBlank(message="装置程序版本不能为空!") -// private String programVersion; - -// /** -// * 调试人员 -// */ -// @ApiModelProperty(value="调试人员") -// @NotBlank(message="调试人员不能为空!") -// private String debugPerson; -// -// /** -// * 出厂日期 -// */ -// @ApiModelProperty(value="出厂日期") -// @NotNull(message="出厂日期不能为空!") -// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") -// private Date producteTime; -// -// /** -// * 检修日期 -// */ -// @ApiModelProperty(value="检修日期") -// @NotNull(message="检修日期不能为空!") -// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") -// private Date checkTime; -// -// /** -// * 调试日期 -// */ -// @ApiModelProperty(value="调试日期") -// @NotNull(message="调试日期不能为空!") -// @JsonFormat(pattern = "yyyy-MM-dd",timezone = "GMT+8") -// private Date debugTime; - /** * 合同号 */ @ApiModelProperty(value="合同号") private String cntractNo; -// /** -// * 营销经理 -// */ -// @ApiModelProperty(value="营销经理") -// private String salesManager; - /** * 装置接入方式 */ @@ -127,4 +82,19 @@ public class CsEquipmentDeliveryAddParm{ @ApiModelProperty(value="排序") private Integer sort; + @ApiModelProperty(value="前置机id") + private String nodeId; + + @ApiModelProperty(value="前置机进程号") + private Integer nodeProcess; + + @ApiModelProperty(value="模板id") + private String modelId; + + @ApiModelProperty(value="工程id") + private String engineeringId; + + @ApiModelProperty(value="项目id") + private String projectId; + } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java index 6e46271..c3a6709 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsEquipmentDeliveryAuditParm.java @@ -95,4 +95,10 @@ public class CsEquipmentDeliveryAuditParm { @ApiModelProperty(value="排序") private Integer sort; + + @ApiModelProperty(value="前置机id") + private String nodeId; + + @ApiModelProperty(value="前置机进程号") + private Integer nodeProcess; } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsLineParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsLineParam.java index 944d4c9..60776e2 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsLineParam.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/CsLineParam.java @@ -1,6 +1,7 @@ package com.njcn.csdevice.pojo.param; import com.njcn.db.bo.BaseEntity; +import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; @@ -18,25 +19,66 @@ public class CsLineParam extends BaseEntity { private String lineId; + /** + * 监测点名称 + */ + private String name; + + @ApiModelProperty(value="工程id") + private String engineeringId; + + @ApiModelProperty(value="项目id") + private String projectId; + + /** + * 装置id + */ + private String devId; + + /** + * 装置mac + */ + private String devMac; + /** * 电压等级 */ private Double volGrade; /** - * PT变比 + * 接线方式 + */ + private Integer conType; + + /** + * PT一次变比 */ private Double ptRatio; /** - * CT变比 + * PT二次变比 + */ + private Double pt2Ratio; + + /** + * CT一次变比 */ private Double ctRatio; /** - * 接线方式 + * CT二次变比 */ - private Integer conType; + private Double ct2Ratio; + + /** + * 监测点线路号 + */ + private Integer clDid; + + /** + * 统计间隔 + */ + private Integer lineInterval; /** * 模板id @@ -49,8 +91,7 @@ public class CsLineParam extends BaseEntity { private String dataSetId; /** - * 统计间隔 + * 运行状态(0:运行;1:检修;2:停运;3:调试;4:退运) */ - private Integer lineInterval; - + private Integer runStatus; } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/NodeParam.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/NodeParam.java new file mode 100644 index 0000000..d861d5d --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/param/NodeParam.java @@ -0,0 +1,104 @@ +package com.njcn.csdevice.pojo.param; + +import com.njcn.common.pojo.constant.PatternRegex; +import com.njcn.web.constant.ValidMessage; +import com.njcn.web.pojo.param.BaseParam; +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import javax.validation.constraints.*; + +/** + * pqs + * + * @author cdf + * @date 2022/1/14 + */ +@Data +@ApiModel +public class NodeParam { + + /** + * 名称 + */ + @ApiModelProperty(name = "name",value = "前置服务器名称") + @NotBlank(message = "前置机名称不能为空") + @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = ValidMessage.NAME_FORMAT_ERROR) + private String name; + + /** + * 服务器IP + */ + @ApiModelProperty(name = "ip",value = "服务器IP") + @NotBlank(message = "前置机IP不能为空") + @Pattern(regexp = PatternRegex.IP_REGEX, message = ValidMessage.IP_FORMAT_ERROR) + private String ip; + + /** + * 描述 + */ + @ApiModelProperty(name = "remark",value = "描述") + private String remark; + + + /** + * 状态 前置等级 + */ + @ApiModelProperty(name = "nodeGrade",value = "前置等级") + @NotNull(message = "前置机等级不可为空") + private Integer nodeGrade; + + /** + * 前置机支持最大装置数 + */ + @ApiModelProperty(name = "nodeDevNum",value = "前置机支持最大装置数") + @NotNull(message = "前置机支持最大装置数不可为空") + @Min(value = 1, message = "装置数不可小于1") + @Max(value = 1000, message = "装置数不可大于1000") + private Integer nodeDevNum; + + /** + * 前置机支持最大进程数量 + */ + @ApiModelProperty(name = "nodeDevNum",value = "前置机支持最大进程数量") + @NotNull(message = "前置机支持最大进程数量") + @Min(value = 1, message = "最大进程数量不可小于1") + @Max(value = 10, message = "最大进程数量不可大于10") + private Integer maxProcessNum; + + /** + * 排序 + */ + @ApiModelProperty(name = "sort",value = "排序") + @NotNull(message = "排序不可为空") + private Integer sort; + + /** + * 更新操作实体 + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class NodeUpdateParam extends NodeParam { + + /** + * 表Id + */ + @ApiModelProperty("id") + @NotBlank(message = ValidMessage.ID_NOT_BLANK) + @Pattern(regexp = PatternRegex.SYSTEM_ID, message = ValidMessage.ID_FORMAT_ERROR) + private String id; + } + + /** + * 前置查询 + */ + @Data + @EqualsAndHashCode(callSuper = true) + public static class NodeQueryParam extends BaseParam { + @ApiModelProperty("前置等级") + private Integer nodeGrade; + + } +} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java index 61d7bfb..1b1d16b 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsEquipmentDeliveryPO.java @@ -64,8 +64,6 @@ public class CsEquipmentDeliveryPO extends BaseEntity { @TableField(value = "dev_access_method") private String devAccessMethod; - - /** * 合同号 */ @@ -120,4 +118,16 @@ public class CsEquipmentDeliveryPO extends BaseEntity { @TableField(value = "sort") private Integer sort; + /** + * 前置服务器IP + */ + @TableField(value = "node_id") + private String nodeId; + + /** + * 前置进程号 + */ + @TableField(value = "node_process") + private Integer nodeProcess; + } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java index 2e29f08..3e18086 100644 --- a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/CsLinePO.java @@ -66,12 +66,24 @@ public class CsLinePO extends BaseEntity { @TableField(value = "pt_ratio") private Double ptRatio; + /** + * PT2次变比 + */ + @TableField(value = "pt2_ratio") + private Double pt2Ratio; + /** * CT变比 */ @TableField(value = "ct_ratio") private Double ctRatio; + /** + * CT2变比 + */ + @TableField(value = "ct2_ratio") + private Double ct2Ratio; + /** * 状态(0:删除 1:正常) */ @@ -101,4 +113,10 @@ public class CsLinePO extends BaseEntity { */ @TableField(value = "line_interval") private Integer lineInterval; + + /** + * 运行状态 + */ + @TableField(value = "run_status") + private Integer runStatus; } \ No newline at end of file diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Node.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Node.java new file mode 100644 index 0000000..fb811c1 --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/po/Node.java @@ -0,0 +1,70 @@ +package com.njcn.csdevice.pojo.po; + +import com.baomidou.mybatisplus.annotation.TableName; +import com.njcn.db.bo.BaseEntity; +import lombok.Data; +import lombok.EqualsAndHashCode; + +import java.io.Serializable; + +/** + *

+ * + *

+ * + * @author xy + */ +@Data +@EqualsAndHashCode(callSuper = true) +@TableName("pq_node") +public class Node extends BaseEntity implements Serializable { + + private static final long serialVersionUID = 1L; + + /** + * 前置序号 + */ + private String id; + + /** + * 名称 + */ + private String name; + + /** + * 服务器IP + */ + private String ip; + + /** + * 描述 + */ + private String remark; + + /** + * 状态 0-删除;1-正常;默认正常 + */ + private Integer state; + + /** + * 状态 前置等级 + */ + private Integer nodeGrade; + + /** + * 前置机支持最大装置数 + */ + private Integer nodeDevNum; + + + /** + * 前置机支持最大进程数量 + */ + private Integer maxProcessNum; + + /** + * 排序 + */ + private Integer sort; + +} diff --git a/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java new file mode 100644 index 0000000..0e89288 --- /dev/null +++ b/cs-device/cs-device-api/src/main/java/com/njcn/csdevice/pojo/vo/DeviceInfo.java @@ -0,0 +1,70 @@ +package com.njcn.csdevice.pojo.vo; + +import com.fasterxml.jackson.annotation.JsonFormat; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; +import java.util.List; + +//台账信息 +@Data +public class DeviceInfo implements Serializable { + + @ApiModelProperty("终端索引") + private String id; + + @ApiModelProperty("终端mac") + private String ip; + + @ApiModelProperty("终端型号") + private String devType; + + @ApiModelProperty("终端名称") + private String name; + + @ApiModelProperty("前置机序号") + private Integer node; + + @ApiModelProperty("监测点集合") + private List monitorData; + + //终端下的监测点信息 + @Data + public static class MonitorInfo implements Serializable { + + @ApiModelProperty("监测点索引") + private String id; + + @ApiModelProperty("名称") + private String name; + + @ApiModelProperty("监测点逻辑号") + private String lineNo; + + @ApiModelProperty("监测点电压等级") + private String voltageLevel; + + @ApiModelProperty("监测点运行状态 0:运行;1:检修;2:停运;3:调试;4:退运") + private Integer status; + + @ApiModelProperty("监测点接线方式 0-星型 1-角型 2-V型") + private String ptType; + + @ApiModelProperty("装置id") + private String deviceId; + + @ApiModelProperty("pt1") + private Double pt1; + + @ApiModelProperty("pt2") + private Double pt2; + + @ApiModelProperty("ct1") + private Double ct1; + + @ApiModelProperty("ct2") + private Double ct2; + } + +} \ No newline at end of file diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java index 36a4f3b..d288514 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/equipment/EquipmentDeliveryController.java @@ -45,7 +45,6 @@ import java.util.List; import java.util.Objects; import java.util.stream.Collectors; import java.util.stream.Stream; - /** * Description: * 接口文档访问地址:http://serverIP:port/swagger-ui.html @@ -60,7 +59,6 @@ import java.util.stream.Stream; @Api(tags = " 出厂设备") @AllArgsConstructor public class EquipmentDeliveryController extends BaseController { - private final CsEquipmentDeliveryService csEquipmentDeliveryService; private final IMqttUserService mqttUserService; private final CsDevModelRelationService csDevModelRelationService; @@ -85,7 +83,6 @@ public class EquipmentDeliveryController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/AuditEquipmentDelivery") @ApiOperation("删除出厂设备") @@ -115,16 +112,13 @@ public class EquipmentDeliveryController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); } - - @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryEquipmentByndid") @ApiOperation("通过ndid查询出厂设备") @ApiImplicitParam(name = "ndid", value = "网关识别码", required = true) public HttpResult queryEquipmentByndid(@RequestParam("ndid")String ndid){ String methodDescribe = getMethodDescribe("queryEquipmentByndid"); - - CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentByndid (ndid); + CsEquipmentDeliveryVO csEquipmentDeliveryVO = csEquipmentDeliveryService.queryEquipmentByndid (ndid); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csEquipmentDeliveryVO, methodDescribe); } @@ -146,11 +140,12 @@ public class EquipmentDeliveryController extends BaseController { @ApiImplicitParam(name = "status", value = "状态", required = true) }) @DeviceLog(operateType = DeviceOperate.UPDATESTATUSBYNDID) - public HttpResult updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status){ + public HttpResult updateStatusBynDid(@RequestParam("nDId") String nDid,@RequestParam("status") Integer status){ String methodDescribe = getMethodDescribe("updateStatusBynDid"); csEquipmentDeliveryService.updateStatusBynDid(nDid,status); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryEquipmentById") @ApiOperation("设备查询通过id获取") @@ -217,13 +212,11 @@ public class EquipmentDeliveryController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); } - @ResponseBody @ApiOperation("导出设备模板") @GetMapping(value = "getExcelTemplate") public HttpResult getExcelTemplate(HttpServletResponse response) { String methodDescribe = getMethodDescribe("getExcelTemplate"); - ExportParams exportParams = new ExportParams("批量导入模板(请严格按照模板标准填入数据)", "终端入网检测录入信息"); exportParams.setStyle(ExcelStyleUtil.class); Workbook workbook = ExcelExportUtil.exportExcel(exportParams, DeviceExcelTemplete.class, new ArrayList()); @@ -256,10 +249,10 @@ public class EquipmentDeliveryController extends BaseController { mqttUserService.insertMqttUser(temp.getNdid()); } }); - } return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } + @ResponseBody @ApiOperation("联调完成") @PostMapping(value = "testcompletion") @@ -282,8 +275,8 @@ public class EquipmentDeliveryController extends BaseController { @PostMapping("/updateSoftInfo") @ApiOperation("更新设备软件信息") @ApiImplicitParams({ - @ApiImplicitParam(name = "nDid", value = "网络设备码", required = true), - @ApiImplicitParam(name = "id", value = "软件信息id", required = true) + @ApiImplicitParam(name = "nDid", value = "网络设备码", required = true), + @ApiImplicitParam(name = "id", value = "软件信息id", required = true) }) @ApiIgnore public HttpResult updateSoftInfo(@RequestParam("nDid") String nDid,@RequestParam("id") String id){ @@ -306,7 +299,6 @@ public class EquipmentDeliveryController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/rebootDevice") @ApiOperation("重启设备") @@ -348,4 +340,37 @@ public class EquipmentDeliveryController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); } -} + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/addCldDev") + @ApiOperation("新增云前置设备") + @ApiImplicitParam(name = "param", value = "参数", required = true) + @DeviceLog(operateType = DeviceOperate.ADD) + public HttpResult addCldDev(@RequestBody @Validated CsEquipmentDeliveryAddParm param){ + String methodDescribe = getMethodDescribe("addCldDev"); + CsEquipmentDeliveryPO po = csEquipmentDeliveryService.saveCld(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/delCldDev") + @ApiOperation("删除云前置设备") + @ApiImplicitParam(name = "id", value = "id", required = true) + @DeviceLog(operateType = DeviceOperate.DELETE) + public HttpResult delCldDev(@RequestBody @Validated String id){ + String methodDescribe = getMethodDescribe("delCldDev"); + boolean result = csEquipmentDeliveryService.delCldDev(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/updateCldDev") + @ApiOperation("修改云前置设备") + @ApiImplicitParam(name = "param", value = "参数", required = true) + @DeviceLog(operateType = DeviceOperate.UPDATE) + public HttpResult updateCldDev(@RequestBody @Validated CsEquipmentDeliveryAuditParm param){ + String methodDescribe = getMethodDescribe("updateCldDev"); + boolean result = csEquipmentDeliveryService.updateCldDev(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + +} \ No newline at end of file diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java new file mode 100644 index 0000000..3d66daf --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/IcdController.java @@ -0,0 +1,59 @@ +package com.njcn.csdevice.controller.icd; + +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.csdevice.param.IcdLedgerParam; +import com.njcn.csdevice.param.IcdParam; +import com.njcn.csdevice.pojo.vo.DeviceInfo; +import com.njcn.csdevice.service.IcdService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiOperation; +import lombok.AllArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +/** + * @author xy + * @version V1.0.0 + */ +@Slf4j +@RestController +@RequestMapping("/icd") +@Api(tags = "云前置改造") +@AllArgsConstructor +public class IcdController extends BaseController { + + private final IcdService icdService; + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getLedgerInfo") + @ApiOperation("获取台账信息") + @ApiImplicitParam(name = "param", value = "参数", required = true) + public HttpResult> getLedgerInfo(@RequestBody @Validated IcdParam param){ + String methodDescribe = getMethodDescribe("getLedgerInfo"); + List result = icdService.getLedgerInfo(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/addLedgerInfo") + @ApiOperation("新增台账信息") + @ApiImplicitParam(name = "param", value = "参数", required = true) + public HttpResult> addLedgerInfo(@RequestBody @Validated IcdLedgerParam param){ + String methodDescribe = getMethodDescribe("addLedgerInfo"); + icdService.addLedgerInfo(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/NodeController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/NodeController.java new file mode 100644 index 0000000..4a67d3b --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/icd/NodeController.java @@ -0,0 +1,163 @@ +package com.njcn.csdevice.controller.icd; + + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.njcn.common.pojo.annotation.OperateInfo; +import com.njcn.common.pojo.constant.OperateType; +import com.njcn.common.pojo.enums.common.LogEnum; +import com.njcn.common.pojo.enums.response.CommonResponseEnum; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.common.utils.HttpResultUtil; +import com.njcn.csdevice.pojo.param.NodeParam; +import com.njcn.csdevice.pojo.po.Node; +import com.njcn.csdevice.service.INodeService; +import com.njcn.web.controller.BaseController; +import io.swagger.annotations.Api; +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; +import io.swagger.annotations.ApiOperation; +import lombok.RequiredArgsConstructor; +import lombok.extern.slf4j.Slf4j; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import javax.validation.constraints.NotNull; +import java.util.List; + +/** + * 前置程序控制器 + * @author xy + */ +@Slf4j +@Api(tags = "前置机管理") +@RestController +@RequestMapping("node") +@RequiredArgsConstructor +public class NodeController extends BaseController { + + private final INodeService iNodeService; + + /** + * 新增前置机 + * @author cdf + * @date 2021/6/23 + */ + @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD) + @ApiOperation("新增前置机") + @ApiImplicitParam(value = "前置机信息",name = "nodeParam",required = true) + @PostMapping("addNode") + public HttpResult addNode(@Validated @RequestBody NodeParam nodeParam){ + String methodDescribe = getMethodDescribe("addNode"); + boolean result = iNodeService.addNode(nodeParam); + if (result){ + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); + } else { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe); + } + } + + /** + * 修改前置机 + * @author cdf + * @date 2021/6/23 + */ + @ApiOperation("修改前置机") + @ApiImplicitParam(value = "前置机信息",name = "updateNodeParam",required = true) + @PutMapping("updateNode") + @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE) + public HttpResult updateNode(@Validated @RequestBody NodeParam.NodeUpdateParam updateNodeParam){ + String methodDescribe = getMethodDescribe("updateNode"); + boolean result = iNodeService.updateNode(updateNodeParam); + if (result){ + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); + } else { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe); + } + } + + /** + * 删除前置 + * @author cdf + * @date 2021/6/23 + */ + @ApiOperation(value = "删除前置机") + @ApiImplicitParam(value = "前置机id",name = "id",required = true) + @PostMapping("delNode") + @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.DELETE) + public HttpResult delNode(@Validated @NotNull(message = "id不可为空") @RequestParam("id")String id){ + String methodDescribe = getMethodDescribe("delNode"); + boolean result = iNodeService.delNode(id); + if (result){ + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); + } else { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe); + } + } + + /** + * 变更前置机状态 + * @author cdf + * @date 2021/6/23 + */ + @ApiOperation(value = "变更前置机状态") + @ApiImplicitParams({ + @ApiImplicitParam(value = "前置机id",name = "id",required = true ), + @ApiImplicitParam(value = "前置机状态",name = "state",required = true ) + }) + @PostMapping("updateNodeState") + @OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.UPDATE) + public HttpResult updateNodeState(@Validated @NotNull(message = "id不可为空") @RequestParam("id")String id,@NotNull(message = "状态不为空") @RequestParam("state")Integer state){ + String methodDescribe = getMethodDescribe("updateNodeState"); + boolean result = iNodeService.updateNodeState(id,state); + if (result){ + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); + } else { + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe); + } + } + + /** + * 获取全部前置机分页 + * @author cdf + * @date 2021/6/23 + */ + @ApiOperation("获取全部前置机") + @OperateInfo(info = LogEnum.BUSINESS_MEDIUM) + @PostMapping("nodeList") + public HttpResult> nodeList(@RequestBody NodeParam.NodeQueryParam nodeQueryParam){ + String methodDescribe = getMethodDescribe("nodeList"); + Page page = iNodeService.nodeList(nodeQueryParam); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, page, methodDescribe); + } + + /** + * 获取全部前置机不分页 + * @author cdf + * @date 2021/6/23 + */ + @ApiOperation("获取全部前置机") + @OperateInfo(info = LogEnum.BUSINESS_MEDIUM) + @GetMapping("/nodeAllList") + public HttpResult> nodeAllList(){ + String methodDescribe = getMethodDescribe("nodeAllList"); + List resList = iNodeService.nodeAllList(); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, resList, methodDescribe); + } + + /** + * 根据id获取前置机 + * @author cdf + * @date 2021/6/23 + */ + @ApiOperation("根据id获取前置机") + @ApiImplicitParam(value = "前置机id",name = "id",required = true) + @OperateInfo(info = LogEnum.BUSINESS_MEDIUM) + @GetMapping("/getNodeById") + public HttpResult getNodeById(@Validated @NotNull(message = "id不可为空") @RequestParam("id")String id){ + String methodDescribe = getMethodDescribe("getNodeById"); + Node node = iNodeService.getNodeById(id); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, node, methodDescribe); + } + +} + diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java index e08d1ad..48b4d40 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/line/CslineController.java @@ -92,16 +92,6 @@ public class CslineController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); } -// @OperateInfo(info = LogEnum.BUSINESS_COMMON) -// @PostMapping("/addLineList") -// @ApiOperation("批量新增监测点及绑定关系") -// @ApiImplicitParam(name = "list", value = "监测点数据集", required = true) -// public HttpResult addLines(@RequestBody List list){ -// String methodDescribe = getMethodDescribe("addLines"); -// csLinePOService.addLines(list); -// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); -// } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/findByNdid") @ApiOperation("根据ndid查询监测点") @@ -167,4 +157,32 @@ public class CslineController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/addCldLine") + @ApiOperation("新增云前置监测点") + @ApiImplicitParam(name = "param", value = "param", required = true) + public HttpResult> addCldLine(@RequestBody @Validated CsLineParam param) { + String methodDescribe = getMethodDescribe("addCldLine"); + csLinePOService.addCldLine(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/updateCldLine") + @ApiOperation("修改云前置监测点") + @ApiImplicitParam(name = "id", value = "id", required = true) + public HttpResult> updateCldLine(@RequestParam("id") String id) { + String methodDescribe = getMethodDescribe("updateCldLine"); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/delCldLine") + @ApiOperation("删除云前置监测点") + @ApiImplicitParam(name = "id", value = "监测点id", required = true) + public HttpResult> delCldLine(@RequestParam("id") String id) { + String methodDescribe = getMethodDescribe("delCldLine"); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/AppProjectController.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/AppProjectController.java index dffb9c0..7c9da47 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/AppProjectController.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/controller/project/AppProjectController.java @@ -1,5 +1,6 @@ package com.njcn.csdevice.controller.project; +import cn.hutool.core.util.ObjectUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.enums.common.LogEnum; @@ -68,8 +69,8 @@ public class AppProjectController extends BaseController { public HttpResult addAppProject(@Validated AppProjectAddParm appProjectAddParm){ String methodDescribe = getMethodDescribe("addAppProject"); - Boolean flag = appProjectService.addAppProject(appProjectAddParm); - return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe); + AppProjectPO po = appProjectService.addAppProject(appProjectAddParm); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, ObjectUtil.isNotNull(po), methodDescribe); } @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/auditAppProject") diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEquipmentDeliveryMapper.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEquipmentDeliveryMapper.java index a22db44..7babfef 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEquipmentDeliveryMapper.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/CsEquipmentDeliveryMapper.java @@ -1,5 +1,6 @@ package com.njcn.csdevice.mapper; +import com.baomidou.dynamic.datasource.annotation.DS; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; @@ -21,6 +22,7 @@ import java.util.List; * @author clam * @version V1.0.0 */ +@DS("master") public interface CsEquipmentDeliveryMapper extends BaseMapper { Page queryProjectEquipmentVO(Page returnpage,@Param("projectEquipmentQueryParm")ProjectEquipmentQueryParm projectEquipmentQueryParm,@Param("device")List device); @@ -32,4 +34,5 @@ public interface CsEquipmentDeliveryMapper extends BaseMapper + * Mapper 接口 + *

+ * + * @author cdf + * @since 2022-01-04 + */ +@DS("sjzx") +public interface NodeMapper extends BaseMapper { + + List nodeDeviceList(@Param("nodeDeviceParam") IcdParam icdParam); +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/CsEquipmentDeliveryMapper.xml b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/CsEquipmentDeliveryMapper.xml index 672ada1..e2c9b6d 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/CsEquipmentDeliveryMapper.xml +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/CsEquipmentDeliveryMapper.xml @@ -124,4 +124,17 @@ + + + \ No newline at end of file diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/NodeMapper.xml b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/NodeMapper.xml new file mode 100644 index 0000000..65b1519 --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/mapper/mapping/NodeMapper.xml @@ -0,0 +1,43 @@ + + + + + + diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppProjectService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppProjectService.java index df0755d..d42bd77 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppProjectService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/AppProjectService.java @@ -27,8 +27,8 @@ public interface AppProjectService extends IService { * @return: java.lang.Boolean * @Author: clam * @Date: 2023/3/27 - */ - Boolean addAppProject(AppProjectAddParm appProjectAddOrAuditParm); + */ + AppProjectPO addAppProject(AppProjectAddParm appProjectAddOrAuditParm); /** * @Description: AuditAppProject * @Param: [appProjectAuditParm] diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsDevModelService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsDevModelService.java index 3dc8f75..c85b919 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsDevModelService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsDevModelService.java @@ -76,4 +76,10 @@ public interface CsDevModelService extends IService{ */ CsDevModelPO getModelById(String id); + /** + * 获取云前置模板 + * @return + */ + CsDevModelPO getCldModel(); + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java index da52cc5..8d663fc 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsEquipmentDeliveryService.java @@ -32,30 +32,30 @@ public interface CsEquipmentDeliveryService extends IService getCldDevByIp(String id, List runFlag); + + + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java index 77bfa25..2aa3261 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/CsLinePOService.java @@ -47,4 +47,7 @@ public interface CsLinePOService extends IService{ void updateIds(CsLineParam csLineParam); List getLinesByDevList(List list); + + void addCldLine(CsLineParam param); + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/INodeService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/INodeService.java new file mode 100644 index 0000000..5031021 --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/INodeService.java @@ -0,0 +1,79 @@ +package com.njcn.csdevice.service; + + +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; +import com.njcn.csdevice.pojo.param.NodeParam; +import com.njcn.csdevice.pojo.po.Node; + +import java.util.List; + +/** + *

+ * 服务类 + *

+ * + * @author cdf + * @since 2022-01-07 + */ +public interface INodeService extends IService { + + + /** + * 新增前置机 + * @author cdf + * @date 2021/6/23 + */ + boolean addNode(NodeParam nodeParam); + + /** + * 修改前置机 + * @author cdf + * @date 2021/6/23 + */ + boolean updateNode(NodeParam.NodeUpdateParam nodeParam); + + /** + * 删除前置机 + * @author cdf + * @date 2021/6/23 + */ + boolean delNode(String id); + + /** + * 修改前置机状态 + * @author cdf + * @date 2021/6/23 + */ + boolean updateNodeState(String id, Integer state); + + /** + * 查询前置机列表 + * @author cdf + * @date 2021/6/23 + */ + Page nodeList(NodeParam.NodeQueryParam nodeQueryParam); + + /** + * 查询前置机列表不分页 + * @author cdf + * @date 2021/6/23 + */ + List nodeAllList(); + + /** + * 根据前置机id获取前置机 + * @author cdf + * @date 2021/6/23 + */ + Node getNodeById(String id); + + /** + * 根据前置机名称获取详细信息 + * @param nodeName 前置机名称 + * @return 前置信息 + */ + Node getNodeByNodeName(String nodeName); + + Node getNodeByIp(String ip); +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java new file mode 100644 index 0000000..37f2b51 --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/IcdService.java @@ -0,0 +1,15 @@ +package com.njcn.csdevice.service; + +import com.njcn.csdevice.param.IcdLedgerParam; +import com.njcn.csdevice.param.IcdParam; +import com.njcn.csdevice.pojo.vo.DeviceInfo; + +import java.util.List; + +public interface IcdService { + + List getLedgerInfo(IcdParam param); + + void addLedgerInfo(IcdLedgerParam param); + +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppProjectServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppProjectServiceImpl.java index 29cff6e..ce28bcb 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppProjectServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/AppProjectServiceImpl.java @@ -55,7 +55,7 @@ class AppProjectServiceImpl extends ServiceImpl @Override @Transactional(rollbackFor = Exception.class) - public Boolean addAppProject(AppProjectAddParm appProjectAddOrAuditParm) { + public AppProjectPO addAppProject(AppProjectAddParm appProjectAddOrAuditParm) { AppProjectPO appProjectPO = new AppProjectPO ( ); // Boolean result = checkName (appProjectAddOrAuditParm.getUserId ( ), appProjectAddOrAuditParm.getName ( )); // if (result) { @@ -109,19 +109,33 @@ class AppProjectServiceImpl extends ServiceImpl } } - CsLedger csLedger = csLedgerMapper.selectById(appProjectAddOrAuditParm.getEngineeringId()); - Optional.ofNullable(csLedger).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ENGINEERING_DATA_ERROR)); - CsLedger csLedger1 = new CsLedger(); - csLedger1.setId(appProjectPO.getId()); - csLedger1.setPid(appProjectAddOrAuditParm.getEngineeringId()); - csLedger1.setPids(csLedger.getPids()+ ","+appProjectAddOrAuditParm.getEngineeringId()); - csLedger1.setLevel(1); - csLedger1.setName(appProjectPO.getName()); - csLedger1.setState(1); - csLedger1.setSort(0); - csLedgerMapper.insert(csLedger1); - - return save; + //云协议工程 + if (Objects.nonNull(appProjectAddOrAuditParm.getIcdEngineeringId())){ + CsLedger csLedger1 = new CsLedger(); + csLedger1.setId(appProjectPO.getId()); + csLedger1.setPid(appProjectAddOrAuditParm.getEngineeringId()); + csLedger1.setPids("0,"+appProjectAddOrAuditParm.getEngineeringId()); + csLedger1.setLevel(1); + csLedger1.setName(appProjectPO.getName()); + csLedger1.setState(1); + csLedger1.setSort(0); + csLedgerMapper.insert(csLedger1); + } + //其他工程 + else { + CsLedger csLedger = csLedgerMapper.selectById(appProjectAddOrAuditParm.getEngineeringId()); + Optional.ofNullable(csLedger).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.ENGINEERING_DATA_ERROR)); + CsLedger csLedger1 = new CsLedger(); + csLedger1.setId(appProjectPO.getId()); + csLedger1.setPid(appProjectAddOrAuditParm.getEngineeringId()); + csLedger1.setPids(csLedger.getPids()+ ","+appProjectAddOrAuditParm.getEngineeringId()); + csLedger1.setLevel(1); + csLedger1.setName(appProjectPO.getName()); + csLedger1.setState(1); + csLedger1.setSort(0); + csLedgerMapper.insert(csLedger1); + } + return appProjectPO; } private Boolean checkName( String name,String id,String engineeringId) { diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDevModelServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDevModelServiceImpl.java index d765531..cb2590f 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDevModelServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsDevModelServiceImpl.java @@ -1,10 +1,12 @@ package com.njcn.csdevice.service.impl; +import cn.hutool.core.collection.CollectionUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.mapper.CsDevModelMapper; import com.njcn.csdevice.pojo.param.CsDevModelAddParm; import com.njcn.csdevice.pojo.param.CsDevModelAuditParm; @@ -26,6 +28,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import java.sql.Date; +import java.util.List; import java.util.Objects; /** @@ -157,4 +160,20 @@ public class CsDevModelServiceImpl extends ServiceImpl list = this.lambdaQuery() + .eq(CsDevModelPO::getDevTypeName,"CLD") + .eq(CsDevModelPO::getStatus,1) + .list(); + if (CollectionUtil.isEmpty(list)) { + throw new BusinessException(AlgorithmResponseEnum.CLD_MODEL_MISSING); + } else { + if (list.size() > 1) { + throw new BusinessException(AlgorithmResponseEnum.CLD_MODEL_MORE); + } + } + return list.get(0); + } + } diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java index 1ce5186..4ed32da 100644 --- a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/CsEquipmentDeliveryServiceImpl.java @@ -26,6 +26,7 @@ import com.njcn.csdevice.api.CsLogsFeignClient; import com.njcn.csdevice.constant.DataParam; import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper; +import com.njcn.csdevice.mapper.CsLedgerMapper; import com.njcn.csdevice.mapper.CsSoftInfoMapper; import com.njcn.csdevice.pojo.param.*; import com.njcn.csdevice.pojo.po.*; @@ -66,9 +67,8 @@ import java.io.InputStream; import java.time.LocalDateTime; import java.util.*; import java.util.stream.Collectors; - /** - * + * * Description: * 接口文档访问地址:http://serverIP:port/swagger-ui.html * Date: 2023/3/30 16:23【需求编号】 @@ -79,7 +79,6 @@ import java.util.stream.Collectors; @Service @RequiredArgsConstructor public class CsEquipmentDeliveryServiceImpl extends ServiceImpl implements CsEquipmentDeliveryService{ - private final CsDevModelRelationService csDevModelRelationService; private final ICsDataSetService csDataSetService; private final ICsLedgerService csLedgerService; @@ -98,6 +97,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl wrapper = new QueryWrapper(); @@ -186,8 +187,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl wrapper = new QueryWrapper(); wrapper.eq ("ndid", ndid); @@ -220,7 +220,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl list = this.baseMapper.queryProjectEquipmentVO(returnpage,projectEquipmentQueryParm,device); list.getRecords().stream().forEach(temp->{ temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId())); @@ -235,18 +234,16 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,csEquipmentDeliveryAuditParm.getNdid()) - .in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3)) - .ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); + .in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3)) + .ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); int countByAccount = this.count(lambdaQueryWrapper); //大于等于1个则表示重复 if (countByAccount >= 1) { throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR); } - LambdaQueryWrapper lambdaQueryWrapper2 = new LambdaQueryWrapper<>(); lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()); CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2); - List list = this.lambdaQuery() .ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()) .ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()) @@ -264,7 +261,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl list(CsEquipmentDeliveryQueryParm queryParam) { -// QueryWrapper queryWrapper = new QueryWrapper(); -// if (ObjectUtil.isNotNull(queryParam)) { -// //查询参数不为空,进行条件填充 -// if (StrUtil.isNotBlank(queryParam.getSearchValue())) { -// //部门根据名称模糊查询 -// queryWrapper -// .and(param -> param.like("cs_equipment_delivery.name", queryParam.getSearchValue()) -// .or().like("cs_equipment_delivery.ndid", queryParam.getSearchValue()) -// .or().like("cs_equipment_delivery.mac", queryParam.getSearchValue())); -// } -// //排序 -// if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) { -// queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy())); -// } else { -// //默认根据创建时间排序 -// queryWrapper.orderBy(true, false, "create_time"); -// } -// } -// if (StrUtil.isNotBlank(queryParam.getDevType()) && !Objects.isNull(queryParam.getDevType())){ -// queryWrapper.eq("cs_equipment_delivery.dev_type", queryParam.getDevType()); -// } -// if (StrUtil.isNotBlank(queryParam.getDevModel()) && !Objects.isNull(queryParam.getDevModel())){ -// queryWrapper.eq("cs_equipment_delivery.dev_model", queryParam.getDevModel()); -// } -// if (StrUtil.isNotBlank(queryParam.getDevAccessMethod()) && !Objects.isNull(queryParam.getDevAccessMethod())){ -// queryWrapper.eq("cs_equipment_delivery.dev_access_method", queryParam.getDevAccessMethod()); -// } -// if (!Objects.isNull(queryParam.getStatus())){ -// queryWrapper.eq("cs_equipment_delivery.status", queryParam.getStatus()); -// } else { -// queryWrapper.in("cs_equipment_delivery.status", Arrays.asList(1,2,3)); -// } -// if (!Objects.isNull(queryParam.getRunStatus())){ -// queryWrapper.eq("cs_equipment_delivery.run_status", queryParam.getRunStatus()); -// } else { -// queryWrapper.in("cs_equipment_delivery.run_status", Arrays.asList(1,2)); -// } -// if (!Objects.isNull(queryParam.getProcess())){ -// queryWrapper.eq("cs_equipment_delivery.process", queryParam.getProcess()); -// } -// Page page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper); -// page.getRecords().forEach(item->{ -// if (!Objects.isNull(item.getQrPath())){ -// item.setQrPath(item.getQrPath()); -// } -// }); -// //新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入) -// for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){ -// if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){ -// csEquipmentDeliveryVO.setStatus(5); -// } else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) { -// csEquipmentDeliveryVO.setStatus(6); -// } -// //判断装置是否已经连接上mqtt服务器 -// String clientName = "NJCN-" + csEquipmentDeliveryVO.getNdid().substring(csEquipmentDeliveryVO.getNdid().length() - 6); -// boolean mqttClient = mqttUtil.judgeClientOnline(clientName); -// if (mqttClient) { -// csEquipmentDeliveryVO.setConnectStatus("已连接"); -// } else { -// csEquipmentDeliveryVO.setConnectStatus("未连接"); -// } -// } -// return page; -// } - @Override public DeviceManagerVO getDeviceData(String deviceId, String type, String lineId) { DeviceManagerVO deviceManagerVo = new DeviceManagerVO(); @@ -443,7 +372,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl dataSet = new ArrayList<>(); List modelId = csDevModelRelationService.findModelByDevId(deviceId); if (CollUtil.isNotEmpty(modelId)){ @@ -472,6 +401,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl trueCollect = new ArrayList<> ( ); List falseCollect = new ArrayList<> ( ); - for (int i = 0; i < terminalBaseList.getList ( ).size ( ); i++) { DeviceExcelTemplete deviceExcelTemplete = terminalBaseList.getList ( ).get (i); - if(!deviceExcelTemplete.getNdid().matches(regex)){ DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete(); BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException); @@ -551,7 +484,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl children = deviceType.get(0).getChildren(); Map map = children.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO)); - List collect = children.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevType())).collect(Collectors.toList()); SysDicTreePO sysDicTreePO = map.get(deviceExcelTemplete.getDevType()); if(CollectionUtils.isEmpty(collect)){ @@ -583,15 +514,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl children1 = sysDicTreePO.getChildren(); Map map2 = children1.stream().collect(Collectors.toMap(SysDicTreePO::getName, dictTreeVO -> dictTreeVO)); - List collect2 = children1.stream().filter(temp -> Objects.equals(temp.getName(), deviceExcelTemplete.getDevModel())).collect(Collectors.toList()); - if(CollectionUtils.isEmpty(collect2)){ DeviceExcelTemplete.IllegalityDeviceExcelTemplete idlegalityDeviceException = new DeviceExcelTemplete.IllegalityDeviceExcelTemplete(); BeanUtils.copyProperties(deviceExcelTemplete,idlegalityDeviceException); @@ -602,8 +529,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl collect1 = new ArrayList<>(); @@ -618,7 +543,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl list = csEquipmentProcessPOService.lambdaQuery().eq(CsEquipmentProcessPO::getDevId, one.getNdid()). eq(CsEquipmentProcessPO::getProcess, type).orderByDesc(CsEquipmentProcessPO::getStartTime).list(); @@ -735,8 +657,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl lambdaUpdateWrapper = new LambdaUpdateWrapper<>(); lambdaUpdateWrapper.eq(CsEquipmentDeliveryPO::getNdid,nDid) - .ne(CsEquipmentDeliveryPO::getRunStatus,0) - .set(CsEquipmentDeliveryPO::getSoftinfoId,id); + .ne(CsEquipmentDeliveryPO::getRunStatus,0) + .set(CsEquipmentDeliveryPO::getSoftinfoId,id); result = this.update(lambdaUpdateWrapper); if (result) { refreshDeviceDataCache(); @@ -800,6 +722,195 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl devList = getListByNodeId(param.getNodeId()); + if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) { + throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT); + } + //判断2 + int process = findLeastFrequentProcess(devList,node.getMaxProcessNum()); + csEquipmentDeliveryPo.setNodeProcess(process); + result = this.save(csEquipmentDeliveryPo); + + //新增设备与模板之间的关系 获取云前置模板 + CsDevModelPO csDevModelPO = csDevModelService.getCldModel(); + CsDevModelRelationAddParm relationAddParam = new CsDevModelRelationAddParm(); + relationAddParam.setDevId(csEquipmentDeliveryPo.getId()); + relationAddParam.setModelId(csDevModelPO.getId()); + relationAddParam.setDid(1); + CsDevModelRelationPO relation = csDevModelRelationService.addDevModelRelation(relationAddParam); + + //新增台账数据 + CsLedger csLedger = new CsLedger(); + csLedger.setId(csEquipmentDeliveryPo.getId()); + csLedger.setPid(param.getProjectId()); + csLedger.setPids("0," + param.getEngineeringId() + "," + param.getProjectId()); + csLedger.setLevel(2); + csLedger.setName(param.getName()); + csLedger.setState(1); + csLedger.setSort(0); + int addLedger = csLedgerMapper.insert(csLedger); + + if (result && ObjectUtil.isNotNull(relation) && addLedger > 0) { + refreshDeviceDataCache(); + } + return csEquipmentDeliveryPo; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public Boolean delCldDev(String id) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId,id); + boolean update = this.remove(lambdaQueryWrapper); + List list = csLedgerService.lambdaQuery().eq(CsLedger::getPid, id).list(); + if(!CollectionUtils.isEmpty(list)){ + List collect = list.stream().map(CsLedger::getId).collect(Collectors.toList()); + LambdaQueryWrapper csLinePOLambdaQueryWrapper = new LambdaQueryWrapper<>(); + csLinePOLambdaQueryWrapper.in(CsLinePO::getLineId,collect); + csLinePOService.remove(csLinePOLambdaQueryWrapper); + } + LambdaQueryWrapper csLedgerLambdaQueryWrapper = new LambdaQueryWrapper<>(); + csLedgerLambdaQueryWrapper.clear(); + csLedgerLambdaQueryWrapper.eq(CsLedger::getId,id); + csLedgerService.remove(csLedgerLambdaQueryWrapper); + csLedgerLambdaQueryWrapper.clear(); + csLedgerLambdaQueryWrapper.eq(CsLedger::getPid,id); + csLedgerService.remove(csLedgerLambdaQueryWrapper); + csDevModelRelationService.lambdaUpdate().eq(CsDevModelRelationPO::getDevId,id).set(CsDevModelRelationPO::getStatus,0).update(); + if (update) { + refreshDeviceDataCache(); + } + return true; + } + + @Override + public Boolean updateCldDev(CsEquipmentDeliveryAuditParm param) { + //云前置设备判断,修改云前置判断设备是否达到上限 + if(ObjectUtil.isNotNull(param.getNodeId())){ + Node node = nodeService.getNodeById(param.getNodeId()); + List devList = getListByNodeId(param.getNodeId()); + if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) { + throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT); + } + //自动分配进程号 + int process = findLeastFrequentProcess(devList,node.getMaxProcessNum()); + param.setNodeProcess(process); + } + StringUtil.containsSpecialCharacters(param.getNdid()); + boolean result; + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid,param.getNdid()) + .in(CsEquipmentDeliveryPO::getStatus,Arrays.asList(1,2,3)) + .ne(CsEquipmentDeliveryPO::getId, param.getId()); + int countByAccount = this.count(lambdaQueryWrapper); + //大于等于1个则表示重复 + if (countByAccount >= 1) { + throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR); + } + LambdaQueryWrapper lambdaQueryWrapper2 = new LambdaQueryWrapper<>(); + lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId()); + CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2); + List list = this.lambdaQuery() + .ne(CsEquipmentDeliveryPO::getId, param.getId()) + .ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()) + .eq(CsEquipmentDeliveryPO::getName, param.getName()) + .ne(CsEquipmentDeliveryPO::getRunStatus, 0).list(); + if(!CollectionUtils.isEmpty (list)){ + throw new BusinessException ("设备名称不能重复"); + } + CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO(); + BeanUtils.copyProperties (param, csEquipmentDeliveryPo); + String path = this.createPath(param.getNdid()); + csEquipmentDeliveryPo.setMac(path); + result = this.updateById(csEquipmentDeliveryPo); + //修改台账树中的设备名称 + CsLedger csLedger = csLedgerService.findDataById(param.getId()); + if (!Objects.isNull(csLedger)) { + CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update(); + BeanUtils.copyProperties (csLedger, csLedgerParam); + csLedgerParam.setName(param.getName()); + csLedgerService.updateLedgerTree(csLedgerParam); + } + if (result) { + refreshDeviceDataCache(); + if (!Objects.equals(po.getUsageStatus(),param.getUsageStatus())) { + DeviceLogDTO dto = new DeviceLogDTO(); + dto.setUserName(RequestUtil.getUsername()); + dto.setOperate("设备使用状态被修改"); + dto.setResult(1); + dto.setLoginName(RequestUtil.getLoginName()); + csLogsFeignClient.addUserLog(dto); + } + } + return result; + } + + @Override + public List getCldDevByIp(String id, List runFlag) { + //运行状态转换 + List state = new ArrayList<>(); + if (CollectionUtil.isNotEmpty(runFlag)) { + if (runFlag.contains(0)) { + state.add(1); + } + if (runFlag.contains(2)) { + state.add(0); + } + //fixme 目前治理设备只有启用和停用,没有那么多状态,如果前置传递其他状态,先设置一个不存在的状态 + state.add(9); + } + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,id) + .in(ObjectUtil.isNotEmpty(state),CsEquipmentDeliveryPO::getUsageStatus,state); + return this.list(lambdaQueryWrapper); + } + + //根据前置机id获取装置数量 + public List getListByNodeId(String nodeId) { + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId) + .in(CsEquipmentDeliveryPO::getRunStatus,Arrays.asList(1,2)); + return this.list(lambdaQueryWrapper); + } + + public int findLeastFrequentProcess(List items, Integer process) { + Map processCounts = items.stream() + .collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess, Collectors.counting())); + for (int i = 1; i <= process; i++) { + processCounts.putIfAbsent(i, 0L); + } + //如果列表为空,默认返回1 + return processCounts.entrySet().stream() + .min(Comparator.comparingLong(Map.Entry::getValue)) + .map(Map.Entry::getKey) + .orElse(1); + } + /** * 根据ndid生成二维码 * @param ndid @@ -819,7 +930,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl implements CsLinePOService{ + private final CsLedgerMapper csLedgerMapper; + private final CsDevModelService csDevModelService; + private final ICsDataSetService csDataSetService; + private final DicDataFeignClient dicDataFeignClient; @Override public List getLineByDev(List list) { @@ -88,6 +100,42 @@ public class CsLinePOServiceImpl extends ServiceImpl i return this.lambdaQuery().in(CsLinePO::getDeviceId,list).eq(CsLinePO::getStatus,1).list(); } + @Override + @Transactional(rollbackFor = Exception.class) + public void addCldLine(CsLineParam param) { + CsLinePO po = new CsLinePO(); + //1.新增监测点信息 + BeanUtils.copyProperties(param,po); + po.setStatus(1); + po.setRunStatus(2); + po.setLineId(param.getDevMac().replace(":","") + param.getClDid()); + //模板id + CsDevModelPO po1 = csDevModelService.getCldModel(); + po.setDataModelId(po1.getId()); + //设备id + po.setDeviceId(param.getDevId()); + //数据集id + List list = csDataSetService.findDataSetByModelId(po1.getId()); + if (CollectionUtil.isNotEmpty(list)) { + po.setDataSetId(list.get(0).getId()); + } + //监测位置 + DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData(); + po.setPosition(data.getId()); + this.save(po); + + //2.新增台账树信息 + CsLedger csLedger = new CsLedger(); + csLedger.setId(param.getDevMac().replace(":","") + param.getClDid()); + csLedger.setPid(param.getDevId()); + csLedger.setPids("0," + param.getEngineeringId() + "," + param.getProjectId() + "," + param.getDevId()); + csLedger.setName(param.getName()); + csLedger.setLevel(3); + csLedger.setState(1); + csLedger.setSort(0); + csLedgerMapper.insert(csLedger); + } + // /** // * 1.平台端默认配置拓扑图模板,包含拓扑图信息(cs_topology_diagram_template)和拓扑图上监测点的点位信息(cs_line_topology_template) // * diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java new file mode 100644 index 0000000..f754658 --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/IcdServiceImpl.java @@ -0,0 +1,220 @@ +package com.njcn.csdevice.service.impl; + +import cn.hutool.core.collection.CollectionUtil; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.njcn.access.utils.ChannelObjectUtil; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.csdevice.param.IcdLedgerParam; +import com.njcn.csdevice.param.IcdParam; +import com.njcn.csdevice.pojo.param.AppProjectAddParm; +import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryAddParm; +import com.njcn.csdevice.pojo.param.CsLineParam; +import com.njcn.csdevice.pojo.po.*; +import com.njcn.csdevice.pojo.vo.DeviceInfo; +import com.njcn.csdevice.service.*; +import com.njcn.redis.pojo.enums.AppRedisKey; +import com.njcn.redis.utils.RedisUtil; +import com.njcn.system.enums.DicDataEnum; +import com.njcn.system.pojo.po.SysDicTreePO; +import lombok.RequiredArgsConstructor; +import org.jetbrains.annotations.NotNull; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; + +import java.util.*; +import java.util.function.Function; +import java.util.stream.Collectors; + +@Service +@RequiredArgsConstructor +class IcdServiceImpl implements IcdService { + + private final INodeService nodeService; + private final ChannelObjectUtil channelObjectUtil; + private final RedisUtil redisUtil; + private final CsEngineeringService csEngineeringService; + private final AppProjectService appProjectService; + private final CsEquipmentDeliveryService csEquipmentDeliveryService; + private final CsDevModelRelationService csDevModelRelationService; + private final CsLinePOService csLinePOService; + + @Override + public List getLedgerInfo(IcdParam param) { + //获取装置型号 + Map sysDicTreeMap = new HashMap<>(); + List dictTreeList = channelObjectUtil.objectToList(redisUtil.getObjectByKey(AppRedisKey.DICT_TREE),SysDicTreePO.class); + SysDicTreePO po = dictTreeList.stream().filter(item -> Objects.equals(item.getCode(), DicDataEnum.DEV_CLD.getCode())).findFirst().orElse(null); + if (ObjectUtil.isNotNull(po)) { + String id = po.getId(); + List cldDevType = dictTreeList.stream().filter(item->Objects.equals(item.getPid(),id)).collect(Collectors.toList()); + sysDicTreeMap = cldDevType.stream().collect(Collectors.toMap(SysDicTreePO::getId, Function.identity())); + } + + List result = new ArrayList<>(); + //根据ip获取前置机信息 + Node node = nodeService.getNodeByIp(param.getIp()); + if (ObjectUtil.isNotNull(node)) { + //根据前置机ip获取装置信息 + List poList = csEquipmentDeliveryService.getCldDevByIp(node.getId(),param.getRunFlag()); + if (CollectionUtil.isNotEmpty(poList)) { + //获取监测点集合 + List devList = poList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList()); + List lineList = csLinePOService.getLinesByDevList(devList); + Map> lineMap = lineList.stream().collect(Collectors.groupingBy(CsLinePO::getDeviceId)); + //组装返回结构体 + Map finalSysDicTreeMap = sysDicTreeMap; + poList.forEach(dev->{ + DeviceInfo detail = new DeviceInfo(); + detail.setId(dev.getId()); + detail.setName(dev.getName()); + detail.setIp(dev.getMac()); + detail.setDevType(Objects.isNull(finalSysDicTreeMap.get(dev.getDevModel())) ? "/":finalSysDicTreeMap.get(dev.getDevModel()).getCode()); + detail.setNode(dev.getNodeProcess()); + + // 只获取当前设备的监测点数据 + List lines = lineMap.get(dev.getId()); + if (CollectionUtil.isNotEmpty(lines)) { + List monitorInfos = new ArrayList<>(); + lines.forEach(line->{ + DeviceInfo.MonitorInfo monitorInfo = new DeviceInfo.MonitorInfo(); + monitorInfo.setDeviceId(dev.getId()); + monitorInfo.setId(line.getLineId()); + monitorInfo.setName(line.getName()); + monitorInfo.setLineNo(String.valueOf(line.getClDid())); + monitorInfo.setVoltageLevel(line.getVolGrade() + "kV"); + monitorInfo.setStatus(line.getRunStatus()); + monitorInfo.setPtType(String.valueOf(line.getConType())); + monitorInfo.setPt1(line.getPtRatio()); + monitorInfo.setPt2(line.getPt2Ratio()); + monitorInfo.setCt1(line.getCtRatio()); + monitorInfo.setCt2(line.getCt2Ratio()); + monitorInfos.add(monitorInfo); + }); + detail.setMonitorData(monitorInfos); + } + result.add(detail); + }); + } + } + return result; + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void addLedgerInfo(IcdLedgerParam param) { + // 第一种:全流程创建 + if (isAllIndicesNull(param)) { + handleFullProcessCreation(param); + } + // 第二种:从工程创建 + else if (ObjectUtil.isNotNull(param.getEngineeringIndex())) { + handleFromEngineeringCreation(param); + } + // 第三种:从项目创建 + else if (ObjectUtil.isNotNull(param.getProjectIndex())) { + handleFromProjectCreation(param); + } + // 第四种:从设备创建 + else if (CollectionUtil.isNotEmpty(param.getDevice())) { + handleFromDeviceCreation(param); + } + } + + private boolean isAllIndicesNull(IcdLedgerParam param) { + return ObjectUtil.isNull(param.getEngineeringIndex()) + && ObjectUtil.isNull(param.getProjectIndex()) + && ObjectUtil.isNull(param.getDevIndex()); + } + + private void handleFullProcessCreation(@NotNull IcdLedgerParam param) { + if (ObjectUtil.isNotNull(param.getEngineering())) { + CsEngineeringPO po1 = csEngineeringService.addEngineering(param.getEngineering()); + param.setEngineeringIndex(po1.getId()); + createProjectAndDevices(param); + } + } + + private void handleFromEngineeringCreation(IcdLedgerParam param) { + createProjectAndDevices(param); + } + + private void handleFromProjectCreation(IcdLedgerParam param) { + saveDevicesAndLines(param); + } + + private void handleFromDeviceCreation(IcdLedgerParam param) { + saveLines(param); + } + + private void createProjectAndDevices(IcdLedgerParam param) { + AppProjectAddParm project = param.getProject(); + if (ObjectUtil.isNotNull(project)) { + project.setEngineeringId(param.getEngineeringIndex()); + project.setIcdEngineeringId(param.getEngineeringIndex()); + AppProjectPO po2 = appProjectService.addAppProject(project); + param.setProjectIndex(po2.getId()); + } + saveDevicesAndLines(param); + } + + private void saveDevicesAndLines(IcdLedgerParam param) { + List devList = param.getDevice(); + if (CollectionUtil.isNotEmpty(devList)) { + Map devMacMap = new HashMap<>(); + for (CsEquipmentDeliveryAddParm dev : devList) { + dev.setEngineeringId(param.getEngineeringIndex()); + dev.setProjectId(param.getProjectIndex()); + CsEquipmentDeliveryPO po3 = csEquipmentDeliveryService.saveCld(dev); + devMacMap.put(dev.getMac(),po3.getId()); + } + param.setDevMacMap(devMacMap); + } + saveLines(param); + } + + private void saveLines(IcdLedgerParam param) { + List lineList = param.getLine(); + if (CollectionUtil.isNotEmpty(lineList)) { + boolean result = checkAndAlertDuplicates(lineList); + if (result) { + throw new BusinessException("监测点线路号重复,请调整!"); + } + for (CsLineParam line : lineList) { + line.setEngineeringId(param.getEngineeringIndex()); + line.setProjectId(param.getProjectIndex()); + if (Objects.isNull(param.getDevIndex())) { + line.setDevId(param.getDevMacMap().get(line.getDevMac())); + } else { + LambdaQueryWrapper wrapper = new LambdaQueryWrapper<>(); + wrapper.eq(CsLinePO::getDeviceId,param.getDevIndex()).eq(CsLinePO::getClDid,line.getClDid()).eq(CsLinePO::getStatus,1); + CsLinePO po4 = csLinePOService.getOne(wrapper); + if (ObjectUtil.isNotNull(po4)) { + throw new BusinessException("监测点线路号重复,请调整!"); + } + line.setDevId(param.getDevIndex()); + } + csLinePOService.addCldLine(line); + } + } + } + + //判断相同设备不能存在相同的线路号监测点 + public boolean checkAndAlertDuplicates(List devices) { + // 使用Set来记录已经出现过的devMac+clDid组合 + Set seenCombinations = new HashSet<>(); + List duplicates = new ArrayList<>(); + + for (CsLineParam device : devices) { + String combination = device.getDevMac() + "-" + device.getClDid(); + if (seenCombinations.contains(combination)) { + // 发现重复,添加到重复列表 + duplicates.add(device); + } else { + seenCombinations.add(combination); + } + } + return !duplicates.isEmpty(); + } + +} diff --git a/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/NodeServiceImpl.java b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/NodeServiceImpl.java new file mode 100644 index 0000000..750c05f --- /dev/null +++ b/cs-device/cs-device-boot/src/main/java/com/njcn/csdevice/service/impl/NodeServiceImpl.java @@ -0,0 +1,166 @@ +package com.njcn.csdevice.service.impl; + + +import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.njcn.common.pojo.enums.common.DataStateEnum; +import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.csdevice.enums.AlgorithmResponseEnum; +import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper; +import com.njcn.csdevice.mapper.NodeMapper; +import com.njcn.csdevice.pojo.param.NodeParam; +import com.njcn.csdevice.pojo.po.Node; +import com.njcn.csdevice.service.INodeService; +import com.njcn.db.constant.DbConstant; +import com.njcn.device.biz.enums.DeviceResponseEnum; +import com.njcn.web.factory.PageFactory; +import lombok.AllArgsConstructor; +import org.springframework.beans.BeanUtils; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Propagation; +import org.springframework.transaction.annotation.Transactional; + +import java.util.List; +import java.util.Objects; + +/** + *

+ * 服务实现类 + *

+ * + * @author cdf + * @since 2022-01-07 + */ +@DS("sjzx") +@Service +@AllArgsConstructor +public class NodeServiceImpl extends ServiceImpl implements INodeService { + + private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper; + + @Override + public boolean addNode(NodeParam nodeParam) { + checkNode(nodeParam, false); + Node node = new Node(); + BeanUtils.copyProperties(nodeParam, node); + node.setState(DataStateEnum.ENABLE.getCode()); + this.save(node); + return true; + } + + @Override + public boolean updateNode(NodeParam.NodeUpdateParam nodeParam) { + //修改最大进程时,需要判断,如果进程数减少,需要先将少的进程数下面的测点分配到其他进程下面 + int count = csEquipmentDeliveryMapper.getListByNodeProcess(nodeParam.getId(),nodeParam.getMaxProcessNum()); + if (count > 0) { + throw new BusinessException(AlgorithmResponseEnum.DEV_OLD_DATA); + } + checkNode(nodeParam, true); + Node node = new Node(); + BeanUtils.copyProperties(nodeParam, node); + this.updateById(node); + return true; + } + + @Override + public boolean delNode(String id) { + //删除前置机,如果前置机下有设备,不允许删除 + int count = csEquipmentDeliveryMapper.getListByNodeProcess(id,null); + if (count > 0) { + throw new BusinessException(AlgorithmResponseEnum.DEV_EXIST_DATA); + } + return this.removeById(id); + } + + @Override + public boolean updateNodeState(String id, Integer state) { + Node node = new Node(); + node.setId(id); + node.setState(state); + return this.updateById(node); + } + + + @Override + public Page nodeList(NodeParam.NodeQueryParam nodeQueryParam) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + //查询参数不为空,进行条件填充 + if (Objects.nonNull(nodeQueryParam)) { + if(Objects.nonNull(nodeQueryParam.getNodeGrade()) ){ + queryWrapper.eq("pq_node.node_grade",nodeQueryParam.getNodeGrade()); + } + if(Objects.nonNull(nodeQueryParam.getSearchState()) ){ + queryWrapper.eq("pq_node.state",nodeQueryParam.getSearchState()); + } + //模糊值查询 + if (StrUtil.isNotBlank(nodeQueryParam.getSearchValue())) { + //仅提供名称、ip模糊查询 + queryWrapper.and(param -> param.like("pq_node.name", nodeQueryParam.getSearchValue()) + .or().like("pq_node.ip", nodeQueryParam.getSearchValue())); + } + //排序字段不为空 + if (ObjectUtil.isAllNotEmpty(nodeQueryParam.getSortBy(), nodeQueryParam.getOrderBy())) { + queryWrapper.orderBy(true, nodeQueryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(nodeQueryParam.getSortBy())); + } else { + //没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序 + queryWrapper.orderBy(true, true, "pq_node.sort"); + } + } + return this.page(new Page<>(PageFactory.getPageNum(nodeQueryParam), PageFactory.getPageSize(nodeQueryParam)), queryWrapper); + } + + @Override + public List nodeAllList(){ + LambdaQueryWrapper nodeLambdaQueryWrapper = new LambdaQueryWrapper<>(); + nodeLambdaQueryWrapper.eq(Node::getState,DataStateEnum.ENABLE.getCode()).orderByAsc(Node::getState); + return this.list(nodeLambdaQueryWrapper); + } + + @Override + @Transactional(propagation = Propagation.NOT_SUPPORTED) + public Node getNodeById(String id) { + return this.getById(id); + } + + @Override + public Node getNodeByNodeName(String nodeName) { + LambdaQueryWrapper nodeLambdaQueryWrapper = new LambdaQueryWrapper<>(); + nodeLambdaQueryWrapper.eq(Node::getName, nodeName) + .eq(Node::getState, DataStateEnum.ENABLE.getCode()); + return this.baseMapper.selectOne(nodeLambdaQueryWrapper); + } + + @Override + public Node getNodeByIp(String ip) { + LambdaQueryWrapper nodeLambdaQueryWrapper = new LambdaQueryWrapper<>(); + nodeLambdaQueryWrapper.eq(Node::getIp, ip) + .eq(Node::getState, DataStateEnum.ENABLE.getCode()); + return this.baseMapper.selectOne(nodeLambdaQueryWrapper); + } + + /** + * 校验参数,检查是否存在相同编码的字典类型 + */ + private void checkNode(NodeParam nodeParam, boolean isExcludeSelf) { + LambdaQueryWrapper nodeLambdaQueryWrapper = new LambdaQueryWrapper<>(); + nodeLambdaQueryWrapper + .eq(Node::getIp, nodeParam.getIp()) + .eq(Node::getState, DataStateEnum.ENABLE.getCode()); + //更新的时候,需排除当前记录 + if (isExcludeSelf) { + if (nodeParam instanceof NodeParam.NodeUpdateParam) { + nodeLambdaQueryWrapper.ne(Node::getId, ((NodeParam.NodeUpdateParam) nodeParam).getId()); + } + } + int countByAccount = this.count(nodeLambdaQueryWrapper); + //大于等于1个则表示重复 + if (countByAccount >= 1) { + throw new BusinessException(DeviceResponseEnum.NODE_IP_SAME); + } + } +} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/enums/CsHarmonicResponseEnum.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/enums/CsHarmonicResponseEnum.java index fe93922..d3655c5 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/enums/CsHarmonicResponseEnum.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/enums/CsHarmonicResponseEnum.java @@ -17,7 +17,9 @@ public enum CsHarmonicResponseEnum { CS_DEVICE_COMMON_ERROR("A00600","治理稳态模块异常"), BIND_TARGET_ERROR("A00601","指标参数绑定异常"), MAKE_UP_ERROR("A00602","补招失败"), - RECORD_MISSING("A00602","record.bin文件缺失,补召失败") + RECORD_MISSING("A00602","record.bin文件缺失,补召失败"), + + EVENT_FILE_NOT_SAME("A00603","cfg、dat文件名称不一致"), ; diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CldEventParam.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CldEventParam.java new file mode 100644 index 0000000..f0a7942 --- /dev/null +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/param/CldEventParam.java @@ -0,0 +1,38 @@ +package com.njcn.csharmonic.param; + +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.io.Serializable; + +/** + * @author xy + */ +@Data +public class CldEventParam implements Serializable { + + @ApiModelProperty("监测点id") + private String monitorId; + + @ApiModelProperty("暂降触发时间") + private String startTime; + + @ApiModelProperty("幅值") + private Double amplitude; + + @ApiModelProperty("持续时间") + private Double duration; + + @ApiModelProperty("暂态类型 0-未知 1-暂降 2-暂升 3-中断 4-瞬态") + private Integer eventType; + + @ApiModelProperty("相别") + private String phase; + + @ApiModelProperty("Cfg文件路径") + private String wavePathCfg; + + @ApiModelProperty("Dat文件路径") + private String wavePathDat; + +} diff --git a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java index 61d119b..ccc6921 100644 --- a/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java +++ b/cs-harmonic/cs-harmonic-api/src/main/java/com/njcn/csharmonic/pojo/po/CsEventPO.java @@ -117,4 +117,10 @@ public class CsEventPO extends BaseEntity { */ @TableField(value = "persist_time") private Double persistTime; + + /** + * 暂降幅值 + */ + @TableField(value = "amplitude") + private Double amplitude; } \ No newline at end of file diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CsEventController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CsEventController.java index f94e7dc..dc518ad 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CsEventController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/CsEventController.java @@ -7,6 +7,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.utils.HttpResultUtil; import com.njcn.csdevice.pojo.vo.DataGroupEventVO; +import com.njcn.csharmonic.param.CldEventParam; import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.DataParam; @@ -42,7 +43,6 @@ public class CsEventController extends BaseController { private final CsEventPOService csEventPOService; - @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/queryEventList") @ApiOperation("暂降事件列表查询") @@ -53,7 +53,6 @@ public class CsEventController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); } - @OperateInfo(info = LogEnum.BUSINESS_COMMON) @PostMapping("/pageQueryByLineId") @ApiOperation("根据监测点分页查询暂降事件") @@ -121,4 +120,14 @@ public class CsEventController extends BaseController { return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/addCldEvent") + @ApiOperation("新增云前置事件") + @ApiImplicitParam(name = "param", value = "事件信息", required = true) + public HttpResult addCldEvent(@RequestBody CldEventParam param) { + String methodDescribe = getMethodDescribe("addCldEvent"); + csEventPOService.addCldEvent(param); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } + } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/RealDataController.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/RealDataController.java index 2005cf4..b2664bf 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/RealDataController.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/controller/RealDataController.java @@ -70,4 +70,14 @@ public class RealDataController extends BaseController { } } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @PostMapping("/getCldBaseRealData") + @ApiOperation("获取云前置基础实时数据") + @ApiImplicitParam(name = "lineId", value = "监测点id") + public HttpResult getCldBaseRealData(@RequestParam("lineId") String lineId) { + String methodDescribe = getMethodDescribe("getCldBaseRealData"); + realDataService.getCldBaseRealData(lineId); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "平台下发指令成功", methodDescribe); + } + } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java index 5058893..7612b19 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/CsEventPOService.java @@ -1,12 +1,13 @@ package com.njcn.csharmonic.service; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.csdevice.pojo.vo.DataGroupEventVO; +import com.njcn.csharmonic.param.CldEventParam; import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.DataParam; import com.njcn.csharmonic.pojo.po.CsEventPO; -import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.csharmonic.pojo.vo.CsEventVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.event.file.pojo.dto.WaveDataDTO; @@ -56,4 +57,6 @@ public interface CsEventPOService extends IService{ List queryByModelId(DataParam param); + void addCldEvent(CldEventParam param); + } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/RealDataService.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/RealDataService.java index f79adcb..7787c54 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/RealDataService.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/RealDataService.java @@ -17,4 +17,6 @@ public interface RealDataService { */ boolean getHarmRealData(String lineId,Integer target); + void getCldBaseRealData(String lineId); + } diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java index 566bfdd..5294459 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventPOServiceImpl.java @@ -18,7 +18,9 @@ import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.pojo.dto.DevDetailDTO; import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.vo.DataGroupEventVO; +import com.njcn.csharmonic.enums.CsHarmonicResponseEnum; import com.njcn.csharmonic.mapper.CsEventPOMapper; +import com.njcn.csharmonic.param.CldEventParam; import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.DataParam; @@ -57,6 +59,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URLEncoder; import java.time.LocalDateTime; +import java.time.format.DateTimeFormatter; import java.util.*; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -74,21 +77,13 @@ import java.util.stream.Stream; public class CsEventPOServiceImpl extends ServiceImpl implements CsEventPOService { private final EvtDataService evtDataService; - private final FileStorageUtil fileStorageUtil; - private final WaveFileComponent waveFileComponent; - private final CsLineFeignClient csLineFeignClient; - private final CsLedgerFeignClient csLedgerFeignClient; - private final EpdFeignClient epdFeignClient; - private final CsEventUserPOService csEventUserPOService; - private final EleEvtFeignClient eleEvtFeignClient; - private final WavePicComponent wavePicComponent; private final MinIossProperties minIossProperties; @@ -245,6 +240,71 @@ public class CsEventPOServiceImpl extends ServiceImpl lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper.eq(CsEventPO::getLineId,param.getMonitorId()).eq(CsEventPO::getStartTime,param.getStartTime()); + CsEventPO event = this.getOne(lambdaQueryWrapper); + if (Objects.isNull(event)) { + //首次录入 + //根据监测点获取装置信息 + CsLinePO po = csLineFeignClient.getById(param.getMonitorId()).getData(); + CsEventPO eventPo = new CsEventPO(); + eventPo.setLineId(param.getMonitorId()); + eventPo.setDeviceId(po.getDeviceId()); + LocalDateTime time = LocalDateTime.parse(param.getStartTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_MS_PATTERN)); + eventPo.setStartTime(time); + eventPo.setTag(getTag(param.getEventType())); + eventPo.setType(0); + eventPo.setClDid(Integer.parseInt(param.getMonitorId().substring(param.getMonitorId().length() - 1))); + eventPo.setLevel(2); + eventPo.setProcess(4); + eventPo.setPersistTime(param.getDuration()/1000); + eventPo.setAmplitude(param.getAmplitude()); + this.baseMapper.insert(eventPo); + } else { + if (StrUtil.isNotBlank(param.getWavePathCfg()) && StrUtil.isNotBlank(param.getWavePathDat())) { + //更新文件信息 + //先校验两份文件的名称是否一致 + String cfgFileName = param.getWavePathCfg().split("\\.")[0]; + String datFileName = param.getWavePathDat().split("\\.")[0]; + if (!Objects.equals(cfgFileName, datFileName)) { + throw new BusinessException(CsHarmonicResponseEnum.EVENT_FILE_NOT_SAME); + } + this.lambdaUpdate() + .eq(CsEventPO::getLineId,param.getMonitorId()) + .eq(CsEventPO::getStartTime,param.getStartTime()) + .set(CsEventPO::getWavePath,cfgFileName) + .update(); + } + } + } + + public String getTag(Integer type) { + String tag; + switch (type) { + case 1: + tag = "Evt_Sys_DipStr"; + break; + case 2: + tag = "Evt_Sys_SwlStr"; + break; + case 3: + tag = "Evt_Sys_IntrStr"; + break; + case 4: + tag = "Transient"; + break; + default: + tag = "Un_Know"; + break; + } + return tag; + } + + + /** * @return WaveDataDTO diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java index 7d05142..42969f4 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/CsEventUserPOServiceImpl.java @@ -3,42 +3,37 @@ package com.njcn.csharmonic.service.impl; import cn.hutool.core.collection.CollectionUtil; import com.alibaba.fastjson.JSONArray; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.njcn.common.pojo.constant.LogInfo; import com.njcn.csdevice.api.CsLedgerFeignClient; import com.njcn.csdevice.constant.DataParam; import com.njcn.csdevice.pojo.dto.DevDetailDTO; - import com.njcn.csdevice.pojo.vo.CsLedgerVO; import com.njcn.csharmonic.mapper.CsEventPOMapper; +import com.njcn.csharmonic.mapper.CsEventUserPOMapper; import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryParam; +import com.njcn.csharmonic.pojo.po.CsEventUserPO; import com.njcn.csharmonic.pojo.vo.EventDetailVO; -import com.njcn.csharmonic.service.CsEventPOService; +import com.njcn.csharmonic.service.CsEventUserPOService; import com.njcn.influx.pojo.dto.EventDataSetDTO; import com.njcn.influx.service.EvtDataService; import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.EleEvtFeignClient; import com.njcn.system.api.EpdFeignClient; - import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEvtParm; import com.njcn.user.enums.AppRoleEnum; import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; - import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.util.*; import java.util.stream.Collectors; -import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; -import com.njcn.csharmonic.pojo.po.CsEventUserPO; -import com.njcn.csharmonic.mapper.CsEventUserPOMapper; -import com.njcn.csharmonic.service.CsEventUserPOService; -import org.springframework.util.CollectionUtils; -import org.springframework.util.StringUtils; - /** * * Description: diff --git a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RealDataServiceImpl.java b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RealDataServiceImpl.java index 7b3a139..6137116 100644 --- a/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RealDataServiceImpl.java +++ b/cs-harmonic/cs-harmonic-boot/src/main/java/com/njcn/csharmonic/service/impl/RealDataServiceImpl.java @@ -1,22 +1,30 @@ package com.njcn.csharmonic.service.impl; +import com.alibaba.cloud.commons.lang.StringUtils; import com.njcn.access.api.AskDeviceDataFeignClient; import com.njcn.access.utils.MqttUtil; import com.njcn.common.pojo.exception.BusinessException; import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.DataSetFeignClient; +import com.njcn.csdevice.api.EquipmentFeignClient; import com.njcn.csdevice.pojo.po.CsDataSet; import com.njcn.csdevice.pojo.po.CsLinePO; +import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO; import com.njcn.csharmonic.service.RealDataService; import com.njcn.redis.utils.RedisUtil; +import com.njcn.web.utils.RequestUtil; import lombok.RequiredArgsConstructor; +import lombok.extern.log4j.Log4j; +import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; -import java.util.Objects; +import java.util.*; +import java.util.stream.Collectors; /** * @author xuyang */ +@Slf4j @Service @RequiredArgsConstructor public class RealDataServiceImpl implements RealDataService { @@ -24,6 +32,7 @@ public class RealDataServiceImpl implements RealDataService { private final CsLineFeignClient csLineFeignClient; private final DataSetFeignClient dataSetFeignClient; private final AskDeviceDataFeignClient askDeviceDataFeignClient; + private final EquipmentFeignClient equipmentFeignClient; private final RedisUtil redisUtil; private final MqttUtil mqttUtil; @@ -93,4 +102,116 @@ public class RealDataServiceImpl implements RealDataService { } return result; } + + @Override + public void getCldBaseRealData(String lineId) { + try { + // 参数校验 + if (StringUtils.isBlank(lineId) || lineId.length() <= 1) { + throw new BusinessException("线路ID格式错误"); + } + String nDid = lineId.substring(0, lineId.length() - 1); + CsEquipmentDeliveryVO csEquipmentDeliveryVO = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); + if (Objects.isNull(csEquipmentDeliveryVO)) { + log.warn("未找到对应的设备信息,nDid: {}", nDid); + return; + } + // 检查设备运行状态 + if (csEquipmentDeliveryVO.getRunStatus() == 1) { + throw new BusinessException("装置离线,无法获取实时数据"); + } + // 请求设备数据 + askDeviceDataFeignClient.askCldRealData(csEquipmentDeliveryVO.getId(), lineId); + // 更新Redis中的用户集合 - 使用工具方法消除重复代码 + updateRedisUserSet("rtDataUserId:" + lineId, RequestUtil.getUserIndex(), 600L); + updateRedisUserSet("cldRtDataOverTime:" + lineId, RequestUtil.getUserIndex(), 5L); + } catch (BusinessException e) { + throw e; + } catch (Exception e) { + log.error("获取CLD基础实时数据失败,lineId: {}", lineId, e); + throw new BusinessException("获取实时数据失败,请稍后重试"); + } + } + + /** + * 更新Redis中的用户集合 + */ + private void updateRedisUserSet(String redisKey, String userIndex, Long expireSeconds) { + try { + Object redisObject = redisUtil.getObjectByKey(redisKey); + Set userSet = convertObjectToSetSafe(redisObject); + userSet.add(userIndex); + redisUtil.saveByKeyWithExpire(redisKey, userSet, expireSeconds); + } catch (Exception e) { + log.error("更新Redis用户集合失败,key: {}", redisKey, e); + } + } + + /** + * 安全的对象到Set转换方法 + */ + private Set convertObjectToSetSafe(Object obj) { + if (obj == null) { + return new HashSet<>(); + } + if (obj instanceof Set) { + // 类型安全的转换 + Set rawSet = (Set) obj; + return rawSet.stream() + .filter(Objects::nonNull) + .map(Object::toString) + .collect(Collectors.toSet()); + } else if (obj instanceof Collection) { + return ((Collection) obj).stream() + .filter(Objects::nonNull) + .map(Object::toString) + .collect(Collectors.toSet()); + } else { + log.warn("Redis中的对象类型不是Set或Collection: {}", obj.getClass().getName()); + return new HashSet<>(); + } + } + +// @Override +// public void getCldBaseRealData(String lineId) { +// String nDid = lineId.substring(0, lineId.length() - 1); +// CsEquipmentDeliveryVO csEquipmentDeliveryVO = equipmentFeignClient.queryEquipmentByndid(nDid).getData(); +// if (Objects.nonNull(csEquipmentDeliveryVO)) { +// if (csEquipmentDeliveryVO.getRunStatus() == 1) { +// throw new BusinessException("装置离线"); +// } +// askDeviceDataFeignClient.askCldRealData(csEquipmentDeliveryVO.getId(),lineId); +// +// Object object1 = redisUtil.getObjectByKey("rtDataUserId:"+lineId); +// Set users1; +// if (Objects.isNull(object1)) { +// users1 = new HashSet<>(); +// } else { +// users1 = convertObjectToSet(object1); +// } +// users1.add(RequestUtil.getUserIndex()); +// redisUtil.saveByKeyWithExpire("rtDataUserId:"+lineId, users1,600L); +// +// Object object2 = redisUtil.getObjectByKey("cldRtDataOverTime:"+lineId); +// Set users2; +// if (Objects.isNull(object2)) { +// users2 = new HashSet<>(); +// } else { +// users2 = convertObjectToSet(object2); +// } +// users2.add(RequestUtil.getUserIndex()); +// redisUtil.saveByKeyWithExpire("cldRtDataOverTime:"+lineId, users2,5L); +// } +// } +// +// public Set convertObjectToSet(Object obj) { +// if (obj instanceof Collection) { +// return ((Collection) obj).stream() +// .filter(Objects::nonNull) +// .map(Object::toString) +// .collect(Collectors.toSet()); +// } +// return Collections.emptySet(); +// } + }