|
|
@@ -17,6 +17,7 @@ public class IotWarnBussinessService {
|
|
|
|
|
|
/**
|
|
|
* 查询设备+配置的重复次数
|
|
|
+ * 注意:如果没数据会返回Null
|
|
|
*
|
|
|
* @param devId
|
|
|
* @param configId
|
|
|
@@ -24,8 +25,9 @@ public class IotWarnBussinessService {
|
|
|
*/
|
|
|
public Long selectIotWarnCountByDevAndConfig(String devId, String configId) {
|
|
|
IotWarncount iotWarncount = iotWarncountMapper.selectIotWarnCountByDevAndConfig(devId, configId);
|
|
|
+ // 如果为Null,说明还没触发过
|
|
|
if (iotWarncount == null) {
|
|
|
- return 0L;
|
|
|
+ return null;
|
|
|
}
|
|
|
return iotWarncount.getWctCount();
|
|
|
}
|
|
|
@@ -38,10 +40,8 @@ public class IotWarnBussinessService {
|
|
|
* @param configId
|
|
|
* @return
|
|
|
*/
|
|
|
- int incrementReCount(Long reCount, String devId, String configId, String tid) {
|
|
|
+ public int incrementReCount(Long reCount, String devId, String configId, String tid) {
|
|
|
if (reCount == null) {
|
|
|
- return iotWarncountMapper.updateIncrementReCount(devId, configId);
|
|
|
- } else {
|
|
|
//从新添加,就是从0变为1
|
|
|
IotWarncount iotWarncount = new IotWarncount();
|
|
|
iotWarncount.setWctBid(IdUtils.fastUUID());
|
|
|
@@ -51,10 +51,12 @@ public class IotWarnBussinessService {
|
|
|
iotWarncount.setWctCount(1L);
|
|
|
iotWarncount.setTid(tid);
|
|
|
return iotWarncountMapper.insertIncrementReCount(iotWarncount);
|
|
|
+ } else {
|
|
|
+ return iotWarncountMapper.updateIncrementReCount(devId, configId);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- int incrementReCount(Long reCount, WarnResult warnResult) {
|
|
|
+ public int incrementReCount(Long reCount, WarnResult warnResult) {
|
|
|
return incrementReCount(reCount, warnResult.getDevId(), warnResult.getConfigId(), warnResult.getTid());
|
|
|
}
|
|
|
|
|
|
@@ -63,16 +65,25 @@ public class IotWarnBussinessService {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- int resetReCount() {
|
|
|
+ public int resetReCount() {
|
|
|
return iotWarncountMapper.resetReCount();
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 重置指定设备和配置的重复次数
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public int resetReCountByDevIdAndConfigId(String devId, String configId) {
|
|
|
+ return iotWarncountMapper.resetReCountByDevIdAndConfigId(devId, configId);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 插入预警记录
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- int insertWarnRecord(IotWarnlog iotWarnlog) {
|
|
|
+ public int insertWarnRecord(IotWarnlog iotWarnlog) {
|
|
|
return iotWarncountMapper.insertWarnRecord(iotWarnlog);
|
|
|
}
|
|
|
|