|
|
@@ -13,16 +13,12 @@ import com.xunmei.common.core.domain.iot.domain.IotAlarmDefenceArea;
|
|
|
import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystem;
|
|
|
import com.xunmei.common.core.domain.iot.domain.IotAlarmSubsystemLog;
|
|
|
import com.xunmei.common.core.domain.iot.domain.IotDevice;
|
|
|
-import com.xunmei.common.core.domain.mediator.domain.MediatorAlarmRuleExpress;
|
|
|
-import com.xunmei.common.core.domain.mediator.domain.MediatorAlarmRuleSource;
|
|
|
import com.xunmei.common.core.domain.mediator.domain.MediatorCategory;
|
|
|
-import com.xunmei.common.core.domain.mediator.domain.MediatorTimeTemplate;
|
|
|
import com.xunmei.common.core.enums.CategoryDataEnum;
|
|
|
import com.xunmei.common.core.util.BeanHelper;
|
|
|
import com.xunmei.common.core.utils.IDHelper;
|
|
|
import com.xunmei.common.redis.utils.RedisUtils;
|
|
|
import com.xunmei.mediator.api.mapper.IotAlarmSubsystemMapper;
|
|
|
-import com.xunmei.mediator.api.mapper.MediatorTimeTemplateMapper;
|
|
|
import com.xunmei.mediator.api.mapper.ProtectionLogMapper;
|
|
|
import com.xunmei.mediator.api.service.*;
|
|
|
import com.xunmei.mediator.util.RedisCheckRepeatDataUtil;
|
|
|
@@ -78,8 +74,7 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
private IotAlarmDefenceAreaService defenceAreService;
|
|
|
@Resource
|
|
|
private NorthErrorService northErrorService;
|
|
|
- @Resource
|
|
|
- private MediatorTimeTemplateMapper timeTemplateMapper;
|
|
|
+
|
|
|
@Override
|
|
|
public IotAlarmSubsystem findByCodeAndOrgId(String defenceAreaCode, Long orgId) {
|
|
|
return lambdaQuery()
|
|
|
@@ -261,113 +256,6 @@ public class IotAlarmSubSystemServiceImpl extends ServiceImpl<IotAlarmSubsystemM
|
|
|
return "device_" + orgId + "_" + deviceType + "_data_map";
|
|
|
}
|
|
|
|
|
|
- private void dealAlarmDataByAllTimeTemplate(MediatorAlarmRuleExpress alarmRuleExpress, IotAlarmSubsystem protection) {
|
|
|
- //全时段
|
|
|
- MediatorTimeTemplate timeTemplate = timeTemplateMapper.selectById(alarmRuleExpress.getTimeTemplateId());
|
|
|
- final List<Map> listMap = JSON.parseArray(timeTemplate.getTemplatecontent(), Map.class);
|
|
|
- for (Map timeMap : listMap) {
|
|
|
-
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(DateUtil.offsetDay(new Date(), -1));
|
|
|
- calendar.setFirstDayOfWeek(Calendar.MONDAY);
|
|
|
- int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
-
|
|
|
- String startTime = (String) timeMap.get("startTime");
|
|
|
- String endTime = (String) timeMap.get("endTime");
|
|
|
- final Object weekday = timeMap.get("weekday");
|
|
|
-
|
|
|
- final String string = JSON.toJSONString(weekday);
|
|
|
-
|
|
|
-
|
|
|
- final List<Integer> list = JSON.parseArray(string, Integer.class);
|
|
|
- //如果时间模板中 不包含今天则返回
|
|
|
- if (!list.contains(weekDay)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- final Date sTime = DateUtil.parse(startTime, "HH:mm");
|
|
|
- final Date eTime = DateUtil.parse(endTime, "HH:mm");
|
|
|
- final Date now = DateUtil.parse(DateUtil.format(new Date(), "HH:mm"), "HH:mm");
|
|
|
-
|
|
|
- final boolean in = DateUtil.isIn(now, sTime, eTime);
|
|
|
- if (!in) {
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- boolean isAlarm = false;
|
|
|
- final String operator = alarmRuleExpress.getOperator();
|
|
|
- final String value = alarmRuleExpress.getValue();
|
|
|
- if (AlarmRuleExpressOperateEnum.EQUALS.getText().equals(operator)) {
|
|
|
- isAlarm = protection.getStatus() == Integer.parseInt(value);
|
|
|
- }
|
|
|
-
|
|
|
- if (isAlarm) {
|
|
|
- /* DeviceAlarm deviceAlarm = new DeviceAlarm();
|
|
|
- deviceAlarm.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
- deviceAlarm.setContent(ProductTypeEnum.ALARM_ZONE + " 触发动环设备告警规则告警");
|
|
|
- deviceAlarm.setImageList(null);
|
|
|
- deviceAlarm.setDeviceId(protection.getDeviceId());
|
|
|
- deviceAlarm.setIsRestore(0);
|
|
|
- deviceAlarmDao.save(deviceAlarm);*/
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void dealAlarmDataByWorkTimeTemplate(MediatorAlarmRuleExpress alarmRuleExpress, IotAlarmSubsystem protection, MediatorAlarmRuleSource alarmRuleSource) {
|
|
|
- //使用作息时间模板
|
|
|
- /* final Long orgId = protection.getOrgId();
|
|
|
- final int year = DateUtil.year(new Date());
|
|
|
- WorkTimeSet weekday = objectMapper.selectWorkTimeSet(orgId, year);
|
|
|
- if (weekday == null) {
|
|
|
- return;
|
|
|
- }
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
- calendar.setTime(DateUtil.offsetDay(new Date(), -1));
|
|
|
- calendar.setFirstDayOfWeek(Calendar.MONDAY);
|
|
|
- int weekDay = calendar.get(Calendar.DAY_OF_WEEK);
|
|
|
- final List<Integer> weekDayList = getWeekDayList(weekday);
|
|
|
- //如果作息时间模板中 不包含今天即今天任何情况都不报警,则返回
|
|
|
- if (!weekDayList.contains(weekDay)) {
|
|
|
- return;
|
|
|
- }
|
|
|
- boolean isAlarm = false;
|
|
|
- //获取告警表达式内容
|
|
|
- final String operator = alarmRuleExpress.getOperator();
|
|
|
- final String value = alarmRuleExpress.getValue();
|
|
|
- Date now = DateUtil.parse(DateUtil.format(new Date(), "HH:mm"), "HH:mm");
|
|
|
- Date workOffTime = DateUtil.parse(weekday.getWorkOffTime(), "HH:mm");
|
|
|
- //如果 作息中的下班时间早于当前时间,即当前时间 大于 作息中下班时间,即当前时间已经下班
|
|
|
- //此处认定 如果当前时间小于下班时间,那么都属于上班时间,使用上班告警规则
|
|
|
- final boolean isOffWork = workOffTime.before(now);
|
|
|
- MediatorAlarmRule alarmRule = objectMapper.selectAlarmRuleById(alarmRuleSource.getRuleId());
|
|
|
- if (isOffWork && ObjectUtil.equal("downinspection", alarmRule.getType())) {
|
|
|
- //如果已经下班,使用下班巡检告警规则
|
|
|
- //判断表达式的值 于当前布撤防状态值是否一致
|
|
|
- if (AlarmRuleExpressOperateEnum.EQUALS.getText().equals(operator)) {
|
|
|
- isAlarm = protection.getStatus() == Integer.parseInt(value);
|
|
|
- }
|
|
|
- }
|
|
|
- if (!isOffWork && ObjectUtil.equal("upinspection", alarmRule.getType())) {
|
|
|
- //如果还没下班,使用上班巡检告警规则
|
|
|
- //判断表达式的值 于当前布撤防状态值是否一致
|
|
|
- if (AlarmRuleExpressOperateEnum.EQUALS.getText().equals(operator)) {
|
|
|
- isAlarm = protection.getStatus() == Integer.parseInt(value);
|
|
|
- }
|
|
|
- }
|
|
|
- if (isAlarm) {
|
|
|
- DeviceAlarm deviceAlarm = new DeviceAlarm();
|
|
|
- deviceAlarm.setId(UUID.randomUUID().toString().replace("-", ""));
|
|
|
- deviceAlarm.setContent(ProductTypeEnum.ALARM_ZONE + " 触发动环设备告警规则告警");
|
|
|
- deviceAlarm.setImageList(null);
|
|
|
- deviceAlarm.setDeviceId(protection.getDeviceId());
|
|
|
- deviceAlarm.setIsRestore(0);
|
|
|
- deviceAlarmDao.save(deviceAlarm);
|
|
|
- }*/
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
@Override
|
|
|
public ReceiveErrorDto defenceAreaList(DataPageDto<DefenceAreaDto> request, String branchId, String msgId) {
|
|
|
String packageGuid = request.getPackageGuid();
|