云前置改造-台账相关功能
This commit is contained in:
@@ -1,16 +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.CsLineClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
@@ -51,4 +45,7 @@ public interface CsLineFeignClient {
|
||||
|
||||
@PostMapping("/getLinesByDevList")
|
||||
HttpResult<List<CsLinePO>> getLinesByDevList(@RequestBody List<String> ids);
|
||||
|
||||
@PostMapping("/updateLineDataByList")
|
||||
HttpResult<String> updateDataByList(@RequestParam("list") List<String> list, @RequestParam("id") String id, @RequestParam("setId") String setId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsTerminalLogsClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csTerminalLogs", fallbackFactory = CsTerminalLogsClientFallbackFactory.class,contextId = "csTerminalLogs")
|
||||
|
||||
public interface CsTerminalLogsFeignClient {
|
||||
|
||||
@PostMapping("/updateLaterData")
|
||||
HttpResult<String> updateLaterData(@RequestParam("id") String id, @RequestParam("code") String code);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsTerminalReplyClientFallbackFactory;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csTerminalReply", fallbackFactory = CsTerminalReplyClientFallbackFactory.class,contextId = "csTerminalReply")
|
||||
|
||||
public interface CsTerminalReplyFeignClient {
|
||||
|
||||
@PostMapping("/updateData")
|
||||
HttpResult<String> updateData(@RequestParam("id") String id,@RequestParam("state") Integer state,@RequestParam("deviceId") String deviceId);
|
||||
|
||||
}
|
||||
@@ -28,4 +28,7 @@ public interface DevModelRelationFeignClient {
|
||||
@PostMapping("/getModelByType")
|
||||
HttpResult<String> getModelByType(@RequestParam("devId") String devId, @RequestParam("type") Integer type);
|
||||
|
||||
@PostMapping("/updateDataByList")
|
||||
HttpResult<String> updateDataByList(@RequestParam("list") List<String> list, @RequestParam("id") String id);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.NodeFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.Node;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/node", fallbackFactory = NodeFallbackFactory.class,contextId = "node")
|
||||
public interface NodeFeignClient {
|
||||
|
||||
@ApiOperation("获取全部前置机")
|
||||
@GetMapping("/nodeAllList")
|
||||
HttpResult<List<Node>> nodeAllList();
|
||||
|
||||
|
||||
}
|
||||
@@ -80,6 +80,12 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置id集合获取监测点id集合",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> updateDataByList(List<String> list, String id, String setId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置集合修改监测点信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.CsTerminalLogsFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsTerminalLogsClientFallbackFactory implements FallbackFactory<CsTerminalLogsFeignClient> {
|
||||
@Override
|
||||
public CsTerminalLogsFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsTerminalLogsFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> updateLaterData(String id, String code) {
|
||||
log.error("{}异常,降级处理,异常为:{}","更新最新一组数据的推送状态",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.CsTerminalReplyFeignClient;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsTerminalReplyClientFallbackFactory implements FallbackFactory<CsTerminalReplyFeignClient> {
|
||||
@Override
|
||||
public CsTerminalReplyFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsTerminalReplyFeignClient() {
|
||||
@Override
|
||||
public HttpResult<String> updateData(String id, Integer state, String deviceId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","更新推送结果",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,12 @@ public class DevModelRelationFeignClientFallbackFactory implements FallbackFacto
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置类型查询模板",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> updateDataByList(List<String> list, String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据装置集合修改模板信息",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.csdevice.api.fallback;
|
||||
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.NodeFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.Node;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class NodeFallbackFactory implements FallbackFactory<NodeFeignClient> {
|
||||
@Override
|
||||
public NodeFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new NodeFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<List<Node>> nodeAllList() {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取全部前置机异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,7 @@ 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 com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -30,6 +31,9 @@ public class IcdLedgerParam implements Serializable {
|
||||
@ApiModelProperty("设备和mac关系")
|
||||
private Map<String,String> devMacMap;
|
||||
|
||||
@ApiModelProperty("设备mac和设备信息关系")
|
||||
private Map<String, CsEquipmentDeliveryPO> devMap;
|
||||
|
||||
@ApiModelProperty("工程信息")
|
||||
private CsEngineeringAddParm engineering;
|
||||
|
||||
|
||||
@@ -13,9 +13,9 @@ import java.util.List;
|
||||
@Data
|
||||
public class IcdParam implements Serializable {
|
||||
|
||||
@ApiModelProperty("前置ip,不传时查询所有的终端台账信息")
|
||||
@NotBlank(message = "前置ip不可为空")
|
||||
private String ip;
|
||||
@ApiModelProperty("前置id,不传时查询所有的终端台账信息")
|
||||
@NotBlank(message = "前置id不可为空")
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("终端运行状态,不传则查询所有的终端信息 (0:运行;1:检修;2:停运;3:调试;4:退运)")
|
||||
private List<Integer> runFlag;
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
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 lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-09-26
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("cs_terminal_logs")
|
||||
public class CsTerminalLogs extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 设备id
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 前置服务器id
|
||||
*/
|
||||
private String nodeId;
|
||||
|
||||
/**
|
||||
* 进程号
|
||||
*/
|
||||
private Integer nodeProcess;
|
||||
|
||||
/**
|
||||
* 操作类型(0:新增 1:修改 2:删除)
|
||||
*/
|
||||
private Integer operateType;
|
||||
|
||||
/**
|
||||
* 是否推送(0未推送 1已推送)
|
||||
*/
|
||||
private Integer isPush;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
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;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-10-09
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
@TableName("cs_terminal_reply")
|
||||
public class CsTerminalReply extends BaseEntity implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 消息id
|
||||
*/
|
||||
private String replyId;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 前置id
|
||||
*/
|
||||
private String nodeId;
|
||||
|
||||
/**
|
||||
* 进程号
|
||||
*/
|
||||
private Integer processNo;
|
||||
|
||||
/**
|
||||
* 设备id集合
|
||||
*/
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 是否收到(0:未收到 1:收到)
|
||||
*/
|
||||
private Integer isReceived;
|
||||
|
||||
|
||||
}
|
||||
@@ -25,6 +25,12 @@ public class DeviceInfo implements Serializable {
|
||||
@ApiModelProperty("前置机序号")
|
||||
private Integer node;
|
||||
|
||||
@ApiModelProperty("开启的进程数")
|
||||
private Integer maxProcessNum;
|
||||
|
||||
@ApiModelProperty("对时启动标志")
|
||||
private boolean rightTime;
|
||||
|
||||
@ApiModelProperty("监测点集合")
|
||||
private List<MonitorInfo> monitorData;
|
||||
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.Node;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class NodeProcessDeviceVo implements Serializable {
|
||||
|
||||
private Node node;
|
||||
|
||||
private List<ProcessDevice> processDeviceList;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public static class ProcessDevice implements Serializable{
|
||||
private Integer processNo;
|
||||
private String processState;
|
||||
private List<CsEquipmentDeliveryPO> deviceInfoList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -153,6 +153,12 @@
|
||||
<artifactId>access-api</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>common-mq</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -103,4 +103,18 @@ public class DevModelRelationController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, modelId, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateDataByList")
|
||||
@ApiOperation("根据装置集合修改模板信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "list", value = "装置id集合", required = true),
|
||||
@ApiImplicitParam(name = "id", value = "模板id", required = true)
|
||||
})
|
||||
@ApiIgnore
|
||||
public HttpResult<String> updateDataByList(@RequestParam("list") List<String> list, @RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("updateDataByList");
|
||||
csDevModelRelationService.updateDataByList(list,id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ public class EquipmentDeliveryController extends BaseController {
|
||||
@ApiOperation("删除云前置设备")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
@DeviceLog(operateType = DeviceOperate.DELETE)
|
||||
public HttpResult<Boolean> delCldDev(@RequestBody @Validated String id){
|
||||
public HttpResult<Boolean> delCldDev(@RequestParam("id") String id){
|
||||
String methodDescribe = getMethodDescribe("delCldDev");
|
||||
boolean result = csEquipmentDeliveryService.delCldDev(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
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.service.ICsTerminalLogsService;
|
||||
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.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-09-26
|
||||
*/
|
||||
@Slf4j
|
||||
@RequestMapping("/csTerminalLogs")
|
||||
@RestController
|
||||
@Api(tags = "云前置台账信息日志")
|
||||
@AllArgsConstructor
|
||||
public class CsTerminalLogsController extends BaseController {
|
||||
|
||||
private final ICsTerminalLogsService csTerminalLogsService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/pushCldInfo")
|
||||
@ApiOperation("推送日志台账信息")
|
||||
public HttpResult<String> pushCldInfo(){
|
||||
String methodDescribe = getMethodDescribe("pushCldInfo");
|
||||
String result = csTerminalLogsService.pushCldInfo();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateCldInfo")
|
||||
@ApiOperation("更新日志台账信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true),
|
||||
@ApiImplicitParam(name = "code", value = "流程状态", required = true)
|
||||
})
|
||||
public HttpResult<String> updateCldInfo(@RequestParam String id, @RequestParam Integer code){
|
||||
String methodDescribe = getMethodDescribe("updateCldInfo");
|
||||
csTerminalLogsService.updateLogs(id,code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateLaterData")
|
||||
@ApiOperation("更新最新一组数据的推送状态")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "设备id", required = true),
|
||||
@ApiImplicitParam(name = "code", value = "流程状态", required = true)
|
||||
})
|
||||
public HttpResult<String> updateLaterData(@RequestParam String id, @RequestParam String code){
|
||||
String methodDescribe = getMethodDescribe("updateLaterData");
|
||||
csTerminalLogsService.updateLaterData(id,code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
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.service.ICsTerminalReplyService;
|
||||
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.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-10-09
|
||||
*/
|
||||
@Slf4j
|
||||
@RequestMapping("/csTerminalReply")
|
||||
@RestController
|
||||
@Api(tags = "云前置台账信息响应记录")
|
||||
@AllArgsConstructor
|
||||
|
||||
public class CsTerminalReplyController extends BaseController {
|
||||
|
||||
private final ICsTerminalReplyService csTerminalReplyService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryData")
|
||||
@ApiOperation("查询推送结果")
|
||||
public HttpResult<List<String>> queryData(){
|
||||
String methodDescribe = getMethodDescribe("queryData");
|
||||
List<String> result = csTerminalReplyService.queryReplyData();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateData")
|
||||
@ApiOperation("更新推送结果")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "id", value = "参数", required = true),
|
||||
@ApiImplicitParam(name = "state", value = "状态", required = true),
|
||||
@ApiImplicitParam(name = "deviceId", value = "设备id", required = true)
|
||||
})
|
||||
public HttpResult<String> updateData(@RequestParam String id,@RequestParam Integer state,@RequestParam String deviceId){
|
||||
String methodDescribe = getMethodDescribe("updateData");
|
||||
csTerminalReplyService.updateReplyData(id,state,deviceId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import com.njcn.csdevice.param.IcdParam;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
import com.njcn.csdevice.service.IcdService;
|
||||
import com.njcn.mq.message.CldControlMessage;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
@@ -64,4 +65,14 @@ public class IcdController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/restartProcess")
|
||||
@ApiOperation("重启前置机进程")
|
||||
@ApiImplicitParam(name = "message", value = "message", required = true)
|
||||
public HttpResult<String> restartProcess(@RequestBody CldControlMessage message){
|
||||
String methodDescribe = getMethodDescribe("restartProcess");
|
||||
icdService.restartProcess(message);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ 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.pojo.vo.NodeProcessDeviceVo;
|
||||
import com.njcn.csdevice.service.INodeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -159,5 +160,19 @@ public class NodeController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, node, methodDescribe);
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据前置机id获取下面的进程和设备
|
||||
* @author xy
|
||||
*/
|
||||
@ApiOperation("根据前置机id获取下面的进程和设备")
|
||||
@ApiImplicitParam(value = "前置机id",name = "id",required = true)
|
||||
@OperateInfo(info = LogEnum.BUSINESS_MEDIUM)
|
||||
@GetMapping("/getProcessNoAndDeviceById")
|
||||
public HttpResult<NodeProcessDeviceVo> getProcessNoAndDeviceById(@Validated @NotNull(message = "id不可为空") @RequestParam("id")String id){
|
||||
String methodDescribe = getMethodDescribe("getProcessNoAndDeviceById");
|
||||
NodeProcessDeviceVo vo = iNodeService.getProcessNoAndDeviceById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -156,5 +156,14 @@ public class CsLedgerController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, allList, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/cldTree")
|
||||
@ApiOperation("云前置树")
|
||||
public HttpResult<CsLedgerVO> cldTree(){
|
||||
String methodDescribe = getMethodDescribe("cldTree");
|
||||
CsLedgerVO vo = csLedgerService.cldTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,7 @@ import com.njcn.device.biz.utils.COverlimitUtil;
|
||||
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.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -171,6 +172,11 @@ public class CslineController extends BaseController {
|
||||
public HttpResult<List<CsLinePO>> addCldLine(@RequestBody @Validated CsLineParam param) {
|
||||
String methodDescribe = getMethodDescribe("addCldLine");
|
||||
csLinePOService.addCldLine(param);
|
||||
//新增监测点限值
|
||||
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1);
|
||||
overlimit.setId(param.getLineId());
|
||||
overlimitMapper.deleteById(param.getLineId());
|
||||
overlimitMapper.insert(overlimit);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -181,6 +187,11 @@ public class CslineController extends BaseController {
|
||||
public HttpResult<List<CsLinePO>> updateCldLine(@RequestBody CsLineParam param) {
|
||||
String methodDescribe = getMethodDescribe("updateCldLine");
|
||||
csLinePOService.updateCldLine(param);
|
||||
//修改监测点限值
|
||||
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1);
|
||||
overlimit.setId(param.getLineId());
|
||||
overlimitMapper.deleteById(param.getLineId());
|
||||
overlimitMapper.insert(overlimit);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -194,4 +205,19 @@ public class CslineController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateLineDataByList")
|
||||
@ApiOperation("根据装置集合修改监测点信息")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "list", value = "装置id集合", required = true),
|
||||
@ApiImplicitParam(name = "id", value = "模板id", required = true),
|
||||
@ApiImplicitParam(name = "setId", value = "数据集id", required = true),
|
||||
})
|
||||
@ApiIgnore
|
||||
public HttpResult<String> updateDataByList(@RequestParam("list") List<String> list, @RequestParam("id") String id, @RequestParam("setId") String setId){
|
||||
String methodDescribe = getMethodDescribe("updateLineDataByList");
|
||||
csLinePOService.updateLineDataByList(list,id,setId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -35,4 +35,6 @@ public interface CsEquipmentDeliveryMapper extends BaseMapper<CsEquipmentDeliver
|
||||
int getCounts(@Param("queryParam") CsEquipmentDeliveryQueryParm queryParam);
|
||||
|
||||
int getListByNodeProcess(@Param("nodeId")String nodeId,@Param("process")Integer process);
|
||||
|
||||
List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(@Param("nodeId")String nodeId,@Param("process")Integer process);
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsTerminalLogs;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-09-26
|
||||
*/
|
||||
public interface CsTerminalLogsMapper extends BaseMapper<CsTerminalLogs> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsTerminalReply;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-10-09
|
||||
*/
|
||||
public interface CsTerminalReplyMapper extends BaseMapper<CsTerminalReply> {
|
||||
|
||||
}
|
||||
@@ -137,4 +137,16 @@
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="getDataByNodeIdAndProcessNo" resultType="com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO">
|
||||
select
|
||||
*
|
||||
from
|
||||
cs_equipment_delivery
|
||||
where
|
||||
node_id = #{nodeId} and run_status != 0
|
||||
<if test="process != null and process !=''">
|
||||
and node_process = #{process}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
@@ -55,5 +55,5 @@ public interface CsDevModelRelationService extends IService<CsDevModelRelationPO
|
||||
|
||||
String getVersionByDevId(String devId);
|
||||
|
||||
|
||||
void updateDataByList(List<String> list, String id);
|
||||
}
|
||||
|
||||
@@ -183,4 +183,6 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
|
||||
*/
|
||||
List<CsEquipmentDeliveryPO> getDevListByProjectId(String projectId);
|
||||
|
||||
List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.csdevice.service;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -48,7 +49,7 @@ public interface CsLinePOService extends IService<CsLinePO>{
|
||||
|
||||
List<CsLinePO> getLinesByDevList(List<String> list);
|
||||
|
||||
void addCldLine(CsLineParam param);
|
||||
CsLinePO addCldLine(CsLineParam param);
|
||||
|
||||
void updateCldLine(CsLineParam param);
|
||||
|
||||
@@ -60,4 +61,6 @@ public interface CsLinePOService extends IService<CsLinePO>{
|
||||
* @param status 运行状态
|
||||
*/
|
||||
void updateCldLineStatus(List<CsLinePO> lineList, Integer status);
|
||||
|
||||
void updateLineDataByList(List<String> list, String id, String setId);
|
||||
}
|
||||
|
||||
@@ -83,4 +83,6 @@ public interface ICsLedgerService extends IService<CsLedger> {
|
||||
* @return
|
||||
*/
|
||||
List<CsLedgerVO> getProAndEngineer(List<String> id);
|
||||
|
||||
CsLedgerVO cldTree();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsTerminalLogs;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-09-26
|
||||
*/
|
||||
public interface ICsTerminalLogsService extends IService<CsTerminalLogs> {
|
||||
|
||||
/**
|
||||
* 更新台账操作日志信息
|
||||
*/
|
||||
void updateLogs(String id, Integer code);
|
||||
|
||||
/**
|
||||
* 推送台账操作日志信息
|
||||
*/
|
||||
String pushCldInfo();
|
||||
|
||||
void updateLaterData(String id, String code);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsTerminalReply;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-10-09
|
||||
*/
|
||||
public interface ICsTerminalReplyService extends IService<CsTerminalReply> {
|
||||
|
||||
List<String> queryReplyData();
|
||||
|
||||
void updateReplyData(String id,Integer state,String deviceId);
|
||||
|
||||
}
|
||||
@@ -5,6 +5,7 @@ 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 com.njcn.csdevice.pojo.vo.NodeProcessDeviceVo;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -76,4 +77,6 @@ public interface INodeService extends IService<Node> {
|
||||
Node getNodeByNodeName(String nodeName);
|
||||
|
||||
Node getNodeByIp(String ip);
|
||||
|
||||
NodeProcessDeviceVo getProcessNoAndDeviceById(String id);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.csdevice.param.IcdLedgerParam;
|
||||
import com.njcn.csdevice.param.IcdParam;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
import com.njcn.mq.message.CldControlMessage;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -15,4 +16,6 @@ public interface IcdService {
|
||||
|
||||
CldLedgerVo getLedgerById(String id);
|
||||
|
||||
void restartProcess(CldControlMessage message);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
@@ -101,4 +102,11 @@ public class CsDevModelRelationServiceImpl extends ServiceImpl<CsDevModelRelatio
|
||||
public String getVersionByDevId(String devId) {
|
||||
return this.baseMapper.getVersionByDevId(devId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateDataByList(List<String> list, String id) {
|
||||
LambdaUpdateWrapper<CsDevModelRelationPO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(CsDevModelRelationPO::getDevId,list).set(CsDevModelRelationPO::getModelId,id);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ 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.mapper.CsTerminalLogsMapper;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
@@ -100,6 +101,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final INodeService nodeService;
|
||||
private final CsDevModelService csDevModelService;
|
||||
private final CsLedgerMapper csLedgerMapper;
|
||||
private final CsTerminalLogsMapper csTerminalLogsMapper;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -156,6 +158,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
|
||||
@Override
|
||||
public Boolean AuditEquipmentDelivery(String id) {
|
||||
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one();
|
||||
//物理删除
|
||||
QueryWrapper<CsEquipmentDeliveryPO> wrapper = new QueryWrapper();
|
||||
wrapper.eq ("id", id);
|
||||
@@ -784,6 +787,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean delCldDev(String id) {
|
||||
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getId, id).one();
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getId,id);
|
||||
boolean update = this.remove(lambdaQueryWrapper);
|
||||
@@ -805,6 +809,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
if (update) {
|
||||
refreshDeviceDataCache();
|
||||
}
|
||||
//新增操作日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(id);
|
||||
csTerminalLogs.setOperateType(2);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogs.setNodeId(one.getNodeId());
|
||||
csTerminalLogs.setNodeProcess(one.getNodeProcess());
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -867,6 +879,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csLogsFeignClient.addUserLog(dto);
|
||||
}
|
||||
}
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(csEquipmentDeliveryPo.getId());
|
||||
csTerminalLogs.setOperateType(1);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -932,10 +950,25 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
QueryWrapper<CsLedger> csLedgerQueryWrapper = new QueryWrapper();
|
||||
csLedgerQueryWrapper.lambda().eq(CsLedger::getPid, projectId).eq(CsLedger::getState,1);
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
if (CollectionUtil.isEmpty(csLedgers)) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
List<String> collect = csLedgers.stream().map(CsLedger::getId).collect(Collectors.toList());
|
||||
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,collect).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo) {
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId)
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
|
||||
.eq(CsEquipmentDeliveryPO::getDevAccessMethod,"CLD");
|
||||
if (ObjectUtil.isNotNull(processNo)) {
|
||||
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeProcess,processNo);
|
||||
}
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
//根据前置机id获取装置数量
|
||||
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
|
||||
@@ -650,6 +650,85 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsLedgerVO cldTree() {
|
||||
|
||||
List<CsLedgerVO> engineerTree = new ArrayList<>();
|
||||
List<CsLedgerVO> projectTree = new ArrayList<>();
|
||||
List<CsLedgerVO> deviceTree = new ArrayList<>();
|
||||
List<CsLedgerVO> lineTree = new ArrayList<>();
|
||||
|
||||
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
||||
if (CollectionUtil.isNotEmpty(allList)) {
|
||||
//工程集合
|
||||
List<CsLedgerVO> tree1 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).collect(Collectors.toList());
|
||||
//项目集合
|
||||
List<CsLedgerVO> tree2 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).collect(Collectors.toList());
|
||||
//设备集合
|
||||
List<CsLedgerVO> tree3 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).collect(Collectors.toList());
|
||||
//监测点集合
|
||||
List<CsLedgerVO> tree4 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).collect(Collectors.toList());
|
||||
|
||||
//筛选出云前置设备
|
||||
if (CollectionUtil.isNotEmpty(tree3)) {
|
||||
Set<String> list1 = new HashSet<>();
|
||||
List<String> devList = tree3.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
|
||||
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devList);
|
||||
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
|
||||
|
||||
//list1是 cld设备
|
||||
devs.forEach(item->{
|
||||
if (item.getDevType().equals(vo1.getId())) {
|
||||
list1.add(item.getId());
|
||||
}
|
||||
});
|
||||
//list2是 非cld设备
|
||||
Set<String> list2 = devList.stream().filter(item -> !list1.contains(item)).collect(Collectors.toSet());
|
||||
List<CsLedgerVO> tree5 = tree3.stream().filter(vo -> list2.contains(vo.getId())).collect(Collectors.toList());
|
||||
Set<String> list3 = tree5.stream().map(CsLedgerVO::getPid).collect(Collectors.toSet());
|
||||
projectTree = tree2.stream().filter(vo -> !list3.contains(vo.getId())).collect(Collectors.toList());
|
||||
|
||||
|
||||
List<CsLedgerVO> tree6 = tree2.stream().filter(vo -> list3.contains(vo.getId())).collect(Collectors.toList());
|
||||
Set<String> proList = tree6.stream().map(CsLedgerVO::getPid).collect(Collectors.toSet());
|
||||
engineerTree = tree1.stream().filter(vo -> !proList.contains(vo.getId())).collect(Collectors.toList());
|
||||
|
||||
if (CollectionUtil.isNotEmpty(list1)) {
|
||||
deviceTree = tree3.stream().filter(vo -> list1.contains(vo.getId())).collect(Collectors.toList());
|
||||
lineTree = tree4.stream().filter(vo -> list1.contains(vo.getPid())).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(deviceTree)) {
|
||||
List<CsLedgerVO> finalLineTree = lineTree;
|
||||
deviceTree.forEach(item->{
|
||||
item.setChildren(getChildren(item, finalLineTree));
|
||||
});
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(projectTree)) {
|
||||
List<CsLedgerVO> finalDeviceTree = deviceTree;
|
||||
projectTree.forEach(item->{
|
||||
item.setChildren(getChildren(item, finalDeviceTree));
|
||||
});
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(engineerTree)) {
|
||||
List<CsLedgerVO> finalProjectTree = projectTree;
|
||||
engineerTree.forEach(item->{
|
||||
item.setChildren(getChildren(item, finalProjectTree));
|
||||
});
|
||||
}
|
||||
|
||||
CsLedgerVO government = new CsLedgerVO();
|
||||
government.setLevel(0);
|
||||
government.setName(DataParam.cldDev);
|
||||
government.setPid("0");
|
||||
government.setId(IdUtil.simpleUUID());
|
||||
government.setChildren(engineerTree);
|
||||
|
||||
return government;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子节点
|
||||
*/
|
||||
|
||||
@@ -8,29 +8,21 @@ import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
import com.njcn.csdevice.mapper.CsLinePOMapper;
|
||||
import com.njcn.csdevice.mapper.OverlimitMapper;
|
||||
import com.njcn.csdevice.mapper.CsTerminalLogsMapper;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.po.CsDevModelPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.service.CsDevModelService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsDataSetService;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
import com.njcn.device.biz.utils.COverlimitUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.user.pojo.constant.FunctionState;
|
||||
import com.njcn.user.pojo.po.Function;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -50,7 +42,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
private final CsDevModelService csDevModelService;
|
||||
private final ICsDataSetService csDataSetService;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final OverlimitMapper overlimitMapper;
|
||||
private final CsTerminalLogsMapper csTerminalLogsMapper;
|
||||
|
||||
@Override
|
||||
public List<CsLinePO> getLineByDev(List<String> list) {
|
||||
@@ -111,7 +103,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void addCldLine(CsLineParam param) {
|
||||
public CsLinePO addCldLine(CsLineParam param) {
|
||||
String lineId = param.getDevMac().replace(":","") + param.getLineNo();
|
||||
CsLinePO po = new CsLinePO();
|
||||
//1.新增监测点信息
|
||||
@@ -145,21 +137,17 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
csLedger.setState(1);
|
||||
csLedger.setSort(0);
|
||||
csLedgerMapper.insert(csLedger);
|
||||
|
||||
//3.新增监测点限值
|
||||
Overlimit overlimit = COverlimitUtil.globalAssemble(param.getVolGrade().floatValue(),10f,10f,10f,0,1);
|
||||
overlimit.setId(lineId);
|
||||
overlimitMapper.deleteById(lineId);
|
||||
overlimitMapper.insert(overlimit);
|
||||
return po;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void updateCldLine(CsLineParam param) {
|
||||
LambdaQueryWrapper<CsLinePO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsLinePO::getDeviceId,param.getDevId())
|
||||
.ne(CsLinePO::getLineId,param.getLineId())
|
||||
.eq(CsLinePO::getStatus,1)
|
||||
.eq(CsLinePO::getClDid,param.getClDid());
|
||||
.eq(CsLinePO::getLineNo,param.getLineNo())
|
||||
.eq(CsLinePO::getStatus,1);
|
||||
List<CsLinePO> lineList = this.list(wrapper);
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
throw new BusinessException("监测点线路号重复,请调整!");
|
||||
@@ -167,23 +155,47 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
LambdaUpdateWrapper<CsLinePO> lambdaUpdateWrapper = new LambdaUpdateWrapper<>();
|
||||
lambdaUpdateWrapper.eq(CsLinePO::getLineId,param.getLineId())
|
||||
.eq(CsLinePO::getStatus,1)
|
||||
.set(CsLinePO::getVolGrade,param.getVolGrade())
|
||||
.set(CsLinePO::getName,param.getName())
|
||||
.set(CsLinePO::getLineNo,param.getLineNo())
|
||||
.set(CsLinePO::getConType,param.getConType())
|
||||
.set(CsLinePO::getLineInterval,param.getLineInterval())
|
||||
.set(CsLinePO::getPtRatio,param.getPtRatio())
|
||||
.set(CsLinePO::getPt2Ratio,param.getPt2Ratio())
|
||||
.set(CsLinePO::getCtRatio,param.getCtRatio())
|
||||
.set(CsLinePO::getCt2Ratio,param.getCt2Ratio())
|
||||
.set(CsLinePO::getClDid,param.getClDid())
|
||||
.set(CsLinePO::getLineInterval,param.getLineInterval())
|
||||
.set(CsLinePO::getVolGrade,param.getVolGrade())
|
||||
.set(CsLinePO::getRunStatus,param.getRunStatus());
|
||||
this.update(lambdaUpdateWrapper);
|
||||
|
||||
//修改台账树中监测点的名称
|
||||
QueryWrapper<CsLedger> queryWrapper = new QueryWrapper();
|
||||
queryWrapper.eq("state",1).eq("id",param.getLineId());
|
||||
CsLedger csLedger = csLedgerMapper.selectOne(queryWrapper);
|
||||
csLedger.setName(param.getName());
|
||||
csLedgerMapper.updateById(csLedger);
|
||||
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(param.getDevId());
|
||||
csTerminalLogs.setOperateType(1);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCldLine(String id) {
|
||||
CsLinePO po = this.getById(id);
|
||||
|
||||
this.removeById(id);
|
||||
csLedgerMapper.deleteById(id);
|
||||
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(po.getDeviceId());
|
||||
csTerminalLogs.setOperateType(1);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -192,6 +204,13 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
this.updateBatchById(lineList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLineDataByList(List<String> list, String id, String setId) {
|
||||
LambdaUpdateWrapper<CsLinePO> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.in(CsLinePO::getDeviceId,list).set(CsLinePO::getDataModelId,id).set(CsLinePO::getDataSetId,setId);
|
||||
this.update(updateWrapper);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * 1.平台端默认配置拓扑图模板,包含拓扑图信息(cs_topology_diagram_template)和拓扑图上监测点的点位信息(cs_line_topology_template)
|
||||
// *
|
||||
|
||||
@@ -0,0 +1,287 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsTerminalLogsMapper;
|
||||
import com.njcn.csdevice.mapper.CsTerminalReplyMapper;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsTerminalLogsService;
|
||||
import com.njcn.csdevice.service.INodeService;
|
||||
import com.njcn.mq.message.CldControlMessage;
|
||||
import com.njcn.mq.message.CldUpdateLedgerMessage;
|
||||
import com.njcn.mq.template.CldControlMessageTemplate;
|
||||
import com.njcn.mq.template.CldUpdateLedgerMessageTemplate;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-09-26
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper, CsTerminalLogs> implements ICsTerminalLogsService {
|
||||
|
||||
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
private final INodeService nodeService;
|
||||
private final CldUpdateLedgerMessageTemplate template;
|
||||
private final CldControlMessageTemplate controlMessageTemplate;
|
||||
private final RedisUtil redisUtil;
|
||||
private final CsTerminalReplyMapper csTerminalReplyMapper;
|
||||
|
||||
@Override
|
||||
public void updateLogs(String id, Integer code) {
|
||||
LambdaUpdateWrapper<CsTerminalLogs> wrapper = new LambdaUpdateWrapper<>();
|
||||
wrapper.set(CsTerminalLogs::getIsPush, 0)
|
||||
.eq(CsTerminalLogs::getDeviceId, id);
|
||||
this.update(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public String pushCldInfo() {
|
||||
LambdaQueryWrapper<CsTerminalLogs> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsTerminalLogs::getIsPush, 0);
|
||||
List<CsTerminalLogs> list = this.list(wrapper);
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
//新增台账集合
|
||||
List<String> addList = new ArrayList<>();
|
||||
//修改台账集合
|
||||
List<String> updateList = new ArrayList<>();
|
||||
//删除台账集合
|
||||
List<String> deleteList = new ArrayList<>();
|
||||
|
||||
//根据设备分组,判断设备的操作,整合
|
||||
Map<String,List<CsTerminalLogs>> map = list.stream().collect(Collectors.groupingBy(CsTerminalLogs::getDeviceId));
|
||||
map.forEach((k,v)->{
|
||||
List<Integer> operateTypeList = v.stream().map(CsTerminalLogs::getOperateType).distinct().collect(Collectors.toList());
|
||||
|
||||
if (operateTypeList.size() == 3) {
|
||||
//啥也不用干
|
||||
//deleteList.add(k);
|
||||
} else if (operateTypeList.size() == 2 && operateTypeList.contains(0) && operateTypeList.contains(1)) {
|
||||
addList.add(k);
|
||||
} else if (operateTypeList.size() == 2 && operateTypeList.contains(0) && operateTypeList.contains(2)) {
|
||||
//啥也不用干
|
||||
} else if (operateTypeList.size() == 2 && operateTypeList.contains(1) && operateTypeList.contains(2)) {
|
||||
deleteList.add(k);
|
||||
} else if (operateTypeList.size() == 1 && operateTypeList.contains(0)) {
|
||||
addList.add(k);
|
||||
} else if (operateTypeList.size() == 1 && operateTypeList.contains(1)) {
|
||||
updateList.add(k);
|
||||
} else if (operateTypeList.size() == 1 && operateTypeList.contains(2)) {
|
||||
deleteList.add(k);
|
||||
}
|
||||
});
|
||||
//整合后 所有设备的id
|
||||
List<String> devList = Stream.of(addList, updateList, deleteList).flatMap(List::stream).collect(Collectors.toList());
|
||||
//获取设备集合
|
||||
List<CsEquipmentDeliveryPO> deviceList = csEquipmentDeliveryService.listByIds(devList);
|
||||
//按照前置机id分组
|
||||
Map<String,List<CsEquipmentDeliveryPO>> nodeMap = deviceList.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
|
||||
nodeMap.forEach((k,v)->{
|
||||
int maxProcessNum = nodeService.getNodeById(k).getMaxProcessNum();
|
||||
//按照进程号分组
|
||||
Map<Integer,List<CsEquipmentDeliveryPO>> nodeProcessMap = v.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess));
|
||||
nodeProcessMap.forEach((k1,v1)->{
|
||||
if (v1.size() > 10) {
|
||||
//一个进程下修改的设备数量超过10台,重启该进程号下的前置
|
||||
CldControlMessage cldControlMessage = new CldControlMessage();
|
||||
cldControlMessage.setGuid(IdUtil.simpleUUID());
|
||||
cldControlMessage.setCode("set_process");
|
||||
cldControlMessage.setProcessNo(k1);
|
||||
cldControlMessage.setFun("delete");
|
||||
cldControlMessage.setProcessNum(maxProcessNum);
|
||||
controlMessageTemplate.sendMember(cldControlMessage,k);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
if (CollectionUtil.isNotEmpty(addList)) {
|
||||
sendMessage(addList, deviceList, "add_terminal");
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(updateList)) {
|
||||
sendMessage(updateList, deviceList, "ledger_modify");
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(deleteList)) {
|
||||
sendDeleteMessage(deleteList, list, "delete_terminal");
|
||||
}
|
||||
|
||||
//推送完将数据改成推送
|
||||
LambdaUpdateWrapper<CsTerminalLogs> wrapper2 = new LambdaUpdateWrapper<>();
|
||||
wrapper2.set(CsTerminalLogs::getIsPush, 1);
|
||||
this.update(wrapper2);
|
||||
} else {
|
||||
return "暂无需要推送的数据";
|
||||
}
|
||||
return "成功";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateLaterData(String id, String code) {
|
||||
int operateType;
|
||||
if (Objects.equals(code, "add_terminal")) {
|
||||
operateType = 0;
|
||||
} else if (Objects.equals(code, "ledger_modify")) {
|
||||
operateType = 1;
|
||||
} else{
|
||||
operateType = 2;
|
||||
}
|
||||
//找出最新的数据,将状态改为未推送,下次可以再次推送
|
||||
this.lambdaUpdate()
|
||||
.eq(CsTerminalLogs::getDeviceId, id)
|
||||
.eq(CsTerminalLogs::getOperateType, operateType)
|
||||
.orderByDesc(CsTerminalLogs::getCreateTime)
|
||||
.last("LIMIT 1")
|
||||
.set(CsTerminalLogs::getIsPush, 0)
|
||||
.update();
|
||||
}
|
||||
|
||||
public void sendMessage(List<String> addList, List<CsEquipmentDeliveryPO> deviceList, String type) {
|
||||
List<CsEquipmentDeliveryPO> filteredList = deviceList.stream().filter(device -> addList.contains(device.getId())).collect(Collectors.toList());
|
||||
//获取监测点信息
|
||||
List<CsLinePO> lineList = csLinePOService.getLinesByDevList(addList);
|
||||
|
||||
Map<String,List<CsEquipmentDeliveryPO>> nodeMap1 = filteredList.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
|
||||
nodeMap1.forEach((k,v)->{
|
||||
CldUpdateLedgerMessage message = new CldUpdateLedgerMessage();
|
||||
message.setCode(type);
|
||||
//按照进程号分组
|
||||
Map<Integer,List<CsEquipmentDeliveryPO>> nodeProcessMap1 = v.stream().collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeProcess));
|
||||
for (Map.Entry<Integer, List<CsEquipmentDeliveryPO>> entry : nodeProcessMap1.entrySet()) {
|
||||
Integer k1 = entry.getKey();
|
||||
List<CsEquipmentDeliveryPO> v1 = entry.getValue();
|
||||
String guid = IdUtil.simpleUUID();
|
||||
message.setGuid(guid);
|
||||
message.setProcessNo(String.valueOf(k1));
|
||||
List<CldUpdateLedgerMessage.CldDeviceDto> list1 = new ArrayList<>();
|
||||
v1.forEach(item -> {
|
||||
CldUpdateLedgerMessage.CldDeviceDto deviceDto = new CldUpdateLedgerMessage.CldDeviceDto();
|
||||
deviceDto.setId(item.getId());
|
||||
deviceDto.setNode(item.getNodeProcess());
|
||||
deviceDto.setName(item.getName());
|
||||
deviceDto.setIp(item.getMac());
|
||||
deviceDto.setDevType(dictTreeFeignClient.queryById(item.getDevModel()).getData().getName());
|
||||
Node node = nodeService.getNodeById(item.getNodeId());
|
||||
if (node != null) {
|
||||
deviceDto.setMaxProcessNum(node.getMaxProcessNum());
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
List<CldUpdateLedgerMessage.CldMonitorDto> list2 = new ArrayList<>();
|
||||
lineList.forEach(item2 -> {
|
||||
if (Objects.equals(item.getId(), item2.getDeviceId())) {
|
||||
CldUpdateLedgerMessage.CldMonitorDto cldLineDto = new CldUpdateLedgerMessage.CldMonitorDto();
|
||||
cldLineDto.setId(item2.getLineId());
|
||||
cldLineDto.setName(item.getName());
|
||||
cldLineDto.setLineNo(String.valueOf(item2.getLineNo()));
|
||||
cldLineDto.setVoltageLevel(item2.getVolGrade() + "kV");
|
||||
cldLineDto.setStatus(item.getRunStatus());
|
||||
cldLineDto.setPtType(String.valueOf(item2.getConType()));
|
||||
cldLineDto.setDeviceId(item2.getDeviceId());
|
||||
cldLineDto.setPt1(item2.getPtRatio());
|
||||
cldLineDto.setPt2(item2.getPt2Ratio());
|
||||
cldLineDto.setCt1(item2.getCtRatio());
|
||||
cldLineDto.setCt2(item2.getCt2Ratio());
|
||||
list2.add(cldLineDto);
|
||||
}
|
||||
});
|
||||
deviceDto.setMonitorData(list2);
|
||||
}
|
||||
list1.add(deviceDto);
|
||||
|
||||
//存储发送的数据记录,用于后面响应校验
|
||||
CsTerminalReply csFmTerminalReply = new CsTerminalReply();
|
||||
csFmTerminalReply.setReplyId(guid);
|
||||
csFmTerminalReply.setCode(type);
|
||||
csFmTerminalReply.setNodeId(k);
|
||||
csFmTerminalReply.setProcessNo(k1);
|
||||
csFmTerminalReply.setDeviceId(item.getId());
|
||||
csFmTerminalReply.setIsReceived(0);
|
||||
csTerminalReplyMapper.insert(csFmTerminalReply);
|
||||
});
|
||||
message.setData(list1);
|
||||
template.sendMember(message, k);
|
||||
|
||||
//缓存本次发送数据GUID的集合,用于查询数据
|
||||
Object object = redisUtil.getObjectByKey(RequestUtil.getUserIndex()+"reply");
|
||||
if (object != null) {
|
||||
String value = object + "," + guid;
|
||||
redisUtil.saveByKeyWithExpire(RequestUtil.getUserIndex()+"reply", value, 60L);
|
||||
} else {
|
||||
redisUtil.saveByKeyWithExpire(RequestUtil.getUserIndex()+"reply", guid, 60L);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void sendDeleteMessage(List<String> list, List<CsTerminalLogs> csTerminalLogs, String type) {
|
||||
List<CsTerminalLogs> filteredList = csTerminalLogs.stream().filter(device -> list.contains(device.getDeviceId()) && Objects.equals(device.getOperateType(),2)).collect(Collectors.toList());
|
||||
Map<String,List<CsTerminalLogs>> nodeMap1 = filteredList.stream().collect(Collectors.groupingBy(CsTerminalLogs::getNodeId));
|
||||
nodeMap1.forEach((k,v)->{
|
||||
CldUpdateLedgerMessage message = new CldUpdateLedgerMessage();
|
||||
message.setCode(type);
|
||||
//按照进程号分组
|
||||
Map<Integer,List<CsTerminalLogs>> nodeProcessMap1 = v.stream().collect(Collectors.groupingBy(CsTerminalLogs::getNodeProcess));
|
||||
nodeProcessMap1.forEach((k1,v1)->{
|
||||
String guid = IdUtil.simpleUUID();
|
||||
message.setGuid(guid);
|
||||
message.setProcessNo(String.valueOf(k1));
|
||||
List<CldUpdateLedgerMessage.CldDeviceDto> list1 = new ArrayList<>();
|
||||
v1.forEach(item->{
|
||||
CldUpdateLedgerMessage.CldDeviceDto deviceDto = new CldUpdateLedgerMessage.CldDeviceDto();
|
||||
deviceDto.setId(item.getDeviceId());
|
||||
deviceDto.setNode(item.getNodeProcess());
|
||||
Node node = nodeService.getNodeById(item.getNodeId());
|
||||
if (node != null) {
|
||||
deviceDto.setMaxProcessNum(node.getMaxProcessNum());
|
||||
}
|
||||
list1.add(deviceDto);
|
||||
|
||||
//存储发送的数据记录,用于后面响应校验
|
||||
CsTerminalReply csFmTerminalReply = new CsTerminalReply();
|
||||
csFmTerminalReply.setReplyId(guid);
|
||||
csFmTerminalReply.setCode(type);
|
||||
csFmTerminalReply.setNodeId(k);
|
||||
csFmTerminalReply.setProcessNo(k1);
|
||||
csFmTerminalReply.setDeviceId(item.getDeviceId());
|
||||
csFmTerminalReply.setIsReceived(0);
|
||||
csTerminalReplyMapper.insert(csFmTerminalReply);
|
||||
});
|
||||
message.setData(list1);
|
||||
template.sendMember(message,k);
|
||||
|
||||
//缓存本次发送数据GUID的集合,用于查询数据
|
||||
Object object = redisUtil.getObjectByKey(RequestUtil.getUserIndex()+"reply");
|
||||
if (object != null) {
|
||||
String value = object + "," + guid;
|
||||
redisUtil.saveByKeyWithExpire(RequestUtil.getUserIndex()+"reply", value, 60L);
|
||||
} else {
|
||||
redisUtil.saveByKeyWithExpire(RequestUtil.getUserIndex()+"reply", guid, 60L);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,95 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsTerminalReplyMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsTerminalReply;
|
||||
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
||||
import com.njcn.csdevice.service.ICsTerminalLogsService;
|
||||
import com.njcn.csdevice.service.ICsTerminalReplyService;
|
||||
import com.njcn.csdevice.service.INodeService;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2025-10-09
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMapper, CsTerminalReply> implements ICsTerminalReplyService {
|
||||
|
||||
private final RedisUtil redisUtil;
|
||||
private final INodeService nodeService;
|
||||
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
private final ICsTerminalLogsService csTerminalLogsService;
|
||||
|
||||
@Override
|
||||
public List<String> queryReplyData() {
|
||||
List<String> result = new ArrayList<>();
|
||||
Object object = redisUtil.getObjectByKey(RequestUtil.getUserIndex()+"reply");
|
||||
if (object != null) {
|
||||
List<String> redisList = Stream.of(object.toString().split(",")).collect(Collectors.toList());
|
||||
List<CsTerminalReply> list = this.lambdaQuery().in(CsTerminalReply::getReplyId,redisList).orderByAsc(CsTerminalReply::getCreateTime).list();
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
Map<Integer,List<CsTerminalReply>> map = list.stream().collect(Collectors.groupingBy(CsTerminalReply::getIsReceived));
|
||||
List<CsTerminalReply> list1 = map.get(1);
|
||||
if (CollectionUtil.isEmpty(list1)) {
|
||||
String key = "更新失败,未收到前置应答,请查看应答报文是否发送";
|
||||
result.add(key);
|
||||
//将cs_terminal_logs数据置为未发送
|
||||
list.forEach(item->{
|
||||
csTerminalLogsService.updateLaterData(item.getDeviceId(),item.getCode());
|
||||
});
|
||||
} else {
|
||||
list.forEach(item->{
|
||||
String key;
|
||||
String code;
|
||||
if (Objects.equals(item.getCode(), "add_terminal")) {
|
||||
code = "新增";
|
||||
} else if (Objects.equals(item.getCode(), "ledger_modify")) {
|
||||
code = "修改";
|
||||
} else {
|
||||
code = "删除";
|
||||
}
|
||||
String nodeName = nodeService.getNodeById(item.getNodeId()).getName();
|
||||
List<CsEquipmentDeliveryPO> devList1 = csEquipmentDeliveryService.getAll();
|
||||
List<CsEquipmentDeliveryPO> devList2 = devList1.stream().filter(item1 -> Objects.equals(item1.getId(), item.getDeviceId())).collect(Collectors.toList());
|
||||
List<String> devNameList = devList2.stream().map(CsEquipmentDeliveryPO::getName).collect(Collectors.toList());
|
||||
String devNameListString = devNameList.toString();
|
||||
if (item.getIsReceived() == 0) {
|
||||
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + code + "数据失败";
|
||||
//将cs_terminal_logs数据置为未发送
|
||||
csTerminalLogsService.updateLaterData(item.getDeviceId(),item.getCode());
|
||||
} else {
|
||||
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + code + "数据成功";
|
||||
}
|
||||
result.add(key);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateReplyData(String id,Integer state,String deviceId) {
|
||||
this.lambdaUpdate().set(CsTerminalReply::getIsReceived,state)
|
||||
.eq(CsTerminalReply::getDeviceId,deviceId)
|
||||
.eq(CsTerminalReply::getReplyId,id);
|
||||
}
|
||||
}
|
||||
@@ -3,8 +3,8 @@ package com.njcn.csdevice.service.impl;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.access.utils.ChannelObjectUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.param.IcdLedgerParam;
|
||||
@@ -16,6 +16,7 @@ import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CldLedgerVo;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceInfo;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.mq.message.CldControlMessage;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
@@ -43,7 +44,7 @@ class IcdServiceImpl implements IcdService {
|
||||
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final ICsLedgerService csLedgerService;
|
||||
private final MqttPublisher publisher;
|
||||
private final ICsTerminalLogsService csTerminalLogsService;
|
||||
|
||||
@Override
|
||||
public List<DeviceInfo> getLedgerInfo(IcdParam param) {
|
||||
@@ -59,7 +60,7 @@ class IcdServiceImpl implements IcdService {
|
||||
|
||||
List<DeviceInfo> result = new ArrayList<>();
|
||||
//根据ip获取前置机信息
|
||||
Node node = nodeService.getNodeByIp(param.getIp());
|
||||
Node node = nodeService.getNodeById(param.getId());
|
||||
if (ObjectUtil.isNotNull(node)) {
|
||||
//根据前置机ip获取装置信息
|
||||
List<CsEquipmentDeliveryPO> poList = csEquipmentDeliveryService.getCldDevByIp(node.getId(),param.getRunFlag());
|
||||
@@ -77,6 +78,7 @@ class IcdServiceImpl implements IcdService {
|
||||
detail.setIp(dev.getMac());
|
||||
detail.setDevType(Objects.isNull(finalSysDicTreeMap.get(dev.getDevModel())) ? "/":finalSysDicTreeMap.get(dev.getDevModel()).getCode());
|
||||
detail.setNode(dev.getNodeProcess());
|
||||
detail.setMaxProcessNum(node.getMaxProcessNum());
|
||||
|
||||
// 只获取当前设备的监测点数据
|
||||
List<CsLinePO> lines = lineMap.get(dev.getId());
|
||||
@@ -122,10 +124,8 @@ class IcdServiceImpl implements IcdService {
|
||||
handleFromProjectCreation(param);
|
||||
}
|
||||
// 第四种:从设备创建
|
||||
else if (CollectionUtil.isNotEmpty(param.getDevice())) {
|
||||
else if (ObjectUtil.isNotNull(param.getDevIndex())) {
|
||||
handleFromDeviceCreation(param);
|
||||
//todo 新增完监测点后,需要通知前置修改台账信息
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -160,6 +160,11 @@ class IcdServiceImpl implements IcdService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void restartProcess(CldControlMessage message) {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置工程信息
|
||||
*/
|
||||
@@ -202,8 +207,10 @@ class IcdServiceImpl implements IcdService {
|
||||
vo.setProjectInfoList(appProjectPOS);
|
||||
// 设置设备信息
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getDevListByProjectId(id);
|
||||
if (CollectionUtil.isNotEmpty(devList)) {
|
||||
vo.setDeviceInfoList(devList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 处理2级数据(设备级别)
|
||||
@@ -242,12 +249,6 @@ class IcdServiceImpl implements IcdService {
|
||||
// 设置线路信息
|
||||
List<CsLinePO> line = csLinePOService.listByIds(Collections.singletonList(id));
|
||||
vo.setLineInfoList(line);
|
||||
}
|
||||
|
||||
public void sendFrontLedger() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private boolean isAllIndicesNull(IcdLedgerParam param) {
|
||||
@@ -291,18 +292,22 @@ class IcdServiceImpl implements IcdService {
|
||||
List<CsEquipmentDeliveryAddParm> devList = param.getDevice();
|
||||
if (CollectionUtil.isNotEmpty(devList)) {
|
||||
Map<String,String> devMacMap = new HashMap<>();
|
||||
Map<String, CsEquipmentDeliveryPO> devMap = 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());
|
||||
devMap.put(dev.getMac(),po3);
|
||||
}
|
||||
param.setDevMacMap(devMacMap);
|
||||
param.setDevMap(devMap);
|
||||
}
|
||||
saveLines(param);
|
||||
}
|
||||
|
||||
private void saveLines(IcdLedgerParam param) {
|
||||
List<CsLinePO> list = new ArrayList<>();
|
||||
List<CsLineParam> lineList = param.getLine();
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
boolean result = checkAndAlertDuplicates(lineList);
|
||||
@@ -323,8 +328,20 @@ class IcdServiceImpl implements IcdService {
|
||||
}
|
||||
line.setDevId(param.getDevIndex());
|
||||
}
|
||||
csLinePOService.addCldLine(line);
|
||||
CsLinePO po = csLinePOService.addCldLine(line);
|
||||
list.add(po);
|
||||
}
|
||||
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
if (ObjectUtil.isNotNull(param.getDevIndex()) && StringUtil.isNotBlank(param.getDevIndex())) {
|
||||
csTerminalLogs.setDeviceId(param.getDevIndex());
|
||||
} else {
|
||||
csTerminalLogs.setDeviceId(param.getDevMacMap().get(lineList.get(0).getDevMac()));
|
||||
}
|
||||
csTerminalLogs.setOperateType(0);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsService.save(csTerminalLogs);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,9 @@ 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.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.Node;
|
||||
import com.njcn.csdevice.pojo.vo.NodeProcessDeviceVo;
|
||||
import com.njcn.csdevice.service.INodeService;
|
||||
import com.njcn.db.constant.DbConstant;
|
||||
import com.njcn.device.biz.enums.DeviceResponseEnum;
|
||||
@@ -25,8 +27,10 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Propagation;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -143,6 +147,24 @@ public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements IN
|
||||
return this.baseMapper.selectOne(nodeLambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public NodeProcessDeviceVo getProcessNoAndDeviceById(String id) {
|
||||
NodeProcessDeviceVo nodeProcessDeviceVo = new NodeProcessDeviceVo();
|
||||
Node node = this.getById(id);
|
||||
nodeProcessDeviceVo.setNode(node);
|
||||
List<NodeProcessDeviceVo.ProcessDevice> processDeviceList = new ArrayList<>();
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryMapper.getDataByNodeIdAndProcessNo(id,null);
|
||||
for (int i = 1; i <= node.getMaxProcessNum(); i++) {
|
||||
int finalI = i;
|
||||
NodeProcessDeviceVo.ProcessDevice processDevice = new NodeProcessDeviceVo.ProcessDevice();
|
||||
processDevice.setProcessNo(i);
|
||||
processDevice.setDeviceInfoList(devList.stream().filter(dev -> Objects.equals(dev.getNodeProcess(), finalI)).collect(Collectors.toList()));
|
||||
processDeviceList.add(processDevice);
|
||||
}
|
||||
nodeProcessDeviceVo.setProcessDeviceList(processDeviceList);
|
||||
return nodeProcessDeviceVo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同编码的字典类型
|
||||
*/
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.njcn.csdevice.mapper.*;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsMarketDataVO;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.CsMarketDataService;
|
||||
import com.njcn.csdevice.service.RoleEngineerDevService;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
@@ -16,7 +12,6 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -99,7 +94,7 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
|
||||
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getEnginerId).distinct().collect(Collectors.toList());
|
||||
|
||||
}else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())){
|
||||
}else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())||Objects.equals(role,"bxs_user")){
|
||||
List<CsEngineeringPO> csEngineeringPOS = csEngineeringMapper.selectList(null);
|
||||
collect =csEngineeringPOS.stream().filter(temp->Objects.equals(temp.getStatus(),"1")).map(CsEngineeringPO::getId).collect(Collectors.toList());
|
||||
}
|
||||
@@ -201,7 +196,7 @@ public class RoleEngineerDevServiceImpl implements RoleEngineerDevService {
|
||||
List<CsTouristDataPO> csTouristDataPOS = csTouristDataPOMapper.selectList(null);
|
||||
collect = csTouristDataPOS.stream().map(CsTouristDataPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
|
||||
}else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())){
|
||||
}else if(Objects.equals(role,AppRoleEnum.ROOT.getCode())||Objects.equals(role,AppRoleEnum.OPERATION_MANAGER.getCode())||Objects.equals(role,"bxs_user")){
|
||||
csLedgerQueryWrapper.clear();
|
||||
csLedgerQueryWrapper.eq("level",2).eq("state",1);
|
||||
List<CsLedger> csLedgers = csLedgerMapper.selectList(csLedgerQueryWrapper);
|
||||
|
||||
@@ -53,7 +53,7 @@ public class InfluxDbParamUtil {
|
||||
//如果是云前置设备,直接返回clDid
|
||||
boolean isCLdDevice = DicDataEnum.DEV_CLD.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryDTOList.get(0).getDevType()).getData().getCode());
|
||||
if(isCLdDevice){
|
||||
return String.valueOf(finalCsLinePOList.get(0).getLineNo());
|
||||
// return String.valueOf(finalCsLinePOList.get(0).getLineNo());
|
||||
}
|
||||
//之后的逻辑还是按照原来的不变
|
||||
String position = csLineFeignClient.getPositionById(lineId).getData();
|
||||
|
||||
@@ -11,9 +11,15 @@ import java.io.Serializable;
|
||||
@Data
|
||||
public class CldEventParam implements Serializable {
|
||||
|
||||
@ApiModelProperty("设备id")
|
||||
private String devId;
|
||||
|
||||
@ApiModelProperty("监测点id")
|
||||
private String monitorId;
|
||||
|
||||
@ApiModelProperty("监测点序号")
|
||||
private Integer cpuNo;
|
||||
|
||||
@ApiModelProperty("暂降触发时间")
|
||||
private String startTime;
|
||||
|
||||
@@ -29,10 +35,7 @@ public class CldEventParam implements Serializable {
|
||||
@ApiModelProperty("相别")
|
||||
private String phase;
|
||||
|
||||
@ApiModelProperty("Cfg文件路径")
|
||||
private String wavePathCfg;
|
||||
|
||||
@ApiModelProperty("Dat文件路径")
|
||||
private String wavePathDat;
|
||||
@ApiModelProperty("文件路径")
|
||||
private String wavePath;
|
||||
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ import java.util.List;
|
||||
@Data
|
||||
public class ZuTaiDTO {
|
||||
|
||||
@SerializedName("done_json")
|
||||
private List<Detail> doneJson;
|
||||
@SerializedName("json")
|
||||
private List<Detail> json;
|
||||
|
||||
@Data
|
||||
public static class Detail{
|
||||
@@ -37,12 +37,12 @@ public class ZuTaiDTO {
|
||||
private Boolean display;
|
||||
|
||||
@SerializedName("lineId")
|
||||
private List<String> lineId;
|
||||
private String lineId;
|
||||
|
||||
@SerializedName("UID")
|
||||
private List<String> uId;
|
||||
|
||||
@SerializedName("UName")
|
||||
@SerializedName("UIDName")
|
||||
private String target;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package com.njcn.csharmonic.pojo.vo;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.annotations.SerializedName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -31,6 +33,7 @@ public class CsPageVO {
|
||||
private String pid;
|
||||
|
||||
@ApiModelProperty(value="前端使用")
|
||||
@JsonProperty("kId")
|
||||
private String kId;
|
||||
|
||||
@ApiModelProperty(value="组态项目名称")
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.csharmonic.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class FrontWarnVO implements Serializable {
|
||||
|
||||
@ApiModelProperty("前置id")
|
||||
private String frontId;
|
||||
|
||||
@ApiModelProperty("前置ip")
|
||||
private String frontIp;
|
||||
|
||||
@ApiModelProperty("前置进程号")
|
||||
private Integer processNo;
|
||||
|
||||
@ApiModelProperty("事件发生时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty("告警描述")
|
||||
private String tag;
|
||||
|
||||
@ApiModelProperty("告警码")
|
||||
private Integer code;
|
||||
|
||||
}
|
||||
@@ -8,9 +8,11 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
@@ -76,6 +78,16 @@ public class EventUserController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/frontWarnInfo")
|
||||
@ApiOperation("前置告警信息")
|
||||
@ApiImplicitParam(name = "baseParam", value = "基础查询数据", required = true)
|
||||
public HttpResult<Page<CsEventPO>> frontWarnInfo(@RequestBody BaseParam baseParam) {
|
||||
String methodDescribe = getMethodDescribe("frontWarnInfo");
|
||||
Page<CsEventPO> list = csEventUserPOService.getFrontWarnInfo(baseParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateStatus")
|
||||
@ApiOperation("已读事件")
|
||||
@@ -86,5 +98,4 @@ public class EventUserController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -44,7 +44,6 @@ public class RealDataController extends BaseController {
|
||||
public HttpResult<Boolean> getRealData(@RequestParam("lineId") String lineId) {
|
||||
String methodDescribe = getMethodDescribe("getRealData");
|
||||
boolean result = realDataService.getBaseRealData(lineId);
|
||||
redisUtil.saveByKeyWithExpire("rtDataUserId:"+lineId, RequestUtil.getUserIndex(),600L);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
@@ -69,15 +68,4 @@ public class RealDataController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getCldBaseRealData")
|
||||
@ApiOperation("获取云前置基础实时数据")
|
||||
@ApiImplicitParam(name = "lineId", value = "监测点id")
|
||||
public HttpResult<String> getCldBaseRealData(@RequestParam("lineId") String lineId) {
|
||||
String methodDescribe = getMethodDescribe("getCldBaseRealData");
|
||||
realDataService.getCldBaseRealData(lineId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "平台下发指令成功", methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,11 +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.csharmonic.param.CsEventUserQueryPage;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -29,4 +31,6 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
|
||||
Page<EventDetailVO> queryEventpage(CsEventUserQueryPage csEventUserQueryPage);
|
||||
|
||||
Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage);
|
||||
|
||||
Page<CsEventPO> getFrontWarnInfo(BaseParam baseParam);
|
||||
}
|
||||
|
||||
@@ -16,7 +16,4 @@ public interface RealDataService {
|
||||
* @param lineId
|
||||
*/
|
||||
boolean getHarmRealData(String lineId,Integer target);
|
||||
|
||||
void getCldBaseRealData(String lineId);
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ 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;
|
||||
@@ -41,7 +40,9 @@ import com.njcn.influx.pojo.dto.EventDataSetDTO;
|
||||
import com.njcn.influx.service.EvtDataService;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import com.njcn.minioss.config.MinIossProperties;
|
||||
import com.njcn.minioss.util.MinIoUtils;
|
||||
import com.njcn.oss.constant.GeneralConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.EleEvtFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
@@ -61,6 +62,7 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.net.URLEncoder;
|
||||
@@ -95,6 +97,7 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
private final WavePicComponent wavePicComponent;
|
||||
private final MinIossProperties minIossProperties;
|
||||
private final InfluxDbUtils influxDbUtils;
|
||||
private final MinIoUtils minIoUtils;
|
||||
|
||||
@Override
|
||||
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
|
||||
@@ -291,18 +294,13 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, records);
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.isNotBlank(param.getWavePathCfg()) && StrUtil.isNotBlank(param.getWavePathDat())) {
|
||||
if (StrUtil.isNotBlank(param.getWavePath())) {
|
||||
//更新文件信息
|
||||
//先校验两份文件的名称是否一致
|
||||
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)
|
||||
.set(CsEventPO::getWavePath,param.getWavePath())
|
||||
.update();
|
||||
}
|
||||
}
|
||||
@@ -351,6 +349,16 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
|
||||
throw new BusinessException(WaveFileResponseEnum.ANALYSE_WAVE_NOT_FOUND);
|
||||
}
|
||||
String cfgPath = waveName.concat(GeneralConstant.CFG), datPath = waveName.concat(GeneralConstant.DAT);
|
||||
//不同设备,波形文件后缀大小写不一致,针对大小写判断文件是否存在
|
||||
boolean result1 = minIoUtils.checkFileIsExist(minIossProperties.getBucket(), cfgPath);
|
||||
if (!result1) {
|
||||
cfgPath = waveName.concat(GeneralConstant.CFG_LOWER);
|
||||
}
|
||||
boolean result2 = minIoUtils.checkFileIsExist(minIossProperties.getBucket(), datPath);
|
||||
if (!result2) {
|
||||
datPath = waveName.concat(GeneralConstant.DAT_LOWER);
|
||||
}
|
||||
|
||||
System.out.println("波形路径-------------------" + cfgPath);
|
||||
try (
|
||||
InputStream cfgStream = fileStorageUtil.getFileStream(cfgPath);
|
||||
|
||||
@@ -1,19 +1,26 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.csp.sentinel.util.StringUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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.api.NodeFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.po.Node;
|
||||
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.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import com.njcn.csharmonic.service.CsEventUserPOService;
|
||||
@@ -25,6 +32,7 @@ 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.pojo.param.BaseParam;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -33,6 +41,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -53,6 +62,7 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
private final EleEvtFeignClient eleEvtFeignClient;
|
||||
private final CsEventPOMapper csEventPOMapper;
|
||||
private final NodeFeignClient nodeFeignClient;
|
||||
|
||||
@Override
|
||||
public Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam) {
|
||||
@@ -504,4 +514,36 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
return returnpage;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<CsEventPO> getFrontWarnInfo(BaseParam baseParam) {
|
||||
Page<CsEventPO> page = new Page<>(baseParam.getPageNum(), baseParam.getPageSize());
|
||||
List<Node> nodeList = nodeFeignClient.nodeAllList().getData();
|
||||
Map<String, Node> nodeMap = nodeList.stream().collect(Collectors.toMap(Node::getId, Function.identity()));
|
||||
|
||||
if (CollectionUtil.isNotEmpty(nodeList)) {
|
||||
if (ObjectUtil.isNotNull(baseParam.getSearchValue()) || StringUtil.isNotBlank(baseParam.getSearchValue())) {
|
||||
nodeList = nodeList.stream().filter(item-> item.getName().contains(baseParam.getSearchValue()) || item.getIp().contains(baseParam.getSearchValue())).collect(Collectors.toList());
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(nodeList)) {
|
||||
List<String> nodeIds = nodeList.stream().map(Node::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<CsEventPO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(CsEventPO::getDeviceId, nodeIds)
|
||||
.between(CsEventPO::getStartTime,
|
||||
DateUtil.beginOfDay(DateUtil.parse(baseParam.getSearchBeginTime())).toString(),
|
||||
DateUtil.endOfDay(DateUtil.parse(baseParam.getSearchEndTime())).toString())
|
||||
.eq(CsEventPO::getType, 4)
|
||||
.orderByDesc(CsEventPO::getStartTime);
|
||||
page = csEventPOMapper.selectPage(page, queryWrapper);
|
||||
}
|
||||
}
|
||||
List<CsEventPO> records = page.getRecords();
|
||||
if (CollUtil.isNotEmpty(records)) {
|
||||
page.getRecords().forEach(item->{
|
||||
//这边将前置名称放进lineId字段;将前置IP放进wavePath字段;进程号使用clDid
|
||||
item.setLineId(nodeMap.get(item.getDeviceId()).getName());
|
||||
item.setWavePath(nodeMap.get(item.getDeviceId()).getIp());
|
||||
});
|
||||
}
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.google.common.reflect.TypeToken;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
@@ -21,7 +22,9 @@ import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import dm.jdbc.util.StringUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
@@ -109,20 +112,20 @@ public class LineTargetServiceImpl implements ILineTargetService {
|
||||
String path = csPagePOService.queryById(id).getPath();
|
||||
InputStream inputStream = fileStorageUtil.getFileStream(path);
|
||||
ZuTaiDTO zuTaiDto = analysisJson(inputStream);
|
||||
zuTaiDto.getDoneJson().forEach(item->{
|
||||
if (!Objects.isNull(item.getTarget())){
|
||||
zuTaiDto.getJson().forEach(item->{
|
||||
if (!Objects.isNull(item.getTarget()) && StringUtils.isNotBlank(item.getTarget())){
|
||||
String targetTag = item.getTarget().split("\\$")[0];
|
||||
String phasic = item.getTarget().split("\\$")[1];
|
||||
String dataType = item.getTarget().split("\\$")[2];
|
||||
if (CollectionUtils.isEmpty(item.getUId()) || CollectionUtils.isEmpty(item.getLineId())){
|
||||
if (CollectionUtils.isEmpty(item.getUId()) || ObjectUtil.isNull(item.getLineId())){
|
||||
throw new BusinessException(CsHarmonicResponseEnum.BIND_TARGET_ERROR);
|
||||
}
|
||||
CsDataArray dataArray = dataArrayFeignClient.getDataArrayById(item.getUId().get(0),targetTag).getData().get(0);
|
||||
String targetName = dataArray.getAnotherName();
|
||||
String dataId = dataArray.getDataId();
|
||||
String classId = epdFeignClient.selectById(dataId).getData().getClassId();
|
||||
String clDid = influxDbParamUtil.getClDidByLineId(item.getLineId().get(3));
|
||||
result.add(getLineRtData(item.getId(),item.getLineId().get(3),classId,targetTag,phasic,dataType,targetName,clDid));
|
||||
String clDid = influxDbParamUtil.getClDidByLineId(item.getLineId());
|
||||
result.add(getLineRtData(item.getId(),item.getLineId(),influxDbParamUtil.getTableNameByClassId(classId),targetTag,phasic,dataType,targetName,clDid));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
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;
|
||||
@@ -10,7 +9,6 @@ import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
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.system.api.DictTreeFeignClient;
|
||||
@@ -50,36 +48,47 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
//判断设备类型 治理无线设备需要判断mqtt、云前置设备直接判断设备运行状态
|
||||
CsEquipmentDeliveryPO dev = equipmentFeignClient.getDevByLineId(lineId).getData();
|
||||
String devModelCode = dictTreeFeignClient.queryById(dev.getDevType()).getData().getCode();
|
||||
// if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
// if (dev.getRunStatus() == 1) {
|
||||
// throw new BusinessException("装置离线");
|
||||
// }
|
||||
// } else {
|
||||
// String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
||||
// boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
// if (!mqttClient) {
|
||||
// throw new BusinessException("装置离线");
|
||||
// }
|
||||
// }
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (dev.getRunStatus() == 1) {
|
||||
throw new BusinessException("装置离线");
|
||||
}
|
||||
} else {
|
||||
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
if (!mqttClient) {
|
||||
throw new BusinessException("装置离线");
|
||||
}
|
||||
}
|
||||
Integer clDid = Integer.parseInt(lineId.substring(lineId.length() - 1));
|
||||
//获取装置所用模板
|
||||
CsLinePO po = csLineFeignClient.getById(lineId).getData();
|
||||
String modelId = po.getDataModelId();
|
||||
CsDataSet csDataSet = dataSetFeignClient.getBaseDataSet(modelId,clDid).getData();
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
askDeviceDataFeignClient.askCldRealData(dev.getId(),lineId,dev.getNodeId());
|
||||
CsDataSet csDataSet = dataSetFeignClient.getBaseDataSet(modelId,1).getData();
|
||||
askDeviceDataFeignClient.askCldRealData(dev.getId(),lineId,dev.getNodeId(),csDataSet.getIdx());
|
||||
updateRedisUserSet("rtDataUserId:" + lineId, RequestUtil.getUserIndex(), 600L);
|
||||
updateRedisUserSet("cldRtDataOverTime:" + lineId, RequestUtil.getUserIndex(), 5L);
|
||||
} else {
|
||||
CsDataSet csDataSet = dataSetFeignClient.getBaseDataSet(modelId,clDid).getData();
|
||||
askDeviceDataFeignClient.askRealData(nDid,csDataSet.getIdx(),clDid);
|
||||
redisUtil.saveByKeyWithExpire("rtDataUserId:"+lineId, RequestUtil.getUserIndex(),600L);
|
||||
}
|
||||
//等待装置响应,获取询问结果
|
||||
Thread.sleep(2000);
|
||||
Object object = redisUtil.getObjectByKey("devResponse");
|
||||
Object object;
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
object = redisUtil.getObjectByKey("devResponse:" + lineId);
|
||||
} else {
|
||||
object = redisUtil.getObjectByKey("devResponse");
|
||||
}
|
||||
if (Objects.isNull(object)) {
|
||||
result = false;
|
||||
//throw new BusinessException("数据获取失败,设备无响应");
|
||||
} else {
|
||||
int code = (Integer) object;
|
||||
if (code != 200) {
|
||||
result = false;
|
||||
//throw new BusinessException("数据获取失败,设备无响应");
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
@@ -93,21 +102,40 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
boolean result = true;
|
||||
try {
|
||||
String nDid = lineId.substring(0, lineId.length() - 1);
|
||||
//判断设备类型 治理无线设备需要判断mqtt、云前置设备直接判断设备运行状态
|
||||
CsEquipmentDeliveryPO dev = equipmentFeignClient.getDevByLineId(lineId).getData();
|
||||
String devModelCode = dictTreeFeignClient.queryById(dev.getDevType()).getData().getCode();
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
if (dev.getRunStatus() == 1) {
|
||||
throw new BusinessException("装置离线");
|
||||
}
|
||||
} else {
|
||||
String clientName = "NJCN-" + nDid.substring(nDid.length() - 6);
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
if (!mqttClient) {
|
||||
throw new BusinessException("装置离线");
|
||||
}
|
||||
}
|
||||
Integer clDid = Integer.parseInt(lineId.substring(lineId.length() - 1));
|
||||
//获取装置所用模板
|
||||
CsLinePO po = csLineFeignClient.getById(lineId).getData();
|
||||
String modelId = po.getDataModelId();
|
||||
//根据指标来获取不同的数据集
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
CsDataSet csDataSet = dataSetFeignClient.getHarmonicDataSet(modelId,1,target).getData();
|
||||
askDeviceDataFeignClient.askCldRealData(dev.getId(),lineId,dev.getNodeId(),csDataSet.getIdx());
|
||||
} else {
|
||||
CsDataSet csDataSet = dataSetFeignClient.getHarmonicDataSet(modelId,clDid,target).getData();
|
||||
askDeviceDataFeignClient.askRealData(nDid,csDataSet.getIdx(),clDid);
|
||||
}
|
||||
//等待装置响应,获取询问结果
|
||||
Thread.sleep(2000);
|
||||
Object object = redisUtil.getObjectByKey("devResponse");
|
||||
Object object;
|
||||
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
|
||||
object = redisUtil.getObjectByKey("devResponse:" + lineId);
|
||||
} else {
|
||||
object = redisUtil.getObjectByKey("devResponse");
|
||||
}
|
||||
if (Objects.isNull(object)) {
|
||||
result = false;
|
||||
} else {
|
||||
@@ -122,36 +150,6 @@ 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,csEquipmentDeliveryVO.getNodeId());
|
||||
// 更新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中的用户集合
|
||||
*/
|
||||
@@ -191,46 +189,4 @@ public class RealDataServiceImpl implements RealDataService {
|
||||
}
|
||||
}
|
||||
|
||||
// @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<String> 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<String> users2;
|
||||
// if (Objects.isNull(object2)) {
|
||||
// users2 = new HashSet<>();
|
||||
// } else {
|
||||
// users2 = convertObjectToSet(object2);
|
||||
// }
|
||||
// users2.add(RequestUtil.getUserIndex());
|
||||
// redisUtil.saveByKeyWithExpire("cldRtDataOverTime:"+lineId, users2,5L);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// public Set<String> convertObjectToSet(Object obj) {
|
||||
// if (obj instanceof Collection) {
|
||||
// return ((Collection<?>) obj).stream()
|
||||
// .filter(Objects::nonNull)
|
||||
// .map(Object::toString)
|
||||
// .collect(Collectors.toSet());
|
||||
// }
|
||||
// return Collections.emptySet();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
36
pom.xml
36
pom.xml
@@ -19,17 +19,38 @@
|
||||
<description>治理项目</description>
|
||||
<packaging>pom</packaging>
|
||||
<properties>
|
||||
<middle.server.url>192.168.1.22</middle.server.url>
|
||||
<service.server.url>127.0.0.1</service.server.url>
|
||||
<docker.server.url>192.168.1.22</docker.server.url>
|
||||
|
||||
<!-- <middle.server.url>192.168.1.22</middle.server.url>-->
|
||||
<!-- <service.server.url>192.168.1.126</service.server.url>-->
|
||||
<!-- <docker.server.url>192.168.1.22</docker.server.url>-->
|
||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||
<!-- <nacos.namespace>b0b0dedf-baa9-407f-bef6-988b9e0a640d</nacos.namespace>-->
|
||||
|
||||
<middle.server.url>192.168.1.103</middle.server.url>
|
||||
<service.server.url>192.168.1.126</service.server.url>
|
||||
<docker.server.url>192.168.1.103</docker.server.url>
|
||||
<nacos.url>${middle.server.url}:18848</nacos.url>
|
||||
<nacos.namespace>415a1c87-33aa-47bd-8e25-13cc456c87ed</nacos.namespace>
|
||||
<nacos.namespace>72972c43-3c20-4452-a261-66624e17da97</nacos.namespace>
|
||||
|
||||
<!-- <middle.server.url>192.168.1.103</middle.server.url>-->
|
||||
<!-- <service.server.url>192.168.1.103</service.server.url>-->
|
||||
<!-- <docker.server.url>192.168.1.103</docker.server.url>-->
|
||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||
<!-- <nacos.namespace></nacos.namespace>-->
|
||||
|
||||
<!--102-->
|
||||
<!-- <middle.server.url>192.168.1.102</middle.server.url>-->
|
||||
<!-- <service.server.url>127.0.0.1</service.server.url>-->
|
||||
<!-- <docker.server.url>192.168.1.102</docker.server.url>-->
|
||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||
<!-- <nacos.namespace>d99572a5-415e-480b-bb92-30f05c2f6d93</nacos.namespace>-->
|
||||
|
||||
<!-- <middle.server.url>192.168.1.102</middle.server.url>-->
|
||||
<!-- <service.server.url>192.168.1.102</service.server.url>-->
|
||||
<!-- <docker.server.url>192.168.1.102</docker.server.url>-->
|
||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||
<!-- <nacos.namespace>c208a65e-1578-4372-b7c0-97fecd323fe6</nacos.namespace>-->
|
||||
|
||||
<!--27-->
|
||||
<!-- <middle.server.url>192.168.1.27</middle.server.url>-->
|
||||
<!-- <service.server.url>127.0.0.1</service.server.url>-->
|
||||
@@ -42,6 +63,13 @@
|
||||
<!-- <docker.server.url>192.168.1.22</docker.server.url>-->
|
||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||
<!-- <nacos.namespace></nacos.namespace>-->
|
||||
|
||||
<!-- <middle.server.url>192.168.4.151</middle.server.url>-->
|
||||
<!-- <service.server.url>192.168.4.151</service.server.url>-->
|
||||
<!-- <docker.server.url>192.168.4.151</docker.server.url>-->
|
||||
<!-- <nacos.url>${middle.server.url}:18848</nacos.url>-->
|
||||
<!-- <nacos.namespace>3b3dbb4a-bd15-4a01-a6ef-7f179583ddfc</nacos.namespace>-->
|
||||
|
||||
<!--sentinel:port-->
|
||||
<sentinel.url>${middle.server.url}:8080</sentinel.url>
|
||||
<!--网关地址,主要用于配置swagger中认证token-->
|
||||
|
||||
Reference in New Issue
Block a user