8 Commits

Author SHA1 Message Date
xy
b7574b2916 云前置功能调整 2025-11-04 14:08:59 +08:00
xy
43bdcbf623 微调 2025-10-28 13:35:37 +08:00
xy
629ba0746a 云前置改造-补召功能调整 2025-10-23 09:41:05 +08:00
xy
b86c81d70a 云前置改造-新增补召功能 2025-10-22 15:04:46 +08:00
xy
d10240758b 云前置改造-微调 2025-10-20 09:30:13 +08:00
xy
995bd8b310 云前置改造-前置功能优化 2025-10-17 10:49:15 +08:00
xy
9531e18e93 云前置改造-暂态数据补召功能 2025-10-15 20:50:04 +08:00
xy
753a22eb4c 云前置改造-台账更新功能 2025-10-14 13:24:56 +08:00
42 changed files with 1153 additions and 101 deletions

View File

@@ -1,18 +1,13 @@
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.CsLedgerFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.param.CsLedgerParam;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;

View File

@@ -3,9 +3,12 @@ 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 com.njcn.csdevice.param.IcdBzReplyParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author xy
@@ -15,6 +18,13 @@ import org.springframework.web.bind.annotation.RequestParam;
public interface CsTerminalReplyFeignClient {
@PostMapping("/updateData")
HttpResult<String> updateData(@RequestParam("id") String id,@RequestParam("state") Integer state,@RequestParam("deviceId") String deviceId);
@ApiOperation("更新推送结果")
HttpResult<String> updateData(@RequestBody @Validated IcdBzReplyParam param);
@PostMapping("/updateBzData")
@ApiOperation("更新补召推送结果")
HttpResult<String> updateBzData(@RequestBody @Validated IcdBzReplyParam param);
}

View File

@@ -0,0 +1,29 @@
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 com.njcn.csdevice.api.fallback.IcdFallbackFactory;
import com.njcn.csdevice.param.IcdBzParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/icd", fallbackFactory = IcdFallbackFactory.class,contextId = "icd")
public interface IcdFeignClient {
@PostMapping("/bzEvent")
@ApiOperation("补召事件")
HttpResult<String> bzEvent(@RequestBody @Validated IcdBzParam param);
@PostMapping("/bzFile")
@ApiOperation("补召波形")
HttpResult<String> bzFile(@RequestBody @Validated IcdBzParam param);
}

View File

