|
@@ -12,11 +12,10 @@ import com.example.opc_common.util.Result;
|
|
|
import com.example.opc_da.dao.DataModelDao;
|
|
|
import com.example.opc_da.dao.DataSourceDao;
|
|
|
import com.example.opc_da.dao.ItemGroupDao;
|
|
|
-import com.example.opc_da.dao.MessageNoticeDao;
|
|
|
import com.example.opc_da.dynamicSchedule.CronTaskRegister;
|
|
|
import com.example.opc_da.dynamicSchedule.SchedulingRunnable;
|
|
|
import com.example.opc_da.service.ItemGroupService;
|
|
|
-import com.example.opc_da.task.*;
|
|
|
+import com.example.opc_da.task.OpcDaTask;
|
|
|
import com.example.opc_da.util.OpcDaUtil;
|
|
|
import com.example.opc_da.util.RedisUtil;
|
|
|
import com.example.opc_da.util.UserUtil;
|
|
@@ -28,7 +27,6 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
-import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
|
|
|
@Service
|
|
@@ -42,7 +40,7 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
private UserUtil userUtil;
|
|
|
|
|
|
@Autowired
|
|
|
- private OpcAsyncTask opcAsyncTask;
|
|
|
+ private OpcDaTask opcDaTask;
|
|
|
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
@@ -67,8 +65,8 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
String userId = userUtil.getCurrentUserId();
|
|
|
itemGroup.setUserId(userId);
|
|
|
Integer readMode = itemGroup.getReadMode();
|
|
|
- if (readMode != ConstantStr.ON_CHANGE && readMode != ConstantStr.EXCEED_SET_VALUE &&
|
|
|
- readMode != ConstantStr.SPECIFY_TIME) {
|
|
|
+ if (readMode != ConstantStr.ON_FREQUENCY && readMode != ConstantStr.ON_CHANGE &&
|
|
|
+ readMode != ConstantStr.EXCEED_SET_VALUE) {
|
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前未适配此种类型的读取模式");
|
|
|
}
|
|
|
if (readMode == ConstantStr.ON_CHANGE) {
|
|
@@ -80,9 +78,6 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
}
|
|
|
}
|
|
|
if (readMode == ConstantStr.EXCEED_SET_VALUE) {
|
|
|
- if (Blank.isEmpty(itemGroup.getReadModeType())) {
|
|
|
- return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "请选择一种比较类型");
|
|
|
- }
|
|
|
if (Blank.isEmpty(itemGroup.getEventMode())) {
|
|
|
return Result.no(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "阈值条件");
|
|
|
}
|
|
@@ -215,13 +210,22 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
clsId.equals(OpcDaDriverEnum.YOKOGAWA.getValue()) ||
|
|
|
clsId.equals(OpcDaDriverEnum.PAS300.getValue())
|
|
|
) {
|
|
|
+ redisUtil.set(ConstantStr.ITEM_GROUP + id, true);
|
|
|
//新增定时器任务
|
|
|
String cronId = "";
|
|
|
String cron = "0 0 0 ? * ";
|
|
|
if (Blank.isEmpty(readWeek)) {
|
|
|
cron = cron + "MON,TUE,WED,THU,FRI,SAT,SUN";
|
|
|
+ //立即执行一次Timer
|
|
|
+ opcDaTask.opcDaTask(itemGroup, dataSource, cronId);
|
|
|
} else {
|
|
|
- cron = cron + itemGroup.getReadWeek();
|
|
|
+ cron = cron + readWeek;
|
|
|
+ for (String str : readWeek.split(",")) {
|
|
|
+ if (str.equals(DateUtil.getCurrentWeekEn())) {
|
|
|
+ //立即执行一次Timer
|
|
|
+ opcDaTask.opcDaTask(itemGroup, dataSource, cronId);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if (Blank.isEmpty(itemGroup.getCronId())) {
|
|
|
cronId = UUID.randomUUID().toString().replace("-", "");
|
|
@@ -236,6 +240,7 @@ public class ItemGroupServiceImpl implements ItemGroupService {
|
|
|
throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前未适配此种驱动类型");
|
|
|
}
|
|
|
} else if (runState.equals(ConstantStr.STOP_IT)) {
|
|
|
+ redisUtil.set(ConstantStr.ITEM_GROUP + id, false);
|
|
|
itemGroupDao.stopItemGroupById(id, runState);
|
|
|
cronTaskRegister.removeCronTask(itemGroup.getCronId());
|
|
|
return Result.ok("停用成功");
|