app功能合并

This commit is contained in:
xy
2026-03-25 13:33:47 +08:00
parent fc7694a1db
commit 720afd42df
127 changed files with 5356 additions and 1346 deletions

View File

@@ -5,6 +5,8 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory; import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory;
import com.njcn.csdevice.pojo.param.UserDevParam; import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO; import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -29,4 +31,11 @@ public interface CsDeviceUserFeignClient {
@PostMapping("/channelDevByUserId") @PostMapping("/channelDevByUserId")
HttpResult<List<String>> channelDevByUserId(@RequestBody UserDevParam param); HttpResult<List<String>> channelDevByUserId(@RequestBody UserDevParam param);
@PostMapping("/queryUserById")
HttpResult<DevUserVO> queryUserById(@RequestParam("devId") String devId);
@PostMapping("/getList")
@ApiOperation("根据设备集合获取数据")
HttpResult<List<CsDeviceUserPO>> getList(@RequestBody UserDevParam param);
} }

View File

@@ -35,6 +35,10 @@ public interface CsLedgerFeignClient {
@PostMapping("/queryDevDetail") @PostMapping("/queryDevDetail")
HttpResult<DevDetailDTO> queryDevDetail(@RequestParam("devId") String devId); HttpResult<DevDetailDTO> queryDevDetail(@RequestParam("devId") String devId);
@PostMapping("/lineTree")
@ApiOperation("五层设备树(监测点层,根节点为治理设备和便携式设备)")
HttpResult<List<CsLedgerVO>> lineTree();
@PostMapping("/deviceTree") @PostMapping("/deviceTree")
@ApiOperation("三层设备树(装置层)") @ApiOperation("三层设备树(装置层)")
HttpResult<List<CsLedgerVO>> getDeviceTree(); HttpResult<List<CsLedgerVO>> getDeviceTree();

View File

@@ -1,8 +1,13 @@
package com.njcn.csdevice.api; package com.njcn.csdevice.api;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.ServerInfo; 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.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory; import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -64,6 +69,9 @@ public interface CsLineFeignClient {
@PostMapping("/getAllLine") @PostMapping("/getAllLine")
HttpResult<List<String>> getAllLine(); HttpResult<List<String>> getAllLine();
@PostMapping("/getAllLineDetail")
HttpResult<List<CsLineDTO>> getAllLineDetail();
@PostMapping("/getOverLimitDataByIds") @PostMapping("/getOverLimitDataByIds")
HttpResult<List<Overlimit>> getOverLimitData(@RequestBody List<String> ids); HttpResult<List<Overlimit>> getOverLimitData(@RequestBody List<String> ids);

View File

@@ -0,0 +1,22 @@
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.ProcessFeignClientFallbackFactory;
import com.njcn.csdevice.pojo.po.CsUserPins;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csUserPins", fallbackFactory = ProcessFeignClientFallbackFactory.class,contextId = "csUserPins")
public interface CsUserPinsFeignClient {
@PostMapping("/getPinToTopList")
HttpResult<List<CsUserPins>> getPinToTopList();
}

View File

@@ -0,0 +1,23 @@
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.AppProjectClientFallbackFactory;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
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;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/engineering", fallbackFactory = AppProjectClientFallbackFactory.class,contextId = "engineering")
public interface EngineeringFeignClient {
@PostMapping("/queryEngineering")
HttpResult<List<CsEngineeringVO>> queryEngineering(@Validated @RequestBody CsEngineeringQueryParm csEngineeringQueryParm);
}

View File

@@ -6,6 +6,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsDeviceUserFeignClient; import com.njcn.csdevice.api.CsDeviceUserFeignClient;
import com.njcn.csdevice.pojo.param.UserDevParam; import com.njcn.csdevice.pojo.param.UserDevParam;
import com.njcn.csdevice.pojo.po.CsDeviceUserPO; import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
import com.njcn.csdevice.pojo.vo.DevUserVO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@@ -51,6 +52,18 @@ public class CsDeviceUserClientFallbackFactory implements FallbackFactory<CsDevi
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<DevUserVO> queryUserById(String devId) {
log.error("{}异常,降级处理,异常为:{}","获取设备主/子用户数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsDeviceUserPO>> getList(UserDevParam param) {
log.error("{}异常,降级处理,异常为:{}","根据设备集合获取数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -57,6 +57,12 @@ public class CsLedgerFeignClientFallbackFactory implements FallbackFactory<CsLed
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<CsLedgerVO>> lineTree() {
log.error("{}异常,降级处理,异常为:{}","查询监测点数数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override @Override
public HttpResult<List<CsLedgerVO>> getDeviceTree() { public HttpResult<List<CsLedgerVO>> getDeviceTree() {
log.error("{}异常,降级处理,异常为:{}","查询设备树",cause.toString()); log.error("{}异常,降级处理,异常为:{}","查询设备树",cause.toString());

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.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -103,6 +104,12 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<CsLineDTO>> getAllLineDetail() {
log.error("{}异常,降级处理,异常为:{}","获取系统中所有监测点id详情异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override @Override
public HttpResult<List<Overlimit>> getOverLimitData(List<String> ids) { public HttpResult<List<Overlimit>> getOverLimitData(List<String> ids) {
log.error("{}异常,降级处理,异常为:{}","根据监测点id集合获取国标限值异常",cause.toString()); log.error("{}异常,降级处理,异常为:{}","根据监测点id集合获取国标限值异常",cause.toString());

View File

@@ -0,0 +1,43 @@
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.CsUserPinsFeignClient;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.utils.CsDeviceEnumUtil;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2023/4/10 20:09
*/
@Slf4j
@Component
public class CsUserPinsFeignClientFallbackFactory implements FallbackFactory<CsUserPinsFeignClient> {
@Override
public CsUserPinsFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
exceptionEnum = CsDeviceEnumUtil.getExceptionEnum(businessException.getResult());
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsUserPinsFeignClient() {
@Override
public HttpResult<List<CsUserPins>> getPinToTopList() {
log.error("{}异常,降级处理,异常为:{}","获取用户置顶设备(工程)数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,38 @@
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.EngineeringFeignClient;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class EngineeringClientFallbackFactory implements FallbackFactory<EngineeringFeignClient> {
@Override
public EngineeringFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new EngineeringFeignClient() {
@Override
public HttpResult<List<CsEngineeringVO>> queryEngineering(CsEngineeringQueryParm csEngineeringQueryParm) {
log.error("{}异常,降级处理,异常为:{}","查询工程列表接口异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,28 @@
package com.njcn.csdevice.param;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class CsUserPinsParam implements Serializable {
@ApiModelProperty("用户id")
@NotBlank(message = "用户id")
private String userId;
@ApiModelProperty("目标类型1-设备2-工程")
@NotNull(message = "目标类型1-设备2-工程")
private Integer targetType;
@ApiModelProperty("目标ID设备ID或工程ID")
@NotBlank(message = "目标ID设备ID或工程ID")
private String targetId;
}

View File

@@ -0,0 +1,148 @@
package com.njcn.csdevice.pojo.dto;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
@Data
@NoArgsConstructor
public class CsLineDTO implements Serializable {
/**
* 监测点id
*/
private String lineId;
/**
* 装置id
*/
private String deviceId;
/**
* 装置id
*/
private String deviceType;
/**
* 监测点名称
*/
private String name;
/**
* 字典表:安装位置(负载侧,电网侧, 输出侧)
*/
private String position;
/**
* 数据集id
*/
private String dataSetId;
/**
* 模板id
*/
private String dataModelId;
/**
* 电压等级
*/
private Double volGrade;
/**
* PT变比
*/
private Double ptRatio;
/**
* PT2次变比
*/
private Double pt2Ratio;
/**
* CT变比
*/
private Double ctRatio;
/**
* CT2变比
*/
private Double ct2Ratio;
/**
* 状态(0删除 1正常)
*/
private Integer status;
/**
* 接线方式(0-星型 1-角型 2-V型)
*/
private Integer conType;
/**
* 逻辑子设备id(与模板对应)
*/
private Integer clDid;
/**
* 监测点统计间隔
*/
private Integer lineInterval;
/**
* 运行状态
*/
private Integer runStatus;
/**
* 监测点线路号
*/
private Integer lineNo;
/**
* 监测对象类型
*/
private String monitorObj;
/**
* 是否治理(0:未治理 1:已治理)
*/
private Integer govern;
private String monitorUser;
/**
* 短路容量
*/
private Double shortCircuitCapacity;
/**
* 设备容量
*/
private Double devCapacity;
/**
* 基准容量
*/
private Double basicCapacity;
/**
* 协议容量
*/
private Double protocolCapacity;
/**
* 治理报告文件路径
*/
private String reportFilePath;
/**
* 日志等级(NORMAL、DEBUG、WARN、ERROR)
*/
private String lineLogLevel;
/**
* 是否是主要监测点(0: 不是 1:是)
*/
private Integer isImportant;
}

View File

@@ -31,4 +31,10 @@ public class DevDetailDTO {
@ApiModelProperty(value = "设备名称") @ApiModelProperty(value = "设备名称")
private String equipmentName; private String equipmentName;
@ApiModelProperty(value = "设备通讯状态")
private Integer runStatus;
@ApiModelProperty(value = "设备MAC地址")
private String devMac;
} }

View File

@@ -3,6 +3,8 @@ package com.njcn.csdevice.pojo.dto;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* Description: * Description:
* Date: 2023/8/1 15:25【需求编号】 * Date: 2023/8/1 15:25【需求编号】
@@ -26,4 +28,29 @@ public class LineParamDTO {
@ApiModelProperty(value = "监测点id") @ApiModelProperty(value = "监测点id")
private String lineId; private String lineId;
@ApiModelProperty(value = "时间类型 0:日报 1:月报")
private Integer timeType;
@ApiModelProperty(value = "时间")
private String time;
@ApiModelProperty(value = "起始时间")
private String startTime;
@ApiModelProperty(value = "结束时间")
private String endTime;
@ApiModelProperty(value = "集合")
private List<String> list;
@Data
public static class DevParamDTO {
@ApiModelProperty(value = "时间")
private String time;
@ApiModelProperty(value = "设备id集合")
private List<String> devList;
}
} }

View File

@@ -0,0 +1,44 @@
package com.njcn.csdevice.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import com.njcn.db.bo.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
/**
* <p>
* 用户置顶表
* </p>
*
* @author xy
* @since 2026-03-04
*/
@Getter
@Setter
@TableName("cs_user_pins")
public class CsUserPins extends BaseEntity implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 主键ID
*/
private String id;
/**
* 用户ID
*/
private String userId;
/**
* 目标类型1-设备2-工程
*/
private Integer targetType;
/**
* 目标ID设备ID或工程ID
*/
private String targetId;
}

View File

@@ -67,5 +67,6 @@ public class CsEngineeringVO extends BaseEntity {
@ApiModelProperty(value = "状态") @ApiModelProperty(value = "状态")
private String status; private String status;
@ApiModelProperty(value = "排序")
private Integer sort;
} }

View File

@@ -69,6 +69,9 @@ public class CsLedgerVO implements Serializable {
@ApiModelProperty(name = "process",value = "流程状态") @ApiModelProperty(name = "process",value = "流程状态")
private Integer process; private Integer process;
@ApiModelProperty(name = "isTop",value = "是否置顶,默认不置顶")
private Integer isTop = 0;
@ApiModelProperty(name = "children",value = "子节点") @ApiModelProperty(name = "children",value = "子节点")
private List<CsLedgerVO> children = new ArrayList<>(); private List<CsLedgerVO> children = new ArrayList<>();

View File

@@ -0,0 +1,41 @@
package com.njcn.csdevice.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 类的介绍:
*
* @author xuyang
* @version 1.0.0
* @createTime 2026/3/5
*/
@Data
public class EngineeringHomePageVO implements Serializable {
@ApiModelProperty(name = "engineeringId",value = "工程id")
private String engineeringId;
@ApiModelProperty(name = "engineeringName",value = "工程名称")
private String engineeringName;
@ApiModelProperty(name = "devTotal",value = "设备总数")
private Integer devTotal;
@ApiModelProperty(name = "onlineDevTotal",value = "在线设备数")
private Integer onlineDevTotal;
@ApiModelProperty(name = "offlineDevTotal",value = "离线设备数")
private Integer offlineDevTotal;
@ApiModelProperty(name = "alarmTotal",value = "告警数量(未读)")
private Integer alarmTotal;
@ApiModelProperty(name = "isTop",value = "是否置顶 0:未置顶 1:已置顶")
private Integer isTop = 0;
@ApiModelProperty(name = "sort",value = "排序")
private Integer sort;
}

View File

@@ -1,8 +1,11 @@
package com.njcn.csdevice.pojo.vo; package com.njcn.csdevice.pojo.vo;
import com.njcn.csdevice.pojo.po.CsLinePO;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.util.List;
/** /**
* *
* Description: * Description:
@@ -54,4 +57,16 @@ public class ProjectEquipmentVO {
@ApiModelProperty(value = "设备nDid") @ApiModelProperty(value = "设备nDid")
private String nDid; private String nDid;
@ApiModelProperty(value = "排序")
private Integer sort;
@ApiModelProperty(value = "是否置顶(0:未置顶 1:置顶),默认是0")
private Integer isTop = 0;
@ApiModelProperty(value = "设备类型(监测设备:DEV_CLD 治理设备:Direct_Connected_Device)")
private String devType;
@ApiModelProperty(value = "监测点集合")
private List<CsLinePO> lineList;
} }

View File

@@ -161,4 +161,14 @@ public class DeviceUserController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getList")
@ApiOperation("根据设备集合获取数据")
@ApiImplicitParam(name = "param", value = "参数", required = true)
public HttpResult<List<CsDeviceUserPO>> getList(@RequestBody UserDevParam param){
String methodDescribe = getMethodDescribe("getList");
List<CsDeviceUserPO> list = csDeviceUserPOService.getList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
} }

View File

@@ -54,18 +54,20 @@ public class CsLedgerController extends BaseController {
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/lineTree") @PostMapping("/lineTree")
@ApiOperation("五层设备树(监测点层,根节点为治理设备和便携式设备)") @ApiOperation("五层设备树(监测点层,根节点为治理设备和便携式设备)")
public HttpResult<List<CsLedgerVO>> lineTree(){ @ApiImplicitParam(name = "type", value = "台账树类型")
public HttpResult<List<CsLedgerVO>> lineTree(@RequestParam(required = false) @Validated String type){
String methodDescribe = getMethodDescribe("lineTree"); String methodDescribe = getMethodDescribe("lineTree");
List<CsLedgerVO> list = csLedgerService.getLineTree(); List<CsLedgerVO> list = csLedgerService.getLineTree(type);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deviceTree") @PostMapping("/deviceTree")
@ApiOperation("四层设备树(装置层,根节点为治理设备和便携式设备)") @ApiOperation("四层设备树(装置层,根节点为治理设备和便携式设备)")
public HttpResult<List<CsLedgerVO>> getDeviceTree(){ @ApiImplicitParam(name = "type", value = "台账树类型")
public HttpResult<List<CsLedgerVO>> getDeviceTree(@RequestParam(required = false) @Validated String type){
String methodDescribe = getMethodDescribe("getDeviceTree"); String methodDescribe = getMethodDescribe("getDeviceTree");
List<CsLedgerVO> list = csLedgerService.getDeviceTree(); List<CsLedgerVO> list = csLedgerService.getDeviceTree(type);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }

View File

@@ -7,6 +7,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil; import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -254,6 +255,15 @@ public class CslineController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getAllLineDetail")
@ApiOperation("获取所有监测点id详情")
public HttpResult<List<CsLineDTO>> getAllLineDetail(){
String methodDescribe = getMethodDescribe("getAllLineDetail");
List<CsLineDTO> list = csLinePOService.getAllLineDetail();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON) @OperateInfo(info = LogEnum.BUSINESS_COMMON)
@GetMapping("/getSimpleLine") @GetMapping("/getSimpleLine")
@ApiOperation("查询登录用户拥有的监测点台账") @ApiOperation("查询登录用户拥有的监测点台账")

View File

@@ -0,0 +1,61 @@
package com.njcn.csdevice.controller.project;
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.CsUserPinsParam;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.service.ICsUserPinsService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* <p>
* 用户置顶表 前端控制器
* </p>
*
* @author xy
* @since 2026-03-04
*/
@Slf4j
@RestController
@RequestMapping("/csUserPins")
@Api(tags = "置顶设备(工程)")
@AllArgsConstructor
public class CsUserPinsController extends BaseController {
private final ICsUserPinsService csUserPinsService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/engineeringPinToTop")
@ApiOperation("用户置顶工程(取消置顶)")
public HttpResult<Boolean> engineeringPinToTop(@Validated @RequestBody CsUserPinsParam param){
String methodDescribe = getMethodDescribe("engineeringPinToTop");
Boolean result = csUserPinsService.engineeringPinToTop(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getPinToTopList")
@ApiOperation("获取用户置顶设备(工程)")
public HttpResult<List<CsUserPins>> getPinToTopList(){
String methodDescribe = getMethodDescribe("getPinToTopList");
List<CsUserPins> result = csUserPinsService.getPinToTopList();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -103,4 +103,5 @@ public class EngineeringController extends BaseController {
List<CsEngineeringPO> result = csEngineeringService.getUnlinkedEngineering(userId); List<CsEngineeringPO> result = csEngineeringService.getUnlinkedEngineering(userId);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
} }
} }

View File

@@ -1,6 +1,7 @@
package com.njcn.csdevice.mapper; package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
@@ -21,4 +22,6 @@ public interface CsLinePOMapper extends BaseMapper<CsLinePO> {
Map<String,String> getCustomDetailByLineId(@Param("lineId")String lineId); Map<String,String> getCustomDetailByLineId(@Param("lineId")String lineId);
List<CsLineDTO> findLineList();
} }

View File

@@ -0,0 +1,16 @@
package com.njcn.csdevice.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csdevice.pojo.po.CsUserPins;
/**
* <p>
* 用户置顶表 Mapper 接口
* </p>
*
* @author xy
* @since 2026-03-04
*/
public interface CsUserPinsMapper extends BaseMapper<CsUserPins> {
}

View File

@@ -41,7 +41,9 @@
c.create_time createTime, c.create_time createTime,
c.run_status, c.run_status,
c.mac mac, c.mac mac,
c.process process c.process process,
c.sort sort,
c.dev_type devType
FROM FROM
(select * from cs_ledger where LEVEL = 0 and State =1 (select * from cs_ledger where LEVEL = 0 and State =1
) a, ) a,

View File

@@ -53,4 +53,15 @@
WHERE WHERE
line.line_id = #{lineId} line.line_id = #{lineId}
</select> </select>
<select id="findLineList" resultType="com.njcn.csdevice.pojo.dto.CsLineDTO">
SELECT
t1.*,
t2.dev_type deviceType
FROM
cs_line t1
LEFT JOIN cs_equipment_delivery t2 ON t1.device_id = t2.id
WHERE
t1.`status` = 1
</select>
</mapper> </mapper>

View File

@@ -53,4 +53,6 @@ public interface CsDeviceUserPOService extends IService<CsDeviceUserPO>{
List<String> findDevByUserId(String userId); List<String> findDevByUserId(String userId);
void channelDevByUserId(UserDevParam param); void channelDevByUserId(UserDevParam param);
List<CsDeviceUserPO> getList(UserDevParam param);
} }

View File

@@ -2,6 +2,7 @@ package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -81,6 +82,8 @@ public interface CsLinePOService extends IService<CsLinePO>{
List<String> getAllLine(); List<String> getAllLine();
List<CsLineDTO> getAllLineDetail();
List<CsLinePO> getSimpleLine(); List<CsLinePO> getSimpleLine();
List<CsLinePO> getLineBySensitiveUser(List<String> list); List<CsLinePO> getLineBySensitiveUser(List<String> list);

View File

@@ -29,13 +29,13 @@ public interface ICsLedgerService extends IService<CsLedger> {
* 获取终端台账树 * 获取终端台账树
* @return * @return
*/ */
List<CsLedgerVO> getLineTree(); List<CsLedgerVO> getLineTree(String type);
/** /**
* 终端三层树 * 终端三层树
* @return * @return
*/ */
List<CsLedgerVO> getDeviceTree(); List<CsLedgerVO> getDeviceTree(String type);
/** /**
* 新增台账数据 * 新增台账数据

View File

@@ -0,0 +1,35 @@
package com.njcn.csdevice.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.param.CsUserPinsParam;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import java.util.List;
/**
* <p>
* 用户置顶表 服务类
* </p>
*
* @author xy
* @since 2026-03-04
*/
public interface ICsUserPinsService extends IService<CsUserPins> {
boolean engineeringPinToTop(CsUserPinsParam param);
List<CsUserPins> getPinToTopList();
/**
* 针对台账树中存在置顶的数据进行排序
*
* @param list 置顶数据
* @param tree 台账树
* @param level 树的层级
* 如果第一层不是工程并且是5层树level = 5 5层树层级必须是 0:设备类型 1:工程 2:项目 3:设备 4:监测点
* 如果第一层是工程level = 4 4层树层级必须是 0:工程 1:项目 2:设备 3:监测点其余层级的树也可以使用level = 4只要是工程、项目、设备、监测点这样的结构就行
*/
void channelTree(List<CsUserPins> list, List<CsLedgerVO> tree, Integer level);
}

View File

@@ -17,6 +17,7 @@ import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.DevCountVO; import com.njcn.csdevice.pojo.vo.DevCountVO;
import com.njcn.csdevice.pojo.vo.DevUserVO; import com.njcn.csdevice.pojo.vo.DevUserVO;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
import com.njcn.csdevice.utils.StringUtil;
import com.njcn.csharmonic.api.EventUserFeignClient; import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
@@ -28,6 +29,7 @@ import com.njcn.user.enums.AppRoleEnum;
import com.njcn.user.pojo.po.User; import com.njcn.user.pojo.po.User;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
@@ -156,7 +158,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
devCountVO.setEningerCount(roleengineer.size()); devCountVO.setEningerCount(roleengineer.size());
} }
List<CsLedgerVO> deviceTree = iCsLedgerService.getDeviceTree(); List<CsLedgerVO> deviceTree = iCsLedgerService.getDeviceTree(null);
//由于多加了一程便携式设备 //由于多加了一程便携式设备
List<String> collect1 = deviceTree.stream() List<String> collect1 = deviceTree.stream()
.map(CsLedgerVO::getChildren).flatMap(Collection::stream) .map(CsLedgerVO::getChildren).flatMap(Collection::stream)
@@ -406,7 +408,12 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
@Override @Override
public List<String> findDevByUserId(String userId) { public List<String> findDevByUserId(String userId) {
List<String> result = new ArrayList<>(); List<String> result = new ArrayList<>();
List<CsDeviceUserPO> list = this.lambdaQuery().eq(CsDeviceUserPO::getPrimaryUserId,userId).list(); LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.and(wrapper ->
wrapper.eq(CsDeviceUserPO::getPrimaryUserId, userId)
.or()
.eq(CsDeviceUserPO::getSubUserId, userId));
List<CsDeviceUserPO> list = this.list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)){ if (CollectionUtil.isNotEmpty(list)){
result = list.stream().map(CsDeviceUserPO::getDeviceId).collect(Collectors.toList()); result = list.stream().map(CsDeviceUserPO::getDeviceId).collect(Collectors.toList());
} }
@@ -416,8 +423,26 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
@Override @Override
public void channelDevByUserId(UserDevParam param) { public void channelDevByUserId(UserDevParam param) {
LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsDeviceUserPO::getPrimaryUserId,param.getUserId()) queryWrapper.and(wrapper ->
.in(CsDeviceUserPO::getDeviceId,param.getList()); wrapper.eq(CsDeviceUserPO::getPrimaryUserId, param.getUserId())
.or()
.eq(CsDeviceUserPO::getSubUserId, param.getUserId())
).in(CsDeviceUserPO::getDeviceId, param.getList());
this.remove(queryWrapper); this.remove(queryWrapper);
} }
@Override
public List<CsDeviceUserPO> getList(UserDevParam param) {
LambdaQueryWrapper<CsDeviceUserPO> queryWrapper = new LambdaQueryWrapper<>();
if (StringUtils.isNotBlank(param.getUserId())) {
queryWrapper.and(wrapper ->
wrapper.eq(CsDeviceUserPO::getPrimaryUserId, param.getUserId())
.or()
.eq(CsDeviceUserPO::getSubUserId, param.getUserId())
);
}
queryWrapper.in(CsDeviceUserPO::getDeviceId, param.getList())
.eq(CsDeviceUserPO::getStatus, "1");
return this.list(queryWrapper);
}
} }

View File

@@ -165,7 +165,7 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryParm.getProvince ()),"province",csEngineeringQueryParm.getProvince ()). queryWrapper.eq (StringUtils.isNotBlank (csEngineeringQueryParm.getProvince ()),"province",csEngineeringQueryParm.getProvince ()).
eq (StringUtils.isNotBlank (csEngineeringQueryParm.getCity ()),"city",csEngineeringQueryParm.getCity ()). eq (StringUtils.isNotBlank (csEngineeringQueryParm.getCity ()),"city",csEngineeringQueryParm.getCity ()).
eq ("status","1" ). eq ("status","1" ).
like (StringUtils.isNotBlank (csEngineeringQueryParm.getName ()),"name",csEngineeringQueryParm.getName ()).orderByDesc("create_time"); like (StringUtils.isNotBlank (csEngineeringQueryParm.getName ()),"name",csEngineeringQueryParm.getName ()).orderByAsc("sort");
List<CsEngineeringPO> csEngineeringPOS = this.getBaseMapper ( ).selectList (queryWrapper); List<CsEngineeringPO> csEngineeringPOS = this.getBaseMapper ( ).selectList (queryWrapper);
csEngineeringVOList = csEngineeringPOS.stream ().map (temp->{ csEngineeringVOList = csEngineeringPOS.stream ().map (temp->{
CsEngineeringVO vo = new CsEngineeringVO(); CsEngineeringVO vo = new CsEngineeringVO();
@@ -297,7 +297,6 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
return this.update(queryWrapper); return this.update(queryWrapper);
} }
public String getAreaById(String id){ public String getAreaById(String id){
String areaName =redisUtil.getStringByKey (id); String areaName =redisUtil.getStringByKey (id);

View File

@@ -48,7 +48,6 @@ import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.enums.DicDataTypeEnum; import com.njcn.system.enums.DicDataTypeEnum;
import com.njcn.system.enums.DicTreeEnum;
import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO; import com.njcn.system.pojo.vo.DictTreeVO;
import com.njcn.user.enums.AppRoleEnum; import com.njcn.user.enums.AppRoleEnum;
@@ -107,6 +106,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
private final CsLedgerMapper csLedgerMapper; private final CsLedgerMapper csLedgerMapper;
private final CsTerminalLogsMapper csTerminalLogsMapper; private final CsTerminalLogsMapper csTerminalLogsMapper;
private final ICsCommunicateService csCommunicateService; private final ICsCommunicateService csCommunicateService;
private final ICsUserPinsService csUserPinsService;
@Override @Override
public void refreshDeviceDataCache() { public void refreshDeviceDataCache() {
@@ -158,7 +158,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csEquipmentProcess.setStatus (1); csEquipmentProcess.setStatus (1);
csEquipmentProcessPOService.save(csEquipmentProcess); csEquipmentProcessPOService.save(csEquipmentProcess);
result = this.save (csEquipmentDeliveryPo); result = this.save (csEquipmentDeliveryPo);
if (result) {
//谁新建的设备,则认为是该设备的主用户,新建用户设备关系表数据
boolean addUser = csDeviceUserPOService.add(csEquipmentDeliveryPo.getId());
if (result && addUser) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
return csEquipmentDeliveryPo; return csEquipmentDeliveryPo;
@@ -232,9 +236,45 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return returnpage; return returnpage;
} }
Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage,projectEquipmentQueryParm,device); Page<ProjectEquipmentVO> list = this.baseMapper.queryProjectEquipmentVO(returnpage,projectEquipmentQueryParm,device);
list.getRecords().stream().forEach(temp->{ //根据设备id获取监测点id集合
List<CsLinePO> lineIds = csLinePOService.getLineByDev(device);
list.getRecords().forEach(temp->{
temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId())); temp.setIsPrimaryUser(csDeviceUserPOService.isPrimaryUser(temp.getEquipmentId()));
//获取设备类型
SysDicTreePO po = dictTreeFeignClient.queryById(temp.getDevType()).getData();
temp.setDevType(po.getCode());
temp.setLineList(lineIds.stream().filter(line -> line.getDevId().equals(temp.getEquipmentId())).sorted(Comparator.comparing(CsLinePO::getLineId)).collect(Collectors.toList()));
}); });
List<ProjectEquipmentVO> recordList = list.getRecords();
//获取用户置顶的设备
List<CsUserPins> topList = csUserPinsService.getPinToTopList();
List<String> targetIdList = topList.stream()
.filter(item -> Objects.equals(item.getTargetType(), 1))
.map(CsUserPins::getTargetId)
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targetIdList)) {
List<ProjectEquipmentVO> matchedList = new ArrayList<>();
List<ProjectEquipmentVO> unmatchedList = new ArrayList<>();
for (ProjectEquipmentVO node : recordList) {
if (targetIdList.contains(node.getEquipmentId())) {
node.setIsTop(1);
matchedList.add(node);
} else {
unmatchedList.add(node);
}
}
// 根据 targetIdList 的顺序对匹配的节点进行排序
matchedList.sort(Comparator.comparingInt(node -> targetIdList.indexOf(node.getEquipmentId())));
// 未匹配的节点按照原有的 sort 字段排序,处理 null 值情况
unmatchedList.sort(Comparator.comparing(node -> node.getSort() != null ? node.getSort() : Integer.MAX_VALUE));
// 清空原列表并添加排序后的数据
recordList.clear();
recordList.addAll(matchedList);
recordList.addAll(unmatchedList);
list.setRecords(recordList);
}
return list; return list;
} }
@@ -385,7 +425,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
dataSet = csDataSetService.findDataSetByModelId(modelId,2); dataSet = csDataSetService.findDataSetByModelId(modelId,2);
} }
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo); setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
} else if(Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode()) || Objects.equals(devTypeCode, DicDataEnum.DEV_CLD.getCode())){ } else if(Objects.equals(devTypeCode, DicDataEnum.PORTABLE.getCode())){
List<CsDataSet> dataSet = new ArrayList<>(); List<CsDataSet> dataSet = new ArrayList<>();
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId); List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)){ if (CollUtil.isNotEmpty(modelId)){
@@ -394,6 +434,15 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
} }
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo); setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
} }
} else if(Objects.equals(devTypeCode, DicDataEnum.DEV_CLD.getCode())){
List<CsDataSet> dataSet = new ArrayList<>();
List<CsDevModelRelationPO> modelId = csDevModelRelationService.findModelByDevId(deviceId);
if (CollUtil.isNotEmpty(modelId)){
for (CsDevModelRelationPO item : modelId) {
dataSet.addAll(csDataSetService.findDataSetByModelId(item.getModelId(),1));
}
setDataSetValues(csEquipmentDeliveryPo, dataSet, dataSetList, type, deviceManagerVo);
}
} }
} }
return deviceManagerVo; return deviceManagerVo;
@@ -733,9 +782,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
boolean result = false; boolean result = false;
//获取装置id //获取装置id
CsEquipmentDeliveryPO po = findDevByNDid(nDid); CsEquipmentDeliveryPO po = findDevByNDid(nDid);
//设备型 //设备
String code = dictTreeFeignClient.queryById(po.getDevModel()).getData().getCode(); String code = dictTreeFeignClient.queryById(po.getDevType()).getData().getCode();
if (Objects.equals(DicTreeEnum.PQ_COM.getCode(),code)) { if (Objects.equals(DicDataEnum.DEV_CLD.getCode(),code) || Objects.equals(DicDataEnum.CONNECT_DEV.getCode(),code)) {
result = true; result = true;
} }
return result; return result;
@@ -751,10 +800,11 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) { public CsEquipmentDeliveryPO saveCld(CsEquipmentDeliveryAddParm param) {
boolean result; boolean result;
CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one(); //设备名称可以重复
if(Objects.nonNull (one)){ //CsEquipmentDeliveryPO one = this.lambdaQuery().eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
throw new BusinessException ("设备名称不能重复"); //if(Objects.nonNull (one)){
} // throw new BusinessException ("设备名称不能重复");
//}
StringUtil.containsSpecialCharacters(param.getNdid()); StringUtil.containsSpecialCharacters(param.getNdid());
CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (param.getNdid()); CsEquipmentDeliveryPO po = this.queryEquipmentPOByndid (param.getNdid());
if(!Objects.isNull (po)){ if(!Objects.isNull (po)){
@@ -800,7 +850,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
csLedger.setSort(0); csLedger.setSort(0);
int addLedger = csLedgerMapper.insert(csLedger); int addLedger = csLedgerMapper.insert(csLedger);
if (result && ObjectUtil.isNotNull(relation) && addLedger > 0) { //谁新建的设备,则认为是该设备的主用户,新建用户设备关系表数据
boolean addUser = csDeviceUserPOService.add(csEquipmentDeliveryPo.getId());
if (result && ObjectUtil.isNotNull(relation) && addLedger > 0 && addUser) {
refreshDeviceDataCache(); refreshDeviceDataCache();
} }
return csEquipmentDeliveryPo; return csEquipmentDeliveryPo;
@@ -1037,6 +1090,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
return result.stream() return result.stream()
.filter(data -> idSet.contains(data.getId())) .filter(data -> idSet.contains(data.getId()))
.collect(Collectors.toList()); .collect(Collectors.toList());
} else {
result.clear();
return result;
} }
} }
return result; return result;

