|
@@ -61,20 +61,32 @@ public class OpcService {
|
|
if (failedItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
if (failedItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
for (Map.Entry<String, Integer> entry : failedItems.entrySet()) {
|
|
for (Map.Entry<String, Integer> entry : failedItems.entrySet()) {
|
|
RemoteOpc remoteOpc = new RemoteOpc();
|
|
RemoteOpc remoteOpc = new RemoteOpc();
|
|
- remoteOpc.setPositionNum(entry.getKey().split("_")[0]);
|
|
|
|
|
|
+ // 因为有些标签是:PT_9836_AV,不能用 entry.getKey().split("_")[0],需要找到最后一个_
|
|
|
|
+ int index = entry.getKey().lastIndexOf("_");
|
|
|
|
+ if(index == -1){
|
|
|
|
+ remoteOpc.setPositionNum(entry.getKey());
|
|
|
|
+ }else{
|
|
|
|
+ remoteOpc.setPositionNum(entry.getKey().substring(0, index));
|
|
|
|
+ }
|
|
remoteOpc.setCreatedFlag(0);
|
|
remoteOpc.setCreatedFlag(0);
|
|
remoteOpc.setRemark("opc server未找到改点位。可能原因1:AV/DV配置错误,2:opc server中未配置");
|
|
remoteOpc.setRemark("opc server未找到改点位。可能原因1:AV/DV配置错误,2:opc server中未配置");
|
|
- log.error("opc server未找到该点位。key: " + entry.getKey() + ", value: " + entry.getValue());
|
|
|
|
|
|
+ log.error("opc server未找到该点位。key: " + remoteOpc.getPositionNum() + ", value: " + entry.getValue());
|
|
remoteOpcFailList.add(remoteOpc);
|
|
remoteOpcFailList.add(remoteOpc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (addItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
if (addItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
for (Map.Entry<String, Item> entry : addItems.entrySet()) {
|
|
for (Map.Entry<String, Item> entry : addItems.entrySet()) {
|
|
RemoteOpc remoteOpc = new RemoteOpc();
|
|
RemoteOpc remoteOpc = new RemoteOpc();
|
|
- remoteOpc.setPositionNum(entry.getKey().split("_")[0]);
|
|
|
|
|
|
+ // 因为有些标签是:PT_9836_AV,不能用 entry.getKey().split("_")[0],需要找到最后一个_
|
|
|
|
+ int index = entry.getKey().lastIndexOf("_");
|
|
|
|
+ if(index == -1){
|
|
|
|
+ remoteOpc.setPositionNum(entry.getKey());
|
|
|
|
+ }else{
|
|
|
|
+ remoteOpc.setPositionNum(entry.getKey().substring(0, index));
|
|
|
|
+ }
|
|
remoteOpc.setCreatedFlag(1);
|
|
remoteOpc.setCreatedFlag(1);
|
|
remoteOpc.setRemark("opc server已配置,AV/DV配置正确");
|
|
remoteOpc.setRemark("opc server已配置,AV/DV配置正确");
|
|
- log.error("opc server已配置。key: " + entry.getKey() + ", value: " + entry.getValue());
|
|
|
|
|
|
+ log.error("opc server已配置。key: " + remoteOpc.getPositionNum() + ", value: " + entry.getValue());
|
|
remoteOpcFailList.add(remoteOpc);
|
|
remoteOpcFailList.add(remoteOpc);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -87,7 +99,8 @@ public class OpcService {
|
|
}
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
public static void main(String[] args) {
|
|
- String ss = "FT10402B_AV";
|
|
|
|
- System.out.println(ss.split("_")[0]);
|
|
|
|
|
|
+ String ss = "PT9836";
|
|
|
|
+ int index = ss.lastIndexOf("_");
|
|
|
|
+ System.out.println(ss.substring(0, index));
|
|
}
|
|
}
|
|
}
|
|
}
|