瀏覽代碼

Merge branch 'master' of http://116.63.33.55/git/read_opc

FinalYu 1 年之前
父節點
當前提交
014e2d63dc

+ 0 - 1
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/OpcDaApplication.java

@@ -15,7 +15,6 @@ import org.springframework.web.client.RestTemplate;
 @EnableScheduling//开启定时器
 @MapperScan("com.example.opc_da.dao")
 public class OpcDaApplication {
-
     public static void main(String[] args) {
         SpringApplication.run(OpcDaApplication.class, args);
     }

+ 1 - 10
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/controller/DataSourceController.java

@@ -1,8 +1,7 @@
 package com.example.opc_da.controller;
 
-import com.example.opc_common.entity.DataSourceDriver;
 import com.example.opc_common.entity.DataSource;
-import com.example.opc_common.entity.DriverBasicItem;
+import com.example.opc_common.entity.DataSourceDriver;
 import com.example.opc_common.enums.ModelEnum;
 import com.example.opc_common.enums.OperationEnum;
 import com.example.opc_common.enums.ResultEnum;
@@ -121,14 +120,6 @@ public class DataSourceController {
         return dataSourceService.getNextAllItem(id, itemStr);
     }
 
-    @GetMapping("/readItemValue")
-    public Result readItemValue(Integer id, String itemStr) {
-        if (Blank.isEmpty(id)) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据源不能为空");
-        }
-        return dataSourceService.readItemValue(id, itemStr);
-    }
-
     /**
      * 通过id删除数据源配置
      *

+ 1 - 4
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/DataSourceService.java

@@ -1,8 +1,7 @@
 package com.example.opc_da.service;
 
-import com.example.opc_common.entity.DataSourceDriver;
 import com.example.opc_common.entity.DataSource;
-import com.example.opc_common.entity.DriverBasicItem;
+import com.example.opc_common.entity.DataSourceDriver;
 import com.example.opc_common.util.Result;
 
 public interface DataSourceService {
@@ -31,8 +30,6 @@ public interface DataSourceService {
 
     Result delDataSourceDriver(Integer id);
 
-    Result readItemValue(Integer id, String itemStr);
-
     Result getOpcDaDriverEnum();
 
     Result getDataSourceDriverByid(Integer id);

+ 0 - 31
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/DataSourceServiceImpl.java

@@ -188,37 +188,6 @@ public class DataSourceServiceImpl implements DataSourceService {
     }
 
     @Override
-    public Result readItemValue(Integer id, String itemStr) {
-        DataSource dataSource = dataSourceDao.getDataSourceById(id);
-        if (Blank.isEmpty(dataSource)) {
-            return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "没有此数据源配置,请刷新");
-        }
-        if (Blank.isNotEmpty(dataSource.getIpPassword())) {
-            dataSource = DataSource.convertPassword(dataSource);
-        }
-        DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getTypeId());
-        String dataSourceTypeKey = dataSourceType.getDataSourceTypeKey();
-        if (OpcUtil.isOpcUa(dataSourceTypeKey)) {
-            if (Blank.isEmpty(dataSource.getIpAddress(), dataSource.getIpPort(), dataSource.getIsAnonymous())) {
-                return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "ip地址,端口号,匿名方式都不能为空");
-            }
-            if (dataSource.getIsAnonymous() == ConstantStr.NOT_ANONYMOUS) {
-                if (Blank.isEmpty(dataSource.getIpUserName())) {
-                    return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "选择不匿名方式,需要填写账号");
-                }
-            }
-            return restTemplate.postForObject(opcUaUrl + "/dataSource/getNextAllItem?id=" + id + "&itemStr=" + itemStr, new HttpEntity<>(null, new HttpHeaders()), Result.class);
-        } else if (OpcUtil.isOpcDa(dataSourceTypeKey)) {
-            if (Blank.isEmpty(dataSource.getIpAddress(), dataSource.getIpUserName(), dataSource.getClsId())) {
-                return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "ip地址,账号,opc驱动都不能为空");
-            }
-            return OpcDaUtil.readItemValue(dataSource, itemStr);
-        } else {
-            throw new CustomException(ResultEnum.SERVER_ERROR.getRespCode(), "目前还没有此种类型的连接方式");
-        }
-    }
-
-    @Override
     public Result getOpcDaDriverEnum() {
         Class<OpcDaDriverEnum> clazz = OpcDaDriverEnum.class;
         Object[] objects = clazz.getEnumConstants();

+ 1 - 1
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/UserServiceImpl.java

@@ -699,7 +699,7 @@ public class UserServiceImpl implements UserService {
         if (Blank.isNotEmpty(token)) {
             redisUtil.del(token);
         }
-        return Result.ok("清空用户登录信息成功");
+        return Result.ok("强制下线成功");
     }
 
 

+ 8 - 0
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/task/AsyncAsyncTask.java

@@ -58,8 +58,16 @@ public class AsyncAsyncTask {
     }
 
 
+    /**
+     * 设备报表数据增量速度不高,数据每次过来,
+     * @param reportTableItemList
+     */
     public void addReportTableItemList(List<ReportTableItem> reportTableItemList) {
         if (Blank.isNotEmpty(reportTableItemList)) {
+//            for (ReportTableItem reportTableItem:reportTableItemList
+//                 ) {
+//
+//            }
             reportTableDao.addReportTableItemList(reportTableItemList);
         }
     }

