Commit 407e5c2f authored by duanruiming's avatar duanruiming

[update] 诊断优化-优化效果开始时间

parent 982f18e4
......@@ -20,4 +20,14 @@ public interface CrossSchemeOptLogMapper {
int insertBatch(@Param("list") List<CrossSchemeOptLogPO> list);
List<CrossSchemeOptLogPO> selectMaxByCrossId(String crossId);
/**
* 查询历史表中两个小时内最早得优化记录
*
* @param crossId
* @param optReason
* @param optStartTime
* @return
*/
CrossSchemeOptLogPO selectOptStartEntity(@Param("crossId") String crossId, @Param("optReason") String optReason, @Param("optStartTime") long optStartTime);
}
......@@ -328,13 +328,13 @@ public class DiagnoServiceImpl implements DiagnoService {
public OptEffectVO optEffect(CrossIdAndDirDTO crossIdAndDirDTO) {
String crossId = crossIdAndDirDTO.getCrossId();
OptEffectVO optEffectVO = new OptEffectVO();
TBaseCrossInfo crossInfoPO = crossInfoMapper.selectByPrimaryKey(crossId);
optEffectVO.setCrossName(crossInfoPO.getName());
List<CrossSchemeOptLogPO> maxList = crossSchemeOptLogMapper.selectMaxByCrossId(crossId);
String optReason = null;
if (!CollectionUtils.isEmpty(maxList)) {
CrossSchemeOptLogPO crossSchemeOptLogPO = maxList.get(0);
optEffectVO.setOptStartTime(crossSchemeOptLogPO.getStartTime());
optReason = crossSchemeOptLogPO.getOptReason();
Date endTime = crossSchemeOptLogPO.getEndTime();
if (ObjectUtil.isEmpty(endTime)) {
optEffectVO.setStatus(2);
......@@ -347,6 +347,12 @@ public class DiagnoServiceImpl implements DiagnoService {
long currentSeconds = DateUtil.currentSeconds();
// todo 测试用 固定当前时间为1676082600
currentSeconds = 1676082600;
long optStartTime = currentSeconds - 2 * 60 * 60;
// 优化开始时间,两个小时内最早时间
CrossSchemeOptLogPO optStartEntity = crossSchemeOptLogMapper.selectOptStartEntity(crossId, optReason, optStartTime);
if (Objects.nonNull(optStartEntity)) {
optEffectVO.setOptStartTime(optStartEntity.getStartTime());
}
long preSeconds = currentSeconds - 45 * 60;
if (ObjectUtil.isEmpty(dir) || dir == 0) {
// 获取路口历史数据
......
......@@ -25,8 +25,8 @@ public class OptEffectVO {
String strategyName;
@ApiModelProperty(value = "优化方法")
String ideaName;
@ApiModelProperty(value = "优化开始时间 格式2023-03-02 10:10")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@ApiModelProperty(value = "优化开始时间")
@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "HH:mm", timezone = "GMT+8")
Date optStartTime;
@ApiModelProperty(value = "状态 1已完成 2持续优化")
Integer status;
......
......@@ -53,6 +53,15 @@
and data_batch_time=(SELECT MAX(ABS(data_batch_time)) FROM t_base_cross_scheme_opt_log WHERE cross_id = #{crossId});
</select>
<select id="selectOptStartEntity" resultType="net.wanji.opt.po.base.CrossSchemeOptLogPO">
select
<include refid="Base_Column_List"/>
from t_base_cross_scheme_opt_log
where cross_id = #{crossId} and opt_reason = #{optReason} and data_batch_time > #{optStartTime}
order by data_batch_time desc
limit 1
</select>
<insert id="insertOne" parameterType="net.wanji.opt.po.base.CrossSchemeOptLogPO">
insert into t_base_cross_scheme_opt_log (cross_id, scheme_id, dir_type, turn_type, offset, ring_no, phase_no,
phase_order_id, ori_green_time, opt_time, opt_type, opt_reason,
......
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