Commit 50a3a642 authored by hanbing's avatar hanbing

[update] 添加路口拥堵指数

parent 4af04876
......@@ -11,7 +11,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
* @author
*/
@SpringBootApplication(scanBasePackages = {"net.wanji.web", "net.wanji.common"})
@MapperScan(basePackages = "net.wanji.web.mapper")
@MapperScan(basePackages = {"net.wanji.web.mapper", "net.wanji.databus.dao.mapper"})
@EnableTransactionManagement
@EnableScheduling
@EnableAsync
......
......@@ -13,8 +13,10 @@ import java.util.List;
@NoArgsConstructor
@Data
public class SaveLaneInfoDTO {
@ApiModelProperty(value = "路口ID,如:c7e7b1f352dd4acab4a60088eb391cca", required = true)
@ApiModelProperty(value = "路口ID", required = true)
private String crossId;
@ApiModelProperty(value = "路口拥堵指数", required = true)
private Double crossIndex;
private List<LedConfigListElement> ledConfigList;
private List<DirListElement> dirList;
}
......@@ -11,7 +11,7 @@ import org.springframework.stereotype.Repository;
*/
@Repository
@DS("webService")
public interface RidInfoMapper {
public interface CustomRidInfoMapper {
Double selectRoadLength(@Param("startCrossid") String startCrossid,
@Param("endCrossid") String endCrossid);
......
......@@ -33,7 +33,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
SpecialServiceCrossMapper specialServiceCrossMapper;
@Autowired
RidInfoMapper ridInfoMapper;
CustomRidInfoMapper customRidInfoMapper;
@Autowired
TBaseCrossInfoMapper tBaseCrossInfoMapper;
......@@ -70,7 +70,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
for (int i = 0; i < size - 1; i++) {
SpecialServiceCrossPO currentCross = specialServiceCrossPOList.get(i);
SpecialServiceCrossPO nextCross = specialServiceCrossPOList.get(i + 1);
RidInfoPO ridInfoPO = ridInfoMapper.selectOne(currentCross.getCrossId(), nextCross.getCrossId());
RidInfoPO ridInfoPO = customRidInfoMapper.selectOne(currentCross.getCrossId(), nextCross.getCrossId());
String wkt = ridInfoPO.getWkt();
wkts.add(wkt);
}
......@@ -112,7 +112,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
Integer preSort = maxSort - 1;
String startCrossid = specialServiceCrossMapper.selectCrossIdBySort(specialServiceId, preSort);
// 查询路段
RidInfoPO ridInfoPO = ridInfoMapper.selectOne(startCrossid, endCrossid);
RidInfoPO ridInfoPO = customRidInfoMapper.selectOne(startCrossid, endCrossid);
// 路段关系不正确
if (ridInfoPO == null) {
throw new CrossRelationException("路段关系不正确");
......@@ -173,7 +173,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
SpecialServiceCrossPO nextPO = specialServiceCrossPOList.get(i + 1);
String startCrossid = specialServiceCrossPO.getCrossId();
String endCrossid = nextPO.getCrossId();
String wkt = ridInfoMapper.selectWkt(startCrossid, endCrossid);
String wkt = customRidInfoMapper.selectWkt(startCrossid, endCrossid);
crossListOutVO.setWkt(wkt);
}
crossListOutVOList.add(crossListOutVO);
......@@ -197,7 +197,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
Integer sort = updateCrossInVO.getSort();
Integer nextSort = sort + 1;
String endCrossid = specialServiceCrossMapper.selectCrossIdBySort(specialServiceId, nextSort);
String startCrossOutDirId = ridInfoMapper.selectStartCrossOutDir(crossId, endCrossid);
String startCrossOutDirId = customRidInfoMapper.selectStartCrossOutDir(crossId, endCrossid);
String startCrossInDirId = crossId + "_" + dir + "_2_1";
CrossDirTurnPO crossDirTurnPO = crossDirTurnMapper.selectOneByInAndOutIds(startCrossInDirId, startCrossOutDirId);
String turntype = crossDirTurnPO.getTurntype();
......@@ -214,7 +214,7 @@ public class SpecialServiceServiceImpl implements SpecialServiceService {
Integer preSort = sort - 1;
String preCrossid = specialServiceCrossMapper.selectCrossIdBySort(specialServiceId, preSort);
// 减少路线长度
Double roadLength = ridInfoMapper.selectRoadLength(preCrossid, crossId);
Double roadLength = customRidInfoMapper.selectRoadLength(preCrossid, crossId);
Double oldLength = specialServiceMapper.selectRoadLength(specialServiceId);
oldLength -= roadLength;
specialServiceMapper.updateLength(specialServiceId, oldLength);
......
......@@ -3,8 +3,10 @@ package net.wanji.web.service.scheme.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import net.wanji.common.dto.CrossIdDTO;
import net.wanji.databus.dao.mapper.CrossDataRealtimeMapper;
import net.wanji.databus.dao.mapper.CrossDirDataRealtimeMapper;
import net.wanji.databus.dao.mapper.CrossTurnDataHistMapper;
import net.wanji.databus.po.CrossDataRealtimePO;
import net.wanji.databus.po.CrossDirDataRealtimePO;
import net.wanji.web.common.enums.LightsAddressEnum;
import net.wanji.web.common.exception.LightLaneConflictException;
......@@ -48,6 +50,7 @@ public class CrossConfigServiceImpl implements CrossConfigService {
private final CrossLaneLightsMapper crossLaneLightsMapper;
private final LaneSegmentMapper laneSegmentMapper;
private final CrossLightsMapper crossLightsMapper;
private final CrossDataRealtimeMapper crossDataRealtimeMapper;
// 机动车灯数据库类型与前端类型对应关系
private static final Map<Integer, Integer> MOTOR_VEH_MAP = new HashMap<>(5);
......@@ -72,12 +75,17 @@ public class CrossConfigServiceImpl implements CrossConfigService {
private final CrossTurnDataHistMapper crossTurnDataHistMapper;
private final CrossDirDataRealtimeMapper crossDirDataRealtimeMapper;
public CrossConfigServiceImpl(CrossDirInfoMapper crossDirInfoMapper, LaneInfoMapper laneInfoMapper, CrossLaneLightsMapper crossLaneLightsMapper, LaneSegmentMapper laneSegmentMapper, CrossLightsMapper crossLightsMapper, CrossPhaseLightsMapper crossPhaseLightsMapper, CrossTurnDataHistMapper crossTurnDataHistMapper, CrossDirDataRealtimeMapper crossDirDataRealtimeMapper) {
public CrossConfigServiceImpl(CrossDirInfoMapper crossDirInfoMapper, LaneInfoMapper laneInfoMapper,
CrossLaneLightsMapper crossLaneLightsMapper, LaneSegmentMapper laneSegmentMapper,
CrossLightsMapper crossLightsMapper, CrossDataRealtimeMapper crossDataRealtimeMapper, CrossPhaseLightsMapper crossPhaseLightsMapper,
CrossTurnDataHistMapper crossTurnDataHistMapper,
CrossDirDataRealtimeMapper crossDirDataRealtimeMapper) {
this.crossDirInfoMapper = crossDirInfoMapper;
this.laneInfoMapper = laneInfoMapper;
this.crossLaneLightsMapper = crossLaneLightsMapper;
this.laneSegmentMapper = laneSegmentMapper;
this.crossLightsMapper = crossLightsMapper;
this.crossDataRealtimeMapper = crossDataRealtimeMapper;
this.crossPhaseLightsMapper = crossPhaseLightsMapper;
this.crossTurnDataHistMapper = crossTurnDataHistMapper;
this.crossDirDataRealtimeMapper = crossDirDataRealtimeMapper;
......@@ -307,6 +315,9 @@ public class CrossConfigServiceImpl implements CrossConfigService {
String crossId = crossIdDTO.getCrossId();
SaveLaneInfoDTO saveLaneInfoDTO = new SaveLaneInfoDTO();
saveLaneInfoDTO.setCrossId(crossId);
// 路口拥堵指数
CrossDataRealtimePO crossDataRealtimePO = crossDataRealtimeMapper.selectByCrossId(crossId);
saveLaneInfoDTO.setCrossIndex(crossDataRealtimePO.getTrafficIndex());
// 构造dirList
buildDirList(crossId, saveLaneInfoDTO);
// 构造ledConfigList
......
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.web.mapper.RidInfoMapper">
<mapper namespace="net.wanji.web.mapper.CustomRidInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap type="net.wanji.web.po.RidInfoPO" id="BaseResultMap">
......
......@@ -12,7 +12,7 @@ import org.springframework.transaction.annotation.EnableTransactionManagement;
*/
@SpringBootApplication(scanBasePackages = {"net.wanji.utc", "net.wanji.common"})
@EnableTransactionManagement
@MapperScan(basePackages = "net.wanji.utc.mapper")
@MapperScan(basePackages = {"net.wanji.utc.mapper", "net.wanji.databus.dao.mapper"})
@EnableScheduling
@EnableAsync
public class UtcApplication {
......
......@@ -17,6 +17,4 @@ public interface CrossTurnDataHistMapper extends BaseMapper<CrossTurnDataHistPO>
void insertBatch(@Param("list") List<CrossTurnDataHistPO> list);
void deleteBatch(@Param("list") Collection<String> crossIds);
CrossTurnDataHistPO selectByLane(String crossId, Integer key, String turn);
}
......@@ -16,7 +16,8 @@ import java.util.List;
public interface CrossTurnDataRealtimeMapper extends BaseMapper<CrossTurnDataRealtimePO> {
void insertBatch(@Param("list") List<CrossTurnDataRealtimePO> list);
void deleteBatch(@Param("list") Collection<String> crossIds);
List<CrossTurnDataRealtimePO> selectByCrossId(String crossId);
CrossTurnDataRealtimePO selectByLane(String crossId, Integer key, String turn);
}
......@@ -49,10 +49,4 @@
</foreach>
</delete>
<select id="selectByLane" resultType="net.wanji.databus.po.CrossTurnDataRealtimePO">
select <include refid="Base_Column_List"></include>
from t_cross_turn_data_realtime
where cross_id = #{crossId} and in_dir = #{key} and turn_type = #{turn}
</select>
</mapper>
\ No newline at end of file
......@@ -54,4 +54,11 @@
from t_cross_turn_data_realtime
where cross_id = #{crossId}
</select>
<select id="selectByLane" resultType="net.wanji.databus.po.CrossTurnDataRealtimePO">
select <include refid="Base_Column_List"></include>
from t_cross_turn_data_realtime
where cross_id = #{crossId} and in_dir = #{key} and turn_type = #{turn}
</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