View File

@@ -21,7 +21,7 @@ import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.CsLedgerVO; import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.service.*; import com.njcn.csdevice.service.*;
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient; import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.redis.utils.RedisUtil; import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.AreaFeignClient; import com.njcn.system.api.AreaFeignClient;
import com.njcn.system.api.DictTreeFeignClient; import com.njcn.system.api.DictTreeFeignClient;
@@ -67,12 +67,12 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
private final CsDeviceUserPOMapper csDeviceUserPOMapper; private final CsDeviceUserPOMapper csDeviceUserPOMapper;
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient; private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
private final UserFeignClient userFeignClient; private final UserFeignClient userFeignClient;
private final ICsUserPinsService csUserPinsService;
@Override @Override
public List<CsLedgerVO> getLedgerTree() { public List<CsLedgerVO> getLedgerTree() {
List<CsLedgerVO> list = new ArrayList<>(); List<CsLedgerVO> list = new ArrayList<>();
List<CsLedgerVO> engineeringList = getLineTree(); List<CsLedgerVO> engineeringList = getLineTree(null);
CsLedgerVO vo = new CsLedgerVO(); CsLedgerVO vo = new CsLedgerVO();
vo.setId("9999999"); vo.setId("9999999");
vo.setLevel(0); vo.setLevel(0);
@@ -85,7 +85,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
} }
@Override @Override
public List<CsLedgerVO> getLineTree() { public List<CsLedgerVO> getLineTree(String type) {
List<CsLedgerVO> engineeringList; List<CsLedgerVO> engineeringList;
List<CsLedgerVO> allList = this.baseMapper.getAll(); List<CsLedgerVO> allList = this.baseMapper.getAll();
/*获取用户工程,设备信息过滤*/ /*获取用户工程,设备信息过滤*/
@@ -267,18 +267,131 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
cld.setChildren(engineeringList2); cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>(); List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) { //获取置顶的工程
tree.add(portable); List<CsUserPins> list = csUserPinsService.getPinToTopList();
} if (Objects.equals(type,"engineering")) {
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government); Map<String, CsLedgerVO> engineeringMap = new HashMap<>();
}
if (CollUtil.isNotEmpty(cldDeviceList)) { engineeringList1.forEach(eng -> {
tree.add(cld); CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
engineeringList2.forEach(eng -> {
CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
tree.addAll(new ArrayList<>(engineeringMap.values()));
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0);
portable1.setName("便携式工程");
portable1.setPid("0");
portable1.setId(id);
CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1);
portable2.setName("便携式项目");
portable2.setPid(id);
portable2.setId(IdUtil.simpleUUID());
portable2.setChildren(portables);
portable1.setChildren(Collections.singletonList(portable2));
tree.add(portable1);
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 4);
}
} else {
//按设备类型统计
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
}
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
if (CollUtil.isNotEmpty(cldDeviceList)) {
tree.add(cld);
}
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 5);
}
} }
return tree; return tree;
} }
/**
* 合并两个项目列表,根据项目 ID 去重并合并子节点
*/
private List<CsLedgerVO> mergeProjectList(List<CsLedgerVO> list1, List<CsLedgerVO> list2) {
if (CollectionUtil.isEmpty(list1)) {
return list2 != null ? new ArrayList<>(list2) : new ArrayList<>();
}
if (CollectionUtil.isEmpty(list2)) {
return new ArrayList<>(list1);
}
Map<String, CsLedgerVO> projectMap = new HashMap<>();
list1.forEach(project -> {
projectMap.put(project.getId(), cloneProject(project));
});
list2.forEach(project -> {
CsLedgerVO existingProject = projectMap.get(project.getId());
if (existingProject == null) {
projectMap.put(project.getId(), cloneProject(project));
} else {
List<CsLedgerVO> mergedDevices = new ArrayList<>();
if (existingProject.getChildren() != null) {
mergedDevices.addAll(existingProject.getChildren());
}
if (project.getChildren() != null) {
mergedDevices.addAll(project.getChildren());
}
existingProject.setChildren(mergedDevices);
}
});
return new ArrayList<>(projectMap.values());
}
/**
* 克隆项目对象,避免引用问题
*/
private CsLedgerVO cloneProject(CsLedgerVO project) {
CsLedgerVO cloned = new CsLedgerVO();
cloned.setId(project.getId());
cloned.setPid(project.getPid());
cloned.setLevel(project.getLevel());
cloned.setName(project.getName());
cloned.setType(project.getType());
cloned.setComFlag(project.getComFlag());
cloned.setNDId(project.getNDId());
cloned.setProcess(project.getProcess());
cloned.setLineType(project.getLineType());
cloned.setConType(project.getConType());
cloned.setSort(project.getSort());
if (project.getChildren() != null) {
cloned.setChildren(new ArrayList<>(project.getChildren()));
}
return cloned;
}
//剔除未接入的设备(根据status判断不太稳,所有这里直接判断该设备有没有对应的模板指标) //剔除未接入的设备(根据status判断不太稳,所有这里直接判断该设备有没有对应的模板指标)
private void checkDevSetData(List<CsLedgerVO> ledgerVOS) { private void checkDevSetData(List<CsLedgerVO> ledgerVOS) {
Iterator<CsLedgerVO> iterator = ledgerVOS.iterator(); Iterator<CsLedgerVO> iterator = ledgerVOS.iterator();
@@ -309,7 +422,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
@Override @Override
public List<CsLedgerVO> getDeviceTree() { public List<CsLedgerVO> getDeviceTree(String type) {
List<CsLedgerVO> engineeringList; List<CsLedgerVO> engineeringList;
List<CsLedgerVO> allList = this.baseMapper.getAll(); List<CsLedgerVO> allList = this.baseMapper.getAll();
/*获取用户工程,设备信息过滤*/ /*获取用户工程,设备信息过滤*/
@@ -471,14 +584,69 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
cld.setChildren(engineeringList2); cld.setChildren(engineeringList2);
List<CsLedgerVO> tree = new ArrayList<>(); List<CsLedgerVO> tree = new ArrayList<>();
if (CollUtil.isNotEmpty(portables)) { List<CsUserPins> list = csUserPinsService.getPinToTopList();
tree.add(portable); if (Objects.equals(type,"engineering")) {
Map<String, CsLedgerVO> engineeringMap = new HashMap<>();
engineeringList1.forEach(eng -> {
CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
engineeringList2.forEach(eng -> {
CsLedgerVO existingEng = engineeringMap.get(eng.getId());
if (existingEng == null) {
engineeringMap.put(eng.getId(), eng);
} else {
List<CsLedgerVO> mergedChildren = mergeProjectList(existingEng.getChildren(), eng.getChildren());
existingEng.setChildren(mergedChildren);
}
});
tree.addAll(new ArrayList<>(engineeringMap.values()));
String id = IdUtil.simpleUUID();
CsLedgerVO portable1 = new CsLedgerVO();
portable1.setLevel(0);
portable1.setName("便携式工程");
portable1.setPid("0");
portable1.setId(id);
CsLedgerVO portable2 = new CsLedgerVO();
portable2.setLevel(1);
portable2.setName("便携式项目");
portable2.setPid(id);
portable2.setId(IdUtil.simpleUUID());
portable2.setChildren(portables);
List<CsLedgerVO> portable2List = new ArrayList<>();
portable2List.add(portable2);
portable1.setChildren(portable2List);
tree.add(portable1);
if (CollectionUtil.isNotEmpty(list)) {
csUserPinsService.channelTree(list, tree, 4);
}
} else {
//按设备类型统计
if (CollUtil.isNotEmpty(portables)) {
tree.add(portable);
}
if (CollUtil.isNotEmpty(deviceList)) {
tree.add(government);
}
if (CollUtil.isNotEmpty(cldDevList)) {
tree.add(cld);
}
} }
if (CollUtil.isNotEmpty(deviceList)) { if (CollectionUtil.isNotEmpty(list)) {
tree.add(government); csUserPinsService.channelTree(list, tree, 5);
}
if (CollUtil.isNotEmpty(cldDevList)) {
tree.add(cld);
} }
return tree; return tree;
} }
@@ -575,10 +743,14 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
public DevDetailDTO queryDevDetail(String devId) { public DevDetailDTO queryDevDetail(String devId) {
DevDetailDTO device = new DevDetailDTO(); DevDetailDTO device = new DevDetailDTO();
CsLedger dev = this.findDataById(devId); CsLedger dev = this.findDataById(devId);
//获取设备mac
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(devId);
//如果是便携式设备pid为0,项目,工程都设置为/ //如果是便携式设备pid为0,项目,工程都设置为/
if (Objects.equals(dev.getPid(), "0")) { if (Objects.equals(dev.getPid(), "0")) {
device.setEquipmentName(dev.getName()); device.setEquipmentName(dev.getName());
device.setEquipmentId(devId); device.setEquipmentId(devId);
device.setDevMac(po.getMac());
device.setProjectId("/"); device.setProjectId("/");
device.setProjectName("/"); device.setProjectName("/");
device.setEngineeringid("/"); device.setEngineeringid("/");
@@ -586,11 +758,11 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
} else { } else {
device.setEquipmentName(dev.getName()); device.setEquipmentName(dev.getName());
device.setEquipmentId(devId); device.setEquipmentId(devId);
device.setDevMac(po.getMac());
CsLedger project = this.findDataById(dev.getPid()); CsLedger project = this.findDataById(dev.getPid());
if (ObjectUtil.isNotNull(project)) { if (ObjectUtil.isNotNull(project)) {
device.setProjectId(project.getId()); device.setProjectId(project.getId());
device.setProjectName(project.getName()); device.setProjectName(project.getName());
CsLedger engineer = this.findDataById(project.getPid()); CsLedger engineer = this.findDataById(project.getPid());
if (ObjectUtil.isNotNull(engineer)) { if (ObjectUtil.isNotNull(engineer)) {
device.setEngineeringid(engineer.getId()); device.setEngineeringid(engineer.getId());
@@ -972,100 +1144,210 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
@Override @Override
public CsLedgerVO cldTree() { 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(); List<CsLedgerVO> allList = this.baseMapper.getAll();
if (CollectionUtil.isNotEmpty(allList)) { if (CollectionUtil.isEmpty(allList)) {
//工程集合 CsLedgerVO government = new CsLedgerVO();
List<CsLedgerVO> tree1 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode())).collect(Collectors.toList()); government.setLevel(0);
//项目集合 government.setName(DataParam.cldDev);
List<CsLedgerVO> tree2 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode())).collect(Collectors.toList()); government.setPid("0");
//设备集合 government.setId(IdUtil.simpleUUID());
List<CsLedgerVO> tree3 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode())).collect(Collectors.toList()); government.setChildren(new ArrayList<>());
//监测点集合 return government;
List<CsLedgerVO> tree4 = allList.stream().filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode())).collect(Collectors.toList()); }
//筛选出云前置设备 DictTreeVO cldDict = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
if (CollectionUtil.isNotEmpty(tree3)) { String cldDevTypeId = cldDict.getId();
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设备 List<CsLedgerVO> engineeringList = allList.stream()
devs.forEach(item -> { .filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode()))
if (item.getDevType().equals(vo1.getId())) { .collect(Collectors.toList());
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()); List<CsLedgerVO> projectList = allList.stream()
Set<String> proList = tree6.stream().map(CsLedgerVO::getPid).collect(Collectors.toSet()); .filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()))
engineerTree = tree1.stream().filter(vo -> !proList.contains(vo.getId())).collect(Collectors.toList()); .collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(list1)) { List<CsLedgerVO> deviceList = allList.stream()
deviceTree = tree3.stream() .filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode()))
.filter(vo -> list1.contains(vo.getId())) .collect(Collectors.toList());
.peek(item -> {
CsEquipmentDeliveryPO dev = devsMap.get(item.getId());
if (dev != null) {
item.setComFlag(dev.getRunStatus());
}
})
.collect(Collectors.toList());
lineTree = tree4.stream() List<CsLedgerVO> lineList = allList.stream()
.filter(vo -> list1.contains(vo.getPid())) .filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
.peek(item -> { .collect(Collectors.toList());
CsEquipmentDeliveryPO dev = devsMap.get(item.getId());
if (dev != null) { if (CollectionUtil.isEmpty(deviceList)) {
item.setComFlag(dev.getRunStatus()); CsLedgerVO government = new CsLedgerVO();
} government.setLevel(0);
}) government.setName(DataParam.cldDev);
.collect(Collectors.toList()); government.setPid("0");
government.setId(IdUtil.simpleUUID());
government.setChildren(engineeringList);
return government;
}
List<String> devIds = deviceList.stream().map(CsLedgerVO::getId).collect(Collectors.toList());
List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devIds);
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
Map<String, String> lineDevMap = lineList.stream().collect(Collectors.toMap(CsLedgerVO::getId, CsLedgerVO::getPid));
Set<String> cldDevIds = devs.stream()
.filter(item -> item.getDevType().equals(cldDevTypeId))
.map(CsEquipmentDeliveryPO::getId)
.collect(Collectors.toSet());
Map<String, List<CsLedgerVO>> projectToDeviceMap = deviceList.stream()
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
Map<String, List<CsLedgerVO>> deviceToLineMap = lineList.stream()
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
deviceList.forEach(device -> {
CsEquipmentDeliveryPO dev = devsMap.get(device.getId());
if (dev != null) {
device.setComFlag(dev.getRunStatus());
}
});
lineList.forEach(line -> {
String devId = lineDevMap.get(line.getId());
if (devId != null) {
CsEquipmentDeliveryPO dev = devsMap.get(devId);
if (dev != null) {
line.setComFlag(dev.getRunStatus());
} }
} }
} });
if (CollectionUtil.isNotEmpty(deviceTree)) { engineeringList.forEach(engineering -> {
List<CsLedgerVO> finalLineTree = lineTree; List<CsLedgerVO> projectChildren = new ArrayList<>();
deviceTree.forEach(item -> { for (CsLedgerVO project : projectList) {
item.setChildren(getChildren(item, finalLineTree)); if (project.getPid().equals(engineering.getId())) {
}); List<CsLedgerVO> projectDevices = projectToDeviceMap.getOrDefault(project.getId(), new ArrayList<>());
} if (CollectionUtil.isNotEmpty(projectDevices)) {
if (CollectionUtil.isNotEmpty(projectTree)) { List<CsLedgerVO> deviceChildren = new ArrayList<>();
List<CsLedgerVO> finalDeviceTree = deviceTree; for (CsLedgerVO device : projectDevices) {
projectTree.forEach(item -> { if (cldDevIds.contains(device.getId())) {
item.setChildren(getChildren(item, finalDeviceTree)); List<CsLedgerVO> lineChildren = deviceToLineMap.getOrDefault(device.getId(), new ArrayList<>());
}); device.setChildren(lineChildren);
} deviceChildren.add(device);
if (CollectionUtil.isNotEmpty(engineerTree)) { }
List<CsLedgerVO> finalProjectTree = projectTree; }
engineerTree.forEach(item -> { project.setChildren(deviceChildren);
item.setChildren(getChildren(item, finalProjectTree)); }
}); projectChildren.add(project);
} }
}
engineering.setChildren(projectChildren);
});
CsLedgerVO government = new CsLedgerVO(); CsLedgerVO government = new CsLedgerVO();
government.setLevel(0); government.setLevel(0);
government.setName(DataParam.cldDev); government.setName(DataParam.cldDev);
government.setPid("0"); government.setPid("0");
government.setId(IdUtil.simpleUUID()); government.setId(IdUtil.simpleUUID());
government.setChildren(engineerTree); government.setChildren(engineeringList);
return government; return government;
} }
// @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);
// Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
// 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()))
// .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());
// }
// }
// }
//
// 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;
// }
@Override @Override
public List<DevDetailDTO> getInfoByIds(List<String> list) { public List<DevDetailDTO> getInfoByIds(List<String> list) {
List<DevDetailDTO> details = new ArrayList<>(); List<DevDetailDTO> details = new ArrayList<>();
@@ -1100,20 +1382,47 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
@Override @Override
public List<DevDetailDTO> getDevInfoByEngineerIds(List<String> list) { public List<DevDetailDTO> getDevInfoByEngineerIds(List<String> list) {
List<DevDetailDTO> details = new ArrayList<>(); List<DevDetailDTO> details = new ArrayList<>();
//工程
LambdaQueryWrapper<CsLedger> queryWrapper0 = new LambdaQueryWrapper<>();
queryWrapper0.in(CsLedger::getId, list);
List<CsLedger> engineering = this.list(queryWrapper0);
Map<String, CsLedger> engineeringMap = engineering.stream().collect(Collectors.toMap(CsLedger::getId, item -> item));
//项目
LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(CsLedger::getPid, list); queryWrapper.in(CsLedger::getPid, list);
List<CsLedger> project = this.list(queryWrapper); List<CsLedger> project = this.list(queryWrapper);
//工程id Map<String, CsLedger> projectMap = project.stream().collect(Collectors.toMap(CsLedger::getId, item -> item));
//设备
List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList()); List<String> projectIds = project.stream().map(CsLedger::getId).collect(Collectors.toList());
LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>(); LambdaQueryWrapper<CsLedger> queryWrapper2 = new LambdaQueryWrapper<>();
queryWrapper2.in(CsLedger::getPid, projectIds); queryWrapper2.in(CsLedger::getPid, projectIds);
List<CsLedger> dev = this.list(queryWrapper2); List<CsLedger> dev = this.list(queryWrapper2);
dev.forEach(item -> {
DevDetailDTO detail = new DevDetailDTO(); if (CollectionUtil.isNotEmpty(dev)) {
detail.setEquipmentName(item.getName()); List<String> devIds = dev.stream().map(CsLedger::getId).collect(Collectors.toList());
detail.setEquipmentId(item.getId()); List<CsEquipmentDeliveryPO> devs = csEquipmentDeliveryMapper.selectBatchIds(devIds);
details.add(detail); Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, item -> item));
});
dev.forEach(item -> {
DevDetailDTO detail = new DevDetailDTO();
detail.setEquipmentName(item.getName());
detail.setEquipmentId(item.getId());
CsLedger csLedger = projectMap.get(item.getPid());
detail.setProjectId(csLedger.getId());
detail.setProjectName(csLedger.getName());
CsLedger csLedger1 = engineeringMap.get(csLedger.getPid());
detail.setEngineeringid(csLedger1.getId());
detail.setEngineeringName(csLedger1.getName());
detail.setRunStatus(devsMap.get(item.getId()).getRunStatus());
details.add(detail);
});
}
return details; return details;
} }

