|
@@ -19,6 +19,7 @@ import com.example.opc_da.task.OpcDaTask;
|
|
import com.example.opc_da.util.OpcDaUtil;
|
|
import com.example.opc_da.util.OpcDaUtil;
|
|
import com.example.opc_da.util.RedisUtil;
|
|
import com.example.opc_da.util.RedisUtil;
|
|
import com.example.opc_da.util.UserUtil;
|
|
import com.example.opc_da.util.UserUtil;
|
|
|
|
+import org.openscada.opc.lib.da.Server;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.http.HttpEntity;
|
|
import org.springframework.http.HttpEntity;
|
|
@@ -125,18 +126,18 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
}
|
|
}
|
|
itemGroupDao.delItemByGroupId(id);
|
|
itemGroupDao.delItemByGroupId(id);
|
|
if (Blank.isNotEmpty(itemGroup.getItemList())) {
|
|
if (Blank.isNotEmpty(itemGroup.getItemList())) {
|
|
- List<Item> itemList = itemGroup.getItemList();
|
|
|
|
if (dataSourceType.getDataSourceTypeKey().equals(DataSourceTypeEnum.OPC_DA_REAL.getValue())) {
|
|
if (dataSourceType.getDataSourceTypeKey().equals(DataSourceTypeEnum.OPC_DA_REAL.getValue())) {
|
|
- itemGroup.setItemList(OpcDaUtil.genReadNameDa(dataSource, itemList));
|
|
|
|
|
|
+ itemGroup.setItemList(OpcDaUtil.genReadNameDa(dataSource, itemGroup.getItemList()));
|
|
}
|
|
}
|
|
|
|
+ List<Item> itemList = itemGroup.getItemList();
|
|
int count = 0;
|
|
int count = 0;
|
|
for (Item item : itemList) {
|
|
for (Item item : itemList) {
|
|
if (Blank.isNotEmpty(item.getTableReportId())) {
|
|
if (Blank.isNotEmpty(item.getTableReportId())) {
|
|
- count += 1;
|
|
|
|
|
|
+ count++;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (count > 1) {
|
|
if (count > 1) {
|
|
- return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "一个数据组中,最多只能配置一个事件驱动报表");
|
|
|
|
|
|
+ throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "一个数据组中,最多只能配置一个事件驱动报表");
|
|
}
|
|
}
|
|
itemGroupDao.addItem(id, itemList);
|
|
itemGroupDao.addItem(id, itemList);
|
|
}
|
|
}
|
|
@@ -210,6 +211,20 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
clsId.equals(OpcDaDriverEnum.YOKOGAWA.getValue()) ||
|
|
clsId.equals(OpcDaDriverEnum.YOKOGAWA.getValue()) ||
|
|
clsId.equals(OpcDaDriverEnum.PAS300.getValue())
|
|
clsId.equals(OpcDaDriverEnum.PAS300.getValue())
|
|
) {
|
|
) {
|
|
|
|
+ Server server = null;
|
|
|
|
+ try {
|
|
|
|
+ server = OpcDaUtil.createServer(dataSource);
|
|
|
|
+ if (Blank.isEmpty(server)) {
|
|
|
|
+ return Result.no(ResultEnum.REQUEST_TIME_OUT.getRespCode(), "创建服务失败");
|
|
|
|
+ }
|
|
|
|
+ server.connect();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), OpcDaUtil.genException(e.getMessage()));
|
|
|
|
+ } finally {
|
|
|
|
+ if (Blank.isNotEmpty(server)) {
|
|
|
|
+ server.dispose();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
|
|
redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
|
|
//新增定时器任务
|
|
//新增定时器任务
|
|
String cronId = "";
|
|
String cronId = "";
|
|
@@ -321,18 +336,6 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
if (itemGroup.getRunState() == ConstantStr.START_UP) {
|
|
if (itemGroup.getRunState() == ConstantStr.START_UP) {
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此数据组现在处于运行中,不允许修改");
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此数据组现在处于运行中,不允许修改");
|
|
}
|
|
}
|
|
- if (Blank.isNotEmpty(item.getTableReportId())) {
|
|
|
|
- List<Item> itemList = itemGroupDao.getItemListByGroupId(itemGroup.getId());
|
|
|
|
- if (Blank.isNotEmpty(itemList)) {
|
|
|
|
- for (Item item2 : itemList) {
|
|
|
|
- if (Blank.isNotEmpty(item2.getTableReportId())) {
|
|
|
|
- if (!item2.getId().equals(item.getId())) {
|
|
|
|
- return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "此数据组中有其他项配置了事件驱动报表,修改失败");
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
if (itemGroupDao.updateItem(item) <= 0) {
|
|
if (itemGroupDao.updateItem(item) <= 0) {
|
|
return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "修改item失败");
|
|
return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), "修改item失败");
|
|
}
|
|
}
|