Commit 50a3a642 authored by hanbing's avatar hanbing

[update] 添加路口拥堵指数

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