View File

@@ -16,6 +16,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.utils.PubUtils; import com.njcn.common.utils.PubUtils;
import com.njcn.csdevice.enums.LineBaseEnum; import com.njcn.csdevice.enums.LineBaseEnum;
import com.njcn.csdevice.mapper.*; import com.njcn.csdevice.mapper.*;
import com.njcn.csdevice.pojo.dto.CsLineDTO;
import com.njcn.csdevice.pojo.param.CsLineParam; import com.njcn.csdevice.pojo.param.CsLineParam;
import com.njcn.csdevice.pojo.po.*; import com.njcn.csdevice.pojo.po.*;
import com.njcn.csdevice.pojo.vo.LineDetailDataVO; import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
@@ -24,7 +25,7 @@ import com.njcn.csdevice.service.CsDevModelService;
import com.njcn.csdevice.service.CsLinePOService; import com.njcn.csdevice.service.CsLinePOService;
import com.njcn.csdevice.service.ICsDataSetService; import com.njcn.csdevice.service.ICsDataSetService;
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient; import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.oss.constant.OssPath; import com.njcn.oss.constant.OssPath;
import com.njcn.oss.utils.FileStorageUtil; import com.njcn.oss.utils.FileStorageUtil;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
@@ -153,8 +154,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
List<CsDataSet> list = csDataSetService.findDataSetByModelId(po1.getId()); List<CsDataSet> list = csDataSetService.findDataSetByModelId(po1.getId());
if (CollectionUtil.isNotEmpty(list)) { if (CollectionUtil.isNotEmpty(list)) {
po.setDataSetId(list.get(0).getId()); po.setDataSetId(list.get(0).getId());
po.setClDid(list.get(0).getClDev());
} }
po.setClDid(param.getLineNo());
//监测位置 //监测位置
//DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData(); //DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
po.setPosition(param.getPosition()); po.setPosition(param.getPosition());
@@ -270,6 +271,11 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@Override
public List<CsLineDTO> getAllLineDetail() {
return this.baseMapper.findLineList();
}
@Override @Override
public List<CsLinePO> getSimpleLine() { public List<CsLinePO> getSimpleLine() {
List<String> devIds = commGetDevIds(RequestUtil.getUserIndex()); List<String> devIds = commGetDevIds(RequestUtil.getUserIndex());

View File

@@ -0,0 +1,184 @@
package com.njcn.csdevice.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.csdevice.mapper.CsUserPinsMapper;
import com.njcn.csdevice.param.CsUserPinsParam;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.service.ICsUserPinsService;
import com.njcn.web.utils.RequestUtil;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/**
* <p>
* 用户置顶表 服务实现类
* </p>
*
* @author xy
* @since 2026-03-04
*/
@Service
public class CsUserPinsServiceImpl extends ServiceImpl<CsUserPinsMapper, CsUserPins> implements ICsUserPinsService {
@Override
public boolean engineeringPinToTop(CsUserPinsParam param) {
LambdaUpdateWrapper<CsUserPins> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(CsUserPins::getUserId, param.getUserId())
.eq(CsUserPins::getTargetId, param.getTargetId())
.eq(CsUserPins::getTargetType, param.getTargetType());
CsUserPins csUserPins = this.getOne(wrapper);
//为空,则是置顶
if (Objects.isNull(csUserPins)) {
CsUserPins po = new CsUserPins();
BeanUtils.copyProperties(param, po);
this.save(po);
}
//有数据则是取消置顶
else {
this.removeById(csUserPins.getId());
}
return true;
}
@Override
public List<CsUserPins> getPinToTopList() {
LambdaUpdateWrapper<CsUserPins> wrapper = new LambdaUpdateWrapper<>();
wrapper.eq(CsUserPins::getUserId, RequestUtil.getUserIndex())
.orderByDesc(CsUserPins::getCreateTime);
return this.list(wrapper);
}
@Override
public void channelTree(List<CsUserPins> list, List<CsLedgerVO> tree, Integer level) {
List<String> targetIdList = new ArrayList<>();
List<String> devList = new ArrayList<>();
switch (level) {
case 1:
break;
case 2:
break;
case 3:
break;
case 4:
// 处理工程置顶(第一层)
targetIdList = list.stream()
.filter(item -> Objects.equals(item.getTargetType(), 2))
.map(CsUserPins::getTargetId)
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targetIdList)) {
sortByTargetList(tree, targetIdList);
}
// 处理设备置顶(第三层)
devList = list.stream()
.filter(item -> Objects.equals(item.getTargetType(), 1))
.map(CsUserPins::getTargetId)
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(devList)) {
// 遍历 tree找到第三层的数据进行排序
for (CsLedgerVO firstLevelNode : tree) {
if (firstLevelNode.getLevel() == 0 && CollectionUtil.isNotEmpty(firstLevelNode.getChildren())) {
// 第二层
for (CsLedgerVO secondLevelNode : firstLevelNode.getChildren()) {
if (CollectionUtil.isNotEmpty(secondLevelNode.getChildren())) {
// 第三层
sortByTargetList(secondLevelNode.getChildren(), devList);
}
}
}
}
}
break;
case 5:
// 处理工程置顶(第二层,因为最上面加了一层)
targetIdList = list.stream()
.filter(item -> Objects.equals(item.getTargetType(), 2))
.map(CsUserPins::getTargetId)
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targetIdList)) {
sortSecondLevelByTargetList(tree, targetIdList);
}
// 处理设备置顶(第四层)
devList = list.stream()
.filter(item -> Objects.equals(item.getTargetType(), 1))
.map(CsUserPins::getTargetId)
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(devList)) {
sortFourthLevelByDevList(tree, devList);
}
break;
default:
break;
}
}
/**
* 根据目标 ID 列表对节点列表进行排序
* @param nodeList 需要排序的节点列表
* @param targetIdList 目标 ID 列表(决定排序顺序)
*/
private void sortByTargetList(List<CsLedgerVO> nodeList, List<String> targetIdList) {
// 分离出匹配 targetIdList 的节点和未匹配的节点
List<CsLedgerVO> matchedList = new ArrayList<>();
List<CsLedgerVO> unmatchedList = new ArrayList<>();
for (CsLedgerVO node : nodeList) {
if (targetIdList.contains(node.getId())) {
node.setIsTop(1);
matchedList.add(node);
} else {
unmatchedList.add(node);
}
}
// 根据 targetIdList 的顺序对匹配的节点进行排序
matchedList.sort(Comparator.comparingInt(node -> targetIdList.indexOf(node.getId())));
// 未匹配的节点按照原有的 sort 字段排序,处理 null 值情况
unmatchedList.sort(Comparator.comparing(node -> node.getSort() != null ? node.getSort() : Integer.MAX_VALUE));
// 清空原列表并添加排序后的数据
nodeList.clear();
nodeList.addAll(matchedList);
nodeList.addAll(unmatchedList);
}
/**
* 根据目标 ID 列表对第二层节点进行排序(因为最上面加了一层)
*/
private void sortSecondLevelByTargetList(List<CsLedgerVO> tree, List<String> targetIdList) {
for (CsLedgerVO firstLevelNode : tree) {
if (CollectionUtil.isNotEmpty(firstLevelNode.getChildren())) {
sortByTargetList(firstLevelNode.getChildren(), targetIdList);
}
}
}
/**
* 根据设备 ID 列表对第四层节点进行排序
*/
private void sortFourthLevelByDevList(List<CsLedgerVO> tree, List<String> devList) {
for (CsLedgerVO firstLevelNode : tree) {
if (CollectionUtil.isNotEmpty(firstLevelNode.getChildren())) {
for (CsLedgerVO secondLevelNode : firstLevelNode.getChildren()) {
if (CollectionUtil.isNotEmpty(secondLevelNode.getChildren())) {
for (CsLedgerVO thirdLevelNode : secondLevelNode.getChildren()) {
if (CollectionUtil.isNotEmpty(thirdLevelNode.getChildren())) {
// 第四层
sortByTargetList(thirdLevelNode.getChildren(), devList);
}
}
}
}
}
}
}
}

View File

@@ -31,8 +31,10 @@ import com.njcn.mq.message.BZEventMessage;
import com.njcn.mq.template.BZEventMessageTemplate; import com.njcn.mq.template.BZEventMessageTemplate;
import com.njcn.redis.pojo.enums.AppRedisKey; import com.njcn.redis.pojo.enums.AppRedisKey;
import com.njcn.redis.utils.RedisUtil; import com.njcn.redis.utils.RedisUtil;
import com.njcn.system.api.DictTreeFeignClient;
import com.njcn.system.enums.DicDataEnum; import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.SysDicTreePO; import com.njcn.system.pojo.po.SysDicTreePO;
import com.njcn.system.pojo.vo.DictTreeVO;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@@ -63,6 +65,7 @@ class IcdServiceImpl implements IcdService {
private final ICsTerminalLogsService csTerminalLogsService; private final ICsTerminalLogsService csTerminalLogsService;
private final ICsTerminalReplyService csTerminalReplyService; private final ICsTerminalReplyService csTerminalReplyService;
private final OverLimitWlMapper overLimitWlMapper; private final OverLimitWlMapper overLimitWlMapper;
private final DictTreeFeignClient dictTreeFeignClient;
private final DateTimeFormatter microsecondFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS"); private final DateTimeFormatter microsecondFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss.SSSSSS");
@Override @Override
@@ -537,7 +540,13 @@ class IcdServiceImpl implements IcdService {
// 设置设备信息 // 设置设备信息
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getDevListByProjectId(id); List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getDevListByProjectId(id);
if (CollectionUtil.isNotEmpty(devList)) { if (CollectionUtil.isNotEmpty(devList)) {
vo.setDeviceInfoList(devList); //如果不是监测设备,则不展示
DictTreeVO cldDict = dictTreeFeignClient.queryByCode(DicDataEnum.DEV_CLD.getCode()).getData();
String cldDevTypeId = cldDict.getId();
List<CsEquipmentDeliveryPO> cldDevIds = devList.stream()
.filter(item -> item.getDevType().equals(cldDevTypeId))
.collect(Collectors.toList());
vo.setDeviceInfoList(cldDevIds);
} }
} }

View File

@@ -62,6 +62,11 @@
<artifactId>common-poi</artifactId> <artifactId>common-poi</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>com.njcn</groupId>
<artifactId>harmonic-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> </dependencies>
<properties> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

View File

@@ -0,0 +1,42 @@
package com.njcn.csharmonic.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.response.HttpResult;
import com.njcn.csharmonic.api.fallback.CsAlarmFeignClientFallbackFactory;
import com.njcn.csharmonic.pojo.po.CsAlarm;
import io.swagger.annotations.ApiImplicitParam;
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.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csAlarm", fallbackFactory = CsAlarmFeignClientFallbackFactory.class,contextId = "csAlarm")
public interface CsAlarmFeignClient {
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addList")
@ApiOperation("批量写入数据")
@ApiImplicitParam(name = "list", value = "参数", required = true)
HttpResult<Boolean> addList(@RequestBody List<CsAlarm> list);
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryListByTime")
@ApiOperation("按日期查询数据")
@ApiImplicitParam(name = "time", value = "时间", required = true)
HttpResult<List<CsAlarm>> queryListByTime(@RequestParam("time") String time);
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deleteListByTime")
@ApiOperation("按日期删除数据")
@ApiImplicitParam(name = "time", value = "时间", required = true)
HttpResult<Boolean> deleteListByTime(@RequestParam("time") String time);
}

View File

@@ -0,0 +1,34 @@
package com.njcn.csharmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.CsHarmonicFeignClientFallbackFactory;
import com.njcn.csharmonic.pojo.po.CsHarmonic;
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.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/csHarmonic", fallbackFactory = CsHarmonicFeignClientFallbackFactory.class,contextId = "csHarmonic")
public interface CsHarmonicFeignClient {
@PostMapping("/addList")
@ApiOperation("批量写入数据")
HttpResult<Boolean> addList(@RequestBody List<CsHarmonic> list);
@PostMapping("/queryListByTime")
@ApiOperation("按日期查询数据")
HttpResult<List<CsHarmonic>> queryListByTime(@RequestParam(value = "time") String time);
@PostMapping("/deleteListByTime")
@ApiOperation("按日期删除数据")
HttpResult<Boolean> deleteListByTime(@RequestParam(value = "time") String time);
}

View File

@@ -1,19 +1,13 @@
package com.njcn.csharmonic.api; package com.njcn.csharmonic.api;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 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.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.pojo.response.HttpResult;
import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO; import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.api.fallback.EventFeignClientFallbackFactory; import com.njcn.csharmonic.api.fallback.EventFeignClientFallbackFactory;
import com.njcn.csharmonic.param.CsEventUserQueryPage; 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.CsEventPO;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
@@ -40,4 +34,11 @@ public interface EventFeignClient {
@PostMapping("/getEventByTime") @PostMapping("/getEventByTime")
HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(name = "lineList", required = false) List<String> lineList,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime); HttpResult<List<CsEventPO>> getEventByTime(@RequestParam(name = "lineList", required = false) List<String> lineList,@RequestParam("startTime") String startTime,@RequestParam("endTime") String endTime);
@PostMapping("/getDevAlarmList")
HttpResult<List<CsEventPO>> getDevAlarmList(@RequestBody CsEventUserQueryParam param);
@PostMapping("/getEventByIdList")
HttpResult<List<CsEventPO>> getEventByIdList(@RequestBody List<String> list);
} }

View File

@@ -4,6 +4,7 @@ import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory; import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@@ -20,4 +21,10 @@ public interface EventUserFeignClient {
@PostMapping("/queryEventList") @PostMapping("/queryEventList")
HttpResult<List<EventDetailVO>> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) ; HttpResult<List<EventDetailVO>> queryEventList(@RequestBody CsEventUserQueryParam csEventUserQueryParam) ;
@PostMapping("/addUserEventList")
HttpResult<Boolean> addUserEventList(@RequestBody List<CsEventUserPO> list);
@PostMapping("/deleteByIds")
HttpResult<Boolean> deleteByIds(@RequestBody List<String> eventList);
} }

View File

@@ -3,7 +3,7 @@ package com.njcn.csharmonic.api;
import com.njcn.common.pojo.constant.ServerInfo; import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory; import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import org.springframework.cloud.openfeign.FeignClient; import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;

View File

@@ -0,0 +1,36 @@
package com.njcn.csharmonic.api;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.csharmonic.api.fallback.RStatLimitRateDClientFallbackFactory;
import com.njcn.csharmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
import io.swagger.annotations.ApiImplicitParam;
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 java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "", fallbackFactory = RStatLimitRateDClientFallbackFactory.class,contextId = "")
public interface RStatLimitRateDFeignClient {
@PostMapping("/limitRateD/monitorIdsGetLimitRateInfo")
HttpResult<List<RStatLimitRateDPO>> monitorIdsGetLimitRateInfo(@RequestBody RStatLimitQueryParam rStatLimitQueryParam);
@PostMapping("/harmonic/getLinesRate")
HttpResult<List<RStatLimitRateDPO>> getLinesRate(@RequestBody StatSubstationBizBaseParam param);
}

View File

@@ -0,0 +1,24 @@
package com.njcn.csharmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.SysExcelClientFallbackFactory;
import com.njcn.harmonic.pojo.po.excel.SysExcel;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/sysExcel", fallbackFactory = SysExcelClientFallbackFactory.class,contextId = "sysExcel")
public interface SysExcelFeignClient {
@PostMapping("/querySysExcel")
@ApiOperation("查询")
HttpResult<List<SysExcel>> querySysExcel();
}