+ 5 - 97
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/util/OpcDaUtil.java

@@ -17,6 +17,7 @@ import org.jinterop.dcom.core.JIVariant;
 import org.openscada.opc.dcom.da.OPCSERVERSTATE;
 import org.openscada.opc.dcom.list.ClassDetails;
 import org.openscada.opc.lib.common.ConnectionInformation;
+import org.openscada.opc.lib.da.AddFailedException;
 import org.openscada.opc.lib.da.Group;
 import org.openscada.opc.lib.da.ItemState;
 import org.openscada.opc.lib.da.Server;
@@ -253,10 +254,8 @@ public class OpcDaUtil {
     }
 
     public static List<JSONObject> opcReadItemListValue(DataSource dataSource, String[] items, List<Item> itemList, Map<String, DataModel> dmMap) {
-        Server server = null;
         try {
-            server = createServer(dataSource);
-            server.connect();
+            Server server = getServer(dataSource);
             if (null == server.getServerState()) {
                 throw new CustomException(ResultEnum.NOT_FOUND.getRespCode(), "连接失败");
             }
@@ -316,19 +315,14 @@ public class OpcDaUtil {
                         .sorted(Comparator.comparing((JSONObject jsonObject) -> jsonObject.getInteger("eventMode"), Comparator.nullsFirst(Integer::compareTo).reversed())
                                 .thenComparing(jsonObject -> jsonObject.getString("itemName")
                                 )).collect(Collectors.toList());
-//                jsonObjectList.stream()
-//                        .sorted(Comparator.comparing((JSONObject jsonObject) -> jsonObject.getString("itemName"))
-//                                .thenComparing(jsonObject -> jsonObject.getInteger("eventMode"), Comparator.nullsFirst(Integer::compareTo).reversed()
-//                                )).collect(Collectors.toList());
                 return jsonObjectList;
             }
+        } catch (AddFailedException e) {
+            e.printStackTrace();
+            throw new CustomException(ResultEnum.REQUEST_TIME_OUT.getRespCode(), "数据项通信异常");
         } catch (Exception e) {
             e.printStackTrace();
             throw new CustomException(ResultEnum.REQUEST_TIME_OUT.getRespCode(), genException(e.getMessage()));
-        } finally {
-            if (Blank.isNotEmpty(server)) {
-                server.dispose();
-            }
         }
         return null;
     }
@@ -400,37 +394,6 @@ public class OpcDaUtil {
         }
     }
 
-    public static Result readItemValue(DataSource dataSource, String itemStr) {
-        Server server = null;
-        try {
-            server = createServer(dataSource);
-            server.connect();
-            if (null == server.getServerState()) {
-                throw new CustomException(ResultEnum.NOT_FOUND.getRespCode(), "连接失败");
-            }
-            if (OPCSERVERSTATE.OPC_STATUS_RUNNING == server.getServerState().getServerState()) {
-                Group group = server.addGroup();
-                org.openscada.opc.lib.da.Item item = group.addItem(itemStr);
-                Map<org.openscada.opc.lib.da.Item, ItemState> read = group.read(true, item);
-                ItemState itemState = read.get(item);
-                Map<String, Object> val = getVal(itemState.getValue());
-                String javaType = val.get("javaType").toString();
-                Object value = val.get("value");
-                Map<String, Object> map = new HashMap<>();
-                map.put("javaType", javaType);
-                map.put("value", value);
-                return Result.ok(map);
-            }
-        } catch (Exception e) {
-            throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), genException(e.getMessage()));
-        } finally {
-            if (Blank.isNotEmpty(server)) {
-                server.dispose();
-            }
-        }
-        return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
-    }
-
     public static Result getNextAllItem(DataSource dataSource, String itemStr) {
         try {
             Server server = getServer(dataSource);
@@ -453,36 +416,6 @@ public class OpcDaUtil {
         return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), ResultEnum.REQUEST_WRONGPARAMS.getRespMsg());
     }
 
