package com.qianwen.mdc.collect.vo;
|
|
import java.io.Serializable;
|
import java.util.ArrayList;
|
import java.util.List;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import com.alibaba.fastjson.JSONArray;
|
import com.alibaba.fastjson.JSONObject;
|
|
import cn.hutool.core.util.ObjectUtil;
|
import cn.hutool.json.JSONUtil;
|
import io.swagger.annotations.ApiModelProperty;
|
|
|
/**
|
* 工位采集数据点VO
|
*/
|
public class WorkstationDatapointsVO implements Serializable{
|
|
/**
|
* 序列化,应为需要spring缓存
|
*/
|
private static final long serialVersionUID = 6558493027948435061L;
|
|
@ApiModelProperty("点位表头(json数组)")
|
private String dpHead;
|
|
@ApiModelProperty("点位配置(json数组)")
|
private String dpConfig;
|
|
/**
|
* 工位id
|
*/
|
private long workstationId;
|
|
/**
|
* IOT平台appId
|
*/
|
private String appId;
|
|
//private List<DataPoint> points = null;
|
private List<String> points = new ArrayList<>();
|
|
public WorkstationDatapointsVO(long workstationId, String appId,String dpConfig) {
|
super();
|
this.dpConfig = dpConfig;
|
this.workstationId = workstationId;
|
this.appId = appId;
|
|
initPoints();
|
}
|
void initPoints() {
|
if(ObjectUtil.isEmpty(dpConfig)) {
|
return;
|
}
|
|
JSONArray ptArr = JSONArray.parseArray(dpConfig);
|
|
points = new ArrayList<>();
|
JSONObject ptObj;
|
for(int i=0;i<ptArr.size();i++) {
|
ptObj = ptArr.getJSONObject(i);
|
|
//DataPoint dp = new DataPoint();
|
//dp.setDpName(ptObj.getString("dpName"));
|
|
points.add(ptObj.getString("dpName"));
|
}
|
}
|
|
public String getDpConfig() {
|
return dpConfig;
|
}
|
|
public void setDpConfig(String dpConfig) {
|
this.dpConfig = dpConfig;
|
}
|
|
public long getWorkstationId() {
|
return workstationId;
|
}
|
|
public void setWorkstationId(long workstationId) {
|
this.workstationId = workstationId;
|
}
|
|
public String getDpHead() {
|
return dpHead;
|
}
|
|
public void setDpHead(String dpHead) {
|
this.dpHead = dpHead;
|
}
|
|
public String getAppId() {
|
return appId;
|
}
|
|
public void setAppId(String appId) {
|
this.appId = appId;
|
}
|
|
|
/**
|
* 判断采集变量名称是否在数据点配置种
|
* @param dpName
|
* @return
|
*/
|
public boolean containsDataPoint(String dpName) {
|
if(ObjectUtil.isEmpty(points)) {
|
return false;
|
}
|
|
return points.contains(dpName);
|
/*
|
for(String dpn : points) {
|
if(StringUtils.equals(dpn, dpName)) {
|
return true;
|
}
|
}
|
return false;
|
*/
|
}
|
|
|
}
|
/*
|
class DataPoint{
|
private String dpName;
|
|
public String getDpName() {
|
return dpName;
|
}
|
|
public void setDpName(String dpName) {
|
this.dpName = dpName;
|
}
|
|
|
}
|
*/
|