|
@@ -13,6 +13,7 @@ import com.example.opc_common.util.Blank;
|
|
|
import com.example.opc_common.util.DateUtil;
|
|
|
import com.example.opc_common.util.OpcUtil;
|
|
|
import com.example.opc_common.util.Result;
|
|
|
+import com.example.opc_da.alarmConfig.AlarmTaskRegister;
|
|
|
import com.example.opc_da.dao.*;
|
|
|
import com.example.opc_da.service.ItemGroupService;
|
|
|
import com.example.opc_da.util.*;
|
|
@@ -67,6 +68,9 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
@Resource
|
|
|
private DeviceLedgerDao deviceLedgerDao;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private AlarmTaskRegister alarmTaskRegister;
|
|
|
+
|
|
|
@Override
|
|
|
public synchronized Result addItemGroup(ItemGroup itemGroup) {
|
|
|
String currentUserId = userUtil.getCurrentUserId();
|
|
@@ -86,9 +90,9 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
if (Blank.isNotEmpty(isExistItemGroup)) {
|
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "已经存在此数据组的名称了,请更改名称");
|
|
|
}
|
|
|
+ List<Item> dbItemList = itemGroupDao.getItemListByGroupId(id, null);
|
|
|
if (dataSourceId != itemGroup1.getDataSourceId()) {
|
|
|
// 删除前检查占用
|
|
|
- List<Item> dbItemList = itemGroupDao.getItemListByGroupId(id, null);
|
|
|
List<Integer> delList = dbItemList.stream().map(v -> v.getItemId()).collect(Collectors.toList());
|
|
|
if (delList.size() > 0) {
|
|
|
List<Map<String, Object>> reportDataPolicyNameList = reportDataPolicyDao.getReportDataPolicyNameByItemId(delList);
|
|
@@ -106,6 +110,13 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
}
|
|
|
if (dataSourceId != itemGroup1.getDataSourceId()) {
|
|
|
alarmConfigDao.delAlarmConfigByItemGroupId(id);
|
|
|
+ // 删除点位报警定时任务
|
|
|
+ dbItemList.stream().forEach(item -> {
|
|
|
+ AlarmConfig alarmConfig = new AlarmConfig();
|
|
|
+ alarmConfig.setItemGroupId(item.getItemGroupId());
|
|
|
+ alarmConfig.setItemId(item.getItemId());
|
|
|
+ alarmTaskRegister.removeItemTask(alarmConfig);
|
|
|
+ });
|
|
|
itemGroupDao.delItemByGroupId(id);
|
|
|
}
|
|
|
return Result.ok("修改数据组成功");
|
|
@@ -208,6 +219,14 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
}
|
|
|
|
|
|
alarmConfigDao.delAlarmConfigByItemGroupId(id);
|
|
|
+ List<Item> dbItemList = itemGroupDao.getItemListByGroupId(id, null);
|
|
|
+ // 删除点位报警定时任务
|
|
|
+ dbItemList.stream().forEach(item -> {
|
|
|
+ AlarmConfig alarmConfig = new AlarmConfig();
|
|
|
+ alarmConfig.setItemGroupId(item.getItemGroupId());
|
|
|
+ alarmConfig.setItemId(item.getItemId());
|
|
|
+ alarmTaskRegister.removeItemTask(alarmConfig);
|
|
|
+ });
|
|
|
itemGroupDao.delItemByGroupId(id);
|
|
|
itemGroupDao.delItemGroupById(id);
|
|
|
return Result.ok("删除成功");
|
|
@@ -300,6 +319,14 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
if(alarmConfigDao.delAlarmConfigByIdList(idList)<=0){
|
|
|
return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), ResultEnum.SERVER_ERROR.getRespMsg());
|
|
|
}
|
|
|
+ List<Item> dbItemList = itemGroupDao.getItemValueByIds(idList);
|
|
|
+ // 删除点位报警定时任务
|
|
|
+ dbItemList.stream().forEach(item -> {
|
|
|
+ AlarmConfig alarmConfig = new AlarmConfig();
|
|
|
+ alarmConfig.setItemGroupId(item.getItemGroupId());
|
|
|
+ alarmConfig.setItemId(item.getItemId());
|
|
|
+ alarmTaskRegister.removeItemTask(alarmConfig);
|
|
|
+ });
|
|
|
if (itemGroupDao.deleteItemByIdList(idList) <= 0) {
|
|
|
return Result.no(ResultEnum.SERVER_ERROR.getRespCode(), ResultEnum.SERVER_ERROR.getRespMsg());
|
|
|
}
|
|
@@ -427,6 +454,14 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
}
|
|
|
if(delList.size() > 0){
|
|
|
alarmConfigDao.delAlarmConfigByIdList(delList);
|
|
|
+ List<Item> dbItemList2 = itemGroupDao.getItemValueByIds(delList);
|
|
|
+ // 删除点位报警定时任务
|
|
|
+ dbItemList2.stream().forEach(item -> {
|
|
|
+ AlarmConfig alarmConfig = new AlarmConfig();
|
|
|
+ alarmConfig.setItemGroupId(item.getItemGroupId());
|
|
|
+ alarmConfig.setItemId(item.getItemId());
|
|
|
+ alarmTaskRegister.removeItemTask(alarmConfig);
|
|
|
+ });
|
|
|
itemGroupDao.deleteItemByIdList(delList);
|
|
|
}
|
|
|
return Result.ok("添加数据组成功");
|