|
|
@ -2,11 +2,16 @@ package com.hnac.hzims.history.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.hnac.hzims.history.service.IHistoryDeviceService; |
|
|
|
import com.hnac.hzims.history.service.IHistoryDeviceService; |
|
|
|
import com.hnac.hzims.history.vo.HistoryDataParamVo; |
|
|
|
import com.hnac.hzims.history.vo.HistoryDataParamVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.history.vo.HistoryDevicePointVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.history.vo.HistoryFactoryPointVo; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
import com.hnac.hzinfo.sdk.core.response.Result; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.DeviceDataClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.client.DeviceClient; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceAttrVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; |
|
|
|
import com.hnac.hzinfo.sdk.v5.device.vo.DeviceInstanceVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.hzfac.HzFacClient; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceAttrVO; |
|
|
|
|
|
|
|
import com.hnac.hzinfo.sdk.v5.hzfac.vo.FacDeviceVO; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.log.exception.ServiceException; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
|
import org.springblade.core.tool.api.R; |
|
|
@ -26,6 +31,7 @@ import java.util.stream.Collectors; |
|
|
|
@AllArgsConstructor |
|
|
|
@AllArgsConstructor |
|
|
|
public class HistoryDeviceServiceImpl implements IHistoryDeviceService { |
|
|
|
public class HistoryDeviceServiceImpl implements IHistoryDeviceService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final HzFacClient hzFacClient; |
|
|
|
|
|
|
|
|
|
|
|
private final DeviceClient deviceClient; |
|
|
|
private final DeviceClient deviceClient; |
|
|
|
|
|
|
|
|
|
|
@ -52,8 +58,8 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService { |
|
|
|
* @return |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public List<DeviceInstanceAttrVO> monitor_point(String projectId,String deviceCode,String deviceName, String attrName) { |
|
|
|
public List<HistoryDevicePointVo> device_point(String projectId,String deviceCode,String deviceName, String attrName) { |
|
|
|
List<DeviceInstanceAttrVO> result = new ArrayList<>(); |
|
|
|
List<HistoryDevicePointVo> result = new ArrayList<>(); |
|
|
|
// 查询所有
|
|
|
|
// 查询所有
|
|
|
|
if(StringUtil.isEmpty(deviceCode)){ |
|
|
|
if(StringUtil.isEmpty(deviceCode)){ |
|
|
|
R<List<DeviceInstanceVO>> instances = deviceClient.getOnlineDeviceInstanceSearchName(projectId,""); |
|
|
|
R<List<DeviceInstanceVO>> instances = deviceClient.getOnlineDeviceInstanceSearchName(projectId,""); |
|
|
@ -65,22 +71,93 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService { |
|
|
|
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ |
|
|
|
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
result.addAll(attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getFacDeviceAttrId())).peek(attr->{ |
|
|
|
result.addAll(attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{ |
|
|
|
attr.setName(instance.getName() + "-" + attr.getName()); |
|
|
|
HistoryDevicePointVo point = new HistoryDevicePointVo(); |
|
|
|
|
|
|
|
point.setDeviceCode(instance.getCode()); |
|
|
|
|
|
|
|
point.setName(instance.getName() + "-" + attr.getName()); |
|
|
|
|
|
|
|
point.setSignage(attr.getSignage()); |
|
|
|
|
|
|
|
return point; |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}).collect(Collectors.toList())); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
// 根据设备查询
|
|
|
|
// 根据设备查询
|
|
|
|
Result<List<DeviceInstanceAttrVO>> attrs = deviceClient.getDeviceAttrByName(deviceCode,attrName); |
|
|
|
Result<List<DeviceInstanceAttrVO>> attrs = deviceClient.getDeviceAttrByName(deviceCode,attrName); |
|
|
|
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ |
|
|
|
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ |
|
|
|
return result; |
|
|
|
return result; |
|
|
|
} |
|
|
|
} |
|
|
|
return attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getFacDeviceAttrId())).peek(attr->{ |
|
|
|
return attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{ |
|
|
|
attr.setName(deviceName + "-" + attr.getName()); |
|
|
|
HistoryDevicePointVo point = new HistoryDevicePointVo(); |
|
|
|
|
|
|
|
point.setDeviceCode(deviceCode); |
|
|
|
|
|
|
|
point.setName(deviceName + "-" + attr.getName()); |
|
|
|
|
|
|
|
point.setSignage(attr.getSignage()); |
|
|
|
|
|
|
|
return point; |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
}).collect(Collectors.toList()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* 项目厂组列表 |
|
|
|
|
|
|
|
* @param projectId |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<FacDeviceVO> factory(String projectId) { |
|
|
|
|
|
|
|
Result<List<FacDeviceVO>> result = hzFacClient.facDeviceByProjectId(projectId,""); |
|
|
|
|
|
|
|
if(!result.isSuccess() || CollectionUtil.isEmpty(result.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return result.getData(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 厂租点位列表 |
|
|
|
|
|
|
|
* @param projectId |
|
|
|
|
|
|
|
* @param facDeviceId |
|
|
|
|
|
|
|
* @param facDeviceName |
|
|
|
|
|
|
|
* @param attrName |
|
|
|
|
|
|
|
* @return |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public List<HistoryFactoryPointVo> factory_point(String projectId, String facDeviceId, String facDeviceName, String attrName) { |
|
|
|
|
|
|
|
List<HistoryFactoryPointVo> result = new ArrayList<>(); |
|
|
|
|
|
|
|
// 查询所有
|
|
|
|
|
|
|
|
if(StringUtil.isEmpty(facDeviceId)){ |
|
|
|
|
|
|
|
Result<List<FacDeviceVO>> instances = hzFacClient.facDeviceByProjectId(projectId,attrName); |
|
|
|
|
|
|
|
if(!instances.isSuccess() || CollectionUtil.isEmpty(instances.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
instances.getData().stream().sorted(Comparator.comparing(FacDeviceVO::getName)).forEach(instance->{ |
|
|
|
|
|
|
|
Result<List<FacDeviceAttrVO>> attrs = hzFacClient.facDeviceAttrList(facDeviceId,attrName); |
|
|
|
|
|
|
|
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
result.addAll(attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{ |
|
|
|
|
|
|
|
HistoryFactoryPointVo point = new HistoryFactoryPointVo(); |
|
|
|
|
|
|
|
point.setFactoryId(instance.getId()); |
|
|
|
|
|
|
|
point.setName(attr.getName()); |
|
|
|
|
|
|
|
point.setFactoryAttrId(attr.getId()); |
|
|
|
|
|
|
|
return point; |
|
|
|
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Result<List<FacDeviceAttrVO>> attrs = hzFacClient.facDeviceAttrList(facDeviceId,attrName); |
|
|
|
|
|
|
|
if(!attrs.isSuccess() || CollectionUtil.isEmpty(attrs.getData())){ |
|
|
|
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return attrs.getData().stream().filter(o-> StringUtil.isNotBlank(o.getSignage())).map(attr->{ |
|
|
|
|
|
|
|
HistoryFactoryPointVo point = new HistoryFactoryPointVo(); |
|
|
|
|
|
|
|
point.setFactoryId(facDeviceId); |
|
|
|
|
|
|
|
point.setName(attr.getName()); |
|
|
|
|
|
|
|
point.setFactoryAttrId(attr.getId()); |
|
|
|
|
|
|
|
return point; |
|
|
|
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* 设备历史数据曲线图 |
|
|
|
* 设备历史数据曲线图 |
|
|
|
* @param param |
|
|
|
* @param param |
|
|
|
* @return |
|
|
|
* @return |
|
|
@ -99,7 +176,7 @@ public class HistoryDeviceServiceImpl implements IHistoryDeviceService { |
|
|
|
param.getStartTime(), |
|
|
|
param.getStartTime(), |
|
|
|
param.getEndTime(), |
|
|
|
param.getEndTime(), |
|
|
|
// 默认查询设备 : 0-厂组点, 1-设备
|
|
|
|
// 默认查询设备 : 0-厂组点, 1-设备
|
|
|
|
1, |
|
|
|
0, |
|
|
|
intervalType, |
|
|
|
intervalType, |
|
|
|
param.getIsPage(), |
|
|
|
param.getIsPage(), |
|
|
|
param.getCurrent(), |
|
|
|
param.getCurrent(), |
|
|
|