|
@@ -54,43 +54,44 @@ public class OpcService {
|
|
|
Map<Integer, List<RemoteOpc>> listMap = remoteOpcList.stream().collect(Collectors.groupingBy(RemoteOpc::getLine));
|
|
|
OpcDAClient.connect();
|
|
|
OpcDAClient.findAllItem();
|
|
|
- AddFailedException exception = OpcDAClient.addGroupList(listMap);
|
|
|
- Map<String, Integer> failedItems = exception.getErrors();
|
|
|
- Map<String, Item> addItems = exception.getItems();
|
|
|
List<RemoteOpc> remoteOpcFailList = new ArrayList<>();
|
|
|
- if (failedItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
|
- for (Map.Entry<String, Integer> entry : failedItems.entrySet()) {
|
|
|
- RemoteOpc remoteOpc = new RemoteOpc();
|
|
|
- // 因为有些标签是: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));
|
|
|
+ AddFailedException exception = OpcDAClient.addGroupList(listMap);
|
|
|
+ if (exception != null) {
|
|
|
+ Map<String, Integer> failedItems = exception.getErrors();
|
|
|
+ Map<String, Item> addItems = exception.getItems();
|
|
|
+ if (failedItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
|
+ for (Map.Entry<String, Integer> entry : failedItems.entrySet()) {
|
|
|
+ RemoteOpc remoteOpc = new RemoteOpc();
|
|
|
+ // 因为有些标签是: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.setRemark("opc server未找到改点位。可能原因1:AV/DV配置错误,2:opc server中未配置");
|
|
|
+ log.error("opc server未找到该点位。key: " + remoteOpc.getPositionNum() + ", value: " + entry.getValue());
|
|
|
+ remoteOpcFailList.add(remoteOpc);
|
|
|
}
|
|
|
- remoteOpc.setCreatedFlag(0);
|
|
|
- remoteOpc.setRemark("opc server未找到改点位。可能原因1:AV/DV配置错误,2:opc server中未配置");
|
|
|
- log.error("opc server未找到该点位。key: " + remoteOpc.getPositionNum() + ", value: " + entry.getValue());
|
|
|
- remoteOpcFailList.add(remoteOpc);
|
|
|
}
|
|
|
- }
|
|
|
- if (addItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
|
- for (Map.Entry<String, Item> entry : addItems.entrySet()) {
|
|
|
- RemoteOpc remoteOpc = new RemoteOpc();
|
|
|
- // 因为有些标签是: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));
|
|
|
+ if (addItems != null) {// 有不存在的item,需要更新对应的点位信息
|
|
|
+ for (Map.Entry<String, Item> entry : addItems.entrySet()) {
|
|
|
+ RemoteOpc remoteOpc = new RemoteOpc();
|
|
|
+ // 因为有些标签是: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.setRemark("opc server已配置,AV/DV配置正确");
|
|
|
+ log.error("opc server已配置。key: " + remoteOpc.getPositionNum() + ", value: " + entry.getValue());
|
|
|
+ remoteOpcFailList.add(remoteOpc);
|
|
|
}
|
|
|
- remoteOpc.setCreatedFlag(1);
|
|
|
- remoteOpc.setRemark("opc server已配置,AV/DV配置正确");
|
|
|
- log.error("opc server已配置。key: " + remoteOpc.getPositionNum() + ", value: " + entry.getValue());
|
|
|
- remoteOpcFailList.add(remoteOpc);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
if (!CollectionUtils.isEmpty(remoteOpcFailList)) {
|
|
|
remoteOpcMapper.updateBatch(remoteOpcFailList);
|
|
|
}
|
|
@@ -99,8 +100,13 @@ public class OpcService {
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
|
|
- String ss = "PT9836";
|
|
|
- int index = ss.lastIndexOf("_");
|
|
|
- System.out.println(ss.substring(0, index));
|
|
|
+
|
|
|
+ Item[][] itemArrList = new Item[10][];
|
|
|
+ Item[] itemArr = new Item[10];
|
|
|
+ itemArrList[0] = itemArr;
|
|
|
+
|
|
|
+ Item[] itemArr2 = new Item[5];
|
|
|
+ itemArrList[1] = itemArr2;
|
|
|
+ System.out.println("");
|
|
|
}
|
|
|
}
|