Compare commits
39 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| e629c8b42c | |||
| 9f5c273180 | |||
| d84d91a241 | |||
| ff3341549f | |||
| 99fb7aab66 | |||
| e1d731c774 | |||
| bdfdc9e75c | |||
| d43e0dd661 | |||
| dbdf9ba000 | |||
| a27315075c | |||
| 6f66e1d336 | |||
| 57d5b159ef | |||
| de60b53dd1 | |||
| 870ace35cb | |||
| 9438f75c01 | |||
| d44b4f3576 | |||
| ad7835f0db | |||
| b2e9597839 | |||
| 95d9432298 | |||
| 689f9ee51c | |||
| 38be9f6839 | |||
| 85f0775c97 | |||
| 681ec99f23 | |||
| 16c0620dd3 | |||
| cf691db0a6 | |||
| a6f424025a | |||
| f81be47e5f | |||
| 202888ca14 | |||
| 94929e66d5 | |||
| 4d5950d5ad | |||
| ff7b05bbb6 | |||
| ea2962840c | |||
| 1d8d714d66 | |||
| 23574f0819 | |||
| a82ea6b217 | |||
| 16724d7d79 | |||
| aa36c077f2 | |||
| 82e5d6c8e2 | |||
| 76000e4fff |
@@ -3,8 +3,7 @@ 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.CsCommTerminalFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.api.fallback.CsDeviceUserClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
@@ -31,4 +30,7 @@ public interface CsCommTerminalFeignClient {
|
||||
|
||||
@GetMapping("getPqUserIdsByUser")
|
||||
HttpResult<List<String>> getPqUserIdsByUser(@RequestParam("userId") String userId);
|
||||
|
||||
@PostMapping("/getLedgerByLineId")
|
||||
HttpResult<List<DevDetailDTO>> getLedgerByLineId(@RequestBody List<String> list);
|
||||
}
|
||||
|
||||
@@ -8,6 +8,8 @@ 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
|
||||
*/
|
||||
@@ -17,4 +19,7 @@ public interface CsCommunicateFeignClient {
|
||||
|
||||
@PostMapping("/insertion")
|
||||
HttpResult<String> insertion(@RequestBody PqsCommunicateDto pqsCommunicateDto);
|
||||
|
||||
@PostMapping("/insertionList")
|
||||
HttpResult<String> insertionList(@RequestBody List<PqsCommunicateDto> list);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
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.CsDeviceRegistryFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/csDeviceRegistry", fallbackFactory = CsDeviceRegistryFallbackFactory.class,contextId = "csDeviceRegistry")
|
||||
public interface CsDeviceRegistryFeignClient {
|
||||
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("批量新增设备注册记录")
|
||||
HttpResult<Boolean> add(@RequestBody @Validated List<CsDeviceRegistry> list);
|
||||
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改设备注册记录")
|
||||
HttpResult<Boolean> update(@RequestBody @Validated CsDeviceRegistry csDeviceRegistry);
|
||||
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除设备注册记录")
|
||||
HttpResult<Boolean> delete(@RequestParam("id") String id);
|
||||
|
||||
@PostMapping("/queryByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid查询设备注册记录")
|
||||
HttpResult<List<CsDeviceRegistry>> queryByCurrentNdid(@RequestParam("currentNdid") String currentNdid);
|
||||
|
||||
@PostMapping("/queryByCurrentNdidAndClDid")
|
||||
@ApiOperation("根据currentNdid和clDid查询设备注册记录")
|
||||
HttpResult<CsDeviceRegistry> queryByCurrentNdidAndClDid(@RequestParam("currentNdid") String currentNdid, @RequestParam("clDid") Integer clDid);
|
||||
|
||||
@PostMapping("/updateIsAccessByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid修改isAccess")
|
||||
HttpResult<Boolean> updateIsAccessByCurrentNdid(@RequestParam("currentNdid") String currentNdid, @RequestParam("isAccess") Integer isAccess);
|
||||
|
||||
}
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.njcn.csdevice.api;
|
||||
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.api.fallback.CsLineClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.dto.CsLineDTO;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
@@ -75,9 +72,9 @@ public interface CsLineFeignClient {
|
||||
@PostMapping("/getOverLimitDataByIds")
|
||||
HttpResult<List<Overlimit>> getOverLimitData(@RequestBody List<String> ids);
|
||||
|
||||
@PostMapping("/getLineBySensitiveUser")
|
||||
@ApiOperation("根据敏感用户查询监测点")
|
||||
HttpResult<List<CsLinePO>> getLineBySensitiveUser(@RequestBody List<String> list);
|
||||
@PostMapping("/getDevBySensitiveUser")
|
||||
@ApiOperation("根据敏感用户查询装置")
|
||||
HttpResult<List<CsEquipmentDeliveryPO>> getDevBySensitiveUser(@RequestBody List<String> list);
|
||||
|
||||
@PostMapping("/list")
|
||||
HttpResult<List<CsLinePO>> list(@RequestBody CsLinePO param);
|
||||
|
||||
@@ -4,9 +4,12 @@ import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.CsLineTopologyClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
||||
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;
|
||||
|
||||
@@ -19,4 +22,8 @@ public interface CsLineTopologyFeignClient {
|
||||
@PostMapping("/addList")
|
||||
HttpResult<String> addList(@RequestBody List<AppLineTopologyDiagramPO> list);
|
||||
|
||||
@PostMapping("/queryTopologyDiagram")
|
||||
@ApiOperation("查询装置拓扑图")
|
||||
HttpResult<AppTopologyDiagramVO> queryTopologyDiagram(@RequestParam(value="devId") String devId);
|
||||
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.constant.ServerInfo;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.fallback.DeviceMessageClientFallbackFactory;
|
||||
import com.njcn.csdevice.param.DeviceMessageParam;
|
||||
import com.njcn.csdevice.param.LineInfoParam;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
@@ -29,6 +30,6 @@ public interface DeviceMessageFeignClient {
|
||||
|
||||
@PostMapping("/getLineInfo")
|
||||
@ApiOperation("获取监测点信息")
|
||||
HttpResult<String> getLineInfo(@RequestParam("id") String id);
|
||||
HttpResult<String> getLineInfo(@RequestBody LineInfoParam param);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
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.SmsSendClientFallbackFactory;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@FeignClient(value = ServerInfo.CS_DEVICE_BOOT, path = "/sms", fallbackFactory = SmsSendClientFallbackFactory.class,contextId = "sms")
|
||||
public interface SmsSendFeignClient {
|
||||
|
||||
@PostMapping("/send/simple")
|
||||
@ApiOperation("发送短信(简化参数)")
|
||||
HttpResult<String> sendSmsSimple(@RequestParam("receiver") String receiver
|
||||
, @RequestParam("content") String content
|
||||
, @RequestParam("messageType") String messageType);
|
||||
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -51,6 +52,12 @@ public class CsCommTerminalFeignClientFallbackFactory implements FallbackFactory
|
||||
log.error("{}异常,降级处理,异常为:{}","根据登录用户id获取电能质量用户id集合",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<DevDetailDTO>> getLedgerByLineId(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据监测点id集合获取所有台账信息异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,6 +10,8 @@ import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 类的介绍:
|
||||
*
|
||||
@@ -35,6 +37,12 @@ public class CsCommunicateFeignClientFallbackFactory implements FallbackFactory<
|
||||
log.error("{}异常,降级处理,异常为:{}","新增记录",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> insertionList(List<PqsCommunicateDto> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量插入数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
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.CsDeviceRegistryFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class CsDeviceRegistryFallbackFactory implements FallbackFactory<CsDeviceRegistryFeignClient> {
|
||||
@Override
|
||||
public CsDeviceRegistryFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new CsDeviceRegistryFeignClient() {
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> add(List<CsDeviceRegistry> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","批量新增设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> update(CsDeviceRegistry csDeviceRegistry) {
|
||||
log.error("{}异常,降级处理,异常为:{}","修改设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> delete(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","删除设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsDeviceRegistry>> queryByCurrentNdid(String currentNdid) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据currentNdid查询设备注册记录异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<CsDeviceRegistry> queryByCurrentNdidAndClDid(String currentNdid, Integer clDid) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据currentNdid和clDid查询设备注册记录数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> updateIsAccessByCurrentNdid(String currentNdid, Integer isAccess) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据currentNdid修改isAccess异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
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.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.device.biz.pojo.po.Overlimit;
|
||||
@@ -117,7 +118,7 @@ public class CsLineClientFallbackFactory implements FallbackFactory<CsLineFeignC
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsLinePO>> getLineBySensitiveUser(List<String> list) {
|
||||
public HttpResult<List<CsEquipmentDeliveryPO>> getDevBySensitiveUser(List<String> list) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据敏感用户查询监测点异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.CsLineTopologyFeignClient;
|
||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -33,6 +34,12 @@ public class CsLineTopologyClientFallbackFactory implements FallbackFactory<CsLi
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<AppTopologyDiagramVO> queryTopologyDiagram(String devId) {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询装置拓扑图异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.csdevice.api.DeviceMessageFeignClient;
|
||||
import com.njcn.csdevice.param.DeviceMessageParam;
|
||||
import com.njcn.csdevice.param.LineInfoParam;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -41,7 +42,7 @@ public class DeviceMessageClientFallbackFactory implements FallbackFactory<Devic
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<String> getLineInfo(String id) {
|
||||
public HttpResult<String> getLineInfo(LineInfoParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取监测点信息数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@@ -21,4 +21,7 @@ public class IcdBzParam implements Serializable {
|
||||
@ApiModelProperty("结束时间")
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty("补召类型 0:稳态 1:暂态事件 2:波形)")
|
||||
private Integer bzType;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.csdevice.param;
|
||||
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
public class LineInfoParam {
|
||||
|
||||
@ApiModelProperty("nDid")
|
||||
private String nDid;
|
||||
|
||||
@ApiModelProperty("监测点集合")
|
||||
List<CsLinePO> list;
|
||||
|
||||
}
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.njcn.csdevice.pojo.dto;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-03-31
|
||||
*/
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotEmpty;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* 系统凭证请求 DTO
|
||||
*
|
||||
* @author msgpush
|
||||
*/
|
||||
@Data
|
||||
public class CredentialReqDTO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 上游系统名称
|
||||
*/
|
||||
@NotEmpty(message = "上游系统名称不能为空")
|
||||
private String systemName;
|
||||
|
||||
/**
|
||||
* 密钥(用于生成凭证)
|
||||
*/
|
||||
@NotEmpty(message = "密钥不能为空")
|
||||
private String secretKey;
|
||||
|
||||
}
|
||||
@@ -1,14 +1,8 @@
|
||||
package com.njcn.csdevice.pojo.dto;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
*
|
||||
* Description:
|
||||
@@ -76,8 +70,6 @@ public class CsEquipmentDeliveryDTO {
|
||||
*/
|
||||
private String debugPerson;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 合同号
|
||||
*/
|
||||
@@ -120,4 +112,5 @@ public class CsEquipmentDeliveryDTO {
|
||||
* 设备软件信息id
|
||||
*/
|
||||
private String softinfoId;
|
||||
|
||||
}
|
||||
@@ -19,7 +19,12 @@ public class CsLineDTO implements Serializable {
|
||||
private String deviceId;
|
||||
|
||||
/**
|
||||
* 装置id
|
||||
* 装置名称
|
||||
*/
|
||||
private String deviceName;
|
||||
|
||||
/**
|
||||
* 装置类型
|
||||
*/
|
||||
private String deviceType;
|
||||
|
||||
|
||||
@@ -34,12 +34,27 @@ public class DevDetailDTO {
|
||||
@ApiModelProperty(value = "设备名称")
|
||||
private String equipmentName;
|
||||
|
||||
@ApiModelProperty(value = "监测点id")
|
||||
private String lineId;
|
||||
|
||||
@ApiModelProperty(value = "监测点名称")
|
||||
private String lineName;
|
||||
|
||||
@ApiModelProperty(value = "设备通讯状态")
|
||||
private Integer runStatus;
|
||||
|
||||
@ApiModelProperty(value = "设备MAC地址")
|
||||
private String devMac;
|
||||
|
||||
@ApiModelProperty(value = "nDid")
|
||||
private String nDid;
|
||||
|
||||
@ApiModelProperty(value = "监测对象")
|
||||
private String objType;
|
||||
|
||||
// @ApiModelProperty(value = "设备治理方案")
|
||||
// private String governType;
|
||||
|
||||
@ApiModelProperty(value = "监测点id集合")
|
||||
private List<String> lineList;
|
||||
}
|
||||
|
||||
@@ -44,5 +44,6 @@ public class AppLineTopologyDiagramParm extends BaseEntity {
|
||||
|
||||
private Double lat;
|
||||
|
||||
private String target;
|
||||
|
||||
}
|
||||
@@ -111,4 +111,13 @@ public class CsEquipmentDeliveryAddParm implements Serializable {
|
||||
|
||||
@ApiModelProperty(value="是否支持升级(0:否 1:是)")
|
||||
private Integer upgrade;
|
||||
|
||||
@ApiModelProperty(value="治理方法")
|
||||
private String governMethod;
|
||||
|
||||
@ApiModelProperty(value="敏感用户id")
|
||||
private String monitorUser;
|
||||
|
||||
@ApiModelProperty(value="治理类型(稳态:harmonic 暂态:event)")
|
||||
private String governType;
|
||||
}
|
||||
@@ -116,4 +116,13 @@ public class CsEquipmentDeliveryAuditParm {
|
||||
|
||||
@ApiModelProperty(value="是否支持升级(0:否 1:是)")
|
||||
private Integer upgrade;
|
||||
|
||||
@ApiModelProperty(value="治理方法")
|
||||
private String governMethod;
|
||||
|
||||
@ApiModelProperty(value="敏感用户id")
|
||||
private String monitorUser;
|
||||
|
||||
@ApiModelProperty(value="治理类型(稳态:harmonic 暂态:event)")
|
||||
private String governType;
|
||||
}
|
||||
@@ -45,5 +45,7 @@ public class AppLineTopologyDiagramPO extends BaseEntity {
|
||||
@TableField(value = "lat")
|
||||
private Double lat;
|
||||
|
||||
@TableField(value = "target")
|
||||
private String target;
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
@@ -43,6 +44,12 @@ public class CsDataArray extends BaseEntity {
|
||||
*/
|
||||
private String anotherName;
|
||||
|
||||
/**
|
||||
* influxdb 存储的名称
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private String influxDbName;
|
||||
|
||||
/**
|
||||
* 字典序号
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
*
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-06-17
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_device_registry")
|
||||
public class CsDeviceRegistry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 监测点id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 当前设备NDID
|
||||
*/
|
||||
private String currentNdid;
|
||||
|
||||
/**
|
||||
* 老的设备NDID
|
||||
*/
|
||||
private String oldNdid;
|
||||
|
||||
/**
|
||||
* 逻辑子设备编号
|
||||
*/
|
||||
private Integer clDid;
|
||||
|
||||
/**
|
||||
* 首次接入时间
|
||||
*/
|
||||
private LocalDateTime firstSeenTime;
|
||||
|
||||
/**
|
||||
* 修改完mac是否完成首次接入(0:未接入 1:已接入)
|
||||
*/
|
||||
private Integer isAccess;
|
||||
|
||||
|
||||
}
|
||||
@@ -127,14 +127,7 @@ public class CsLinePO extends BaseEntity {
|
||||
*/
|
||||
@TableField(value = "monitor_obj")
|
||||
private String monitorObj;
|
||||
/**
|
||||
* 是否治理(0:未治理 1:已治理)
|
||||
*/
|
||||
@TableField(value = "is_govern")
|
||||
private Integer govern;
|
||||
|
||||
@TableField(value = "monitor_user")
|
||||
private String monitorUser;
|
||||
|
||||
/**
|
||||
* 短路容量
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
package com.njcn.csdevice.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Data
|
||||
@TableName("cs_sms_send_record")
|
||||
public class CsSmsSendRecord implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String id;
|
||||
|
||||
private String receiver;
|
||||
|
||||
private String content;
|
||||
|
||||
private String messageType;
|
||||
|
||||
private String credentialToken;
|
||||
|
||||
private Integer sendStatus;
|
||||
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
private String failReason;
|
||||
|
||||
private Integer retryCount;
|
||||
|
||||
private Integer maxRetry;
|
||||
|
||||
private Long responseTime;
|
||||
|
||||
private LocalDateTime sendTime;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
|
||||
private LocalDateTime updateTime;
|
||||
}
|
||||
@@ -1,8 +1,6 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.bo.BaseEntity;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
@@ -43,5 +41,6 @@ public class AppLineTopologyDiagramVO {
|
||||
|
||||
private String linePostion;
|
||||
|
||||
|
||||
@ApiModelProperty(value="绑定的指标")
|
||||
private String target;
|
||||
}
|
||||
@@ -106,4 +106,7 @@ public class CsEquipmentDeliveryVO extends BaseEntity {
|
||||
@ApiModelProperty(value="所属项目名称")
|
||||
private String associatedProjectName;
|
||||
|
||||
@ApiModelProperty(value="修改完mac是否完成首次接入(0:未接入 1:已接入)")
|
||||
private Integer isAccess;
|
||||
|
||||
}
|
||||
@@ -75,6 +75,18 @@ public class CsLedgerVO implements Serializable {
|
||||
@ApiModelProperty(name = "devConType",value = "设备连接方式 MQTT || CLD")
|
||||
private String devConType;
|
||||
|
||||
@ApiModelProperty(name = "监测点关联用户id")
|
||||
private String sensitiveUserId;
|
||||
|
||||
@ApiModelProperty(name = "监测点关联用户名称")
|
||||
private String sensitiveUserName;
|
||||
|
||||
@ApiModelProperty(name = "治理方案名称")
|
||||
private String governPlanName;
|
||||
|
||||
@ApiModelProperty(name = "监测点线路号")
|
||||
private Integer lineNo;
|
||||
|
||||
@ApiModelProperty(name = "children",value = "子节点")
|
||||
private List<CsLedgerVO> children = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -5,7 +5,6 @@ import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
@@ -31,6 +30,9 @@ public class DataGroupEventVO {
|
||||
@ApiModelProperty("装置ID")
|
||||
private String deviceId;
|
||||
|
||||
@ApiModelProperty("设备网络码")
|
||||
private String nDid;
|
||||
|
||||
@ApiModelProperty("装置名称")
|
||||
private String devName;
|
||||
|
||||
@@ -65,9 +67,24 @@ public class DataGroupEventVO {
|
||||
private Double amplitude;
|
||||
|
||||
@ApiModelProperty("严重度")
|
||||
private String severity;
|
||||
private Double severity;
|
||||
|
||||
@ApiModelProperty("波形路径")
|
||||
private String wavePath;
|
||||
|
||||
@ApiModelProperty("事件落点")
|
||||
private String landPoint;
|
||||
|
||||
@ApiModelProperty("暂降原因")
|
||||
private String advanceReason;
|
||||
|
||||
@ApiModelProperty("暂降类型")
|
||||
private String advanceType;
|
||||
|
||||
@ApiModelProperty("暂降源与监测位置关系 0-未知、1-上游、2-下游")
|
||||
private String sagSource;
|
||||
|
||||
@ApiModelProperty("监测点电压等级")
|
||||
private Double lineVoltage;
|
||||
|
||||
}
|
||||
|
||||
@@ -71,4 +71,7 @@ public class DevCountVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(value = "反馈数")
|
||||
private Integer feedBackCount = 0;
|
||||
|
||||
@ApiModelProperty(value = "当前工程监测点数")
|
||||
private Integer lineCount = 0;
|
||||
}
|
||||
|
||||
@@ -62,5 +62,8 @@ public class DeviceManagerVO {
|
||||
|
||||
@ApiModelProperty(value = "数据类型 rt:实时数据 history:历史数据")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "排序")
|
||||
private Integer sort;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +0,0 @@
|
||||
package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import cn.hutool.core.lang.RegexPool;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2026-02-27
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "管理后台 - 消息记录发送 Request VO")
|
||||
public class MessageRecordReqVO {
|
||||
|
||||
private String channel;
|
||||
|
||||
@Schema(description = "消息类型", example = "verify_code/order_notify/marketing/system_notify")
|
||||
@NotBlank(message = "消息类型不能为空")
|
||||
private String messageType;
|
||||
|
||||
@Schema(description = "接收者")
|
||||
@NotBlank(message = "接收者不能为空")
|
||||
@Pattern(regexp = RegexPool.EMAIL + "|" + RegexPool.MOBILE, message = "必须是有效的邮箱或手机号格式")
|
||||
private String receiver;
|
||||
|
||||
@Schema(description = "标题")
|
||||
private String title;
|
||||
|
||||
@Schema(description = "消息内容")
|
||||
private String content;
|
||||
|
||||
@Schema(description = "模板编码")
|
||||
private String templateCode;
|
||||
|
||||
@Schema(description = "模板参数")
|
||||
private String templateParams;
|
||||
}
|
||||
@@ -8,17 +8,25 @@ import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class PqSensitiveUserLineVO {
|
||||
@ApiModelProperty("工程名称")
|
||||
private String engineeringName;
|
||||
@ApiModelProperty("项目名称")
|
||||
private String projectName;
|
||||
@ApiModelProperty("设备id")
|
||||
private String devId;
|
||||
@ApiModelProperty("设备名称")
|
||||
private String devName;
|
||||
@ApiModelProperty("治理对象")
|
||||
private String sensitiveUser;
|
||||
@ApiModelProperty("监测点ID")
|
||||
private String lineId;
|
||||
@ApiModelProperty("测点名称")
|
||||
private String lineName;
|
||||
@ApiModelProperty("是否治理")
|
||||
@ApiModelProperty("治理方案")
|
||||
private String govern;
|
||||
@ApiModelProperty("电压等级")
|
||||
private double volGrade;
|
||||
@ApiModelProperty("监测类型")
|
||||
@ApiModelProperty("监测位置")
|
||||
private String position;
|
||||
@ApiModelProperty("运行状态")
|
||||
private String runStatus;
|
||||
|
||||
@@ -2,6 +2,7 @@ package com.njcn.csdevice.pojo.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -20,6 +21,9 @@ public class RecordAllDevTreeVo {
|
||||
@ApiModelProperty("设备名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("设备状态")
|
||||
private Integer runStatus;
|
||||
|
||||
@ApiModelProperty("线路")
|
||||
private List<RecordAllLineTreeVo> children;
|
||||
|
||||
|
||||
@@ -167,6 +167,11 @@
|
||||
<artifactId>message-api</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>event-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -75,4 +75,13 @@ public class PqsCommunicateController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON,operateType = OperateType.ADD)
|
||||
@PostMapping("/insertionList")
|
||||
@ApiOperation("批量插入数据")
|
||||
public HttpResult<String> insertionList(@RequestBody List<PqsCommunicateDto> list) {
|
||||
String methodDescribe = getMethodDescribe("insertionList");
|
||||
pqsCommunicateCvtQuery.insertionList(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -101,7 +100,6 @@ public class CsDataArrayController extends BaseController {
|
||||
@PostMapping("/findListByParam")
|
||||
@ApiOperation("根据条件查询详细数据")
|
||||
@ApiImplicitParam(name = "param", value = "参数集合", required = true)
|
||||
@ApiIgnore
|
||||
public HttpResult<List<CsDataArray>> findListByParam(@RequestBody DataArrayParam param){
|
||||
String methodDescribe = getMethodDescribe("findListByParam");
|
||||
List<CsDataArray> list = csDataArrayService.findListByParam(param);
|
||||
|
||||
@@ -0,0 +1,148 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
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.po.CsDeviceRegistry;
|
||||
import com.njcn.csdevice.service.ICsDeviceRegistryService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/csDeviceRegistry")
|
||||
@Api(tags = "设备注册台账记录表")
|
||||
@AllArgsConstructor
|
||||
public class CsDeviceRegistryController extends BaseController {
|
||||
|
||||
private final ICsDeviceRegistryService csDeviceRegistryService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("批量新增设备注册记录")
|
||||
@ApiImplicitParam(name = "list", value = "设备注册信息列表", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated List<CsDeviceRegistry> list) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
boolean result = csDeviceRegistryService.add(list);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改设备注册记录")
|
||||
@ApiImplicitParam(name = "csDeviceRegistry", value = "设备注册信息", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated CsDeviceRegistry csDeviceRegistry) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
boolean result = csDeviceRegistryService.update(csDeviceRegistry);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateBatch")
|
||||
@ApiOperation("批量修改设备注册记录")
|
||||
@ApiImplicitParam(name = "list", value = "设备注册信息列表", required = true)
|
||||
public HttpResult<Boolean> updateBatch(@RequestBody @Validated List<CsDeviceRegistry> list) {
|
||||
String methodDescribe = getMethodDescribe("updateBatch");
|
||||
boolean result = csDeviceRegistryService.updateBatch(list);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除设备注册记录")
|
||||
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
boolean result = csDeviceRegistryService.delete(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateIsAccessByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid修改isAccess")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true),
|
||||
@ApiImplicitParam(name = "isAccess", value = "接入状态(0:未接入 1:已接入)", required = true)
|
||||
})
|
||||
public HttpResult<Boolean> updateIsAccessByCurrentNdid(
|
||||
@RequestParam("currentNdid") String currentNdid,
|
||||
@RequestParam("isAccess") Integer isAccess) {
|
||||
String methodDescribe = getMethodDescribe("updateIsAccessByCurrentNdid");
|
||||
boolean result = csDeviceRegistryService.updateIsAccessByCurrentNdid(currentNdid, isAccess);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/deleteByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid删除设备注册记录")
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true)
|
||||
public HttpResult<List<CsDeviceRegistry>> deleteByCurrentNdid(@RequestParam("currentNdid") String currentNdid) {
|
||||
String methodDescribe = getMethodDescribe("deleteByCurrentNdid");
|
||||
csDeviceRegistryService.deleteByCurrentNdid(currentNdid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryByCurrentNdid")
|
||||
@ApiOperation("根据currentNdid查询设备注册记录")
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true)
|
||||
public HttpResult<List<CsDeviceRegistry>> queryByCurrentNdid(@RequestParam("currentNdid") String currentNdid) {
|
||||
String methodDescribe = getMethodDescribe("queryByCurrentNdid");
|
||||
List<CsDeviceRegistry> list = csDeviceRegistryService.queryByCurrentNdid(currentNdid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据id查询设备注册记录")
|
||||
@ApiImplicitParam(name = "id", value = "监测点id", required = true)
|
||||
public HttpResult<CsDeviceRegistry> getById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
CsDeviceRegistry csDeviceRegistry = csDeviceRegistryService.getById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, csDeviceRegistry, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/queryByCurrentNdidAndClDid")
|
||||
@ApiOperation("根据currentNdid和clDid查询设备注册记录")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "currentNdid", value = "当前设备NDID", required = true),
|
||||
@ApiImplicitParam(name = "clDid", value = "逻辑子设备编号", required = true)
|
||||
})
|
||||
public HttpResult<CsDeviceRegistry> queryByCurrentNdidAndClDid(
|
||||
@RequestParam("currentNdid") String currentNdid,
|
||||
@RequestParam("clDid") Integer clDid) {
|
||||
String methodDescribe = getMethodDescribe("queryByCurrentNdidAndClDid");
|
||||
CsDeviceRegistry pojo = csDeviceRegistryService.queryByCurrentNdidAndClDid(currentNdid, clDid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pojo, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.csdevice.controller.equipment;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
@@ -10,7 +9,6 @@ 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.po.CsEventSendMsg;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEventSendMsgVO;
|
||||
import com.njcn.csdevice.service.ICsEventSendMsgService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
|
||||
@@ -179,9 +179,5 @@ public class CsGroupController extends BaseController {
|
||||
Map<String,List<ThdDataVO>> result = csGroupService.sensitiveUserTrendData(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -48,7 +48,7 @@ public class CsUpgradeLogsController extends BaseController {
|
||||
@GetMapping("/getByDevId")
|
||||
@ApiOperation("查询指定devId的所有升级日志")
|
||||
@ApiImplicitParam(name = "devId", value = "装置Id", required = true)
|
||||
public HttpResult<List<CsUpgradeLogs>> getByDevId(@RequestBody String devId) {
|
||||
public HttpResult<List<CsUpgradeLogs>> getByDevId(@RequestParam("devId") String devId) {
|
||||
String methodDescribe = getMethodDescribe("getByDevId");
|
||||
List<CsUpgradeLogs> result = csUpgradeLogsService.lambdaQuery().eq(CsUpgradeLogs::getDevId, devId).list();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
|
||||
@@ -14,7 +14,6 @@ import com.njcn.csdevice.enums.DeviceOperate;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevVersionVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
||||
@@ -30,7 +29,6 @@ import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.web.advice.DeviceLog;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
@@ -1,39 +1,23 @@
|
||||
package com.njcn.csdevice.controller.ledger;
|
||||
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
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.mapper.PqsDeviceUnitMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.service.CsCommTerminalService;
|
||||
import com.njcn.csdevice.service.CsDeviceUserPOService;
|
||||
import com.njcn.csdevice.service.CsEquipmentDeliveryService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.constant.UserType;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -108,11 +92,17 @@ public class CsCommTerminalController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, pqsDeviceUnit, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 根据监测点id集合,获取所有台账信息
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLedgerByLineId")
|
||||
@ApiOperation("根据监测点id集合获取所有台账信息")
|
||||
@ApiImplicitParam(name = "list", value = "实体", required = true)
|
||||
public HttpResult<List<DevDetailDTO>> getLedgerByLineId(@RequestBody List<String> list) {
|
||||
String methodDescribe = getMethodDescribe("getLedgerByLineId");
|
||||
List<DevDetailDTO> result = commTerminalService.getLedgerByLineId(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ public class CsLedgerController extends BaseController {
|
||||
@PostMapping("/AppLineTree")
|
||||
@ApiOperation("app端监测点树")
|
||||
public HttpResult<List<CsLedgerVO>> appLineTree(){
|
||||
String methodDescribe = getMethodDescribe("AppLineTree");
|
||||
String methodDescribe = getMethodDescribe("appLineTree");
|
||||
List<CsLedgerVO> list = csLedgerService.appLineTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
@@ -90,14 +90,14 @@ public class CsLedgerController extends BaseController {
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/objTree")
|
||||
@ApiOperation("三层对象用户树")
|
||||
public HttpResult<List<CsLedgerVO>> objTree(){
|
||||
String methodDescribe = getMethodDescribe("getProjectTree");
|
||||
List<CsLedgerVO> list = csLedgerService.objTree();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
// @PostMapping("/objTree")
|
||||
// @ApiOperation("三层对象用户树")
|
||||
// public HttpResult<List<CsLedgerVO>> objTree(){
|
||||
// String methodDescribe = getMethodDescribe("getProjectTree");
|
||||
// List<CsLedgerVO> list = csLedgerService.objTree();
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, list, methodDescribe);
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/add")
|
||||
|
||||
@@ -9,6 +9,7 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
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.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO;
|
||||
@@ -29,6 +30,7 @@ import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Description:
|
||||
@@ -147,6 +149,9 @@ public class CslineController extends BaseController {
|
||||
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsLinePO::getLineId,lineId).eq(CsLinePO::getStatus,1);
|
||||
CsLinePO po = csLinePOService.getOne(queryWrapper);
|
||||
if (Objects.isNull(po.getLineNo())) {
|
||||
po.setLineNo(po.getClDid());
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, po, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -295,11 +300,11 @@ public class CslineController extends BaseController {
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLineBySensitiveUser")
|
||||
@ApiOperation("根据敏感用户查询监测点")
|
||||
public HttpResult<List<CsLinePO>> getLineBySensitiveUser(@RequestBody List<String> list) {
|
||||
String methodDescribe = getMethodDescribe("getLineBySensitiveUser");
|
||||
List<CsLinePO> result = csLinePOService.getLineBySensitiveUser(list);
|
||||
@PostMapping("/getDevBySensitiveUser")
|
||||
@ApiOperation("根据敏感用户查询装置")
|
||||
public HttpResult<List<CsEquipmentDeliveryPO>> getDevBySensitiveUser(@RequestBody List<String> list) {
|
||||
String methodDescribe = getMethodDescribe("getDevBySensitiveUser");
|
||||
List<CsEquipmentDeliveryPO> result = csLinePOService.getDevBySensitiveUser(list);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,12 +7,8 @@ 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.DeviceMessageParam;
|
||||
import com.njcn.csdevice.pojo.param.DataArrayParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerDetailVO;
|
||||
import com.njcn.csdevice.param.LineInfoParam;
|
||||
import com.njcn.csdevice.service.DeviceMessageService;
|
||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
@@ -22,7 +18,6 @@ import io.swagger.annotations.ApiOperation;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import springfox.documentation.annotations.ApiIgnore;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -47,8 +42,8 @@ public class DeviceMessageController extends BaseController {
|
||||
@PostMapping("/getEventUserByDeviceId")
|
||||
@ApiOperation("根据设备获取需要推送的用户id")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "devId", value = "设备id", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "isAdmin", value = "是否需要推送给管理员", required = true, paramType = "query")
|
||||
@ApiImplicitParam(name = "devId", value = "设备id", required = true, paramType = "query"),
|
||||
@ApiImplicitParam(name = "isAdmin", value = "是否需要推送给普通用户", required = true, paramType = "query")
|
||||
})
|
||||
public HttpResult<List<String>> getEventUserByDeviceId(@RequestParam("devId") String devId, @RequestParam("isAdmin") Boolean isAdmin){
|
||||
String methodDescribe = getMethodDescribe("getEventUserByDeviceId");
|
||||
@@ -69,10 +64,10 @@ public class DeviceMessageController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getLineInfo")
|
||||
@ApiOperation("获取监测点信息")
|
||||
@ApiImplicitParam(name = "id", value = "参数", required = true, paramType = "query")
|
||||
public HttpResult<String> getLineInfo(@RequestParam("id") String id){
|
||||
@ApiImplicitParam(name = "param", value = "参数", required = true)
|
||||
public HttpResult<String> getLineInfo(@RequestBody LineInfoParam param){
|
||||
String methodDescribe = getMethodDescribe("getLineInfo");
|
||||
deviceMessageService.getLineInfo(id);
|
||||
deviceMessageService.getLineInfo(param.getNDid(),param.getList());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, "success", methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,77 +0,0 @@
|
||||
package com.njcn.csdevice.controller.message;
|
||||
|
||||
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.MessageRecordReqVO;
|
||||
import com.njcn.csdevice.service.ISmsSendService;
|
||||
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.*;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/sms")
|
||||
@Api(tags = "短信发送管理")
|
||||
@AllArgsConstructor
|
||||
public class SmsSendController extends BaseController {
|
||||
|
||||
private final ISmsSendService smsSendService;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/send")
|
||||
@ApiOperation("发送短信(同步,包含重试)")
|
||||
public HttpResult<String> sendSms(@RequestBody MessageRecordReqVO vo) {
|
||||
String methodDescribe = getMethodDescribe("sendSms");
|
||||
|
||||
try {
|
||||
smsSendService.sendSmsWithRetry(vo);
|
||||
return HttpResultUtil.assembleCommonResponseResult(
|
||||
CommonResponseEnum.SUCCESS,
|
||||
"短信发送成功",
|
||||
methodDescribe
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("短信发送失败", e);
|
||||
return HttpResultUtil.assembleCommonResponseResult(
|
||||
CommonResponseEnum.FAIL,
|
||||
e.getMessage(),
|
||||
methodDescribe
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/send/simple")
|
||||
@ApiOperation("发送短信(简化参数)")
|
||||
public HttpResult<String> sendSmsSimple(
|
||||
@RequestParam String receiver,
|
||||
@RequestParam String content,
|
||||
@RequestParam(defaultValue = "verify_code") String messageType) {
|
||||
String methodDescribe = getMethodDescribe("sendSmsSimple");
|
||||
|
||||
try {
|
||||
smsSendService.sendSmsWithRetry(receiver, content, messageType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(
|
||||
CommonResponseEnum.SUCCESS,
|
||||
"短信发送成功",
|
||||
methodDescribe
|
||||
);
|
||||
} catch (Exception e) {
|
||||
log.error("短信发送失败", e);
|
||||
return HttpResultUtil.assembleCommonResponseResult(
|
||||
CommonResponseEnum.FAIL,
|
||||
e.getMessage(),
|
||||
methodDescribe
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,10 @@ package com.njcn.csdevice.handler;
|
||||
|
||||
|
||||
import com.github.tocrhz.mqtt.annotation.MqttSubscribe;
|
||||
|
||||
import com.github.tocrhz.mqtt.annotation.Payload;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.service.CsLogsPOService;
|
||||
|
||||
import com.njcn.cssystem.api.CsLogsFeignClient;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.eclipse.paho.client.mqttv3.MqttMessage;
|
||||
@@ -25,8 +23,7 @@ import java.nio.charset.StandardCharsets;
|
||||
@AllArgsConstructor
|
||||
public class MqttMessageHandler {
|
||||
|
||||
|
||||
private final CsLogsPOService csLogsPOService;
|
||||
private final CsLogsFeignClient csLogsFeignClient;
|
||||
|
||||
/**
|
||||
* 插入devicelog
|
||||
@@ -34,7 +31,7 @@ public class MqttMessageHandler {
|
||||
@MqttSubscribe(value = "/deviceLog")
|
||||
public void responseRtData(String topic, MqttMessage message, @Payload String payload) {
|
||||
DeviceLogDTO deviceLogDTO = PubUtils.json2obj(new String(message.getPayload(), StandardCharsets.UTF_8),DeviceLogDTO.class);
|
||||
csLogsPOService.addLog(deviceLogDTO);
|
||||
csLogsFeignClient.addUserLog(deviceLogDTO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-06-17
|
||||
*/
|
||||
public interface CsDeviceRegistryMapper extends BaseMapper<CsDeviceRegistry> {
|
||||
|
||||
}
|
||||
@@ -1,10 +1,8 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.csdevice.pojo.po.CsEventSendMsg;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEventSendMsgVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
package com.njcn.csdevice.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsSmsSendRecord;
|
||||
|
||||
public interface CsSmsSendRecordMapper extends BaseMapper<CsSmsSendRecord> {
|
||||
}
|
||||
@@ -105,7 +105,6 @@
|
||||
t0.ndid = #{param.id}
|
||||
and t1.did = #{param.did}
|
||||
and t3.cl_dev = #{param.cldId}
|
||||
and (t3.data_type = 'Stat' or t3.data_type is NULL)
|
||||
and t3.idx = #{param.idx}
|
||||
and t4.stat_method = #{param.statMethod}
|
||||
order by t4.sort
|
||||
|
||||
@@ -14,7 +14,8 @@
|
||||
where
|
||||
pid = #{modelId}
|
||||
and cl_dev = #{clDev}
|
||||
and (data_type = 'Stat' or data_type IS NULL)
|
||||
-- and (data_type = 'Stat' or data_type IS NULL)
|
||||
and store_flag = 1
|
||||
order by type,cl_dev
|
||||
</select>
|
||||
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.csdevice.mapper.CsDeviceRegistryMapper">
|
||||
|
||||
</mapper>
|
||||
@@ -57,7 +57,8 @@
|
||||
<select id="findLineList" resultType="com.njcn.csdevice.pojo.dto.CsLineDTO">
|
||||
SELECT
|
||||
t1.*,
|
||||
t2.dev_type deviceType
|
||||
t2.dev_type deviceType,
|
||||
t2.name deviceName
|
||||
FROM
|
||||
cs_line t1
|
||||
LEFT JOIN cs_equipment_delivery t2 ON t1.device_id = t2.id
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
|
||||
<select id="getRecordAll" resultType="com.njcn.csdevice.pojo.vo.RecordAllDevTreeVo">
|
||||
<if test="wlRecordPageParam.isTrueFlag == 0">
|
||||
select a.dev_id as id,b.name as name from wl_record a
|
||||
select a.dev_id as id,b.name as name,b.run_status as runStatus from wl_record a
|
||||
left join cs_equipment_delivery b on a.dev_id = b.id
|
||||
where a.type=1 and a.state =1 and a.end_time is not null
|
||||
and
|
||||
@@ -31,7 +31,7 @@
|
||||
group by a.dev_id,b.name having a.dev_id is not null and b.name is not null
|
||||
</if>
|
||||
<if test="wlRecordPageParam.isTrueFlag == 1">
|
||||
select a.dev_id as id,b.name as name from wl_record a
|
||||
select a.dev_id as id,b.name as name,b.run_status as runStatus from wl_record a
|
||||
left join cs_equipment_delivery b on a.dev_id = b.id
|
||||
where a.type=1 and a.state =1 and a.end_time is not null
|
||||
and exists
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,4 +15,6 @@ public interface CsCommTerminalService {
|
||||
PqsDeviceUnit lineUnitDetail(String lineId);
|
||||
|
||||
List<String> commGetDevIds(String userId);
|
||||
|
||||
List<DevDetailDTO> getLedgerByLineId(List<String> id);
|
||||
}
|
||||
|
||||
@@ -5,13 +5,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.param.*;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
import com.njcn.csdevice.pojo.vo.DevVersionVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerVO;
|
||||
import com.njcn.csdevice.pojo.vo.ProjectEquipmentVO;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
|
||||
import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO;
|
||||
@@ -86,7 +87,7 @@ public interface CsLinePOService extends IService<CsLinePO>{
|
||||
|
||||
List<CsLinePO> getSimpleLine();
|
||||
|
||||
List<CsLinePO> getLineBySensitiveUser(List<String> list);
|
||||
List<CsEquipmentDeliveryPO> getDevBySensitiveUser(List<String> list);
|
||||
|
||||
Page<PqSensitiveUserLineVO> getSensitiveUserLineList(BaseParam param);
|
||||
boolean uploadReport(MultipartFile file, String lineId);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.csdevice.param.DeviceMessageParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
|
||||
import java.util.List;
|
||||
@@ -14,6 +15,6 @@ public interface DeviceMessageService {
|
||||
|
||||
List<User> getSendUserByType(DeviceMessageParam param);
|
||||
|
||||
void getLineInfo(String id);
|
||||
void getLineInfo(String id,List<CsLinePO> list);
|
||||
|
||||
}
|
||||
|
||||
@@ -45,4 +45,6 @@ public interface ICsCommunicateService {
|
||||
List<PqsCommunicateDto> getRawDataEnd(LineCountEvaluateParam lineParam);
|
||||
|
||||
void insertion(PqsCommunicateDto pqsCommunicateDto);
|
||||
|
||||
void insertionList(List<PqsCommunicateDto> list);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author xy
|
||||
* @since 2026-06-17
|
||||
*/
|
||||
public interface ICsDeviceRegistryService extends IService<CsDeviceRegistry> {
|
||||
|
||||
boolean add(List<CsDeviceRegistry> list);
|
||||
|
||||
boolean update(CsDeviceRegistry csDeviceRegistry);
|
||||
|
||||
boolean updateBatch(List<CsDeviceRegistry> list);
|
||||
|
||||
boolean delete(String id);
|
||||
|
||||
boolean updateIsAccessByCurrentNdid(String currentNdid, Integer isAccess);
|
||||
|
||||
void deleteByCurrentNdid(String currentNdid);
|
||||
|
||||
List<CsDeviceRegistry> queryByCurrentNdid(String currentNdid);
|
||||
|
||||
CsDeviceRegistry queryByCurrentNdidAndClDid(String currentNdid, Integer clDid);
|
||||
}
|
||||
@@ -80,7 +80,7 @@ public interface ICsLedgerService extends IService<CsLedger> {
|
||||
List<CsLedgerVO> getztProjectTree();
|
||||
|
||||
|
||||
List<CsLedgerVO> objTree();
|
||||
// List<CsLedgerVO> objTree();
|
||||
|
||||
/**
|
||||
* 根据设备集合获取项目和工程
|
||||
@@ -97,4 +97,6 @@ public interface ICsLedgerService extends IService<CsLedger> {
|
||||
|
||||
List<DevDetailDTO> getEngineeringHaveDevs(List<String> list);
|
||||
|
||||
List<CsLedger> queryByPid(String pid);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* PqdData数据拆分服务
|
||||
*
|
||||
* @author system
|
||||
* @since 2026-05-22
|
||||
*/
|
||||
public interface IPqdDataSplitService {
|
||||
|
||||
Map<String, Object> splitPqdData(List<PqdData> pqdDataList);
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.njcn.csdevice.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.csdevice.pojo.po.CsSmsSendRecord;
|
||||
import com.njcn.csdevice.pojo.vo.MessageRecordReqVO;
|
||||
|
||||
public interface ISmsSendService extends IService<CsSmsSendRecord> {
|
||||
|
||||
void sendSmsWithRetry(String receiver, String content, String messageType);
|
||||
|
||||
void sendSmsWithRetry(MessageRecordReqVO messageRecordReqVO);
|
||||
}
|
||||
@@ -5,7 +5,6 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.mapper.AppLineTopologyDiagramMapper;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
import com.njcn.csdevice.pojo.param.AppTopologyDiagramQueryParm;
|
||||
import com.njcn.csdevice.pojo.param.LinePostionParam;
|
||||
import com.njcn.csdevice.pojo.po.AppLineTopologyDiagramPO;
|
||||
@@ -13,11 +12,14 @@ import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.AppLineTopologyDiagramVO;
|
||||
import com.njcn.csdevice.pojo.vo.AppTopologyDiagramVO;
|
||||
import com.njcn.csdevice.pojo.vo.CsLineTopologyTemplateVO;
|
||||
import com.njcn.csdevice.service.AppLineTopologyDiagramService;
|
||||
import com.njcn.csdevice.service.AppTopologyDiagramService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsLedgerService;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
@@ -41,6 +43,9 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopolo
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final AppTopologyDiagramService appTopologyDiagramService;
|
||||
private final ICsLedgerService iCsLedgerService;
|
||||
private final RedisUtil redisUtil;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
@Override
|
||||
public AppTopologyDiagramVO query(String devId) {
|
||||
CsLedger one = iCsLedgerService.lambdaQuery().eq(CsLedger::getId, devId).eq(CsLedger::getState,1).one();
|
||||
@@ -73,7 +78,7 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopolo
|
||||
}
|
||||
public List<AppLineTopologyDiagramVO> queryByLineIds(List<String> lineIds) {
|
||||
List<AppLineTopologyDiagramVO> result = new ArrayList<>();
|
||||
if (lineIds != null && lineIds.size() > 0) {
|
||||
if (lineIds != null && !lineIds.isEmpty()) {
|
||||
result = this.getBaseMapper().queryByLineIds( lineIds);
|
||||
}
|
||||
return result;
|
||||
@@ -83,15 +88,22 @@ public class AppLineTopologyDiagramServiceImpl extends ServiceImpl<AppLineTopolo
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void auditList(LinePostionParam linePostionParam) {
|
||||
|
||||
|
||||
linePostionParam.getPointList().forEach(temp->{
|
||||
csLinePOService.lambdaUpdate().eq(CsLinePO::getLineId,temp.getLineId()).set(CsLinePO::getName,temp.getName()).set(CsLinePO::getPosition,temp.getLinePostion()).update();
|
||||
this.lambdaUpdate().eq(AppLineTopologyDiagramPO::getId,temp.getId()).
|
||||
eq(AppLineTopologyDiagramPO::getLineId,temp.getLineId()).set(AppLineTopologyDiagramPO::getLat,temp.getLat()).
|
||||
set(AppLineTopologyDiagramPO::getLng,temp.getLng()).set(AppLineTopologyDiagramPO::getId,linePostionParam.getId()).update();
|
||||
|
||||
iCsLedgerService.lambdaUpdate().eq(CsLedger::getId,temp.getLineId()).set(CsLedger::getName,temp.getName()).update();
|
||||
set(AppLineTopologyDiagramPO::getLng,temp.getLng()).set(AppLineTopologyDiagramPO::getId,linePostionParam.getId())
|
||||
.set(AppLineTopologyDiagramPO::getTarget,temp.getTarget())
|
||||
.update();
|
||||
iCsLedgerService.lambdaUpdate().eq(CsLedger::getId,temp.getLineId()).set(CsLedger::getName,temp.getName()).update();
|
||||
});
|
||||
//修改指标后,删除缓存数据
|
||||
String deviceId = csLinePOService.getById(linePostionParam.getPointList().get(0).getLineId()).getDeviceId();
|
||||
DictTreeVO dictTreeVO = dictTreeFeignClient.queryByCode("baseData").getData();
|
||||
String key = deviceId + "#";
|
||||
if (dictTreeVO != null) {
|
||||
key = deviceId + "#" + dictTreeVO.getId();
|
||||
}
|
||||
redisUtil.delete(key);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,13 @@ import com.njcn.csdevice.mapper.PqsDeviceUnitMapper;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceUserPO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLedger;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.vo.CsMarketDataVO;
|
||||
import com.njcn.csdevice.pojo.vo.CsTouristDataParmVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import com.njcn.device.biz.pojo.po.PqsDeviceUnit;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
@@ -21,9 +24,7 @@ import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -43,6 +44,7 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
private final CsMarketDataService csMarketDataService;
|
||||
private final ICsLedgerService csLedgerService;
|
||||
private final CsTouristDataPOService csTouristDataPOService;
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
|
||||
|
||||
@Override
|
||||
@@ -66,18 +68,15 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
@Override
|
||||
public List<String> getPqUserIdsByUser(String userId) {
|
||||
List<String> result = new ArrayList<>();
|
||||
List<String> devIds = commGetDevIds(userId);
|
||||
if (CollUtil.isEmpty(devIds)) {
|
||||
List<String> lineIds = getLineIdsByUser(userId);
|
||||
if (CollUtil.isEmpty(lineIds)) {
|
||||
return result;
|
||||
}
|
||||
LambdaQueryWrapper<CsLinePO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(CsLinePO::getLineId, CsLinePO::getMonitorUser).in(CsLinePO::getDeviceId, devIds)
|
||||
.eq(CsLinePO::getStatus, DataStateEnum.ENABLE.getCode());
|
||||
List<CsLinePO> poList =csLinePOMapper.selectList(lambdaQueryWrapper);
|
||||
if (CollUtil.isNotEmpty(poList)) {
|
||||
result = poList.stream().map(CsLinePO::getMonitorUser).distinct().collect(Collectors.toList());
|
||||
List<PqGovernPlan> governPlans = pqGovernPlanFeignClient.getListByMonitorPoint(lineIds).getData();
|
||||
if (CollUtil.isEmpty(governPlans)) {
|
||||
return result;
|
||||
}
|
||||
return result;
|
||||
return governPlans.stream().map(PqGovernPlan::getPid).distinct().collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -126,4 +125,90 @@ public class CsCommTerminalServiceImpl implements CsCommTerminalService {
|
||||
}
|
||||
return devIds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DevDetailDTO> getLedgerByLineId(List<String> id) {
|
||||
List<DevDetailDTO> result = new ArrayList<>();
|
||||
List<CsLedger> lineLedgers = csLedgerService.listByIds(id);
|
||||
Set<String> equipmentIds = new HashSet<>();
|
||||
Set<String> projectIds = new HashSet<>();
|
||||
Set<String> engineeringIds = new HashSet<>();
|
||||
|
||||
if (CollUtil.isEmpty(lineLedgers)) {
|
||||
return result;
|
||||
}
|
||||
for (CsLedger item : lineLedgers) {
|
||||
String pids = item.getPids();
|
||||
if (pids == null) {
|
||||
continue;
|
||||
}
|
||||
String[] pidArr = pids.split(",");
|
||||
if (pidArr.length < 4) {
|
||||
continue;
|
||||
}
|
||||
engineeringIds.add(pidArr[1]);
|
||||
projectIds.add(pidArr[2]);
|
||||
equipmentIds.add(pidArr[3]);
|
||||
}
|
||||
|
||||
Map<String, CsLinePO> csLinePoMap = csLinePOMapper.selectBatchIds(id)
|
||||
.stream().collect(Collectors.toMap(CsLinePO::getLineId, item -> item));
|
||||
Map<String, CsLedger> equipmentLedgerMap = csLedgerService.listByIds(equipmentIds)
|
||||
.stream().collect(Collectors.toMap(CsLedger::getId, item -> item));
|
||||
Map<String, CsEquipmentDeliveryPO> equipmentDeliveryMap = csEquipmentDeliveryService.listByIds(equipmentIds)
|
||||
.stream().collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, item -> item));
|
||||
Map<String, CsLedger> projectLedgerMap = csLedgerService.listByIds(projectIds)
|
||||
.stream().collect(Collectors.toMap(CsLedger::getId, item -> item));
|
||||
Map<String, CsLedger> engineeringLedgerMap = csLedgerService.listByIds(engineeringIds)
|
||||
.stream().collect(Collectors.toMap(CsLedger::getId, item -> item));
|
||||
|
||||
for (CsLedger item : lineLedgers) {
|
||||
String pids = item.getPids();
|
||||
if (pids == null) {
|
||||
continue;
|
||||
}
|
||||
String[] pidArr = pids.split(",");
|
||||
if (pidArr.length < 4) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String engineeringId = pidArr[1];
|
||||
String projectId = pidArr[2];
|
||||
String equipmentId = pidArr[3];
|
||||
|
||||
CsLedger engineeringLedger = engineeringLedgerMap.get(engineeringId);
|
||||
CsLedger projectLedger = projectLedgerMap.get(projectId);
|
||||
CsLedger equipmentLedger = equipmentLedgerMap.get(equipmentId);
|
||||
if (engineeringLedger == null || projectLedger == null || equipmentLedger == null) {
|
||||
continue;
|
||||
}
|
||||
DevDetailDTO dto = new DevDetailDTO();
|
||||
dto.setEngineeringid(engineeringId);
|
||||
dto.setEngineeringName(engineeringLedger.getName());
|
||||
dto.setProjectId(projectId);
|
||||
dto.setProjectName(projectLedger.getName());
|
||||
dto.setEquipmentId(equipmentId);
|
||||
dto.setEquipmentName(equipmentLedger.getName());
|
||||
dto.setLineId(item.getId());
|
||||
dto.setLineName(item.getName());
|
||||
dto.setObjType(csLinePoMap.get(item.getId()).getMonitorObj());
|
||||
|
||||
if (Objects.isNull(csLinePoMap.get(item.getId()).getRunStatus())) {
|
||||
CsEquipmentDeliveryPO delivery = equipmentDeliveryMap.get(equipmentId);
|
||||
if (delivery != null) {
|
||||
Integer runStatus = delivery.getRunStatus();
|
||||
if (runStatus == 1) {
|
||||
dto.setRunStatus(2);
|
||||
} else if (runStatus == 2) {
|
||||
dto.setRunStatus(0);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
dto.setRunStatus(csLinePoMap.get(item.getId()).getRunStatus());
|
||||
}
|
||||
result.add(dto);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,22 +1,26 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsDataArrayMapper;
|
||||
import com.njcn.csdevice.pojo.dto.DataArrayDTO;
|
||||
import com.njcn.csdevice.pojo.param.DataArrayParam;
|
||||
import com.njcn.csdevice.pojo.po.CsDataArray;
|
||||
import com.njcn.csdevice.pojo.po.CsDataSet;
|
||||
import com.njcn.csdevice.pojo.vo.DataArrayTreeVO;
|
||||
import com.njcn.csdevice.pojo.vo.DeviceManagerDetailVO;
|
||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
@@ -33,6 +37,7 @@ import java.util.stream.Collectors;
|
||||
public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDataArray> implements ICsDataArrayService {
|
||||
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
@Override
|
||||
public List<CsDataArray> getArrayBySet(String dataSet) {
|
||||
@@ -52,10 +57,13 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
||||
for (Map.Entry<String, List<EleEpdPqd>> entry : map.entrySet()) {
|
||||
DeviceManagerDetailVO vo = new DeviceManagerDetailVO();
|
||||
EleEpdPqd eleEpdPqd = entry.getValue().get(0);
|
||||
if (Objects.equals(eleEpdPqd.getPhase(),"M")){
|
||||
if (Objects.equals(eleEpdPqd.getPhase(),"T")){
|
||||
vo.setPhasic("/");
|
||||
} else {
|
||||
vo.setPhasic(entry.getValue().stream().map(EleEpdPqd::getPhase).collect(Collectors.joining(",")));
|
||||
vo.setPhasic(entry.getValue().stream()
|
||||
.map(EleEpdPqd::getPhase)
|
||||
.map(phase -> "T".equals(phase) ? "总" : phase)
|
||||
.collect(Collectors.joining(",")));
|
||||
}
|
||||
vo.setName(entry.getKey());
|
||||
vo.setType(eleEpdPqd.getType());
|
||||
@@ -104,7 +112,7 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
||||
DataArrayTreeVO vo3 = new DataArrayTreeVO();
|
||||
vo3.setId(item.getDataSetId() + item.getDataArrayName()+item2);
|
||||
vo3.setName(item2);
|
||||
if (Objects.equals(item2,"M")){
|
||||
if (Objects.equals(item2,"T")){
|
||||
vo3.setShowName("无相别");
|
||||
} else {
|
||||
vo3.setShowName(item2);
|
||||
@@ -173,7 +181,34 @@ public class CsDataArrayServiceImpl extends ServiceImpl<CsDataArrayMapper, CsDat
|
||||
|
||||
@Override
|
||||
public List<CsDataArray> findListByParam(DataArrayParam param) {
|
||||
return this.baseMapper.findListByParam(param);
|
||||
List<CsDataArray> list = this.baseMapper.findListByParam(param);
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
DictData pqd = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
|
||||
if (ObjectUtil.isNotNull(pqd) && ObjectUtil.isNotNull(pqd.getId())) {
|
||||
List<EleEpdPqd> epdList = epdFeignClient.dictMarkByDataType(pqd.getId()).getData();
|
||||
if (!CollectionUtils.isEmpty(epdList)) {
|
||||
Map<String, EleEpdPqd> epdPqdMap = epdList.stream().collect(Collectors.toMap(EleEpdPqd::getId, Function.identity()));
|
||||
list.forEach(item->{
|
||||
EleEpdPqd epdPqd = epdPqdMap.get(item.getDataId());
|
||||
if (!Objects.isNull(epdPqd)) {
|
||||
if (epdPqd.getOtherName() == null || epdPqd.getOtherName().isEmpty()) {
|
||||
item.setInfluxDbName(epdPqd.getName());
|
||||
} else {
|
||||
String[] parts = item.getName().split("_");
|
||||
String lastPart = parts[parts.length - 1];
|
||||
boolean isLastNumeric = lastPart.matches("\\d+");
|
||||
if (isLastNumeric) {
|
||||
item.setInfluxDbName(epdPqd.getOtherName() + "_" + lastPart);
|
||||
} else {
|
||||
item.setInfluxDbName(epdPqd.getOtherName());
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -38,7 +38,7 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
||||
.eq(CsDataSet::getPid,modelId)
|
||||
.in(CsDataSet::getType, Arrays.asList(0,2))
|
||||
.eq(CsDataSet::getStoreFlag,1)
|
||||
.and(i->i.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
|
||||
// .and(i->i.eq(CsDataSet::getDataType,"Stat").or().isNull(CsDataSet::getDataType))
|
||||
.orderByAsc(CsDataSet::getIdx)
|
||||
.list();
|
||||
}
|
||||
@@ -64,6 +64,7 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
||||
.eq(CsDataSet::getPid,modelId)
|
||||
.eq(CsDataSet::getClDev,clDev)
|
||||
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType))
|
||||
.eq(CsDataSet::getStoreFlag,0)
|
||||
.list();
|
||||
return list.stream().min(Comparator.comparingInt(CsDataSet::getIdx)).get();
|
||||
}
|
||||
@@ -73,7 +74,8 @@ public class CsDataSetServiceImpl extends ServiceImpl<CsDataSetMapper, CsDataSet
|
||||
LambdaQueryWrapper<CsDataSet> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CsDataSet::getPid,modelId)
|
||||
.eq(CsDataSet::getClDev,clDev)
|
||||
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType));
|
||||
.and(i->i.eq(CsDataSet::getDataType,"Rt").or().isNull(CsDataSet::getDataType))
|
||||
.eq(CsDataSet::getStoreFlag,0);
|
||||
//谐波电压含有率
|
||||
if (target == 0) {
|
||||
wrapper.eq(CsDataSet::getName,"Ds$Pqd$Rt$HarmV$0".concat(clDev.toString()));
|
||||
|
||||
@@ -1,25 +1,19 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsDevCapacityPOMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDevCapacityPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.service.CsDevCapacityPOService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -48,16 +42,13 @@ public class CsDevCapacityPOServiceImpl extends ServiceImpl<CsDevCapacityPOMappe
|
||||
|
||||
@Override
|
||||
public Double getDevCapacity(String id) {
|
||||
List<CsLinePO> csLinePOS = csLinePOService.queryByDevId(id);
|
||||
|
||||
//String areaId = dicDataFeignClient.getDicDataByCode(DicDataEnum.OUTPUT_SIDE.getCode()).getData().getId();
|
||||
|
||||
//Optional.ofNullable(csLinePOS).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.LINE_DATA_ERROR));
|
||||
//List<CsLinePO> collect1 = csLinePOS.stream().filter(temp -> Objects.equals(areaId, temp.getPosition())).collect(Collectors.toList());
|
||||
List<CsLinePO> pos = csLinePOService.queryByDevId(id);
|
||||
/*治理侧监测点*/
|
||||
CsLinePO csLinePO = csLinePOS.get(0);
|
||||
CsDevCapacityPO one = this.lambdaQuery().eq(CsDevCapacityPO::getLineId, csLinePO.getLineId()).eq(CsDevCapacityPO::getCldid, 0).one();
|
||||
// Optional.ofNullable(one).orElseThrow(()-> new BusinessException(AlgorithmResponseEnum.DATA_MISSING));
|
||||
CsLinePO po = pos.stream().filter(item -> Objects.equals(item.getClDid(),0)).findFirst().orElse(null);
|
||||
if (po == null) {
|
||||
return 0.0;
|
||||
}
|
||||
CsDevCapacityPO one = this.lambdaQuery().eq(CsDevCapacityPO::getLineId, po.getLineId()).eq(CsDevCapacityPO::getCldid, 0).one();
|
||||
if(Objects.isNull(one)){
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsDeviceRegistryMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsDeviceRegistry;
|
||||
import com.njcn.csdevice.service.ICsDeviceRegistryService;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author 徐扬
|
||||
*/
|
||||
@Service
|
||||
public class CsDeviceRegistryServiceImpl extends ServiceImpl<CsDeviceRegistryMapper, CsDeviceRegistry> implements ICsDeviceRegistryService {
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean add(List<CsDeviceRegistry> list) {
|
||||
return this.saveBatch(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean update(CsDeviceRegistry csDeviceRegistry) {
|
||||
return this.updateById(csDeviceRegistry);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public boolean updateBatch(List<CsDeviceRegistry> list) {
|
||||
return this.updateBatchById(list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByCurrentNdid(String currentNdid) {
|
||||
LambdaQueryWrapper<CsDeviceRegistry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid);
|
||||
this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delete(String id) {
|
||||
return this.removeById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateIsAccessByCurrentNdid(String currentNdid, Integer isAccess) {
|
||||
LambdaUpdateWrapper<CsDeviceRegistry> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid)
|
||||
.set(CsDeviceRegistry::getIsAccess, isAccess);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsDeviceRegistry> queryByCurrentNdid(String currentNdid) {
|
||||
LambdaQueryWrapper<CsDeviceRegistry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid);
|
||||
return this.list(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CsDeviceRegistry queryByCurrentNdidAndClDid(String currentNdid, Integer clDid) {
|
||||
LambdaQueryWrapper<CsDeviceRegistry> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsDeviceRegistry::getCurrentNdid, currentNdid)
|
||||
.eq(CsDeviceRegistry::getClDid, clDid);
|
||||
return this.getOne(queryWrapper);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsDeviceUserPOMapper;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
||||
@@ -31,11 +32,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static java.util.Objects.isNull;
|
||||
@@ -62,6 +59,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
private final EventUserFeignClient eventUserFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final IMqttUserService mqttUserService;
|
||||
private final CsCommTerminalFeignClient commTerminalService;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -158,6 +156,14 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
// 如果游客没有配置任何数据权限,返回空列表
|
||||
appLedger = new ArrayList<>();
|
||||
}
|
||||
} else {
|
||||
//根据用户获取所属的设备
|
||||
List<String> lineIds = commTerminalService.getLineIdsByUser(RequestUtil.getUserIndex()).getData();
|
||||
if (CollectionUtil.isEmpty(lineIds)) {
|
||||
return vo;
|
||||
}
|
||||
Set<String> targetLineIds = new HashSet<>(lineIds);
|
||||
appLedger = filterLedgerTree(appLedger, targetLineIds);
|
||||
}
|
||||
|
||||
if (CollectionUtil.isNotEmpty(appLedger)) {
|
||||
@@ -235,6 +241,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
}
|
||||
|
||||
//note 当前工程数据
|
||||
vo.setLineCount(0);
|
||||
//当前工程id
|
||||
vo.setCurrentId(id);
|
||||
//设备集合
|
||||
@@ -287,6 +294,7 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
}
|
||||
//获取未读事件数量
|
||||
if (CollectionUtil.isNotEmpty(currentLineIds)) {
|
||||
vo.setLineCount(currentLineIds.size());
|
||||
CsEventUserQueryParam param1 = new CsEventUserQueryParam();
|
||||
param1.setUserId(RequestUtil.getUserIndex());
|
||||
param1.setStartTime(PublicDataUtils.calculateMonthStart(time));
|
||||
@@ -316,6 +324,40 @@ public class CsDeviceUserPOServiceImpl extends ServiceImpl<CsDeviceUserPOMapper,
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 递归过滤台账树,仅保留包含目标lineId的分支
|
||||
*/
|
||||
private List<CsLedgerVO> filterLedgerTree(List<CsLedgerVO> nodes, Set<String> targetLineIds) {
|
||||
if (CollectionUtils.isEmpty(nodes)) {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
return nodes.stream()
|
||||
.filter(node -> isNodeRelevant(node, targetLineIds))
|
||||
.peek(node -> {
|
||||
// 递归过滤子节点,并重新设置过滤后的子列表
|
||||
if (CollectionUtil.isNotEmpty(node.getChildren())) {
|
||||
node.setChildren(filterLedgerTree(node.getChildren(), targetLineIds));
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断当前节点或其任意子孙节点是否包含目标lineId
|
||||
*/
|
||||
private boolean isNodeRelevant(CsLedgerVO node, Set<String> targetLineIds) {
|
||||
// 1. 当前节点本身就是目标监测点
|
||||
if (node.getId() != null && targetLineIds.contains(node.getId())) {
|
||||
return true;
|
||||
}
|
||||
// 2. 子孙节点中包含目标监测点
|
||||
if (CollectionUtil.isNotEmpty(node.getChildren())) {
|
||||
return node.getChildren().stream()
|
||||
.anyMatch(child -> isNodeRelevant(child, targetLineIds));
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @Description: 判断当前用户是否是主用户 0-否1-是
|
||||
* @Param:
|
||||
|
||||
@@ -138,6 +138,7 @@ public class CsEngineeringServiceImpl extends ServiceImpl<CsEngineeringMapper, C
|
||||
if(StringUtils.isNotBlank(csEngineeringAuditParm.getName())){
|
||||
csLedger1.setName(csEngineeringAuditParm.getName());
|
||||
}
|
||||
csLedger1.setSort(csEngineeringAuditParm.getSort());
|
||||
csLedgerMapper.updateById(csLedger1);
|
||||
List<CsEngineeringPO> list = this.lambdaQuery().eq(CsEngineeringPO::getName, csEngineeringAuditParm.getName()).eq(CsEngineeringPO::getStatus, "1").list();
|
||||
if(list.size()>1){
|
||||
|
||||
@@ -24,10 +24,8 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.api.AskDeviceDataFeignClient;
|
||||
import com.njcn.access.utils.MqttUtil;
|
||||
import com.njcn.common.pojo.dto.DeviceLogDTO;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsLedgerFeignClient;
|
||||
import com.njcn.csdevice.api.CsLogsFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.CsEquipmentDeliveryMapper;
|
||||
@@ -46,6 +44,7 @@ import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csdevice.util.QRCodeUtil;
|
||||
import com.njcn.csdevice.utils.ExcelStyleUtil;
|
||||
import com.njcn.csdevice.utils.StringUtil;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
@@ -68,7 +67,10 @@ import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.data.redis.core.StringRedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -97,6 +99,7 @@ import java.util.stream.Collectors;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliveryMapper, CsEquipmentDeliveryPO> implements CsEquipmentDeliveryService {
|
||||
private static final Logger logger = LoggerFactory.getLogger(CsEquipmentDeliveryServiceImpl.class);
|
||||
private final CsDevModelRelationService csDevModelRelationService;
|
||||
private final ICsDataSetService csDataSetService;
|
||||
private final ICsLedgerService csLedgerService;
|
||||
@@ -113,7 +116,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final RedisUtil redisUtil;
|
||||
private final CsSoftInfoMapper csSoftInfoMapper;
|
||||
private final MqttUtil mqttUtil;
|
||||
private final CsLogsFeignClient csLogsFeignClient;
|
||||
private final INodeService nodeService;
|
||||
private final CsDevModelService csDevModelService;
|
||||
private final CsLedgerMapper csLedgerMapper;
|
||||
@@ -128,6 +130,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final OverLimitWlMapper overLimitWlMapper;
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
private final CsHarmonicPlanLineFeignClient csHarmonicPlanLineFeignClient;
|
||||
private final ICsDeviceRegistryService csDeviceRegistryService;
|
||||
private final StringRedisTemplate stringRedisTemplate;
|
||||
|
||||
@Override
|
||||
public void refreshDeviceDataCache() {
|
||||
@@ -214,7 +219,8 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csLinePOService.remove(csLinePOLambdaQueryWrapper);
|
||||
//删除监测点限值
|
||||
overLimitWlMapper.deleteBatchIds(collect);
|
||||
|
||||
//删除配置
|
||||
csHarmonicPlanLineFeignClient.deleteByLineIds(collect);
|
||||
QueryWrapper<AppLineTopologyDiagramPO> appLineTopologyDiagramPOQueryWrapper = new QueryWrapper<>();
|
||||
appLineTopologyDiagramPOQueryWrapper.clear();
|
||||
appLineTopologyDiagramPOQueryWrapper.in("line_id", collect);
|
||||
@@ -242,6 +248,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
QueryWrapper<CsTouristDataPO> queryWrap = new QueryWrapper<>();
|
||||
queryWrap.eq("device_id", id);
|
||||
csTouristDataPOService.getBaseMapper().delete(queryWrap);
|
||||
//删除设备注册表
|
||||
if (po != null) {
|
||||
csDeviceRegistryService.deleteByCurrentNdid(po.getNdid());
|
||||
}
|
||||
if (update) {
|
||||
refreshDeviceDataCache();
|
||||
}
|
||||
@@ -256,12 +266,17 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
return result;
|
||||
}
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryPO, result);
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryPO, result);
|
||||
if (!Objects.isNull(csEquipmentDeliveryPO.getAssociatedEngineering()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedEngineering(), "")) {
|
||||
result.setAssociatedEngineeringName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedEngineering()).getName());
|
||||
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedEngineering());
|
||||
if (!Objects.isNull(csLedger)) {
|
||||
result.setAssociatedEngineeringName(csLedger.getName());
|
||||
}
|
||||
}
|
||||
if (!Objects.isNull(csEquipmentDeliveryPO.getAssociatedProject()) && !Objects.equals(csEquipmentDeliveryPO.getAssociatedProject(), "")) {
|
||||
result.setAssociatedProjectName(csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedProject()).getName());
|
||||
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryPO.getAssociatedProject());
|
||||
if (!Objects.isNull(csLedger)) {
|
||||
result.setAssociatedProjectName(csLedger.getName());
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
@@ -306,7 +321,6 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
//判断设备是否存在告警
|
||||
temp.setIsAlarm(CollectionUtil.isNotEmpty(eventMap.get(temp.getEquipmentId())));
|
||||
});
|
||||
|
||||
//获取用户置顶的设备
|
||||
List<CsUserPins> topList = csUserPinsService.getPinToTopList();
|
||||
List<String> targetIdList = topList.stream().filter(item -> Objects.equals(item.getTargetType(), 1)).map(CsUserPins::getTargetId).collect(Collectors.toList());
|
||||
@@ -334,50 +348,236 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
return list;
|
||||
}
|
||||
|
||||
// ... existing code ...
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) {
|
||||
StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid());
|
||||
boolean result;
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
|
||||
int countByAccount = this.count(lambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm auditParm) {
|
||||
StringUtil.containsSpecialCharacters(auditParm.getNdid());
|
||||
// 校验ndid不重复
|
||||
long ndidCount = this.count(new LambdaQueryWrapper<CsEquipmentDeliveryPO>()
|
||||
.eq(CsEquipmentDeliveryPO::getNdid, auditParm.getNdid())
|
||||
.in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3))
|
||||
.ne(CsEquipmentDeliveryPO::getId, auditParm.getId()));
|
||||
if (ndidCount > 0) {
|
||||
throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
|
||||
}
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
|
||||
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
|
||||
List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()).ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
// 查询原记录
|
||||
CsEquipmentDeliveryPO po = this.getById(auditParm.getId());
|
||||
if (Objects.isNull(po)) {
|
||||
throw new BusinessException("设备不存在");
|
||||
}
|
||||
// 校验设备名称不重复
|
||||
long nameCount = this.lambdaQuery()
|
||||
.ne(CsEquipmentDeliveryPO::getId, auditParm.getId())
|
||||
.ne(CsEquipmentDeliveryPO::getNdid, auditParm.getNdid())
|
||||
.eq(CsEquipmentDeliveryPO::getName, auditParm.getName())
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus, 0)
|
||||
.eq(CsEquipmentDeliveryPO::getDevAccessMethod, "MQTT")
|
||||
.count();
|
||||
if (nameCount > 0) {
|
||||
throw new BusinessException("设备名称不能重复");
|
||||
}
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
|
||||
BeanUtils.copyProperties(csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
|
||||
result = this.updateById(csEquipmentDeliveryPo);
|
||||
//如果是已经接入的设备需要修改台账树中的设备名称
|
||||
CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
|
||||
CsEquipmentDeliveryPO updatePo = new CsEquipmentDeliveryPO();
|
||||
// 修改了ndid时的联动处理
|
||||
if (!Objects.equals(po.getNdid(), auditParm.getNdid())) {
|
||||
handleNdidChange(po, auditParm, updatePo);
|
||||
}
|
||||
BeanUtils.copyProperties(auditParm, updatePo);
|
||||
updatePo.setMac(createPath(auditParm.getNdid()));
|
||||
// 更新台账树中的设备名称及工程/项目
|
||||
CsLedger csLedger = csLedgerService.findDataById(auditParm.getId());
|
||||
if (ObjectUtil.isNotNull(csLedger)) {
|
||||
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
|
||||
BeanUtils.copyProperties(csLedger, csLedgerParam);
|
||||
csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
|
||||
csLedgerService.updateLedgerTree(csLedgerParam);
|
||||
csLedger.setName(auditParm.getName());
|
||||
updateLedger(csLedger);
|
||||
handleEngineeringProjectChange(po, auditParm, csLedger);
|
||||
}
|
||||
if (result) {
|
||||
refreshDeviceDataCache();
|
||||
if (!Objects.equals(po.getUsageStatus(), csEquipmentDeliveryAuditParm.getUsageStatus())) {
|
||||
DeviceLogDTO dto = new DeviceLogDTO();
|
||||
dto.setUserName(RequestUtil.getUsername());
|
||||
dto.setOperate("设备使用状态被修改");
|
||||
dto.setResult(1);
|
||||
dto.setLoginName(RequestUtil.getLoginName());
|
||||
csLogsFeignClient.addUserLog(dto);
|
||||
}
|
||||
}
|
||||
return result;
|
||||
return this.updateById(updatePo);
|
||||
}
|
||||
|
||||
private void handleNdidChange(CsEquipmentDeliveryPO po, CsEquipmentDeliveryAuditParm auditParm, CsEquipmentDeliveryPO updatePo) {
|
||||
String oldNdid = po.getNdid();
|
||||
String newNdid = auditParm.getNdid();
|
||||
// 1、更新设备注册表信息记录
|
||||
List<CsDeviceRegistry> registryList = csDeviceRegistryService.queryByCurrentNdid(oldNdid);
|
||||
List<CsDeviceRegistry> updateList = registryList.stream().map(item -> {
|
||||
CsDeviceRegistry registry = new CsDeviceRegistry();
|
||||
registry.setId(item.getId());
|
||||
registry.setCurrentNdid(newNdid);
|
||||
registry.setOldNdid(oldNdid);
|
||||
registry.setClDid(item.getClDid());
|
||||
registry.setFirstSeenTime(item.getFirstSeenTime());
|
||||
registry.setIsAccess(0);
|
||||
return registry;
|
||||
}).collect(Collectors.toList());
|
||||
csDeviceRegistryService.updateBatch(updateList);
|
||||
// 2、迁移redis缓存
|
||||
transferRedisCache(AppRedisKey.MODEL, oldNdid, newNdid);
|
||||
transferRedisCache(AppRedisKey.LINE_POSITION, oldNdid, newNdid);
|
||||
// 3、修改设备状态为离线、已注册
|
||||
updatePo.setRunStatus(1);
|
||||
updatePo.setStatus(2);
|
||||
// 4、清空老mac的数据模板
|
||||
stringRedisTemplate.convertAndSend("model_cache_clear", "clear");
|
||||
// 5、修改二维码信息
|
||||
updatePo.setQrPath(this.createQr(newNdid));
|
||||
}
|
||||
|
||||
private void transferRedisCache(String keyPrefix, String oldNdid, String newNdid) {
|
||||
Object data = redisUtil.getObjectByKey(keyPrefix + oldNdid);
|
||||
if (data != null) {
|
||||
redisUtil.delete(keyPrefix + oldNdid);
|
||||
redisUtil.saveByKey(keyPrefix + newNdid, data);
|
||||
}
|
||||
}
|
||||
|
||||
private void handleEngineeringProjectChange(CsEquipmentDeliveryPO po, CsEquipmentDeliveryAuditParm auditParm, CsLedger csLedger) {
|
||||
boolean engineeringChanged = !Objects.equals(po.getAssociatedEngineering(), auditParm.getAssociatedEngineering());
|
||||
boolean projectChanged = !Objects.equals(po.getAssociatedProject(), auditParm.getAssociatedProject());
|
||||
if (!engineeringChanged && !projectChanged) {
|
||||
return;
|
||||
}
|
||||
// 已接入过的设备,工程和项目不能为空
|
||||
if (!Objects.equals(po.getStatus(), 1)) {
|
||||
if (StringUtils.isBlank(auditParm.getAssociatedEngineering()) || StringUtils.isBlank(auditParm.getAssociatedProject())) {
|
||||
throw new BusinessException("装置已接入过,工程项目不可设置为空");
|
||||
}
|
||||
// 修改设备台账的pid和pids
|
||||
csLedger.setPid(auditParm.getAssociatedProject());
|
||||
String[] pidsParts = csLedger.getPids().split(",");
|
||||
pidsParts[1] = auditParm.getAssociatedEngineering();
|
||||
pidsParts[2] = auditParm.getAssociatedProject();
|
||||
csLedger.setPids(String.join(",", pidsParts));
|
||||
updateLedger(csLedger);
|
||||
// 修改监测点的pids
|
||||
List<CsLedger> lineLedgers = csLedgerService.queryByPid(po.getId());
|
||||
lineLedgers.forEach(item -> {
|
||||
String[] linePidsParts = item.getPids().split(",");
|
||||
linePidsParts[1] = auditParm.getAssociatedEngineering();
|
||||
linePidsParts[2] = auditParm.getAssociatedProject();
|
||||
item.setPids(String.join(",", linePidsParts));
|
||||
updateLedger(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private void updateLedger(CsLedger csLedger) {
|
||||
CsLedgerParam.Update updateParam = new CsLedgerParam.Update();
|
||||
BeanUtils.copyProperties(csLedger, updateParam);
|
||||
csLedgerService.updateLedgerTree(updateParam);
|
||||
}
|
||||
|
||||
// ... existing code ...
|
||||
|
||||
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = Exception.class)
|
||||
// public Boolean updateEquipmentDelivery(CsEquipmentDeliveryAuditParm csEquipmentDeliveryAuditParm) {
|
||||
// StringUtil.containsSpecialCharacters(csEquipmentDeliveryAuditParm.getNdid());
|
||||
// boolean result;
|
||||
// LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).in(CsEquipmentDeliveryPO::getStatus, Arrays.asList(1, 2, 3)).ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
|
||||
// int countByAccount = this.count(lambdaQueryWrapper);
|
||||
// //大于等于1个则表示重复
|
||||
// if (countByAccount >= 1) {
|
||||
// throw new BusinessException(AlgorithmResponseEnum.NDID_ERROR);
|
||||
// }
|
||||
// LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId());
|
||||
// CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
|
||||
// CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
|
||||
// //修改了mac地址
|
||||
// if (!Objects.equals(po.getNdid(), csEquipmentDeliveryAuditParm.getNdid())) {
|
||||
// List<CsDeviceRegistry> updateList = new ArrayList<>();
|
||||
// //1、更新设备注册表信息记录
|
||||
// List<CsDeviceRegistry> list = csDeviceRegistryService.queryByCurrentNdid(po.getNdid());
|
||||
// list.forEach(item->{
|
||||
// CsDeviceRegistry csDeviceRegistry = new CsDeviceRegistry();
|
||||
// csDeviceRegistry.setId(item.getId());
|
||||
// csDeviceRegistry.setCurrentNdid(csEquipmentDeliveryAuditParm.getNdid());
|
||||
// csDeviceRegistry.setOldNdid(po.getNdid());
|
||||
// csDeviceRegistry.setClDid(item.getClDid());
|
||||
// csDeviceRegistry.setFirstSeenTime(item.getFirstSeenTime());
|
||||
// csDeviceRegistry.setIsAccess(0);
|
||||
// updateList.add(csDeviceRegistry);
|
||||
// });
|
||||
// csDeviceRegistryService.updateBatch(updateList);
|
||||
// //2、修改redis的缓存信息
|
||||
// Object data1 = redisUtil.getObjectByKey(AppRedisKey.MODEL + po.getNdid());
|
||||
// Object data2 = redisUtil.getObjectByKey(AppRedisKey.LINE_POSITION + po.getNdid());
|
||||
// if (data1 != null) {
|
||||
// redisUtil.delete(AppRedisKey.MODEL + po.getNdid());
|
||||
// redisUtil.saveByKey(AppRedisKey.MODEL + csEquipmentDeliveryAuditParm.getNdid(), data1);
|
||||
// }
|
||||
// if (data2 != null) {
|
||||
// redisUtil.delete(AppRedisKey.LINE_POSITION + po.getNdid());
|
||||
// redisUtil.saveByKey(AppRedisKey.LINE_POSITION + csEquipmentDeliveryAuditParm.getNdid(), data2);
|
||||
// }
|
||||
// //3、修改设备状态,设备应该是离线 已注册
|
||||
// csEquipmentDeliveryPo.setRunStatus(1);
|
||||
// csEquipmentDeliveryPo.setStatus(2);
|
||||
// //4.清空老mac的数据模板
|
||||
// stringRedisTemplate.convertAndSend("model_cache_clear", "clear");
|
||||
// //5.修改二维码信息
|
||||
// String qr = this.createQr(csEquipmentDeliveryAuditParm.getNdid());
|
||||
// csEquipmentDeliveryPo.setQrPath(qr);
|
||||
// }
|
||||
// List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, csEquipmentDeliveryAuditParm.getId()).ne(CsEquipmentDeliveryPO::getNdid, csEquipmentDeliveryAuditParm.getNdid()).eq(CsEquipmentDeliveryPO::getName, csEquipmentDeliveryAuditParm.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
|
||||
// if (!CollectionUtils.isEmpty(list)) {
|
||||
// throw new BusinessException("设备名称不能重复");
|
||||
// }
|
||||
// BeanUtils.copyProperties(csEquipmentDeliveryAuditParm, csEquipmentDeliveryPo);
|
||||
// csEquipmentDeliveryPo.setMac(csEquipmentDeliveryAuditParm.getNdid().replaceAll("(.{2})", "$1:").substring(0, 17));
|
||||
//
|
||||
// //如果是已经接入的设备需要修改台账树中的设备名称
|
||||
// CsLedger csLedger = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
|
||||
// if (ObjectUtil.isNotNull(csLedger)) {
|
||||
// CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
|
||||
// BeanUtils.copyProperties(csLedger, csLedgerParam);
|
||||
// csLedgerParam.setName(csEquipmentDeliveryAuditParm.getName());
|
||||
// csLedgerService.updateLedgerTree(csLedgerParam);
|
||||
// }
|
||||
// //修改预设的工程和项目
|
||||
// //判断设备状态,如果已经接入过,那么工程项目就不能设置为null;如果没有接入过,没有限制
|
||||
// if (!Objects.equals(po.getAssociatedEngineering(), csEquipmentDeliveryAuditParm.getAssociatedEngineering())
|
||||
// || !Objects.equals(po.getAssociatedProject(), csEquipmentDeliveryAuditParm.getAssociatedProject())) {
|
||||
// if (po.getStatus() != 1) {
|
||||
// if (Objects.isNull(csEquipmentDeliveryAuditParm.getAssociatedEngineering()) || Objects.isNull(csEquipmentDeliveryAuditParm.getAssociatedProject())) {
|
||||
// throw new BusinessException("装置已接入过,工程项目不可设置为空");
|
||||
// } else {
|
||||
// //修改设备
|
||||
// CsLedger csLedger2 = csLedgerService.findDataById(csEquipmentDeliveryAuditParm.getId());
|
||||
// csLedger2.setPid(csEquipmentDeliveryAuditParm.getAssociatedProject());
|
||||
// String pidS = csLedger2.getPids();
|
||||
// String[] parts = pidS.split(",");
|
||||
// parts[1] = csEquipmentDeliveryAuditParm.getAssociatedEngineering();
|
||||
// parts[2] = csEquipmentDeliveryAuditParm.getAssociatedProject();
|
||||
// String newPidS = String.join(",", parts);
|
||||
// csLedger2.setPids(newPidS);
|
||||
// CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
|
||||
// BeanUtils.copyProperties(csLedger2, csLedgerParam);
|
||||
// csLedgerService.updateLedgerTree(csLedgerParam);
|
||||
// csEquipmentDeliveryPo.setAssociatedEngineering(csEquipmentDeliveryAuditParm.getAssociatedEngineering());
|
||||
// csEquipmentDeliveryPo.setAssociatedProject(csEquipmentDeliveryAuditParm.getAssociatedProject());
|
||||
// //修改监测点
|
||||
// List<CsLedger> csLedgers = csLedgerService.queryByPid(po.getId());
|
||||
// csLedgers.forEach(item->{
|
||||
// String linePidS = item.getPids();
|
||||
// String[] lineParts = linePidS.split(",");
|
||||
// lineParts[1] = csEquipmentDeliveryAuditParm.getAssociatedEngineering();
|
||||
// lineParts[2] = csEquipmentDeliveryAuditParm.getAssociatedProject();
|
||||
// String lineNewPidS = String.join(",", lineParts);
|
||||
// item.setPids(lineNewPidS);
|
||||
// CsLedgerParam.Update csLedgerParam2 = new CsLedgerParam.Update();
|
||||
// BeanUtils.copyProperties(item, csLedgerParam2);
|
||||
// csLedgerService.updateLedgerTree(csLedgerParam2);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// result = this.updateById(csEquipmentDeliveryPo);
|
||||
// return result;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void updateStatusBynDid(String nDId, Integer status) {
|
||||
boolean result;
|
||||
@@ -397,6 +597,14 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
queryParam.setPageNum((queryParam.getPageNum() - 1) * queryParam.getPageSize());
|
||||
int total = this.baseMapper.getCounts(queryParam);
|
||||
if (total > 0) {
|
||||
//获取设备注册信息表数据
|
||||
List<CsDeviceRegistry> list = csDeviceRegistryService.list();
|
||||
Map<String, List<CsDeviceRegistry>> groupedMap;
|
||||
if (list == null || list.isEmpty()) {
|
||||
groupedMap = Collections.emptyMap();
|
||||
} else {
|
||||
groupedMap = list.stream().collect(Collectors.groupingBy(CsDeviceRegistry::getCurrentNdid));
|
||||
}
|
||||
List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam);
|
||||
//新增逻辑(针对便携式设备、监测设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
|
||||
for (CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList) {
|
||||
@@ -416,6 +624,10 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
} else {
|
||||
csEquipmentDeliveryVO.setConnectStatus("未连接");
|
||||
}
|
||||
List<CsDeviceRegistry> data = groupedMap.get(csEquipmentDeliveryVO.getNdid());
|
||||
if (data != null && !data.isEmpty()) {
|
||||
csEquipmentDeliveryVO.setIsAccess(data.get(0).getIsAccess());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(queryParam.getConnectStatus())) {
|
||||
recordList = recordList.stream().filter(item -> queryParam.getConnectStatus() == 0 ? "未连接".equals(item.getConnectStatus()) : "已连接".equals(item.getConnectStatus())).collect(Collectors.toList());
|
||||
@@ -507,6 +719,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
dataSetVO.setName(item.getAnotherName());
|
||||
dataSetVO.setType("rt");
|
||||
dataSetList.add(dataSetVO);
|
||||
dataSetVO.setSort(item.getIdx());
|
||||
deviceManagerVo.setDataLevel(item.getDataLevel());
|
||||
}
|
||||
} else {
|
||||
@@ -514,31 +727,38 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
boolean isPortableDevice = DataParam.portableDevType.equals(csEquipmentDeliveryPo.getDevType());
|
||||
boolean isCLdDevice = DicDataEnum.DEV_CLD.getCode().equals(dictTreeFeignClient.queryById(csEquipmentDeliveryPo.getDevType()).getData().getCode());
|
||||
|
||||
addDataSet(dataSetList, item, "最新数据", "rt");
|
||||
addDataSet(dataSetList, item, "历史统计数据", "history");
|
||||
addDataSet(dataSetList, item, "历史趋势", "trenddata");
|
||||
addDataSet(dataSetList, item, "最新数据", "rt",0);
|
||||
if (item.getClDev() == 0 && item.getType() == 0) {
|
||||
//限制角色展示
|
||||
String role = RequestUtil.getUserRole();
|
||||
List<String> strings = JSONArray.parseArray(role, String.class);
|
||||
if (strings.contains(AppRoleEnum.ENGINEERING_USER.getCode()) || strings.contains(AppRoleEnum.OPERATION_MANAGER.getCode()) || strings.contains(AppRoleEnum.ROOT.getCode())) {
|
||||
addDataSet(dataSetList, item, "模块数据", "moduleData");
|
||||
addDataSet(dataSetList, item, "模块数据", "moduleData",3);
|
||||
}
|
||||
addDataSet(dataSetList, item, "历史数据", "trenddata",2);
|
||||
addDataSet(dataSetList, item, "暂态数据", "event",4);
|
||||
addDataSet(dataSetList, item, "运行数据", "devRunTrend",5);
|
||||
} else {
|
||||
addDataSet(dataSetList, item, "历史数据", "trenddata",2);
|
||||
addDataSet(dataSetList, item, "暂态数据", "event",4);
|
||||
addDataSet(dataSetList, item, "运行数据", "devRunTrend",5);
|
||||
addDataSet(dataSetList, item, "电度数据", "kilowattHour",6);
|
||||
}
|
||||
if (isPortableDevice) {
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata",1);
|
||||
// 便携式设备特有的数据集
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata");
|
||||
addDataSet(dataSetList, item, "暂态事件", "event");
|
||||
addDataSet(dataSetList, item, "测试项日志", "items");
|
||||
addDataSet(dataSetList, item, "测试项数据", "items",7);
|
||||
}
|
||||
if (isCLdDevice) {
|
||||
// 云前置数据集
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata");
|
||||
addDataSet(dataSetList, item, "暂态事件", "event");
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata",1);
|
||||
}
|
||||
addDataSet(dataSetList, item, "运行趋势", "devRunTrend");
|
||||
|
||||
deviceManagerVo.setDataLevel(item.getDataLevel());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(dataSetList)) {
|
||||
dataSetList.sort(Comparator.comparing(DeviceManagerVO.DataSetVO::getSort));
|
||||
}
|
||||
deviceManagerVo.setDataSetList(dataSetList);
|
||||
List<CsLinePO> csLinePOS = csLinePOService.findByNdid(csEquipmentDeliveryPo.getNdid());
|
||||
if (!csLinePOS.isEmpty()) {
|
||||
@@ -548,11 +768,12 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
}
|
||||
}
|
||||
|
||||
private void addDataSet(List<DeviceManagerVO.DataSetVO> dataSetList, CsDataSet item, String name, String type) {
|
||||
private void addDataSet(List<DeviceManagerVO.DataSetVO> dataSetList, CsDataSet item, String name, String type, Integer sort) {
|
||||
DeviceManagerVO.DataSetVO dataSetVO = new DeviceManagerVO.DataSetVO();
|
||||
dataSetVO.setId(item.getId());
|
||||
dataSetVO.setName(name);
|
||||
dataSetVO.setType(type);
|
||||
dataSetVO.setSort(sort);
|
||||
dataSetList.add(dataSetVO);
|
||||
}
|
||||
|
||||
@@ -572,6 +793,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
return this.lambdaQuery().eq(CsEquipmentDeliveryPO::getNdid, nDid).ne(CsEquipmentDeliveryPO::getRunStatus, 0).one();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public List<CsEquipmentDeliveryPO> importEquipment(MultipartFile file, HttpServletResponse response) {
|
||||
@@ -945,22 +1167,13 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
csTerminalLogs.setNodeProcess(one.getNodeProcess());
|
||||
csTerminalLogs.setDeviceName(one.getName());
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
//删除设备注册表
|
||||
csDeviceRegistryService.deleteByCurrentNdid(one.getNdid());
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean updateCldDev(CsEquipmentDeliveryAuditParm param) {
|
||||
// //云前置设备判断,修改云前置判断设备是否达到上限
|
||||
// if(ObjectUtil.isNotNull(param.getNodeId())){
|
||||
// Node node = nodeService.getNodeById(param.getNodeId());
|
||||
// List<CsEquipmentDeliveryPO> devList = getListByNodeId(param.getNodeId());
|
||||
// if (ObjectUtil.isNotEmpty(devList) && devList.size() >= node.getNodeDevNum()) {
|
||||
// throw new BusinessException (AlgorithmResponseEnum.OVER_MAX_DEV_COUNT);
|
||||
// }
|
||||
// //自动分配进程号
|
||||
// int process = findLeastFrequentProcess(devList,node.getMaxProcessNum());
|
||||
// param.setNodeProcess(process);
|
||||
// }
|
||||
StringUtil.containsSpecialCharacters(param.getNdid());
|
||||
boolean result;
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
@@ -973,14 +1186,28 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper2 = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper2.eq(CsEquipmentDeliveryPO::getId, param.getId());
|
||||
CsEquipmentDeliveryPO po = this.baseMapper.selectOne(lambdaQueryWrapper2);
|
||||
if (!Objects.equals(po.getNdid(), param.getNdid())) {
|
||||
List<CsDeviceRegistry> updateList = new ArrayList<>();
|
||||
//修改了mac地址
|
||||
List<CsDeviceRegistry> list = csDeviceRegistryService.queryByCurrentNdid(po.getNdid());
|
||||
list.forEach(item->{
|
||||
CsDeviceRegistry csDeviceRegistry = new CsDeviceRegistry();
|
||||
csDeviceRegistry.setId(item.getId());
|
||||
csDeviceRegistry.setCurrentNdid(param.getNdid());
|
||||
csDeviceRegistry.setOldNdid(po.getNdid());
|
||||
csDeviceRegistry.setClDid(item.getClDid());
|
||||
csDeviceRegistry.setFirstSeenTime(item.getFirstSeenTime());
|
||||
updateList.add(csDeviceRegistry);
|
||||
});
|
||||
csDeviceRegistryService.updateBatch(updateList);
|
||||
}
|
||||
List<CsEquipmentDeliveryPO> list = this.lambdaQuery().ne(CsEquipmentDeliveryPO::getId, param.getId()).ne(CsEquipmentDeliveryPO::getNdid, param.getNdid()).eq(CsEquipmentDeliveryPO::getName, param.getName()).ne(CsEquipmentDeliveryPO::getRunStatus, 0).list();
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
throw new BusinessException("设备名称不能重复");
|
||||
}
|
||||
CsEquipmentDeliveryPO csEquipmentDeliveryPo = new CsEquipmentDeliveryPO();
|
||||
BeanUtils.copyProperties(param, csEquipmentDeliveryPo);
|
||||
String path = this.createPath(param.getNdid());
|
||||
csEquipmentDeliveryPo.setMac(path);
|
||||
csEquipmentDeliveryPo.setMac(param.getNdid().replaceAll("(.{2})", "$1:").substring(0, 17));
|
||||
result = this.updateById(csEquipmentDeliveryPo);
|
||||
//修改台账树中的设备名称
|
||||
CsLedger csLedger = csLedgerService.findDataById(param.getId());
|
||||
@@ -988,19 +1215,9 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
CsLedgerParam.Update csLedgerParam = new CsLedgerParam.Update();
|
||||
BeanUtils.copyProperties(csLedger, csLedgerParam);
|
||||
csLedgerParam.setName(param.getName());
|
||||
csLedgerParam.setSort(param.getSort());
|
||||
csLedgerService.updateLedgerTree(csLedgerParam);
|
||||
}
|
||||
if (result) {
|
||||
refreshDeviceDataCache();
|
||||
if (!Objects.equals(po.getUsageStatus(), param.getUsageStatus())) {
|
||||
DeviceLogDTO dto = new DeviceLogDTO();
|
||||
dto.setUserName(RequestUtil.getUsername());
|
||||
dto.setOperate("设备使用状态被修改");
|
||||
dto.setResult(1);
|
||||
dto.setLoginName(RequestUtil.getLoginName());
|
||||
csLogsFeignClient.addUserLog(dto);
|
||||
}
|
||||
}
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(csEquipmentDeliveryPo.getId());
|
||||
|
||||
@@ -1,14 +1,11 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.mapper.CsEventSendMsgMapper;
|
||||
import com.njcn.csdevice.pojo.po.CsEventSendMsg;
|
||||
import com.njcn.csdevice.pojo.po.CsLogsPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEventSendMsgVO;
|
||||
import com.njcn.csdevice.service.ICsEventSendMsgService;
|
||||
import com.njcn.cssystem.pojo.po.CsFeedbackChatPO;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
|
||||
@@ -25,20 +25,24 @@ import com.njcn.csdevice.mapper.CsDataSetMapper;
|
||||
import com.njcn.csdevice.mapper.CsGroArrMapper;
|
||||
import com.njcn.csdevice.mapper.CsGroupMapper;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.dto.CsLineDTO;
|
||||
import com.njcn.csdevice.pojo.param.EnergyBaseParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsGroupVO;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupEventVO;
|
||||
import com.njcn.csdevice.pojo.vo.DataGroupTemplateVO;
|
||||
import com.njcn.csdevice.pojo.vo.EnergyTemplateVO;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsDataArrayService;
|
||||
import com.njcn.csdevice.service.ICsGroupService;
|
||||
import com.njcn.csdevice.service.ICsLedgerService;
|
||||
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
||||
import com.njcn.csdevice.utils.DataChangeUtil;
|
||||
import com.njcn.csharmonic.api.EventFeignClient;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.constant.HarmonicConstant;
|
||||
import com.njcn.csharmonic.param.*;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import com.njcn.csharmonic.pojo.vo.ThdDataTdVO;
|
||||
import com.njcn.csharmonic.pojo.vo.ThdDataVO;
|
||||
import com.njcn.device.biz.mapper.OverLimitWlMapper;
|
||||
@@ -49,7 +53,6 @@ import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import com.njcn.influx.service.EvtDataService;
|
||||
import com.njcn.system.api.*;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.po.EleEvtParm;
|
||||
import com.njcn.system.pojo.vo.CsStatisticalSetVO;
|
||||
@@ -65,11 +68,8 @@ import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.text.DecimalFormat;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZonedDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
import java.util.function.Function;
|
||||
@@ -112,6 +112,8 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
|
||||
private final String GRID_SIDE_DICT_CODE = "Grid_Side";
|
||||
private final String LOAD_SIDE_DICT_CODE = "Load_Side";
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -316,24 +318,28 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
|
||||
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
||||
}
|
||||
Double ct = finalCsLinePOList.get(0).getCtRatio();
|
||||
Double pt = finalCsLinePOList.get(0).getPtRatio();
|
||||
Double ct = finalCsLinePOList.get(0).getCtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getCt2Ratio())?1.0:finalCsLinePOList.get(0).getCt2Ratio());
|
||||
Double pt = finalCsLinePOList.get(0).getPtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getPt2Ratio())?1.0:finalCsLinePOList.get(0).getPt2Ratio());
|
||||
if(CollectionUtil.isNotEmpty(commonStatisticalQueryParam.getList())){
|
||||
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
|
||||
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(param.getStatisticalId())).getData();
|
||||
eleEpdPqds.forEach(epdPqd->{
|
||||
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(temp.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
|
||||
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
|
||||
} else {
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
|
||||
}
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
|
||||
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(commonStatisticalQueryParam.getStartTime(),DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
|
||||
commonQueryParam.setEndTime(DateUtil.format(DateUtil.endOfDay(DateUtil.parse(commonStatisticalQueryParam.getEndTime(),DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN));
|
||||
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType().toUpperCase());
|
||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
|
||||
return commonQueryParam;
|
||||
@@ -343,7 +349,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
String unit;
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
@@ -451,21 +457,6 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
vo.setAnotherName(epdPqd.getShowName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
//长时闪变
|
||||
if (Objects.equals(epdPqd.getOtherName(), "plt")) {
|
||||
List<Instant> timeInstants = getTimeInstants(commonStatisticalQueryParam.getStartTime(), commonStatisticalQueryParam.getEndTime(), 2, ChronoUnit.HOURS, DEFAULT_ZONE);
|
||||
collect1 = collect1.stream()
|
||||
.filter(vo -> timeInstants.contains(vo.getTime()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
//短时闪变 || 电压波动
|
||||
else if (Objects.equals(epdPqd.getOtherName(), "pst") || Objects.equals(epdPqd.getOtherName(), "fluc")) {
|
||||
List<Instant> timeInstants = getTimeInstants(commonStatisticalQueryParam.getStartTime(), commonStatisticalQueryParam.getEndTime(), 10, ChronoUnit.MINUTES, DEFAULT_ZONE);
|
||||
collect1 = collect1.stream()
|
||||
.filter(vo -> timeInstants.contains(vo.getTime()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
result.addAll(collect1);
|
||||
});
|
||||
}
|
||||
@@ -493,8 +484,13 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
commonQueryParam.setLineId(temp.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency);
|
||||
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ finalFrequency);
|
||||
} else {
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName()+ finalFrequency);
|
||||
}
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType() == null ? DataParam.portableDevStatisticalMethods:commonStatisticalQueryParam.getValueType());
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType() == null ? DataParam.portableDevStatisticalMethods.toUpperCase():commonStatisticalQueryParam.getValueType().toUpperCase());
|
||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
|
||||
return commonQueryParam;
|
||||
@@ -503,7 +499,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
@@ -526,9 +522,24 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
csEventUserQueryPage.setLineId(commonStatisticalQueryParam.getLineId());
|
||||
csEventUserQueryPage.setStartTime(commonStatisticalQueryParam.getStartTime());
|
||||
csEventUserQueryPage.setEndTime(commonStatisticalQueryParam.getEndTime());
|
||||
csEventUserQueryPage.setEvtParamTmMin(commonStatisticalQueryParam.getEvtParamTmMin());
|
||||
csEventUserQueryPage.setEvtParamTmMax(commonStatisticalQueryParam.getEvtParamTmMax());
|
||||
csEventUserQueryPage.setFeatureAmplitudeMin(commonStatisticalQueryParam.getFeatureAmplitudeMin());
|
||||
csEventUserQueryPage.setFeatureAmplitudeMax(commonStatisticalQueryParam.getFeatureAmplitudeMax());
|
||||
csEventUserQueryPage.setSeverityMin(commonStatisticalQueryParam.getSeverityMin());
|
||||
csEventUserQueryPage.setSeverityMax(commonStatisticalQueryParam.getSeverityMax());
|
||||
csEventUserQueryPage.setTarget(commonStatisticalQueryParam.getTarget());
|
||||
csEventUserQueryPage.setFileFlag(commonStatisticalQueryParam.getFileFlag());
|
||||
Page<DataGroupEventVO> csEventVOPage = eventFeignClient.pageQueryByLineId(csEventUserQueryPage).getData();
|
||||
|
||||
//获取监测点电压等级
|
||||
List<CsLineDTO> list = csLinePOService.getAllLineDetail();
|
||||
Map<String, CsLineDTO> map = list.stream().collect(Collectors.toMap(CsLineDTO::getLineId, temp -> temp));
|
||||
csEventVOPage.getRecords().forEach(temp->{
|
||||
//监测点电压等级
|
||||
Double volGrade = map.get(temp.getLineId()).getVolGrade();
|
||||
if (!Objects.isNull(volGrade)) {
|
||||
temp.setLineVoltage(volGrade);
|
||||
}
|
||||
//事件描述、相别、暂降幅值,需要特殊处理赋值
|
||||
//事件描述
|
||||
CsLedger dataById = iCsLedgerService.findDataById(temp.getLineId());
|
||||
@@ -579,24 +590,165 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
}
|
||||
});
|
||||
return csEventVOPage;
|
||||
} else if ("4".equals(type)) {
|
||||
formatQueryParamList(commonStatisticalQueryParam);
|
||||
List<ThdDataVO> result = new ArrayList<>();
|
||||
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Collections.singletonList(commonStatisticalQueryParam.getLineId())).getData();
|
||||
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId, finalCsLinePOList.get(0).getDataSetId()));
|
||||
if (Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())) {
|
||||
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
||||
}
|
||||
Double ct = finalCsLinePOList.get(0).getCtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getCt2Ratio()) ? 1.0 : finalCsLinePOList.get(0).getCt2Ratio());
|
||||
Double pt = finalCsLinePOList.get(0).getPtRatio() / (Objects.isNull(finalCsLinePOList.get(0).getPt2Ratio()) ? 1.0 : finalCsLinePOList.get(0).getPt2Ratio());
|
||||
if (CollectionUtil.isNotEmpty(commonStatisticalQueryParam.getList())) {
|
||||
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()) {
|
||||
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(param.getStatisticalId())).getData();
|
||||
eleEpdPqds.forEach(epdPqd -> {
|
||||
List<CommonQueryParam> commonQueryParams = finalCsLinePOList.stream().map(temp -> {
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(temp.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
|
||||
commonQueryParam.setColumnName(epdPqd.getName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
|
||||
} else {
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
|
||||
}
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
|
||||
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(commonStatisticalQueryParam.getStartTime(), DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
|
||||
commonQueryParam.setEndTime(DateUtil.format(DateUtil.endOfDay(DateUtil.parse(commonStatisticalQueryParam.getEndTime(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN));
|
||||
|
||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
|
||||
return commonQueryParam;
|
||||
}).collect(Collectors.toList());
|
||||
List<StatisticalDataDTO> deviceRtData;
|
||||
if (commonStatisticalQueryParam.getDataModel() == 0) {
|
||||
deviceRtData = commonService.getDeviceRtDataByTime(commonQueryParams);
|
||||
} else {
|
||||
deviceRtData = commonService.getDianDuData(commonQueryParams);
|
||||
}
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
String unit;
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(Objects.equals("T", temp.getPhaseType()) ? null : temp.getPhaseType());
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
vo.setStatMethod(temp.getValueType());
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
if (temp.getValue() != null) {
|
||||
double re = 0;
|
||||
if (Objects.equals("Primary", commonStatisticalQueryParam.getDataLevel())) {
|
||||
if (Objects.equals("Primary", csDataSet.getDataLevel())) {
|
||||
if (HarmonicConstant.POWER_LIST.contains(epdPqd.getShowName())) {
|
||||
re = Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue()));
|
||||
vo.setStatisticalData(re);
|
||||
unit = epdPqd.getUnit();
|
||||
} else {
|
||||
vo.setStatisticalData(Objects.isNull(temp.getValue()) ? 3.14159 : Double.parseDouble(df.format(temp.getValue())));
|
||||
unit = epdPqd.getUnit();
|
||||
}
|
||||
} else {
|
||||
if (Objects.nonNull(epdPqd.getPrimaryFormula())) {
|
||||
switch (epdPqd.getPrimaryFormula()) {
|
||||
case "*PT":
|
||||
re = temp.getValue() * pt;
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
case "*CT":
|
||||
re = temp.getValue() * ct;
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
case "*PT*CT":
|
||||
re = temp.getValue() * pt * ct;
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
default:
|
||||
re = temp.getValue();
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
}
|
||||
vo.setStatisticalData(Double.valueOf(df.format(re)));
|
||||
} else {
|
||||
re = temp.getValue();
|
||||
unit = epdPqd.getUnit();
|
||||
vo.setStatisticalData(Double.valueOf(df.format(re)));
|
||||
}
|
||||
|
||||
}
|
||||
} else {
|
||||
if (Objects.equals("Primary", csDataSet.getDataLevel())) {
|
||||
if (Objects.nonNull(epdPqd.getPrimaryFormula())) {
|
||||
switch (epdPqd.getPrimaryFormula()) {
|
||||
case "*PT":
|
||||
re = temp.getValue() / pt;
|
||||
break;
|
||||
case "*CT":
|
||||
re = temp.getValue() / ct;
|
||||
break;
|
||||
case "*PT*CT":
|
||||
re = temp.getValue() / pt / ct;
|
||||
break;
|
||||
default:
|
||||
re = temp.getValue();
|
||||
break;
|
||||
}
|
||||
vo.setStatisticalData(Double.valueOf(df.format(re)));
|
||||
} else {
|
||||
re = temp.getValue();
|
||||
vo.setStatisticalData(Double.valueOf(df.format(re)));
|
||||
}
|
||||
} else {
|
||||
vo.setStatisticalData(Double.valueOf(df.format(temp.getValue())));
|
||||
}
|
||||
unit = epdPqd.getUnit();
|
||||
}
|
||||
} else {
|
||||
vo.setStatisticalData(null);
|
||||
if (Objects.equals("Primary", commonStatisticalQueryParam.getDataLevel())) {
|
||||
if (Objects.equals("Primary", csDataSet.getDataLevel())) {
|
||||
unit = epdPqd.getUnit();
|
||||
} else {
|
||||
if (Objects.nonNull(epdPqd.getPrimaryFormula())) {
|
||||
switch (epdPqd.getPrimaryFormula()) {
|
||||
case "*PT":
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
case "*CT":
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
case "*PT*CT":
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
default:
|
||||
unit = epdPqd.getUnit();
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
unit = epdPqd.getUnit();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
unit = epdPqd.getUnit();
|
||||
}
|
||||
}
|
||||
vo.setUnit(unit);
|
||||
vo.setStatisticalIndex(epdPqd.getId());
|
||||
vo.setStatisticalName(epdPqd.getName());
|
||||
vo.setAnotherName(epdPqd.getShowName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
result.addAll(collect1);
|
||||
});
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static List<Instant> getTimeInstants(String startDateStr, String endDateStr, long interval, ChronoUnit unit, ZoneId zone) {
|
||||
List<Instant> instants = new ArrayList<>();
|
||||
LocalDate startDate = LocalDate.parse(startDateStr, DATE_FORMATTER);
|
||||
LocalDate endDate = LocalDate.parse(endDateStr, DATE_FORMATTER);
|
||||
// 转换为指定时区的 ZonedDateTime
|
||||
ZonedDateTime current = startDate.atStartOfDay(zone);
|
||||
ZonedDateTime endDateTime = endDate.atTime(23, 59, 59).atZone(zone);
|
||||
while (!current.isAfter(endDateTime)) {
|
||||
instants.add(current.toInstant());
|
||||
current = current.plus(interval, unit);
|
||||
}
|
||||
return instants;
|
||||
}
|
||||
|
||||
private void formatQueryParamList(CommonStatisticalQueryParam commonStatisticalQueryParam){
|
||||
List<CommonStatisticalQueryParam> list = new ArrayList<>();
|
||||
if(commonStatisticalQueryParam.getList() != null && commonStatisticalQueryParam.getList().size() > 0){
|
||||
@@ -659,7 +811,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
@@ -736,7 +888,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(commonStatisticalQueryParam.getLineId())).getData();
|
||||
if(commonStatisticalQueryParam.getList() != null && commonStatisticalQueryParam.getList().size() > 0){
|
||||
for (CommonStatisticalQueryParam param : commonStatisticalQueryParam.getList()){
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(param.getStatisticalId())).getData();
|
||||
ThdDataTdVO.ThdDataSpectrumVOData thdDataSpectrumVOData = new ThdDataTdVO.ThdDataSpectrumVOData();
|
||||
List<ThdDataVO> result = new ArrayList();
|
||||
eleEpdPqds.forEach(epdPqd->{
|
||||
@@ -759,7 +911,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
List<ThdDataVO> collect1 = deviceRtData.stream().map(temp -> {
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
@@ -838,23 +990,25 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())) {
|
||||
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
||||
}
|
||||
Double ct = finalCsLinePO.getCtRatio();
|
||||
Double pt = finalCsLinePO.getPtRatio();
|
||||
Double ct = finalCsLinePO.getCtRatio() / (Objects.isNull(finalCsLinePO.getCt2Ratio())?1.0:finalCsLinePO.getCt2Ratio());
|
||||
Double pt = finalCsLinePO.getPtRatio() / (Objects.isNull(finalCsLinePO.getPt2Ratio())?1.0:finalCsLinePO.getPt2Ratio());
|
||||
if(CollectionUtil.isNotEmpty(trendDataQueryParam.getList())) {
|
||||
for (TrendDataQueryParam param : trendDataQueryParam.getList()) {
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(param.getStatisticalId())).getData();
|
||||
for (EleEpdPqd epdPqd : eleEpdPqds) {
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(finalCsLinePO.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
commonQueryParam.setColumnName(epdPqd.getName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
|
||||
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
|
||||
} else {
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName()+ (StringUtils.isEmpty(param.getFrequency()) ? "":"_"+param.getFrequency()));
|
||||
}
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
|
||||
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(trendDataQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
|
||||
commonQueryParam.setEndTime(DateUtil.format(DateUtil.endOfDay(DateUtil.parse(trendDataQueryParam.getSearchEndTime(), DatePattern.NORM_DATE_PATTERN)), DatePattern.NORM_DATETIME_PATTERN));
|
||||
|
||||
commonQueryParam.setDataType(trendDataQueryParam.getValueType());
|
||||
|
||||
commonQueryParam.setDataType(trendDataQueryParam.getValueType().toUpperCase());
|
||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(finalCsLinePO.getLineId()));
|
||||
|
||||
List<StatisticalDataDTO> deviceRtData = commonService.getNewDeviceRtDataByTime(Collections.singletonList(commonQueryParam));
|
||||
@@ -862,7 +1016,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
String unit;
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(Objects.equals("M", temp.getPhaseType()) ? null : temp.getPhaseType());
|
||||
vo.setPhase(Objects.equals("T", temp.getPhaseType()) ? null : temp.getPhaseType());
|
||||
String position = finalCsLinePO.getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
@@ -970,21 +1124,6 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
vo.setAnotherName(epdPqd.getShowName());
|
||||
return vo;
|
||||
}).collect(Collectors.toList());
|
||||
|
||||
//长时闪变
|
||||
if (Objects.equals(epdPqd.getOtherName(), "plt")) {
|
||||
List<Instant> timeInstants = getTimeInstants(trendDataQueryParam.getSearchBeginTime(), trendDataQueryParam.getSearchEndTime(), 2, ChronoUnit.HOURS, DEFAULT_ZONE);
|
||||
collect1 = collect1.stream()
|
||||
.filter(vo -> timeInstants.contains(vo.getTime()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
//短时闪变 || 电压波动
|
||||
else if (Objects.equals(epdPqd.getOtherName(), "pst") || Objects.equals(epdPqd.getOtherName(), "fluc")) {
|
||||
List<Instant> timeInstants = getTimeInstants(trendDataQueryParam.getSearchBeginTime(), trendDataQueryParam.getSearchEndTime(), 10, ChronoUnit.MINUTES, DEFAULT_ZONE);
|
||||
collect1 = collect1.stream()
|
||||
.filter(vo -> timeInstants.contains(vo.getTime()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
result.addAll(collect1);
|
||||
}
|
||||
}
|
||||
@@ -1000,9 +1139,10 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
if(Objects.isNull(csDataSet) || StrUtil.isBlank(csDataSet.getDataLevel())){
|
||||
throw new BusinessException("当前测点数据集主要信息缺失,请联系管理员排查(测点表里面数据集id缺失)");
|
||||
}
|
||||
Double ct = finalCsLinePO.getCtRatio();
|
||||
Double pt = finalCsLinePO.getPtRatio();
|
||||
// String position = finalCsLinePO.getPosition();
|
||||
Double ct = finalCsLinePO.getCtRatio() / (Objects.isNull(finalCsLinePO.getCt2Ratio())?1.0:finalCsLinePO.getCt2Ratio());
|
||||
Double pt = finalCsLinePO.getPtRatio() / (Objects.isNull(finalCsLinePO.getPt2Ratio())?1.0:finalCsLinePO.getPt2Ratio());
|
||||
|
||||
// String position = finalCsLinePO.getPosition();
|
||||
Overlimit overlimit = overLimitWlMapper.selectById(finalCsLinePO.getLineId());
|
||||
if (Objects.isNull(overlimit)) {
|
||||
throw new BusinessException("当前测点限值信息缺失,请联系管理员排查");
|
||||
@@ -1011,13 +1151,13 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
if(CollectionUtil.isNotEmpty(fittingDataQueryParam.getList())) {
|
||||
for (FittingDataQueryParam param : fittingDataQueryParam.getList()) {
|
||||
String dictCode = dictTreeFeignClient.queryById(param.getStatisticalId()).getData().getCode();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(param.getStatisticalId())).getData();
|
||||
List<ThdDataVO> dataList = new ArrayList<>();
|
||||
for (EleEpdPqd epdPqd : eleEpdPqds) {
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(finalCsLinePO.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
commonQueryParam.setColumnName(epdPqd.getName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName() + (StringUtils.isEmpty(param.getFrequency()) ? "" : "_" + param.getFrequency()));
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
|
||||
commonQueryParam.setStartTime(DateUtil.format(DateUtil.parse(fittingDataQueryParam.getSearchBeginTime(), DatePattern.NORM_DATE_PATTERN), DatePattern.NORM_DATETIME_PATTERN));
|
||||
@@ -1026,7 +1166,9 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
String dataType = param.getValueType();
|
||||
if (StrUtil.isEmpty(dataType)) {
|
||||
// 电能质量指标,取限值计算类型,判断是否越限
|
||||
dataType = epdPqd.getFormula();
|
||||
dataType = epdPqd.getFormula().toUpperCase();
|
||||
} else {
|
||||
dataType = dataType.toUpperCase();
|
||||
}
|
||||
commonQueryParam.setDataType(dataType);
|
||||
|
||||
@@ -1038,7 +1180,7 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
// vo.setLineName(finalCsLinePO.getName());
|
||||
vo.setPhase(Objects.equals("M", temp.getPhaseType()) ? null : temp.getPhaseType());
|
||||
vo.setPhase(Objects.equals("T", temp.getPhaseType()) ? null : temp.getPhaseType());
|
||||
// vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
vo.setStatMethod(commonQueryParam.getDataType());
|
||||
@@ -1196,19 +1338,14 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
}
|
||||
result.put("before", new ArrayList<>());
|
||||
result.put("after", new ArrayList<>());
|
||||
String sensitiveUserId = param.getSensitiveUserId();
|
||||
List<CsLinePO> linePOList = csLineFeignClient.getLineBySensitiveUser(Collections.singletonList(sensitiveUserId)).getData();
|
||||
if (CollUtil.isEmpty(linePOList)) {
|
||||
PqGovernPlan plan = pqGovernPlanFeignClient.getById(param.getSensitiveUserId()).getData();
|
||||
if (Objects.isNull(plan)) {
|
||||
return result;
|
||||
}
|
||||
DictData loadSideDictData = dicDataFeignClient.getDicDataByCode(LOAD_SIDE_DICT_CODE).getData();
|
||||
DictData gridSideDictData = dicDataFeignClient.getDicDataByCode(GRID_SIDE_DICT_CODE).getData();
|
||||
CsLinePO gridSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(gridSideDictData.getId())).findFirst().orElse(null);
|
||||
CsLinePO loadSideLine = linePOList.stream().filter(linePO -> linePO.getPosition().equals(loadSideDictData.getId())).findFirst().orElse(null);
|
||||
TrendDataQueryParam trendDataQueryParam = new TrendDataQueryParam();
|
||||
trendDataQueryParam.setSearchBeginTime(param.getSearchBeginTime());
|
||||
trendDataQueryParam.setSearchEndTime(param.getSearchEndTime());
|
||||
trendDataQueryParam.setValueType(param.getValueType());
|
||||
trendDataQueryParam.setValueType(param.getValueType().toUpperCase());
|
||||
trendDataQueryParam.setDataLevel(param.getDataLevel());
|
||||
List<SensitiveUserTrendDataQueryParam> paramList = param.getList();
|
||||
List<TrendDataQueryParam> indexList = paramList.stream().map(item -> {
|
||||
@@ -1220,17 +1357,14 @@ public class CsGroupServiceImpl extends ServiceImpl<CsGroupMapper, CsGroup> impl
|
||||
return queryParam;
|
||||
}).collect(Collectors.toList());
|
||||
trendDataQueryParam.setList(indexList);
|
||||
if (loadSideLine != null) {
|
||||
trendDataQueryParam.setLineId(loadSideLine.getLineId());
|
||||
List<ThdDataVO> thdDataList = this.trendData(trendDataQueryParam);
|
||||
result.put("before", thdDataList);
|
||||
}
|
||||
if (gridSideLine != null) {
|
||||
trendDataQueryParam.setLineId(gridSideLine.getLineId());
|
||||
List<ThdDataVO> thdDataList = this.trendData(trendDataQueryParam);
|
||||
result.put("after", thdDataList);
|
||||
}
|
||||
|
||||
//治理前
|
||||
trendDataQueryParam.setLineId(plan.getGovernBefore());
|
||||
List<ThdDataVO> thdDataList1 = this.trendData(trendDataQueryParam);
|
||||
result.put("before", thdDataList1);
|
||||
//治理后
|
||||
trendDataQueryParam.setLineId(plan.getGovernAfter());
|
||||
List<ThdDataVO> thdDataList2 = this.trendData(trendDataQueryParam);
|
||||
result.put("after", thdDataList2);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -5,14 +5,11 @@ import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.api.CsMarketDataFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||
import com.njcn.csdevice.mapper.*;
|
||||
@@ -22,7 +19,9 @@ import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.CsLedgerVO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.AreaFeignClient;
|
||||
@@ -30,14 +29,12 @@ import com.njcn.system.api.DictTreeFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.Area;
|
||||
import com.njcn.system.pojo.vo.DictTreeVO;
|
||||
import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.user.pojo.constant.UserType;
|
||||
import com.njcn.user.pojo.vo.UserVO;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
@@ -67,8 +64,8 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
private final ICsDataSetService csDataSetService;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final ICsUserPinsService csUserPinsService;
|
||||
private final CsCommTerminalFeignClient csCommTerminalFeignClient;
|
||||
|
||||
@@ -165,27 +162,99 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CsLedgerVO> finalLineList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.peek(
|
||||
item -> {
|
||||
item.setType("line");
|
||||
String index = item.getId().substring(item.getId().length() - 1);
|
||||
if (Objects.equals(index, "0")) {
|
||||
item.setLineType(0);
|
||||
} else {
|
||||
item.setLineType(1);
|
||||
}
|
||||
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsLinePO::getLineId, item.getId()).eq(CsLinePO::getStatus, 1);
|
||||
CsLinePO po = csLinePOService.getOne(queryWrapper);
|
||||
item.setConType(po.getConType());
|
||||
}
|
||||
)
|
||||
//获取治理方案
|
||||
List<PqGovernPlan> governPlan = pqGovernPlanFeignClient.getListExcludeNull().getData();
|
||||
Map<String, PqGovernPlan> beforeMap = Optional.ofNullable(governPlan)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.filter(p -> p.getGovernBefore() != null)
|
||||
.collect(Collectors.toMap(
|
||||
PqGovernPlan::getGovernBefore,
|
||||
Function.identity(),
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
Map<String, PqGovernPlan> afterMap = Optional.ofNullable(governPlan)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.filter(p -> p.getGovernAfter() != null)
|
||||
.collect(Collectors.toMap(
|
||||
PqGovernPlan::getGovernAfter,
|
||||
Function.identity(),
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
//获取治理用户
|
||||
// 1. governPlan 防 null + 过滤掉 pid 为 null 的数据
|
||||
List<String> sensitiveUser = Optional.ofNullable(governPlan)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.map(PqGovernPlan::getPid)
|
||||
.filter(Objects::nonNull)
|
||||
.distinct()
|
||||
.collect(Collectors.toList());
|
||||
|
||||
// 2. 没有 id 就不调用远程接口,直接返回空 Map
|
||||
Map<String, PqSensitiveUser> sensitiveUserMap;
|
||||
if (CollectionUtils.isEmpty(sensitiveUser)) {
|
||||
sensitiveUserMap = Collections.emptyMap();
|
||||
} else {
|
||||
List<PqSensitiveUser> sensitiveUserList = pqSensitiveUserFeignClient
|
||||
.getListByIds(sensitiveUser)
|
||||
.getData();
|
||||
// 3. sensitiveUserList 防 null
|
||||
sensitiveUserMap = Optional.ofNullable(sensitiveUserList)
|
||||
.orElse(Collections.emptyList())
|
||||
.stream()
|
||||
.filter(u -> u != null && u.getId() != null)
|
||||
.collect(Collectors.toMap(
|
||||
PqSensitiveUser::getId,
|
||||
Function.identity(),
|
||||
(v1, v2) -> v1
|
||||
));
|
||||
}
|
||||
List<CsLedgerVO> finalLineList;
|
||||
//获取监测点数据
|
||||
Integer targetLevel = LineBaseEnum.LINE_LEVEL.getCode();
|
||||
List<String> lineIds = allList.stream()
|
||||
.filter(item -> item != null && targetLevel.equals(item.getLevel()))
|
||||
.map(CsLedgerVO::getId)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(lineIds)) {
|
||||
List<CsLinePO> poList = csLinePOService.listByIds(lineIds);
|
||||
Map<String, CsLinePO> lineMap = poList.stream().collect(Collectors.toMap(CsLinePO::getLineId,Function.identity(),(v1, v2) -> v1));
|
||||
finalLineList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(targetLevel))
|
||||
.peek(
|
||||
item -> {
|
||||
PqGovernPlan beforePlan = beforeMap.get(item.getId());
|
||||
PqGovernPlan afterPlan = afterMap.get(item.getId());
|
||||
if (beforePlan != null) {
|
||||
PqSensitiveUser user = sensitiveUserMap.get(beforePlan.getPid());
|
||||
item.setSensitiveUserId(beforePlan.getPid());
|
||||
item.setSensitiveUserName(Objects.isNull(user) ? null : user.getName());
|
||||
item.setGovernPlanName(beforePlan.getGovernName());
|
||||
}
|
||||
if (afterPlan != null) {
|
||||
PqSensitiveUser user = sensitiveUserMap.get(afterPlan.getPid());
|
||||
item.setSensitiveUserId(afterPlan.getPid());
|
||||
item.setSensitiveUserName(Objects.isNull(user) ? null : user.getName());
|
||||
item.setGovernPlanName(afterPlan.getGovernName());
|
||||
}
|
||||
item.setType("line");
|
||||
CsLinePO po = lineMap.get(item.getId());
|
||||
item.setConType(po.getConType());
|
||||
if (Objects.isNull(po.getClDid())) {
|
||||
item.setSort(po.getLineNo());
|
||||
} else {
|
||||
item.setSort(po.getClDid());
|
||||
}
|
||||
item.setLineType(Objects.equals(po.getClDid(), 0) ? 0 : 1);
|
||||
}
|
||||
)
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort, Comparator.nullsLast(Comparator.naturalOrder())))
|
||||
.collect(Collectors.toList());
|
||||
} else {
|
||||
finalLineList = allList;
|
||||
}
|
||||
checkDevSetData(deviceList);
|
||||
List<CsLedgerVO> engineeringList1 = new ArrayList<>();
|
||||
List<CsLedgerVO> projectList1 = new ArrayList<>();
|
||||
@@ -470,7 +539,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
}
|
||||
});
|
||||
|
||||
return new ArrayList<>(projectMap.values());
|
||||
List<CsLedgerVO> result = new ArrayList<>(projectMap.values());
|
||||
result.sort(Comparator.comparing(CsLedgerVO::getSort, Comparator.nullsLast(Comparator.naturalOrder())));
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -846,6 +917,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
device.setEquipmentName(dev.getName());
|
||||
device.setEquipmentId(devId);
|
||||
device.setDevMac(po.getMac());
|
||||
device.setNDid(po.getNdid());
|
||||
device.setProjectId("/");
|
||||
device.setProjectName("/");
|
||||
device.setEngineeringid("/");
|
||||
@@ -854,6 +926,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
device.setEquipmentName(dev.getName());
|
||||
device.setEquipmentId(devId);
|
||||
device.setDevMac(po.getMac());
|
||||
device.setNDid(po.getNdid());
|
||||
CsLedger project = this.findDataById(dev.getPid());
|
||||
if (ObjectUtil.isNotNull(project)) {
|
||||
device.setProjectId(project.getId());
|
||||
@@ -1056,88 +1129,88 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<CsLedgerVO> objTree() {
|
||||
List<CsLedgerVO> result = new ArrayList<>();
|
||||
String userId = RequestUtil.getUserIndex();
|
||||
UserVO userVO = userFeignClient.getUserById(userId).getData();
|
||||
List<String> devIds;
|
||||
if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) {
|
||||
devIds = csEquipmentDeliveryMapper.selectList(null).stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
|
||||
} else {
|
||||
LambdaQueryWrapper<CsDeviceUserPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.select(CsDeviceUserPO::getDeviceId)
|
||||
.and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId))
|
||||
.eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode());
|
||||
List<CsDeviceUserPO> devList = csDeviceUserPOMapper.selectList(lambdaQueryWrapper);
|
||||
devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
}
|
||||
if (CollUtil.isEmpty(devIds)) {
|
||||
return result;
|
||||
}
|
||||
List<CsLinePO> poList = csLinePOService.lambdaQuery().in(CsLinePO::getDeviceId, devIds)
|
||||
.eq(CsLinePO::getStatus, DataStateEnum.ENABLE.getCode()).ne(CsLinePO::getMonitorUser,"").isNotNull(CsLinePO::getMonitorUser).list();
|
||||
if (CollUtil.isEmpty(poList)) {
|
||||
return result;
|
||||
}
|
||||
List<String> objIds = poList.stream().map(CsLinePO::getMonitorUser).distinct().collect(Collectors.toList());
|
||||
List<String> lineIds = poList.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
||||
|
||||
List<PqSensitiveUser> pqSensitiveUserList = pqSensitiveUserFeignClient.getListByIds(objIds).getData();
|
||||
if (CollUtil.isEmpty(pqSensitiveUserList)) {
|
||||
return result;
|
||||
}
|
||||
Map<String,String> objMap = pqSensitiveUserList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, PqSensitiveUser::getName));
|
||||
|
||||
List<CsLedger> csLineList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, lineIds));
|
||||
Map<String,List<String>> lineMap = csLineList.stream().collect(Collectors.groupingBy(it->it.getPids().split(StrUtil.COMMA)[LineBaseEnum.PROJECT_LEVEL.getCode()+1],Collectors.mapping(CsLedger::getId,Collectors.toList())));
|
||||
|
||||
List<String> projectIds = csLineList.stream().map(it -> it.getPids().split(StrUtil.COMMA)[LineBaseEnum.PROJECT_LEVEL.getCode()+1]).distinct().collect(Collectors.toList());
|
||||
List<CsLedger> projectList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, projectIds));
|
||||
|
||||
List<CsLedgerVO> realProjectList = new ArrayList<>();
|
||||
projectList.forEach(pro->{
|
||||
CsLedgerVO csLedgerVO = new CsLedgerVO();
|
||||
csLedgerVO.setId(pro.getId());
|
||||
csLedgerVO.setPid(pro.getPid());
|
||||
csLedgerVO.setLevel(pro.getLevel());
|
||||
csLedgerVO.setName(pro.getName());
|
||||
|
||||
List<CsLedgerVO> temObjList = new ArrayList<>();
|
||||
if(lineMap.containsKey(pro.getId())){
|
||||
List<String> ids = lineMap.get(pro.getId());
|
||||
List<String> objTemIds = poList.stream().filter(it->ids.contains(it.getLineId())).map(CsLinePO::getMonitorUser).distinct().collect(Collectors.toList());
|
||||
if(CollUtil.isNotEmpty(objTemIds)){
|
||||
objTemIds.forEach(it->{
|
||||
CsLedgerVO inner = new CsLedgerVO();
|
||||
inner.setName(objMap.getOrDefault(it,"未知异常用户"));
|
||||
inner.setId(it);
|
||||
inner.setLevel(2);
|
||||
temObjList.add(inner);
|
||||
});
|
||||
}
|
||||
}
|
||||
csLedgerVO.setChildren(temObjList);
|
||||
realProjectList.add(csLedgerVO);
|
||||
});
|
||||
|
||||
List<String> gcIds = projectList.stream().map(CsLedger::getPid).collect(Collectors.toList());
|
||||
List<CsLedger> gcList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, gcIds));
|
||||
|
||||
List<CsLedgerVO> realGcList = new ArrayList<>();
|
||||
gcList.forEach(gc->{
|
||||
CsLedgerVO csLedgerVO = new CsLedgerVO();
|
||||
csLedgerVO.setId(gc.getId());
|
||||
csLedgerVO.setPid(gc.getPid());
|
||||
csLedgerVO.setLevel(gc.getLevel());
|
||||
csLedgerVO.setName(gc.getName());
|
||||
|
||||
List<CsLedgerVO> proList = realProjectList.stream().filter(it->gc.getId().equals(it.getPid())).collect(Collectors.toList());
|
||||
csLedgerVO.setChildren(proList);
|
||||
realGcList.add(csLedgerVO);
|
||||
});
|
||||
return realGcList;
|
||||
}
|
||||
// @Override
|
||||
// public List<CsLedgerVO> objTree() {
|
||||
// List<CsLedgerVO> result = new ArrayList<>();
|
||||
// String userId = RequestUtil.getUserIndex();
|
||||
// UserVO userVO = userFeignClient.getUserById(userId).getData();
|
||||
// List<String> devIds;
|
||||
// if (userVO.getType().equals(UserType.SUPER_ADMINISTRATOR) || userVO.getType().equals(UserType.ADMINISTRATOR)) {
|
||||
// devIds = csEquipmentDeliveryMapper.selectList(null).stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
|
||||
// } else {
|
||||
// LambdaQueryWrapper<CsDeviceUserPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
// lambdaQueryWrapper.select(CsDeviceUserPO::getDeviceId)
|
||||
// .and(w -> w.eq(CsDeviceUserPO::getPrimaryUserId, userId).or().eq(CsDeviceUserPO::getSubUserId, userId))
|
||||
// .eq(CsDeviceUserPO::getStatus, DataStateEnum.ENABLE.getCode());
|
||||
// List<CsDeviceUserPO> devList = csDeviceUserPOMapper.selectList(lambdaQueryWrapper);
|
||||
// devIds = devList.stream().map(CsDeviceUserPO::getDeviceId).distinct().collect(Collectors.toList());
|
||||
// }
|
||||
// if (CollUtil.isEmpty(devIds)) {
|
||||
// return result;
|
||||
// }
|
||||
// List<CsLinePO> poList = csLinePOService.lambdaQuery().in(CsLinePO::getDeviceId, devIds)
|
||||
// .eq(CsLinePO::getStatus, DataStateEnum.ENABLE.getCode()).ne(CsLinePO::getMonitorUser,"").isNotNull(CsLinePO::getMonitorUser).list();
|
||||
// if (CollUtil.isEmpty(poList)) {
|
||||
// return result;
|
||||
// }
|
||||
// List<String> objIds = poList.stream().map(CsLinePO::getMonitorUser).distinct().collect(Collectors.toList());
|
||||
// List<String> lineIds = poList.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
||||
//
|
||||
// List<PqSensitiveUser> pqSensitiveUserList = pqSensitiveUserFeignClient.getListByIds(objIds).getData();
|
||||
// if (CollUtil.isEmpty(pqSensitiveUserList)) {
|
||||
// return result;
|
||||
// }
|
||||
// Map<String,String> objMap = pqSensitiveUserList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, PqSensitiveUser::getName));
|
||||
//
|
||||
// List<CsLedger> csLineList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, lineIds));
|
||||
// Map<String,List<String>> lineMap = csLineList.stream().collect(Collectors.groupingBy(it->it.getPids().split(StrUtil.COMMA)[LineBaseEnum.PROJECT_LEVEL.getCode()+1],Collectors.mapping(CsLedger::getId,Collectors.toList())));
|
||||
//
|
||||
// List<String> projectIds = csLineList.stream().map(it -> it.getPids().split(StrUtil.COMMA)[LineBaseEnum.PROJECT_LEVEL.getCode()+1]).distinct().collect(Collectors.toList());
|
||||
// List<CsLedger> projectList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, projectIds));
|
||||
//
|
||||
// List<CsLedgerVO> realProjectList = new ArrayList<>();
|
||||
// projectList.forEach(pro->{
|
||||
// CsLedgerVO csLedgerVO = new CsLedgerVO();
|
||||
// csLedgerVO.setId(pro.getId());
|
||||
// csLedgerVO.setPid(pro.getPid());
|
||||
// csLedgerVO.setLevel(pro.getLevel());
|
||||
// csLedgerVO.setName(pro.getName());
|
||||
//
|
||||
// List<CsLedgerVO> temObjList = new ArrayList<>();
|
||||
// if(lineMap.containsKey(pro.getId())){
|
||||
// List<String> ids = lineMap.get(pro.getId());
|
||||
// List<String> objTemIds = poList.stream().filter(it->ids.contains(it.getLineId())).map(CsLinePO::getMonitorUser).distinct().collect(Collectors.toList());
|
||||
// if(CollUtil.isNotEmpty(objTemIds)){
|
||||
// objTemIds.forEach(it->{
|
||||
// CsLedgerVO inner = new CsLedgerVO();
|
||||
// inner.setName(objMap.getOrDefault(it,"未知异常用户"));
|
||||
// inner.setId(it);
|
||||
// inner.setLevel(2);
|
||||
// temObjList.add(inner);
|
||||
// });
|
||||
// }
|
||||
// }
|
||||
// csLedgerVO.setChildren(temObjList);
|
||||
// realProjectList.add(csLedgerVO);
|
||||
// });
|
||||
//
|
||||
// List<String> gcIds = projectList.stream().map(CsLedger::getPid).collect(Collectors.toList());
|
||||
// List<CsLedger> gcList = this.baseMapper.selectList(new LambdaQueryWrapper<CsLedger>().in(CsLedger::getId, gcIds));
|
||||
//
|
||||
// List<CsLedgerVO> realGcList = new ArrayList<>();
|
||||
// gcList.forEach(gc->{
|
||||
// CsLedgerVO csLedgerVO = new CsLedgerVO();
|
||||
// csLedgerVO.setId(gc.getId());
|
||||
// csLedgerVO.setPid(gc.getPid());
|
||||
// csLedgerVO.setLevel(gc.getLevel());
|
||||
// csLedgerVO.setName(gc.getName());
|
||||
//
|
||||
// List<CsLedgerVO> proList = realProjectList.stream().filter(it->gc.getId().equals(it.getPid())).collect(Collectors.toList());
|
||||
// csLedgerVO.setChildren(proList);
|
||||
// realGcList.add(csLedgerVO);
|
||||
// });
|
||||
// return realGcList;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<CsLedgerVO> getProAndEngineer(List<String> id) {
|
||||
@@ -1169,60 +1242,33 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
public CsLedgerVO cldTree() {
|
||||
List<CsLedgerVO> allList = this.baseMapper.getAll();
|
||||
if (CollectionUtil.isEmpty(allList)) {
|
||||
CsLedgerVO government = new CsLedgerVO();
|
||||
government.setLevel(-1);
|
||||
government.setName("台账树");
|
||||
government.setPid("0");
|
||||
government.setId(IdUtil.simpleUUID());
|
||||
government.setChildren(new ArrayList<>());
|
||||
return government;
|
||||
return buildTreeRootNode(new ArrayList<>());
|
||||
}
|
||||
|
||||
List<CsLedgerVO> engineeringList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.ENGINEERING_LEVEL.getCode()))
|
||||
Map<Integer, List<CsLedgerVO>> levelMap = allList.stream()
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getLevel));
|
||||
|
||||
List<CsLedgerVO> projectList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.PROJECT_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CsLedgerVO> deviceList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.DEVICE_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
List<CsLedgerVO> lineList = allList.stream()
|
||||
.filter(item -> item.getLevel().equals(LineBaseEnum.LINE_LEVEL.getCode()))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
List<CsLedgerVO> engineeringList = levelMap.getOrDefault(LineBaseEnum.ENGINEERING_LEVEL.getCode(), new ArrayList<>());
|
||||
List<CsLedgerVO> projectList = levelMap.getOrDefault(LineBaseEnum.PROJECT_LEVEL.getCode(), new ArrayList<>());
|
||||
List<CsLedgerVO> deviceList = levelMap.getOrDefault(LineBaseEnum.DEVICE_LEVEL.getCode(), new ArrayList<>());
|
||||
List<CsLedgerVO> lineList = levelMap.getOrDefault(LineBaseEnum.LINE_LEVEL.getCode(), new ArrayList<>());
|
||||
|
||||
if (CollectionUtil.isEmpty(deviceList)) {
|
||||
CsLedgerVO government = new CsLedgerVO();
|
||||
government.setLevel(-1);
|
||||
government.setName("台账树");
|
||||
government.setPid("0");
|
||||
government.setId(IdUtil.simpleUUID());
|
||||
government.setChildren(engineeringList);
|
||||
return government;
|
||||
Map<String, List<CsLedgerVO>> projectByPidMap = projectList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
engineeringList.forEach(eng -> eng.setChildren(projectByPidMap.getOrDefault(eng.getId(), new ArrayList<>())));
|
||||
return buildTreeRootNode(engineeringList);
|
||||
}
|
||||
|
||||
// 批量查询设备交付信息
|
||||
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()
|
||||
.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));
|
||||
Map<String, CsEquipmentDeliveryPO> devsMap = devs.stream()
|
||||
.collect(Collectors.toMap(CsEquipmentDeliveryPO::getId, Function.identity()));
|
||||
Set<String> cldDevIds = devs.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toSet());
|
||||
|
||||
// 填充设备状态信息
|
||||
deviceList.forEach(device -> {
|
||||
CsEquipmentDeliveryPO dev = devsMap.get(device.getId());
|
||||
if (dev != null) {
|
||||
@@ -1231,6 +1277,9 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
}
|
||||
});
|
||||
|
||||
// 填充监测点状态信息
|
||||
Map<String, String> lineDevMap = lineList.stream()
|
||||
.collect(Collectors.toMap(CsLedgerVO::getId, CsLedgerVO::getPid));
|
||||
lineList.forEach(line -> {
|
||||
String devId = lineDevMap.get(line.getId());
|
||||
if (devId != null) {
|
||||
@@ -1241,39 +1290,48 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
}
|
||||
});
|
||||
|
||||
engineeringList.forEach(engineering -> {
|
||||
List<CsLedgerVO> sortedProjects = projectList.stream()
|
||||
.filter(project -> project.getPid().equals(engineering.getId()))
|
||||
.peek(project -> {
|
||||
List<CsLedgerVO> projectDevices = projectToDeviceMap.getOrDefault(project.getId(), new ArrayList<>());
|
||||
if (CollectionUtil.isNotEmpty(projectDevices)) {
|
||||
List<CsLedgerVO> sortedDevices = projectDevices.stream()
|
||||
.filter(device -> cldDevIds.contains(device.getId()))
|
||||
.peek(device -> {
|
||||
List<CsLedgerVO> sortedLines = deviceToLineMap.getOrDefault(device.getId(), new ArrayList<>())
|
||||
.stream()
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
device.setChildren(sortedLines);
|
||||
})
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
project.setChildren(sortedDevices);
|
||||
}
|
||||
})
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
.collect(Collectors.toList());
|
||||
engineering.setChildren(sortedProjects);
|
||||
// 预构建pid映射
|
||||
Map<String, List<CsLedgerVO>> projectByEngineeringMap = projectList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
Map<String, List<CsLedgerVO>> deviceByProjectMap = deviceList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
Map<String, List<CsLedgerVO>> lineByDeviceMap = lineList.stream()
|
||||
.collect(Collectors.groupingBy(CsLedgerVO::getPid));
|
||||
|
||||
// 逐层构建树:设备 -> 监测点
|
||||
deviceList.forEach(device -> {
|
||||
if (cldDevIds.contains(device.getId())) {
|
||||
device.setChildren(lineByDeviceMap.getOrDefault(device.getId(), new ArrayList<>()));
|
||||
}
|
||||
});
|
||||
|
||||
CsLedgerVO government = new CsLedgerVO();
|
||||
government.setLevel(-1);
|
||||
government.setName("台账树");
|
||||
government.setPid("0");
|
||||
government.setId(IdUtil.simpleUUID());
|
||||
government.setChildren(engineeringList);
|
||||
// 项目 -> 设备(仅包含有交付记录的设备)
|
||||
projectList.forEach(project -> {
|
||||
List<CsLedgerVO> projectDevices = deviceByProjectMap.getOrDefault(project.getId(), new ArrayList<>());
|
||||
if (CollectionUtil.isNotEmpty(projectDevices)) {
|
||||
List<CsLedgerVO> validDevices = projectDevices.stream()
|
||||
.filter(device -> cldDevIds.contains(device.getId()))
|
||||
.collect(Collectors.toList());
|
||||
project.setChildren(validDevices);
|
||||
}
|
||||
});
|
||||
|
||||
return government;
|
||||
// 工程 -> 项目
|
||||
engineeringList.forEach(eng ->
|
||||
eng.setChildren(projectByEngineeringMap.getOrDefault(eng.getId(), new ArrayList<>()))
|
||||
);
|
||||
|
||||
return buildTreeRootNode(engineeringList);
|
||||
}
|
||||
|
||||
private CsLedgerVO buildTreeRootNode(List<CsLedgerVO> children) {
|
||||
CsLedgerVO root = new CsLedgerVO();
|
||||
root.setLevel(-1);
|
||||
root.setName("台账树");
|
||||
root.setPid("0");
|
||||
root.setId(IdUtil.simpleUUID());
|
||||
root.setChildren(children);
|
||||
return root;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -1423,6 +1481,13 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsLedger> queryByPid(String pid) {
|
||||
return this.list(new LambdaQueryWrapper<CsLedger>()
|
||||
.eq(CsLedger::getPid, pid)
|
||||
.eq(CsLedger::getState, 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取子节点
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.csdevice.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -11,12 +12,15 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.access.api.CsLineLatestDataFeignClient;
|
||||
import com.njcn.access.pojo.po.CsLineLatestData;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.PubUtils;
|
||||
import com.njcn.csdevice.api.CsCommTerminalFeignClient;
|
||||
import com.njcn.csdevice.enums.LineBaseEnum;
|
||||
import com.njcn.csdevice.mapper.*;
|
||||
import com.njcn.csdevice.pojo.dto.CsLineDTO;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.param.CsLineParam;
|
||||
import com.njcn.csdevice.pojo.po.*;
|
||||
import com.njcn.csdevice.pojo.vo.LineDetailDataVO;
|
||||
@@ -24,7 +28,14 @@ import com.njcn.csdevice.pojo.vo.PqSensitiveUserLineVO;
|
||||
import com.njcn.csdevice.service.CsDevModelService;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.ICsDataSetService;
|
||||
import com.njcn.csdevice.service.ICsDeviceRegistryService;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanFeignClient;
|
||||
import com.njcn.csharmonic.api.CsHarmonicPlanLineFeignClient;
|
||||
import com.njcn.csharmonic.api.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.api.PqSensitiveUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import com.njcn.device.biz.pojo.po.PqSensitiveUser;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
@@ -44,6 +55,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@@ -64,15 +76,18 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
private final ICsDataSetService csDataSetService;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
private final CsTerminalLogsMapper csTerminalLogsMapper;
|
||||
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
|
||||
private final PqSensitiveUserFeignClient pqSensitiveUserFeignClient;
|
||||
|
||||
private final PqGovernPlanFeignClient pqGovernPlanFeignClient;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final UserFeignClient userFeignClient;
|
||||
private final CsEquipmentDeliveryMapper csEquipmentDeliveryMapper;
|
||||
private final CsDeviceUserPOMapper csDeviceUserPOMapper;
|
||||
private final DictTreeFeignClient dictTreeFeignClient;
|
||||
|
||||
private final CsHarmonicPlanFeignClient csHarmonicPlanFeignClient;
|
||||
private final CsHarmonicPlanLineFeignClient csHarmonicPlanLineFeignClient;
|
||||
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
|
||||
private final CsCommTerminalFeignClient csCommTerminal;
|
||||
private final ICsDeviceRegistryService csDeviceRegistryService;
|
||||
|
||||
@Override
|
||||
public List<CsLinePO> getLineByDev(List<String> list) {
|
||||
@@ -138,13 +153,24 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public CsLinePO addCldLine(CsLineParam param) {
|
||||
String lineId = param.getDevMac().replace(":","") + param.getLineNo();
|
||||
String lineId = IdUtil.fastSimpleUUID();
|
||||
String nDid = param.getDevMac().replace(":", "");
|
||||
List<CsDeviceRegistry> data = csDeviceRegistryService.queryByCurrentNdid(nDid);
|
||||
Map<Integer, String> clDidToIdMap;
|
||||
if (CollUtil.isNotEmpty(data)) {
|
||||
clDidToIdMap = data.stream().collect(Collectors.toMap(CsDeviceRegistry::getClDid, CsDeviceRegistry::getId, (a, b) -> a));
|
||||
} else {
|
||||
clDidToIdMap = new HashMap<>();
|
||||
}
|
||||
if (!Objects.isNull(clDidToIdMap.get(param.getLineNo()))) {
|
||||
lineId = clDidToIdMap.get(param.getLineNo());
|
||||
}
|
||||
CsLinePO po = new CsLinePO();
|
||||
//1.新增监测点信息
|
||||
BeanUtils.copyProperties(param,po);
|
||||
po.setStatus(1);
|
||||
po.setRunStatus(param.getRunStatus());
|
||||
po.setLineId(param.getDevMac().replace(":","") + param.getLineNo());
|
||||
po.setLineId(lineId);
|
||||
//模板id
|
||||
CsDevModelPO po1 = csDevModelService.getCldModel();
|
||||
po.setDataModelId(po1.getId());
|
||||
@@ -157,10 +183,8 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
}
|
||||
po.setClDid(param.getLineNo());
|
||||
//监测位置
|
||||
//DictData data = dicDataFeignClient.getDicDataByCode(DicDataEnum.GRID_SIDE.getCode()).getData();
|
||||
po.setPosition(param.getPosition().isEmpty()?null:param.getPosition());
|
||||
this.save(po);
|
||||
|
||||
//2.新增台账树信息
|
||||
CsLedger csLedger = new CsLedger();
|
||||
csLedger.setId(lineId);
|
||||
@@ -171,6 +195,26 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
csLedger.setState(1);
|
||||
csLedger.setSort(0);
|
||||
csLedgerMapper.insert(csLedger);
|
||||
//3.新增稳态事件指标配置
|
||||
csHarmonicPlanLineFeignClient.deleteByLineIds(Collections.singletonList(lineId));
|
||||
List<CsHarmonicPlan> planList = csHarmonicPlanFeignClient.getByName("通用方案").getData();
|
||||
if (CollectionUtil.isNotEmpty(planList)) {
|
||||
CsHarmonicPlan plan = planList.get(0);
|
||||
CsHarmonicPlanLineParam param1 = new CsHarmonicPlanLineParam();
|
||||
param1.setId(plan.getId());
|
||||
param1.setLineIds(Collections.singletonList(lineId));
|
||||
csHarmonicPlanLineFeignClient.savePlanLines(param1);
|
||||
}
|
||||
//4.新增装置注册表数据
|
||||
if (Objects.isNull(clDidToIdMap.get(param.getLineNo()))) {
|
||||
CsDeviceRegistry registry = new CsDeviceRegistry();
|
||||
registry.setId(lineId);
|
||||
registry.setCurrentNdid(nDid);
|
||||
registry.setOldNdid(nDid);
|
||||
registry.setClDid(param.getLineNo());
|
||||
registry.setFirstSeenTime(LocalDateTime.now());
|
||||
csDeviceRegistryService.add(Collections.singletonList(registry));
|
||||
}
|
||||
return po;
|
||||
}
|
||||
|
||||
@@ -205,9 +249,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
.set(CsLinePO::getShortCircuitCapacity,param.getShortCircuitCapacity())
|
||||
.set(CsLinePO::getMonitorObj,param.getMonitorObj())
|
||||
.set(CsLinePO::getMonitorObj,param.getMonitorObj())
|
||||
.set(CsLinePO::getGovern,param.getGovern())
|
||||
.set(CsLinePO::getPosition,param.getPosition())
|
||||
.set(CsLinePO::getMonitorUser,param.getMonitorUser())
|
||||
.set(CsLinePO::getLineLogLevel,param.getLineLogLevel())
|
||||
.set(CsLinePO::getIsImportant,param.getIsImportant());
|
||||
this.update(lambdaUpdateWrapper);
|
||||
@@ -219,28 +261,38 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
csLedger.setName(param.getName());
|
||||
csLedgerMapper.updateById(csLedger);
|
||||
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(param.getDevId());
|
||||
csTerminalLogs.setOperateType(1);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
//新增台账日志 1056协议记录,其他协议不记录
|
||||
String devId = param.getDevId();
|
||||
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectById(devId);
|
||||
if (Objects.equals(po.getDevAccessMethod(), "CLD")) {
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(devId);
|
||||
csTerminalLogs.setOperateType(1);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void deleteCldLine(String id) {
|
||||
CsLinePO po = this.getById(id);
|
||||
|
||||
this.removeById(id);
|
||||
csLedgerMapper.deleteById(id);
|
||||
|
||||
//新增台账日志
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(po.getDeviceId());
|
||||
csTerminalLogs.setOperateType(1);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
//删除稳态事件指标配置
|
||||
csHarmonicPlanLineFeignClient.deleteByLineIds(Collections.singletonList(id));
|
||||
//删除装置注册表数据
|
||||
csDeviceRegistryService.delete(id);
|
||||
//新增台账日志 1056协议记录,其他协议不记录
|
||||
String devId = po.getDeviceId();
|
||||
CsEquipmentDeliveryPO devPo = csEquipmentDeliveryMapper.selectById(devId);
|
||||
if (Objects.equals(devPo.getDevAccessMethod(), "CLD")) {
|
||||
CsTerminalLogs csTerminalLogs = new CsTerminalLogs();
|
||||
csTerminalLogs.setDeviceId(devId);
|
||||
csTerminalLogs.setOperateType(1);
|
||||
csTerminalLogs.setIsPush(0);
|
||||
csTerminalLogsMapper.insert(csTerminalLogs);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -305,11 +357,12 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CsLinePO> getLineBySensitiveUser(List<String> list) {
|
||||
return this.lambdaQuery()
|
||||
.in(CsLinePO::getMonitorUser,list)
|
||||
.eq(CsLinePO::getStatus, 1)
|
||||
.list();
|
||||
public List<CsEquipmentDeliveryPO> getDevBySensitiveUser(List<String> list) {
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper
|
||||
// .in(CsEquipmentDeliveryPO::getMonitorUser,list)
|
||||
.ne(CsEquipmentDeliveryPO::getRunStatus, DataStateEnum.DELETED.getCode());
|
||||
return csEquipmentDeliveryMapper.selectList(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -322,10 +375,7 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
List<CsLinePO> poList = getSimpleLine();
|
||||
// 构建基础查询条件
|
||||
LambdaQueryWrapper<CsLinePO> lambdaQueryWrapper = new LambdaQueryWrapper<CsLinePO>()
|
||||
.eq(CsLinePO::getStatus, 1)
|
||||
// 关联敏感用户
|
||||
//.isNotNull(CsLinePO::getMonitorUser)
|
||||
.orderByAsc(CsLinePO::getMonitorUser);
|
||||
.eq(CsLinePO::getStatus, 1);
|
||||
// 只有当lineList不为空时才添加in条件
|
||||
if (CollUtil.isNotEmpty(poList)) {
|
||||
List<String> lineList = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
||||
@@ -340,32 +390,54 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
if (CollUtil.isEmpty(records)) {
|
||||
return result;
|
||||
}
|
||||
//获取用户id
|
||||
List<String> ids = records.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
||||
List<PqGovernPlan> governPlans = pqGovernPlanFeignClient.getListByMonitorPoint(ids).getData();
|
||||
if (CollUtil.isEmpty(governPlans)) {
|
||||
return result;
|
||||
}
|
||||
Map<String, PqGovernPlan> lineMap1 = governPlans.stream().collect(Collectors.toMap(PqGovernPlan::getGovernBefore, item -> item));
|
||||
Map<String, PqGovernPlan> lineMap2 = governPlans.stream().collect(Collectors.toMap(PqGovernPlan::getGovernAfter, item -> item));
|
||||
|
||||
List<PqSensitiveUserLineVO> list = new ArrayList<>();
|
||||
List<String> sensitiveUserIds = list.stream().map(PqSensitiveUserLineVO::getSensitiveUser).distinct().collect(Collectors.toList());
|
||||
|
||||
List<String> sensitiveUserIds = governPlans.stream().map(PqGovernPlan::getPid).distinct().collect(Collectors.toList());
|
||||
Map<String, String> sensitiveUserNameMap = new HashMap<>();
|
||||
List<PqSensitiveUser> pqSensitiveUserList = pqSensitiveUserFeignClient.getListByIds(sensitiveUserIds).getData();
|
||||
if (CollUtil.isNotEmpty(pqSensitiveUserList)) {
|
||||
sensitiveUserNameMap = pqSensitiveUserList.stream().collect(Collectors.toMap(PqSensitiveUser::getId, PqSensitiveUser::getName));
|
||||
}
|
||||
// 最新数据时间
|
||||
List<CsLineLatestData> lineLatestDataList = csLineLatestDataFeignClient.listData().getData();
|
||||
Map<String,CsLineLatestData> lineLatestDataMap = new HashMap<>();
|
||||
if (CollUtil.isNotEmpty(lineLatestDataList)) {
|
||||
lineLatestDataMap = lineLatestDataList.stream().collect(Collectors.toMap(CsLineLatestData::getLineId, item -> item));
|
||||
}
|
||||
|
||||
PqSensitiveUserLineVO sensitiveUserLineVO;
|
||||
|
||||
List<String> lineIds = records.stream().map(CsLinePO::getLineId).distinct().collect(Collectors.toList());
|
||||
List<DevDetailDTO> devDetailDTOList = csCommTerminal.getLedgerByLineId(lineIds).getData();
|
||||
Map<String, DevDetailDTO> devDetailDTOMap = devDetailDTOList.stream().collect(Collectors.toMap(DevDetailDTO::getLineId, item -> item));
|
||||
|
||||
List<PqSensitiveUserLineVO> list = new ArrayList<>();
|
||||
for (CsLinePO record : records) {
|
||||
sensitiveUserLineVO = new PqSensitiveUserLineVO();
|
||||
// 治理对象
|
||||
sensitiveUserLineVO.setSensitiveUser(sensitiveUserNameMap.getOrDefault(record.getMonitorUser(), null));
|
||||
sensitiveUserLineVO.setEngineeringName(devDetailDTOMap.get(record.getLineId()).getEngineeringName());
|
||||
sensitiveUserLineVO.setProjectName(devDetailDTOMap.get(record.getLineId()).getProjectName());
|
||||
sensitiveUserLineVO.setDevName(devDetailDTOMap.get(record.getLineId()).getEquipmentName());
|
||||
// 治理对象 && 是否治理
|
||||
PqGovernPlan plan1 = lineMap1.get(record.getLineId());
|
||||
if (!Objects.isNull(plan1)) {
|
||||
sensitiveUserLineVO.setSensitiveUser(sensitiveUserNameMap.getOrDefault(plan1.getPid(), null));
|
||||
sensitiveUserLineVO.setGovern(Objects.isNull(plan1.getGovernMethod()) ? "未治理" : plan1.getGovernMethod());
|
||||
}
|
||||
PqGovernPlan plan2 = lineMap2.get(record.getLineId());
|
||||
if (!Objects.isNull(plan2)) {
|
||||
sensitiveUserLineVO.setSensitiveUser(sensitiveUserNameMap.getOrDefault(plan2.getPid(), null));
|
||||
sensitiveUserLineVO.setGovern(Objects.isNull(plan2.getGovernMethod()) ? "未治理" : plan2.getGovernMethod());
|
||||
}
|
||||
// 测点名称
|
||||
sensitiveUserLineVO.setLineId(record.getLineId());
|
||||
sensitiveUserLineVO.setLineName(record.getName());
|
||||
// 是否治理
|
||||
if (ObjectUtil.isNotEmpty(record.getGovern())) {
|
||||
if (record.getGovern().equals(0)) {
|
||||
sensitiveUserLineVO.setGovern("未治理");
|
||||
}
|
||||
if (record.getGovern().equals(1)) {
|
||||
sensitiveUserLineVO.setGovern("已治理");
|
||||
}
|
||||
}
|
||||
// 监测类型
|
||||
if (ObjectUtil.isNotNull(record.getPosition())) {
|
||||
sensitiveUserLineVO.setPosition(record.getPosition());
|
||||
@@ -378,23 +450,12 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
if (ObjectUtil.isNotNull(record.getVolGrade())) {
|
||||
sensitiveUserLineVO.setVolGrade(record.getVolGrade());
|
||||
}
|
||||
// 运行状态
|
||||
if (ObjectUtil.isNotNull(record.getRunStatus())) {
|
||||
//获取设备状态
|
||||
int devRunStatus = csEquipmentDeliveryMapper.selectById(record.getDeviceId()).getRunStatus();
|
||||
sensitiveUserLineVO.setRunStatus(getRunStatusDescription(devRunStatus));
|
||||
}
|
||||
// 通讯状态
|
||||
sensitiveUserLineVO.setRunStatus(String.valueOf(devDetailDTOMap.get(record.getLineId()).getRunStatus()));
|
||||
// 报告文件
|
||||
sensitiveUserLineVO.setReportFilePath(record.getReportFilePath());
|
||||
// 最新数据时间
|
||||
// List<CsLineLatestData> lineLatestDataList = csLineLatestDataFeignClient.listData().getData();
|
||||
// if (CollUtil.isNotEmpty(lineLatestDataList)) {
|
||||
// sensitiveUserLineVO.setLatestTime(lineLatestDataList.stream()
|
||||
// .filter(item -> item.getLineId().equals(record.getLineId()))
|
||||
// .map(CsLineLatestData::getTimeId)
|
||||
// .max(LocalDateTime::compareTo)
|
||||
// .orElse(null));
|
||||
// }
|
||||
//最新数据时间
|
||||
sensitiveUserLineVO.setLatestTime(Objects.isNull(lineLatestDataMap.get(record.getLineId()))? null : lineLatestDataMap.get(record.getLineId()).getTimeId());
|
||||
list.add(sensitiveUserLineVO);
|
||||
}
|
||||
result.setRecords(list);
|
||||
@@ -442,15 +503,6 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
lineDetailDataVO.setBdName(csLedgerMapper.selectById(csLedger.getPids().split(StrUtil.COMMA)[LineBaseEnum.PROJECT_LEVEL.getCode()+1]).getName());
|
||||
}
|
||||
lineDetailDataVO.setLineName(csLinePO.getName());
|
||||
//Device device = deviceMapper.selectById(devId);
|
||||
//lineDetailDataVO.setComFlag(PubUtils.comFlag(device.getComFlag()));
|
||||
//lineDetailDataVO.setRunFlag(PubUtils.lineRunFlag(lineDetail.getRunFlag()));
|
||||
//lineDetailDataVO.setIp(device.getIp());
|
||||
//lineDetailDataVO.setLoginTime(device.getLoginTime());
|
||||
//lineDetailDataVO.setDevId(device.getId());
|
||||
//lineDetailDataVO.setBusinessType(dicDataFeignClient.getDicDataById(lineDetail.getBusinessType()).getData().getName());
|
||||
//lineDetailDataVO.setLoadType(dicDataFeignClient.getDicDataById(lineDetail.getLoadType()).getData().getName());
|
||||
lineDetailDataVO.setObjName(csLinePO.getMonitorUser());
|
||||
lineDetailDataVO.setLineId(csLinePO.getLineId());
|
||||
lineDetailDataVO.setPtType(PubUtils.ptType(csLinePO.getConType()));
|
||||
lineDetailDataVO.setPt(csLinePO.getPtRatio() + "/" + (Objects.isNull(csLinePO.getPt2Ratio())?1.0:csLinePO.getPt2Ratio()));
|
||||
@@ -473,8 +525,10 @@ public class CsLinePOServiceImpl extends ServiceImpl<CsLinePOMapper, CsLinePO> i
|
||||
public List<CsLinePO> getLineList(CsLinePO param) {
|
||||
List<String> keywordsLineIds = new ArrayList<>();
|
||||
List<CsLinePO> poList = getSimpleLine();
|
||||
if (CollUtil.isNotEmpty(poList)) {
|
||||
if (CollUtil.isNotEmpty(poList) && !poList.isEmpty()) {
|
||||
keywordsLineIds = poList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
||||
} else {
|
||||
return poList;
|
||||
}
|
||||
List<CsLinePO> result = this.list(new LambdaQueryWrapper<CsLinePO>()
|
||||
.eq(CsLinePO::getStatus, 1)
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
@@ -163,7 +164,7 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
|
||||
@Override
|
||||
public List<CsTerminalReply> getBzReplyData(String lineId) {
|
||||
LambdaQueryWrapper<CsTerminalReply> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.in(CsTerminalReply::getCode,Arrays.asList("allFile","allEvent","oneFile"))
|
||||
wrapper.in(CsTerminalReply::getCode,Arrays.asList("allFile","allEvent","oneFile","harmonic"))
|
||||
.orderByDesc(CsTerminalReply::getCreateTime);
|
||||
if (!Objects.isNull(lineId) && StringUtils.isNotBlank(lineId)) {
|
||||
wrapper.like(CsTerminalReply::getLineId,lineId);
|
||||
@@ -177,30 +178,18 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
|
||||
QueryWrapper<CsTerminalReply> queryWrapper = new QueryWrapper<>();
|
||||
if (StrUtil.isNotBlank(param.getSearchValue())) {
|
||||
queryWrapper.like("cs_terminal_reply.line_id", param.getSearchValue());
|
||||
// //获取监测点id
|
||||
// List<CsLinePO> list = csLinePOService.getLineByName(param.getSearchValue());
|
||||
// if (CollectionUtil.isEmpty(list)) {
|
||||
// return page;
|
||||
// } else {
|
||||
// queryWrapper.and(pr -> {
|
||||
// // 获取所有 lineId
|
||||
// List<String> lineIds = list.stream()
|
||||
// .map(CsLinePO::getLineId)
|
||||
// .collect(Collectors.toList());
|
||||
// // 使用 OR 条件连接多个 lineId
|
||||
// for (int i = 0; i < lineIds.size(); i++) {
|
||||
// if (i == 0) {
|
||||
// pr.like("cs_terminal_reply.line_id", lineIds.get(i));
|
||||
// } else {
|
||||
// pr.or().like("cs_terminal_reply.line_id", lineIds.get(i));
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
// }
|
||||
}
|
||||
queryWrapper.between("cs_terminal_reply.Create_Time"
|
||||
, DateUtil.beginOfDay(DateUtil.parse(param.getSearchBeginTime()))
|
||||
, DateUtil.endOfDay(DateUtil.parse(param.getSearchEndTime())));
|
||||
//排序
|
||||
queryWrapper.orderBy(true, false, "cs_terminal_reply.create_time");
|
||||
queryWrapper.in("cs_terminal_reply.code", Arrays.asList("allFile", "allEvent", "oneFile"));
|
||||
//这边不想新建字段了,用SortBy代替补召类型
|
||||
if (Objects.equals(param.getSortBy(), "harmonic")) {
|
||||
queryWrapper.in("cs_terminal_reply.code", Collections.singletonList("harmonic"));
|
||||
} else {
|
||||
queryWrapper.in("cs_terminal_reply.code", Arrays.asList("allFile", "allEvent", "oneFile"));
|
||||
}
|
||||
Page<CsTerminalReply> csTerminalReplyPage = this.baseMapper.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
|
||||
List<CsTerminalReply> records = csTerminalReplyPage.getRecords();
|
||||
@@ -209,25 +198,15 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
|
||||
Map<String, CsLedgerVO> ledgerMap = data.stream().collect(Collectors.toMap(CsLedgerVO::getId, Function.identity()));
|
||||
List<CldLogsVo> cldLogsVos = new ArrayList<>();
|
||||
records.forEach(item->{
|
||||
if (Objects.isNull(ledgerMap.get(item.getDeviceId()))) {
|
||||
return;
|
||||
}
|
||||
String pids = ledgerMap.get(item.getDeviceId()).getPids();
|
||||
String[] split = pids.split(",");
|
||||
CldLogsVo cldLogsVo = new CldLogsVo();
|
||||
cldLogsVo.setEngineeringName(ledgerMap.get(split[1]).getName());
|
||||
cldLogsVo.setProjectName(ledgerMap.get(split[2]).getName());
|
||||
cldLogsVo.setDeviceName(ledgerMap.get(item.getDeviceId()).getName());
|
||||
// String lineId = item.getLineId();
|
||||
// String[] lineSplit = lineId.split(",");
|
||||
// String result;
|
||||
// if (lineSplit.length == 1) {
|
||||
// result = ledgerMap.get(lineSplit[0]).getName();
|
||||
// } else {
|
||||
// result = Arrays.stream(lineSplit)
|
||||
// .map(ledgerMap::get)
|
||||
// .filter(Objects::nonNull)
|
||||
// .map(CsLedgerVO::getName)
|
||||
// .collect(Collectors.joining(","));
|
||||
// }
|
||||
// cldLogsVo.setLineName(result);
|
||||
cldLogsVo.setLineName(ledgerMap.get(param.getSearchValue()).getName());
|
||||
cldLogsVo.setLog(getLogDescription(item.getCode()));
|
||||
cldLogsVo.setLogTime(item.getCreateTime());
|
||||
@@ -278,6 +257,9 @@ public class CsTerminalReplyServiceImpl extends ServiceImpl<CsTerminalReplyMappe
|
||||
case "oneFile":
|
||||
result = "补召单事件波形";
|
||||
break;
|
||||
case "harmonic":
|
||||
result = "稳态数据";
|
||||
break;
|
||||
default:
|
||||
result = "未知";
|
||||
}
|
||||
|
||||
@@ -37,7 +37,6 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
|
||||
private final AskDeviceDataFeignClient askDeviceDataFeignClient;
|
||||
private final RedisUtil redisUtil;
|
||||
private final ChannelObjectUtil channelObjectUtil;
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
private final MqttUtil mqttUtil;
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@@ -51,11 +50,14 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
|
||||
}
|
||||
redisUtil.delete(AppRedisKey.DEVICE_ROOT_PATH + nDid);
|
||||
askDeviceDataFeignClient.askDeviceRootPath(nDid);
|
||||
Thread.sleep(3000);
|
||||
Object object = redisUtil.getObjectByKey(AppRedisKey.DEVICE_ROOT_PATH + nDid);
|
||||
if (Objects.nonNull(object)) {
|
||||
makeUpVo.setPrjDataPath(object.toString());
|
||||
makeUpVo.setType("dir");
|
||||
for (int i = 0; i <= 3; i++) {
|
||||
Thread.sleep(1000);
|
||||
Object object = redisUtil.getObjectByKey(AppRedisKey.DEVICE_ROOT_PATH + nDid);
|
||||
if (Objects.nonNull(object)) {
|
||||
makeUpVo.setPrjDataPath(object.toString());
|
||||
makeUpVo.setType("dir");
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(e.getMessage());
|
||||
@@ -75,12 +77,15 @@ public class DeviceFtpServiceImpl implements DeviceFtpService {
|
||||
redisUtil.delete(AppRedisKey.PROJECT_INFO + nDid);
|
||||
// 请求设备文件或目录信息
|
||||
askDeviceDataFeignClient.askDeviceFileOrDir(nDid, name);
|
||||
Thread.sleep(10000);
|
||||
// 从 Redis 获取对象
|
||||
Object object = redisUtil.getObjectByKey(AppRedisKey.PROJECT_INFO + nDid);
|
||||
if (object != null) {
|
||||
// 根据类型处理不同的数据
|
||||
processObject(result, object, type);
|
||||
for (int i = 0; i <= 10; i++) {
|
||||
Thread.sleep(1000);
|
||||
// 从 Redis 获取对象
|
||||
Object object = redisUtil.getObjectByKey(AppRedisKey.PROJECT_INFO + nDid);
|
||||
if (object != null) {
|
||||
// 根据类型处理不同的数据
|
||||
processObject(result, object, type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// 捕获特定异常并抛出运行时异常
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.CsDeviceUserFeignClient;
|
||||
import com.njcn.csdevice.param.DeviceMessageParam;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
@@ -18,6 +17,7 @@ import com.njcn.user.api.UserFeignClient;
|
||||
import com.njcn.user.pojo.po.User;
|
||||
import com.njcn.user.pojo.po.app.AppInfoSet;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
@@ -25,6 +25,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
class DeviceMessageServiceImpl implements DeviceMessageService {
|
||||
|
||||
private final AppUserFeignClient appUserFeignClient;
|
||||
@@ -37,17 +38,17 @@ class DeviceMessageServiceImpl implements DeviceMessageService {
|
||||
|
||||
@Override
|
||||
public List<String> getEventUserByDeviceId(String devId, Boolean isAdmin) {
|
||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
||||
List<String> result = new ArrayList<>(list);
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
||||
if (isAdmin) {
|
||||
List<User> adminUser = appUserFeignClient.getAdminInfo().getData();
|
||||
List<String> adminList = adminUser.stream().map(User::getId).collect(Collectors.toList());
|
||||
result.addAll(adminList);
|
||||
List<String> list = csDeviceUserFeignClient.findUserById(devId).getData();
|
||||
List<String> result = new ArrayList<>(list);
|
||||
adminList.addAll(result);
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(result)) {
|
||||
result = result.stream().distinct().collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(adminList)) {
|
||||
adminList = adminList.stream().distinct().collect(Collectors.toList());
|
||||
}
|
||||
return result;
|
||||
return adminList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -86,11 +87,17 @@ class DeviceMessageServiceImpl implements DeviceMessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getLineInfo(String id) {
|
||||
public void getLineInfo(String id, List<CsLinePO> list) {
|
||||
Map<Integer,String> map = new HashMap<>();
|
||||
List<CsLinePO> lineList = csLinePOService.findByNdid(id);
|
||||
List<CsLinePO> lineList;
|
||||
if (CollectionUtil.isNotEmpty(list) && list != null) {
|
||||
lineList = list;
|
||||
} else {
|
||||
lineList = csLinePOService.findByNdid(id);
|
||||
}
|
||||
if (CollectionUtil.isEmpty(lineList)){
|
||||
throw new BusinessException("监测点为空");
|
||||
log.error("监测点为空");
|
||||
return;
|
||||
}
|
||||
for (CsLinePO item : lineList) {
|
||||
if (Objects.isNull(item.getPosition()) || item.getPosition().isEmpty()){
|
||||
|
||||
@@ -164,9 +164,8 @@ class IcdServiceImpl implements IcdService {
|
||||
}
|
||||
Integer level = csLedger.getLevel();
|
||||
String[] pids = csLedger.getPids().split(StrUtil.COMMA);
|
||||
Integer sort = csLedger.getSort();
|
||||
// 设置工程信息(所有级别都需要)
|
||||
setEngineeringInfo(vo, level, pids, id, sort);
|
||||
setEngineeringInfo(vo, level, pids, id);
|
||||
// 根据级别设置不同的业务数据
|
||||
switch (level) {
|
||||
case 0:
|
||||
@@ -251,13 +250,13 @@ class IcdServiceImpl implements IcdService {
|
||||
DatePattern.NORM_DATETIME_PATTERN
|
||||
);
|
||||
if (CollectionUtil.isNotEmpty(param.getLineList())) {
|
||||
processWithLineIds(param.getLineList(), beginDay, endDay);
|
||||
processWithLineIds(param.getLineList(), beginDay, endDay, param.getBzType());
|
||||
} else {
|
||||
processWithoutLineIds(beginDay, endDay);
|
||||
processWithoutLineIds(beginDay, endDay, param.getBzType());
|
||||
}
|
||||
}
|
||||
|
||||
private void processWithLineIds(List<String> lineList, String beginDay, String endDay) {
|
||||
private void processWithLineIds(List<String> lineList, String beginDay, String endDay, Integer bzType) {
|
||||
List<CsLinePO> csLineList = csLinePOService.listByIds(lineList);
|
||||
List<String> deviceIdList = csLineList.stream()
|
||||
.map(CsLinePO::getDeviceId)
|
||||
@@ -268,10 +267,10 @@ class IcdServiceImpl implements IcdService {
|
||||
Map<String, List<CsEquipmentDeliveryPO>> devMap = equipmentList.stream()
|
||||
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
|
||||
|
||||
handleEventsAndLogs(devMap, csLineList, beginDay, endDay);
|
||||
handleEventsAndLogs(devMap, csLineList, beginDay, endDay, bzType);
|
||||
}
|
||||
|
||||
private void processWithoutLineIds(String beginDay, String endDay) {
|
||||
private void processWithoutLineIds(String beginDay, String endDay, Integer bzType) {
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getAllOnline();
|
||||
if (CollectionUtil.isEmpty(devList)) return;
|
||||
|
||||
@@ -283,14 +282,15 @@ class IcdServiceImpl implements IcdService {
|
||||
Map<String, List<CsEquipmentDeliveryPO>> devMap = devList.stream()
|
||||
.collect(Collectors.groupingBy(CsEquipmentDeliveryPO::getNodeId));
|
||||
|
||||
handleEventsAndLogs(devMap, csLineList, beginDay, endDay);
|
||||
handleEventsAndLogs(devMap, csLineList, beginDay, endDay, bzType);
|
||||
}
|
||||
|
||||
private void handleEventsAndLogs(
|
||||
Map<String, List<CsEquipmentDeliveryPO>> devMap,
|
||||
List<CsLinePO> csLineList,
|
||||
String beginDay,
|
||||
String endDay
|
||||
String endDay,
|
||||
Integer bzType
|
||||
) {
|
||||
devMap.forEach((nodeId, devices) -> {
|
||||
List<BZEventMessage.Event> events = new ArrayList<>();
|
||||
@@ -300,13 +300,13 @@ class IcdServiceImpl implements IcdService {
|
||||
for (CsEquipmentDeliveryPO device : devices) {
|
||||
String uuid = IdUtil.simpleUUID();
|
||||
|
||||
BZEventMessage.Event event = buildEvent(uuid, device, csLineList, beginDay, endDay);
|
||||
BZEventMessage.Event event = buildEvent(uuid, device, csLineList, beginDay, endDay, bzType);
|
||||
events.add(event);
|
||||
|
||||
CsTerminalLogs log = buildTerminalLog(uuid, device, csLineList);
|
||||
logsToSave.add(log);
|
||||
|
||||
List<CsTerminalReply> reply = buildTerminalReply(uuid, device, csLineList);
|
||||
List<CsTerminalReply> reply = buildTerminalReply(uuid, device, csLineList, bzType);
|
||||
repliesToSave.addAll(reply);
|
||||
}
|
||||
csTerminalLogsService.saveBatch(logsToSave);
|
||||
@@ -316,7 +316,7 @@ class IcdServiceImpl implements IcdService {
|
||||
}
|
||||
|
||||
private BZEventMessage.Event buildEvent(String guid, CsEquipmentDeliveryPO device,
|
||||
List<CsLinePO> csLineList, String beginDay, String endDay) {
|
||||
List<CsLinePO> csLineList, String beginDay, String endDay, Integer bzType) {
|
||||
BZEventMessage.Event event = new BZEventMessage.Event();
|
||||
event.setGuid(guid);
|
||||
event.setTerminalId(device.getId());
|
||||
@@ -327,7 +327,11 @@ class IcdServiceImpl implements IcdService {
|
||||
.collect(Collectors.toList());
|
||||
|
||||
event.setMonitorIdList(monitorIds);
|
||||
event.setDataType(1);
|
||||
if (!Objects.isNull(bzType) && bzType == 0) {
|
||||
event.setDataType(0);
|
||||
} else {
|
||||
event.setDataType(1);
|
||||
}
|
||||
event.setTimeInterval(Collections.singletonList(beginDay + "~" + endDay));
|
||||
return event;
|
||||
}
|
||||
@@ -351,7 +355,7 @@ class IcdServiceImpl implements IcdService {
|
||||
}
|
||||
|
||||
private List<CsTerminalReply> buildTerminalReply(String replyId, CsEquipmentDeliveryPO device,
|
||||
List<CsLinePO> csLineList) {
|
||||
List<CsLinePO> csLineList, Integer bzType) {
|
||||
List<CsTerminalReply> replies = new ArrayList<>();
|
||||
List<String> lineIds = csLineList.stream()
|
||||
.filter(line -> Objects.equals(line.getDeviceId(), device.getId()))
|
||||
@@ -366,7 +370,11 @@ class IcdServiceImpl implements IcdService {
|
||||
reply.setDeviceId(device.getId());
|
||||
reply.setLineId(lineId);
|
||||
reply.setIsReceived(0);
|
||||
reply.setCode("allEvent");
|
||||
if (!Objects.isNull(bzType) && bzType == 0) {
|
||||
reply.setCode("harmonic");
|
||||
} else {
|
||||
reply.setCode("allEvent");
|
||||
}
|
||||
replies.add(reply);
|
||||
});
|
||||
return replies;
|
||||
@@ -485,7 +493,7 @@ class IcdServiceImpl implements IcdService {
|
||||
/**
|
||||
* 设置工程信息
|
||||
*/
|
||||
private void setEngineeringInfo(CldLedgerVo vo, Integer level, String[] pids, String id, Integer sort) {
|
||||
private void setEngineeringInfo(CldLedgerVo vo, Integer level, String[] pids, String id) {
|
||||
String engineeringId;
|
||||
|
||||
if (level == 0) {
|
||||
@@ -504,7 +512,7 @@ class IcdServiceImpl implements IcdService {
|
||||
vo.setProvince(po.getProvince());
|
||||
vo.setCity(po.getCity());
|
||||
vo.setEngineeringDescription(po.getDescription());
|
||||
vo.setSort(sort);
|
||||
vo.setSort(po.getSort());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -526,6 +534,7 @@ class IcdServiceImpl implements IcdService {
|
||||
vo1.setTopoId(Objects.isNull(appTopologyDiagramPOMap.get(item.getId()))?null:appTopologyDiagramPOMap.get(item.getId()).getTopoId());
|
||||
result.add(vo1);
|
||||
});
|
||||
result.sort(Comparator.comparingInt(ProjectVO::getSort));
|
||||
}
|
||||
vo.setProjectInfoList(result);
|
||||
}
|
||||
@@ -549,20 +558,13 @@ class IcdServiceImpl implements IcdService {
|
||||
vo1.setTopoId(Objects.isNull(appTopologyDiagramPOMap.get(item.getId()))?null:appTopologyDiagramPOMap.get(item.getId()).getTopoId());
|
||||
result.add(vo1);
|
||||
});
|
||||
result.sort(Comparator.comparingInt(ProjectVO::getSort));
|
||||
}
|
||||
vo.setProjectInfoList(result);
|
||||
// 设置设备信息
|
||||
List<CsEquipmentDeliveryPO> devList = csEquipmentDeliveryService.getDevListByProjectId(id);
|
||||
devList.sort(Comparator.comparingInt(CsEquipmentDeliveryPO::getSort));
|
||||
vo.setDeviceInfoList(devList);
|
||||
// if (CollectionUtil.isNotEmpty(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);
|
||||
// }
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -586,11 +588,13 @@ class IcdServiceImpl implements IcdService {
|
||||
vo1.setTopoId(Objects.isNull(appTopologyDiagramPOMap.get(item.getId()))?null:appTopologyDiagramPOMap.get(item.getId()).getTopoId());
|
||||
result.add(vo1);
|
||||
});
|
||||
result.sort(Comparator.comparingInt(ProjectVO::getSort));
|
||||
}
|
||||
vo.setProjectInfoList(result);
|
||||
}
|
||||
// 设置设备信息
|
||||
List<CsEquipmentDeliveryPO> csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(id));
|
||||
csEquipmentDeliveryPOS.sort(Comparator.comparingInt(CsEquipmentDeliveryPO::getSort));
|
||||
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
|
||||
// 设置线路信息
|
||||
List<CsLinePO> list = csLinePOService.queryByDevId(id);
|
||||
@@ -603,13 +607,15 @@ class IcdServiceImpl implements IcdService {
|
||||
item.setCt2Ratio(1.0);
|
||||
}
|
||||
if (Objects.isNull(item.getLineNo())) {
|
||||
item.setLineNo(item.getClDid() == 0 ? null:item.getClDid());
|
||||
item.setLineNo(item.getClDid() == 0 ? 0:item.getClDid());
|
||||
}
|
||||
if (Objects.isNull(item.getRunStatus())) {
|
||||
item.setRunStatus(csEquipmentDeliveryPOS.get(0).getRunStatus());
|
||||
}
|
||||
});
|
||||
}
|
||||
list.sort(Comparator.comparingInt((CsLinePO cs) -> cs.getClDid() == null ? Integer.MAX_VALUE : cs.getClDid())
|
||||
.thenComparingInt(cs -> cs.getLineNo() == null ? Integer.MAX_VALUE : cs.getLineNo()));
|
||||
vo.setLineInfoList(list);
|
||||
}
|
||||
|
||||
@@ -634,6 +640,7 @@ class IcdServiceImpl implements IcdService {
|
||||
vo1.setTopoId(Objects.isNull(appTopologyDiagramPOMap.get(item.getId()))?null:appTopologyDiagramPOMap.get(item.getId()).getTopoId());
|
||||
result.add(vo1);
|
||||
});
|
||||
result.sort(Comparator.comparingInt(ProjectVO::getSort));
|
||||
}
|
||||
vo.setProjectInfoList(result);
|
||||
}
|
||||
@@ -642,6 +649,7 @@ class IcdServiceImpl implements IcdService {
|
||||
if (pids.length > 3) {
|
||||
String deviceId = pids[3];
|
||||
csEquipmentDeliveryPOS = csEquipmentDeliveryService.listByIds(Collections.singletonList(deviceId));
|
||||
csEquipmentDeliveryPOS.sort(Comparator.comparingInt(CsEquipmentDeliveryPO::getSort));
|
||||
vo.setDeviceInfoList(csEquipmentDeliveryPOS);
|
||||
} else {
|
||||
csEquipmentDeliveryPOS = new ArrayList<>();
|
||||
@@ -649,17 +657,17 @@ class IcdServiceImpl implements IcdService {
|
||||
// 设置线路信息
|
||||
List<CsLinePO> line = csLinePOService.listByIds(Collections.singletonList(id));
|
||||
if (CollectionUtil.isNotEmpty(line)) {
|
||||
line.forEach(item->{
|
||||
if (Objects.isNull(item.getPt2Ratio())) {
|
||||
for (CsLinePO item : line) {
|
||||
if (item.getPt2Ratio() == null) {
|
||||
item.setPt2Ratio(1.0);
|
||||
}
|
||||
if (Objects.isNull(item.getCt2Ratio())) {
|
||||
if (item.getCt2Ratio() == null) {
|
||||
item.setCt2Ratio(1.0);
|
||||
}
|
||||
if (Objects.isNull(item.getLineNo())) {
|
||||
item.setLineNo(item.getClDid() == 0 ? null:item.getClDid());
|
||||
}
|
||||
});
|
||||
item.setLineNo(item.getClDid());
|
||||
}
|
||||
line.sort(Comparator.comparingInt((CsLinePO cs) -> cs.getClDid() == null ? Integer.MAX_VALUE : cs.getClDid())
|
||||
.thenComparingInt(cs -> cs.getLineNo() == null ? Integer.MAX_VALUE : cs.getLineNo()));
|
||||
}
|
||||
vo.setLineInfoList(line);
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
|
||||
/**
|
||||
@@ -321,6 +322,52 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertionList(List<PqsCommunicateDto> list) {
|
||||
if (CollectionUtils.isEmpty(list)) {
|
||||
return;
|
||||
}
|
||||
Map<String, List<PqsCommunicateDto>> groupByDevId = list.stream().collect(Collectors.groupingBy(PqsCommunicateDto::getDevId));
|
||||
List<String> lineProtocols = new ArrayList<>();
|
||||
groupByDevId.forEach((ndid, dtoList) -> {
|
||||
LambdaQueryWrapper<CsEquipmentDeliveryPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CsEquipmentDeliveryPO::getNdid, ndid).ne(CsEquipmentDeliveryPO::getRunStatus, 0);
|
||||
CsEquipmentDeliveryPO po = csEquipmentDeliveryMapper.selectOne(lambdaQueryWrapper);
|
||||
if (po == null) {
|
||||
log.warn("未找到ndid={}对应的装置信息,跳过", ndid);
|
||||
return;
|
||||
}
|
||||
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||
influxQueryWrapper.eq(PqsCommunicate::getDevId, po.getId()).timeDesc().limit(1);
|
||||
List<PqsCommunicate> pqsCommunicates = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||
|
||||
Integer lastType = CollectionUtils.isEmpty(pqsCommunicates) ? null : pqsCommunicates.get(0).getType();
|
||||
|
||||
for (PqsCommunicateDto dto : dtoList) {
|
||||
if (lastType != null && Objects.equals(lastType, dto.getType())) {
|
||||
continue;
|
||||
}
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put("dev_id", po.getId());
|
||||
Map<String, Object> fields = new HashMap<>();
|
||||
fields.put("type", dto.getType());
|
||||
fields.put("description", dto.getDescription());
|
||||
long time = LocalDateTime.parse(dto.getTime(), DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN))
|
||||
.atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
Point point = influxDbUtils.pointBuilder("pqs_communicate", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("")
|
||||
.consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
lineProtocols.add(batchPoints.lineProtocol());
|
||||
lastType = dto.getType();
|
||||
}
|
||||
});
|
||||
if (!lineProtocols.isEmpty()) {
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, lineProtocols);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<PqsCommunicate> getPqsCommunicateData(LineCountEvaluateParam lineParam) {
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper(PqsCommunicate.class);
|
||||
|
||||
@@ -2,27 +2,27 @@ package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.util.IdUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.tocrhz.mqtt.publisher.MqttPublisher;
|
||||
import com.njcn.advance.api.EventCauseFeignClient;
|
||||
import com.njcn.advance.pojo.dto.EventAnalysisDTO;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.constant.DataParam;
|
||||
import com.njcn.csdevice.enums.AlgorithmResponseEnum;
|
||||
import com.njcn.csdevice.mapper.PortableOfflLogMapper;
|
||||
import com.njcn.csdevice.param.UploadDataParam;
|
||||
import com.njcn.csdevice.pojo.dto.CsEquipmentDeliveryDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.po.PortableOffMainLog;
|
||||
import com.njcn.csdevice.pojo.po.PortableOfflLog;
|
||||
import com.njcn.csdevice.pojo.po.WlRecord;
|
||||
import com.njcn.csdevice.service.CsLinePOService;
|
||||
import com.njcn.csdevice.service.IPortableOfflLogService;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.csdevice.param.UploadDataParam;
|
||||
import com.njcn.csdevice.service.IWlRecordService;
|
||||
import com.njcn.csdevice.service.PortableOffMainLogService;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.csdevice.util.InfluxDbParamUtil;
|
||||
import com.njcn.csharmonic.api.EventFeignClient;
|
||||
import com.njcn.csharmonic.api.OfflineDataUploadFeignClient;
|
||||
@@ -36,13 +36,18 @@ import com.njcn.csharmonic.offline.mincfg.AnalyseComtradeCfg;
|
||||
import com.njcn.csharmonic.offline.mincfg.vo.CmnModeCfg;
|
||||
import com.njcn.csharmonic.offline.vo.Response;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.influx.imapper.EvtDataMapper;
|
||||
import com.njcn.influx.imapper.PqdDataMapper;
|
||||
import com.njcn.event.common.mapper.WlRmpEventDetailMapper;
|
||||
import com.njcn.event.common.service.EventAnalysisService;
|
||||
import com.njcn.event.pojo.po.RmpEventDetailPO;
|
||||
import com.njcn.influx.imapper.*;
|
||||
import com.njcn.influx.pojo.po.*;
|
||||
import com.njcn.influx.pojo.po.cs.EntData;
|
||||
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.EleEvtFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -50,11 +55,10 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.ListUtils;
|
||||
import org.apache.commons.io.FilenameUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.poi.ss.formula.functions.T;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.io.*;
|
||||
import java.math.BigDecimal;
|
||||
import java.text.DecimalFormat;
|
||||
@@ -81,29 +85,38 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
|
||||
|
||||
private final DecimalFormat df = new DecimalFormat("#0.000");
|
||||
|
||||
private final FileStorageUtil fileStorageUtil;
|
||||
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
|
||||
private final OfflineDataUploadFeignClient offlineDataUploadFeignClient;
|
||||
|
||||
private final EleEvtFeignClient eleEvtFeignClient;
|
||||
|
||||
private final EventFeignClient eventFeignClient;
|
||||
|
||||
private final EquipmentFeignClient equipmentFeignClient;
|
||||
|
||||
private final InfluxDbParamUtil influxDbParamUtil;
|
||||
|
||||
private final PqdDataMapper pqdDataMapper;
|
||||
|
||||
private final EvtDataMapper evtDataMapper;
|
||||
|
||||
private final DataVMapper dataVMapper;
|
||||
private final DataIMapper dataIMapper;
|
||||
private final DataHarmRateVMapper dataHarmRateV;
|
||||
private final DataHarmRateIMapper dataHarmRateI;
|
||||
private final DataInHarmVMapper dataInHarmV;
|
||||
private final DataHarmPowerPMapper dataHarmPowerP;
|
||||
private final DataHarmPowerQMapper dataHarmPowerQ;
|
||||
private final DataHarmPowerSMapper dataHarmPowerS;
|
||||
private final DataFlickerMapper dataFlicker;
|
||||
private final DataFlucMapper dataFluc;
|
||||
private final DataPltMapper dataPlt;
|
||||
private final DataHarmPhasicVMapper dataHarmPhasicV;
|
||||
private final DataHarmPhasicIMapper dataHarmPhasicI;
|
||||
|
||||
private final IPqdDataSplitService pqdDataSplitService;
|
||||
private final MqttPublisher publisher;
|
||||
private final PortableOffMainLogService portableOffMainLogService;
|
||||
private final IWlRecordService wlRecordService;
|
||||
private final CsLinePOService csLinePOService;
|
||||
private final WlRmpEventDetailMapper wlRmpEventDetailMapper;
|
||||
private final EventCauseFeignClient eventCauseFeignClient;
|
||||
private final EventAnalysisService eventAnalysisService;
|
||||
|
||||
@Override
|
||||
public Page<PortableOfflLog> queryPage(BaseParam baseParam) {
|
||||
@@ -177,14 +190,15 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
@DSTransactional
|
||||
public void importEquipment(UploadDataParam uploadDataParam){
|
||||
String lineId = uploadDataParam.getLineId();
|
||||
//获取监测点信息
|
||||
LambdaQueryWrapper<CsLinePO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(CsLinePO::getLineId,lineId).eq(CsLinePO::getStatus,1);
|
||||
CsLinePO po = csLinePOService.getOne(queryWrapper);
|
||||
String cdid = uploadDataParam.getLineId().substring(uploadDataParam.getLineId().length() - 1);
|
||||
//String cdid = uploadDataParam.getLineId().substring(uploadDataParam.getLineId().length() - 1);
|
||||
Integer cdid = po.getClDid();
|
||||
//第一步解析redcord.bin文件获取监测点序号做校验
|
||||
List<MultipartFile> record = uploadDataParam.getFiles().stream().filter(
|
||||
temp -> temp.getOriginalFilename().contains("record.bin"))
|
||||
@@ -202,7 +216,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
//监测点序号
|
||||
int lineIdx = cmnModeCfg.line_idx;
|
||||
|
||||
if(lineIdx!=Integer.valueOf(cdid)){
|
||||
if(lineIdx != cdid){
|
||||
throw new BusinessException(AlgorithmResponseEnum.LINE_NUM_MISMATCH);
|
||||
}
|
||||
|
||||
@@ -302,7 +316,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
|
||||
List<PqdData> pqdData = (List<PqdData>) response.getObj();
|
||||
pqdData.forEach(temp->{
|
||||
temp.setClDid(cdid);
|
||||
temp.setClDid(String.valueOf(cdid));
|
||||
temp.setIsAbnormal(0);
|
||||
temp.setProcess(data1.get(0).getProcess()+"");
|
||||
temp.setLineId(uploadDataParam.getLineId());
|
||||
@@ -337,7 +351,6 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
.eq(WlRecord::getEndTime,wlRecord.getEndTime()).update();
|
||||
wlRecordService.save(wlRecord);
|
||||
|
||||
|
||||
//如果明确返回了state 那么当前文件解析出错
|
||||
if(response.getState() != null){
|
||||
portableOfflLog.setState(response.getState());
|
||||
@@ -353,7 +366,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
List<List<PqdData>> partition = ListUtils.partition(pqdData, 1500);
|
||||
for (List<PqdData> sliceList : partition) {
|
||||
List<PqdData> sublistAsOriginalListType = new ArrayList<>(sliceList);
|
||||
pqdDataMapper.insertBatch(sublistAsOriginalListType);
|
||||
Map<String, Object> map = pqdDataSplitService.splitPqdData(sublistAsOriginalListType);
|
||||
insertData(map);
|
||||
}
|
||||
//min结果集解析入库后就不需要在解析了
|
||||
minFlag = false;
|
||||
@@ -381,6 +395,8 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
}
|
||||
List<NewTaglogbuffer> newTaglogbuffers = (List<NewTaglogbuffer>) response.getObj();
|
||||
if(newTaglogbuffers != null && !newTaglogbuffers.isEmpty()){
|
||||
List<DictData> list1 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_REASON.getCode()).getData();
|
||||
List<DictData> list2 = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.EVENT_TYPE.getCode()).getData();
|
||||
//否则正常标记为成功解析
|
||||
portableOfflLog.setState(1);
|
||||
portableOfflLog.setAllCount(newTaglogbuffers.size());
|
||||
@@ -451,14 +467,14 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
}
|
||||
}
|
||||
csEventPO.setWavePath(wavePath);
|
||||
|
||||
//默认暂态事件
|
||||
csEventPO.setType(0);
|
||||
String clDid = influxDbParamUtil.getClDidByLineId(uploadDataParam.getLineId());
|
||||
csEventPO.setClDid(clDid == null ? null : Integer.parseInt(clDid));
|
||||
|
||||
|
||||
csEventPO.setProcess(csEquipmentDeliveryDTO.getProcess());
|
||||
csEventPOS.add(csEventPO);
|
||||
|
||||
|
||||
EntData entData = new EntData();
|
||||
entData.setUuid(csEventPO.getId());
|
||||
entData.setTime(new Date().toInstant());
|
||||
@@ -503,12 +519,48 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
log.info("类型log,插入infulxDb的evtData");
|
||||
try {
|
||||
evtDataMapper.insertOne(entData);
|
||||
//添加其余数据
|
||||
csEventPO.setPhase(entData.getEvtParamPhase());
|
||||
csEventPO.setPersistTime(entData.getEvtParamTm());
|
||||
csEventPO.setAmplitude(entData.getEvtParamVVaDepth());
|
||||
|
||||
if (Objects.equals(csEventPO.getTag(),DataParam.dipStrName)) {
|
||||
//计算暂降原因和类型
|
||||
EventAnalysisDTO var1 = new EventAnalysisDTO();
|
||||
var1.setWlFilePath(wavePath);
|
||||
EventAnalysisDTO dto = eventCauseFeignClient.analysisCauseAndType(var1).getData();
|
||||
String id1 = list1.stream()
|
||||
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getCause()))
|
||||
.map(DictData::getId)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
csEventPO.setAdvanceReason(id1);
|
||||
|
||||
String id2 = list2.stream()
|
||||
.filter(item -> Objects.equals(item.getAlgoDescribe(), dto.getType()))
|
||||
.map(DictData::getId)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
csEventPO.setAdvanceType(id2);
|
||||
if (!Objects.isNull(csEventPO.getAmplitude()) && !Objects.isNull(csEventPO.getPersistTime())) {
|
||||
//计算暂降严重度
|
||||
csEventPO.setSeverity(Double.valueOf(getYzd(csEventPO.getPersistTime()*1000,csEventPO.getAmplitude())));
|
||||
}
|
||||
}
|
||||
if (!Objects.isNull(csEventPO.getAmplitude()) && !Objects.isNull(csEventPO.getPersistTime())) {
|
||||
//计算落点
|
||||
String dropZone = eventAnalysisService.determineDropZone(String.valueOf(csEventPO.getAmplitude()),String.valueOf(csEventPO.getPersistTime()));
|
||||
csEventPO.setLandPoint(dropZone);
|
||||
}
|
||||
csEventPOS.add(csEventPO);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
log.info("类型log,插入mysql事件表cs_event");
|
||||
eventFeignClient.saveBatchEventList(csEventPOS);
|
||||
//同步数据到 r_mp_event_detail
|
||||
csEventPOS.forEach(this::insertEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -529,6 +581,95 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
portableOffMainLogService.save(portableOffMainLog);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取该事件的严重度
|
||||
*
|
||||
* @param persistTime 持续时间 ms单位
|
||||
* @param eventValue 暂降、暂升幅值
|
||||
*/
|
||||
public String getYzd(Double persistTime, Double eventValue) {
|
||||
Double yzd;
|
||||
// 格式化小数
|
||||
DecimalFormat df = new DecimalFormat("0.000");
|
||||
if (persistTime <= 20) {
|
||||
yzd = 1.0 - eventValue;
|
||||
} else if (persistTime > 20 && persistTime <= 200) {
|
||||
yzd = 2.0 * (1 - eventValue);
|
||||
} else if (persistTime > 200 && persistTime <= 500) {
|
||||
yzd = 3.3 * (1 - eventValue);
|
||||
} else if (persistTime > 500 && persistTime <= 10000) {
|
||||
yzd = 5.0 * (1 - eventValue);
|
||||
} else {
|
||||
yzd = 10.0 * (1 - eventValue);
|
||||
}
|
||||
return df.format(yzd);
|
||||
}
|
||||
|
||||
public void insertEvent(CsEventPO item) {
|
||||
RmpEventDetailPO rmpEventDetailPo = new RmpEventDetailPO();
|
||||
rmpEventDetailPo.setEventId(item.getId());
|
||||
rmpEventDetailPo.setMeasurementPointId(item.getLineId());
|
||||
rmpEventDetailPo.setStartTime(item.getStartTime());
|
||||
rmpEventDetailPo.setEventType(getEventType(item.getTag()));
|
||||
rmpEventDetailPo.setFeatureAmplitude(item.getAmplitude());
|
||||
rmpEventDetailPo.setDuration(item.getPersistTime());
|
||||
rmpEventDetailPo.setEventDescribe(getTag(item.getTag()));
|
||||
rmpEventDetailPo.setWavePath(item.getWavePath());
|
||||
if (!Objects.isNull(item.getWavePath())) {
|
||||
rmpEventDetailPo.setFileFlag(1);
|
||||
} else {
|
||||
rmpEventDetailPo.setFileFlag(0);
|
||||
}
|
||||
rmpEventDetailPo.setPhase(item.getPhase());
|
||||
rmpEventDetailPo.setAdvanceReason(item.getAdvanceReason());
|
||||
rmpEventDetailPo.setAdvanceType(item.getAdvanceType());
|
||||
if (!Objects.isNull(item.getAdvanceReason()) && !Objects.isNull(item.getAdvanceType())) {
|
||||
rmpEventDetailPo.setDealFlag(1);
|
||||
} else {
|
||||
rmpEventDetailPo.setDealFlag(0);
|
||||
}
|
||||
wlRmpEventDetailMapper.insert(rmpEventDetailPo);
|
||||
}
|
||||
|
||||
public String getTag(String tag) {
|
||||
switch (tag) {
|
||||
case "Evt_Sys_DipStr":
|
||||
tag = DicDataEnum.VOLTAGE_DIP.getCode();
|
||||
break;
|
||||
case "Evt_Sys_SwlStr":
|
||||
tag = DicDataEnum.VOLTAGE_RISE.getCode();
|
||||
break;
|
||||
case "Evt_Sys_IntrStr":
|
||||
tag = DicDataEnum.SHORT_INTERRUPTIONS.getCode();
|
||||
break;
|
||||
default:
|
||||
tag = "Un_Know";
|
||||
break;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
public String getEventType(String tag) {
|
||||
switch (tag) {
|
||||
case "Evt_Sys_DipStr":
|
||||
DictData dip = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_DIP.getCode()).getData();
|
||||
tag = dip.getId();
|
||||
break;
|
||||
case "Evt_Sys_SwlStr":
|
||||
DictData rise = dicDataFeignClient.getDicDataByCode(DicDataEnum.VOLTAGE_RISE.getCode()).getData();
|
||||
tag = rise.getId();
|
||||
break;
|
||||
case "Evt_Sys_IntrStr":
|
||||
DictData interruptions = dicDataFeignClient.getDicDataByCode(DicDataEnum.SHORT_INTERRUPTIONS.getCode()).getData();
|
||||
tag = interruptions.getId();
|
||||
break;
|
||||
default:
|
||||
tag = "Un_Know";
|
||||
break;
|
||||
}
|
||||
return tag;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Page<PortableOffMainLog> queryMainLogPage(BaseParam baseParam) {
|
||||
Page<PortableOffMainLog> returnpage = new Page<> (baseParam.getPageNum(), baseParam.getPageSize ());
|
||||
@@ -587,7 +728,7 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
String dictDataCode = null;
|
||||
switch (volConType) {
|
||||
case 0:
|
||||
dictDataCode = "star";
|
||||
dictDataCode = "Trans_Business";
|
||||
break;
|
||||
case 1:
|
||||
dictDataCode = "Star_Triangle";
|
||||
@@ -604,4 +745,87 @@ public class PortableOfflLogServiceImpl extends ServiceImpl<PortableOfflLogMappe
|
||||
}
|
||||
return Objects.isNull(result)?null:result;
|
||||
}
|
||||
|
||||
public void insertData(Map<String, Object> map) {
|
||||
//13张表
|
||||
map.forEach((key, value) -> {
|
||||
switch (key) {
|
||||
case "data_v":
|
||||
dataVMapper.insertBatch((List<DataV>) value);
|
||||
break;
|
||||
case "data_i":
|
||||
dataIMapper.insertBatch((List<DataI>) value);
|
||||
break;
|
||||
case "data_flicker":
|
||||
//10分钟入一组
|
||||
List<DataFlicker> list = (List<DataFlicker>) value;
|
||||
if (!CollectionUtils.isEmpty(list)) {
|
||||
list.forEach(item->{
|
||||
Instant time = getTime(item.getTime(),600);
|
||||
item.setTime(time);
|
||||
});
|
||||
dataFlicker.insertBatch(list);
|
||||
}
|
||||
break;
|
||||
case "data_fluc":
|
||||
//10分钟入一组
|
||||
List<DataFluc> list2 = (List<DataFluc>) value;
|
||||
if (!CollectionUtils.isEmpty(list2)) {
|
||||
list2.forEach(item->{
|
||||
Instant time = getTime(item.getTime(),600);
|
||||
item.setTime(time);
|
||||
});
|
||||
dataFluc.insertBatch(list2);
|
||||
}
|
||||
break;
|
||||
case "data_harmphasic_i":
|
||||
dataHarmPhasicI.insertBatch((List<DataHarmPhasicI>) value);
|
||||
break;
|
||||
case "data_harmphasic_v":
|
||||
dataHarmPhasicV.insertBatch((List<DataHarmPhasicV>) value);
|
||||
break;
|
||||
case "data_harmpower_p":
|
||||
dataHarmPowerP.insertBatch((List<DataHarmPowerP>) value);
|
||||
break;
|
||||
case "data_harmpower_q":
|
||||
dataHarmPowerQ.insertBatch((List<DataHarmPowerQ>) value);
|
||||
break;
|
||||
case "data_harmpower_s":
|
||||
dataHarmPowerS.insertBatch((List<DataHarmPowerS>) value);
|
||||
break;
|
||||
case "data_harmrate_v":
|
||||
dataHarmRateV.insertBatch((List<DataHarmRateV>) value);
|
||||
break;
|
||||
case "data_harmrate_i":
|
||||
dataHarmRateI.insertBatch((List<DataHarmRateI>) value);
|
||||
break;
|
||||
case "data_inharm_v":
|
||||
dataInHarmV.insertBatch((List<DataInHarmV>) value);
|
||||
break;
|
||||
case "data_plt":
|
||||
//2小时入一组
|
||||
List<DataPlt> list3 = (List<DataPlt>) value;
|
||||
if (!CollectionUtils.isEmpty(list3)) {
|
||||
list3.forEach(item->{
|
||||
Instant time = getTime(item.getTime(),7200);
|
||||
item.setTime(time);
|
||||
});
|
||||
dataPlt.insertBatch(list3);
|
||||
}
|
||||
break;
|
||||
case "pqd_data":
|
||||
pqdDataMapper.insertBatch((List<PqdData>) value);
|
||||
break;
|
||||
default:
|
||||
log.warn("不支持的目标表: {}", key);
|
||||
break;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public Instant getTime(Instant time, Integer interval) {
|
||||
long originalTimeSec = time.getEpochSecond();
|
||||
long newTimeSec = (originalTimeSec / interval) * interval;
|
||||
return Instant.ofEpochSecond(newTimeSec);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,470 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.njcn.csdevice.service.IPqdDataSplitService;
|
||||
import com.njcn.influx.pojo.po.*;
|
||||
import com.njcn.influx.pojo.po.cs.PqdData;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import com.njcn.system.api.DicDataFeignClient;
|
||||
import com.njcn.system.api.EpdFeignClient;
|
||||
import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.pojo.po.DictData;
|
||||
import com.njcn.system.pojo.po.EleEpdPqd;
|
||||
import com.njcn.system.pojo.vo.EleEpdPqdListVO;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
/**
|
||||
* PqdData数据拆分服务实现
|
||||
*
|
||||
* @author system
|
||||
* @since 2026-05-22
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqdDataSplitServiceImpl implements IPqdDataSplitService {
|
||||
private final RedisUtil redisUtil;
|
||||
private final EpdFeignClient epdFeignClient;
|
||||
private final DicDataFeignClient dicDataFeignClient;
|
||||
@Override
|
||||
public Map<String, Object> splitPqdData(List<PqdData> pqdDataList) {
|
||||
//获取表映射关系
|
||||
Map<String,String> map1 = new Gson().fromJson(String.valueOf(redisUtil.getObjectByKey(AppRedisKey.ELE_EPD_PQD)), Map.class);
|
||||
//获取字段映射关系
|
||||
DictData pqd = dicDataFeignClient.getDicDataByCode(DicDataEnum.PQD.getCode()).getData();
|
||||
List<EleEpdPqdListVO> list = epdFeignClient.selectAll().getData();
|
||||
List<EleEpdPqd> epdList = list.stream().filter(item -> Objects.equals(item.getDataType(), pqd.getId()))
|
||||
.findFirst()
|
||||
.map(EleEpdPqdListVO::getEleEpdPqdVOS)
|
||||
.orElse(new ArrayList<>());
|
||||
// 处理 harmStart 和 harmEnd
|
||||
List<EleEpdPqd> resultList = epdList.stream()
|
||||
.flatMap(item -> {
|
||||
if (item.getHarmStart() != null && item.getHarmEnd() != null) {
|
||||
List<EleEpdPqd> expandedList = new ArrayList<>();
|
||||
for (int i = item.getHarmStart(); i <= item.getHarmEnd(); i++) {
|
||||
EleEpdPqd newItem = copyEleEpdPqd(item);
|
||||
newItem.setName(item.getName() + "_" + i);
|
||||
newItem.setOtherName(item.getOtherName() + "_" + i);
|
||||
expandedList.add(newItem);
|
||||
}
|
||||
return expandedList.stream();
|
||||
} else {
|
||||
return Stream.of(item);
|
||||
}
|
||||
})
|
||||
.collect(Collectors.toList());
|
||||
Map<String,List<EleEpdPqd>> map2 = resultList.stream().collect(Collectors.groupingBy(EleEpdPqd::getName,LinkedHashMap::new,Collectors.toList()));
|
||||
Map<String,Object> map3 = new HashMap<>();
|
||||
List<Object> list1 = new ArrayList<>();
|
||||
List<Object> list2 = new ArrayList<>();
|
||||
List<Object> list3 = new ArrayList<>();
|
||||
List<Object> list4 = new ArrayList<>();
|
||||
List<Object> list5 = new ArrayList<>();
|
||||
List<Object> list6 = new ArrayList<>();
|
||||
List<Object> list7 = new ArrayList<>();
|
||||
List<Object> list8 = new ArrayList<>();
|
||||
List<Object> list9 = new ArrayList<>();
|
||||
List<Object> list10 = new ArrayList<>();
|
||||
List<Object> list11 = new ArrayList<>();
|
||||
List<Object> list12 = new ArrayList<>();
|
||||
List<Object> list13 = new ArrayList<>();
|
||||
List<Object> list14 = new ArrayList<>();
|
||||
|
||||
|
||||
|
||||
for (PqdData item : pqdDataList) {
|
||||
Map<String, Object> map = extractFieldValues(item);
|
||||
|
||||
DataV dataV = new DataV();
|
||||
dataV.setTime(item.getTime());
|
||||
dataV.setLineId(item.getLineId());
|
||||
dataV.setPhaseType(item.getPhaseType());
|
||||
dataV.setValueType(item.getValueType());
|
||||
dataV.setClDid(item.getClDid());
|
||||
dataV.setProcess(item.getProcess());
|
||||
dataV.setQualityFlag("0");
|
||||
|
||||
DataI dataI = new DataI();
|
||||
dataI.setTime(item.getTime());
|
||||
dataI.setLineId(item.getLineId());
|
||||
dataI.setPhaseType(item.getPhaseType());
|
||||
dataI.setValueType(item.getValueType());
|
||||
dataI.setClDid(item.getClDid());
|
||||
dataI.setProcess(item.getProcess());
|
||||
dataI.setQualityFlag("0");
|
||||
|
||||
DataFlicker dataFlicker = new DataFlicker();
|
||||
dataFlicker.setTime(item.getTime());
|
||||
dataFlicker.setLineId(item.getLineId());
|
||||
dataFlicker.setPhaseType(item.getPhaseType());
|
||||
dataFlicker.setValueType(item.getValueType());
|
||||
dataFlicker.setClDid(item.getClDid());
|
||||
dataFlicker.setProcess(item.getProcess());
|
||||
dataFlicker.setQualityFlag("0");
|
||||
|
||||
DataFluc dataFluc = new DataFluc();
|
||||
dataFluc.setTime(item.getTime());
|
||||
dataFluc.setLineId(item.getLineId());
|
||||
dataFluc.setPhaseType(item.getPhaseType());
|
||||
dataFluc.setValueType(item.getValueType());
|
||||
dataFluc.setClDid(item.getClDid());
|
||||
dataFluc.setProcess(item.getProcess());
|
||||
dataFluc.setQualityFlag("0");
|
||||
|
||||
DataHarmPhasicI dataHarmPhasicI = new DataHarmPhasicI();
|
||||
dataHarmPhasicI.setTime(item.getTime());
|
||||
dataHarmPhasicI.setLineId(item.getLineId());
|
||||
dataHarmPhasicI.setPhaseType(item.getPhaseType());
|
||||
dataHarmPhasicI.setValueType(item.getValueType());
|
||||
dataHarmPhasicI.setClDid(item.getClDid());
|
||||
dataHarmPhasicI.setProcess(item.getProcess());
|
||||
dataHarmPhasicI.setQualityFlag("0");
|
||||
|
||||
DataHarmPhasicV dataHarmPhasicV = new DataHarmPhasicV();
|
||||
dataHarmPhasicV.setTime(item.getTime());
|
||||
dataHarmPhasicV.setLineId(item.getLineId());
|
||||
dataHarmPhasicV.setPhaseType(item.getPhaseType());
|
||||
dataHarmPhasicV.setValueType(item.getValueType());
|
||||
dataHarmPhasicV.setClDid(item.getClDid());
|
||||
dataHarmPhasicV.setProcess(item.getProcess());
|
||||
dataHarmPhasicV.setQualityFlag("0");
|
||||
|
||||
DataHarmPowerP dataHarmPowerP = new DataHarmPowerP();
|
||||
dataHarmPowerP.setTime(item.getTime());
|
||||
dataHarmPowerP.setLineId(item.getLineId());
|
||||
dataHarmPowerP.setPhaseType(item.getPhaseType());
|
||||
dataHarmPowerP.setValueType(item.getValueType());
|
||||
dataHarmPowerP.setClDid(item.getClDid());
|
||||
dataHarmPowerP.setProcess(item.getProcess());
|
||||
dataHarmPowerP.setQualityFlag("0");
|
||||
|
||||
DataHarmPowerQ dataHarmPowerQ = new DataHarmPowerQ();
|
||||
dataHarmPowerQ.setTime(item.getTime());
|
||||
dataHarmPowerQ.setLineId(item.getLineId());
|
||||
dataHarmPowerQ.setPhaseType(item.getPhaseType());
|
||||
dataHarmPowerQ.setValueType(item.getValueType());
|
||||
dataHarmPowerQ.setClDid(item.getClDid());
|
||||
dataHarmPowerQ.setProcess(item.getProcess());
|
||||
dataHarmPowerQ.setQualityFlag("0");
|
||||
|
||||
DataHarmPowerS dataHarmPowerS = new DataHarmPowerS();
|
||||
dataHarmPowerS.setTime(item.getTime());
|
||||
dataHarmPowerS.setLineId(item.getLineId());
|
||||
dataHarmPowerS.setPhaseType(item.getPhaseType());
|
||||
dataHarmPowerS.setValueType(item.getValueType());
|
||||
dataHarmPowerS.setClDid(item.getClDid());
|
||||
dataHarmPowerS.setProcess(item.getProcess());
|
||||
dataHarmPowerS.setQualityFlag("0");
|
||||
|
||||
DataHarmRateV dataHarmRateV = new DataHarmRateV();
|
||||
dataHarmRateV.setTime(item.getTime());
|
||||
dataHarmRateV.setLineId(item.getLineId());
|
||||
dataHarmRateV.setPhaseType(item.getPhaseType());
|
||||
dataHarmRateV.setValueType(item.getValueType());
|
||||
dataHarmRateV.setClDid(item.getClDid());
|
||||
dataHarmRateV.setProcess(item.getProcess());
|
||||
dataHarmRateV.setQualityFlag("0");
|
||||
|
||||
DataHarmRateI dataHarmRateI = new DataHarmRateI();
|
||||
dataHarmRateI.setTime(item.getTime());
|
||||
dataHarmRateI.setLineId(item.getLineId());
|
||||
dataHarmRateI.setPhaseType(item.getPhaseType());
|
||||
dataHarmRateI.setValueType(item.getValueType());
|
||||
dataHarmRateI.setClDid(item.getClDid());
|
||||
dataHarmRateI.setProcess(item.getProcess());
|
||||
dataHarmRateI.setQualityFlag("0");
|
||||
|
||||
DataInHarmV dataInHarmV = new DataInHarmV();
|
||||
dataInHarmV.setTime(item.getTime());
|
||||
dataInHarmV.setLineId(item.getLineId());
|
||||
dataInHarmV.setPhaseType(item.getPhaseType());
|
||||
dataInHarmV.setValueType(item.getValueType());
|
||||
dataInHarmV.setClDid(item.getClDid());
|
||||
dataInHarmV.setProcess(item.getProcess());
|
||||
dataInHarmV.setQualityFlag("0");
|
||||
|
||||
DataPlt dataPlt = new DataPlt();
|
||||
dataPlt.setTime(item.getTime());
|
||||
dataPlt.setLineId(item.getLineId());
|
||||
dataPlt.setPhaseType(item.getPhaseType());
|
||||
dataPlt.setValueType(item.getValueType());
|
||||
dataPlt.setClDid(item.getClDid());
|
||||
dataPlt.setProcess(item.getProcess());
|
||||
dataPlt.setQualityFlag("0");
|
||||
|
||||
PqdData pqdData = new PqdData();
|
||||
pqdData.setTime(item.getTime());
|
||||
pqdData.setLineId(item.getLineId());
|
||||
pqdData.setPhaseType(item.getPhaseType());
|
||||
pqdData.setValueType(item.getValueType());
|
||||
pqdData.setClDid(item.getClDid());
|
||||
pqdData.setProcess(item.getProcess());
|
||||
pqdData.setQualityFlag("0");
|
||||
|
||||
|
||||
boolean hasDataV = false;
|
||||
boolean hasDataI = false;
|
||||
boolean hasData1 = false;
|
||||
boolean hasData2 = false;
|
||||
boolean hasData3 = false;
|
||||
boolean hasData4 = false;
|
||||
boolean hasData5 = false;
|
||||
boolean hasData6 = false;
|
||||
boolean hasData7 = false;
|
||||
boolean hasData8 = false;
|
||||
boolean hasData9 = false;
|
||||
boolean hasData10 = false;
|
||||
boolean hasData11 = false;
|
||||
boolean hasData12 = false;
|
||||
|
||||
for (Map.Entry<String, Object> entry : map.entrySet()) {
|
||||
String fieldName = entry.getKey();
|
||||
Object value = entry.getValue();
|
||||
String capitalizedFieldName = StringUtils.capitalize(fieldName);
|
||||
|
||||
// 跳过公共字段和 null 值
|
||||
if (isCommonField(fieldName) || value == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String table = map1.get(capitalizedFieldName);
|
||||
if (StrUtil.isBlank(table)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
List<EleEpdPqd> epdPqdList = map2.get(capitalizedFieldName);
|
||||
if (CollectionUtils.isEmpty(epdPqdList)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String influxdbName2 = epdPqdList.get(0).getOtherName();
|
||||
if (StrUtil.isBlank(influxdbName2) || influxdbName2.equals(capitalizedFieldName)) {
|
||||
influxdbName2 = capitalizedFieldName;
|
||||
}
|
||||
|
||||
if (Objects.equals(table, "data_v")) {
|
||||
setFieldValue(dataV, influxdbName2, value, true);
|
||||
hasDataV = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_i")) {
|
||||
setFieldValue(dataI, influxdbName2, value, true);
|
||||
hasDataI = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_flicker")) {
|
||||
setFieldValue(dataFlicker, influxdbName2, value, true);
|
||||
hasData1 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_fluc")) {
|
||||
setFieldValue(dataFluc, influxdbName2, value, true);
|
||||
hasData2 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_harmphasic_i")) {
|
||||
setFieldValue(dataHarmPhasicI, influxdbName2, value, true);
|
||||
hasData3 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_harmphasic_v")) {
|
||||
setFieldValue(dataHarmPhasicV, influxdbName2, value, true);
|
||||
hasData4 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_harmpower_p")) {
|
||||
setFieldValue(dataHarmPowerP, influxdbName2, value, true);
|
||||
hasData5 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_harmpower_q")) {
|
||||
setFieldValue(dataHarmPowerQ, influxdbName2, value, true);
|
||||
hasData6 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_harmpower_s")) {
|
||||
setFieldValue(dataHarmPowerS, influxdbName2, value, true);
|
||||
hasData7 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_harmrate_v")) {
|
||||
setFieldValue(dataHarmRateV, influxdbName2, value, true);
|
||||
hasData8 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_harmrate_i")) {
|
||||
setFieldValue(dataHarmRateI, influxdbName2, value, true);
|
||||
hasData9 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_inharm_v")) {
|
||||
setFieldValue(dataInHarmV, influxdbName2, value, true);
|
||||
hasData10 = true;
|
||||
}
|
||||
if (Objects.equals(table, "data_plt")) {
|
||||
setFieldValue(dataPlt, influxdbName2, value, true);
|
||||
hasData11 = true;
|
||||
}
|
||||
if (Objects.equals(table, "pqd_data")) {
|
||||
setFieldValue(pqdData, StringUtils.uncapitalize(influxdbName2), value, false);
|
||||
hasData12 = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasDataV) {
|
||||
list1.add(dataV);
|
||||
}
|
||||
if (hasDataI) {
|
||||
list2.add(dataI);
|
||||
}
|
||||
if (hasData1) {
|
||||
list3.add(dataFlicker);
|
||||
}
|
||||
if (hasData2) {
|
||||
list4.add(dataFluc);
|
||||
}
|
||||
if (hasData3) {
|
||||
list5.add(dataHarmPhasicI);
|
||||
}
|
||||
if (hasData4) {
|
||||
list6.add(dataHarmPhasicV);
|
||||
}
|
||||
if (hasData5) {
|
||||
list7.add(dataHarmPowerP);
|
||||
}
|
||||
if (hasData6) {
|
||||
list8.add(dataHarmPowerQ);
|
||||
}
|
||||
if (hasData7) {
|
||||
list9.add(dataHarmPowerS);
|
||||
}
|
||||
if (hasData8) {
|
||||
list10.add(dataHarmRateV);
|
||||
}
|
||||
if (hasData9) {
|
||||
list11.add(dataHarmRateI);
|
||||
}
|
||||
if (hasData10) {
|
||||
list12.add(dataInHarmV);
|
||||
}
|
||||
if (hasData11) {
|
||||
list13.add(dataPlt);
|
||||
}
|
||||
if (hasData12) {
|
||||
list14.add(pqdData);
|
||||
}
|
||||
}
|
||||
|
||||
map3.put("data_v", list1);
|
||||
map3.put("data_i", list2);
|
||||
map3.put("data_flicker", list3);
|
||||
map3.put("data_fluc", list4);
|
||||
map3.put("data_harmphasic_i", list5);
|
||||
map3.put("data_harmphasic_v", list6);
|
||||
map3.put("data_harmpower_p", list7);
|
||||
map3.put("data_harmpower_q", list8);
|
||||
map3.put("data_harmpower_s", list9);
|
||||
map3.put("data_harmrate_v", list10);
|
||||
map3.put("data_harmrate_i", list11);
|
||||
map3.put("data_inharm_v", list12);
|
||||
map3.put("data_plt", list13);
|
||||
map3.put("pqd_data", list14);
|
||||
return map3;
|
||||
}
|
||||
|
||||
|
||||
private Map<String, Object> extractFieldValues(PqdData pqdData) {
|
||||
Map<String, Object> fieldValues = new HashMap<>();
|
||||
Field[] fields = PqdData.class.getDeclaredFields();
|
||||
|
||||
for (Field field : fields) {
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
Object value = field.get(pqdData);
|
||||
if (value != null) {
|
||||
fieldValues.put(field.getName(), value);
|
||||
} else {
|
||||
fieldValues.put(field.getName(), 0.0d);
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
log.warn("获取字段 {} 的值失败", field.getName(), e);
|
||||
}
|
||||
}
|
||||
return fieldValues;
|
||||
}
|
||||
|
||||
|
||||
private boolean isCommonField(String fieldName) {
|
||||
Set<String> commonFields = new HashSet<>(Arrays.asList(
|
||||
"time", "lineId", "phasicType", "valueType", "clDid",
|
||||
"process", "qualityFlag"
|
||||
));
|
||||
return commonFields.contains(fieldName);
|
||||
}
|
||||
|
||||
private void setFieldValue(Object obj, String fieldName, Object value, boolean isCamelCase) {
|
||||
try {
|
||||
String camelCaseFieldName = fieldName;
|
||||
if (isCamelCase) {
|
||||
camelCaseFieldName = toCamelCase(fieldName);
|
||||
}
|
||||
Field field = obj.getClass().getDeclaredField(camelCaseFieldName);
|
||||
field.setAccessible(true);
|
||||
if (value == null) {
|
||||
Class<?> fieldType = field.getType();
|
||||
if (fieldType == Double.class || fieldType == double.class) {
|
||||
value = 0.0D;
|
||||
} else if (fieldType == Integer.class || fieldType == int.class) {
|
||||
value = 0;
|
||||
} else if (fieldType == Float.class || fieldType == float.class) {
|
||||
value = 0.0F;
|
||||
} else if (fieldType == Long.class || fieldType == long.class) {
|
||||
value = 0L;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
field.set(obj, value);
|
||||
} catch (NoSuchFieldException | IllegalAccessException | IllegalArgumentException e) {
|
||||
log.warn("设置字段 {} 的值失败", fieldName, e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static String toCamelCase(String input) {
|
||||
if (input == null || input.isEmpty()) {
|
||||
return input;
|
||||
}
|
||||
StringBuilder result = new StringBuilder();
|
||||
boolean toUpper = false;
|
||||
|
||||
for (char c : input.toCharArray()) {
|
||||
if (c == '_') {
|
||||
toUpper = true;
|
||||
} else {
|
||||
if (toUpper) {
|
||||
result.append(Character.toUpperCase(c));
|
||||
toUpper = false;
|
||||
} else {
|
||||
result.append(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
// 确保首字母小写,以匹配Java实体字段命名规范
|
||||
if (result.length() > 0 && Character.isUpperCase(result.charAt(0))) {
|
||||
result.setCharAt(0, Character.toLowerCase(result.charAt(0)));
|
||||
}
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
private EleEpdPqd copyEleEpdPqd(EleEpdPqd source) {
|
||||
if (source == null) {
|
||||
return null;
|
||||
}
|
||||
EleEpdPqd target = new EleEpdPqd();
|
||||
BeanUtils.copyProperties(source, target);
|
||||
return target;
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,6 @@ package com.njcn.csdevice.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.dynamic.datasource.annotation.DS;
|
||||
import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
@@ -79,17 +78,11 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
|
||||
RStatIntegrityD data = new RStatIntegrityD();
|
||||
//治理监测点
|
||||
if (item.getClDid() == 0) {
|
||||
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"apf_data","Apf_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
|
||||
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"apf_data","Apf_Freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
|
||||
}
|
||||
else {
|
||||
//云前置监测点
|
||||
if (ObjectUtil.isNotNull(item.getLineNo())) {
|
||||
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
|
||||
}
|
||||
//治理、无线监测点
|
||||
else {
|
||||
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"pqd_data","Pq_Freq","value","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
|
||||
}
|
||||
//云前置监测点 && 治理、无线监测点
|
||||
statisticalDataDTO = commonService.getDataCounts(item.getLineId(),"data_v","freq","value","T","AVG",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
|
||||
}
|
||||
data.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));
|
||||
data.setLineIndex(item.getLineId());
|
||||
|
||||
@@ -132,7 +132,8 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
|
||||
}
|
||||
}
|
||||
} else {
|
||||
onlineMinutes = 0;
|
||||
//如果设备连一条记录没有,那就根本没接入,不需要统计
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,417 +0,0 @@
|
||||
package com.njcn.csdevice.service.impl;
|
||||
|
||||
import com.alibaba.nacos.shaded.com.google.gson.Gson;
|
||||
import com.alibaba.nacos.shaded.com.google.gson.JsonObject;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.csdevice.mapper.CsSmsSendRecordMapper;
|
||||
import com.njcn.csdevice.pojo.dto.CredentialReqDTO;
|
||||
import com.njcn.csdevice.pojo.dto.SendResult;
|
||||
import com.njcn.csdevice.pojo.po.CsSmsSendRecord;
|
||||
import com.njcn.csdevice.pojo.vo.MessageRecordReqVO;
|
||||
import com.njcn.csdevice.service.ISmsSendService;
|
||||
import com.njcn.redis.utils.RedisUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.net.ConnectException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.SocketTimeoutException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class SmsSendServiceImpl extends ServiceImpl<CsSmsSendRecordMapper, CsSmsSendRecord> implements ISmsSendService {
|
||||
|
||||
@Value("${msg.credential_url:http://192.168.2.126:48083/admin-api/push/credential/generate}")
|
||||
private String CREDENTIAL_URL;
|
||||
@Value("${msg.sms_send_url:http://192.168.2.126:48083/admin-api/push/message/send/sms}")
|
||||
private String SMS_SEND_URL;
|
||||
@Value("${msg.connect_timeout:5000}")
|
||||
private Integer CONNECT_TIMEOUT;
|
||||
@Value("${msg.read_timeout:30000}")
|
||||
private Integer READ_TIMEOUT;
|
||||
@Value("${msg.system_name:NPQS-9500}")
|
||||
private String SYSTEM_NAME;
|
||||
@Value("${msg.secret_key:123456}")
|
||||
private String SECRET_KEY;
|
||||
|
||||
private static final int[] RETRY_DELAYS = {1, 2, 3};
|
||||
private static final int MAX_RETRY = 3;
|
||||
private static final String CREDENTIAL_CACHE_KEY = "SMS_CREDENTIAL_TOKEN";
|
||||
private static final Gson GSON = new Gson();
|
||||
|
||||
@Resource
|
||||
private RedisUtil redisUtil;
|
||||
|
||||
@Override
|
||||
public void sendSmsWithRetry(String receiver, String content, String messageType) {
|
||||
MessageRecordReqVO vo = new MessageRecordReqVO();
|
||||
vo.setReceiver(receiver);
|
||||
vo.setContent(content);
|
||||
vo.setMessageType(messageType);
|
||||
sendSmsWithRetry(vo);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSmsWithRetry(MessageRecordReqVO messageRecordReqVO) {
|
||||
CsSmsSendRecord record = initRecord(messageRecordReqVO);
|
||||
|
||||
this.save(record);
|
||||
|
||||
try {
|
||||
String credentialToken = getOrRefreshCredentialWithRetry(record);
|
||||
|
||||
if (credentialToken == null) {
|
||||
record.setSendStatus(0);
|
||||
record.setFailReason("获取凭证失败,已重试3次");
|
||||
log.error("获取凭证失败,短信未发送,接收者: {}", messageRecordReqVO.getReceiver());
|
||||
this.updateById(record);
|
||||
throw new BusinessException("获取凭证失败,已重试3次");
|
||||
}
|
||||
|
||||
record.setCredentialToken(credentialToken);
|
||||
record.setSendTime(LocalDateTime.now());
|
||||
this.updateById(record);
|
||||
|
||||
boolean success = attemptSendWithRetry(messageRecordReqVO, credentialToken, record);
|
||||
|
||||
if (success) {
|
||||
record.setSendStatus(1);
|
||||
record.setFailReason(null);
|
||||
log.info("短信发送成功,接收者: {}", messageRecordReqVO.getReceiver());
|
||||
} else {
|
||||
record.setSendStatus(0);
|
||||
if (record.getFailReason() == null) {
|
||||
record.setFailReason("超过最大重试次数,发送失败");
|
||||
}
|
||||
log.error("短信发送失败,接收者: {},已重试{}次,原因: {}",
|
||||
messageRecordReqVO.getReceiver(), record.getRetryCount(), record.getFailReason());
|
||||
throw new BusinessException("短信发送失败: " + record.getFailReason());
|
||||
}
|
||||
} catch (BusinessException e) {
|
||||
record.setSendStatus(0);
|
||||
record.setFailReason(e.getMessage());
|
||||
log.error("短信发送业务异常,接收者: {}", messageRecordReqVO.getReceiver(), e);
|
||||
this.updateById(record);
|
||||
throw e;
|
||||
} catch (Exception e) {
|
||||
record.setSendStatus(0);
|
||||
record.setFailReason("发送异常: " + e.getMessage());
|
||||
log.error("短信发送异常,接收者: {}", messageRecordReqVO.getReceiver(), e);
|
||||
this.updateById(record);
|
||||
throw new BusinessException("短信发送异常: " + e.getMessage());
|
||||
} finally {
|
||||
this.updateById(record);
|
||||
}
|
||||
}
|
||||
|
||||
private CsSmsSendRecord initRecord(MessageRecordReqVO vo) {
|
||||
CsSmsSendRecord record = new CsSmsSendRecord();
|
||||
record.setReceiver(vo.getReceiver());
|
||||
record.setContent(vo.getContent());
|
||||
record.setMessageType(vo.getMessageType());
|
||||
record.setSendStatus(-1);
|
||||
record.setRetryCount(0);
|
||||
record.setMaxRetry(MAX_RETRY);
|
||||
record.setCreateTime(LocalDateTime.now());
|
||||
return record;
|
||||
}
|
||||
|
||||
private String getOrRefreshCredentialWithRetry(CsSmsSendRecord record) {
|
||||
Object cachedToken = redisUtil.getObjectByKey(CREDENTIAL_CACHE_KEY);
|
||||
if (cachedToken != null) {
|
||||
log.info("使用缓存的凭证令牌");
|
||||
return cachedToken.toString();
|
||||
}
|
||||
|
||||
log.info("缓存中无凭证,开始获取新凭证(最多重试3次)");
|
||||
|
||||
for (int i = 1; i <= 3; i++) {
|
||||
try {
|
||||
String token = fetchNewCredential();
|
||||
log.info("第{}次尝试获取凭证成功", i);
|
||||
return token;
|
||||
} catch (Exception e) {
|
||||
log.warn("第{}次获取凭证失败: {}", i, e.getMessage());
|
||||
|
||||
record.setFailReason("获取凭证第" + i + "次失败: " + e.getMessage());
|
||||
this.updateById(record);
|
||||
|
||||
try {
|
||||
int waitSeconds = i * 10;
|
||||
log.info("等待{}秒后重试...", waitSeconds);
|
||||
TimeUnit.SECONDS.sleep(waitSeconds);
|
||||
} catch (InterruptedException ie) {
|
||||
Thread.currentThread().interrupt();
|
||||
log.error("凭证获取重试被中断");
|
||||
record.setFailReason("获取凭证实例被中断");
|
||||
this.updateById(record);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
log.error("获取凭证失败,已重试3次");
|
||||
return null;
|
||||
}
|
||||
|
||||
private String fetchNewCredential() {
|
||||
CredentialReqDTO reqDTO = new CredentialReqDTO();
|
||||
reqDTO.setSystemName(SYSTEM_NAME);
|
||||
reqDTO.setSecretKey(SECRET_KEY);
|
||||
|
||||
HttpURLConnection connection = null;
|
||||
try {
|
||||
URL url = new URL(CREDENTIAL_URL);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT);
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setDoOutput(true);
|
||||
|
||||
OutputStream outputStream = connection.getOutputStream();
|
||||
outputStream.write(GSON.toJson(reqDTO).getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
if (responseCode != 200) {
|
||||
throw new BusinessException("获取凭证失败,HTTP响应码: " + responseCode);
|
||||
}
|
||||
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8));
|
||||
StringBuilder response = new StringBuilder();
|
||||
String inputLine;
|
||||
while ((inputLine = reader.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
JsonObject jsonResponse = GSON.fromJson(response.toString(), JsonObject.class);
|
||||
int code = jsonResponse.get("code").getAsInt();
|
||||
|
||||
if (code != 0) {
|
||||
String msg = jsonResponse.has("msg") ? jsonResponse.get("msg").getAsString() : "未知错误";
|
||||
throw new BusinessException("获取凭证失败,错误码: " + code + ",错误信息: " + msg);
|
||||
}
|
||||
|
||||
JsonObject data = jsonResponse.getAsJsonObject("data");
|
||||
String token = data.get("credentialToken").getAsString();
|
||||
long expiresTimestamp = data.get("expiresTime").getAsLong();
|
||||
|
||||
LocalDateTime expiresTime = LocalDateTime.ofInstant(
|
||||
Instant.ofEpochMilli(expiresTimestamp),
|
||||
ZoneId.systemDefault()
|
||||
);
|
||||
|
||||
long expireSeconds = calculateExpireSeconds(expiresTime);
|
||||
redisUtil.saveByKeyWithExpire(CREDENTIAL_CACHE_KEY, token, expireSeconds);
|
||||
|
||||
log.info("获取新凭证成功,过期时间: {},缓存有效期: {}秒", expiresTime, expireSeconds);
|
||||
return token;
|
||||
|
||||
} catch (SocketTimeoutException e) {
|
||||
throw new BusinessException("获取凭证超时(30秒),请检查网络连接");
|
||||
} catch (ConnectException e) {
|
||||
throw new BusinessException("无法连接到凭证服务,请检查服务是否启动和网络是否正常");
|
||||
} catch (IOException e) {
|
||||
throw new BusinessException("获取凭证IO异常: " + e.getMessage());
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private long calculateExpireSeconds(LocalDateTime expiresTime) {
|
||||
long expireSeconds = java.time.Duration.between(
|
||||
LocalDateTime.now(),
|
||||
expiresTime
|
||||
).getSeconds();
|
||||
|
||||
expireSeconds = expireSeconds - 60;
|
||||
|
||||
return Math.max(expireSeconds, 60);
|
||||
}
|
||||
|
||||
private boolean attemptSendWithRetry(MessageRecordReqVO vo, String token, CsSmsSendRecord record) {
|
||||
for (int attempt = 0; attempt <= MAX_RETRY; attempt++) {
|
||||
if (attempt > 0) {
|
||||
int delayMinutes = RETRY_DELAYS[attempt - 1];
|
||||
log.info("第{}次重试,等待{}分钟后发送...", attempt, delayMinutes);
|
||||
|
||||
try {
|
||||
TimeUnit.MINUTES.sleep(delayMinutes);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
log.error("重试等待被中断", e);
|
||||
record.setFailReason("重试等待被中断");
|
||||
return false;
|
||||
}
|
||||
record.setRetryCount(attempt);
|
||||
}
|
||||
|
||||
SendResult result = executeSendSms(vo, token, record);
|
||||
|
||||
if (result.isSuccess()) {
|
||||
record.setFailReason(null);
|
||||
log.info("第{}次尝试发送成功,消息ID: {}", attempt, result.getMessageId());
|
||||
return true;
|
||||
}
|
||||
|
||||
record.setFailReason(result.getFailReason());
|
||||
|
||||
if (result.isUnauthorized()) {
|
||||
log.warn("凭证失效(401),重新获取凭证后重试...");
|
||||
String newToken = getOrRefreshCredentialWithRetry(record);
|
||||
if (newToken == null) {
|
||||
record.setFailReason("凭证刷新失败,无法重新获取凭证");
|
||||
return false;
|
||||
}
|
||||
token = newToken;
|
||||
record.setCredentialToken(newToken);
|
||||
this.updateById(record);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!result.isTimeOut()) {
|
||||
log.warn("发送失败且非超时,不再重试,原因: {},响应时间: {}ms",
|
||||
result.getFailReason(), record.getResponseTime());
|
||||
return false;
|
||||
}
|
||||
|
||||
log.warn("第{}次发送超时,将重试,响应时间: {}ms",
|
||||
attempt, record.getResponseTime());
|
||||
}
|
||||
|
||||
record.setFailReason("超过最大重试次数,发送超时");
|
||||
return false;
|
||||
}
|
||||
|
||||
private SendResult executeSendSms(MessageRecordReqVO vo, String token, CsSmsSendRecord record) {
|
||||
HttpURLConnection connection = null;
|
||||
long startTime = System.currentTimeMillis();
|
||||
|
||||
try {
|
||||
URL url = new URL(SMS_SEND_URL);
|
||||
connection = (HttpURLConnection) url.openConnection();
|
||||
connection.setRequestMethod("POST");
|
||||
connection.setRequestProperty("Content-Type", "application/json");
|
||||
connection.setRequestProperty("X-Credential-Token", token);
|
||||
connection.setConnectTimeout(CONNECT_TIMEOUT);
|
||||
connection.setReadTimeout(READ_TIMEOUT);
|
||||
connection.setDoOutput(true);
|
||||
|
||||
OutputStream outputStream = connection.getOutputStream();
|
||||
outputStream.write(GSON.toJson(Collections.singletonList(vo)).getBytes(StandardCharsets.UTF_8));
|
||||
outputStream.flush();
|
||||
outputStream.close();
|
||||
|
||||
int responseCode = connection.getResponseCode();
|
||||
long responseTime = System.currentTimeMillis() - startTime;
|
||||
record.setResponseTime(responseTime);
|
||||
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
responseCode == 200 ? connection.getInputStream() : connection.getErrorStream(),
|
||||
StandardCharsets.UTF_8
|
||||
)
|
||||
);
|
||||
StringBuilder response = new StringBuilder();
|
||||
String inputLine;
|
||||
while ((inputLine = reader.readLine()) != null) {
|
||||
response.append(inputLine);
|
||||
}
|
||||
reader.close();
|
||||
|
||||
if (responseCode != 200) {
|
||||
String failReason = "HTTP响应码异常: " + responseCode;
|
||||
if (response.length() > 0) {
|
||||
failReason += ",响应: " + response.toString();
|
||||
}
|
||||
record.setFailReason(failReason);
|
||||
return new SendResult(false, null, failReason, false, false);
|
||||
}
|
||||
|
||||
JsonObject jsonResponse = GSON.fromJson(response.toString(), JsonObject.class);
|
||||
int code = jsonResponse.get("code").getAsInt();
|
||||
|
||||
if (code == 401) {
|
||||
String failReason = "凭证失效(HTTP 401)";
|
||||
record.setFailReason(failReason);
|
||||
redisUtil.delete(CREDENTIAL_CACHE_KEY);
|
||||
return new SendResult(false, null, failReason, false, true);
|
||||
} else {
|
||||
if (code != 0) {
|
||||
String msg = jsonResponse.has("msg") ? jsonResponse.get("msg").getAsString() : "未知错误";
|
||||
String failReason = "业务错误码: " + code + ",错误信息: " + msg;
|
||||
record.setFailReason(failReason);
|
||||
return new SendResult(false, null, failReason, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
JsonObject firstResult = jsonResponse.getAsJsonArray("data").get(0).getAsJsonObject();
|
||||
boolean result = firstResult.get("result").getAsBoolean();
|
||||
String messageId = firstResult.has("messageId") ? firstResult.get("messageId").getAsString() : null;
|
||||
String detail = firstResult.has("detail") ? firstResult.get("detail").getAsString() : null;
|
||||
|
||||
if (result) {
|
||||
log.info("短信发送成功,接收者: {},消息ID: {},详情: {},耗时: {}ms",
|
||||
vo.getReceiver(), messageId, detail, responseTime);
|
||||
return new SendResult(true, messageId, null, false, false);
|
||||
} else {
|
||||
String failReason = "发送失败: " + detail;
|
||||
record.setFailReason(failReason);
|
||||
return new SendResult(false, messageId, failReason, false, false);
|
||||
}
|
||||
|
||||
} catch (SocketTimeoutException e) {
|
||||
long responseTime = System.currentTimeMillis() - startTime;
|
||||
record.setResponseTime(responseTime);
|
||||
String failReason = "请求超时(30秒)";
|
||||
record.setFailReason(failReason);
|
||||
log.warn("短信发送超时,接收者: {},耗时: {}ms", vo.getReceiver(), responseTime);
|
||||
return new SendResult(false, null, failReason, true, false);
|
||||
} catch (ConnectException e) {
|
||||
long responseTime = System.currentTimeMillis() - startTime;
|
||||
record.setResponseTime(responseTime);
|
||||
String failReason = "无法连接到短信服务";
|
||||
record.setFailReason(failReason);
|
||||
log.error("短信服务连接失败,接收者: {}", vo.getReceiver(), e);
|
||||
return new SendResult(false, null, failReason, false, false);
|
||||
} catch (IOException e) {
|
||||
long responseTime = System.currentTimeMillis() - startTime;
|
||||
record.setResponseTime(responseTime);
|
||||
String failReason = "IO异常: " + e.getMessage();
|
||||
record.setFailReason(failReason);
|
||||
log.error("短信发送IO异常,接收者: {},耗时: {}ms", vo.getReceiver(), responseTime, e);
|
||||
return new SendResult(false, null, failReason, false, false);
|
||||
} finally {
|
||||
if (connection != null) {
|
||||
connection.disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -466,7 +466,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
if(param.getStatisticalId() == null){
|
||||
continue;
|
||||
}
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(param.getStatisticalId()).getData();
|
||||
List<EleEpdPqd> eleEpdPqds = csStatisticalSetFeignClient.queryStatisticalSelect(Collections.singletonList(param.getStatisticalId())).getData();
|
||||
for(WlRecord wl : data){
|
||||
List<CsLinePO> finalCsLinePOList = csLineFeignClient.queryLineById(Arrays.asList(wl.getLineId())).getData();
|
||||
CsDataSet csDataSet = csDataSetMapper.selectOne(new LambdaQueryWrapper<CsDataSet>().eq(CsDataSet::getId,finalCsLinePOList.get(0).getDataSetId()));
|
||||
@@ -482,11 +482,15 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
CommonQueryParam commonQueryParam = new CommonQueryParam();
|
||||
commonQueryParam.setLineId(temp.getLineId());
|
||||
commonQueryParam.setTableName(influxDbParamUtil.getTableNameByClassId(epdPqd.getClassId()));
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
|
||||
if (epdPqd.getName() == null || epdPqd.getName().isEmpty()) {
|
||||
commonQueryParam.setColumnName(epdPqd.getName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
|
||||
} else {
|
||||
commonQueryParam.setColumnName(epdPqd.getOtherName()+ (param.getFrequency() == null ? "":"_"+param.getFrequency()));
|
||||
}
|
||||
commonQueryParam.setPhasic(epdPqd.getPhase());
|
||||
commonQueryParam.setStartTime(LocalDateTimeUtil.format(wl.getStartTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
|
||||
commonQueryParam.setEndTime(LocalDateTimeUtil.format(wl.getEndTime(), DateTimeFormatter.ofPattern(DataParam.timeFormat)));
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType());
|
||||
commonQueryParam.setDataType(commonStatisticalQueryParam.getValueType().toUpperCase());
|
||||
commonQueryParam.setProcess(data1.get(0).getProcess()+"");
|
||||
commonQueryParam.setClDid(influxDbParamUtil.getClDidByLineId(temp.getLineId()));
|
||||
return commonQueryParam;
|
||||
@@ -500,7 +504,7 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
String unit;
|
||||
ThdDataVO vo = new ThdDataVO();
|
||||
vo.setLineId(temp.getLineId());
|
||||
vo.setPhase(Objects.equals("M",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
vo.setPhase(Objects.equals("T",temp.getPhaseType())?null:temp.getPhaseType());
|
||||
String position = finalCsLinePOList.stream().filter(csLinePO -> Objects.equals(csLinePO.getLineId(), vo.getLineId())).collect(Collectors.toList()).get(0).getPosition();
|
||||
vo.setPosition(position);
|
||||
vo.setTime(temp.getTime());
|
||||
@@ -677,13 +681,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
if(Objects.isNull(list.get(i).getEndTime())){
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
String sqlNow = now.format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("data_v",StatisticalDataDTO.class);
|
||||
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
||||
.select(StatisticalDataDTO::getPhaseType)
|
||||
.select(StatisticalDataDTO::getValueType)
|
||||
.last("Pq_Freq")
|
||||
.last("freq")
|
||||
.eq(InfluxDBTableConstant.LINE_ID,lineId)
|
||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
|
||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,"T")
|
||||
.between(InfluxDBTableConstant.TIME,startSql,sqlNow);
|
||||
System.out.println(influxQueryWrapper.generateSql());
|
||||
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);
|
||||
@@ -704,13 +708,13 @@ public class WlRecordServiceImpl extends ServiceImpl<WlRecordMapper, WlRecord> i
|
||||
//如果不存在结束时间,则取后面一条的起始时间作为结束判断标识
|
||||
if(Objects.isNull(list.get(i).getEndTime())){
|
||||
String end = list.get(i+1).getStartTime().format(DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN));
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("pqd_data",StatisticalDataDTO.class);
|
||||
InfluxQueryWrapper influxQueryWrapper = new InfluxQueryWrapper("data_v",StatisticalDataDTO.class);
|
||||
influxQueryWrapper.select(StatisticalDataDTO::getLineId)
|
||||
.select(StatisticalDataDTO::getPhaseType)
|
||||
.select(StatisticalDataDTO::getValueType)
|
||||
.last("Pq_Freq")
|
||||
.last("freq")
|
||||
.eq(InfluxDBTableConstant.LINE_ID,lineId)
|
||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,"M")
|
||||
.eq(InfluxDBTableConstant.PHASIC_TYPE,"T")
|
||||
.between(InfluxDBTableConstant.TIME,startSql,end);
|
||||
System.out.println(influxQueryWrapper.generateSql());
|
||||
StatisticalDataDTO statisticalDataDTO = commonMapper.getLineRtData(influxQueryWrapper);
|
||||
|
||||
@@ -8,7 +8,7 @@ microservice:
|
||||
gateway:
|
||||
url: @gateway.url@
|
||||
server:
|
||||
port: 10220
|
||||
port: 20220
|
||||
#feign接口开启服务熔断降级处理
|
||||
feign:
|
||||
sentinel:
|
||||
@@ -21,9 +21,13 @@ spring:
|
||||
discovery:
|
||||
ip: @service.server.url@
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
config:
|
||||
server-addr: @nacos.url@
|
||||
username: @nacos.username@
|
||||
password: @nacos.password@
|
||||
namespace: @nacos.namespace@
|
||||
file-extension: yaml
|
||||
shared-configs:
|
||||
@@ -41,9 +45,10 @@ spring:
|
||||
|
||||
#项目日志的配置
|
||||
logging:
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&username=@nacos.username@&password=@nacos.password@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
# config: http://@nacos.url@/nacos/v1/cs/configs?tenant=@nacos.namespace@&group=DEFAULT_GROUP&dataId=logback.xml
|
||||
level:
|
||||
root: info
|
||||
root: warn
|
||||
|
||||
data:
|
||||
source:
|
||||
|
||||
@@ -3,12 +3,12 @@ package com.njcn;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.njcn.csdevice.CsDeviceBootApplication;
|
||||
import com.njcn.csdevice.pojo.dto.PqsCommunicateDto;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.service.*;
|
||||
import com.njcn.influx.pojo.po.PqsCommunicate;
|
||||
import com.njcn.influx.query.InfluxQueryWrapper;
|
||||
import com.njcn.csdevice.service.DeviceFtpService;
|
||||
import com.njcn.csdevice.service.ICsCommunicateService;
|
||||
import com.njcn.csdevice.service.IRStatIntegrityDService;
|
||||
import com.njcn.csdevice.service.IRStatOnlineRateDService;
|
||||
import com.njcn.influx.utils.InfluxDbUtils;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.influxdb.InfluxDB;
|
||||
@@ -20,12 +20,15 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit4.SpringRunner;
|
||||
import org.springframework.test.context.web.WebAppConfiguration;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static org.junit.Assert.assertTrue;
|
||||
@@ -37,7 +40,7 @@ import static org.junit.Assert.assertTrue;
|
||||
@WebAppConfiguration
|
||||
@SpringBootTest(classes = CsDeviceBootApplication.class)
|
||||
@Slf4j
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AppTest{
|
||||
|
||||
@Autowired
|
||||
@@ -46,9 +49,69 @@ public class AppTest{
|
||||
@Autowired
|
||||
private ICsCommunicateService csCommunicateService;
|
||||
|
||||
private final IRStatIntegrityDService statIntegrityDService;
|
||||
private final IRStatOnlineRateDService statOnlineRateDService;
|
||||
@Autowired
|
||||
private IRStatIntegrityDService statIntegrityDService;
|
||||
|
||||
@Autowired
|
||||
private IRStatOnlineRateDService statOnlineRateDService;
|
||||
|
||||
public static void main(String[] args) {
|
||||
String eventValue = "122.5493";
|
||||
String persistTime = "0.2410";
|
||||
String data = determineDropZone(eventValue, persistTime);
|
||||
System.out.println("data==:" + data);
|
||||
}
|
||||
|
||||
|
||||
public static String determineDropZone(String eventValue, String persistTime) {
|
||||
if (eventValue != null && !eventValue.trim().isEmpty() && persistTime != null && !persistTime.trim().isEmpty()) {
|
||||
BigDecimal vvm;
|
||||
BigDecimal vvtm;
|
||||
try {
|
||||
vvm = (new BigDecimal(eventValue.trim())).divide(new BigDecimal("100"), 6, RoundingMode.HALF_UP);
|
||||
vvtm = new BigDecimal(persistTime.trim());
|
||||
} catch (Exception var6) {
|
||||
Exception e = var6;
|
||||
log.error("判定压降落点区域入参解析失败,eventValue={}, persistTime={}", new Object[]{eventValue, persistTime, e});
|
||||
return null;
|
||||
}
|
||||
|
||||
if (vvtm.compareTo(new BigDecimal("0.001")) >= 0 && vvm.compareTo(BigDecimal.ZERO) != 0) {
|
||||
if (inRange(vvm, "0.9", "1") && inRange(vvtm, "0.001", "60")) {
|
||||
return "A区";
|
||||
} else if (inRange(vvm, "0", "0.9") && inRange(vvtm, "0.001", "0.05")) {
|
||||
return "A区";
|
||||
} else if (inRange(vvm, "0.5", "0.7") && inRange(vvtm, "0.05", "0.2")) {
|
||||
return "B区";
|
||||
} else if (inRange(vvm, "0.7", "0.8") && inRange(vvtm, "0.05", "0.5")) {
|
||||
return "B区";
|
||||
} else if (inRange(vvm, "0.8", "0.9") && inRange(vvtm, "0.05", "60")) {
|
||||
return "B区";
|
||||
} else if (inRange(vvm, "0", "0.5") && inRange(vvtm, "0.05", "1")) {
|
||||
return "C区";
|
||||
} else if (inRange(vvm, "0.5", "0.7") && inRange(vvtm, "0.2", "1")) {
|
||||
return "C区";
|
||||
} else if (inRange(vvm, "0.7", "0.8") && inRange(vvtm, "0.5", "1")) {
|
||||
return "C区";
|
||||
} else if (inRange(vvm, "0", "0.8") && inRange(vvtm, "1", "60")) {
|
||||
return "D区";
|
||||
} else {
|
||||
log.warn("压降落点区域未匹配任何规则,eventValue={}, persistTime={}", eventValue, persistTime);
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return "A区";
|
||||
}
|
||||
} else {
|
||||
log.warn("判定压降落点区域入参为空,eventValue={}, persistTime={}", eventValue, persistTime);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean inRange(BigDecimal value, String lowerInclusive, String upperExclusive) {
|
||||
return value.compareTo(new BigDecimal(lowerInclusive)) >= 0
|
||||
&& value.compareTo(new BigDecimal(upperExclusive)) < 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Rigorous Test :-)
|
||||
@@ -59,7 +122,6 @@ public class AppTest{
|
||||
assertTrue( true );
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 测试下载文件
|
||||
*/
|
||||
@@ -95,18 +157,76 @@ public class AppTest{
|
||||
}
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "123456", "http://192.168.1.24:8086", "pqsbase_zl", "");
|
||||
|
||||
|
||||
public static void test2() {
|
||||
InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "123456", "http://192.168.1.103:18086", "pqsbase", "");
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put("dev_id","da7aa071bf89864bedea8833133676b7");
|
||||
tags.put("dev_id","0eb0262f706445ac9c69931a60357561");
|
||||
Map<String,Object> fields = new HashMap<>();
|
||||
fields.put("type",1);
|
||||
fields.put("description","通讯正常");
|
||||
long time = LocalDateTime.parse("2025-08-02 18:00:00", DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
// fields.put("type",1);
|
||||
// fields.put("description","通讯正常");
|
||||
fields.put("type",0);
|
||||
fields.put("description","通讯中断");
|
||||
long time = LocalDateTime.parse("2024-01-06 06:00:00", DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
Point point = influxDbUtils.pointBuilder("pqs_communicate", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, Collections.singletonList(batchPoints.lineProtocol()));
|
||||
|
||||
}
|
||||
|
||||
public static void test22() {
|
||||
InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "123456", "http://192.168.1.103:18086", "pqsbase", "");
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put("dev_id","0eb0262f706445ac9c69931a60357561");
|
||||
Map<String,Object> fields = new HashMap<>();
|
||||
fields.put("type",1);
|
||||
fields.put("description","通讯正常");
|
||||
// fields.put("type",0);
|
||||
// fields.put("description","通讯中断");
|
||||
long time = LocalDateTime.parse("2024-01-06 12:00:00", DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
Point point = influxDbUtils.pointBuilder("pqs_communicate", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, Collections.singletonList(batchPoints.lineProtocol()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void test3() {
|
||||
InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "123456", "http://192.168.1.103:18086", "pqsbase", "");
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put("dev_id","0eb0262f706445ac9c69931a60357561");
|
||||
Map<String,Object> fields = new HashMap<>();
|
||||
fields.put("type",0);
|
||||
fields.put("description","通讯中断");
|
||||
// fields.put("type",1);
|
||||
// fields.put("description","通讯正常");
|
||||
long time = LocalDateTime.parse("2024-01-06 18:00:00", DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
Point point = influxDbUtils.pointBuilder("pqs_communicate", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, Collections.singletonList(batchPoints.lineProtocol()));
|
||||
|
||||
}
|
||||
|
||||
public static void test33() {
|
||||
InfluxDbUtils influxDbUtils = new InfluxDbUtils("admin", "123456", "http://192.168.1.103:18086", "pqsbase", "");
|
||||
Map<String, String> tags = new HashMap<>();
|
||||
tags.put("dev_id","0eb0262f706445ac9c69931a60357561");
|
||||
Map<String,Object> fields = new HashMap<>();
|
||||
// fields.put("type",0);
|
||||
// fields.put("description","通讯中断");
|
||||
fields.put("type",1);
|
||||
fields.put("description","通讯正常");
|
||||
long time = LocalDateTime.parse("2024-01-06 22:00:00", DateTimeFormatter.ofPattern(DatePattern.NORM_DATETIME_PATTERN)).atZone(ZoneId.systemDefault()).toInstant().toEpochMilli();
|
||||
Point point = influxDbUtils.pointBuilder("pqs_communicate", time, TimeUnit.MILLISECONDS, tags, fields);
|
||||
BatchPoints batchPoints = BatchPoints.database(influxDbUtils.getDbName()).retentionPolicy("").consistency(InfluxDB.ConsistencyLevel.ALL).build();
|
||||
batchPoints.point(point);
|
||||
influxDbUtils.batchInsert(influxDbUtils.getDbName(), "", InfluxDB.ConsistencyLevel.ALL, TimeUnit.MILLISECONDS, Collections.singletonList(batchPoints.lineProtocol()));
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -9,6 +9,8 @@ import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@@ -19,4 +21,8 @@ public interface CsHarmonicPlanFeignClient {
|
||||
@ApiOperation("根据ID查询稳态指标方案")
|
||||
HttpResult<CsHarmonicPlan> getById(@RequestParam("id") String id);
|
||||
|
||||
@GetMapping("/getByName")
|
||||
@ApiOperation("根据名称查询稳态指标方案")
|
||||
HttpResult<List<CsHarmonicPlan>> getByName(@RequestParam("name") String name);
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,17 @@ 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.CsHarmonicPlanLineFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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
|
||||
*/
|
||||
@@ -18,4 +24,12 @@ public interface CsHarmonicPlanLineFeignClient {
|
||||
@ApiOperation("根据监测点ID查询方案ID")
|
||||
HttpResult<String> getPlanIdByLineId(@RequestParam("lineId") String lineId);
|
||||
|
||||
@PostMapping("/savePlanLines")
|
||||
@ApiOperation("新增方案与监测点关联")
|
||||
HttpResult<Boolean> savePlanLines(@RequestBody @Validated CsHarmonicPlanLineParam param);
|
||||
|
||||
@PostMapping("/deleteByLineIds")
|
||||
@ApiOperation("根据监测点ID集合删除关联")
|
||||
HttpResult<Boolean> deleteByLineIds(@RequestBody List<String> lineIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,12 @@
|
||||
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.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csharmonic.api.fallback.EventUserFeignClientFallbackFactory;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventPO;
|
||||
import com.njcn.csharmonic.pojo.po.CsEventUserPO;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
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.PqGovernPlanClientFallbackFactory;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.cloud.openfeign.FeignClient;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
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 = "/pqGovernPlan", fallbackFactory = PqGovernPlanClientFallbackFactory.class,contextId = "pqGovernPlan")
|
||||
|
||||
public interface PqGovernPlanFeignClient {
|
||||
|
||||
@GetMapping("/getListExcludeNull")
|
||||
@ApiOperation("查询所有治理方案(剔除治理前后监测点为空的数据)")
|
||||
HttpResult<List<PqGovernPlan>> getListExcludeNull();
|
||||
|
||||
@PostMapping("/getListByMonitorPoint")
|
||||
@ApiOperation("清空治理前后监测点数据")
|
||||
HttpResult<List<PqGovernPlan>> getListByMonitorPoint(@RequestBody List<String> ids);
|
||||
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据ID查询治理方案")
|
||||
HttpResult<PqGovernPlan> getById(@RequestParam("id") String id);
|
||||
|
||||
}
|
||||
@@ -3,9 +3,7 @@ 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.api.CsHarmonicPlanFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonic;
|
||||
import com.njcn.csharmonic.pojo.po.CsHarmonicPlan;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -34,6 +32,12 @@ public class CsHarmonicPlanFeignClientFallbackFactory implements FallbackFactory
|
||||
log.error("{}异常,降级处理,异常为:{}","根据ID查询稳态指标方案异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsHarmonicPlan>> getByName(String name) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据名称查询稳态指标方案异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,10 +4,13 @@ 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.CsHarmonicPlanLineFeignClient;
|
||||
import com.njcn.csharmonic.param.CsHarmonicPlanLineParam;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@@ -28,6 +31,18 @@ public class CsHarmonicPlanLineFeignClientFallbackFactory implements FallbackFac
|
||||
log.error("{}异常,降级处理,异常为:{}","根据监测点ID查询方案ID异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> savePlanLines(CsHarmonicPlanLineParam param) {
|
||||
log.error("{}异常,降级处理,异常为:{}","新增方案与监测点关联异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<Boolean> deleteByLineIds(List<String> lineIds) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据监测点ID集合删除关联异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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.PqGovernPlanFeignClient;
|
||||
import com.njcn.csharmonic.pojo.po.PqGovernPlan;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class PqGovernPlanClientFallbackFactory implements FallbackFactory<PqGovernPlanFeignClient> {
|
||||
@Override
|
||||
public PqGovernPlanFeignClient create(Throwable cause) {
|
||||
//判断抛出异常是否为解码器抛出的业务异常
|
||||
Enum<?> exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK;
|
||||
if (cause.getCause() instanceof BusinessException) {
|
||||
BusinessException businessException = (BusinessException) cause.getCause();
|
||||
}
|
||||
Enum<?> finalExceptionEnum = exceptionEnum;
|
||||
return new PqGovernPlanFeignClient() {
|
||||
@Override
|
||||
public HttpResult<List<PqGovernPlan>> getListExcludeNull() {
|
||||
log.error("{}异常,降级处理,异常为:{}","查询所有治理方案异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<PqGovernPlan>> getListByMonitorPoint(List<String> ids) {
|
||||
log.error("{}异常,降级处理,异常为:{}","清空治理前后监测点数据异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<PqGovernPlan> getById(String id) {
|
||||
log.error("{}异常,降级处理,异常为:{}","根据ID查询治理方案异常",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user