View File

@@ -0,0 +1,23 @@
package com.njcn.csharmonic.api;
import com.njcn.common.pojo.constant.ServerInfo;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.fallback.SysExcelRelationClientFallbackFactory;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import java.util.List;
/**
* @author xy
*/
@FeignClient(value = ServerInfo.CS_HARMONIC_BOOT, path = "/sysExcelRelation", fallbackFactory = SysExcelRelationClientFallbackFactory.class,contextId = "sysExcelRelation")
public interface SysExcelRelationFeignClient {
@PostMapping("/queryList")
HttpResult<List<ReportTemplateVO>> queryList(@RequestParam("id") String id);
}

View File

@@ -0,0 +1,49 @@
package com.njcn.csharmonic.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.csharmonic.api.CsAlarmFeignClient;
import com.njcn.csharmonic.pojo.po.CsAlarm;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class CsAlarmFeignClientFallbackFactory implements FallbackFactory<CsAlarmFeignClient> {
@Override
public CsAlarmFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsAlarmFeignClient() {
@Override
public HttpResult<Boolean> addList(List<CsAlarm> list) {
log.error("{}异常,降级处理,异常为:{}","批量写入数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsAlarm>> queryListByTime(String time) {
log.error("{}异常,降级处理,异常为:{}","按日期查询数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> deleteListByTime(String time) {
log.error("{}异常,降级处理,异常为:{}","按日期删除数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,48 @@
package com.njcn.csharmonic.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.csharmonic.api.CsHarmonicFeignClient;
import com.njcn.csharmonic.pojo.po.CsHarmonic;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class CsHarmonicFeignClientFallbackFactory implements FallbackFactory<CsHarmonicFeignClient> {
@Override
public CsHarmonicFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new CsHarmonicFeignClient() {
@Override
public HttpResult<Boolean> addList(List<CsHarmonic> list) {
log.error("{}异常,降级处理,异常为:{}","批量写入数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsHarmonic>> queryListByTime(String time) {
log.error("{}异常,降级处理,异常为:{}","按日期查询数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> deleteListByTime(String time) {
log.error("{}异常,降级处理,异常为:{}","按日期删除数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -7,6 +7,7 @@ import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csdevice.pojo.vo.DataGroupEventVO; import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
import com.njcn.csharmonic.api.EventFeignClient; import com.njcn.csharmonic.api.EventFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryPage; 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.CsEventPO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -58,6 +59,18 @@ public class EventFeignClientFallbackFactory implements FallbackFactory<EventFei
log.error("{}异常,降级处理,异常为:{}","根据时间获取无波形的暂态事件",cause.toString()); log.error("{}异常,降级处理,异常为:{}","根据时间获取无波形的暂态事件",cause.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<List<CsEventPO>> getDevAlarmList(CsEventUserQueryParam param) {
log.error("{}异常,降级处理,异常为:{}","获取设备运行告警事件数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<CsEventPO>> getEventByIdList(List<String> list) {
log.error("{}异常,降级处理,异常为:{}","根据事件id集合获取事件详情异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.EventUserFeignClient; import com.njcn.csharmonic.api.EventUserFeignClient;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -32,6 +33,18 @@ public class EventUserFeignClientFallbackFactory implements FallbackFactory<Even
log.error("{}异常,降级处理,异常为:{}","获取当天事件未读消息未读消息",cause.toString()); log.error("{}异常,降级处理,异常为:{}","获取当天事件未读消息未读消息",cause.toString());
throw new BusinessException(finalExceptionEnum); throw new BusinessException(finalExceptionEnum);
} }
@Override
public HttpResult<Boolean> addUserEventList(List<CsEventUserPO> list) {
log.error("{}异常,降级处理,异常为:{}","新增数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<Boolean> deleteByIds(List<String> eventList) {
log.error("{}异常,降级处理,异常为:{}","根据id删除数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
}; };
} }
} }

View File

@@ -5,7 +5,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient; import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import feign.hystrix.FallbackFactory; import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;

View File

@@ -0,0 +1,44 @@
package com.njcn.csharmonic.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.csharmonic.api.RStatLimitRateDFeignClient;
import com.njcn.csharmonic.pojo.param.RStatLimitQueryParam;
import com.njcn.csharmonic.pojo.param.StatSubstationBizBaseParam;
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class RStatLimitRateDClientFallbackFactory implements FallbackFactory<RStatLimitRateDFeignClient> {
@Override
public RStatLimitRateDFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new RStatLimitRateDFeignClient() {
@Override
public HttpResult<List<RStatLimitRateDPO>> monitorIdsGetLimitRateInfo(RStatLimitQueryParam rStatLimitQueryParam) {
log.error("{}异常,降级处理,异常为:{}","获取指定日期超标监测点详细信息数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
@Override
public HttpResult<List<RStatLimitRateDPO>> getLinesRate(StatSubstationBizBaseParam param) {
log.error("{}异常,降级处理,异常为:{}","获取越限监测点越限次数异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,37 @@
package com.njcn.csharmonic.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.csharmonic.api.SysExcelFeignClient;
import com.njcn.harmonic.pojo.po.excel.SysExcel;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class SysExcelClientFallbackFactory implements FallbackFactory<SysExcelFeignClient> {
@Override
public SysExcelFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new SysExcelFeignClient() {
@Override
public HttpResult<List<SysExcel>> querySysExcel() {
log.error("{}异常,降级处理,异常为:{}","查询模板信息异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -0,0 +1,37 @@
package com.njcn.csharmonic.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.csharmonic.api.SysExcelRelationFeignClient;
import com.njcn.harmonic.common.pojo.vo.ReportTemplateVO;
import feign.hystrix.FallbackFactory;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@Component
public class SysExcelRelationClientFallbackFactory implements FallbackFactory<SysExcelRelationFeignClient> {
@Override
public SysExcelRelationFeignClient create(Throwable cause) {
//判断抛出异常是否为解码器抛出的业务异常
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
if (cause.getCause() instanceof BusinessException) {
BusinessException businessException = (BusinessException) cause.getCause();
}
Enum<?> finalExceptionEnum = exceptionEnum;
return new SysExcelRelationFeignClient() {
@Override
public HttpResult<List<ReportTemplateVO>> queryList(String id) {
log.error("{}异常,降级处理,异常为:{}","查询模板关系数据异常",cause.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -45,4 +45,7 @@ public class CsEventUserQueryPage extends CsEventUserQueryParam{
@ApiModelProperty(value = "测点id") @ApiModelProperty(value = "测点id")
private String lineId; private String lineId;
@ApiModelProperty(value = "排序字段 0:发生时间 1:幅值 2:持续时间")
private Integer sortField;
} }

View File

@@ -0,0 +1,16 @@
package com.njcn.csharmonic.pojo.dto;
import lombok.Data;
import java.io.Serializable;
@Data
public class PhaseData implements Serializable {
public String time;
public String value;
public String phasic;
public String valueType;
public double overLimitValue;
}

View File

@@ -0,0 +1,17 @@
package com.njcn.csharmonic.pojo.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author xy
*/
@Data
public class UnReadEventDto implements Serializable {
private String deviceId;
private Integer count;
}

View File

@@ -0,0 +1,51 @@
package com.njcn.csharmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDate;
/**
* <p>
*
* </p>
*
* @author xy
* @since 2026-03-16
*/
@Getter
@Setter
@TableName("cs_alarm")
public class CsAlarm implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 告警事件id
*/
private String id;
/**
* 设备id集合
*/
private String devList;
/**
* 发生时间
*/
private LocalDate time;
/**
* 中断事件描述
*/
private String interruptEvent;
/**
* 中断事件描述
*/
private String alarmEvent;
}

View File

@@ -0,0 +1,46 @@
package com.njcn.csharmonic.pojo.po;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Getter;
import lombok.Setter;
import java.io.Serializable;
import java.time.LocalDate;
/**
* <p>
*
* </p>
*
* @author xy
* @since 2026-03-13
*/
@Getter
@Setter
@TableName("cs_harmonic")
public class CsHarmonic implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 稳态事件id
*/
private String id;
/**
* 监测点id
*/
private String lineId;
/**
* 发生时间
*/
private LocalDate time;
/**
* 事件描述
*/
private String tag;
}

View File

@@ -12,7 +12,7 @@ import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;
/** /**
* <p> * <p>
* * 该实体类已废弃使用com.njcn.device.biz.pojo.po包下的PqSensitiveUser
* </p> * </p>
* *
* @author xy * @author xy
@@ -21,6 +21,7 @@ import static com.baomidou.mybatisplus.annotation.IdType.ASSIGN_ID;
@Getter @Getter
@Setter @Setter
@TableName("pq_sensitive_user") @TableName("pq_sensitive_user")
@Deprecated
public class PqSensitiveUser extends BaseEntity implements Serializable{ public class PqSensitiveUser extends BaseEntity implements Serializable{
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;

View File

@@ -0,0 +1,70 @@
package com.njcn.csharmonic.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
/**
* @author xy
*/
@Data
public class AlarmVO implements Serializable {
@ApiModelProperty(value = "事件id")
private String eventId;
@ApiModelProperty(value = "时间")
private String date;
@ApiModelProperty(value = "告警设备台数")
private Integer warnNums;
@ApiModelProperty(value = "告警设备id集合")
private List<String> devIds;
@ApiModelProperty(value = "是否读取 0:未读取 1:读取")
private Integer isRead;
@Data
public static class AlarmDetail implements Serializable {
@ApiModelProperty(value = "工程名称")
private String engineeringName;
@ApiModelProperty(value = "项目名称")
private String projectName;
@ApiModelProperty(value = "设备名称")
private String devName;
@ApiModelProperty(value = "告警次数")
private Integer warnCounts = 0;
@ApiModelProperty(value = "告警详情")
private List<WarnDetail> warnDetails = new ArrayList<>();
@ApiModelProperty(value = "中断次数")
private Integer interruptCounts = 0;
@ApiModelProperty(value = "中断详情")
private List<String> interruptDetails = new ArrayList<>();
@Data
public static class WarnDetail implements Serializable {
@ApiModelProperty(value = "告警事件时间")
private String warnEventTime;
@ApiModelProperty(value = "告警事件描述")
private String warnEventDesc;
}
}
}

View File

@@ -0,0 +1,54 @@
package com.njcn.csharmonic.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.List;
/**
* @author xy
*/
@Data
public class HarmonicDetailVO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "指标")
private String targetName;
@ApiModelProperty(value = "越限详情")
private List<HarmDetail> harmDetailList;
@Data
public static class HarmDetail implements Serializable {
@ApiModelProperty(value = "越限时间")
private String statisticsTime;
@ApiModelProperty(value = "数据类型")
private String valueType;
@ApiModelProperty(value = "A相数据")
private String dataA;
@ApiModelProperty(value = "B相数据")
private String dataB;
@ApiModelProperty(value = "C相数据")
private String dataC;
@ApiModelProperty(value = "总相数据")
private String dataT;
@ApiModelProperty(value = "限值")
private Double overLimitData;
@ApiModelProperty(value = "是否有T相")
private Boolean hasT;
}
}

View File

@@ -0,0 +1,63 @@
package com.njcn.csharmonic.pojo.vo;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.time.LocalDate;
import java.util.ArrayList;
import java.util.List;
/**
* @author xy
*/
@Data
public class HarmonicVO implements Serializable {
@ApiModelProperty(value = "稳态数量")
private Integer harmonicNums = 0;
@ApiModelProperty(value = "越限天数")
private Integer overDays = 0;
@ApiModelProperty(value = "越限监测点数")
private Integer overLineNums = 0;
@ApiModelProperty(value = "越限监测点数")
private List<LineHarmonicDetail> list = new ArrayList<>();
@Data
public static class LineHarmonicDetail implements Serializable {
@ApiModelProperty(value = "事件id")
private String eventId;
@ApiModelProperty(value = "工程名称")
private String engineeringName;
@ApiModelProperty(value = "项目名称")
private String projectName;
@ApiModelProperty(value = "设备名称")
private String devName;
@ApiModelProperty(value = "统计日期")
private LocalDate statisticsDate;
@ApiModelProperty(value = "监测点id")
private String lineId;
@ApiModelProperty(value = "监测点名称")
private String lineName;
@ApiModelProperty(value = "越限描述")
private String overLimitDesc;
@ApiModelProperty(value = "是否读取 0:未读取 1:读取")
private Integer isRead;
}
}

View File

@@ -1,142 +0,0 @@
//package com.njcn.csharmonic.utils.report;
//
///**
// * @author hongawen
// * @date: 2020/8/20 13:36
// */
//public class ClearPathUtil {
//
// /**
// * 针对漏洞,新增的特殊字符替换的扫描方法
// */
// public static String cleanString(String str) {
// if (str == null) {
// return null;
// }
// StringBuilder sb = new StringBuilder();
// for (int i = 0; i < str.length(); ++i) {
// sb.append(cleanChar(str.charAt(i)));
// }
// return sb.toString();
// }
//
// private static char cleanChar(char ch) {
//
// // 0 - 9
// for (int i = 48; i < 58; ++i) {
// if (ch == i) {
// return (char) i;
// }
// }
//
// // 'A' - 'Z'
// for (int i = 65; i < 91; ++i) {
// if (ch == i) {
// return (char) i;
// }
// }
//
// // 'a' - 'z'
// for (int i = 97; i < 123; ++i) {
// if (ch == i) {
// return (char) i;
// }
// }
//
// // other valid characters
// switch (ch) {
// case '/':
// return '/';
// case '.':
// return '.';
// case '-':
// return '-';
// case '_':
// return '_';
// case ',':
// return ',';
// case ' ':
// return ' ';
// case '!':
// return '!';
// case '@':
// return '@';
// case '#':
// return '#';
// case '$':
// return '$';
// case '%':
// return '%';
// case '^':
// return '^';
// case '&':
// return '&';
// case '*':
// return '*';
// case '(':
// return '(';
// case ')':
// return ')';
// case '+':
// return '+';
// case '=':
// return '=';
// case ':':
// return ':';
// case ';':
// return ';';
// case '?':
// return '?';
// case '"':
// return '"';
// case '<':
// return '<';
// case '>':
// return '>';
// case '`':
// return '`';
// case '\\':
// return '/';
// case 'I':
// return 'I';
// case 'Ⅱ':
// return 'Ⅱ';
// case 'Ⅲ':
// return 'Ⅲ';
// case 'Ⅳ':
// return 'Ⅳ';
// case '':
// return '';
// case 'Ⅵ':
// return 'Ⅵ';
// case 'Ⅶ':
// return 'Ⅶ';
// case 'Ⅷ':
// return 'Ⅷ';
// case 'Ⅸ':
// return 'Ⅸ';
//
// case 'V':
// return 'V';
// case 'X':
// return 'X';
// case '':
// return '';
// default:
// if (isChineseChar(ch)) {
// return ch;
// }
// return '%';
// }
// }
//
// // 根据Unicode编码判断中文汉字和符号
// private static boolean isChineseChar(char c) {
// Character.UnicodeBlock ub = Character.UnicodeBlock.of(c);
// return ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS
// || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_B
// || ub == Character.UnicodeBlock.CJK_SYMBOLS_AND_PUNCTUATION || ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS
// || ub == Character.UnicodeBlock.GENERAL_PUNCTUATION;
// }
//
//}

View File

@@ -1,83 +0,0 @@
//package com.njcn.csharmonic.utils.report;
//
//import lombok.extern.slf4j.Slf4j;
//import org.apache.poi.openxml4j.opc.OPCPackage;
//import org.apache.poi.xwpf.usermodel.XWPFDocument;
//import org.apache.poi.xwpf.usermodel.XWPFParagraph;
//import org.apache.xmlbeans.XmlException;
//import org.apache.xmlbeans.XmlToken;
//import org.openxmlformats.schemas.drawingml.x2006.main.CTNonVisualDrawingProps;
//import org.openxmlformats.schemas.drawingml.x2006.main.CTPositiveSize2D;
//import org.openxmlformats.schemas.drawingml.x2006.wordprocessingDrawing.CTInline;
//
//import java.io.IOException;
//import java.io.InputStream;
//
//@Slf4j
//public class CustomXWPFDocument extends XWPFDocument {
// // 日志记录
// public CustomXWPFDocument(InputStream in) throws IOException {
// super(in);
// }
//
// public CustomXWPFDocument() {
// super();
// }
//
// public CustomXWPFDocument(OPCPackage pkg) throws IOException {
// super(pkg);
// }
//
// /**
// * @param id
// * @param width
// * 宽
// * @param height
// * 高
// * @param paragraph
// * 段落
// */
// public void createPicture(int id, int width, int height,String blipId, XWPFParagraph paragraph) {
// final int EMU = 9525;
// width *= EMU;
// height *= EMU;
//// String blipId = getAllPictures().get(id).getPackageRelationship().getId();
// CTInline inline = paragraph.createRun().getCTR().addNewDrawing().addNewInline();
// String picXml = "" + "<a:graphic xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">"
// + " <a:graphicData uri=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
// + " <pic:pic xmlns:pic=\"http://schemas.openxmlformats.org/drawingml/2006/picture\">"
// + " <pic:nvPicPr>" + " <pic:cNvPr id=\"" + id + "\" name=\"Generated\"/>"
// + " <pic:cNvPicPr/>" + " </pic:nvPicPr>" + " <pic:blipFill>"
// + " <a:blip r:embed=\"" + blipId
// + "\" xmlns:r=\"http://schemas.openxmlformats.org/officeDocument/2006/relationships\"/>"
// + " <a:stretch>" + " <a:fillRect/>" + " </a:stretch>"
// + " </pic:blipFill>" + " <pic:spPr>" + " <a:xfrm>"
// + " <a:off x=\"0\" y=\"0\"/>" + " <a:ext cx=\"" + width + "\" cy=\""
// + height + "\"/>" + " </a:xfrm>" + " <a:prstGeom prst=\"rect\">"
// + " <a:avLst/>" + " </a:prstGeom>" + " </pic:spPr>"
// + " </pic:pic>" + " </a:graphicData>" + "</a:graphic>";
//
// inline.addNewGraphic().addNewGraphicData();
// XmlToken xmlToken = null;
// try {
// xmlToken = XmlToken.Factory.parse(picXml);
// } catch (XmlException xe) {
// log.error("生成报表发生异常,异常是"+xe.getMessage());
// }
// inline.set(xmlToken);
//
// inline.setDistT(0);
// inline.setDistB(0);
// inline.setDistL(0);
// inline.setDistR(0);
//
// CTPositiveSize2D extent = inline.addNewExtent();
// extent.setCx(width);
// extent.setCy(height);
//
// CTNonVisualDrawingProps docPr = inline.addNewDocPr();
// docPr.setId(id);
// docPr.setName("图片" + id);
// docPr.setDescr("测试");
// }
//}

View File

@@ -1,28 +0,0 @@
//package com.njcn.csharmonic.utils.report;
//
//import java.math.BigDecimal;
//
///**
// * @author hongawen(创建) -----denghuajun移植使用
// * @Date: 2018/8/27 11:29
// */
//public class FloatUtils {
//
//
// /**
// * 保留传入进来的float的两位小数四舍五入的方式
// *
// * @param data Float参数
// */
// public static float get2Float(Float data) {
// if (data == null || data.isNaN() || data.isInfinite()) {
// return 0f;
// }
// int scale = 2;//设置位数
// int roundingMode = 4;//表示四舍五入,可以选择其他舍值方式,例如去尾,等等.
// BigDecimal bd = new BigDecimal(data);
// bd = bd.setScale(scale, roundingMode);
// data = bd.floatValue();
// return data;
// }
//}

View File

@@ -1,224 +0,0 @@
//package com.njcn.csharmonic.utils.report;
//
//import cn.hutool.core.util.ObjectUtil;
//import lombok.SneakyThrows;
//import lombok.extern.slf4j.Slf4j;
//
//import java.io.File;
//import java.io.IOException;
//import java.io.InputStream;
//import java.text.SimpleDateFormat;
//import java.util.*;
//
///**
// * @author wr
// * @description
// * @date 2023/4/10 17:39
// */
//@Slf4j
//public class PubUtils {
// public static boolean createFile(String destFileName) {
// File file = new File(destFileName);
// if (file.exists()) {
// log.warn("创建单个文件" + destFileName + "失败,目标文件已存在!");
// return false;
// }
// if (destFileName.endsWith(File.separator)) {
// log.warn("创建单个文件" + destFileName + "失败,目标文件不能为目录!");
// return false;
// }
// //判断目标文件所在的目录是否存在
// if (!file.getParentFile().exists()) {
// //如果目标文件所在的目录不存在,则创建父目录
// log.warn("目标文件所在目录不存在,准备创建它!");
// if (!file.getParentFile().mkdirs()) {
// log.warn("创建目标文件所在目录失败!");
// return false;
// }
// }
// //创建目标文件
// try {
// if (file.createNewFile()) {
// log.warn("创建单个文件" + destFileName + "成功!");
// return true;
// } else {
// log.warn("创建单个文件" + destFileName + "失败!");
// return false;
// }
// } catch (IOException e) {
// log.warn("创建单个文件" + destFileName + "失败!" + e.getMessage());
// return false;
// }
// }
//
// /**
// * 读取配置文件
// *
// * @param cl 类名字
// * @param strPropertiesName 配置文件名称
// */
// public static Properties readProperties(ClassLoader cl, String strPropertiesName) {
// Properties pros = new Properties();
// InputStream in = null;
// try {
// in = cl.getResourceAsStream(strPropertiesName);
// pros.load(in);
// } catch (Exception e) {
// log.error("读取配置文件失败失败:" + e.getMessage());
// } finally {
// if (in != null) {
// PubUtils.safeClose(in, "安全关闭读取配置文件失败,异常为:");
// }
// }
// return pros;
// }
//
// /**
// * 安全关闭InputStream
// *
// * @param s
// */
// public static void safeClose(InputStream s, String strError) {
// if (s != null) {
// try {
// s.close();
// } catch (IOException e) {
// log.error(strError + e.toString());
// }
// }
// }
//
// public static Double dataLimits(Double data) {
// if (ObjectUtil.isNotNull(data)) {
// return data > 100 ? 100 : data;
// }
// return data;
// }
//
// @SneakyThrows
// public static List<String> getIntervalTime(String startTime, String endTime) {
// List<String> times = new ArrayList<>();
// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
// Date start = sdf.parse(startTime);
// Date end = sdf.parse(endTime);
// // 同月
// if (start.getTime() == end.getTime()) {
// String time = startTime.substring(0, 7);
// times.add(time);
// } else if (start.getYear() == end.getYear()) {
// // 同年
// int startM = start.getMonth() + 1;
// int endM = end.getMonth() + 1;
// int temp = endM - startM;
// for (int i = 0; i <= temp; i++) {
// String time = start.getYear() + 1900 + "";
// int month = startM + i;
// if (month < 10) {
// time = time + "-0" + month;
// } else {
// time = time + "-" + month;
// }
// times.add(time);
// }
// } else {
// // 不同年!!!!这里忽略了年份之间跨年的情况
// int startY = start.getYear() + 1900;
// int startM = start.getMonth() + 1;
// int endY = end.getYear() + 1900;
// int endM = end.getMonth() + 1;
// int tempS = 12 - startM;
// // 连续的年份
// if (endY - startY == 1) {
// // 第一年的时间获取
// for (int i = 0; i <= tempS; i++) {
// int month = startM + i;
// String time = startY + "-";
// if (month < 10) {
// time = time + "0" + month;
// } else {
// time = time + month;
// }
// times.add(time);
// }
// // 第二年的时间获取
//
// for (int i = 1; i <= endM; i++) {
// String time = endY + "-";
// if (i < 10) {
// time = time + "0" + i;
// } else {
// time = time + i;
// }
// times.add(time);
// }
// } else {
// // 不连续的年份
// // 第一年的时间获取
// for (int i = 0; i <= tempS; i++) {
// int month = startM + i;
// String time = startY + "-";
// if (month < 10) {
// time = time + "0" + month;
// } else {
// time = time + month;
// }
// times.add(time);
// }
// int tempY = endY - startY;
// // 中间年份的时间
// for (int i = 1; i < tempY; i++) {
// for (int j = 1; j <= 12; j++) {
// String time = startY + i + "-";
// if (j < 10) {
// time = time + "0" + j;
// } else {
// time = time + j;
// }
// times.add(time);
// }
// }
// // 最后一年的时间获取
// for (int i = 1; i <= endM; i++) {
// String time = endY + "-";
// if (i < 10) {
// time = time + "0" + i;
// } else {
// time = time + i;
// }
// times.add(time);
// }
// }
//
// }
// return times;
// }
//
// @SneakyThrows
// public static List<String> getIntervalDateTime(Integer startTime, int beginDay, Integer endTime, Integer dd) {
// List<String> list = new ArrayList<>();
// Calendar calendar = Calendar.getInstance(Locale.CHINA);
// calendar.set(startTime, endTime - 1, 1);
// //年份
// int year = calendar.get(Calendar.YEAR);
// //月份
// int month = calendar.get(Calendar.MONTH) + 1;
// for (int i = beginDay; i <= dd; i++) {
// String date = null;
// if (month < 10 && i < 10) {
// date = year + "-0" + month + "-0" + i;
// }
// if (month < 10 && i >= 10) {
// date = year + "-0" + month + "-" + i;
// }
// if (month >= 10 && i < 10) {
// date = year + "-" + month + "-0" + i;
// }
// if (month >= 10 && i >= 10) {
// date = year + "-" + month + "-" + i;
// }
//
// list.add(date);
// }
// return list;
// }
//}

View File

@@ -1,30 +0,0 @@
//package com.njcn.csharmonic.utils.report;
//
///**
// * 数据公共工具类
// *
// * @author qijian
// * @version 1.0.0
// * @createTime 2022/10/14 - 10:07
// */
//public class PublicDataUtils {
// /**
// * 功能:下划线命名转驼峰命名
// * 将下划线替换为空格,将字符串根据空格分割成数组,再将每个单词首字母大写
// * @param s
// * @return
// */
// public static String underCamel(String s)
// {
// String separator = "_";
// String under="";
// s = s.toLowerCase().replace(separator, " ");
// String sarr[]=s.split(" ");
// for(int i=0;i<sarr.length;i++)
// {
// String w=sarr[i].substring(0,1).toUpperCase()+sarr[i].substring(1);
// under +=w;
// }
// return under;
// }
//}

View File

@@ -1,25 +0,0 @@
//package com.njcn.csharmonic.utils.report;
//
//import com.alibaba.fastjson.serializer.JSONSerializer;
//import com.alibaba.fastjson.serializer.ObjectSerializer;
//import org.springframework.stereotype.Component;
//
//import java.io.IOException;
//import java.lang.reflect.Type;
//import java.sql.Timestamp;
//
//@Component
//public class TimestampAsLongSerializer implements ObjectSerializer {
//
// @Override
// public void write(JSONSerializer serializer, Object object, Object fieldName, Type fieldType, int features) throws IOException {
// if (object instanceof Timestamp) {
// Timestamp timestamp = (Timestamp) object;
// // 将Timestamp转换为时间戳毫秒数
// long time = timestamp.getTime();
// serializer.write(time);
// } else {
// serializer.write(object);
// }
// }
//}

View File

@@ -1,427 +0,0 @@
//package com.njcn.csharmonic.utils.report;
//
//import cn.hutool.core.collection.CollUtil;
//import com.njcn.oss.constant.OssPath;
//import com.njcn.oss.utils.FileStorageUtil;
//import lombok.RequiredArgsConstructor;
//import lombok.extern.slf4j.Slf4j;
//import org.apache.poi.xwpf.usermodel.*;
//import org.apache.tomcat.util.http.fileupload.IOUtils;
//import org.springframework.core.io.ClassPathResource;
//import org.springframework.core.io.Resource;
//import org.springframework.core.io.ResourceLoader;
//import org.springframework.stereotype.Component;
//import org.springframework.util.FileCopyUtils;
//
//import javax.servlet.ServletOutputStream;
//import javax.servlet.http.HttpServletResponse;
//import java.io.*;
//import java.util.*;
//import java.util.Map.Entry;
//import java.util.regex.Matcher;
//import java.util.regex.Pattern;
//
//@Slf4j
//@Component
//@RequiredArgsConstructor
//public class WordUtil2 {
//
//
// private final ResourceLoader resourceLoader;
// private final FileStorageUtil fileStorageUtil;
//
//
// public void getWord(String path, Map<String, Object> params, String fileName,List<List<String[]>> tableList, HttpServletResponse response)
// throws Exception {
// byte[] docBytes = null;
//
// path = ClearPathUtil.cleanString(path);
// InputStream is = null;
// CustomXWPFDocument doc = null;
// //读取报告模板
// try {
// Resource resource = resourceLoader.getResource("classpath:" + path);
// if (!resource.exists()) {
// throw new FileNotFoundException("模板文件未找到: " + path);
// }
// is = resource.getInputStream();
// doc = new CustomXWPFDocument(is);
// if(CollUtil.isNotEmpty(tableList)){
// this.replaceInTable(doc, params,tableList);
// }else{
// this.replaceInTable(doc, params);
// }
// // 替换表格里面的变量
// this.replaceInPara(doc, params); // 替换文本里面的变量
// } catch (IOException e) {
// getError("获取报告模板异常,原因为:" + e);
// } finally {
// if (null != is) {
// is.close();
// }
// }
// try {
// ServletOutputStream outputStream = response.getOutputStream();
// response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
// response.setContentType("application/octet-stream;charset=UTF-8");
// doc.write(outputStream);
// outputStream.close();
// } catch (Exception e) {
// getError("输出稳态报告异常,原因为:" + e);
// } finally {
// if (doc != null) {
// doc.close();
// }
// }
// }
//
//
//
//
// // 辅助方法:字节数组转十六进制(便于打印排查)
// private static String bytesToHex(byte[] bytes) {
// StringBuilder sb = new StringBuilder();
// for (byte b : bytes) {
// sb.append(String.format("%02X ", b));
// }
// return sb.toString().trim();
// }
//
//
//
//
// public InputStream getReportFile(String path, Map<String, Object> params, List<List<String[]>> tableList)
// throws Exception {
// path = ClearPathUtil.cleanString(path);
// InputStream inStream = null,in = null;
// CustomXWPFDocument doc = null;
// //读取报告模板
// try {
// inStream = new ClassPathResource(path).getInputStream();
// doc = new CustomXWPFDocument(inStream);
// this.replaceInTable(doc,params,tableList);
// this.replaceInPara(doc, params);
// } catch (IOException e) {
// getError("获取报告模板异常,原因为:" + e);
// } finally {
// if (null != inStream) {
// inStream.close();
// }
// }
// try {
// //临时缓冲区
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// doc.write(out);
// byte[] docByteAry = out.toByteArray();
// in = new ByteArrayInputStream(docByteAry);
// out.close();
// } catch (Exception e) {
// getError("输出稳态报告异常,原因为:" + e);
// } finally {
// if (doc != null) {
// doc.close();
// }
// }
// return in;
// }
//
//
//
// public String getReportFileUrl(String path,String fileName,List<List<String[]>> tableList, Map<String, Object> params)
// throws Exception {
// path = ClearPathUtil.cleanString(path);
// InputStream inStream = null,in = null;
// CustomXWPFDocument doc = null;
// //读取报告模板
// try {
// inStream = new ClassPathResource(path).getInputStream();;
// doc = new CustomXWPFDocument(inStream);
// if(CollUtil.isNotEmpty(tableList)){
// this.replaceInTable(doc, params,tableList);
// }else{
// this.replaceInTable(doc, params);
// }
// this.replaceInPara(doc, params); // 替换文本里面的变量
// //临时缓冲区
// ByteArrayOutputStream out = new ByteArrayOutputStream();
// doc.write(out);
// byte[] docByteAry = out.toByteArray();
// in = new ByteArrayInputStream(docByteAry);
// out.close();
// } catch (IOException e) {
// getError("获取报告模板异常,原因为:" + e);
// } finally {
// if (null != inStream) {
// inStream.close();
// }
// if (doc != null) {
// doc.close();
// }
// }
// //上传文件服务器
// return fileStorageUtil.uploadStreamSpecifyName(in, OssPath.ONLINE_REPORT, fileName);
// }
//
//
// private static void getError(String e) {
// log.error(e);
// }
// /**
// * 替换段落里面的变量
// *
// * @param doc 要替换的文档
// * @param params 参数
// */
// private void replaceInPara(CustomXWPFDocument doc, Map<String, Object> params) {
// Iterator<XWPFParagraph> iterator = doc.getParagraphsIterator();
// List<XWPFParagraph> paragraphList = new ArrayList<>();
// XWPFParagraph para;
// while (iterator.hasNext()) {
// para = iterator.next();
// paragraphList.add(para);
// }
// processParagraphs(paragraphList, params, doc);
// }
//
// private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params) {
// Iterator<XWPFTable> it = doc.getTablesIterator();
// while (it.hasNext()) {
// XWPFTable table = it.next();
// List<XWPFTableRow> rows = table.getRows();
// for (XWPFTableRow row : rows) {
// List<XWPFTableCell> cells = row.getTableCells();
// for (XWPFTableCell cell : cells) {
// List<XWPFParagraph> paragraphListTable = cell.getParagraphs();
// processParagraphs(paragraphListTable, params, doc);
// }
// }
// }
// }
//
// public static void processParagraphs(List<XWPFParagraph> paragraphList, Map<String, Object> param,
// CustomXWPFDocument doc) {
// if (paragraphList != null && paragraphList.size() > 0) {
// for (XWPFParagraph paragraph : paragraphList) {
// List<XWPFRun> runs = paragraph.getRuns();
// if (runs.size() > 0) {
// for (XWPFRun run : runs) {
// String bflag = "";
// String text = run.getText(0);
// if (text != null) {
// boolean isSetText = false;
// for (Entry<String, Object> entry : param.entrySet()) {
// String key = entry.getKey();
// if (text.indexOf(key) != -1) {
// isSetText = true;
// Object value = entry.getValue();
// if (value instanceof String) {// 文本替换
// text = text.replace(key, value.toString());
// } else if (value instanceof Map) {// 图片替换
// text = text.replace(key, "");
// Map pic = (Map) value;
// int width = Integer.parseInt(pic.get("width").toString());
// int height = Integer.parseInt(pic.get("height").toString());
// int picType = getPictureType(pic.get("type").toString());
// byte[] byteArray = (byte[]) pic.get("content");
// ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
// try {
// String s = doc.addPictureData(byteInputStream, picType);
//
// doc.createPicture(doc.getAllPictures().size() - 1, width, height,
// s,paragraph);
// bflag = "break";
// } catch (Exception e) {
// getError("文本替换发生异常,异常是" + e.getMessage());
// }
// }
// }
// }
// if (isSetText) {
// run.setText(text, 0);
// }
// }
// if (bflag == "break") {
// break;
// }
// }
// }
// }
// }
// }
//
// /**
// * 替换段落里面的变量
// *
// * @param para 要替换的段落
// * @param params 参数
// */
// private void replaceInPara(XWPFParagraph para, Map<String, Object> params, CustomXWPFDocument doc) {
// List<XWPFRun> runs;
// Matcher matcher;
// // if (this.matcher(para.getParagraphText()).find()) {
// runs = para.getRuns();
// int start = -1;
// int end = -1;
// String str = "";
// for (int i = 0; i < runs.size(); i++) {
// XWPFRun run = runs.get(i);
// String runText = run.toString();
// if ('$' == runText.charAt(0) && '{' == runText.charAt(1)) {
// start = i;
// }
// if ((start != -1)) {
// str += runText;
// }
// if ('}' == runText.charAt(runText.length() - 1)) {
// if (start != -1) {
// end = i;
// break;
// }
// }
// }
//
// for (int i = start; i <= end; i++) {
// para.removeRun(i);
// i--;
// end--;
// }
//
// for (Entry<String, Object> entry : params.entrySet()) {
// String key = entry.getKey();
// if (str.indexOf(key) != -1) {
// Object value = entry.getValue();
// if (value instanceof String) {
// str = str.replace(key, value.toString());
// para.createRun().setText(str, 0);
// break;
// } else if (value instanceof Map) {
// str = str.replace(key, "");
// Map pic = (Map) value;
// int width = Integer.parseInt(pic.get("width").toString());
// int height = Integer.parseInt(pic.get("height").toString());
// int picType = getPictureType(pic.get("type").toString());
// byte[] byteArray = (byte[]) pic.get("content");
// ByteArrayInputStream byteInputStream = new ByteArrayInputStream(byteArray);
// try {
// // int ind = doc.addPicture(byteInputStream,picType);
// // doc.createPicture(ind, width , height,para);
// String s = doc.addPictureData(byteInputStream, picType);
// doc.createPicture(doc.getAllPictures().size() - 1, width, height,s, para);
// para.createRun().setText(str, 0);
// break;
// } catch (Exception e) {
// getError("文件替换发生异常,异常是" + e.getMessage());
// }
// }
// }
// }
// // }
// }
//
// /**
// * 为表格插入数据,行数不够添加新行
// *
// * @param table 需要插入数据的表格
// * @param tableList 插入数据集合
// */
// private static void insertTable(XWPFTable table, List<String[]> tableList) {
// //删除占位符行数
// table.removeRow(1);
// if (CollUtil.isNotEmpty(tableList)) {
// // 创建行,根据需要插入的数据添加新行,不处理表头
// for (int i = 0; i < tableList.size(); i++) {
// XWPFTableRow row = table.createRow();
// List<XWPFTableCell> cells = row.getTableCells();
// for (int j = 0; j < cells.size(); j++) {
// String s = tableList.get(i)[j];
// XWPFTableCell cell = cells.get(j);
// cell.removeParagraph(0);
// XWPFParagraph paragraph = cell.addParagraph();
// paragraph.setAlignment(ParagraphAlignment.CENTER);
// // 在段落中添加文本
// XWPFRun run = paragraph.createRun();
// run.setText(s);
// }
// }
// }
// }
//
// /**
// * 替换表格里面的变量
// *
// * @param doc 要替换的文档
// * @param tableList 存放数据顺序要与表格一致
// * @param params 参数
// */
// private void replaceInTable(CustomXWPFDocument doc, Map<String, Object> params, List<List<String[]>> tableList) {
// Iterator<XWPFTable> iterator = doc.getTablesIterator();
// XWPFTable table;
// List<XWPFTableRow> rows;
// List<XWPFTableCell> cells;
// List<XWPFParagraph> paras;
// Integer num=0;
// while (iterator.hasNext()) {
// table = iterator.next();
// if (table.getRows().size() > 1) {
// // 判断表格是需要替换还是需要插入,判断逻辑有$为替换,表格无$为插入
// if (this.matcher(table.getText()).find()||this.matcherS(table.getText()).find()) {
// rows = table.getRows();
// for (XWPFTableRow row : rows) {
// cells = row.getTableCells();
// for (XWPFTableCell cell : cells) {
// List<XWPFParagraph> paragraphListTable = cell.getParagraphs();
// processParagraphs(paragraphListTable, params, doc);
// }
// }
// }else {
// if (CollUtil.isNotEmpty(tableList.get(num))){
// insertTable(table, tableList.get(num)); // 插入数据
// }
// num++;
// }
// }
// }
// }
//
// /**
// * 正则匹配字符串
// *
// * @param str
// * @return
// */
// private Matcher matcher(String str) {
// Pattern pattern = Pattern.compile("\\$\\{(.+?)\\}", Pattern.CASE_INSENSITIVE);
// Matcher matcher = pattern.matcher(str);
// return matcher;
// }
// private Matcher matcherS(String str) {
// Pattern pattern = Pattern.compile("\\$(.*?)\\$");
// Matcher matcher = pattern.matcher(str);
// return matcher;
// }
//
// /**
// * 根据图片类型,取得对应的图片类型代码
// *
// * @param picType
// * @return int
// */
// private static int getPictureType(String picType) {
// int res = CustomXWPFDocument.PICTURE_TYPE_PICT;
// if (picType != null) {
// if (picType.equalsIgnoreCase("image/png")) {
// res = CustomXWPFDocument.PICTURE_TYPE_PNG;
// } else if (picType.equalsIgnoreCase("image/dib")) {
// res = CustomXWPFDocument.PICTURE_TYPE_DIB;
// } else if (picType.equalsIgnoreCase("image/emf")) {
// res = CustomXWPFDocument.PICTURE_TYPE_EMF;
// } else if (picType.equalsIgnoreCase("image/jpg") || picType.equalsIgnoreCase("image/jpeg")) {
// res = CustomXWPFDocument.PICTURE_TYPE_JPEG;
// } else if (picType.equalsIgnoreCase("image/wmf")) {
// res = CustomXWPFDocument.PICTURE_TYPE_WMF;
// }
// }
// return res;
// }
//
//}

View File

@@ -0,0 +1,96 @@
package com.njcn.csharmonic.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.pojo.dto.LineParamDTO;
import com.njcn.csharmonic.pojo.po.CsAlarm;
import com.njcn.csharmonic.pojo.vo.AlarmVO;
import com.njcn.csharmonic.service.ICsAlarmService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2026-03-16
*/
@Slf4j
@RestController
@RequestMapping("/csAlarm")
@Api(tags = "运行告警事件")
@AllArgsConstructor
public class CsAlarmController extends BaseController {
private final ICsAlarmService csAlarmService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryAlarmList")
@ApiOperation("运行告警事件列表(app)")
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
public HttpResult<List<AlarmVO>> queryAlarmList(@RequestBody LineParamDTO param) {
String methodDescribe = getMethodDescribe("queryAlarmList");
List<AlarmVO> result = csAlarmService.queryAlarmList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryAlarmDetail")
@ApiOperation("运行告警事件详情(app)")
@ApiImplicitParam(name = "param", value = "事件查询参数", required = true)
public HttpResult<List<AlarmVO.AlarmDetail>> queryAlarmDetail(@RequestBody LineParamDTO.DevParamDTO param) {
String methodDescribe = getMethodDescribe("queryAlarmDetail");
List<AlarmVO.AlarmDetail> result = csAlarmService.queryAlarmDetail(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addList")
@ApiOperation("批量写入数据")
@ApiImplicitParam(name = "list", value = "参数", required = true)
public HttpResult<Boolean> addList(@RequestBody List<CsAlarm> list) {
String methodDescribe = getMethodDescribe("addList");
boolean result = csAlarmService.saveOrUpdateBatch(list);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryListByTime")
@ApiOperation("按日期查询数据")
@ApiImplicitParam(name = "time", value = "时间", required = true)
public HttpResult<List<CsAlarm>> queryListByTime(@RequestParam String time) {
String methodDescribe = getMethodDescribe("queryListByTime");
LambdaQueryWrapper<CsAlarm> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsAlarm::getTime, time);
List<CsAlarm> list = csAlarmService.list(wrapper);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deleteListByTime")
@ApiOperation("按日期删除数据")
@ApiImplicitParam(name = "time", value = "时间", required = true)
public HttpResult<Boolean> deleteListByTime(@RequestParam String time) {
String methodDescribe = getMethodDescribe("deleteListByTime");
LambdaQueryWrapper<CsAlarm> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsAlarm::getTime, time);
boolean result = csAlarmService.remove(wrapper);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -176,5 +176,25 @@ public class CsEventController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getDevAlarmList")
@ApiOperation("获取设备运行告警事件")
@ApiImplicitParam(name = "param", value = "事件信息", required = true)
public HttpResult<List<CsEventPO>> getDevAlarmList(@RequestBody CsEventUserQueryParam param) {
String methodDescribe = getMethodDescribe("getDevAlarmList");
List<CsEventPO> list = csEventPOService.getDevAlarmList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEventByIdList")
@ApiOperation("根据事件id获取事件详情")
@ApiImplicitParam(name = "list", value = "id集合", required = true)
public HttpResult<List<CsEventPO>> getEventByIdList(@RequestBody List<String> list) {
String methodDescribe = getMethodDescribe("getEventByIdList");
List<CsEventPO> result = csEventPOService.listByIds(list);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
} }

View File

@@ -0,0 +1,97 @@
package com.njcn.csharmonic.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.pojo.dto.LineParamDTO;
import com.njcn.csharmonic.pojo.po.CsHarmonic;
import com.njcn.csharmonic.pojo.vo.HarmonicDetailVO;
import com.njcn.csharmonic.pojo.vo.HarmonicVO;
import com.njcn.csharmonic.service.ICsHarmonicService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
* <p>
* 前端控制器
* </p>
*
* @author xy
* @since 2026-03-13
*/
@Slf4j
@RestController
@RequestMapping("/csHarmonic")
@Api(tags = "稳态事件")
@AllArgsConstructor
public class CsHarmonicController extends BaseController {
private final ICsHarmonicService csHarmonicService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryHarmonicList")
@ApiOperation("稳态事件列表(app)")
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
public HttpResult<HarmonicVO> queryHarmonicList(@RequestBody LineParamDTO param) {
String methodDescribe = getMethodDescribe("queryHarmonicList");
HarmonicVO vo = csHarmonicService.queryAppList(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryHarmonicDetail")
@ApiOperation("稳态事件详情(app)")
@ApiImplicitParam(name = "param", value = "暂降事件查询参数", required = true)
public HttpResult<List<HarmonicDetailVO>> queryHarmonicDetail(@RequestBody LineParamDTO param) {
String methodDescribe = getMethodDescribe("queryHarmonicDetail");
List<HarmonicDetailVO> vo = csHarmonicService.queryHarmonicDetail(param);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, vo, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addList")
@ApiOperation("批量写入数据")
@ApiImplicitParam(name = "list", value = "暂降事件查询参数", required = true)
public HttpResult<Boolean> addList(@RequestBody List<CsHarmonic> list) {
String methodDescribe = getMethodDescribe("addList");
boolean result = csHarmonicService.saveOrUpdateBatch(list);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/queryListByTime")
@ApiOperation("按日期查询数据")
@ApiImplicitParam(name = "time", value = "时间", required = true)
public HttpResult<List<CsHarmonic>> queryListByTime(@RequestParam String time) {
String methodDescribe = getMethodDescribe("queryListByTime");
LambdaQueryWrapper<CsHarmonic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsHarmonic::getTime, time);
List<CsHarmonic> list = csHarmonicService.list(wrapper);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deleteListByTime")
@ApiOperation("按日期删除数据")
@ApiImplicitParam(name = "time", value = "时间", required = true)
public HttpResult<Boolean> deleteListByTime(@RequestParam String time) {
String methodDescribe = getMethodDescribe("deleteListByTime");
LambdaQueryWrapper<CsHarmonic> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(CsHarmonic::getTime, time);
boolean result = csHarmonicService.remove(wrapper);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -26,6 +26,7 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.io.InputStream;
import java.util.List; import java.util.List;
/** /**
@@ -44,9 +45,6 @@ public class CustomReportController extends BaseController {
private final CustomReportService customReportService; private final CustomReportService customReportService;
/** /**
* 替换报表数据并返回 * 替换报表数据并返回
* @author qijian * @author qijian

View File

@@ -1,5 +1,6 @@
package com.njcn.csharmonic.controller; package com.njcn.csharmonic.controller;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.enums.common.LogEnum; import com.njcn.common.pojo.enums.common.LogEnum;
@@ -10,6 +11,7 @@ import com.njcn.csharmonic.param.CldWarnParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; 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.pojo.vo.EventDetailVO;
import com.njcn.csharmonic.service.CsEventUserPOService; import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
@@ -98,4 +100,24 @@ public class EventUserController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
} }
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/addUserEventList")
@ApiOperation("新增数据")
public HttpResult<Boolean> addUserEventList(@RequestBody List<CsEventUserPO> list) {
String methodDescribe = getMethodDescribe("addUserEventList");
Boolean result = csEventUserPOService.saveBatch(list);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/deleteByIds")
@ApiOperation("根据id删除数据")
public HttpResult<Boolean> deleteByIds(@RequestBody List<String> eventList) {
String methodDescribe = getMethodDescribe("deleteByIds");
LambdaQueryWrapper<CsEventUserPO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CsEventUserPO::getEventId, eventList);
Boolean result = csEventUserPOService.remove(wrapper);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
} }

View File

@@ -0,0 +1,42 @@
package com.njcn.csharmonic.controller;
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.pojo.vo.EngineeringHomePageVO;
import com.njcn.csharmonic.service.HomePageService;
import com.njcn.web.controller.BaseController;
import io.swagger.annotations.Api;
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.RestController;
import java.util.List;
/**
* @author xy
*/
@Slf4j
@RestController
@RequestMapping("/homePage")
@Api(tags = "app首页")
@AllArgsConstructor
public class HomePageController extends BaseController {
private final HomePageService homePageService;
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/getEngineeringHomePage")
@ApiOperation("工程用户首页")
public HttpResult<List<EngineeringHomePageVO>> getEngineeringHomePage(){
String methodDescribe = getMethodDescribe("getEngineeringHomePage");
List<EngineeringHomePageVO> result = homePageService.getEngineeringHomePage();
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
}

View File

@@ -13,9 +13,9 @@ import com.njcn.common.utils.HttpResultUtil;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam; import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo; import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo;
import com.njcn.csharmonic.service.IPqSensitiveUserService; import com.njcn.csharmonic.service.IPqSensitiveUserService;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;

View File

@@ -83,7 +83,7 @@ public class MqttMessageHandler {
public void responseRtData(String topic, @NamedValue("pageId") String pageId, MqttMessage message, @Payload String payload) { public void responseRtData(String topic, @NamedValue("pageId") String pageId, MqttMessage message, @Payload String payload) {
List<CsRtDataVO> list = lineTargetService.getLineData(pageId); List<CsRtDataVO> list = lineTargetService.getLineData(pageId);
Gson gson = new Gson(); Gson gson = new Gson();
publisher.send("/zl/rtData/" + pageId, gson.toJson(list), 1, false); publisher.send("/zl/rtData/" + pageId, gson.toJson(list), 1, false);
} }
@MqttSubscribe(value = "/zl/askTemperData/{devId}", qos = 1) @MqttSubscribe(value = "/zl/askTemperData/{devId}", qos = 1)

View File

@@ -0,0 +1,16 @@
package com.njcn.csharmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.CsAlarm;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xy
* @since 2026-03-16
*/
public interface CsAlarmMapper extends BaseMapper<CsAlarm> {
}

View File

@@ -4,11 +4,13 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
import com.njcn.csharmonic.pojo.po.CsEventUserPO; import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
@@ -21,6 +23,8 @@ import java.util.List;
public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> { public interface CsEventUserPOMapper extends BaseMapper<CsEventUserPO> {
Integer queryEventCount(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam); Integer queryEventCount(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam);
List<UnReadEventDto> queryEngineeringEventCount(@Param("userIndex") String userIndex);
List<EventDetailVO> queryUserEventList(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag); List<EventDetailVO> queryUserEventList(@Param("csEventUserQueryParam") CsEventUserQueryParam csEventUserQueryParam, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag);
Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag); Page<EventDetailVO> queryEventpage(Page<EventDetailVO> returnpage, @Param("csEventUserQueryPage") CsEventUserQueryPage csEventUserQueryPage, @Param("devIds") List<String> devIds, @Param("flag") Boolean flag);

View File

@@ -0,0 +1,16 @@
package com.njcn.csharmonic.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.CsHarmonic;
/**
* <p>
* Mapper 接口
* </p>
*
* @author xy
* @since 2026-03-13
*/
public interface CsHarmonicMapper extends BaseMapper<CsHarmonic> {
}

View File

@@ -1,16 +1,16 @@
package com.njcn.csharmonic.mapper; //package com.njcn.csharmonic.mapper;
//
import com.baomidou.mybatisplus.core.mapper.BaseMapper; //import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser; //import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
//
/** ///**
* <p> // * <p>
* Mapper 接口 // * Mapper 接口
* </p> // * </p>
* // *
* @author xy // * @author xy
* @since 2025-11-17 // * @since 2025-11-17
*/ // */
public interface PqSensitiveUserMapper extends BaseMapper<PqSensitiveUser> { //public interface PqSensitiveUserMapper extends BaseMapper<PqSensitiveUser> {
//
} //}

View File

@@ -28,6 +28,19 @@
</select> </select>
<select id="queryEngineeringEventCount" resultType="com.njcn.csharmonic.pojo.dto.UnReadEventDto">
SELECT
t2.device_id AS deviceId,
COUNT(DISTINCT event_id) AS count
FROM
cs_event_user t1 LEFT JOIN cs_event t2 ON t1.event_id = t2.id
WHERE
t1.`status` = 0
AND t2.type IN (0, 1)
AND t1.user_id = #{userIndex}
GROUP BY t2.device_id
</select>
<select id="queryUserEventList" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO"> <select id="queryUserEventList" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
select DISTINCT a.event_id id, select DISTINCT a.event_id id,
<if test="flag"> <if test="flag">
@@ -83,7 +96,7 @@
1 status, 1 status,
</if> </if>
b.device_id deviceId,b.line_id lineId,b.code code, b.device_id deviceId,b.line_id lineId,b.code code,
b.start_time startTime,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,d.name lineName b.start_time startTime, b.amplitude evtParamVVaDepth,b.persist_time evtParamTm,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,d.name lineName
from cs_event_user a inner join cs_event b on a.event_id=b.id inner join cs_equipment_delivery c on b.device_id=c.id inner join cs_line d on d.device_id=b.device_id and d.clDid=b.cl_did where 1=1 from cs_event_user a inner join cs_event b on a.event_id=b.id inner join cs_equipment_delivery c on b.device_id=c.id inner join cs_line d on d.device_id=b.device_id and d.clDid=b.cl_did where 1=1
and b.process=c.process and b.process=c.process
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.endTime != null and csEventUserQueryPage.endTime !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.endTime != null and csEventUserQueryPage.endTime !=''">
@@ -118,7 +131,22 @@
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.userId != null and csEventUserQueryPage.userId !=''"> <if test="csEventUserQueryPage!=null and csEventUserQueryPage.userId != null and csEventUserQueryPage.userId !=''">
and a.user_id=#{ csEventUserQueryPage.userId} and a.user_id=#{ csEventUserQueryPage.userId}
</if> </if>
order by b.start_time desc <if test="csEventUserQueryPage!=null and csEventUserQueryPage.sortField != null">
<choose>
<when test="csEventUserQueryPage.sortField == 0">
order by b.start_time desc
</when>
<when test="csEventUserQueryPage.sortField == 1">
order by b.amplitude desc
</when>
<when test="csEventUserQueryPage.sortField == 2">
order by b.persist_time desc
</when>
<otherwise>
order by b.start_time desc
</otherwise>
</choose>
</if>
</select> </select>
<select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO"> <select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">

View File

@@ -71,4 +71,10 @@ public interface CsEventPOService extends IService<CsEventPO>{
List<EventStatisticsVo> getEventStatistics(CsEventUserQueryParam param); List<EventStatisticsVo> getEventStatistics(CsEventUserQueryParam param);
List<CsWarnDescVO> getEventDesc(List<String> lineIdList); List<CsWarnDescVO> getEventDesc(List<String> lineIdList);
//获取设备告警事件详情
List<CsEventPO> getEvents(List<String> idList);
List<CsEventPO> getDevAlarmList(CsEventUserQueryParam param);
} }

View File

@@ -5,12 +5,14 @@ import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csharmonic.param.CldWarnParam; import com.njcn.csharmonic.param.CldWarnParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO; import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* *
@@ -25,6 +27,8 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam); Integer queryEventCount(CsEventUserQueryParam csEventUserQueryParam);
List<UnReadEventDto> queryEngineeringEventCount(String userIndex);
List<EventDetailVO> queryUserEventList(CsEventUserQueryParam csEventUserQueryParam); List<EventDetailVO> queryUserEventList(CsEventUserQueryParam csEventUserQueryParam);
void updateStatus(CsEventUserQueryParam csEventUserQueryParam); void updateStatus(CsEventUserQueryParam csEventUserQueryParam);
@@ -34,4 +38,13 @@ public interface CsEventUserPOService extends IService<CsEventUserPO>{
Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage); Page<EventDetailVO> queryEventPageWeb(CsEventUserQueryPage csEventUserQueryPage);
Page<CsEventPO> getFrontWarnInfo(CldWarnParam baseParam); Page<CsEventPO> getFrontWarnInfo(CldWarnParam baseParam);
/**
* 查询用户事件列表
* @param userIndex
* @return
*/
List<CsEventUserPO> queryEventListByUserId(String userIndex,List<String> eventList);
} }

View File

@@ -0,0 +1,14 @@
package com.njcn.csharmonic.service;
import com.njcn.csdevice.pojo.vo.EngineeringHomePageVO;
import java.util.List;
/**
* @author xy
*/
public interface HomePageService {
List<EngineeringHomePageVO> getEngineeringHomePage();
}

View File

@@ -0,0 +1,24 @@
package com.njcn.csharmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csharmonic.pojo.po.CsAlarm;
import com.njcn.csharmonic.pojo.vo.AlarmVO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xy
* @since 2026-03-16
*/
public interface ICsAlarmService extends IService<CsAlarm> {
List<AlarmVO> queryAlarmList(LineParamDTO param);
List<AlarmVO.AlarmDetail> queryAlarmDetail(LineParamDTO.DevParamDTO param);
}

View File

@@ -0,0 +1,25 @@
package com.njcn.csharmonic.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csharmonic.pojo.po.CsHarmonic;
import com.njcn.csharmonic.pojo.vo.HarmonicDetailVO;
import com.njcn.csharmonic.pojo.vo.HarmonicVO;
import java.util.List;
/**
* <p>
* 服务类
* </p>
*
* @author xy
* @since 2026-03-13
*/
public interface ICsHarmonicService extends IService<CsHarmonic> {
HarmonicVO queryAppList(LineParamDTO param);
List<HarmonicDetailVO> queryHarmonicDetail(LineParamDTO param);
}

View File

@@ -3,8 +3,8 @@ package com.njcn.csharmonic.service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam; import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo; import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import java.util.List; import java.util.List;

View File

@@ -6,6 +6,7 @@ import com.njcn.csharmonic.pojo.param.LimitCalendarQueryParam;
import com.njcn.csharmonic.pojo.param.LimitExtentDayQueryParam; import com.njcn.csharmonic.pojo.param.LimitExtentDayQueryParam;
import com.njcn.csharmonic.pojo.param.LimitExtentQueryParam; import com.njcn.csharmonic.pojo.param.LimitExtentQueryParam;
import com.njcn.csharmonic.pojo.param.LimitProbabilityQueryParam; import com.njcn.csharmonic.pojo.param.LimitProbabilityQueryParam;
import com.njcn.csharmonic.pojo.po.RStatLimitRateDPO;
import com.njcn.csharmonic.pojo.po.RStatLimitRateDetailDPO; import com.njcn.csharmonic.pojo.po.RStatLimitRateDetailDPO;
import com.njcn.csharmonic.pojo.vo.LimitCalendarVO; import com.njcn.csharmonic.pojo.vo.LimitCalendarVO;
import com.njcn.csharmonic.pojo.vo.LimitExtentVO; import com.njcn.csharmonic.pojo.vo.LimitExtentVO;
@@ -27,4 +28,6 @@ public interface IRStatLimitRateDetailDService extends IService<RStatLimitRateDe
List<LimitProbabilityVO> limitProbabilityData(LimitProbabilityQueryParam param); List<LimitProbabilityVO> limitProbabilityData(LimitProbabilityQueryParam param);
List<LimitTimeProbabilityVO> limitTimeProbabilityData(LimitProbabilityQueryParam param); List<LimitTimeProbabilityVO> limitTimeProbabilityData(LimitProbabilityQueryParam param);
List<RStatLimitRateDetailDPO> monitorIdsGetLimitRateInfo(String date, List<String> monitorIds);
} }

View File

@@ -0,0 +1,200 @@
package com.njcn.csharmonic.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csharmonic.mapper.CsAlarmMapper;
import com.njcn.csharmonic.pojo.po.CsAlarm;
import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.AlarmVO;
import com.njcn.csharmonic.service.CsEventPOService;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.csharmonic.service.ICsAlarmService;
import com.njcn.system.api.EpdFeignClient;
import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
import static com.njcn.harmonic.utils.PublicDataUtils.calculateMonthEnd;
import static com.njcn.harmonic.utils.PublicDataUtils.calculateMonthStart;
/**
* <p>
* 服务实现类
* </p>
*
* @author xy
* @since 2026-03-16
*/
@Service
@AllArgsConstructor
public class CsAlarmServiceImpl extends ServiceImpl<CsAlarmMapper, CsAlarm> implements ICsAlarmService {
private final CsLedgerFeignClient csLedgerFeignClient;
private final CsEventUserPOService csEventUserPOService;
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
private final CsEventPOService csEventPOService;
private final EpdFeignClient epdFeignClient;
@Override
public List<AlarmVO> queryAlarmList(LineParamDTO param) {
List<AlarmVO> result = new ArrayList<>();
List<CsLedger> lineLedger = csLedgerFeignClient.queryLine(param).getData();
if (CollectionUtil.isNotEmpty(lineLedger)) {
List<CsLedger> devLedger = new ArrayList<>();
//获取所有台账数据
List<CsLedgerVO> ledgers = csLedgerFeignClient.getAllLedger().getData();
ledgers.forEach(item->{
lineLedger.forEach(item2->{
if (Objects.equals(item.getId(), item2.getPid())) {
devLedger.add(item2);
}
});
});
if (CollectionUtil.isNotEmpty(devLedger)) {
List<String> ownerDevList = csCommTerminalFeignClient.getDevIdsByUser(RequestUtil.getUserIndex()).getData();
List<String> devList = devLedger.stream().map(CsLedger::getPid).collect(Collectors.toList());
// 取 ownerDevList 和 devList 的交集
if (CollectionUtil.isNotEmpty(ownerDevList)) {
devList = devList.stream()
.filter(ownerDevList::contains)
.distinct()
.collect(Collectors.toList());
} else {
devList = new ArrayList<>();
}
LambdaQueryWrapper<CsAlarm> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.ge(StrUtil.isNotBlank(param.getTime()), CsAlarm::getTime, calculateMonthStart(param.getTime()))
.le(StrUtil.isNotBlank(param.getTime()), CsAlarm::getTime, calculateMonthEnd(param.getTime()))
.orderByDesc(CsAlarm::getTime);
//先获取设备通讯数据
List<CsAlarm> list = list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
//获取用户推送事件
List<CsEventUserPO> userEvents = csEventUserPOService.queryEventListByUserId(RequestUtil.getUserIndex(), list.stream().map(CsAlarm::getId).collect(Collectors.toList()));
List<String> finalDevList = devList;
result = list.stream()
.map(alarm -> {
AlarmVO alarmVO = new AlarmVO();
alarmVO.setEventId(alarm.getId());
alarmVO.setDate(alarm.getTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd")));
String devListStr = alarm.getDevList();
String[] devIds = devListStr.split(",");
List<String> matchedDevIds = Arrays.stream(devIds)
.filter(devId -> StrUtil.isNotBlank(devId.trim()))
.filter(finalDevList::contains)
.collect(Collectors.toList());
alarmVO.setWarnNums(matchedDevIds.size());
alarmVO.setDevIds(matchedDevIds);
alarmVO.setIsRead(userEvents.stream().filter(item1->item1.getEventId().equals(alarm.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(0));
return alarmVO;
})
.filter(alarmVO -> alarmVO.getWarnNums() > 0)
.sorted((a1, a2) -> a2.getDate().compareTo(a1.getDate()))
.collect(Collectors.toList());
}
}
}
return result;
}
@Override
public List<AlarmVO.AlarmDetail> queryAlarmDetail(LineParamDTO.DevParamDTO param) {
List<AlarmVO.AlarmDetail> result = new ArrayList<>();
LambdaQueryWrapper<CsAlarm> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(StrUtil.isNotBlank(param.getTime()), CsAlarm::getTime, param.getTime());
CsAlarm alarm = getOne(queryWrapper);
if (ObjectUtil.isNotNull(alarm)) {
//获取所有台账数据
List<CsLedgerVO> ledgers = csLedgerFeignClient.getAllLedger().getData();
Map<String,CsLedgerVO> ledgerMap = ledgers.stream().collect(Collectors.toMap(CsLedgerVO::getId, item->item));
String devStr = alarm.getDevList();
String[] devIds = devStr.split(",");
for (int i = 0; i < devIds.length; i++) {
for (int i1 = 0; i1 < param.getDevList().size(); i1++) {
if (Objects.equals(devIds[i], param.getDevList().get(i1))) {
CsLedgerVO csLedgerVO = ledgerMap.get(devIds[i]);
AlarmVO.AlarmDetail alarmDetail = new AlarmVO.AlarmDetail();
alarmDetail.setEngineeringName(ledgerMap.get(csLedgerVO.getPids().split(",")[1]).getName());
alarmDetail.setProjectName(ledgerMap.get(csLedgerVO.getPids().split(",")[2]).getName());
alarmDetail.setDevName(csLedgerVO.getName());
if (ObjectUtil.isNotNull(alarm.getInterruptEvent())) {
String interruptEvent = alarm.getInterruptEvent();
List<List<String>> resultList = new ArrayList<>();
if (StrUtil.isNotBlank(interruptEvent)) {
try {
ObjectMapper objectMapper = new ObjectMapper();
resultList = objectMapper.readValue(interruptEvent, new TypeReference<List<List<String>>>() {});
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
List<String> interruptDetails = resultList.get(i);
if (CollectionUtil.isNotEmpty(interruptDetails)) {
alarmDetail.setInterruptCounts(interruptDetails.get(0).split("").length);
alarmDetail.setInterruptDetails(interruptDetails);
}
}
if (ObjectUtil.isNotNull(alarm.getAlarmEvent())) {
String alarmEvent = alarm.getAlarmEvent();
List<List<String>> resultList = new ArrayList<>();
if (StrUtil.isNotBlank(alarmEvent)) {
try {
ObjectMapper objectMapper = new ObjectMapper();
resultList = objectMapper.readValue(alarmEvent, new TypeReference<List<List<String>>>() {});
} catch (JsonProcessingException e) {
e.printStackTrace();
}
}
List<String> eventDetails = resultList.get(i);
if (CollectionUtil.isNotEmpty(eventDetails)) {
alarmDetail.setWarnCounts(eventDetails.size());
//获取告警时间详情
List<CsEventPO> csEventPOList = csEventPOService.getEvents(eventDetails);
alarmDetail.setWarnDetails(csEventPOList.stream()
.map(event -> {
AlarmVO.AlarmDetail.WarnDetail warnDetail = new AlarmVO.AlarmDetail.WarnDetail();
warnDetail.setWarnEventTime(event.getStartTime().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")));
EleEpdPqd eleEpdPqd = epdFeignClient.findByName(event.getTag()).getData();
warnDetail.setWarnEventDesc(Objects.isNull(eleEpdPqd) ? event.getTag() : eleEpdPqd.getShowName());
return warnDetail;
}).collect(Collectors.toList())
);
alarmDetail.setWarnDetails(alarmDetail.getWarnDetails().stream().sorted((a1, a2) -> a2.getWarnEventTime().compareTo(a1.getWarnEventTime())).collect(Collectors.toList()));
}
}
result.add(alarmDetail);
}
}
}
}
return result;
}
}

View File

@@ -13,10 +13,12 @@ import com.baomidou.dynamic.datasource.annotation.DSTransactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.access.pojo.dto.NoticeUserDto;
import com.njcn.access.utils.SendMessageUtil;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
import com.njcn.csdevice.api.CsLedgerFeignClient; import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.api.EquipmentFeignClient;
import com.njcn.csdevice.enums.AlgorithmResponseEnum; import com.njcn.csdevice.enums.AlgorithmResponseEnum;
import com.njcn.csdevice.pojo.dto.DevDetailDTO; import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
@@ -30,6 +32,7 @@ import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.param.DataParam; import com.njcn.csharmonic.param.DataParam;
import com.njcn.csharmonic.pojo.param.EventStatisticParam; import com.njcn.csharmonic.pojo.param.EventStatisticParam;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.CsEventVO; import com.njcn.csharmonic.pojo.vo.CsEventVO;
import com.njcn.csharmonic.pojo.vo.CsWarnDescVO; import com.njcn.csharmonic.pojo.vo.CsWarnDescVO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
@@ -59,6 +62,11 @@ import com.njcn.system.enums.DicDataEnum;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import com.njcn.system.pojo.po.EleEpdPqd; import com.njcn.system.pojo.po.EleEpdPqd;
import com.njcn.system.pojo.po.EleEvtParm; import com.njcn.system.pojo.po.EleEvtParm;
import com.njcn.user.api.AppInfoSetFeignClient;
import com.njcn.user.api.AppUserFeignClient;
import com.njcn.user.api.UserFeignClient;
import com.njcn.user.pojo.po.User;
import com.njcn.user.pojo.po.app.AppInfoSet;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.RequestUtil; import com.njcn.web.utils.RequestUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -116,8 +124,13 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
private final MinIoUtils minIoUtils; private final MinIoUtils minIoUtils;
private final DicDataFeignClient dicDataFeignClient; private final DicDataFeignClient dicDataFeignClient;
private final WlRmpEventDetailMapper wlRmpEventDetailMapper; private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
//private final CommonEventWaveAnalysisService commonEventWaveAnalysisService; private final AppUserFeignClient appUserFeignClient;
private final EquipmentFeignClient equipmentFeignClient; private final CsDeviceUserFeignClient csDeviceUserFeignClient;
private final UserFeignClient userFeignClient;
private final AppInfoSetFeignClient appInfoSetFeignClient;
private final CsLedgerFeignClient csLedgerFeignclient;
private final SendMessageUtil sendMessageUtil;
@Override @Override
public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) { public List<EventDetailVO> queryEventList(CsEventUserQueryParam csEventUserQueryParam) {
@@ -407,6 +420,50 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
} }
//同步数据到 r_mp_event_detail //同步数据到 r_mp_event_detail
insertEvent(uuid, param, time); insertEvent(uuid, param, time);
//根据设备获取主用户、子用户,设置事件未读数据
NoticeUserDto noticeUserDto = new NoticeUserDto();
NoticeUserDto.Payload payload = new NoticeUserDto.Payload();
List<CsEventUserPO> result = new ArrayList<>();
List<String> eventUser = getEventUser(po.getDeviceId(),true);
//针对用户记录未读信息和推送告警
eventUser.forEach(item->{
CsEventUserPO csEventUser = new CsEventUserPO();
csEventUser.setUserId(item);
csEventUser.setStatus(0);
csEventUser.setEventId(uuid);
result.add(csEventUser);
});
List<User> users = getSendUser(eventUser,0);
if (CollectionUtil.isNotEmpty(users)){
List<String> devCodeList = users.stream().map(User::getDevCode).distinct().collect(Collectors.toList());
noticeUserDto.setPushClientId(devCodeList);
noticeUserDto.setTitle("暂态事件");
}
//获取台账信息
String eventName = epdFeignClient.findByName(getTag(param.getEventType())).getData().getShowName();
DevDetailDTO devDetailDto = csLedgerFeignclient.queryDevDetail(po.getDeviceId()).getData();
String content = devDetailDto.getEngineeringName() + "-" + devDetailDto.getProjectName() + "-" + devDetailDto.getEquipmentName() + "" + time.format(DatePattern.NORM_DATETIME_MS_FORMATTER) + "发生" + eventName;
noticeUserDto.setContent(content);
payload.setType(0);
payload.setPath("/pages/message/message?type="+payload.getType());
noticeUserDto.setPayload(payload);
if (CollectionUtil.isNotEmpty(noticeUserDto.getPushClientId())) {
List<String> filteredList = noticeUserDto.getPushClientId().stream()
.filter(Objects::nonNull)
.distinct()
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(filteredList)) {
noticeUserDto.setPushClientId(filteredList);
sendMessageUtil.sendEventToUser(noticeUserDto);
}
}
//事件用户关系入库
if (CollectionUtil.isNotEmpty(result)){
csEventUserPOService.saveBatch(result);
}
} else { } else {
if (StrUtil.isNotBlank(param.getWavePath())) { if (StrUtil.isNotBlank(param.getWavePath())) {
//更新文件信息 //更新文件信息
@@ -422,6 +479,54 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
} }
} }
public List<String> getEventUser(String devId,boolean isAdmin) {
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
if (isAdmin) {
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
adminList.addAll(list);
}
return adminList;
}
/**
* 获取所有打开推送的用户信息
*/
public List<User> getSendUser(List<String> userList,Integer type) {
List<User> users = new ArrayList<>();
List<String> result = new ArrayList<>();
List<AppInfoSet> appInfoSet = appInfoSetFeignClient.getListById(userList).getData();
switch (type) {
case 0:
result = appInfoSet.stream()
.filter(person -> person.getEventInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
case 1:
result = appInfoSet.stream()
.filter(person -> person.getHarmonicInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
case 2:
result = appInfoSet.stream()
.filter(person -> person.getRunInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
case 3:
result = appInfoSet.stream()
.filter(person -> person.getAlarmInfo() == 1)
.map(AppInfoSet::getUserId).collect(Collectors.toList());
break;
default:
break;
}
if (CollectionUtil.isNotEmpty(result)){
users = userFeignClient.appuserByIdList(result).getData();
}
return users;
}
public void insertEvent(String uuid, CldEventParam param, LocalDateTime time) { public void insertEvent(String uuid, CldEventParam param, LocalDateTime time) {
RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO(); RmpEventDetailPO rmpEventDetailPO = new RmpEventDetailPO();
rmpEventDetailPO.setEventId(uuid); rmpEventDetailPO.setEventId(uuid);
@@ -499,6 +604,23 @@ public class CsEventPOServiceImpl extends ServiceImpl<CsEventPOMapper, CsEventPO
return csWarnDescVOList; return csWarnDescVOList;
} }
@Override
public List<CsEventPO> getEvents(List<String> idList) {
LambdaQueryWrapper<CsEventPO> wrapper = new LambdaQueryWrapper<>();
wrapper.in(CsEventPO::getId,idList);
return this.list(wrapper);
}
@Override
public List<CsEventPO> getDevAlarmList(CsEventUserQueryParam param) {
LambdaQueryWrapper<CsEventPO> wrapper = new LambdaQueryWrapper<>();
wrapper.between(CsEventPO::getStartTime,param.getStartTime(),param.getEndTime())
.eq(CsEventPO::getType,3)
.in(CsEventPO::getLevel,Arrays.asList(1,2,3,6,7))
.in(CsEventPO::getDeviceId,param.getTarget());
return this.list(wrapper);
}
public String getTag(Integer type) { public String getTag(Integer type) {
String tag; String tag;
switch (type) { switch (type) {

View File

@@ -21,6 +21,7 @@ import com.njcn.csharmonic.mapper.CsEventUserPOMapper;
import com.njcn.csharmonic.param.CldWarnParam; import com.njcn.csharmonic.param.CldWarnParam;
import com.njcn.csharmonic.param.CsEventUserQueryPage; import com.njcn.csharmonic.param.CsEventUserQueryPage;
import com.njcn.csharmonic.param.CsEventUserQueryParam; import com.njcn.csharmonic.param.CsEventUserQueryParam;
import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
import com.njcn.csharmonic.pojo.po.CsEventPO; import com.njcn.csharmonic.pojo.po.CsEventPO;
import com.njcn.csharmonic.pojo.po.CsEventUserPO; import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.vo.EventDetailVO; import com.njcn.csharmonic.pojo.vo.EventDetailVO;
@@ -40,6 +41,8 @@ import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*; import java.util.*;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@@ -71,6 +74,11 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
return integer; return integer;
} }
@Override
public List<UnReadEventDto> queryEngineeringEventCount(String userIndex) {
return this.getBaseMapper().queryEngineeringEventCount(userIndex);
}
@Override @Override
public List<EventDetailVO> queryUserEventList(CsEventUserQueryParam csEventUserQueryParam) { public List<EventDetailVO> queryUserEventList(CsEventUserQueryParam csEventUserQueryParam) {
csEventUserQueryParam.setUserId(RequestUtil.getUserIndex()); csEventUserQueryParam.setUserId(RequestUtil.getUserIndex());
@@ -236,139 +244,194 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
if( Objects.equals(role, AppRoleEnum.APP_VIP_USER.getCode())&&Objects.equals(csEventUserQueryPage.getType(),"3")){ if( Objects.equals(role, AppRoleEnum.APP_VIP_USER.getCode())&&Objects.equals(csEventUserQueryPage.getType(),"3")){
csEventUserQueryPage.setLevel("3"); csEventUserQueryPage.setLevel("3");
} }
// if( Objects.equals(role, AppRoleEnum.OPERATION_MANAGER.getCode())||Objects.equals(role, AppRoleEnum.ROOT.getCode())){
// csEventUserQueryPage.setUserId(null);
// flag = Boolean.FALSE;
// }
List<String> deviceId = new ArrayList<>();
List<CsLedgerVO> data = csLedgerFeignClient.getDeviceTree().getData();
// List<String> collect = data.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())|| List<CsLedgerVO> data = csLedgerFeignClient.lineTree().getData();
// Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid())).map(CsLedgerVO::getChildren). if (CollectionUtils.isEmpty(data)) {
// flatMap(Collection::stream).filter(
// temp->StringUtils.isEmpty(csEventUserQueryPage.getProjectId())||
// Objects.equals(temp.getId(), csEventUserQueryPage.getProjectId())
// ).
// map(CsLedgerVO::getChildren).
// flatMap(Collection::stream).filter(
// temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
// Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
// ).
// map(CsLedgerVO::getId).
// collect(Collectors.toList());
List<String> collect = data.stream().filter(temp->StringUtils.isEmpty(csEventUserQueryPage.getEngineeringid())||
Objects.equals(temp.getId(), csEventUserQueryPage.getEngineeringid()))
.map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getProjectId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getProjectId())
).
map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).
map(CsLedgerVO::getChildren).flatMap(Collection::stream).filter(
temp->StringUtils.isEmpty(csEventUserQueryPage.getDeviceId())||
Objects.equals(temp.getId(), csEventUserQueryPage.getDeviceId())
).
map(CsLedgerVO::getId).
collect(Collectors.toList());
if (CollectionUtils.isEmpty(collect)){
return returnpage; return returnpage;
} }
returnpage = this.getBaseMapper().queryEventpage(returnpage,csEventUserQueryPage,collect,flag); // 获取第一层节点(根节点),从第二层开始才是真正的工程
List<CsLedgerVO> firstLevelNodes = new ArrayList<>();
for (CsLedgerVO rootNode : data) {
List<CsLedgerVO> children = rootNode.getChildren();
if (CollectionUtil.isNotEmpty(children)) {
firstLevelNodes.addAll(children);
}
}
returnpage.getRecords().forEach(temp->{ if (CollectionUtils.isEmpty(firstLevelNodes)) {
DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData(); return returnpage;
temp.setEquipmentName(devDetail.getEquipmentName()); }
temp.setProjectId(devDetail.getProjectId());
temp.setProjectName(devDetail.getProjectName());
temp.setEngineeringid(devDetail.getEngineeringid());
temp.setEngineeringName(devDetail.getEngineeringName());
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
temp.setShowName(ele.getShowName());
temp.setCode(ele.getDefaultValue());
if(Objects.equals(csEventUserQueryPage.getType(),"0")){
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData(); // 缓存查询条件到局部变量
List<EventDataSetDTO> eventDataSetDTOS = new ArrayList<>(); String engineeringId = csEventUserQueryPage.getEngineeringid();
for (EleEvtParm eleEvtParm : data1) { String projectId = csEventUserQueryPage.getProjectId();
EventDataSetDTO eventDataSetDTO = new EventDataSetDTO(); String deviceId = csEventUserQueryPage.getDeviceId();
BeanUtils.copyProperties(eleEvtParm,eventDataSetDTO); String lineId = csEventUserQueryPage.getLineId();
if (Objects.equals(eventDataSetDTO.getName(),"Evt_Param_Position")) {
continue;
// eventDataSetDTO.setValue(Objects.equals(temp.getLocation(),"grid")?"电网侧":"负载侧");
}
EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName());
if (evtData == null) {
eventDataSetDTO.setValue("-");
}else {
eventDataSetDTO.setValue(Optional.ofNullable(evtData.getValue()).orElse("-"));
}
// if (Objects.equals(eventDataSetDTO.getName(),"Evt_Param_Position")) {
// eventDataSetDTO.setValue(Objects.equals(temp.getLocation(),"grid")?"电网侧":"负载侧");
// }
eventDataSetDTOS.add(eventDataSetDTO);
}
temp.setDataSet(eventDataSetDTOS);
List<EventDataSetDTO> evtParamVVaDepth = eventDataSetDTOS.stream().
filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_VVaDepth")).
collect(Collectors.toList());
if(CollectionUtil.isEmpty(evtParamVVaDepth)){
temp.setEvtParamVVaDepth("-");
}else {
temp.setEvtParamVVaDepth(evtParamVVaDepth.get(0).getValue()+(Objects.isNull(evtParamVVaDepth.get(0).getUnit())?"":evtParamVVaDepth.get(0).getUnit()));
}
List<EventDataSetDTO> evtParamPosition = eventDataSetDTOS.stream().
filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Position")).
collect(Collectors.toList());
if(CollectionUtil.isEmpty(evtParamPosition)){
temp.setEvtParamPosition("-");
}else {
//temp.setEvtParamPosition(evtParamPosition.get(0).getValue()+(Objects.isNull(evtParamPosition.get(0).getUnit())?"":evtParamPosition.get(0).getUnit()));
temp.setEvtParamPosition(evtParamPosition.get(0).getValue());
}
if (Objects.equals(temp.getEvtParamPosition(),"-")) {
if (!Objects.isNull(temp.getLocation())) {
temp.setEvtParamPosition(Objects.equals(temp.getLocation(),"grid")?"电网侧":"负载侧");
}
}
List<EventDataSetDTO> evtParamTm = eventDataSetDTOS.stream().
filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Tm")).
collect(Collectors.toList());
if(CollectionUtil.isEmpty(evtParamTm)){
temp.setEvtParamTm("-");
}else {
temp.setEvtParamTm(evtParamTm.get(0).getValue()+(Objects.isNull(evtParamTm.get(0).getUnit())?"":evtParamTm.get(0).getUnit()));
}
List<EventDataSetDTO> evtParamPhase = eventDataSetDTOS.stream().
filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Phase")).
collect(Collectors.toList());
if(CollectionUtil.isEmpty(evtParamPhase)){
temp.setEvtParamPhase("-");
}else {
temp.setEvtParamPhase(evtParamPhase.get(0).getValue()+(Objects.isNull(evtParamPhase.get(0).getUnit())?"":evtParamPhase.get(0).getUnit()));
}
// 从第二层开始遍历:工程 -> 项目 -> 设备 -> 监测点
List<String> collect = new ArrayList<>();
for (CsLedgerVO engineering : firstLevelNodes) {
// 过滤工程
if (StringUtil.isNotBlank(engineeringId)
&& !Objects.equals(engineering.getId(), engineeringId)) {
continue;
} }
}); List<CsLedgerVO> projects = engineering.getChildren();
if (CollectionUtils.isEmpty(projects)) {
continue;
}
for (CsLedgerVO project : projects) {
// 过滤项目
if (StringUtil.isNotBlank(projectId)
&& !Objects.equals(project.getId(), projectId)) {
continue;
}
List<CsLedgerVO> devices = project.getChildren();
if (CollectionUtils.isEmpty(devices)) {
continue;
}
for (CsLedgerVO device : devices) {
// 过滤设备
if (StringUtil.isNotBlank(deviceId)
&& !Objects.equals(device.getId(), deviceId)) {
continue;
}
// 如果传了监测点 ID需要进一步过滤
if (StringUtil.isNotBlank(lineId)) {
List<CsLedgerVO> lines = device.getChildren();
if (CollectionUtil.isNotEmpty(lines)) {
boolean hasLine = lines.stream()
.anyMatch(line -> Objects.equals(line.getId(), lineId));
if (hasLine) {
collect.add(device.getId());
}
}
} else {
// 没有传监测点 ID直接添加设备 ID
collect.add(device.getId());
}
}
}
}
if (CollectionUtils.isEmpty(collect)) {
return returnpage;
}
returnpage = this.getBaseMapper().queryEventpage(returnpage, csEventUserQueryPage, collect, flag);
// 先获取原始记录
List<EventDetailVO> originalRecords = returnpage.getRecords();
if (CollectionUtil.isNotEmpty(originalRecords)) {
// 过滤出满足 lineId 条件的记录
List<EventDetailVO> filteredRecords = new ArrayList<>();
for (EventDetailVO temp : originalRecords) {
// 如果没有传 lineId 或者 lineId 匹配,则处理该记录
if (StringUtil.isBlank(csEventUserQueryPage.getLineId())
|| Objects.equals(temp.getLineId(), csEventUserQueryPage.getLineId())) {
DevDetailDTO devDetail = csLedgerFeignClient.queryDevDetail(temp.getDeviceId()).getData();
temp.setEquipmentName(devDetail.getEquipmentName());
temp.setProjectId(devDetail.getProjectId());
temp.setProjectName(devDetail.getProjectName());
temp.setEngineeringid(devDetail.getEngineeringid());
temp.setEngineeringName(devDetail.getEngineeringName());
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
temp.setShowName(Objects.isNull(ele) ? temp.getTag() : ele.getShowName());
temp.setCode(Objects.isNull(ele) ? null : ele.getDefaultValue());
if (Objects.equals(csEventUserQueryPage.getType(), "0")) {
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData();
List<EventDataSetDTO> eventDataSetDTOS = new ArrayList<>();
for (EleEvtParm eleEvtParm : data1) {
EventDataSetDTO eventDataSetDTO = new EventDataSetDTO();
BeanUtils.copyProperties(eleEvtParm, eventDataSetDTO);
if (Objects.equals(eventDataSetDTO.getName(), "Evt_Param_Position")) {
continue;
}
EventDataSetDTO evtData = evtDataService.getEventDataSet("evt_data", temp.getId(), eleEvtParm.getName());
if (evtData == null) {
eventDataSetDTO.setValue("-");
} else {
if (Objects.equals(eleEvtParm.getName(), "Evt_Param_VVaDepth") || Objects.equals(eleEvtParm.getName(), "Evt_Param_Tm")) {
BigDecimal bd = new BigDecimal(evtData.getValue());
bd = bd.setScale(2, RoundingMode.HALF_UP);
eventDataSetDTO.setValue(Optional.ofNullable(bd.toString()).orElse("-"));
} else {
eventDataSetDTO.setValue(Optional.ofNullable(evtData.getValue()).orElse("-"));
}
}
eventDataSetDTOS.add(eventDataSetDTO);
}
temp.setDataSet(eventDataSetDTOS);
List<EventDataSetDTO> evtParamVVaDepth = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_VVaDepth"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamVVaDepth)) {
temp.setEvtParamVVaDepth("-");
} else {
if (Objects.equals(evtParamVVaDepth.get(0).getValue(),"-")) {
temp.setEvtParamVVaDepth("-");
} else {
BigDecimal bd = new BigDecimal(evtParamVVaDepth.get(0).getValue());
bd = bd.setScale(2, RoundingMode.HALF_UP);
temp.setEvtParamVVaDepth(bd + (Objects.isNull(evtParamVVaDepth.get(0).getUnit()) ? "" : evtParamVVaDepth.get(0).getUnit()));
}
}
List<EventDataSetDTO> evtParamPosition = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Position"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamPosition)) {
temp.setEvtParamPosition("-");
} else {
temp.setEvtParamPosition(evtParamPosition.get(0).getValue());
}
if (Objects.equals(temp.getEvtParamPosition(), "-")) {
if (!Objects.isNull(temp.getLocation())) {
temp.setEvtParamPosition(Objects.equals(temp.getLocation(), "grid") ? "电网侧" : "负载侧");
}
}
List<EventDataSetDTO> evtParamTm = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Tm"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamTm)) {
temp.setEvtParamTm("-");
} else {
if (Objects.equals(evtParamTm.get(0).getValue(),"-")) {
temp.setEvtParamTm("-");
} else {
BigDecimal bd = new BigDecimal(evtParamTm.get(0).getValue());
bd = bd.setScale(2, RoundingMode.HALF_UP);
temp.setEvtParamTm(bd + (Objects.isNull(evtParamTm.get(0).getUnit()) ? "" : evtParamTm.get(0).getUnit()));
}
}
List<EventDataSetDTO> evtParamPhase = eventDataSetDTOS.stream()
.filter(dataSetDTO -> Objects.equals(dataSetDTO.getName(), "Evt_Param_Phase"))
.collect(Collectors.toList());
if (CollectionUtil.isEmpty(evtParamPhase)) {
temp.setEvtParamPhase("-");
} else {
temp.setEvtParamPhase(evtParamPhase.get(0).getValue()
+ (Objects.isNull(evtParamPhase.get(0).getUnit()) ? "" : evtParamPhase.get(0).getUnit()));
}
}
// 将处理后的记录添加到结果列表
filteredRecords.add(temp);
}
}
// 清空原来的记录,加入过滤后的记录
returnpage.setRecords(filteredRecords);
}
return returnpage; return returnpage;
} }
@@ -557,4 +620,11 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
} }
return page; return page;
} }
@Override
public List<CsEventUserPO> queryEventListByUserId(String userIndex, List<String> eventList) {
LambdaQueryWrapper<CsEventUserPO> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(CsEventUserPO::getUserId, userIndex).in(CsEventUserPO::getEventId, eventList);
return baseMapper.selectList(queryWrapper);
}
} }

View File

@@ -0,0 +1,339 @@
package com.njcn.csharmonic.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.pojo.dto.LineParamDTO;
import com.njcn.csdevice.pojo.po.CsLedger;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csharmonic.mapper.CsHarmonicMapper;
import com.njcn.csharmonic.pojo.dto.PhaseData;
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
import com.njcn.csharmonic.pojo.po.CsHarmonic;
import com.njcn.csharmonic.pojo.po.RStatLimitRateDetailDPO;
import com.njcn.csharmonic.pojo.vo.HarmonicDetailVO;
import com.njcn.csharmonic.pojo.vo.HarmonicVO;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.csharmonic.service.ICsHarmonicService;
import com.njcn.csharmonic.service.IRStatLimitRateDetailDService;
import com.njcn.harmonic.utils.PublicDataUtils;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import java.lang.reflect.Field;
import java.text.DecimalFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
/**
* <p>
* 服务实现类
* </p>
*
* @author xy
* @since 2026-03-13
*/
@AllArgsConstructor
@Service
public class CsHarmonicServiceImpl extends ServiceImpl<CsHarmonicMapper, CsHarmonic> implements ICsHarmonicService {
private final CsLedgerFeignClient csLedgerFeignClient;
private final CsEventUserPOService csEventUserPOService;
private final IRStatLimitRateDetailDService rStatLimitRateDetailDService;
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
@Override
public HarmonicVO queryAppList(LineParamDTO param) {
HarmonicVO vo = new HarmonicVO();
List<CsLedger> lineLedger = csLedgerFeignClient.queryLine(param).getData();
if (CollectionUtil.isNotEmpty(lineLedger)) {
List<String> lineIds = lineLedger.stream().map(CsLedger::getId).collect(Collectors.toList());
//根据用户获取设备数据权限
List<String> ownerList = csCommTerminalFeignClient.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
List<String> combinedLineIds = new ArrayList<>();
if (CollectionUtil.isNotEmpty(ownerList)) {
combinedLineIds = lineIds.stream()
.filter(ownerList::contains)
.distinct()
.collect(Collectors.toList());
} else {
combinedLineIds = lineIds;
}
LambdaQueryWrapper<CsHarmonic> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.in(CsHarmonic::getLineId, combinedLineIds)
.ge(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthStart(param.getTime()))
.le(StrUtil.isNotBlank(param.getTime()), CsHarmonic::getTime, PublicDataUtils.calculateMonthEnd(param.getTime()))
.orderByDesc(CsHarmonic::getTime);
List<CsHarmonic> list = list(queryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
//获取所有台账数据
List<CsLedgerVO> ledgers = csLedgerFeignClient.getAllLedger().getData();
Map<String,CsLedgerVO> ledgerMap = ledgers.stream().collect(Collectors.toMap(CsLedgerVO::getId, item->item));
List<HarmonicVO.LineHarmonicDetail> lineHarmonicDetails = new ArrayList<>();
vo.setHarmonicNums(list.size());
//获取越限天数
Set<LocalDate> distinctTimes = list.stream().map(CsHarmonic::getTime).filter(Objects::nonNull).collect(Collectors.toSet());
int overDay = distinctTimes.size();
vo.setOverDays(overDay);
//获取监测点
Set<String> distinctLineIds = list.stream().map(CsHarmonic::getLineId).collect(Collectors.toSet());
int overLine = distinctLineIds.size();
vo.setOverLineNums(overLine);
//获取用户推送事件
List<CsEventUserPO> userEvents = csEventUserPOService.queryEventListByUserId(RequestUtil.getUserIndex(), list.stream().map(CsHarmonic::getId).collect(Collectors.toList()));
list.forEach(item->{
CsLedger ledger = lineLedger.stream().filter(item1->item1.getId().equals(item.getLineId())).findFirst().orElse(null);
HarmonicVO.LineHarmonicDetail lineHarmonicDetail = new HarmonicVO.LineHarmonicDetail();
lineHarmonicDetail.setEventId(item.getId());
lineHarmonicDetail.setEngineeringName(ledgerMap.get(ledger.getPids().split(",")[1]).getName());
lineHarmonicDetail.setProjectName(ledgerMap.get(ledger.getPids().split(",")[2]).getName());
lineHarmonicDetail.setDevName(ledgerMap.get(ledger.getPids().split(",")[3]).getName());
lineHarmonicDetail.setLineId(item.getLineId());
lineHarmonicDetail.setLineName(ledger.getName());
lineHarmonicDetail.setStatisticsDate(item.getTime());
lineHarmonicDetail.setOverLimitDesc(item.getTag());
lineHarmonicDetail.setIsRead(userEvents.stream().filter(item1->item1.getEventId().equals(item.getId())).findFirst().map(CsEventUserPO::getStatus).orElse(0));
lineHarmonicDetails.add(lineHarmonicDetail);
});
vo.setList(lineHarmonicDetails);
}
}
return vo;
}
@Override
public List<HarmonicDetailVO> queryHarmonicDetail(LineParamDTO param) {
List<HarmonicDetailVO> list = new ArrayList<>();
//先获取越限详细数据
List<RStatLimitRateDetailDPO> overData = rStatLimitRateDetailDService.monitorIdsGetLimitRateInfo(param.getTime(), Collections.singletonList(param.getLineId()));
//定义监测项配置:字段名 -> 名称前缀
Map<String, String> simpleFields = new LinkedHashMap<>();
simpleFields.put("freqDevOvertime", "频率偏差");
simpleFields.put("voltageDevOvertime", "电压偏差");
simpleFields.put("ubalanceOvertime", "三相电压不平衡度");
simpleFields.put("flickerOvertime", "闪变");
simpleFields.put("uaberranceOvertime", "电压总谐波畸变率");
simpleFields.put("iNegOvertime", "负序电流");
//根据数据组装
overData.forEach(item->{
// 处理简单字段
simpleFields.forEach((fieldName, targetName) -> {
String json = reflectGetValue(item, fieldName);
addHarmonicData(list, json, targetName);
});
// 处理谐波电压含有率 (2-25 次)
for (int i = 2; i <= 25; i++) {
String json = reflectGetValue(item, "uharm" + i + "Overtime");
addHarmonicData(list, json, i + "次谐波电压含有率");
}
// 处理谐波电流有效值 (2-25 次)
for (int i = 2; i <= 25; i++) {
String json = reflectGetValue(item, "iharm" + i + "Overtime");
addHarmonicData(list, json, i + "次谐波电流有效值");
}
// 处理间谐波电压含有率 (0.5-15.5 次)
for (int i = 1; i <= 16; i++) {
String json = reflectGetValue(item, "inuharm" + i + "Overtime");
addHarmonicData(list, json, (i-0.5) + "次间谐波电压含有率");
}
});
return list;
}
/**
* 添加谐波数据到列表
* @param list 结果列表
* @param jsonData JSON 数据
* @param targetName 监测项名称
*/
private void addHarmonicData(List<HarmonicDetailVO> list, String jsonData, String targetName) {
if (ObjectUtil.isNotNull(jsonData)) {
HarmonicDetailVO vo = new HarmonicDetailVO();
vo.setTargetName(targetName);
vo.setHarmDetailList(AnalyzeData(jsonData));
list.add(vo);
}
}
/**
* 使用反射获取对象的字段值
* @param obj 对象实例
* @param fieldName 字段名
* @return 字段值
*/
private String reflectGetValue(Object obj, String fieldName) {
try {
Field field = obj.getClass().getDeclaredField(fieldName);
field.setAccessible(true);
Object value = field.get(obj);
return value == null ? null : value.toString();
} catch (Exception e) {
return null;
}
}
public List<HarmonicDetailVO.HarmDetail> AnalyzeData(String jsonString) {
List<HarmonicDetailVO.HarmDetail> result = new ArrayList<>();
ObjectMapper mapper = new ObjectMapper();
List<PhaseData> phaseDataList = null;
try {
phaseDataList = mapper.readValue(jsonString, new TypeReference<List<PhaseData>>() {});
// 合并数据
Map<String, Map<String, String>> mergedData = new TreeMap<>(new TimeComparator());
for (PhaseData phaseData : phaseDataList) {
String[] times = phaseData.time.split(",");
String[] values = phaseData.value.split(",");
for (int i = 0; i < times.length; i++) {
String time = times[i].trim();
mergedData.putIfAbsent(time, new HashMap<>());
mergedData.get(time).put(phaseData.phasic, values[i].trim());
}
}
// 构建所有详情列表
List<HarmonicDetailVO.HarmDetail> allDetails = new ArrayList<>();
for (Map.Entry<String, Map<String, String>> entry : mergedData.entrySet()) {
String time = entry.getKey();
Map<String, String> values = entry.getValue();
HarmonicDetailVO.HarmDetail detail = new HarmonicDetailVO.HarmDetail();
detail.setStatisticsTime(time);
detail.setDataA(formatValue(values.get("A")));
detail.setDataB(formatValue(values.get("B")));
detail.setDataC(formatValue(values.get("C")));
detail.setDataT(formatValue(values.get("T")));
detail.setValueType(phaseDataList.get(0).valueType);
detail.setOverLimitData(phaseDataList.get(0).overLimitValue);
detail.setHasT(values.containsKey("T"));
allDetails.add(detail);
}
// 选取最严重的 10 条记录(按 dataT 的绝对值排序,如果没有则取其他相)
List<HarmonicDetailVO.HarmDetail> top10Details = allDetails.stream()
.sorted((d1, d2) -> {
Double v1 = getNumericValue(d1);
Double v2 = getNumericValue(d2);
return Double.compare(Math.abs(v2), Math.abs(v1));
})
.limit(10)
.collect(Collectors.toList());
// 按时间排序后返回
result = top10Details.stream()
.sorted((d1, d2) -> {
String t1 = d1.getStatisticsTime();
String t2 = d2.getStatisticsTime();
if (t1 == null || t2 == null) {
return 0;
}
String[] parts1 = t1.split(":");
String[] parts2 = t2.split(":");
for (int i = 0; i < 3; i++) {
int cmp = Integer.compare(Integer.parseInt(parts1[i]), Integer.parseInt(parts2[i]));
if (cmp != 0) return cmp;
}
return 0;
})
.collect(Collectors.toList());
} catch (JsonProcessingException e) {
throw new RuntimeException(e);
}
return result;
}
/**
* 获取用于比较严重程度的数值
* @param detail 谐波详情
* @return 各相数据的绝对值之和
*/
private Double getNumericValue(HarmonicDetailVO.HarmDetail detail) {
double sum = 0.0;
// 累加 dataA
String dataA = detail.getDataA();
if (dataA != null && !"/".equals(dataA)) {
try {
sum += Math.abs(Double.parseDouble(dataA));
} catch (NumberFormatException e) {
// 忽略解析失败的数据
}
}
// 累加 dataB
String dataB = detail.getDataB();
if (dataB != null && !"/".equals(dataB)) {
try {
sum += Math.abs(Double.parseDouble(dataB));
} catch (NumberFormatException e) {
// 忽略解析失败的数据
}
}
// 累加 dataC
String dataC = detail.getDataC();
if (dataC != null && !"/".equals(dataC)) {
try {
sum += Math.abs(Double.parseDouble(dataC));
} catch (NumberFormatException e) {
// 忽略解析失败的数据
}
}
// 累加 dataT
String dataT = detail.getDataT();
if (dataT != null && !"/".equals(dataT)) {
try {
sum += Math.abs(Double.parseDouble(dataT));
} catch (NumberFormatException e) {
// 忽略解析失败的数据
}
}
return sum;
}
/**
* 格式化数值:有值则保留两位小数,无值则返回 /
* @param value 原始字符串值
* @return 格式化后的字符串
*/
private String formatValue(String value) {
if (value == null || value.trim().isEmpty() || "/".equals(value.trim())) {
return "/";
}
try {
DecimalFormat df = new DecimalFormat("0.00");
return df.format(Double.parseDouble(value));
} catch (NumberFormatException e) {
return "/";
}
}
static class TimeComparator implements Comparator<String> {
@Override
public int compare(String t1, String t2) {
String[] parts1 = t1.split(":");
String[] parts2 = t2.split(":");
for (int i = 0; i < 3; i++) {
int cmp = Integer.compare(Integer.parseInt(parts1[i]), Integer.parseInt(parts2[i]));
if (cmp != 0) return cmp;
}
return 0;
}
}
}

View File

@@ -0,0 +1,111 @@
package com.njcn.csharmonic.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import com.njcn.csdevice.api.CsLedgerFeignClient;
import com.njcn.csdevice.api.CsUserPinsFeignClient;
import com.njcn.csdevice.api.EngineeringFeignClient;
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
import com.njcn.csdevice.pojo.param.CsEngineeringQueryParm;
import com.njcn.csdevice.pojo.po.CsUserPins;
import com.njcn.csdevice.pojo.vo.CsEngineeringVO;
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
import com.njcn.csdevice.pojo.vo.EngineeringHomePageVO;
import com.njcn.csharmonic.pojo.dto.UnReadEventDto;
import com.njcn.csharmonic.service.CsEventUserPOService;
import com.njcn.csharmonic.service.HomePageService;
import com.njcn.web.utils.RequestUtil;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author xy
*/
@Service
@AllArgsConstructor
@Slf4j
public class HomePageServiceImpl implements HomePageService {
private final CsEventUserPOService csEventUserPOService;
private final EngineeringFeignClient engineeringFeignClient;
private final CsLedgerFeignClient csLedgerFeignClient;
private final CsUserPinsFeignClient csUserPinsFeignClient;
@Override
public List<EngineeringHomePageVO> getEngineeringHomePage() {
List<EngineeringHomePageVO> result = new ArrayList<>();
List<CsEngineeringVO> engineeringList = engineeringFeignClient.queryEngineering(new CsEngineeringQueryParm()).getData();
if (CollectionUtils.isNotEmpty(engineeringList)) {
List<String> engineeringIds = engineeringList.stream().map(CsEngineeringVO::getId).collect(Collectors.toList());
//根据工程获取设备信息
List<DevDetailDTO> devList = csLedgerFeignClient.getDevInfoByEngineerIds(engineeringIds).getData();
Map<String, List<DevDetailDTO>> devMap = devList.stream().collect(Collectors.groupingBy(DevDetailDTO::getEngineeringid));
//获取未读事件
List<UnReadEventDto> unReadEventList = csEventUserPOService.queryEngineeringEventCount(RequestUtil.getUserIndex());
Map<String, List<UnReadEventDto>> unReadEventMap = unReadEventList.stream().collect(Collectors.groupingBy(UnReadEventDto::getDeviceId));
engineeringList.forEach(item->{
EngineeringHomePageVO vo = new EngineeringHomePageVO();
vo.setEngineeringId(item.getId());
vo.setEngineeringName(item.getName());
List<DevDetailDTO> devs = devMap.get(item.getId());
vo.setDevTotal(Objects.isNull(devs) ? 0:devs.size());
long status1Count = devs == null ? 0 : devs.stream().filter(d -> d.getRunStatus() == 1).count();
long status2Count = devs == null ? 0 : devs.stream().filter(d -> d.getRunStatus() == 2).count();
vo.setOnlineDevTotal((int) status2Count);
vo.setOfflineDevTotal((int) status1Count);
vo.setSort(item.getSort());
//未读的告警数量
int alarmTotal = Objects.isNull(devs) ? 0 : devs.stream()
.map(DevDetailDTO::getEquipmentId)
.filter(Objects::nonNull)
.mapToInt(deviceId -> {
List<UnReadEventDto> events = unReadEventMap.get(deviceId);
return Objects.isNull(events) ? 0 : events.stream()
.mapToInt(UnReadEventDto::getCount)
.sum();
})
.sum();
vo.setAlarmTotal(alarmTotal);
result.add(vo);
});
//获取用户是否有置顶的工程
List<CsUserPins> pinList = csUserPinsFeignClient.getPinToTopList().getData();
if (CollectionUtils.isNotEmpty(pinList)) {
List<String> targetIdList = pinList.stream()
.filter(item -> Objects.equals(item.getTargetType(), 2))
.map(CsUserPins::getTargetId)
.collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(targetIdList)) {
// 分离出匹配 targetIdList 的节点和未匹配的节点
List<EngineeringHomePageVO> matchedList = new ArrayList<>();
List<EngineeringHomePageVO> unmatchedList = new ArrayList<>();
for (EngineeringHomePageVO node : result) {
if (targetIdList.contains(node.getEngineeringId())) {
node.setIsTop(1);
matchedList.add(node);
} else {
unmatchedList.add(node);
}
}
// 根据 targetIdList 的顺序对匹配的节点进行排序
matchedList.sort(Comparator.comparingInt(node -> targetIdList.indexOf(node.getEngineeringId())));
// 未匹配的节点按照原有的 sort 字段排序,处理 null 值情况
unmatchedList.sort(Comparator.comparing(node -> node.getSort() != null ? node.getSort() : Integer.MAX_VALUE));
// 清空原列表并添加排序后的数据
result.clear();
result.addAll(matchedList);
result.addAll(unmatchedList);
}
}
}
return result;
}
}

View File

@@ -12,11 +12,11 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException; import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.csdevice.api.CsLineFeignClient; import com.njcn.csdevice.api.CsLineFeignClient;
import com.njcn.csdevice.pojo.po.CsLinePO; import com.njcn.csdevice.pojo.po.CsLinePO;
import com.njcn.csharmonic.mapper.PqSensitiveUserMapper;
import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam; import com.njcn.csharmonic.pojo.param.PqSensitiveUserParam;
import com.njcn.csharmonic.pojo.po.PqSensitiveUser;
import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo; import com.njcn.csharmonic.pojo.vo.PqSensitiveUserVo;
import com.njcn.csharmonic.service.IPqSensitiveUserService; import com.njcn.csharmonic.service.IPqSensitiveUserService;
import com.njcn.device.biz.mapper.PqSensitiveUserMapper;
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
import com.njcn.system.api.DicDataFeignClient; import com.njcn.system.api.DicDataFeignClient;
import com.njcn.system.pojo.po.DictData; import com.njcn.system.pojo.po.DictData;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;

View File

@@ -521,6 +521,13 @@ public class RStatLimitRateDetailDServiceImpl extends ServiceImpl<RStatLimitRate
return result; return result;
} }
@Override
public List<RStatLimitRateDetailDPO> monitorIdsGetLimitRateInfo(String date, List<String> monitorIds) {
return this.baseMapper.selectList(new LambdaQueryWrapper<RStatLimitRateDetailDPO>()
.in(RStatLimitRateDetailDPO::getLineId, monitorIds)
.eq(RStatLimitRateDetailDPO::getTime, date));
}
/** /**
* 设置LimitExtentVO的最大值和相关信息 * 设置LimitExtentVO的最大值和相关信息
*/ */

View File

@@ -1,48 +1,58 @@
//package com.njcn; package com.njcn;
//
//import com.njcn.influx.utils.InfluxDbUtils; import com.njcn.influx.utils.InfluxDbUtils;
//import com.njcn.influxdb.param.InfluxDBPublicParam; import lombok.AllArgsConstructor;
//import com.njcn.influxdb.utils.InfluxDbUtils; import org.influxdb.InfluxDB;
//import lombok.AllArgsConstructor; import org.influxdb.dto.BatchPoints;
//import org.influxdb.InfluxDB; import org.influxdb.dto.Point;
//import org.influxdb.dto.BatchPoints;
//import org.influxdb.dto.Point; import java.util.*;
// import java.util.concurrent.TimeUnit;
//import java.util.*;
//import java.util.concurrent.TimeUnit; /**
// * 类的介绍:
///** *
// * 类的介绍: * @author xuyang
// * * @version 1.0.0
// * @author xuyang * @createTime 2023/6/5 14:44
// * @version 1.0.0 */
// * @createTime 2023/6/5 14:44 @AllArgsConstructor
// */ public class InfluxDbTest {
//@AllArgsConstructor
//public class InfluxDbTest { public static void main(String[] args) {
// InfluxDbUtils influxDbUtils = new InfluxDbUtils("root", "123456", "http://127.0.0.1:8086", "pqsadmin_jb", "");
// public static void main(String[] args) { List<String> records = new ArrayList<>();
// InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "123456", "http://192.168.1.16:8086", "pqsbase_zl", ""); List<String> phasic = Arrays.asList("A","B","C","M");
// List<String> records = new ArrayList<>(); List<String> dataType = Arrays.asList("max","min","avg","cp95");
// List<String> phasic = Arrays.asList("A","B","C"); long time = System.currentTimeMillis();
// List<String> dataType = Arrays.asList("max","min","avg","cp95"); for (String item1 : phasic) {
// long time = System.currentTimeMillis(); for (String item2 : dataType) {
// for (String item1 : phasic) { Map<String, String> tags = new HashMap<>();
// for (String item2 : dataType) { Map<String, Object> fields = new HashMap<>();
// Map<String, String> tags = new HashMap<>(); tags.put("line_id","00B78D0171091");
// Map<String, Object> fields = new HashMap<>(); tags.put("phasic_type",item1);
// tags.put("line_id","4aea410500fc0cea5a62790e8d493542"); tags.put("value_type",item2);
// tags.put("phasic_type",item1); tags.put("cl_did","1");
// tags.put("value_type",item2); tags.put("process","4");
// fields.put("Hz",new Random().nextDouble()); tags.put("quality_flag","0");
// fields.put("PhV",new Random().nextDouble()); fields.put("Pq_P",1);
// Point point = influxDbUtils.pointBuilder("data_v", time, TimeUnit.MILLISECONDS, tags, fields); fields.put("Pq_PF",null);
// BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName ()).tag(InfluxDBPublicParam.LINE_ID, "4aea410500fc0cea5a62790e8d493542").tag(InfluxDBPublicParam.PHASIC_TYPE,item1).tag(InfluxDBPublicParam.VALUE_TYPE,item2).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build(); fields.put("Pq_DF",1);
// batchPoints.point(point); Point point = influxDbUtils.pointBuilder("data_harmpower_p", time, TimeUnit.MILLISECONDS, tags, fields);
// records.add(batchPoints.lineProtocol()); BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName ()).tag("line_id", "00B78D0171091")
// } .tag("phasic_type",item1)
// } .tag("value_type",item2)
// influxDbUtils.batchInsert(influxDbUtils.getDbName (),"", InfluxDB.ConsistencyLevel.ALL, records); .tag("cl_did","1")
// } .tag("process","4")
// .tag("quality_flag","0")
//} .retentionPolicy("")
.consistency(InfluxDB.ConsistencyLevel.ALL)
.build();
batchPoints.point(point);
records.add(batchPoints.lineProtocol());
}
}
influxDbUtils.batchInsert(influxDbUtils.getDbName (),"", InfluxDB.ConsistencyLevel.ALL, records);
}
}

Some files were not shown because too many files have changed in this diff Show More