Commit 0bde6e7f authored by duanruiming's avatar duanruiming

[add] 诱导屏下屏优化

parent 1a8c023b
package net.wanji.opt.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.opt.dto.induce.MessageParam;
import net.wanji.opt.po.StrategyGreenOptHistEntity;
import java.util.List;
......@@ -14,4 +15,6 @@ public interface StrategyGreenOptHistMapper extends BaseMapper<StrategyGreenOptH
List<StrategyGreenOptHistEntity> selectByGreenId(String greenId);
List<MessageParam> selectGreenOptEndTimeEquipCode();
}
......@@ -306,6 +306,33 @@ public class InducesMonitorTask {
});
}
}
// 下屏逻辑,如果绿波历史表结束优化control_method=-1, 在15分钟内,下屏
try {
List<MessageParam> entities = strategyGreenOptHistMapper.selectGreenOptEndTimeEquipCode();
if (!CollectionUtils.isEmpty(entities)) {
for (MessageParam messageParam : entities) {
String endTime = messageParam.getEndTime();
Integer greenId = messageParam.getGreenId();
String equipCode = messageParam.getEquipCode();
Date parse = DateUtil.parse(endTime, Constants.DATE_FORMAT.E_DATE_FORMAT_SECOND);
long current = System.currentTimeMillis();
// 结束时间小于服务器时间15分钟不在下屏
long time = parse.getTime();
if (time - current < 15 * 60 * 1000) {
continue;
}
messageParam.setFlg(2);
messageParam.setType("TFMH");
induceSendService.send(messageParam);
log.info("当前绿波:{}, 诱导屏编号:{}, 下屏成功", greenId, equipCode);
Thread.sleep(500);
}
}
} catch (Exception e) {
log.error("通过绿波优化结束时间下屏异常:{}", e);
}
} catch (Exception e) {
throw new Exception("每5分钟刷新绿波下发状态失败", e);
} finally {
......
......@@ -12,4 +12,14 @@
) b on a.`green_id` = b.`green_id` and a.`control_time` = b.`control_time` and a.`green_id` = #{greenId} and a.`control_method` = 1 and TIMESTAMPDIFF(SECOND,a.`control_time`, now()) &lt; a.`control_duration`
</select>
<!-- 查询绿波优化记录表当天结束的绿波-->
<select id="selectGreenOptEndTimeEquipCode" resultType="net.wanji.opt.dto.induce.MessageParam">
<!-- select t1.green_id as greenId, t1.control_time as endTime, t2.equip_code as equipCode, t2.id as induceId, t2.source_id as sourceId from-->
<!-- (select green_id, control_time from t_strategy_green_opt_hist t1 where control_time > now() and control_method = -1) t1-->
<!-- left join t_greenwave_induces t2 on t1.green_id = t2.green_id-->
select t1.green_id as greenId, t1.control_time as endTime, t2.equip_code as equipCode, t2.id as induceId, t2.source_id as sourceId from
(select green_id, control_time from t_strategy_green_opt_hist t1 where control_time > STR_TO_DATE('2025-03-01', '%Y-%m-%d') and control_method = -1) t1
left join t_greenwave_induces t2 on t1.green_id = t2.green_id
</select>
</mapper>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment