代码调整
This commit is contained in:
@@ -14,7 +14,7 @@ public enum AccessResponseEnum {
|
|||||||
* A0301 ~ A0399 用于用户模块的枚举
|
* A0301 ~ A0399 用于用户模块的枚举
|
||||||
* <p>
|
* <p>
|
||||||
*/
|
*/
|
||||||
NDID_NO_FIND("A0301", "nDid在平台端未找到或者已接入"),
|
NDID_NO_FIND("A0301", "nDid在平台端未找到或者已注册"),
|
||||||
|
|
||||||
MODEL_REPEAT("A0302", "模板重复,请勿重复录入!"),
|
MODEL_REPEAT("A0302", "模板重复,请勿重复录入!"),
|
||||||
MODEL_NO_FIND("A0302", "模板不存在,请先录入模板数据!"),
|
MODEL_NO_FIND("A0302", "模板不存在,请先录入模板数据!"),
|
||||||
@@ -24,6 +24,7 @@ public enum AccessResponseEnum {
|
|||||||
DEV_NOT_FIND("A0303","装置类型未找到!"),
|
DEV_NOT_FIND("A0303","装置类型未找到!"),
|
||||||
DEV_MODEL_NOT_FIND("A0303","装置型号未找到!"),
|
DEV_MODEL_NOT_FIND("A0303","装置型号未找到!"),
|
||||||
DEV_IS_NOT_ZL("A0303","注册装置不是直连装置!"),
|
DEV_IS_NOT_ZL("A0303","注册装置不是直连装置!"),
|
||||||
|
DEV_IS_NOT_WG("A0303","注册装置不是网关!"),
|
||||||
|
|
||||||
REGISTER_RESPONSE_ERROR("A0304","装置注册,装置侧应答失败!"),
|
REGISTER_RESPONSE_ERROR("A0304","装置注册,装置侧应答失败!"),
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.access.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/7/7 15:00
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WgDevRegisterParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("网关id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Device {
|
||||||
|
|
||||||
|
@ApiModelProperty("设备型号")
|
||||||
|
private String devModel;
|
||||||
|
|
||||||
|
@ApiModelProperty("设备码")
|
||||||
|
private String lDid;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,53 @@
|
|||||||
|
package com.njcn.access.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/7/6 16:11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WgDeviceRegisterParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("网关id")
|
||||||
|
@NotNull(message = "网关id不能为空")
|
||||||
|
private String wgId;
|
||||||
|
|
||||||
|
@ApiModelProperty("装置型号")
|
||||||
|
@NotNull(message = "装置型号不能为空")
|
||||||
|
private String devModel;
|
||||||
|
|
||||||
|
@ApiModelProperty("did")
|
||||||
|
@NotNull(message = "did不能为空")
|
||||||
|
private String did;
|
||||||
|
|
||||||
|
@ApiModelProperty("拓扑图id")
|
||||||
|
@NotNull(message = "拓扑图id不能为空")
|
||||||
|
private String topologyDiagram;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class LineParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("监测点名称")
|
||||||
|
@NotNull(message = "监测点名称不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("安装位置")
|
||||||
|
@NotNull(message = "安装位置不能为空")
|
||||||
|
private String position;
|
||||||
|
|
||||||
|
@ApiModelProperty("中心点经度")
|
||||||
|
@NotNull(message = "中心点经度不能为空")
|
||||||
|
private Double lng;
|
||||||
|
|
||||||
|
@ApiModelProperty("中心点纬度")
|
||||||
|
@NotNull(message = "中心点纬度不能为空")
|
||||||
|
private Double lat;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,65 @@
|
|||||||
|
package com.njcn.access.param;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import javax.validation.constraints.NotNull;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/7/6 15:59
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WgRegisterParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("项目id")
|
||||||
|
@NotNull(message = "项目id不能为空")
|
||||||
|
private String projectId;
|
||||||
|
|
||||||
|
@ApiModelProperty("区域")
|
||||||
|
private String area;
|
||||||
|
|
||||||
|
@ApiModelProperty("拓扑图id")
|
||||||
|
@NotNull(message = "拓扑图id不能为空")
|
||||||
|
private String topologyDiagram;
|
||||||
|
|
||||||
|
@ApiModelProperty("设备识别码")
|
||||||
|
@NotNull(message = "设备识别码不能为空")
|
||||||
|
private String nDid;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class LineParam {
|
||||||
|
|
||||||
|
@ApiModelProperty("监测点名称")
|
||||||
|
@NotNull(message = "监测点名称不能为空")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty("安装位置")
|
||||||
|
@NotNull(message = "安装位置不能为空")
|
||||||
|
private String position;
|
||||||
|
|
||||||
|
@ApiModelProperty("电压等级")
|
||||||
|
@NotNull(message = "电压等级不能为空")
|
||||||
|
private String volGrade;
|
||||||
|
|
||||||
|
@ApiModelProperty("PT变比")
|
||||||
|
@NotNull(message = "PT变比不能为空")
|
||||||
|
private String ptRatio;
|
||||||
|
|
||||||
|
@ApiModelProperty("CT变比")
|
||||||
|
@NotNull(message = "CT变比不能为空")
|
||||||
|
private String ctRatio;
|
||||||
|
|
||||||
|
@ApiModelProperty("中心点经度")
|
||||||
|
@NotNull(message = "中心点经度不能为空")
|
||||||
|
private Double lng;
|
||||||
|
|
||||||
|
@ApiModelProperty("中心点纬度")
|
||||||
|
@NotNull(message = "中心点纬度不能为空")
|
||||||
|
private Double lat;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.njcn.access.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-06
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cs_gateway")
|
||||||
|
public class CsGateway extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 项目id
|
||||||
|
*/
|
||||||
|
private String pid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 位置信息
|
||||||
|
*/
|
||||||
|
private String area;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 拓扑图id
|
||||||
|
*/
|
||||||
|
private String tid;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态 0-删除;1-正常;默认正常
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.njcn.access.pojo.po;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import com.njcn.db.bo.BaseEntity;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关装置关系表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-07
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("cs_gateway_device")
|
||||||
|
public class CsGatewayDevice extends BaseEntity {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关id
|
||||||
|
*/
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关下设备id
|
||||||
|
*/
|
||||||
|
private String devId;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
package com.njcn.access.pojo.vo;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 类的介绍:
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @version 1.0.0
|
||||||
|
* @createTime 2023/7/7 9:09
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class CsGatewayVo {
|
||||||
|
|
||||||
|
@ApiModelProperty("网关id")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty("网关名称")
|
||||||
|
private String wgName;
|
||||||
|
|
||||||
|
@ApiModelProperty("项目名称")
|
||||||
|
private String proName;
|
||||||
|
|
||||||
|
@ApiModelProperty("设备型号")
|
||||||
|
private String devModel;
|
||||||
|
|
||||||
|
@ApiModelProperty("型号版本")
|
||||||
|
private String programVersion;
|
||||||
|
|
||||||
|
@ApiModelProperty("拓扑图")
|
||||||
|
private String filePath;
|
||||||
|
|
||||||
|
@ApiModelProperty("设备集合")
|
||||||
|
private List<Device> list;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public static class Device {
|
||||||
|
|
||||||
|
@ApiModelProperty("设备名称")
|
||||||
|
private String devName;
|
||||||
|
|
||||||
|
@ApiModelProperty("项目名称")
|
||||||
|
private String proName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -35,7 +35,7 @@ public class CsDeviceController extends BaseController {
|
|||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/register")
|
@PostMapping("/register")
|
||||||
@ApiOperation("设备注册")
|
@ApiOperation("直连设备注册")
|
||||||
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||||
public HttpResult<String> devRegister(@RequestParam String nDid){
|
public HttpResult<String> devRegister(@RequestParam String nDid){
|
||||||
csDeviceService.devRegister(nDid);
|
csDeviceService.devRegister(nDid);
|
||||||
@@ -44,7 +44,7 @@ public class CsDeviceController extends BaseController {
|
|||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/model")
|
@PostMapping("/model")
|
||||||
@ApiOperation("获取装置模板信息")
|
@ApiOperation("获取直连设备模板信息")
|
||||||
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||||
public HttpResult<Object> getModel(@RequestParam String nDid){
|
public HttpResult<Object> getModel(@RequestParam String nDid){
|
||||||
String methodDescribe = getMethodDescribe("getModel");
|
String methodDescribe = getMethodDescribe("getModel");
|
||||||
@@ -54,12 +54,11 @@ public class CsDeviceController extends BaseController {
|
|||||||
|
|
||||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
@PostMapping("/access")
|
@PostMapping("/access")
|
||||||
@ApiOperation("设备接入")
|
@ApiOperation("直连设备接入")
|
||||||
@ApiImplicitParam(name = "devAccessParam", value = "接入参数", required = true)
|
@ApiImplicitParam(name = "devAccessParam", value = "接入参数", required = true)
|
||||||
public HttpResult<String> devAccess(@RequestBody @Validated DevAccessParam devAccessParam){
|
public HttpResult<String> devAccess(@RequestBody @Validated DevAccessParam devAccessParam){
|
||||||
String methodDescribe = getMethodDescribe("getModel");
|
String methodDescribe = getMethodDescribe("getModel");
|
||||||
csDeviceService.devAccess(devAccessParam);
|
csDeviceService.devAccess(devAccessParam);
|
||||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,92 @@
|
|||||||
|
package com.njcn.access.controller;
|
||||||
|
|
||||||
|
|
||||||
|
import com.njcn.access.param.WgDeviceRegisterParam;
|
||||||
|
import com.njcn.access.param.WgRegisterParam;
|
||||||
|
import com.njcn.access.pojo.vo.CsGatewayVo;
|
||||||
|
import com.njcn.access.service.ICsGatewayService;
|
||||||
|
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.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.*;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关表 前端控制器
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-06
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/csGateway")
|
||||||
|
@Api(tags = "治理网关信息")
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Validated
|
||||||
|
public class CsGatewayController extends BaseController {
|
||||||
|
|
||||||
|
private final ICsGatewayService csGatewayService;
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/wgRegister")
|
||||||
|
@ApiOperation("网关注册1")
|
||||||
|
@ApiImplicitParam(name = "nDid", value = "设备识别码", required = true)
|
||||||
|
public HttpResult<String> wgRegister(@RequestParam String nDid){
|
||||||
|
String methodDescribe = getMethodDescribe("wgRegister");
|
||||||
|
csGatewayService.wgRegister(nDid);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/wgRegister2")
|
||||||
|
@ApiOperation("网关注册2")
|
||||||
|
@ApiImplicitParam(name = "wgRegisterParam", value = "网关注册参数", required = true)
|
||||||
|
public HttpResult<String> wgRegister2(@RequestBody @Validated WgRegisterParam wgRegisterParam){
|
||||||
|
String methodDescribe = getMethodDescribe("wgRegister2");
|
||||||
|
csGatewayService.wgRegister2(wgRegisterParam);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/findList")
|
||||||
|
@ApiOperation("网关列表")
|
||||||
|
public HttpResult<List<CsGatewayVo>> findList(){
|
||||||
|
String methodDescribe = getMethodDescribe("findList");
|
||||||
|
List<CsGatewayVo> list = csGatewayService.getWgList();
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/findById")
|
||||||
|
@ApiOperation("网关详情")
|
||||||
|
@ApiImplicitParam(name = "wgId", value = "网关注册参数", required = true)
|
||||||
|
public HttpResult<CsGatewayVo> findById(@RequestParam String wgId){
|
||||||
|
String methodDescribe = getMethodDescribe("findById");
|
||||||
|
CsGatewayVo vo = csGatewayService.findById(wgId);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||||
|
@PostMapping("/registerByWg")
|
||||||
|
@ApiOperation("网关下设备注册")
|
||||||
|
@ApiImplicitParam(name = "list", value = "网关下设备注册参数集合", required = true)
|
||||||
|
public HttpResult<String> registerByWg(@RequestBody @Validated List<WgDeviceRegisterParam> list){
|
||||||
|
String methodDescribe = getMethodDescribe("registerByWg");
|
||||||
|
csGatewayService.registerByWg(list);
|
||||||
|
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@@ -108,7 +108,8 @@ public class MqttMessageHandler {
|
|||||||
ReqAndResDto.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResDto.Res.class);
|
ReqAndResDto.Res res = gson.fromJson(new String(message.getPayload(), StandardCharsets.UTF_8), ReqAndResDto.Res.class);
|
||||||
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
if (Objects.equals(res.getCode(),AccessEnum.SUCCESS.getCode())){
|
||||||
if (Objects.equals(res.getType(),TypeEnum.TYPE_17.getCode())){
|
if (Objects.equals(res.getType(),TypeEnum.TYPE_17.getCode())){
|
||||||
equipmentFeignClient.updateStatusBynDid(nDid, AccessEnum.REGISTERED.getCode());
|
//这边用redis缓存来判断是否接收响应
|
||||||
|
redisUtil.saveByKeyWithExpire(nDid,AccessEnum.SUCCESS.getCode(),600L);
|
||||||
//询问模板数据
|
//询问模板数据
|
||||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||||
reqAndResParam.setMid(1);
|
reqAndResParam.setMid(1);
|
||||||
@@ -117,8 +118,6 @@ public class MqttMessageHandler {
|
|||||||
reqAndResParam.setType(TypeEnum.TYPE_3.getCode());
|
reqAndResParam.setType(TypeEnum.TYPE_3.getCode());
|
||||||
reqAndResParam.setExpire(-1);
|
reqAndResParam.setExpire(-1);
|
||||||
publisher.send("/Pfm/DevCmd/V1/"+nDid,new Gson().toJson(reqAndResParam),1,false);
|
publisher.send("/Pfm/DevCmd/V1/"+nDid,new Gson().toJson(reqAndResParam),1,false);
|
||||||
//这边用redis缓存来判断是否接收响应
|
|
||||||
redisUtil.saveByKey(nDid,AccessEnum.SUCCESS.getCode());
|
|
||||||
} else {
|
} else {
|
||||||
log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage());
|
log.info(AccessResponseEnum.MESSAGE_TYPE_ERROR.getMessage());
|
||||||
}
|
}
|
||||||
@@ -160,13 +159,12 @@ public class MqttMessageHandler {
|
|||||||
List<CsLineModel> lineList = csLineModelService.getMonitorNumByModelId(modelId);
|
List<CsLineModel> lineList = csLineModelService.getMonitorNumByModelId(modelId);
|
||||||
String key = "LINE" + nDid;
|
String key = "LINE" + nDid;
|
||||||
//存储监测点模板信息,用于界面回显
|
//存储监测点模板信息,用于界面回显
|
||||||
redisUtil.saveByKey(key,lineList);
|
redisUtil.saveByKeyWithExpire(key,lineList,600L);
|
||||||
//存储模板id
|
//存储模板id
|
||||||
//todo 这边也是要调整的
|
//todo 这边也是要调整的
|
||||||
String key2 = "MODEL" + nDid;
|
String key2 = "MODEL" + nDid;
|
||||||
redisUtil.saveByKey(key2,modelId);
|
redisUtil.saveByKeyWithExpire(key2,modelId,600L);
|
||||||
redisUtil.delete(nDid);
|
redisUtil.delete(nDid);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
package com.njcn.access.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.access.pojo.po.CsGatewayDevice;
|
||||||
|
import com.njcn.access.pojo.vo.CsGatewayVo;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentAlarmPO;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关装置关系表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-07
|
||||||
|
*/
|
||||||
|
public interface CsGatewayDeviceMapper extends BaseMapper<CsGatewayDevice> {
|
||||||
|
|
||||||
|
List<CsEquipmentDeliveryPO> getList(String id);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.njcn.access.mapper;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||||
|
import com.njcn.access.pojo.po.CsGateway;
|
||||||
|
import com.njcn.access.pojo.vo.CsGatewayVo;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关表 Mapper 接口
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-06
|
||||||
|
*/
|
||||||
|
public interface CsGatewayMapper extends BaseMapper<CsGateway> {
|
||||||
|
|
||||||
|
List<CsGatewayVo> getWgList(@Param("userId") String userId);
|
||||||
|
|
||||||
|
CsGatewayVo findById(@Param("id") String id);
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.access.mapper.CsGatewayDeviceMapper">
|
||||||
|
|
||||||
|
<select id="getList" resultType="com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO">
|
||||||
|
select
|
||||||
|
t1.name
|
||||||
|
from
|
||||||
|
cs_gateway_device t0
|
||||||
|
left join cs_equipment_delivery t1 on t0.dev_id = t1.id
|
||||||
|
where t0.id = #{id}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.njcn.access.mapper.CsGatewayMapper">
|
||||||
|
<select id="getWgList" resultType="com.njcn.access.pojo.vo.CsGatewayVo">
|
||||||
|
select
|
||||||
|
t0.id,
|
||||||
|
t1.name devName,
|
||||||
|
t2.name proName,
|
||||||
|
t0.area
|
||||||
|
from
|
||||||
|
cs_gateway t0
|
||||||
|
left join cs_equipment_delivery t1 on t0.id = t1.id
|
||||||
|
left join cs_project t2 on t0.pid = t2.id
|
||||||
|
where t0.create_by = #{userId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="findById" resultType="com.njcn.access.pojo.vo.CsGatewayVo">
|
||||||
|
select
|
||||||
|
t0.id,
|
||||||
|
t1.name wgName,
|
||||||
|
t2.name proName,
|
||||||
|
t1.dev_model devModel,
|
||||||
|
t3.version_no programVersion,
|
||||||
|
t4.file_path filePath
|
||||||
|
from
|
||||||
|
cs_gateway t0
|
||||||
|
left join cs_equipment_delivery t1 on t0.id = t1.id
|
||||||
|
left join cs_project t2 on t0.pid = t2.id
|
||||||
|
left join cs_ed_data t3 on t1.program_version = t3.id
|
||||||
|
left join cs_topology_diagram t4 on t0.tid = t4.id
|
||||||
|
where t0.id = #{id} and t0.status = 1
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
package com.njcn.access.service;
|
package com.njcn.access.service;
|
||||||
|
|
||||||
import com.njcn.access.param.DevAccessParam;
|
import com.njcn.access.param.DevAccessParam;
|
||||||
|
import com.njcn.access.param.WgDeviceRegisterParam;
|
||||||
|
import com.njcn.access.param.WgRegisterParam;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 类的介绍:
|
* 类的介绍:
|
||||||
@@ -29,5 +31,4 @@ public interface ICsDeviceService {
|
|||||||
* @param devAccessParam
|
* @param devAccessParam
|
||||||
*/
|
*/
|
||||||
void devAccess(DevAccessParam devAccessParam);
|
void devAccess(DevAccessParam devAccessParam);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.access.pojo.po.CsGatewayDevice;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentAlarmPO;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关装置关系表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-07
|
||||||
|
*/
|
||||||
|
public interface ICsGatewayDeviceService extends IService<CsGatewayDevice> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据网关id获取网关下装置的信息
|
||||||
|
* @param id
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CsEquipmentDeliveryPO> getList(String id);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
package com.njcn.access.service;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.IService;
|
||||||
|
import com.njcn.access.param.WgDeviceRegisterParam;
|
||||||
|
import com.njcn.access.param.WgRegisterParam;
|
||||||
|
import com.njcn.access.pojo.po.CsGateway;
|
||||||
|
import com.njcn.access.pojo.vo.CsGatewayVo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关表 服务类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-06
|
||||||
|
*/
|
||||||
|
public interface ICsGatewayService extends IService<CsGateway> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关注册
|
||||||
|
* @param nDid 设备识别码
|
||||||
|
*/
|
||||||
|
void wgRegister(String nDid);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关ndid校验成功后,添加网关信息
|
||||||
|
* @param wgRegisterParam
|
||||||
|
*/
|
||||||
|
void wgRegister2(WgRegisterParam wgRegisterParam);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询用户下的网关
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
List<CsGatewayVo> getWgList();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询具体网关信息
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
CsGatewayVo findById(String id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 网关下设备注册
|
||||||
|
* @param list
|
||||||
|
*/
|
||||||
|
void registerByWg(List<WgDeviceRegisterParam> list);
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1,14 +1,19 @@
|
|||||||
package com.njcn.access.service.impl;
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.util.IdUtil;
|
import cn.hutool.core.util.IdUtil;
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||||
import com.njcn.access.enums.AccessEnum;
|
import com.njcn.access.enums.AccessEnum;
|
||||||
import com.njcn.access.enums.AccessResponseEnum;
|
import com.njcn.access.enums.AccessResponseEnum;
|
||||||
import com.njcn.access.enums.TypeEnum;
|
import com.njcn.access.enums.TypeEnum;
|
||||||
import com.njcn.access.param.DevAccessParam;
|
import com.njcn.access.param.DevAccessParam;
|
||||||
|
import com.njcn.access.param.WgDeviceRegisterParam;
|
||||||
|
import com.njcn.access.param.WgRegisterParam;
|
||||||
import com.njcn.access.pojo.dto.AccessDto;
|
import com.njcn.access.pojo.dto.AccessDto;
|
||||||
import com.njcn.access.pojo.dto.ReqAndResDto;
|
import com.njcn.access.pojo.dto.ReqAndResDto;
|
||||||
|
import com.njcn.access.pojo.po.CsGateway;
|
||||||
import com.njcn.access.service.ICsDeviceService;
|
import com.njcn.access.service.ICsDeviceService;
|
||||||
|
import com.njcn.access.service.ICsGatewayService;
|
||||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||||
import com.njcn.common.pojo.exception.BusinessException;
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
import com.njcn.common.utils.PubUtils;
|
import com.njcn.common.utils.PubUtils;
|
||||||
@@ -66,6 +71,8 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
|
|
||||||
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
|
private final CsDeviceUserFeignClient csDeviceUserFeignClient;
|
||||||
|
|
||||||
|
private final ICsGatewayService csGatewayService;
|
||||||
|
|
||||||
private final MqttPublisher publisher;
|
private final MqttPublisher publisher;
|
||||||
|
|
||||||
private final RedisUtil redisUtil;
|
private final RedisUtil redisUtil;
|
||||||
@@ -177,7 +184,7 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
devModelRelationFeignClient.addDevModelRelation(csDevModelRelationAddParm);
|
devModelRelationFeignClient.addDevModelRelation(csDevModelRelationAddParm);
|
||||||
redisUtil.delete("MODEL" + devAccessParam.getNDid());
|
redisUtil.delete("MODEL" + devAccessParam.getNDid());
|
||||||
//5.修改装置状态
|
//5.修改装置状态
|
||||||
equipmentFeignClient.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.ACCESS.getCode());
|
equipmentFeignClient.updateStatusBynDid(devAccessParam.getNDid(), AccessEnum.REGISTERED.getCode());
|
||||||
//6.设置心跳时间,超时改为掉线
|
//6.设置心跳时间,超时改为掉线
|
||||||
redisUtil.saveByKeyWithExpire("MQTT:" + devAccessParam.getNDid(), Instant.now().toEpochMilli(),180L);
|
redisUtil.saveByKeyWithExpire("MQTT:" + devAccessParam.getNDid(), Instant.now().toEpochMilli(),180L);
|
||||||
//7.绑定装置和人的关系
|
//7.绑定装置和人的关系
|
||||||
@@ -194,7 +201,6 @@ public class CsDeviceServiceImpl implements ICsDeviceService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void zhiLianRegister(String nDid,String devType) {
|
public void zhiLianRegister(String nDid,String devType) {
|
||||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||||
reqAndResParam.setMid(1);
|
reqAndResParam.setMid(1);
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.access.mapper.CsGatewayDeviceMapper;
|
||||||
|
import com.njcn.access.pojo.po.CsGatewayDevice;
|
||||||
|
import com.njcn.access.service.ICsGatewayDeviceService;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentAlarmPO;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关装置关系表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-07
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class CsGatewayDeviceServiceImpl extends ServiceImpl<CsGatewayDeviceMapper, CsGatewayDevice> implements ICsGatewayDeviceService {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsEquipmentDeliveryPO> getList(String id) {
|
||||||
|
return this.baseMapper.getList(id);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,116 @@
|
|||||||
|
package com.njcn.access.service.impl;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||||
|
import com.njcn.access.enums.AccessEnum;
|
||||||
|
import com.njcn.access.enums.AccessResponseEnum;
|
||||||
|
import com.njcn.access.mapper.CsGatewayMapper;
|
||||||
|
import com.njcn.access.param.WgDeviceRegisterParam;
|
||||||
|
import com.njcn.access.param.WgRegisterParam;
|
||||||
|
import com.njcn.access.pojo.po.CsGateway;
|
||||||
|
import com.njcn.access.pojo.vo.CsGatewayVo;
|
||||||
|
import com.njcn.access.service.ICsGatewayDeviceService;
|
||||||
|
import com.njcn.access.service.ICsGatewayService;
|
||||||
|
import com.njcn.common.pojo.exception.BusinessException;
|
||||||
|
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||||
|
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||||
|
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||||
|
import com.njcn.oss.utils.FileStorageUtil;
|
||||||
|
import com.njcn.system.api.DictTreeFeignClient;
|
||||||
|
import com.njcn.system.enums.DicDataEnum;
|
||||||
|
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||||
|
import com.njcn.web.utils.RequestUtil;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 网关表 服务实现类
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author xuyang
|
||||||
|
* @since 2023-07-06
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CsGatewayServiceImpl extends ServiceImpl<CsGatewayMapper, CsGateway> implements ICsGatewayService {
|
||||||
|
|
||||||
|
private final FileStorageUtil fileStorageUtil;
|
||||||
|
|
||||||
|
private final EquipmentFeignClient equipmentFeignClient;
|
||||||
|
|
||||||
|
private final DictTreeFeignClient dictTreeFeignClient;
|
||||||
|
|
||||||
|
private final ICsGatewayDeviceService csGatewayDeviceService;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void wgRegister(String nDid) {
|
||||||
|
//1.判断nDid是否存在
|
||||||
|
CsEquipmentDeliveryVO csEquipmentDeliveryVO = equipmentFeignClient.queryEquipmentByndid(nDid).getData();
|
||||||
|
if (Objects.isNull(csEquipmentDeliveryVO.getNdid())){
|
||||||
|
throw new BusinessException(AccessResponseEnum.NDID_NO_FIND);
|
||||||
|
}
|
||||||
|
//2.判断设备是否是网关
|
||||||
|
SysDicTreePO sysDicTreePo = dictTreeFeignClient.queryById(csEquipmentDeliveryVO.getDevType()).getData();
|
||||||
|
if (Objects.isNull(sysDicTreePo)){
|
||||||
|
throw new BusinessException(AccessResponseEnum.DEV_NOT_FIND);
|
||||||
|
}
|
||||||
|
String code = sysDicTreePo.getCode();
|
||||||
|
if (!Objects.equals(code, DicDataEnum.GATEWAY_DEV.getCode())){
|
||||||
|
throw new BusinessException(AccessResponseEnum.DEV_IS_NOT_WG);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = {Exception.class})
|
||||||
|
public void wgRegister2(WgRegisterParam wgRegisterParam) {
|
||||||
|
CsEquipmentDeliveryVO csEquipmentDeliveryVO = equipmentFeignClient.queryEquipmentByndid(wgRegisterParam.getNDid()).getData();
|
||||||
|
CsGateway csGateway = new CsGateway();
|
||||||
|
csGateway.setId(csEquipmentDeliveryVO.getId());
|
||||||
|
csGateway.setPid(wgRegisterParam.getProjectId());
|
||||||
|
csGateway.setArea(wgRegisterParam.getArea());
|
||||||
|
csGateway.setTid(wgRegisterParam.getTopologyDiagram());
|
||||||
|
csGateway.setStatus(1);
|
||||||
|
this.save(csGateway);
|
||||||
|
equipmentFeignClient.updateStatusBynDid(wgRegisterParam.getNDid(), AccessEnum.REGISTERED.getCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<CsGatewayVo> getWgList() {
|
||||||
|
return this.baseMapper.getWgList(RequestUtil.getUserIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public CsGatewayVo findById(String id) {
|
||||||
|
CsGatewayVo vo = this.baseMapper.findById(id);
|
||||||
|
vo.setFilePath (fileStorageUtil.getFileUrl (vo.getFilePath()));
|
||||||
|
List<CsEquipmentDeliveryPO> list = csGatewayDeviceService.getList(id);
|
||||||
|
List<CsGatewayVo.Device> devList = new ArrayList<>();
|
||||||
|
if (CollectionUtil.isNotEmpty(list)){
|
||||||
|
list.forEach(item->{
|
||||||
|
CsGatewayVo.Device pojo = new CsGatewayVo.Device();
|
||||||
|
pojo.setDevName(item.getName());
|
||||||
|
pojo.setProName(vo.getProName());
|
||||||
|
devList.add(pojo);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
vo.setList(devList);
|
||||||
|
return vo;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void registerByWg(List<WgDeviceRegisterParam> list) {
|
||||||
|
list.forEach(item->{
|
||||||
|
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user