Compare commits
40 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0d7d1781e3 | |||
| b794842d33 | |||
| 5e0c2d5cbc | |||
| 6c9a33c05d | |||
| a847f541f1 | |||
| 94b5b92991 | |||
| 882d56a2c5 | |||
| 1629e1c4cc | |||
| 45846e1889 | |||
| 030384333e | |||
| dc9958b249 | |||
| a607437225 | |||
| d277eba5fb | |||
| 913c2ef262 | |||
| 0fe80e12b5 | |||
| ffb6ead753 | |||
| 6782b19b7d | |||
| eeb22c749a | |||
| 31c21a43f4 | |||
| a923978f72 | |||
| 40588c6cd4 | |||
| cb76943f0f | |||
| 660925df31 | |||
| 0ce5840d02 | |||
| 9bd6ca43e1 | |||
| d6056e2cac | |||
| 8d8eb4d274 | |||
| b045860a43 | |||
| c0c3ae4e41 | |||
| 443adfaa37 | |||
| a314b3c862 | |||
| 282a592a13 | |||
| 0f839dfd5b | |||
| 45f706475b | |||
| 0a06d2d5eb | |||
| bba6da3c7d | |||
| 71d59528a3 | |||
| 06de2121f6 | |||
| 65d39224ed | |||
| fda83a1bd9 |
@@ -1,7 +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.CsLedgerFeignClientFallbackFactory;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||
@@ -39,4 +43,9 @@ public interface CsLedgerFeignClient {
|
||||
@PostMapping("/deviceTree")
|
||||
@ApiOperation("三层设备树(装置层)")
|
||||
HttpResult<List<CsLedgerVO>> getDeviceTree();
|
||||
}
|
||||
|
||||
@PostMapping("/getAllLedger")
|
||||
HttpResult<List<CsLedgerVO>> getAllLedger();
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -62,6 +62,12 @@ public class CsLedgerFeignClientFallbackFactory implements FallbackFactory<CsLed
|
||||
log.error("{}异常,降级处理,异常为:{}","查询设备树",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpResult<List<CsLedgerVO>> getAllLedger() {
|
||||
log.error("{}异常,降级处理,异常为:{}","获取台账树所有数据",cause.toString());
|
||||
throw new BusinessException(finalExceptionEnum);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,4 +37,7 @@ public class CsEquipmentDeliveryQueryParm extends BaseParam {
|
||||
@ApiModelProperty("流程步骤")
|
||||
private Integer process;
|
||||
|
||||
@ApiModelProperty("物联通讯状态 0:未连接 1:已连接")
|
||||
private Integer connectStatus;
|
||||
|
||||
}
|
||||
@@ -28,8 +28,17 @@ public class CsLedgerVO implements Serializable {
|
||||
|
||||
@ApiModelProperty(name = "path",value = "拓扑图路径")
|
||||
private String path;
|
||||
|
||||
@ApiModelProperty(name = "provinceId",value = "省Id")
|
||||
private String provinceId;
|
||||
|
||||
|
||||
@ApiModelProperty(name = "cityId",value = "市Id")
|
||||
private String cityId;
|
||||
|
||||
@ApiModelProperty(name = "area",value = "区域")
|
||||
private String area;
|
||||
|
||||
@ApiModelProperty(name = "remark",value = "备注")
|
||||
private String remark;
|
||||
|
||||
@@ -54,6 +63,9 @@ public class CsLedgerVO implements Serializable {
|
||||
@ApiModelProperty(name = "conType",value = "接线方式 0-星型 1-角型 2-V型")
|
||||
private Integer conType;
|
||||
|
||||
@ApiModelProperty(name = "process",value = "流程状态")
|
||||
private Integer process;
|
||||
|
||||
@ApiModelProperty(name = "children",value = "子节点")
|
||||
private List<CsLedgerVO> children = new ArrayList<>();
|
||||
|
||||
|
||||
@@ -20,10 +20,20 @@ public class EachModuleVO implements Serializable {
|
||||
@ApiModelProperty("模块状态")
|
||||
private String moduleState;
|
||||
|
||||
List<harmonicVo> dataList;
|
||||
@ApiModelProperty("模块运行状态数据")
|
||||
List<HarmonicVo> dataList;
|
||||
|
||||
@ApiModelProperty("负载电流数据")
|
||||
List<DataVo> loadList;
|
||||
|
||||
@ApiModelProperty("模块输出电流")
|
||||
List<DataVo> modOutList;
|
||||
|
||||
@ApiModelProperty("模块温度")
|
||||
List<DataVo> temperatureList;
|
||||
|
||||
@Data
|
||||
public static class harmonicVo implements Serializable {
|
||||
public static class HarmonicVo implements Serializable {
|
||||
|
||||
@ApiModelProperty("稳态数据时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@@ -41,4 +51,18 @@ public class EachModuleVO implements Serializable {
|
||||
@ApiModelProperty("事件名称")
|
||||
private String eventName;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class DataVo implements Serializable {
|
||||
|
||||
@ApiModelProperty("稳态数据时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime time;
|
||||
|
||||
@ApiModelProperty("相别")
|
||||
private String phasicType;
|
||||
|
||||
@ApiModelProperty("数据")
|
||||
private Double data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,7 @@ import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.HttpResultUtil;
|
||||
import com.njcn.csdevice.mapper.CsLedgerMapper;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.dto.LineParamDTO;
|
||||
import com.njcn.csdevice.pojo.param.CsLedgerParam;
|
||||
@@ -39,6 +40,7 @@ import java.util.List;
|
||||
public class CsLedgerController extends BaseController {
|
||||
|
||||
private final ICsLedgerService csLedgerService;
|
||||
private final CsLedgerMapper csLedgerMapper;
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/tree")
|
||||
@@ -145,5 +147,14 @@ public class CsLedgerController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, details, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/getAllLedger")
|
||||
@ApiOperation("获取台账树所有数据")
|
||||
public HttpResult<List<CsLedgerVO>> getAllLedger(){
|
||||
String methodDescribe = getMethodDescribe("getAllLedger");
|
||||
List<CsLedgerVO> allList = csLedgerMapper.getAll();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, allList, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -80,4 +80,14 @@ public class AppProjectController extends BaseController {
|
||||
Boolean flag = appProjectService.AuditAppProject(appProjectAuditParm);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/updateProject")
|
||||
@ApiOperation("web修改项目信息")
|
||||
public HttpResult<Boolean> updateProject(@RequestBody @Validated AppProjectAuditParm appProjectAuditParm){
|
||||
String methodDescribe = getMethodDescribe("updateProject");
|
||||
Boolean flag = appProjectService.updateProject(appProjectAuditParm);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, flag, methodDescribe);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.njcn.csdevice.job;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import com.njcn.csdevice.service.IRStatIntegrityDService;
|
||||
import com.njcn.csdevice.service.IRStatOnlineRateDService;
|
||||
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.scheduling.annotation.EnableScheduling;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
|
||||
/**
|
||||
* @author xy
|
||||
*/
|
||||
@Component
|
||||
@EnableScheduling
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class DayDataJob {
|
||||
|
||||
private final IRStatIntegrityDService statIntegrityDService;
|
||||
private final IRStatOnlineRateDService statOnlineRateDService;
|
||||
|
||||
/**
|
||||
* 每天1点计算治理设备的完整性
|
||||
*
|
||||
* @date 2025/7/1
|
||||
*/
|
||||
@Scheduled(cron = "0 0 1 * * ?")
|
||||
public void lineIntegrityJob() {
|
||||
StatisticsDataParam param = new StatisticsDataParam();
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
LocalDateTime start = yesterday.atStartOfDay();
|
||||
LocalDateTime end = yesterday.atTime(23, 59, 59);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN);
|
||||
param.setStartTime(start.format(formatter));
|
||||
param.setEndTime(end.format(formatter));
|
||||
statIntegrityDService.addData(param);
|
||||
}
|
||||
|
||||
/**
|
||||
* 每天2点计算治理设备的在线率
|
||||
*
|
||||
* @date 2025/7/1
|
||||
*/
|
||||
@Scheduled(cron = "0 30 1 * * ?")
|
||||
public void devOnlineRateJob() {
|
||||
StatisticsDataParam param = new StatisticsDataParam();
|
||||
LocalDate yesterday = LocalDate.now().minusDays(1);
|
||||
LocalDateTime start = yesterday.atStartOfDay();
|
||||
LocalDateTime end = yesterday.atTime(23, 59, 59);
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern(DatePattern.NORM_DATE_PATTERN);
|
||||
param.setStartTime(start.format(formatter));
|
||||
param.setEndTime(end.format(formatter));
|
||||
statOnlineRateDService.addData(param);
|
||||
}
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package com.njcn.csdevice.mapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.csdevice.pojo.param.CsEquipmentDeliveryQueryParm;
|
||||
import com.njcn.csdevice.pojo.param.ProjectEquipmentQueryParm;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.vo.CsEquipmentDeliveryVO;
|
||||
@@ -25,5 +26,10 @@ public interface CsEquipmentDeliveryMapper extends BaseMapper<CsEquipmentDeliver
|
||||
|
||||
Page<CsEquipmentDeliveryVO> page(Page<CsEquipmentDeliveryPO> returnpage, @Param("ew") QueryWrapper<CsEquipmentDeliveryPO> queryWrapper);
|
||||
|
||||
//获取符合条件的设备列表
|
||||
List<CsEquipmentDeliveryVO> getList(@Param("queryParam") CsEquipmentDeliveryQueryParm queryParam);
|
||||
|
||||
//获取符合条件的设备数量
|
||||
int getCounts(@Param("queryParam") CsEquipmentDeliveryQueryParm queryParam);
|
||||
|
||||
}
|
||||
@@ -87,5 +87,41 @@
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getList" resultType="CsEquipmentDeliveryVO">
|
||||
select
|
||||
*
|
||||
from
|
||||
cs_equipment_delivery
|
||||
<where>
|
||||
1=1
|
||||
<if test="queryParam.process != null and queryParam.process !=''">
|
||||
and process = #{queryParam.process}
|
||||
</if>
|
||||
<if test="queryParam.runStatus != null and queryParam.runStatus !=''">
|
||||
and run_status = #{queryParam.runStatus}
|
||||
</if>
|
||||
<if test="queryParam.searchValue != null and queryParam.searchValue !=''">
|
||||
and (name like concat('%',#{queryParam.searchValue},'%') or ndid like concat('%',#{queryParam.searchValue},'%'))
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="getCounts" resultType="int">
|
||||
select
|
||||
count(1)
|
||||
from
|
||||
cs_equipment_delivery
|
||||
<where>
|
||||
1=1
|
||||
<if test="queryParam.process != null and queryParam.process !=''">
|
||||
and process = #{queryParam.process}
|
||||
</if>
|
||||
<if test="queryParam.runStatus != null and queryParam.runStatus !=''">
|
||||
and run_status = #{queryParam.runStatus}
|
||||
</if>
|
||||
<if test="queryParam.searchValue != null and queryParam.searchValue !=''">
|
||||
and (name like concat('%',#{queryParam.searchValue},'%') or ndid like concat('%',#{queryParam.searchValue},'%'))
|
||||
</if>
|
||||
</where>
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -37,6 +37,9 @@ public interface AppProjectService extends IService<AppProjectPO> {
|
||||
* @Date: 2023/3/27
|
||||
*/
|
||||
Boolean AuditAppProject(AppProjectAuditParm appProjectAuditParm);
|
||||
|
||||
Boolean updateProject(AppProjectAuditParm appProjectAuditParm);
|
||||
|
||||
/**
|
||||
* @Description: queryProject
|
||||
* @Param: [appProjectQueryParm]
|
||||
|
||||
@@ -132,7 +132,7 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
|
||||
// eq ("user_id", userId).
|
||||
eq ("name", name);
|
||||
Integer integer = csLedgerMapper.selectCount (queryWrapper);
|
||||
return integer > 0 ? true : false;
|
||||
return integer > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -249,7 +249,25 @@ class AppProjectServiceImpl extends ServiceImpl<AppProjectMapper, AppProjectPO>
|
||||
csLedger2.setName(appProjectAuditParm.getName());
|
||||
}
|
||||
csLedgerMapper.updateById(csLedger2);
|
||||
return i == 1 ? true : false;
|
||||
return i == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = BusinessException.class)
|
||||
public Boolean updateProject(AppProjectAuditParm appProjectAuditParm) {
|
||||
//修改项目表
|
||||
this.lambdaUpdate().set(AppProjectPO::getName,appProjectAuditParm.getName())
|
||||
.set(AppProjectPO::getArea,appProjectAuditParm.getArea())
|
||||
.set(AppProjectPO::getDescription,appProjectAuditParm.getDescription())
|
||||
.eq(AppProjectPO::getId,appProjectAuditParm.getId())
|
||||
.eq(AppProjectPO::getStatus,"1")
|
||||
.update();
|
||||
//修改台账表
|
||||
CsLedger csLedger = new CsLedger();
|
||||
csLedger.setId(appProjectAuditParm.getId());
|
||||
csLedger.setName(appProjectAuditParm.getName());
|
||||
csLedgerMapper.updateById(csLedger);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -6,9 +6,10 @@ import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONArray;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import com.alibaba.nacos.client.naming.utils.CollectionUtils;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
@@ -35,7 +36,6 @@ 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.db.constant.DbConstant;
|
||||
import com.njcn.oss.constant.OssPath;
|
||||
import com.njcn.oss.utils.FileStorageUtil;
|
||||
import com.njcn.redis.pojo.enums.AppRedisKey;
|
||||
@@ -46,7 +46,7 @@ import com.njcn.system.enums.DicDataEnum;
|
||||
import com.njcn.system.enums.DicDataTypeEnum;
|
||||
import com.njcn.system.enums.DicTreeEnum;
|
||||
import com.njcn.system.pojo.po.SysDicTreePO;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.user.enums.AppRoleEnum;
|
||||
import com.njcn.web.utils.RequestUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
@@ -292,71 +292,109 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
|
||||
@Override
|
||||
public Page<CsEquipmentDeliveryVO> list(CsEquipmentDeliveryQueryParm queryParam) {
|
||||
QueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new QueryWrapper<CsEquipmentDeliveryPO>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
//查询参数不为空,进行条件填充
|
||||
if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
//部门根据名称模糊查询
|
||||
queryWrapper
|
||||
.and(param -> param.like("cs_equipment_delivery.name", queryParam.getSearchValue())
|
||||
.or().like("cs_equipment_delivery.ndid", queryParam.getSearchValue())
|
||||
.or().like("cs_equipment_delivery.mac", queryParam.getSearchValue()));
|
||||
Page<CsEquipmentDeliveryVO> page = new Page<> ();
|
||||
page.setCurrent(queryParam.getPageNum());
|
||||
page.setSize(queryParam.getPageSize());
|
||||
queryParam.setPageNum((queryParam.getPageNum()-1)*queryParam.getPageSize());
|
||||
int total = this.baseMapper.getCounts(queryParam);
|
||||
if (total > 0) {
|
||||
List<CsEquipmentDeliveryVO> recordList = this.baseMapper.getList(queryParam);
|
||||
//新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
|
||||
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : recordList){
|
||||
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){
|
||||
csEquipmentDeliveryVO.setStatus(5);
|
||||
} else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) {
|
||||
csEquipmentDeliveryVO.setStatus(6);
|
||||
}
|
||||
//判断装置是否已经连接上mqtt服务器
|
||||
String clientName = "NJCN-" + csEquipmentDeliveryVO.getNdid().substring(csEquipmentDeliveryVO.getNdid().length() - 6);
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
if (mqttClient) {
|
||||
csEquipmentDeliveryVO.setConnectStatus("已连接");
|
||||
} else {
|
||||
csEquipmentDeliveryVO.setConnectStatus("未连接");
|
||||
}
|
||||
}
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//默认根据创建时间排序
|
||||
queryWrapper.orderBy(true, false, "create_time");
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(queryParam.getDevType()) && !Objects.isNull(queryParam.getDevType())){
|
||||
queryWrapper.eq("cs_equipment_delivery.dev_type", queryParam.getDevType());
|
||||
}
|
||||
if (StrUtil.isNotBlank(queryParam.getDevModel()) && !Objects.isNull(queryParam.getDevModel())){
|
||||
queryWrapper.eq("cs_equipment_delivery.dev_model", queryParam.getDevModel());
|
||||
}
|
||||
if (StrUtil.isNotBlank(queryParam.getDevAccessMethod()) && !Objects.isNull(queryParam.getDevAccessMethod())){
|
||||
queryWrapper.eq("cs_equipment_delivery.dev_access_method", queryParam.getDevAccessMethod());
|
||||
}
|
||||
if (!Objects.isNull(queryParam.getStatus())){
|
||||
queryWrapper.eq("cs_equipment_delivery.status", queryParam.getStatus());
|
||||
} else {
|
||||
queryWrapper.in("cs_equipment_delivery.status", Arrays.asList(1,2,3));
|
||||
}
|
||||
if (!Objects.isNull(queryParam.getRunStatus())){
|
||||
queryWrapper.eq("cs_equipment_delivery.run_status", queryParam.getRunStatus());
|
||||
} else {
|
||||
queryWrapper.in("cs_equipment_delivery.run_status", Arrays.asList(1,2));
|
||||
}
|
||||
if (!Objects.isNull(queryParam.getProcess())){
|
||||
queryWrapper.eq("cs_equipment_delivery.process", queryParam.getProcess());
|
||||
}
|
||||
Page<CsEquipmentDeliveryVO> page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
page.getRecords().forEach(item->{
|
||||
if (!Objects.isNull(item.getQrPath())){
|
||||
item.setQrPath(item.getQrPath());
|
||||
}
|
||||
});
|
||||
//新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
|
||||
for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){
|
||||
if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){
|
||||
csEquipmentDeliveryVO.setStatus(5);
|
||||
} else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) {
|
||||
csEquipmentDeliveryVO.setStatus(6);
|
||||
}
|
||||
//判断装置是否已经连接上mqtt服务器
|
||||
String clientName = "NJCN-" + csEquipmentDeliveryVO.getNdid().substring(csEquipmentDeliveryVO.getNdid().length() - 6);
|
||||
boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
if (mqttClient) {
|
||||
csEquipmentDeliveryVO.setConnectStatus("已连接");
|
||||
} else {
|
||||
csEquipmentDeliveryVO.setConnectStatus("未连接");
|
||||
if (ObjectUtil.isNotNull(queryParam.getConnectStatus())) {
|
||||
recordList = recordList.stream()
|
||||
.filter(item -> queryParam.getConnectStatus() == 0
|
||||
? "未连接".equals(item.getConnectStatus())
|
||||
: "已连接".equals(item.getConnectStatus()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
page.setTotal(CollectionUtil.isEmpty(recordList) ? 0 : recordList.size());
|
||||
page.setRecords(recordList);
|
||||
}
|
||||
return page;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public Page<CsEquipmentDeliveryVO> list(CsEquipmentDeliveryQueryParm queryParam) {
|
||||
// QueryWrapper<CsEquipmentDeliveryPO> queryWrapper = new QueryWrapper<CsEquipmentDeliveryPO>();
|
||||
// if (ObjectUtil.isNotNull(queryParam)) {
|
||||
// //查询参数不为空,进行条件填充
|
||||
// if (StrUtil.isNotBlank(queryParam.getSearchValue())) {
|
||||
// //部门根据名称模糊查询
|
||||
// queryWrapper
|
||||
// .and(param -> param.like("cs_equipment_delivery.name", queryParam.getSearchValue())
|
||||
// .or().like("cs_equipment_delivery.ndid", queryParam.getSearchValue())
|
||||
// .or().like("cs_equipment_delivery.mac", queryParam.getSearchValue()));
|
||||
// }
|
||||
// //排序
|
||||
// if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
// queryWrapper.orderBy(true, queryParam.getOrderBy().equalsIgnoreCase(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
// } else {
|
||||
// //默认根据创建时间排序
|
||||
// queryWrapper.orderBy(true, false, "create_time");
|
||||
// }
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(queryParam.getDevType()) && !Objects.isNull(queryParam.getDevType())){
|
||||
// queryWrapper.eq("cs_equipment_delivery.dev_type", queryParam.getDevType());
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(queryParam.getDevModel()) && !Objects.isNull(queryParam.getDevModel())){
|
||||
// queryWrapper.eq("cs_equipment_delivery.dev_model", queryParam.getDevModel());
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(queryParam.getDevAccessMethod()) && !Objects.isNull(queryParam.getDevAccessMethod())){
|
||||
// queryWrapper.eq("cs_equipment_delivery.dev_access_method", queryParam.getDevAccessMethod());
|
||||
// }
|
||||
// if (!Objects.isNull(queryParam.getStatus())){
|
||||
// queryWrapper.eq("cs_equipment_delivery.status", queryParam.getStatus());
|
||||
// } else {
|
||||
// queryWrapper.in("cs_equipment_delivery.status", Arrays.asList(1,2,3));
|
||||
// }
|
||||
// if (!Objects.isNull(queryParam.getRunStatus())){
|
||||
// queryWrapper.eq("cs_equipment_delivery.run_status", queryParam.getRunStatus());
|
||||
// } else {
|
||||
// queryWrapper.in("cs_equipment_delivery.run_status", Arrays.asList(1,2));
|
||||
// }
|
||||
// if (!Objects.isNull(queryParam.getProcess())){
|
||||
// queryWrapper.eq("cs_equipment_delivery.process", queryParam.getProcess());
|
||||
// }
|
||||
// Page<CsEquipmentDeliveryVO> page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
// page.getRecords().forEach(item->{
|
||||
// if (!Objects.isNull(item.getQrPath())){
|
||||
// item.setQrPath(item.getQrPath());
|
||||
// }
|
||||
// });
|
||||
// //新增逻辑(只针对便携式设备):修改设备中的未注册状态(status = 1)改为5(前端定义的字典也即未接入)
|
||||
// for(CsEquipmentDeliveryVO csEquipmentDeliveryVO : page.getRecords()){
|
||||
// if(DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 1){
|
||||
// csEquipmentDeliveryVO.setStatus(5);
|
||||
// } else if (DataParam.portableDevType.equals(csEquipmentDeliveryVO.getDevType()) && csEquipmentDeliveryVO.getStatus() == 2) {
|
||||
// csEquipmentDeliveryVO.setStatus(6);
|
||||
// }
|
||||
// //判断装置是否已经连接上mqtt服务器
|
||||
// String clientName = "NJCN-" + csEquipmentDeliveryVO.getNdid().substring(csEquipmentDeliveryVO.getNdid().length() - 6);
|
||||
// boolean mqttClient = mqttUtil.judgeClientOnline(clientName);
|
||||
// if (mqttClient) {
|
||||
// csEquipmentDeliveryVO.setConnectStatus("已连接");
|
||||
// } else {
|
||||
// csEquipmentDeliveryVO.setConnectStatus("未连接");
|
||||
// }
|
||||
// }
|
||||
// return page;
|
||||
// }
|
||||
|
||||
@Override
|
||||
public DeviceManagerVO getDeviceData(String deviceId, String type, String lineId) {
|
||||
DeviceManagerVO deviceManagerVo = new DeviceManagerVO();
|
||||
@@ -391,17 +429,7 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
List<CsDataSet> dataSet = new ArrayList<>();
|
||||
//治理监测点
|
||||
if (Objects.equals(code, DicDataEnum.OUTPUT_SIDE.getCode())){
|
||||
// select
|
||||
// t1.id
|
||||
// from
|
||||
// cs_dev_model_relation t0
|
||||
// left join cs_dev_model t1 on
|
||||
// t0.model_id = t1.id
|
||||
// where
|
||||
// t0.status="1" and
|
||||
// t0.dev_id = #{devId} and t1.`type` = #{type}
|
||||
modelId = csDevModelRelationService.getModelByType(deviceId,0);
|
||||
//select * from cs_data_set where pid = modelId and clDev = 0
|
||||
dataSet = csDataSetService.findDataSetByModelId(modelId,0);
|
||||
}
|
||||
//电网侧监测点
|
||||
@@ -447,6 +475,16 @@ public class CsEquipmentDeliveryServiceImpl extends ServiceImpl<CsEquipmentDeliv
|
||||
addDataSet(dataSetList, item, "最新数据", "rt");
|
||||
addDataSet(dataSetList, item, "历史统计数据", "history");
|
||||
addDataSet(dataSetList, item, "历史趋势", "trenddata");
|
||||
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");
|
||||
}
|
||||
}
|
||||
if (isPortableDevice) {
|
||||
// 便携式设备特有的数据集
|
||||
addDataSet(dataSetList, item, "实时数据", "realtimedata");
|
||||
|
||||
@@ -91,6 +91,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
item.setComFlag(po.getRunStatus());
|
||||
item.setNDId(po.getNdid());
|
||||
item.setType("device");
|
||||
item.setProcess(po.getProcess());
|
||||
})
|
||||
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
@@ -119,6 +120,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
deviceList.forEach(dev -> dev.setChildren(getChildren(dev, finalLineList)));
|
||||
projectList.forEach(pro -> pro.setChildren(getChildren(pro, deviceList)));
|
||||
engineeringList.forEach(eng -> eng.setChildren(getChildren(eng, projectList)));
|
||||
engineeringList = engineeringList.stream().sorted(Comparator.comparing(CsLedgerVO::getSort)).collect(Collectors.toList());
|
||||
//获取便携式设备树
|
||||
CsLedgerVO portable = new CsLedgerVO();
|
||||
portable.setLevel(0);
|
||||
@@ -222,6 +224,7 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
item.setComFlag(po.getRunStatus());
|
||||
item.setNDId(po.getNdid());
|
||||
item.setType("device");
|
||||
item.setProcess(po.getProcess());
|
||||
})
|
||||
.filter(item -> Objects.equals(poMap.get(item.getId()).getUsageStatus(), 1))
|
||||
.sorted(Comparator.comparing(CsLedgerVO::getSort))
|
||||
@@ -353,10 +356,13 @@ public class CsLedgerServiceImpl extends ServiceImpl<CsLedgerMapper, CsLedger> i
|
||||
engineeringList.forEach(eng -> {
|
||||
CsEngineeringPO csEngineeringPO = csEngineeringMapper.selectById(eng.getId());
|
||||
eng.setArea(this.getAreaById(csEngineeringPO.getProvince())+this.getAreaById(csEngineeringPO.getCity()));
|
||||
eng.setProvinceId(csEngineeringPO.getProvince());
|
||||
eng.setCityId(csEngineeringPO.getCity());
|
||||
eng.setRemark(csEngineeringPO.getDescription());
|
||||
eng.setChildren(getChildren(eng, projectList));
|
||||
}
|
||||
);
|
||||
|
||||
return engineeringList;
|
||||
}
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class InfluxdbCsCommunicateServiceImpl implements ICsCommunicateService {
|
||||
.select(PqsCommunicate::getDevId)
|
||||
.select(PqsCommunicate::getDescription)
|
||||
.select(PqsCommunicate::getType)
|
||||
.le(PqsCommunicate::getTime, lineParam.getEndTime())
|
||||
.between(PqsCommunicate::getTime, lineParam.getStartTime(), lineParam.getEndTime())
|
||||
.timeDesc()
|
||||
.limit(1);
|
||||
List<PqsCommunicate> list = pqsCommunicateMapper.selectByQueryWrapper(influxQueryWrapper);
|
||||
|
||||
@@ -67,17 +67,17 @@ public class RStatIntegrityDServiceImpl extends MppServiceImpl<RStatIntegrityDMa
|
||||
RStatIntegrityD data = new RStatIntegrityD();
|
||||
//治理监测点
|
||||
if (item.getClDid() == 0) {
|
||||
statisticalDataDTO = commonService.getCounts(item.getLineId(),"apf_data","Apf_Freq","frequency","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","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
|
||||
}
|
||||
//电能质量监测点
|
||||
else {
|
||||
statisticalDataDTO = commonService.getCounts(item.getLineId(),"pqd_data","Pq_Freq","frequency","M","avg",item.getClDid().toString(),process.toString(),time+" 00:00:00",time+" 23:59:59");
|
||||
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");
|
||||
}
|
||||
data.setTimeId(LocalDate.parse(time, DatePattern.NORM_DATE_FORMATTER));
|
||||
data.setLineIndex(item.getLineId());
|
||||
data.setDueTime(dueCount);
|
||||
data.setRealTime(statisticalDataDTO == null || statisticalDataDTO.getFrequency() == null
|
||||
? 0 : Integer.parseInt(statisticalDataDTO.getFrequency()));
|
||||
data.setRealTime(statisticalDataDTO == null || statisticalDataDTO.getValue() == null
|
||||
? 0 : (int)Math.round(statisticalDataDTO.getValue()));
|
||||
result.add(data);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -15,13 +15,17 @@ import com.njcn.csdevice.pojo.po.RStatOnlineRateD;
|
||||
import com.njcn.csdevice.service.ICsCommunicateService;
|
||||
import com.njcn.csdevice.service.IRStatOnlineRateDService;
|
||||
import com.njcn.csdevice.util.TimeUtil;
|
||||
import com.njcn.csharmonic.param.DataParam;
|
||||
import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
|
||||
import com.njcn.influx.deprecated.InfluxDBPublicParam;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.ParseException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
@@ -159,18 +163,30 @@ public class RStatOnlineRateDServiceImpl extends MppServiceImpl<RStatOnlineRateD
|
||||
} else {
|
||||
minute = (int) onlineTime;
|
||||
}
|
||||
} else {
|
||||
}
|
||||
/*当前统计时间内仅有一条数据*/
|
||||
else {
|
||||
if (type != null) {
|
||||
/*当前统计时间内仅有一条数据*/
|
||||
long differ = DateUtil.between(date, newDate, DateUnit.MINUTE);
|
||||
if (online.equals(type)) {
|
||||
minute = InfluxDBPublicParam.DAY_MINUTE - (int) differ;
|
||||
}
|
||||
} else {
|
||||
List<PqsCommunicateDto> communicateDataOld = pqsCommunicateService.getRawDataEnd(lineParam);
|
||||
// if (!communicateDataOld.isEmpty()){
|
||||
// if (online.equals(communicateDataOld.get(0).getType())){
|
||||
// minute = InfluxDBPublicParam.DAY_MINUTE;
|
||||
// }
|
||||
// }
|
||||
if (!communicateDataOld.isEmpty()){
|
||||
if (online.equals(communicateDataOld.get(0).getType())){
|
||||
minute = InfluxDBPublicParam.DAY_MINUTE;
|
||||
try {
|
||||
if (online.equals(communicateDataOld.get(0).getType())){
|
||||
minute = (int) DateUtil.between(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(communicateDataOld.get(0).getTime()), new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(lineParam.getEndTime()), DateUnit.MINUTE);
|
||||
} else {
|
||||
minute = (int) DateUtil.between(new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(lineParam.getStartTime()), new SimpleDateFormat(DatePattern.NORM_DATETIME_PATTERN).parse(communicateDataOld.get(0).getTime()), DateUnit.MINUTE);
|
||||
}
|
||||
} catch (ParseException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,14 +3,12 @@ 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.csdevice.pojo.po.AppProjectPO;
|
||||
import com.njcn.csharmonic.api.EventUserFeignClient;
|
||||
import com.njcn.csharmonic.param.CsEventUserQueryParam;
|
||||
import com.njcn.csharmonic.pojo.vo.EventDetailVO;
|
||||
import feign.hystrix.FallbackFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -23,6 +23,8 @@ public class StatisticsDataParam implements Serializable {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
private String endTime;
|
||||
|
||||
private Integer process;
|
||||
|
||||
private List<String> idList;
|
||||
|
||||
}
|
||||
|
||||
@@ -116,8 +116,11 @@ public class EventDetailVO {
|
||||
//用于波形分析区别pms,pq
|
||||
private String systemType="ZL";
|
||||
|
||||
@ApiModelProperty("子模块编号")
|
||||
private String moduleNo;
|
||||
|
||||
|
||||
|
||||
@ApiModelProperty("逻辑子设备编码")
|
||||
private Integer clDid;
|
||||
|
||||
}
|
||||
|
||||
@@ -45,6 +45,9 @@ public class HalfMonthReportVO implements Serializable {
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private LocalDateTime latestTime;
|
||||
|
||||
@ApiModelProperty("流程状态")
|
||||
private Integer process;
|
||||
|
||||
@ApiModelProperty("数据完整性")
|
||||
private Double integrity;
|
||||
|
||||
|
||||
@@ -121,7 +121,7 @@
|
||||
<select id="queryEventPageWeb" resultType="com.njcn.csharmonic.pojo.vo.EventDetailVO">
|
||||
select DISTINCT b.id id,
|
||||
b.device_id deviceId,b.line_id lineId,b.code code,
|
||||
b.start_time startTime,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location
|
||||
b.start_time startTime,b.tag tag ,b.wave_path wavePath,b.instant_pics,b.rms_pics , b.type type,b.level level,b.location location,b.cl_did clDid
|
||||
<if test="csEventUserQueryPage!=null and csEventUserQueryPage.type != 3 ">
|
||||
,d.name lineName
|
||||
</if>
|
||||
|
||||
@@ -422,6 +422,9 @@ public class CsEventUserPOServiceImpl extends ServiceImpl<CsEventUserPOMapper, C
|
||||
EleEpdPqd ele = epdFeignClient.findByName(temp.getTag()).getData();
|
||||
temp.setShowName(ele.getShowName());
|
||||
temp.setCode(ele.getDefaultValue());
|
||||
if (temp.getLineId().endsWith("0")) {
|
||||
temp.setModuleNo("模块" + temp.getClDid());
|
||||
}
|
||||
if(Objects.equals(csEventUserQueryPage.getType(),"0")){
|
||||
|
||||
List<EleEvtParm> data1 = eleEvtFeignClient.queryByPid(ele.getId()).getData();
|
||||
|
||||
@@ -55,6 +55,7 @@ import java.text.DecimalFormat;
|
||||
import java.time.Duration;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -234,7 +235,7 @@ public class DataServiceImpl implements IDataService {
|
||||
commonQueryParam.setColumnName("Apf_ModWorkingSts");
|
||||
commonQueryParam.setResultName("value");
|
||||
commonQueryParam.setTableName("apf_data");
|
||||
commonQueryParam.setStartTime(param.getEndTime()+" 00:00:00");
|
||||
commonQueryParam.setStartTime(param.getStartTime()+" 00:00:00");
|
||||
commonQueryParam.setEndTime(param.getEndTime()+" 23:59:59");
|
||||
commonQueryParam.setLineId(param.getLineId());
|
||||
commonQueryParam.setDataType("Apf_ModType");
|
||||
@@ -243,14 +244,18 @@ public class DataServiceImpl implements IDataService {
|
||||
EachModuleVO moduleVO = new EachModuleVO();
|
||||
moduleVO.setModuleName("模块"+i);
|
||||
|
||||
List<EachModuleVO.harmonicVo> list1 = new ArrayList<>();
|
||||
List<EachModuleVO.HarmonicVo> list1 = new ArrayList<>();
|
||||
commonQueryParam.setClDid(Integer.toString(i));
|
||||
|
||||
//获取模块数据
|
||||
List<EachModuleVO.DataVo> list2 = new ArrayList<>();
|
||||
List<EachModuleVO.DataVo> list3 = new ArrayList<>();
|
||||
List<EachModuleVO.DataVo> list4 = new ArrayList<>();
|
||||
|
||||
//获取模块状态数据
|
||||
List<StatisticalDataDTO> dto = commonService.getEachModule(commonQueryParam);
|
||||
if (CollectionUtil.isNotEmpty(dto)) {
|
||||
dto.forEach(item->{
|
||||
EachModuleVO.harmonicVo vo = new EachModuleVO.harmonicVo();
|
||||
EachModuleVO.HarmonicVo vo = new EachModuleVO.HarmonicVo();
|
||||
vo.setTime(LocalDateTime.ofInstant(item.getTime().minus(8, ChronoUnit.HOURS), ZoneId.systemDefault()));
|
||||
vo.setStateDesc(channelState(item.getValue()));
|
||||
vo.setDataType(0);
|
||||
@@ -260,6 +265,33 @@ public class DataServiceImpl implements IDataService {
|
||||
moduleVO.setModuleState("离线");
|
||||
}
|
||||
|
||||
//获取模块电流数据
|
||||
List<StatisticalDataDTO> dto2 = commonService.getModuleData(commonQueryParam);
|
||||
if (CollectionUtil.isNotEmpty(dto2)) {
|
||||
dto2.forEach(item->{
|
||||
|
||||
EachModuleVO.DataVo vo1 = new EachModuleVO.DataVo();
|
||||
vo1.setTime(LocalDateTime.ofInstant(item.getTime().minus(8, ChronoUnit.HOURS), ZoneId.systemDefault()));
|
||||
vo1.setPhasicType(item.getPhaseType());
|
||||
vo1.setData(Objects.isNull(item.getValue()) ? 3.14159 : Double.parseDouble(df.format(item.getValue())));
|
||||
|
||||
EachModuleVO.DataVo vo2 = new EachModuleVO.DataVo();
|
||||
vo2.setTime(LocalDateTime.ofInstant(item.getTime().minus(8, ChronoUnit.HOURS), ZoneId.systemDefault()));
|
||||
vo2.setPhasicType(item.getPhaseType());
|
||||
vo2.setData(Objects.isNull(item.getAvgValue()) ? 3.14159 : Double.parseDouble(df.format(item.getAvgValue())));
|
||||
|
||||
if (Objects.equals(item.getPhaseType(),"M")) {
|
||||
EachModuleVO.DataVo vo3 = new EachModuleVO.DataVo();
|
||||
vo3.setTime(LocalDateTime.ofInstant(item.getTime().minus(8, ChronoUnit.HOURS), ZoneId.systemDefault()));
|
||||
vo3.setPhasicType(item.getPhaseType());
|
||||
vo3.setData(Objects.isNull(item.getMinValue()) ? 3.14159 : Double.parseDouble(df.format(item.getMinValue())));
|
||||
list4.add(vo3);
|
||||
}
|
||||
list2.add(vo1);
|
||||
list3.add(vo2);
|
||||
});
|
||||
}
|
||||
|
||||
//获取模块事件
|
||||
LambdaQueryWrapper<CsEventPO> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(CsEventPO::getLineId, param.getLineId())
|
||||
@@ -271,9 +303,21 @@ public class DataServiceImpl implements IDataService {
|
||||
if (CollectionUtil.isNotEmpty(eventList)) {
|
||||
eventList.forEach(item->{
|
||||
EleEpdPqd epdPqd = epdFeignClient.findByName(item.getTag()).getData();
|
||||
EachModuleVO.harmonicVo vo = new EachModuleVO.harmonicVo();
|
||||
EachModuleVO.HarmonicVo vo = new EachModuleVO.HarmonicVo();
|
||||
vo.setTime(item.getStartTime());
|
||||
vo.setStateDesc(channelState2(item.getTag()));
|
||||
//查询事件状态 如果往前查寻没有数据、则往后查询事件
|
||||
if (Objects.equals("Alm_Apf_ModConnect",item.getTag())) {
|
||||
if (ObjectUtil.isNotEmpty(list1)) {
|
||||
Optional<EachModuleVO.HarmonicVo> optional = list1.stream()
|
||||
// 筛选时间早于参考时间且目标字段等于指定值的记录
|
||||
.filter(vo1 -> vo1.getTime().isBefore(item.getStartTime()))
|
||||
.filter(vo2 -> vo2.getDataType() == 0)
|
||||
.findFirst();
|
||||
optional.ifPresent(harmonicVo -> vo.setStateDesc(harmonicVo.getStateDesc()));
|
||||
}
|
||||
} else {
|
||||
vo.setStateDesc(channelState2(item.getTag()));
|
||||
}
|
||||
vo.setEventCode(item.getTag());
|
||||
vo.setDataType(1);
|
||||
if (ObjectUtil.isNotNull(epdPqd)) {
|
||||
@@ -285,17 +329,58 @@ public class DataServiceImpl implements IDataService {
|
||||
});
|
||||
}
|
||||
if (CollectionUtil.isNotEmpty(list1)) {
|
||||
List<EachModuleVO.harmonicVo> dataList = list1.stream()
|
||||
.sorted(Comparator.comparing(EachModuleVO.harmonicVo::getTime))
|
||||
List<EachModuleVO.HarmonicVo> dataList = list1.stream()
|
||||
.sorted(Comparator.comparing(EachModuleVO.HarmonicVo::getTime))
|
||||
.collect(Collectors.toList());
|
||||
moduleVO.setDataList(dataList);
|
||||
EachModuleVO.harmonicVo last = dataList.get(dataList.size() - 1);
|
||||
if (Objects.equals(last.getDataType(),0)) {
|
||||
moduleVO.setModuleState(last.getStateDesc());
|
||||
} else if (Objects.equals(last.getDataType(),1)) {
|
||||
moduleVO.setModuleState(Objects.equals(last.getStateDesc(),"Alm_Apf_ModDisConnect") ? "离线" : "运行");
|
||||
//处理APF模块连接事件状态
|
||||
dataList.forEach(item->{
|
||||
if (Objects.equals(item.getEventCode(),"Alm_Apf_ModConnect")) {
|
||||
Optional<EachModuleVO.HarmonicVo> optional = dataList.stream()
|
||||
// 筛选时间早于参考时间且目标字段等于指定值的记录
|
||||
.filter(vo1 -> vo1.getTime().isAfter(item.getTime()) && vo1.getDataType() == 1)
|
||||
.filter(vo2 -> !Objects.equals("Alm_Apf_ModDisConnect",vo2.getEventCode()) && !Objects.equals("Alm_Apf_ModConnect",vo2.getEventCode()))
|
||||
.findFirst();
|
||||
if (optional.isPresent()) {
|
||||
item.setStateDesc(optional.get().getStateDesc());
|
||||
} else {
|
||||
item.setStateDesc("无状态");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
EachModuleVO.HarmonicVo last = dataList.get(dataList.size() - 1);
|
||||
moduleVO.setModuleState(last.getStateDesc());
|
||||
//如果模块掉线超过30分钟,则续上数据
|
||||
int timeCompare = compareWithCurrentTime(commonQueryParam.getEndTime());
|
||||
LocalDateTime currentTime;
|
||||
switch (timeCompare) {
|
||||
case -1:
|
||||
case 0:
|
||||
currentTime = LocalDateTime.now();
|
||||
break;
|
||||
case 1:
|
||||
currentTime = LocalDateTime.parse(commonQueryParam.getEndTime(), DatePattern.NORM_DATETIME_FORMATTER);
|
||||
break;
|
||||
default:
|
||||
currentTime = LocalDateTime.now();
|
||||
System.out.println("比较失败");
|
||||
}
|
||||
|
||||
LocalDateTime givenTime = last.getTime();
|
||||
Duration duration = Duration.between(givenTime, currentTime);
|
||||
boolean isMoreThan30Minutes = duration.toMinutes() > 30;
|
||||
if (isMoreThan30Minutes) {
|
||||
EachModuleVO.HarmonicVo vo = new EachModuleVO.HarmonicVo();
|
||||
vo.setTime(currentTime);
|
||||
vo.setStateDesc(last.getStateDesc());
|
||||
vo.setDataType(0);
|
||||
dataList.add(vo);
|
||||
}
|
||||
moduleVO.setDataList(dataList);
|
||||
}
|
||||
moduleVO.setModOutList(list2);
|
||||
moduleVO.setLoadList(list3);
|
||||
moduleVO.setTemperatureList(list4);
|
||||
result.add(moduleVO);
|
||||
}
|
||||
}
|
||||
@@ -323,7 +408,16 @@ public class DataServiceImpl implements IDataService {
|
||||
Double value = Double.parseDouble(redisUtilObjectByKey.toString());
|
||||
moduleVO.setModuleState(channelState(value));
|
||||
} else {
|
||||
moduleVO.setModuleState("离线");
|
||||
//再询问一次
|
||||
publisher.send("/Pfm/DevCmd/" + version + "/" + nDid, new Gson().toJson(dto), 1, false);
|
||||
Thread.sleep(800);
|
||||
Object redisUtilObjectByKey2 = redisUtil.getObjectByKey("ApfRtData:" + mid);
|
||||
if (ObjectUtil.isNotNull(redisUtilObjectByKey2)) {
|
||||
Double value = Double.parseDouble(redisUtilObjectByKey2.toString());
|
||||
moduleVO.setModuleState(channelState(value));
|
||||
} else {
|
||||
moduleVO.setModuleState("离线");
|
||||
}
|
||||
}
|
||||
mid = mid + 1;
|
||||
if (mid > 10000) {
|
||||
@@ -338,6 +432,17 @@ public class DataServiceImpl implements IDataService {
|
||||
return result;
|
||||
}
|
||||
|
||||
public int compareWithCurrentTime(String timeString) {
|
||||
// 定义日期时间格式
|
||||
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
||||
// 解析字符串时间为LocalDateTime对象
|
||||
LocalDateTime specifiedTime = LocalDateTime.parse(timeString, formatter);
|
||||
// 获取当前时间
|
||||
LocalDateTime currentTime = LocalDateTime.now();
|
||||
// 比较两个时间
|
||||
return currentTime.compareTo(specifiedTime);
|
||||
}
|
||||
|
||||
|
||||
public ReqAndResDto.Req askApfModuleData(Integer mid, Integer clDId, Integer idx) {
|
||||
ReqAndResDto.Req reqAndResParam = new ReqAndResDto.Req();
|
||||
@@ -367,13 +472,13 @@ public class DataServiceImpl implements IDataService {
|
||||
str = "离线";
|
||||
break;
|
||||
case 1:
|
||||
str = "运行";
|
||||
str = "停止";
|
||||
break;
|
||||
case 2:
|
||||
str = "运行(停止)";
|
||||
str = "运行";
|
||||
break;
|
||||
case 3:
|
||||
str = "运行(故障)";
|
||||
str = "故障";
|
||||
break;
|
||||
default:
|
||||
str = "无状态";
|
||||
@@ -383,11 +488,15 @@ public class DataServiceImpl implements IDataService {
|
||||
}
|
||||
|
||||
public String channelState2(String code) {
|
||||
String str;
|
||||
String str = null;
|
||||
if ("Alm_Apf_ModDisConnect".equals(code)) {
|
||||
str = "离线";
|
||||
} else {
|
||||
} else if ("Alm_Apf_ModRunStop".equals(code) || "Alm_Apf_JT_stsLock".equals(code) || "Alm_Apf_JT_stsUnLock".equals(code)) {
|
||||
str = "停止";
|
||||
} else if ("Alm_Apf_ModRunRun".equals(code)) {
|
||||
str = "运行";
|
||||
} else if ("Alm_Apf_ModRunFault".equals(code)) {
|
||||
str = "故障";
|
||||
}
|
||||
return str;
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
package com.njcn.csharmonic.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollectionUtil;
|
||||
import com.njcn.csdevice.api.CsLineFeignClient;
|
||||
import com.njcn.csdevice.api.EquipmentFeignClient;
|
||||
import com.njcn.csdevice.api.IntegrityFeignClient;
|
||||
import com.njcn.csdevice.api.OnlineRateFeignClient;
|
||||
import com.njcn.access.api.CsLineLatestDataFeignClient;
|
||||
import com.njcn.access.pojo.po.CsLineLatestData;
|
||||
import com.njcn.csdevice.api.*;
|
||||
import com.njcn.csdevice.pojo.dto.DevDetailDTO;
|
||||
import com.njcn.csdevice.pojo.po.CsEquipmentDeliveryPO;
|
||||
import com.njcn.csdevice.pojo.po.CsLinePO;
|
||||
import com.njcn.csdevice.pojo.po.RStatIntegrityD;
|
||||
@@ -13,7 +13,6 @@ import com.njcn.csharmonic.pojo.param.StatisticsDataParam;
|
||||
import com.njcn.csharmonic.pojo.vo.DataVo;
|
||||
import com.njcn.csharmonic.pojo.vo.HalfMonthReportVO;
|
||||
import com.njcn.csharmonic.service.IStatisticsDataDataService;
|
||||
import com.njcn.influx.pojo.bo.CommonQueryParam;
|
||||
import com.njcn.influx.pojo.dto.StatisticalDataDTO;
|
||||
import com.njcn.influx.service.CommonService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@@ -38,6 +37,8 @@ public class StatisticsDataDataServiceImpl implements IStatisticsDataDataService
|
||||
private final CommonService commonService;
|
||||
private final IntegrityFeignClient integrityFeignClient;
|
||||
private final OnlineRateFeignClient onlineRateFeignClient;
|
||||
private final CsLineLatestDataFeignClient csLineLatestDataFeignClient;
|
||||
private final CsLedgerFeignClient csLedgerFeignClient;
|
||||
|
||||
@Override
|
||||
public List<DataVo> getLineIntegrity(StatisticsDataParam param) {
|
||||
@@ -90,60 +91,72 @@ public class StatisticsDataDataServiceImpl implements IStatisticsDataDataService
|
||||
//获取装置
|
||||
List<CsEquipmentDeliveryPO> equipmentDeliveryList = equipmentFeignClient.getAll().getData();
|
||||
if (CollectionUtil.isNotEmpty(equipmentDeliveryList)) {
|
||||
//获取监测点集合
|
||||
List<String> devList = equipmentDeliveryList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
|
||||
List<CsLinePO> csLineList = csLineFeignClient.getLinesByDevList(devList).getData();
|
||||
if (CollectionUtil.isNotEmpty(csLineList)) {
|
||||
Map<String,List<CsLinePO>> devMap = csLineList.stream().collect(Collectors.groupingBy(CsLinePO::getDeviceId));
|
||||
List<String> lineList = csLineList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
||||
List<String> deviceList = csLineList.stream().map(CsLinePO::getDeviceId).collect(Collectors.toList());
|
||||
//获取监测点数据完整性
|
||||
List<RStatIntegrityD> list1 = integrityFeignClient.list(lineList,param.getStartTime(),param.getEndTime()).getData();
|
||||
//获取终端在线率
|
||||
List<RStatOnlineRateD> list2 = onlineRateFeignClient.list(deviceList,param.getStartTime(),param.getEndTime()).getData();
|
||||
equipmentDeliveryList.forEach(dev->{
|
||||
List<CsLinePO> list = devMap.get(dev.getId());
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
list.forEach(line->{
|
||||
HalfMonthReportVO vo = new HalfMonthReportVO();
|
||||
vo.setEngineeringName("工程名称");
|
||||
vo.setProjectName("项目名称");
|
||||
vo.setDevName(dev.getName());
|
||||
vo.setDevType(dev.getDevType());
|
||||
vo.setMac(dev.getMac());
|
||||
vo.setOperationalStatus(dev.getUsageStatus() == 0 ? "停运" : "在运");
|
||||
//fixme 先用设备登记时间记作投运时间
|
||||
vo.setOperationalTime(dev.getCreateTime());
|
||||
vo.setLineName(line.getName());
|
||||
vo.setCommunicationStatus(dev.getRunStatus() == 1 ? "离线" : "在线");
|
||||
vo.setLatestTime(LocalDateTime.now());
|
||||
List<CsEquipmentDeliveryPO> processList = Objects.isNull(param.getProcess())
|
||||
? equipmentDeliveryList
|
||||
: equipmentDeliveryList.stream()
|
||||
.filter(item -> Objects.equals(item.getProcess(), param.getProcess()))
|
||||
.collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(processList)) {
|
||||
//获取监测点集合
|
||||
List<String> devList = processList.stream().map(CsEquipmentDeliveryPO::getId).collect(Collectors.toList());
|
||||
List<CsLinePO> csLineList = csLineFeignClient.getLinesByDevList(devList).getData();
|
||||
if (CollectionUtil.isNotEmpty(csLineList)) {
|
||||
Map<String,List<CsLinePO>> devMap = csLineList.stream().collect(Collectors.groupingBy(CsLinePO::getDeviceId));
|
||||
List<String> lineList = csLineList.stream().map(CsLinePO::getLineId).collect(Collectors.toList());
|
||||
List<String> deviceList = csLineList.stream().map(CsLinePO::getDeviceId).collect(Collectors.toList());
|
||||
//获取监测点数据完整性
|
||||
List<RStatIntegrityD> list1 = integrityFeignClient.list(lineList,param.getStartTime(),param.getEndTime()).getData();
|
||||
//获取终端在线率
|
||||
List<RStatOnlineRateD> list2 = onlineRateFeignClient.list(deviceList,param.getStartTime(),param.getEndTime()).getData();
|
||||
//获取监测点最新数据时间
|
||||
List<CsLineLatestData> list3 = csLineLatestDataFeignClient.listData().getData();
|
||||
equipmentDeliveryList.forEach(dev->{
|
||||
List<CsLinePO> list = devMap.get(dev.getId());
|
||||
if (CollectionUtil.isNotEmpty(list)) {
|
||||
list.forEach(line->{
|
||||
DevDetailDTO dto = csLedgerFeignClient.queryDevDetail(dev.getId()).getData();
|
||||
HalfMonthReportVO vo = new HalfMonthReportVO();
|
||||
vo.setEngineeringName(dto.getEngineeringName());
|
||||
vo.setProjectName(dto.getProjectName());
|
||||
vo.setDevName(dev.getName());
|
||||
vo.setDevType(dev.getDevModel());
|
||||
vo.setMac(dev.getMac());
|
||||
vo.setOperationalTime(dev.getCreateTime());
|
||||
vo.setOperationalStatus(dev.getUsageStatus() == 0 ? "停运" : "在运");
|
||||
vo.setLineName(line.getName());
|
||||
vo.setCommunicationStatus(dev.getRunStatus() == 1 ? "离线" : "在线");
|
||||
vo.setLatestTime(LocalDateTime.now());
|
||||
vo.setProcess(dev.getProcess());
|
||||
|
||||
List<RStatIntegrityD> l1 = list1.stream().filter(item -> item.getLineIndex().equals(line.getLineId())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(l1)) {
|
||||
double ratio = BigDecimal.valueOf(
|
||||
l1.stream().mapToDouble(RStatIntegrityD::getRealTime).sum() * 100.0
|
||||
).divide(
|
||||
BigDecimal.valueOf(l1.stream().mapToDouble(RStatIntegrityD::getDueTime).sum()),
|
||||
2, RoundingMode.HALF_UP
|
||||
).doubleValue();
|
||||
vo.setIntegrity(ratio);
|
||||
} else {
|
||||
vo.setIntegrity(0.0);
|
||||
}
|
||||
List<RStatIntegrityD> l1 = list1.stream().filter(item -> item.getLineIndex().equals(line.getLineId())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(l1)) {
|
||||
double ratio = BigDecimal.valueOf(
|
||||
l1.stream().mapToDouble(RStatIntegrityD::getRealTime).sum() * 100.0
|
||||
).divide(
|
||||
BigDecimal.valueOf(l1.stream().mapToDouble(RStatIntegrityD::getDueTime).sum()),
|
||||
2, RoundingMode.HALF_UP
|
||||
).doubleValue();
|
||||
vo.setIntegrity(ratio);
|
||||
} else {
|
||||
vo.setIntegrity(0.0);
|
||||
}
|
||||
|
||||
List<RStatOnlineRateD> l2 = list2.stream().filter(item -> item.getDevIndex().equals(dev.getId())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(l2)) {
|
||||
int onlineMin = l2.stream().mapToInt(RStatOnlineRateD::getOnlineMin).sum();
|
||||
double ratio = new BigDecimal(onlineMin * 100.0 / (1440 * l2.size())).setScale(2,RoundingMode.HALF_UP).doubleValue();
|
||||
vo.setOnlineRate(ratio);
|
||||
} else {
|
||||
vo.setOnlineRate(0.0);
|
||||
}
|
||||
result.add(vo);
|
||||
});
|
||||
}
|
||||
});
|
||||
//获取最新数据时间
|
||||
List<RStatOnlineRateD> l2 = list2.stream().filter(item -> item.getDevIndex().equals(dev.getId())).collect(Collectors.toList());
|
||||
if (CollectionUtil.isNotEmpty(l2)) {
|
||||
int onlineMin = l2.stream().mapToInt(RStatOnlineRateD::getOnlineMin).sum();
|
||||
double ratio = new BigDecimal(onlineMin * 100.0 / (1440 * l2.size())).setScale(2,RoundingMode.HALF_UP).doubleValue();
|
||||
vo.setOnlineRate(ratio);
|
||||
} else {
|
||||
vo.setOnlineRate(0.0);
|
||||
}
|
||||
//获取最新数据时间
|
||||
List<CsLineLatestData> l3 = list3.stream().filter(item -> item.getLineId().equals(line.getLineId())).collect(Collectors.toList());
|
||||
vo.setLatestTime(CollectionUtil.isNotEmpty(l3) ? l3.get(0).getTimeId() : null);
|
||||
result.add(vo);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
|
||||
Reference in New Issue
Block a user