Commit 84817317 authored by hanbing's avatar hanbing

[add] 新信号评价-运行评价-路口列表

parent bf0a2bf1
package net.wanji.opt.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
/**
* @author Kent HAN
* @date 2023/6/9 13:52
*/
@Data
@ApiModel(value = "CrossNameBO", description = "路口名称")
public class CrossNameBO {
@ApiModelProperty(value = "路口名称")
private String crossName;
}
......@@ -21,7 +21,7 @@ import javax.ws.rs.core.MediaType;
*
* @author Kent HAN
*/
@Api(value = "EvaluateController", description = "信号评价")
@Api(value = "EvaluateController", description = "信号评价(旧)")
@RequestMapping("/evaluate")
@RestController
public class EvaluateController {
......@@ -32,7 +32,7 @@ public class EvaluateController {
this.evaluateService = evaluateService;
}
@ApiOperation(value = "路口详情", notes = "路口详情", response = JsonViewObject.class,
@ApiOperation(value = "路口详情(旧)", notes = "路口详情(旧)", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/evaluateCrossDetail",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......@@ -44,7 +44,7 @@ public class EvaluateController {
return JsonViewObject.newInstance().success(evaluateCrossDetailVO);
}
@ApiOperation(value = "评价指标", notes = "评价指标", response = JsonViewObject.class,
@ApiOperation(value = "评价指标(旧)", notes = "评价指标(旧)", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/evaluateMetrics",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......
package net.wanji.opt.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.bo.CrossNameBO;
import net.wanji.opt.service.impl.RunningEvaluateServiceImpl;
import net.wanji.databus.vo.RunningEvaluateCrossListVO;
import org.springframework.web.bind.annotation.*;
import javax.ws.rs.core.MediaType;
import java.util.List;
/**
* 运行评价
*
* @author Kent HAN
*/
@Api(value = "RunningEvaluateController", description = "运行评价")
@RequestMapping("/runningEvaluate")
@RestController
public class RunningEvaluateController {
private final RunningEvaluateServiceImpl runningEvaluateService;
public RunningEvaluateController(RunningEvaluateServiceImpl runningEvaluateService) {
this.runningEvaluateService = runningEvaluateService;
}
@ApiOperation(value = "路口列表", notes = "路口列表", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/crossList",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = RunningEvaluateCrossListVO.class),
})
public JsonViewObject crossList(@RequestBody CrossNameBO crossNameBO) {
List<RunningEvaluateCrossListVO> res = runningEvaluateService.crossList(crossNameBO);
return JsonViewObject.newInstance().success(res);
}
}
\ No newline at end of file
package net.wanji.opt.service;
import net.wanji.databus.vo.RunningEvaluateCrossListVO;
import net.wanji.opt.bo.CrossNameBO;
import java.util.List;
public interface RunningEvaluateService {
List<RunningEvaluateCrossListVO> crossList(CrossNameBO crossNameBO);
}
package net.wanji.opt.service.impl;
import lombok.extern.slf4j.Slf4j;
import net.wanji.common.utils.tool.CrossUtil;
import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.vo.RunningEvaluateCrossListVO;
import net.wanji.opt.bo.CrossNameBO;
import net.wanji.opt.service.RunningEvaluateService;
import org.springframework.stereotype.Service;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
/**
* @author Kent HAN
* @date 2023/8/21 9:53
*/
@Slf4j
@Service
public class RunningEvaluateServiceImpl implements RunningEvaluateService {
private final CrossDataRealtimeMapper crossDataRealtimeMapper;
public RunningEvaluateServiceImpl(CrossDataRealtimeMapper crossDataRealtimeMapper) {
this.crossDataRealtimeMapper = crossDataRealtimeMapper;
}
@Override
public List<RunningEvaluateCrossListVO> crossList(CrossNameBO crossNameBO) {
String crossName = crossNameBO.getCrossName();
List<RunningEvaluateCrossListVO> crossDataRealtimePOList = crossDataRealtimeMapper.selectByCrossName(crossName);
for (RunningEvaluateCrossListVO runningEvaluateCrossListVO : crossDataRealtimePOList) {
Double sturation = runningEvaluateCrossListVO.getSturation();
runningEvaluateCrossListVO.setServiceLevel(CrossUtil.getServiceLevel(sturation));
}
// 按服务水平降序排序
List<RunningEvaluateCrossListVO> res = crossDataRealtimePOList.stream()
.sorted(Comparator.comparing(RunningEvaluateCrossListVO::getSturation).reversed())
.collect(Collectors.toList());
return res;
}
}
......@@ -3,6 +3,7 @@ package net.wanji.databus.dao.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.vo.AbnormalCrossListVO;
import net.wanji.databus.vo.RunningEvaluateCrossListVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
......@@ -22,4 +23,8 @@ public interface CrossDataRealtimeMapper extends BaseMapper<CrossDataRealtimePO>
List<AbnormalCrossListVO> selectAbnormalCross(Integer status, String name, Integer type);
CrossDataRealtimePO selectByCrossId(String crossId);
List<CrossDataRealtimePO> selectAll();
List<RunningEvaluateCrossListVO> selectByCrossName(String crossName);
}
package net.wanji.databus.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* @author Kent HAN
* @date 2023/2/9 8:38
*/
@Data
@NoArgsConstructor
@ApiModel(value = "RunningEvaluateCrossListVO", description = "运行评价-路口列表VO")
public class RunningEvaluateCrossListVO {
@ApiModelProperty(value = "路口ID")
private String crossId;
@ApiModelProperty(value = "路口名称")
private String crossName;
@ApiModelProperty(name = "饱和度")
private Double sturation;
@ApiModelProperty(value = "服务水平")
String serviceLevel;
}
......@@ -86,4 +86,19 @@
where cross_id = #{crossId}
</select>
<select id="selectAll" resultType="net.wanji.databus.po.CrossDataRealtimePO">
select <include refid="Base_Column_List"></include>
from t_cross_data_realtime
</select>
<select id="selectByCrossName" resultType="net.wanji.databus.vo.RunningEvaluateCrossListVO">
select t1.cross_id as crossId, t1.sturation as sturation, t2.name as crossName
from t_cross_data_realtime t1 join t_base_cross_info t2 on t1.cross_id = t2.id
<where>
<if test="crossName != null and crossName != ''">
AND t2.name LIKE CONCAT('%',#{crossName},'%')
</if>
</where>
</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