package vip.xiaonuo.Timer; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import io.swagger.models.auth.In; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import org.springframework.transaction.annotation.Transactional; import vip.xiaonuo.common.timer.CommonTimerTaskRunner; import vip.xiaonuo.modular.ai.taskInspection.entity.TaskInspection; import vip.xiaonuo.modular.ai.taskInspection.mapper.TaskInspectionMapper; import vip.xiaonuo.modular.base.baseConfig.entity.BaseConfig; import vip.xiaonuo.modular.base.baseConfig.mapper.BaseConfigMapper; import vip.xiaonuo.modular.warning.warningInfo.entity.WarningInfo; import vip.xiaonuo.modular.warning.warningInfo.mapper.WarningInfoMapper; import vip.xiaonuo.modular.warning.warningManager.entity.WarningManager; import vip.xiaonuo.modular.warning.warningManager.mapper.WarningManagerMapper; import java.util.Date; import java.util.List; @Slf4j @Component public class WarningTransferTimer implements CommonTimerTaskRunner { @Autowired private WarningInfoMapper warningInfoMapper; @Autowired private WarningManagerMapper warningManagerMapper; @Autowired private TaskInspectionMapper taskInspectionMapper; @Autowired private BaseConfigMapper baseConfigMapper; @Override @Transactional public void action() { List warningInfos = warningInfoMapper.selectList(new QueryWrapper().lambda().eq(WarningInfo::getWarningStatus, 0)); for (WarningInfo warningInfo : warningInfos) { Date warningTime = warningInfo.getWarningTime(); String configName = baseConfigMapper.selectById(warningInfo.getWarningTypeId()).getConfigName(); Date now = new Date(); Integer warningType = null; switch (configName) { case "环控预警": warningType = 0; break; case "能耗预警": warningType = 1; break; case "饲喂预警": warningType = 2; break; case "巡检预警": warningType = 3; break; } WarningManager warningManager = warningManagerMapper.selectOne(new QueryWrapper().lambda().eq(WarningManager::getType, warningType).eq(WarningManager::getOrgId, warningInfo.getOrgId())); if (warningManager != null) { Integer warningUpgradeTime = warningManager.getWarningUpgradeTime(); int gap = (int) ((now.getTime() - warningTime.getTime()) / (1000 * 60)); if (warningUpgradeTime >= gap) { String firstManagerId = warningManager.getFirstManagerId(); warningInfo.setWarningNotifierId(firstManagerId); TaskInspection taskInspection = taskInspectionMapper.selectOne(new QueryWrapper().lambda().eq(TaskInspection::getWarningId, warningInfo.getId())); taskInspection.setNotifierId(firstManagerId); warningInfoMapper.updateById(warningInfo); taskInspectionMapper.updateById(taskInspection); } } } } }