-//    public static JSONObject getNextItem(TreeBrowser treeBrowser, String itemStr) {
-//        if (Blank.isEmpty(itemStr)) {
-//            return browserTree(treeBrowser, new Branch());
-//        } else {
-//            JSONObject jsonObject = new JSONObject();
-//            String[] split = itemStr.split("!@");
-//            Branch branch = new Branch();
-//            List<Branch> branchList = getBranch(treeBrowser, branch);
-//            for (int i = 0; i < split.length; i++) {
-//                String itemId = split[i];
-//                if (i == split.length - 1) {
-//                    for (Branch branch1 : branchList) {
-//                        if (itemId.equals(branch1.getName())) {
-//                            jsonObject = browserTree(treeBrowser, branch1);
-//                            break;
-//                        }
-//                    }
-//                } else {
-//                    for (Branch branch1 : branchList) {
-//                        if (itemId.equals(branch1.getName())) {
-//                            branchList = getBranch(treeBrowser, branch1);
-//                            break;
-//                        }
-//                    }
-//                }
-//            }
-//            return jsonObject;
-//        }
-//    }
-
     /**
      * 优化之后获取下级节点
      *
@@ -509,31 +442,6 @@ public class OpcDaUtil {
         }
     }
 
-    public static List<Branch> getBranch(TreeBrowser treeBrowser, Branch branch) {
-        try {
-            treeBrowser.fillBranches(branch);
-        } catch (Exception ignored) {
-        }
-        try {
-            treeBrowser.fillLeaves(branch);
-        } catch (Exception ignored) {
-        }
-//        Iterator iter = branch.getLeaves().iterator();
-//        while (iter.hasNext()) {
-//            Leaf leaf = (Leaf) iter.next();
-//            //key是leaf.getName(),value是leaf.getItemId()
-//            tree.addTree(new MapTree(leaf.getName(), leaf.getItemId()));
-//            //this.itemList.put(leaf.getName(),leaf.getItemId())
-//        }
-        Iterator iter = branch.getBranches().iterator();
-        List<Branch> branchList = new ArrayList<>();
-        while (iter.hasNext()) {
-            branch = (Branch) iter.next();
-            branchList.add(branch);
-        }
-        return branchList;
-    }
-
     /**
      * 通过上一级,获取下一次的所有item
      *

+ 4 - 1
chaunyi_opc/opc_da/src/main/resources/application-dev.yml

@@ -15,7 +15,7 @@ spring:
     password: root
     hikari:
       minimum-idle: 100
-      connection-timeout: 60000
+      connection-timeout: 30000
       idle-timeout: 1800000
       maximum-pool-size: 500
       max-lifetime: 0
@@ -37,3 +37,6 @@ mybatis:
   configuration:
     #开启sql日志文件
     log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+logging:
+  level:
+    root: error

+ 4 - 1
chaunyi_opc/opc_da/src/main/resources/application-prod.yml

@@ -15,7 +15,7 @@ spring:
     password: root
     hikari:
       minimum-idle: 100
-      connection-timeout: 60000
+      connection-timeout: 30000
       idle-timeout: 1800000
       maximum-pool-size: 500
       max-lifetime: 0
@@ -37,3 +37,6 @@ spring:
 #  configuration:
     #开启sql日志文件
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
+logging:
+  level:
+    root: error

+ 0 - 6
chuanyi-admin/package.json

@@ -6,8 +6,6 @@
   "scripts": {
     "dev": "vue-cli-service serve",
     "lint": "eslint --fix --ext .js,.vue src",
-    "electron:build": "vue-cli-service electron:build",
-    "electron:serve": "vue-cli-service electron:serve",
     "build:prod": "vue-cli-service build",
     "build:stage": "vue-cli-service build --mode staging",
     "preview": "node build/index.js --preview",
@@ -26,7 +24,6 @@
     "driver.js": "0.9.5",
     "dropzone": "5.5.1",
     "echarts": "4.2.1",
-    "electron": "^23.1.4",
     "element-ui": "2.13.2",
     "file-saver": "2.0.1",
     "fuse.js": "3.4.4",
@@ -66,8 +63,6 @@
     "chalk": "2.4.2",
     "chokidar": "2.1.5",
     "connect": "3.6.6",
-    "electron": "^13.0.0",
-    "electron-devtools-installer": "^3.1.0",
     "eslint": "6.7.2",
     "eslint-plugin-vue": "6.2.2",
     "html-webpack-plugin": "3.2.0",
@@ -82,7 +77,6 @@
     "serve-static": "1.13.2",
     "svg-sprite-loader": "4.1.3",
     "svgo": "1.2.0",
-    "vue-cli-plugin-electron-builder": "~2.1.1",
     "vue-template-compiler": "2.6.10"
   },
   "browserslist": [