Browse Source

修改后台管理系统中,配置数据驱动,数据项未更新同步的问题,修改系统扫描数据组,如果未运行和异常停止的,都自启动

zhoupeng 1 year ago
parent
commit
1f8f9633d9

+ 1 - 1
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/dynamicSchedule/DynamicScheduleConfig.java

@@ -69,7 +69,7 @@ public class DynamicScheduleConfig implements SchedulingConfigurer {
                 String clsId = dataSource.getClsId().toUpperCase();
                 DataSourceType dataSourceType = dataSourceDao.getDataSourceTypeById(dataSource.getTypeId());
                 if (OpcUtil.isOpcDa(dataSourceType.getDataSourceTypeKey())) {
-                    if (itemGroup.getRunState() == ConstantStr.START_UP) {
+                    if (itemGroup.getRunState() == ConstantStr.START_UP || itemGroup.getRunState() == ConstantStr.EXCEPT_STOP_UP) {
                         if (Blank.isEmpty(dataSource.getIpAddress(), dataSource.getIpUserName(), dataSource.getIpPassword())) {
                             throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "数据组配置的数据源的ip地址,帐户,密码都不能为空");
                         }

+ 2 - 4
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/service/impl/DataSourceServiceImpl.java

@@ -315,7 +315,6 @@ public class DataSourceServiceImpl implements DataSourceService {
             if (Blank.isNotEmpty(driverBasicItemList)) {
                 dataSourceDao.addDriverBasicItemList(id, driverBasicItemList);
             }
-            DataSourceDriver newDataSourceDriver = dataSourceDao.getDataSourceDriverByid(dataSourceDriver.getId());
             List<DataSource> dataSourceList = dataSourceDao.getDataSourceByclsId(clsId);
             if (Blank.isNotEmpty(dataSourceList)) {
                 List<ItemGroup> itemGroupList = itemGroupDao.getIgListByDsId(dataSourceList);
@@ -327,8 +326,7 @@ public class DataSourceServiceImpl implements DataSourceService {
                         }
                     }
                     List<Item> itemList = itemGroupDao.getItemListByGidList(itemGroupList);
-                    itemList = OpcDaUtil.genBasicDa(itemList,
-                            Blank.isEmpty(newDataSourceDriver) ? null : newDataSourceDriver);
+                    itemList = OpcDaUtil.genBasicDa(itemList, dataSourceDriver);
                     if (Blank.isNotEmpty(itemList)) {
                         String strArr = "";
                         int size = itemList.size();
@@ -367,7 +365,7 @@ public class DataSourceServiceImpl implements DataSourceService {
             List<ItemGroup> itemGroupList = itemGroupDao.getIgListByDsId(dataSourceList);
             if (Blank.isNotEmpty(itemGroupList)) {
                 for (ItemGroup itemGroup : itemGroupList) {
-                    itemGroupDao.updateItByItemGroupId(itemGroup.getId(),ConstantStr.BASIC_ATTRIBUTES);
+                    itemGroupDao.updateItByItemGroupId(itemGroup.getId(), ConstantStr.BASIC_ATTRIBUTES);
                 }
             }
         }

+ 0 - 30
chaunyi_opc/opc_da/src/main/java/com/example/opc_da/util/OpcDaUtil.java

@@ -173,36 +173,6 @@ public class OpcDaUtil {
                 itemList.get(i).setItemType(ConstantStr.BASIC_ATTRIBUTES);
             }
         }
-//        if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.KEPSERVER.getValue()) ||
-//                dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.SCADA.getValue()) ||
-//                dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.PAS300.getValue())
-//        ) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                itemList.get(i).setItemReadName(itemList.get(i).getItemName());
-//            }
-//        } else if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.YOKOGAWA.getValue())) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                itemList.get(i).setItemReadName(itemList.get(i).getItemName().replaceFirst("\\.", "!"));
-//            }
-//        } else if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.OPCIFIX.getValue())) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                String itemName = itemList.get(i).getItemName();
-//                try {
-//                    int j = itemName.indexOf(".");
-//                    String s = itemName.substring(j + 1);
-//                    itemList.get(i).setItemReadName(itemName.substring(0, j) + s.substring(s.indexOf(".")));
-//                } catch (Exception e) {
-//                    itemList.remove(i);
-//                }
-//            }
-//        } else if (dataSource.getClsId().toUpperCase().equals(OpcDaDriverEnum.WINCC.getValue())) {
-//            for (int i = 0; i < itemList.size(); i++) {
-//                String itemName = itemList.get(i).getItemName();
-//                itemList.get(i).setItemReadName(itemName.substring(itemName.lastIndexOf(".") + 1));
-//            }
-//        } else {
-//            throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前未适配此种驱动类型");
-//        }
         return itemList;
     }