@@ -4,6 +4,7 @@ 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 com.njcn.csdevice.param.IcdBzReplyParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
@@ -23,9 +24,16 @@ public class CsTerminalReplyClientFallbackFactory implements FallbackFactory<CsT
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsTerminalReplyFeignClient() {
@Override
public HttpResult<String> updateData(String id, Integer state, String deviceId) {
log.error("{}异常,降级处理,异常为:{}","更新推送结果",cause.toString());
public HttpResult<String> updateData(IcdBzReplyParam param) {
log.error("{}异常,降级处理,异常为:{}","更新推送结果异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> updateBzData(IcdBzReplyParam param) {
log.error("{}异常,降级处理,异常为:{}","更新补召推送结果异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};

View File

@@ -0,0 +1,40 @@
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.IcdFeignClient;
import com.njcn.csdevice.param.IcdBzParam;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
/**
* @author xy
*/
@Slf4j
@Component
public class IcdFallbackFactory implements FallbackFactory<IcdFeignClient> {
@Override
public IcdFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new IcdFeignClient() {
@Override
public HttpResult<String> bzEvent(IcdBzParam param) {
log.error("{}异常,降级处理,异常为:{}","定时补召事件异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<String> bzFile(IcdBzParam param) {
log.error("{}异常,降级处理,异常为:{}","定时补召波形异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -58,7 +58,7 @@ public interface DataParam {
String GOVERNANCE_SYSTEM = "治理系统";
String cldDev = "云前置设备";
String cldDev = "在线设备";
String EvtParamPhase = "Evt_Param_Phase";

View File

@@ -0,0 +1,24 @@
package com.njcn.csdevice.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* @author xy
*/
@Data
public class IcdBzParam implements Serializable {
@ApiModelProperty("监测点集合")
private List<String> lineList;
@ApiModelProperty("开始时间")
private String startTime;
@ApiModelProperty("结束时间")
private String endTime;
}

View File

@@ -0,0 +1,31 @@
package com.njcn.csdevice.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class IcdBzReplyParam implements Serializable {
@ApiModelProperty("guid")
private String id;
@ApiModelProperty("状态")
private Integer state;
@ApiModelProperty("设备id")
private String deviceId;
@ApiModelProperty("监测点id")
private String lineId;
@ApiModelProperty("响应码")
private Integer code;
@ApiModelProperty("响应消息")
private String msg;
}

View File

@@ -0,0 +1,22 @@
package com.njcn.csdevice.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class IcdNodeParam implements Serializable {
@ApiModelProperty("设备id")
private String id;
@ApiModelProperty("前置服务器id")
private String nodeId;
@ApiModelProperty("进程号")
private Integer processNo;
}

View File

@@ -5,6 +5,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import javax.validation.constraints.Min;
/**
*
* Description:
@@ -53,21 +55,25 @@ public class CsLineParam extends BaseEntity {
/**
* PT一次变比
*/
@Min(value = 1, message = "PT一次变比必须大于等于1")
private Double ptRatio;
/**
* PT二次变比
*/
@Min(value = 1, message = "PT二次变比必须大于等于1")
private Double pt2Ratio;
/**
* CT一次变比
*/
@Min(value = 1, message = "CT一次变比必须大于等于1")
private Double ctRatio;
/**
* CT二次变比
*/
@Min(value = 1, message = "CT二次变比必须大于等于1")
private Double ct2Ratio;
/**

View File

@@ -4,8 +4,6 @@ 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;
@@ -34,6 +32,16 @@ public class CsTerminalLogs extends BaseEntity implements Serializable {
*/
private String deviceId;
/**
* 设备名称
*/
private String deviceName;
/**
* 监测点id
*/
private String lineId;
/**
* 前置服务器id
*/

View File

@@ -48,14 +48,34 @@ public class CsTerminalReply extends BaseEntity implements Serializable {
private Integer processNo;
/**
* 设备id集合
* 设备id
*/
private String deviceId;
/**
* 设备名称
*/
private String deviceName;
/**
* 监测点id
*/
private String lineId;
/**
* 是否收到0未收到 1收到
*/
private Integer isReceived;
/**
* 接收消息状态码
*/
private Integer receivedCode;
/**
* 接收消息描述
*/
private String receivedMsg;
}

View File

@@ -0,0 +1,42 @@
package com.njcn.csdevice.pojo.vo;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author xy
* 日志信息
*/
@Data
public class CldLogsVo implements Serializable {
@ApiModelProperty("工程名称")
private String engineeringName;
@ApiModelProperty("项目名称")
private String projectName;
@ApiModelProperty("设备名称")
private String deviceName;
@ApiModelProperty("监测点名称")
private String lineName;
@ApiModelProperty("补召类型")
private String log;
@ApiModelProperty("补召时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime logTime;
@ApiModelProperty("状态")
private String status;
@ApiModelProperty("结果")
private String result;
}

View File

@@ -2,6 +2,7 @@ package com.njcn.csdevice.controller.equipment;
import cn.afterturn.easypoi.excel.ExcelExportUtil;
import cn.afterturn.easypoi.excel.entity.ExportParams;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
@@ -152,6 +153,9 @@ public class EquipmentDeliveryController extends BaseController {
@ApiImplicitParam(name = "ids", value = "设备id集合", required = true)
public HttpResult<List<CsEquipmentDeliveryDTO>> queryEquipmentById(@RequestParam List<String> ids){
String methodDescribe = getMethodDescribe("queryEquipmentById");
if (CollectionUtil.isEmpty(ids)) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(ids);
List<CsEquipmentDeliveryDTO> collect = csEquipmentDeliveryPOS.stream().map(temp -> {
CsEquipmentDeliveryDTO csEquipmentDeliveryDTO = new CsEquipmentDeliveryDTO();

View File

@@ -1,23 +1,26 @@
package com.njcn.csdevice.controller.icd;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.param.IcdBzParam;
import com.njcn.csdevice.param.IcdBzReplyParam;
import com.njcn.csdevice.pojo.vo.CldLogsVo;
import com.njcn.csdevice.service.ICsTerminalReplyService;
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.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 org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.util.List;
@@ -51,14 +54,30 @@ public class CsTerminalReplyController extends BaseController {
@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){
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> updateData(@RequestBody @Validated IcdBzReplyParam param){
String methodDescribe = getMethodDescribe("updateData");
csTerminalReplyService.updateReplyData(id,state,deviceId);
csTerminalReplyService.updateReplyData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzLogs")
@ApiOperation("补召日志")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<Page<CldLogsVo>> bzLogs(@RequestBody @Validated BaseParam param){
String methodDescribe = getMethodDescribe("bzLogs");
Page<CldLogsVo> list = csTerminalReplyService.getBzLogs(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateBzData")
@ApiOperation("更新补召推送结果")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> updateBzData(@RequestBody @Validated IcdBzReplyParam param){
String methodDescribe = getMethodDescribe("updateBzData");
csTerminalReplyService.updateBzData(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}

View File

@@ -5,12 +5,12 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.param.IcdBzParam;
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.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;
@@ -66,12 +66,32 @@ public class IcdController extends BaseController {
}
@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);
@PostMapping("/bzFileByEventId")
@ApiOperation("指定事件补召波形")
@ApiImplicitParam(name = "eventId", value = "事件id", required = true)
public HttpResult<String> bzFileByEventId(@RequestParam String eventId){
String methodDescribe = getMethodDescribe("bzFileByEventId");
icdService.bzFileByEventId(eventId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzEvent")
@ApiOperation("补召事件")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> bzEvent(@RequestBody @Validated IcdBzParam param){
String methodDescribe = getMethodDescribe("bzEvent");
icdService.bzEvent(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/bzFile")
@ApiOperation("补召波形")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> bzFile(@RequestBody @Validated IcdBzParam param){
String methodDescribe = getMethodDescribe("bzFile");
icdService.bzFile(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}

View File

@@ -8,6 +8,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.param.IcdNodeParam;
import com.njcn.csdevice.pojo.param.NodeParam;
import com.njcn.csdevice.pojo.po.Node;
import com.njcn.csdevice.pojo.vo.NodeProcessDeviceVo;
@@ -174,5 +175,41 @@ public class NodeController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/restartProcess")
@ApiOperation("重启前置机进程")
@ApiImplicitParams({
@ApiImplicitParam(name = "nodeId", value = "前置服务器id", required = true),
@ApiImplicitParam(name = "processNo", value = "进程号", required = true)
})
public HttpResult<String> restartProcess(@RequestParam String nodeId,@RequestParam Integer processNo){
String methodDescribe = getMethodDescribe("restartProcess");
iNodeService.restartProcess(nodeId,processNo);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateDevProcessNo")
@ApiOperation("更新设备进程号")
@ApiImplicitParams({
@ApiImplicitParam(name = "id", value = "设备id", required = true),
@ApiImplicitParam(name = "processNo", value = "进程号", required = true)
})
public HttpResult<String> updateDevProcessNo(@RequestParam String id,@RequestParam Integer processNo){
String methodDescribe = getMethodDescribe("updateDevProcessNo");
String result = iNodeService.updateDevProcessNo(id,processNo);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/updateDevNode")
@ApiOperation("更新设备前置信息")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<String> updateDevNode(@RequestBody IcdNodeParam param){
String methodDescribe = getMethodDescribe("updateDevNode");
String result = iNodeService.updateDevNode(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -1,7 +1,11 @@
package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.csdevice.pojo.po.CsTerminalReply;
import com.njcn.user.pojo.vo.RoleVO;
import org.apache.ibatis.annotations.Param;
/**
* <p>
@@ -13,4 +17,6 @@ import com.njcn.csdevice.pojo.po.CsTerminalReply;
*/
public interface CsTerminalReplyMapper extends BaseMapper<CsTerminalReply> {
Page<CsTerminalReply> page(@Param("page")Page<RoleVO> page, @Param("ew") QueryWrapper<CsTerminalReply> queryWrapper);
}

View File

@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.njcn.csdevice.mapper.CsTerminalReplyMapper">
<!--获取角色分页列表-->
<select id="page" resultType="CsTerminalReply">
select
cs_terminal_reply.*
from
cs_terminal_reply
WHERE ${ew.sqlSegment}
</select>
</mapper>

View File

@@ -130,6 +130,12 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
*/
List<CsEquipmentDeliveryPO> getAll();
/**
* 获取所有装置信息(投运且在线)
* @return
*/
List<CsEquipmentDeliveryPO> getAllOnline();
/**
* 判断设备型号
*/
@@ -185,4 +191,6 @@ public interface CsEquipmentDeliveryService extends IService<CsEquipmentDelivery
List<CsEquipmentDeliveryPO> getDataByNodeIdAndProcessNo(String nodeId, Integer processNo);
List<CsEquipmentDeliveryPO> getListByIds(List<String> devList);
}

View File

@@ -63,4 +63,11 @@ public interface CsLinePOService extends IService<CsLinePO>{
void updateCldLineStatus(List<CsLinePO> lineList, Integer status);
void updateLineDataByList(List<String> list, String id, String setId);
/**
* 根据名称获取监测点
* @param lineName
* @return
*/
List<CsLinePO> getLineByName(String lineName);
}

View File

@@ -1,7 +1,13 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.param.IcdBzParam;
import com.njcn.csdevice.param.IcdBzReplyParam;
import com.njcn.csdevice.pojo.po.CsTerminalReply;
import com.njcn.csdevice.pojo.vo.CldLogsVo;
import com.njcn.web.pojo.param.BaseParam;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -17,6 +23,12 @@ public interface ICsTerminalReplyService extends IService<CsTerminalReply> {
List<String> queryReplyData();
void updateReplyData(String id,Integer state,String deviceId);
void updateReplyData(IcdBzReplyParam param);
List<CsTerminalReply> getBzReplyData(String lineId);
Page<CldLogsVo> getBzLogs(BaseParam param);
void updateBzData(IcdBzReplyParam param);
}

View File

@@ -3,9 +3,11 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.param.IcdNodeParam;
import com.njcn.csdevice.pojo.param.NodeParam;
import com.njcn.csdevice.pojo.po.Node;
import com.njcn.csdevice.pojo.vo.NodeProcessDeviceVo;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
@@ -79,4 +81,10 @@ public interface INodeService extends IService<Node> {
Node getNodeByIp(String ip);
NodeProcessDeviceVo getProcessNoAndDeviceById(String id);
void restartProcess(String nodeId, Integer processNo);
String updateDevProcessNo(String id, Integer processNo);
String updateDevNode(IcdNodeParam param);
}

View File

@@ -1,10 +1,10 @@
package com.njcn.csdevice.service;
import com.njcn.csdevice.param.IcdBzParam;
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;
@@ -16,6 +16,10 @@ public interface IcdService {
CldLedgerVo getLedgerById(String id);
void restartProcess(CldControlMessage message);
void bzFileByEventId(String eventId);
void bzEvent(IcdBzParam param);
void bzFile(IcdBzParam param);
}

View File

@@ -428,6 +428,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
if (isCLdDevice) {
// 云前置数据集
addDataSet(dataSetList, item, "实时数据", "realtimedata");
addDataSet(dataSetList, item, "暂态事件", "event");
}
deviceManagerVo.setDataLevel(item.getDataLevel());
}
@@ -706,6 +707,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return this.lambdaQuery().ne(CsEquipmentDeliveryPO::getRunStatus,0).list();
}
@Override
public List<CsEquipmentDeliveryPO> getAllOnline() {
return this.lambdaQuery()
.ne(CsEquipmentDeliveryPO::getRunStatus,0)
.eq(CsEquipmentDeliveryPO::getUsageStatus,1)
.isNotNull(CsEquipmentDeliveryPO::getNodeId)
.list();
}
@Override
public boolean judgeDevModel(String nDid) {
boolean result = false;
@@ -816,23 +826,24 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csTerminalLogs.setIsPush(0);
csTerminalLogs.setNodeId(one.getNodeId());
csTerminalLogs.setNodeProcess(one.getNodeProcess());
csTerminalLogs.setDeviceName(one.getName());
csTerminalLogsMapper.insert(csTerminalLogs);
return true;
}
@Override
public Boolean updateCldDev(CsEquipmentDeliveryAuditParm param) {
//云前置设备判断,修改云前置判断设备是否达到上限
if(ObjectUtil.isNotNull(param.getNodeId())){
Node node = nodeService.getNodeById(param.getNodeId());
List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
}
//自动分配进程号
int process = findLeastFrequentProcess(devList,node.getMaxProcessNum());
param.setNodeProcess(process);
}
// //云前置设备判断,修改云前置判断设备是否达到上限
// if(ObjectUtil.isNotNull(param.getNodeId())){
// Node node = nodeService.getNodeById(param.getNodeId());
// List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
// if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
// throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
// }
// //自动分配进程号
// int process = findLeastFrequentProcess(devList,node.getMaxProcessNum());
// param.setNodeProcess(process);
// }
StringUtil.containsSpecialCharacters(param.getNdid());
boolean result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
@@ -969,6 +980,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return this.list(lambdaQueryWrapper);
}
@Override
public List<CsEquipmentDeliveryPO> getListByIds(List<String> devList) {
return this.lambdaQuery().in(CsEquipmentDeliveryPO::getId,devList).list();
}
//根据前置机id获取装置数量
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();

View File

@@ -7,11 +7,9 @@ import cn.hutool.core.util.IdUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.constant.DataParam;
import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.*;
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.param.CsLedgerParam;
@@ -54,7 +52,6 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
private final CsDevModelRelationService csDevModelRelationService;
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final ICsDataSetService csDataSetService;
private final EquipmentFeignClient equipmentFeignClient;
private final DictTreeFeignClient dictTreeFeignClient;
@Override
@@ -82,14 +79,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
//区分治理装置和云前置装置
List<String> zhiLianDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>();
List<CsEquipmentDeliveryDTO> csEquipmentDeliveryPOS = equipmentFeignClient.queryDeviceById(device).getData();
if (CollectionUtil.isNotEmpty(csEquipmentDeliveryPOS)) {
if (CollectionUtil.isNotEmpty(device)) {
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectBatchIds(device);
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
Optional.ofNullable(vo1)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.map(CsEquipmentDeliveryPO::getId)
.forEach(cldDevice::add)
);
DictTreeVO vo2 = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
@@ -97,11 +94,10 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.map(CsEquipmentDeliveryPO::getId)
.forEach(zhiLianDevice::add)
);
}
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
@@ -287,14 +283,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
List<String> zhiLianDevice = new ArrayList<>();
List<String> cldDevice = new ArrayList<>();
List<CsEquipmentDeliveryDTO> csEquipmentDeliveryPOS = equipmentFeignClient.queryDeviceById(device).getData();
if (CollectionUtil.isNotEmpty(csEquipmentDeliveryPOS)) {
if (CollectionUtil.isNotEmpty(device)) {
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryMapper.selectBatchIds(device);
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
Optional.ofNullable(vo1)
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.map(CsEquipmentDeliveryPO::getId)
.forEach(cldDevice::add)
);
DictTreeVO vo2 = dictTreeFeignClient.queryByCode(DicDataEnum.CONNECT_DEV.getCode()).getData();
@@ -302,10 +298,11 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
.map(DictTreeVO::getId)
.ifPresent(id -> csEquipmentDeliveryPOS.stream()
.filter(item -> Objects.equals(item.getDevType(), id))
.map(CsEquipmentDeliveryDTO::getId)
.map(CsEquipmentDeliveryPO::getId)
.forEach(zhiLianDevice::add)
);
}
engineeringList = allList.stream().filter(item->roleengineer.contains(item.getId())).collect(Collectors.toList());
List<CsLedgerVO> projectList = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
@@ -674,6 +671,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
Set<String> list1 = new HashSet<>();
List<String> devList = tree3.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devList);
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
DictTreeVO vo1 = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
//list1是 cld设备
@@ -688,14 +686,30 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
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());
deviceTree = tree3.stream()
.filter(vo -> list1.contains(vo.getId()))
.peek(item -> {
CsEquipmentDeliveryPO dev = devsMap.get(item.getId());
if (dev != null) {
item.setComFlag(dev.getRunStatus());
}
})
.collect(Collectors.toList());
lineTree = tree4.stream()
.filter(vo -> list1.contains(vo.getPid()))
.peek(item -> {
CsEquipmentDeliveryPO dev = devsMap.get(item.getId());
if (dev != null) {
item.setComFlag(dev.getRunStatus());
}
})
.collect(Collectors.toList());
}
}
}

View File

@@ -211,6 +211,11 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
this.update(updateWrapper);
}
@Override
public List<CsLinePO> getLineByName(String lineName) {
return this.lambdaQuery().like(CsLinePO::getName,lineName).list();
}
// /**
// * 1.平台端默认配置拓扑图模板,包含拓扑图信息(cs_topology_diagram_template)和拓扑图上监测点的点位信息(cs_line_topology_template)
// *

View File

@@ -146,8 +146,10 @@ public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper,
operateType = 0;
} else if (Objects.equals(code, "ledger_modify")) {
operateType = 1;
} else{
} else if (Objects.equals(code, "delete_terminal")){
operateType = 2;
} else {
operateType = 3;
}
//找出最新的数据,将状态改为未推送,下次可以再次推送
this.lambdaUpdate()
@@ -175,7 +177,7 @@ public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper,
List<CsEquipmentDeliveryPO> v1 = entry.getValue();
String guid = IdUtil.simpleUUID();
message.setGuid(guid);
message.setProcessNo(String.valueOf(k1));
message.setProcessNo(k1);
List<CldUpdateLedgerMessage.CldDeviceDto> list1 = new ArrayList<>();
v1.forEach(item -> {
CldUpdateLedgerMessage.CldDeviceDto deviceDto = new CldUpdateLedgerMessage.CldDeviceDto();
@@ -248,7 +250,7 @@ public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper,
nodeProcessMap1.forEach((k1,v1)->{
String guid = IdUtil.simpleUUID();
message.setGuid(guid);
message.setProcessNo(String.valueOf(k1));
message.setProcessNo(k1);
List<CldUpdateLedgerMessage.CldDeviceDto> list1 = new ArrayList<>();
v1.forEach(item->{
CldUpdateLedgerMessage.CldDeviceDto deviceDto = new CldUpdateLedgerMessage.CldDeviceDto();
@@ -267,6 +269,7 @@ public class CsTerminalLogsServiceImpl extends ServiceImpl<CsTerminalLogsMapper,
csFmTerminalReply.setNodeId(k);
csFmTerminalReply.setProcessNo(k1);
csFmTerminalReply.setDeviceId(item.getDeviceId());
csFmTerminalReply.setDeviceName(item.getDeviceName());
csFmTerminalReply.setIsReceived(0);
csTerminalReplyMapper.insert(csFmTerminalReply);
});

View File

@@ -1,23 +1,33 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.mapper.CsTerminalReplyMapper;
import com.njcn.csdevice.param.IcdBzReplyParam;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsTerminalReply;
import com.njcn.csdevice.pojo.vo.CldLogsVo;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
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.factory.PageFactory;
import com.njcn.web.pojo.param.BaseParam;
import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -37,6 +47,7 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
private final INodeService nodeService;
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final ICsTerminalLogsService csTerminalLogsService;
private final CsLedgerFeignClient csLedgerFeignClient;
@Override
public List<String> queryReplyData() {
@@ -58,25 +69,30 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
} else {
list.forEach(item->{
String key;
String code;
String code = "";
if (Objects.equals(item.getCode(), "add_terminal")) {
code = "新增";
} else if (Objects.equals(item.getCode(), "ledger_modify")) {
code = "修改";
} else {
} else if (Objects.equals(item.getCode(), "delete_terminal")){
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();
String devNameListString;
if (CollectionUtil.isNotEmpty(devNameList)) {
devNameListString = devNameList.toString();
} else {
devNameListString = "[" + item.getDeviceName() + "]";
}
if (item.getIsReceived() == 0) {
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + code + "数据失败";
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据失败";
//将cs_terminal_logs数据置为未发送
csTerminalLogsService.updateLaterData(item.getDeviceId(),item.getCode());
} else {
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + code + "数据成功";
key = nodeName + item.getProcessNo() + "号进程下," + devNameListString + "设备" + code + "数据成功";
}
result.add(key);
});
@@ -87,9 +103,137 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
}
@Override
public void updateReplyData(String id,Integer state,String deviceId) {
this.lambdaUpdate().set(CsTerminalReply::getIsReceived,state)
.eq(CsTerminalReply::getDeviceId,deviceId)
.eq(CsTerminalReply::getReplyId,id);
public void updateReplyData(IcdBzReplyParam param) {
LambdaUpdateWrapper<CsTerminalReply> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(CsTerminalReply::getIsReceived,param.getState())
.set(CsTerminalReply::getReceivedCode,param.getCode())
.set(CsTerminalReply::getReceivedMsg,param.getMsg())
.eq(CsTerminalReply::getReplyId,param.getId())
.eq(CsTerminalReply::getDeviceId,param.getDeviceId());
this.update(wrapper);
}
@Override
public List<CsTerminalReply> getBzReplyData(String lineId) {
LambdaQueryWrapper<CsTerminalReply> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CsTerminalReply::getCode,Arrays.asList("allFile","allEvent","oneFile"))
.orderByDesc(CsTerminalReply::getCreateTime);
if (!Objects.isNull(lineId) && StringUtils.isNotBlank(lineId)) {
wrapper.like(CsTerminalReply::getLineId,lineId);
}
return this.list(wrapper);
}
@Override
public Page<CldLogsVo> getBzLogs(BaseParam param) {
Page<CldLogsVo> page = new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param));
QueryWrapper<CsTerminalReply> queryWrapper = new QueryWrapper<>();
if (StrUtil.isNotBlank(param.getSearchValue())) {
queryWrapper.like("cs_terminal_reply.line_id", param.getSearchValue());
// //获取监测点id
// List<CsLinePO> list = csLinePOService.getLineByName(param.getSearchValue());
// if (CollectionUtil.isEmpty(list)) {
// return page;
// } else {
// queryWrapper.and(pr -> {
// // 获取所有 lineId
// List<String> lineIds = list.stream()
// .map(CsLinePO::getLineId)
// .collect(Collectors.toList());
// // 使用 OR 条件连接多个 lineId
// for (int i = 0; i < lineIds.size(); i++) {
// if (i == 0) {
// pr.like("cs_terminal_reply.line_id", lineIds.get(i));
// } else {
// pr.or().like("cs_terminal_reply.line_id", lineIds.get(i));
// }
// }
// });
// }
}
//排序
queryWrapper.orderBy(true, false, "cs_terminal_reply.create_time");
queryWrapper.in("cs_terminal_reply.code", Arrays.asList("allFile", "allEvent", "oneFile"));
Page<CsTerminalReply> csTerminalReplyPage = this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
List<CsTerminalReply> records = csTerminalReplyPage.getRecords();
if (CollectionUtil.isNotEmpty(records)) {
List<CsLedgerVO> data = csLedgerFeignClient.getAllLedger().getData();
Map<String, CsLedgerVO> ledgerMap = data.stream().collect(Collectors.toMap(CsLedgerVO::getId, Function.identity()));
List<CldLogsVo> cldLogsVos = new ArrayList<>();
records.forEach(item->{
String pids = ledgerMap.get(item.getDeviceId()).getPids();
String[] split = pids.split(",");
CldLogsVo cldLogsVo = new CldLogsVo();
cldLogsVo.setEngineeringName(ledgerMap.get(split[1]).getName());
cldLogsVo.setProjectName(ledgerMap.get(split[2]).getName());
cldLogsVo.setDeviceName(ledgerMap.get(item.getDeviceId()).getName());
// String lineId = item.getLineId();
// String[] lineSplit = lineId.split(",");
// String result;
// if (lineSplit.length == 1) {
// result = ledgerMap.get(lineSplit[0]).getName();
// } else {
// result = Arrays.stream(lineSplit)
// .map(ledgerMap::get)
// .filter(Objects::nonNull)
// .map(CsLedgerVO::getName)
// .collect(Collectors.joining(","));
// }
// cldLogsVo.setLineName(result);
cldLogsVo.setLineName(ledgerMap.get(param.getSearchValue()).getName());
cldLogsVo.setLog(getLogDescription(item.getCode()));
cldLogsVo.setLogTime(item.getCreateTime());
if (Objects.equals(item.getIsReceived(),0)) {
cldLogsVo.setStatus("补召已下发");
cldLogsVo.setResult("/");
} else {
if (item.getReceivedCode() == 200) {
cldLogsVo.setStatus("补召成功");
cldLogsVo.setResult(item.getReceivedMsg());
} else {
cldLogsVo.setStatus("补召失败");
cldLogsVo.setResult(item.getReceivedMsg());
}
}
cldLogsVos.add(cldLogsVo);
});
page.setRecords(cldLogsVos);
}
page.setTotal(csTerminalReplyPage.getTotal());
page.setPages(csTerminalReplyPage.getPages());
return page;
}
@Override
public void updateBzData(IcdBzReplyParam param) {
LambdaUpdateWrapper<CsTerminalReply> wrapper = new LambdaUpdateWrapper<>();
wrapper.set(CsTerminalReply::getIsReceived,param.getState())
.set(CsTerminalReply::getReceivedCode,param.getCode())
.set(CsTerminalReply::getReceivedMsg,param.getMsg())
.eq(CsTerminalReply::getReplyId,param.getId())
.eq(CsTerminalReply::getDeviceId,param.getDeviceId());
if (Objects.nonNull(param.getLineId()) && StringUtils.isNotBlank(param.getLineId())) {
wrapper.eq(CsTerminalReply::getLineId,param.getLineId());
}
this.update(wrapper);
}
public String getLogDescription(String code) {
String result;
switch (code) {
case "allFile":
result = "补召缺失波形文件";
break;
case "allEvent":
result = "补召事件";
break;
case "oneFile":
result = "补召单事件波形";
break;
default:
result = "未知";
}
return result;
}
}

View File

@@ -1,12 +1,17 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.IdUtil;
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.njcn.access.utils.ChannelObjectUtil;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.param.IcdBzParam;
import com.njcn.csdevice.param.IcdLedgerParam;
import com.njcn.csdevice.param.IcdParam;
import com.njcn.csdevice.pojo.param.AppProjectAddParm;
@@ -16,7 +21,10 @@ 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.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.mq.message.BZEventMessage;
import com.njcn.mq.template.BZEventMessageTemplate;
import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.enums.DicDataEnum;
@@ -27,6 +35,8 @@ import org.jetbrains.annotations.NotNull;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.function.Function;
import java.util.stream.Collectors;
@@ -44,7 +54,11 @@ class IcdServiceImpl implements IcdService {
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
private final CsLinePOService csLinePOService;
private final ICsLedgerService csLedgerService;
private final BZEventMessageTemplate bzEventMessageTemplate;
private final EventFeignClient eventFeignClient;
private final ICsTerminalLogsService csTerminalLogsService;
private final ICsTerminalReplyService csTerminalReplyService;
private final DateTimeFormatter microsecondFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
@Override
public List<DeviceInfo> getLedgerInfo(IcdParam param) {
@@ -161,8 +175,316 @@ class IcdServiceImpl implements IcdService {
}
@Override
public void restartProcess(CldControlMessage message) {
@Transactional(rollbackFor = Exception.class)
public void bzFileByEventId(String eventId) {
CsEventPO po = eventFeignClient.queryById(eventId).getData();
if (ObjectUtil.isNull(po)) {
throw new BusinessException("事件缺失");
}
//获取设备信息
CsEquipmentDeliveryPO dev = csEquipmentDeliveryService.getDevByLineId(po.getLineId());
BZEventMessage.Event file = new BZEventMessage.Event();
file.setGuid(po.getId());
file.setTerminalId(po.getDeviceId());
file.setMonitorIdList(Collections.singletonList(po.getLineId()));
file.setTimeInterval(Collections.singletonList(po.getStartTime().format(microsecondFormatter)));
file.setDataType(2);
//记录发送日志
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
csTerminalLogs.setId(po.getId());
csTerminalLogs.setDeviceId(dev.getId());
csTerminalLogs.setLineId(po.getLineId());
csTerminalLogs.setOperateType(3);
csTerminalLogs.setNodeId(dev.getNodeId());
csTerminalLogs.setNodeProcess(dev.getNodeProcess());
csTerminalLogs.setIsPush(1);
csTerminalLogsService.saveOrUpdate(csTerminalLogs);
//记录响应日志
CsTerminalReply csTerminalReply = new CsTerminalReply();
csTerminalReply.setId(IdUtil.simpleUUID());
csTerminalReply.setReplyId(po.getId());
csTerminalReply.setNodeId(dev.getNodeId());
csTerminalReply.setProcessNo(dev.getNodeProcess());
csTerminalReply.setDeviceId(dev.getId());
csTerminalReply.setLineId(po.getLineId());
csTerminalReply.setIsReceived(0);
csTerminalReply.setCode("oneFile");
csTerminalReplyService.saveOrUpdate(csTerminalReply);
//发送消息
bzEventMessageTemplate.sendMember(Collections.singletonList(file),dev.getNodeId());
}
@Override
@Transactional(rollbackFor = Exception.class)
public void bzEvent(IcdBzParam param) {
// 参数校验
if (StrUtil.isBlank(param.getStartTime()) || StrUtil.isBlank(param.getEndTime())) {
throw new BusinessException("开始时间和结束时间不能为空");
}
LocalDateTime startLocalDate;
LocalDateTime endLocalDate;
try {
startLocalDate = LocalDateTimeUtil.parse(param.getStartTime(), DatePattern.NORM_DATE_PATTERN);
endLocalDate = LocalDateTimeUtil.parse(param.getEndTime(), DatePattern.NORM_DATE_PATTERN);
} catch (Exception e) {
throw new BusinessException("时间格式不正确,请使用 yyyy-MM-dd 格式");
}
String beginDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.beginOfDay(startLocalDate),
DatePattern.NORM_DATETIME_PATTERN
);
String endDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.endOfDay(endLocalDate),
DatePattern.NORM_DATETIME_PATTERN
);
if (CollectionUtil.isNotEmpty(param.getLineList())) {
processWithLineIds(param.getLineList(), beginDay, endDay);
} else {
processWithoutLineIds(beginDay, endDay);
}
}
private void processWithLineIds(List<String> lineList, String beginDay, String endDay) {
List<CsLinePO> csLineList = csLinePOService.listByIds(lineList);
List<String> deviceIdList = csLineList.stream()
.map(CsLinePO::getDeviceId)
.distinct()
.collect(Collectors.toList());
List<CsEquipmentDeliveryPO> equipmentList = csEquipmentDeliveryService.listByIds(deviceIdList);
Map<String, List<CsEquipmentDeliveryPO>> devMap = equipmentList.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
handleEventsAndLogs(devMap, csLineList, beginDay, endDay);
}
private void processWithoutLineIds(String beginDay, String endDay) {
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getAllOnline();
if (CollectionUtil.isEmpty(devList)) return;
List<String> deviceIds = devList.stream()
.map(CsEquipmentDeliveryPO::getId)
.collect(Collectors.toList());
List<CsLinePO> csLineList = csLinePOService.getLinesByDevList(deviceIds);
Map<String, List<CsEquipmentDeliveryPO>> devMap = devList.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
handleEventsAndLogs(devMap, csLineList, beginDay, endDay);
}
private void handleEventsAndLogs(
Map<String, List<CsEquipmentDeliveryPO>> devMap,
List<CsLinePO> csLineList,
String beginDay,
String endDay
) {
devMap.forEach((nodeId, devices) -> {
List<BZEventMessage.Event> events = new ArrayList<>();
List<CsTerminalLogs> logsToSave = new ArrayList<>();
List<CsTerminalReply> repliesToSave = new ArrayList<>();
for (CsEquipmentDeliveryPO device : devices) {
String uuid = IdUtil.simpleUUID();
BZEventMessage.Event event = buildEvent(uuid, device, csLineList, beginDay, endDay);
events.add(event);
CsTerminalLogs log = buildTerminalLog(uuid, device, csLineList);
logsToSave.add(log);
List<CsTerminalReply> reply = buildTerminalReply(uuid, device, csLineList);
repliesToSave.addAll(reply);
}
csTerminalLogsService.saveBatch(logsToSave);
csTerminalReplyService.saveBatch(repliesToSave);
bzEventMessageTemplate.sendMember(events, nodeId);
});
}
private BZEventMessage.Event buildEvent(String guid, CsEquipmentDeliveryPO device,
List<CsLinePO> csLineList, String beginDay, String endDay) {
BZEventMessage.Event event = new BZEventMessage.Event();
event.setGuid(guid);
event.setTerminalId(device.getId());
List<String> monitorIds = csLineList.stream()
.filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
.map(CsLinePO::getLineId)
.collect(Collectors.toList());
event.setMonitorIdList(monitorIds);
event.setDataType(1);
event.setTimeInterval(Collections.singletonList(beginDay + "~" + endDay));
return event;
}
private CsTerminalLogs buildTerminalLog(String id, CsEquipmentDeliveryPO device,
List<CsLinePO> csLineList) {
List<String> lineIds = csLineList.stream()
.filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
.map(CsLinePO::getLineId)
.collect(Collectors.toList());
CsTerminalLogs log = new CsTerminalLogs();
log.setId(id);
log.setDeviceId(device.getId());
log.setLineId(String.join(",", lineIds));
log.setOperateType(3);
log.setNodeId(device.getNodeId());
log.setNodeProcess(device.getNodeProcess());
log.setIsPush(1);
return log;
}
private List<CsTerminalReply> buildTerminalReply(String replyId, CsEquipmentDeliveryPO device,
List<CsLinePO> csLineList) {
List<CsTerminalReply> replies = new ArrayList<>();
List<String> lineIds = csLineList.stream()
.filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
.map(CsLinePO::getLineId)
.collect(Collectors.toList());
lineIds.forEach(lineId -> {
CsTerminalReply reply = new CsTerminalReply();
reply.setId(IdUtil.simpleUUID());
reply.setReplyId(replyId);
reply.setNodeId(device.getNodeId());
reply.setProcessNo(device.getNodeProcess());
reply.setDeviceId(device.getId());
reply.setLineId(lineId);
reply.setIsReceived(0);
reply.setCode("allEvent");
replies.add(reply);
});
return replies;
}
// private CsTerminalReply buildTerminalReply(String replyId, CsEquipmentDeliveryPO device,
// List<CsLinePO> csLineList) {
// List<String> lineIds = csLineList.stream()
// .filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
// .map(CsLinePO::getLineId)
// .collect(Collectors.toList());
//
// CsTerminalReply reply = new CsTerminalReply();
// reply.setId(IdUtil.simpleUUID());
// reply.setReplyId(replyId);
// reply.setNodeId(device.getNodeId());
// reply.setProcessNo(device.getNodeProcess());
// reply.setDeviceId(device.getId());
// reply.setLineId(String.join(",", lineIds));
// reply.setIsReceived(0);
// reply.setCode("allEvent");
// return reply;
// }
@Override
@Transactional(rollbackFor = Exception.class)
public void bzFile(IcdBzParam param) {
String beginDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.beginOfDay(LocalDateTimeUtil.parse(param.getStartTime(), DatePattern.NORM_DATE_PATTERN)),
DatePattern.NORM_DATETIME_PATTERN
);
String endDay = LocalDateTimeUtil.format(
LocalDateTimeUtil.endOfDay(LocalDateTimeUtil.parse(param.getEndTime(), DatePattern.NORM_DATE_PATTERN)),
DatePattern.NORM_DATETIME_PATTERN
);
// 获取监测点没有波形的事件信息
List<CsEventPO> eventList = eventFeignClient.getEventByTime(param.getLineList(), beginDay, endDay).getData();
if (CollUtil.isEmpty(eventList)) {
return;
}
// 获取装置信息,用于区分不同服务器
List<String> deviceIds = eventList.stream()
.map(CsEventPO::getDeviceId)
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (CollUtil.isEmpty(deviceIds)) {
return;
}
List<CsEquipmentDeliveryPO> equipmentList = csEquipmentDeliveryService.listByIds(deviceIds);
if (CollUtil.isEmpty(equipmentList)) {
return;
}
Map<String, List<CsEquipmentDeliveryPO>> nodeToDeviceMap = equipmentList.stream()
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
// 构建 deviceId -> CsEventPO 映射,避免重复 filter
Map<String, List<CsEventPO>> deviceToEventMap = eventList.stream()
.filter(event -> event.getDeviceId() != null)
.collect(Collectors.groupingBy(CsEventPO::getDeviceId));
nodeToDeviceMap.forEach((nodeId, deviceList) -> {
List<BZEventMessage.Event> msgList = new ArrayList<>();
List<CsTerminalLogs> logList = new ArrayList<>();
List<CsTerminalReply> replyList = new ArrayList<>();
for (CsEquipmentDeliveryPO device : deviceList) {
String deviceId = device.getId();
List<CsEventPO> eventsForDevice = deviceToEventMap.getOrDefault(deviceId, Collections.emptyList());
Map<String, List<CsEventPO>> lineToEventMap = eventsForDevice.stream()
.filter(event -> event.getLineId() != null)
.collect(Collectors.groupingBy(CsEventPO::getLineId));
lineToEventMap.forEach((lineId, eventGroup) -> {
BZEventMessage.Event event = new BZEventMessage.Event();
String guid = IdUtil.simpleUUID();
event.setGuid(guid);
event.setTerminalId(deviceId);
event.setMonitorIdList(Collections.singletonList(lineId));
event.setDataType(2);
List<String> timeList = eventGroup.stream()
.map(CsEventPO::getStartTime)
.filter(Objects::nonNull)
.map(dt -> dt.format(microsecondFormatter))
.collect(Collectors.toList());
event.setTimeInterval(timeList);
msgList.add(event);
// 记录发送日志
CsTerminalLogs log = new CsTerminalLogs();
log.setId(guid);
log.setDeviceId(deviceId);
log.setLineId(lineId);
log.setOperateType(3);
log.setNodeId(device.getNodeId());
log.setNodeProcess(device.getNodeProcess());
log.setIsPush(1);
logList.add(log);
// 记录响应日志
CsTerminalReply reply = new CsTerminalReply();
reply.setId(IdUtil.simpleUUID());
reply.setReplyId(guid);
reply.setNodeId(device.getNodeId());
reply.setProcessNo(device.getNodeProcess());
reply.setDeviceId(deviceId);
reply.setLineId(lineId);
reply.setIsReceived(0);
reply.setCode("allFile");
replyList.add(reply);
});
}
if (CollUtil.isNotEmpty(logList)) {
csTerminalLogsService.saveBatch(logList);
}
if (CollUtil.isNotEmpty(replyList)) {
csTerminalReplyService.saveBatch(replyList);
}
if (CollUtil.isNotEmpty(msgList)) {
bzEventMessageTemplate.sendMember(msgList, nodeId);
}
});
}
/**

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
@@ -13,6 +14,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
import com.njcn.csdevice.mapper.NodeMapper;
import com.njcn.csdevice.param.IcdNodeParam;
import com.njcn.csdevice.pojo.param.NodeParam;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.Node;
@@ -20,6 +22,8 @@ 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;
import com.njcn.mq.message.CldControlMessage;
import com.njcn.mq.template.CldControlMessageTemplate;
import com.njcn.web.factory.PageFactory;
import lombok.AllArgsConstructor;
import org.springframework.beans.BeanUtils;
@@ -28,6 +32,7 @@ import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
@@ -46,6 +51,7 @@ import java.util.stream.Collectors;
public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements INodeService {
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
private final CldControlMessageTemplate controlMessageTemplate;
@Override
public boolean addNode(NodeParam nodeParam) {
@@ -165,6 +171,84 @@ public class NodeServiceImpl extends ServiceImpl<NodeMapper, Node> implements IN
return nodeProcessDeviceVo;
}
@Override
public void restartProcess(String nodeId, Integer processNo) {
Node node = getNodeById(nodeId);
CldControlMessage cldControlMessage = new CldControlMessage();
cldControlMessage.setGuid(IdUtil.simpleUUID());
cldControlMessage.setCode("set_process");
cldControlMessage.setNodeId(nodeId);
cldControlMessage.setProcessNo(processNo);
cldControlMessage.setFun("delete");
cldControlMessage.setProcessNum(node.getMaxProcessNum());
controlMessageTemplate.sendMember(cldControlMessage,nodeId);
}
@Override
public String updateDevProcessNo(String id, Integer processNo) {
String result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsEquipmentDeliveryPO::getId,id);
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectOne(wrapper);
if (Objects.equals(po.getNodeProcess(),processNo)) {
return "修改进程号前后一致,暂不调整";
}
int oldProcessNo = po.getNodeProcess();
po.setNodeProcess(processNo);
int count = csEquipmentDeliveryMapper.updateById(po);
if (count > 0) {
result = "修改成功";
//重启前置机进程(两个)
//原来的
restartProcess(po.getNodeId(), oldProcessNo);
//修改后的
restartProcess(po.getNodeId(), processNo);
} else {
result = "修改失败";
}
return result;
}
@Override
public String updateDevNode(IcdNodeParam param) {
String result;
LambdaQueryWrapper<CsEquipmentDeliveryPO> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsEquipmentDeliveryPO::getId,param.getId());
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectOne(wrapper);
if (Objects.equals(po.getNodeId(),param.getNodeId()) && Objects.equals(po.getNodeProcess(),param.getProcessNo())) {
return "前置机修改前后一致,暂不调整";
}
Node node = getNodeById(param.getNodeId());
List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
}
int oldProcessNo = po.getNodeProcess();
po.setNodeId(param.getNodeId());
po.setNodeProcess(param.getProcessNo());
int count = csEquipmentDeliveryMapper.updateById(po);
if (count > 0) {
result = "修改成功";
//重启前置机进程(两个)
//原来的
restartProcess(po.getNodeId(), oldProcessNo);
//修改后的
restartProcess(param.getNodeId(), param.getProcessNo());
} else {
result = "修改失败";
}
return result;
}
//根据前置机id获取装置数量
public List<CsEquipmentDeliveryPO> getListByNodeId(String nodeId) {
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNodeId,nodeId)
.in(CsEquipmentDeliveryPO::getRunStatus, Arrays.asList(1,2));
return csEquipmentDeliveryMapper.selectList(lambdaQueryWrapper);
}
/**
* 校验参数,检查是否存在相同编码的字典类型
*/

View File

@@ -6,11 +6,11 @@ import cn.hutool.core.util.ObjectUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.mapper.RStatIntegrityDMapper;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
import com.njcn.csdevice.service.IRStatIntegrityDService;
import com.njcn.csdevice.util.TimeUtil;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
@@ -42,15 +42,21 @@ import java.util.stream.Collectors;
@RequiredArgsConstructor
public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMapper, RStatIntegrityD> implements IRStatIntegrityDService {
private final EquipmentFeignClient equipmentFeignClient;
private final CsLineFeignClient csLineFeignClient;
private final CommonService commonService;
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
@Override
public void addData(StatisticsDataParam param) {
List<RStatIntegrityD> result = new ArrayList<>();
List<CsEquipmentDeliveryPO> devList;
//判断是否指定设备补招
if (CollectionUtil.isNotEmpty(param.getIdList())) {
devList = csEquipmentDeliveryService.getListByIds(param.getIdList());
} else {
//获取库中正常的所有装置
List<CsEquipmentDeliveryPO> devList = equipmentFeignClient.getAll().getData();
devList = csEquipmentDeliveryService.getAll();
}
if (CollectionUtil.isNotEmpty(devList)) {
Map<String, CsEquipmentDeliveryPO> devMap = devList.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
//获取所有监测点

View File

@@ -6,16 +6,15 @@ import cn.hutool.core.date.DateUnit;
import cn.hutool.core.date.DateUtil;
import com.baomidou.dynamic.datasource.annotation.DS;
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.mapper.RStatOnlineRateDMapper;
import com.njcn.csdevice.param.LineCountEvaluateParam;
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
import com.njcn.csdevice.service.ICsCommunicateService;
import com.njcn.csdevice.service.IRStatOnlineRateDService;
import com.njcn.csdevice.util.TimeUtil;
import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.influx.deprecated.InfluxDBPublicParam;
import lombok.AllArgsConstructor;
@@ -25,7 +24,6 @@ import org.springframework.stereotype.Service;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
@@ -46,14 +44,24 @@ import java.util.List;
public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateDMapper, RStatOnlineRateD> implements IRStatOnlineRateDService {
private final Integer online = 1;
private final EquipmentFeignClient equipmentFeignClient;
private final ICsCommunicateService pqsCommunicateService;
private final CsEquipmentDeliveryService csEquipmentDeliveryService;
@Override
public void addData(StatisticsDataParam param) {
List<RStatOnlineRateD> list = new ArrayList<>();
List<CsEquipmentDeliveryPO> devList;
//判断是否指定设备补招
if (CollectionUtil.isNotEmpty(param.getIdList())) {
devList = csEquipmentDeliveryService.getListByIds(param.getIdList());
} else {
//获取库中正常的所有装置
List<CsEquipmentDeliveryPO> devList = equipmentFeignClient.getAll().getData();
devList = csEquipmentDeliveryService.getAll();
}
if (CollectionUtil.isEmpty(devList)) {
return;
}
if (CollectionUtil.isNotEmpty(devList)) {
//获取需要计算的时间
List<String> dateRange = TimeUtil.getDateRangeAsString(param.getStartTime(), param.getEndTime());
@@ -190,6 +198,8 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
} catch (ParseException e) {
throw new RuntimeException(e);
}
} else {
minute = InfluxDBPublicParam.DAY_MINUTE;
}
}
}

View File

@@ -1,19 +1,24 @@
package com.njcn.csharmonic.api;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
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.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.api.fallback.EventFeignClientFallbackFactory;
import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -30,5 +35,9 @@ public interface EventFeignClient {
@PostMapping("/queryByIndex")
HttpResult<CsEventPO> queryByIndex(@RequestBody CsEventPO csEventPO);
@PostMapping("/queryById")
HttpResult<CsEventPO> queryById(@RequestParam("eventId") String eventId);
}
@PostMapping("/getEventByTime")
HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(name = "lineList", required = false) List<String> lineList,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime);
}

View File

@@ -8,13 +8,10 @@ import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestBody;
import java.time.LocalDateTime;
import java.util.List;
/**
@@ -49,6 +46,18 @@ public class EventFeignClientFallbackFactory implements FallbackFactory<EventFei
log.error("{}异常,降级处理,异常为:{}","根据根据表唯一索引查询(用于校验是否存在该事件)s",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<CsEventPO> queryById(String eventId) {
log.error("{}异常,降级处理,异常为:{}","根据事件id查询数据",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsEventPO>> getEventByTime(List<String> lineList, String startTime, String endTime) {
log.error("{}异常,降级处理,异常为:{}","根据时间获取无波形的暂态事件",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -27,6 +27,9 @@ public class CsRtDataVO {
@ApiModelProperty("监测点id")
private String lineId;
@ApiModelProperty("设备状态 1:离线 2:在线")
private Integer devStatus;
@ApiModelProperty("相别")
private String phaseType;

View File

@@ -19,6 +19,7 @@ import com.njcn.event.file.pojo.dto.WaveDataDTO;
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;
@@ -111,6 +112,16 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryById")
@ApiOperation("根据事件id查询数据")
public HttpResult<CsEventPO> queryById(String eventId) {
String methodDescribe = getMethodDescribe("queryById");
CsEventPO po = csEventPOService.lambdaQuery().eq(CsEventPO::getId,eventId).one();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryByModelId")
@ApiOperation("获取各模块事件")
@@ -130,4 +141,18 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventByTime")
@ApiOperation("根据时间获取无波形的暂态事件")
@ApiImplicitParams({
@ApiImplicitParam(name = "lineList", value = "监测点id"),
@ApiImplicitParam(name = "startTime", value = "开始时间"),
@ApiImplicitParam(name = "endTime", value = "结束时间")
})
public HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(required = false) List<String> lineList,@RequestParam String startTime,@RequestParam String endTime) {
String methodDescribe = getMethodDescribe("getEventByTime");
List<CsEventPO> list = csEventPOService.getEventByTime(lineList,startTime,endTime);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
}

View File

@@ -11,6 +11,7 @@ import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.event.file.pojo.dto.WaveDataDTO;
import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDateTime;
@@ -59,4 +60,6 @@ public interface CsEventPOService extends IService<CsEventPO>{
void addCldEvent(CldEventParam param);
List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime);
}

View File

@@ -42,7 +42,6 @@ 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;
@@ -62,7 +61,6 @@ 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;
@@ -306,6 +304,18 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
}
}
@Override
public List<CsEventPO> getEventByTime(List<String> lineList, String startTime, String endTime) {
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper.between(CsEventPO::getStartTime,startTime,endTime)
.eq(CsEventPO::getType,0)
.isNull(CsEventPO::getWavePath);
if (CollUtil.isNotEmpty(lineList)) {
lambdaQueryWrapper.in(CsEventPO::getLineId,lineList);
}
return this.list(lambdaQueryWrapper);
}
public String getTag(Integer type) {
String tag;
switch (type) {

View File

@@ -5,8 +5,8 @@ import com.alibaba.nacos.shaded.com.google.gson.Gson;
import com.google.common.reflect.TypeToken;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.*;
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.po.CsDataArray;
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
import com.njcn.csdevice.pojo.vo.LineTargetVO;
@@ -22,7 +22,6 @@ 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;
@@ -74,6 +73,8 @@ public class LineTargetServiceImpl implements ILineTargetService {
private final InfluxDbParamUtil influxDbParamUtil;
private final EquipmentFeignClient equipmentFeignClient;
@Override
public List<DataArrayTreeVO> getLineTarget(String lineId) {
List<String> setList = new ArrayList<>();
@@ -125,7 +126,12 @@ public class LineTargetServiceImpl implements ILineTargetService {
String dataId = dataArray.getDataId();
String classId = epdFeignClient.selectById(dataId).getData().getClassId();
String clDid = influxDbParamUtil.getClDidByLineId(item.getLineId());
result.add(getLineRtData(item.getId(),item.getLineId(),influxDbParamUtil.getTableNameByClassId(classId),targetTag,phasic,dataType,targetName,clDid));
//基础信息
CsRtDataVO vo = getLineRtData(item.getId(),item.getLineId(),influxDbParamUtil.getTableNameByClassId(classId),targetTag,phasic,dataType,targetName,clDid);
//设备状态信息
CsEquipmentDeliveryPO po = equipmentFeignClient.getDevByLineId(item.getLineId()).getData();
vo.setDevStatus(po.getRunStatus());
result.add(vo);
}
});
return result;

View File

@@ -74,7 +74,7 @@ public class RealDataServiceImpl implements RealDataService {
redisUtil.saveByKeyWithExpire("rtDataUserId:"+lineId, RequestUtil.getUserIndex(),600L);
}
//等待装置响应,获取询问结果
Thread.sleep(2000);
Thread.sleep(5000);
Object object;
if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),devModelCode)) {
object = redisUtil.getObjectByKey("devResponse:" + lineId);

View File

@@ -9,6 +9,7 @@ import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
import com.njcn.csharmonic.pojo.vo.DataVo;
import com.njcn.csharmonic.pojo.vo.HalfMonthReportVO;
@@ -91,6 +92,7 @@ public class StatisticsDataDataServiceImpl implements IStatisticsDataDataService
//获取装置
List<CsEquipmentDeliveryPO> equipmentDeliveryList = equipmentFeignClient.getAll().getData();
if (CollectionUtil.isNotEmpty(equipmentDeliveryList)) {
Map<String, CsEquipmentDeliveryPO> map = equipmentDeliveryList.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
List<CsEquipmentDeliveryPO> processList = Objects.isNull(param.getProcess())
? equipmentDeliveryList
: equipmentDeliveryList.stream()
@@ -99,6 +101,9 @@ public class StatisticsDataDataServiceImpl implements IStatisticsDataDataService
if (CollectionUtil.isNotEmpty(processList)) {
//获取监测点集合
List<String> devList = processList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
if (CollectionUtil.isEmpty(devList)) {
return result;
}
List<CsLinePO> csLineList = csLineFeignClient.getLinesByDevList(devList).getData();
if (CollectionUtil.isNotEmpty(csLineList)) {
Map<String,List<CsLinePO>> devMap = csLineList.stream().collect(Collectors.groupingBy(CsLinePO::getDeviceId));
@@ -123,7 +128,11 @@ public class StatisticsDataDataServiceImpl implements IStatisticsDataDataService
vo.setMac(dev.getMac());
vo.setOperationalTime(dev.getCreateTime());
vo.setOperationalStatus(dev.getUsageStatus() == 0 ? "停运" : "在运");
if (Objects.equals(line.getName(),"治理监测点")) {
vo.setLineName(line.getName() + "(" + map.get(dev.getId()).getModuleNumber() + "模块)");
} else {
vo.setLineName(line.getName());
}
vo.setCommunicationStatus(dev.getRunStatus() == 1 ? "离线" : "在线");
vo.setLatestTime(LocalDateTime.now());
vo.setProcess(dev.getProcess());