Commit e10d8984 authored by hanbing's avatar hanbing

方案管理-灯组配置-灯组设置、车道配置列表

parent 30095e49
...@@ -9,8 +9,6 @@ import net.wanji.web.dto.SaveLightsInfoDTO; ...@@ -9,8 +9,6 @@ import net.wanji.web.dto.SaveLightsInfoDTO;
import net.wanji.web.service.scheme.impl.LightsConfigServiceImpl; import net.wanji.web.service.scheme.impl.LightsConfigServiceImpl;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.ws.rs.core.MediaType; import javax.ws.rs.core.MediaType;
...@@ -18,9 +16,10 @@ import javax.ws.rs.core.MediaType; ...@@ -18,9 +16,10 @@ import javax.ws.rs.core.MediaType;
* @author Kent HAN * @author Kent HAN
* @date 2022/12/20 10:14 * @date 2022/12/20 10:14
*/ */
/// 弃用,与CrossConfigController合并
// @Api(value = "LightsConfigController", description = "方案管理-灯组配置") // @Api(value = "LightsConfigController", description = "方案管理-灯组配置")
@RequestMapping("/lightsConfig") // @RequestMapping("/lightsConfig")
@RestController // @RestController
public class LightsConfigController { public class LightsConfigController {
private final LightsConfigServiceImpl lightsConfigService; private final LightsConfigServiceImpl lightsConfigService;
......
...@@ -17,4 +17,6 @@ public interface CrossLaneLightsMapper { ...@@ -17,4 +17,6 @@ public interface CrossLaneLightsMapper {
void deleteByCrossId(@Param("crossId") String crossId); void deleteByCrossId(@Param("crossId") String crossId);
void insertBatch(@Param("entities") List<CrossLaneLightsPO> entities); void insertBatch(@Param("entities") List<CrossLaneLightsPO> entities);
String selectLightsCodeByLaneId(@Param("laneId") String laneId);
} }
...@@ -19,4 +19,8 @@ public interface CrossLightsMapper { ...@@ -19,4 +19,8 @@ public interface CrossLightsMapper {
void insertBatch(@Param("entities") List<CrossLightsPO> entities); void insertBatch(@Param("entities") List<CrossLightsPO> entities);
CrossLightsPO selectByCrossIdAndLedNum(@Param("crossId") String crossId, @Param("ledNum") String ledNum); CrossLightsPO selectByCrossIdAndLedNum(@Param("crossId") String crossId, @Param("ledNum") String ledNum);
List<CrossLightsPO> selectByCrossId(@Param("crossId") String crossId);
List<CrossLightsPO> selectByCrossIdAndDir(@Param("crossId") String crossId, @Param("dir") Integer dir);
} }
...@@ -19,6 +19,7 @@ import net.wanji.web.service.scheme.CrossConfigService; ...@@ -19,6 +19,7 @@ import net.wanji.web.service.scheme.CrossConfigService;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
...@@ -48,6 +49,29 @@ public class CrossConfigServiceImpl implements CrossConfigService { ...@@ -48,6 +49,29 @@ public class CrossConfigServiceImpl implements CrossConfigService {
ADDRESS_DIR_MAP.put("8", 4); ADDRESS_DIR_MAP.put("8", 4);
} }
// 放行方向与灯组位置对应关系
private static final Map<Integer, Integer> DIR_ADDRESS_MAP = new HashMap<>(8);
static {
DIR_ADDRESS_MAP.put(5, 1);
DIR_ADDRESS_MAP.put(6, 2);
DIR_ADDRESS_MAP.put(7, 3);
DIR_ADDRESS_MAP.put(8, 4);
DIR_ADDRESS_MAP.put(1, 5);
DIR_ADDRESS_MAP.put(2, 6);
DIR_ADDRESS_MAP.put(3, 7);
DIR_ADDRESS_MAP.put(4, 8);
}
// 机动车灯数据库类型与前端类型对应关系
private static final Map<Integer, Integer> MOTOR_VEH_MAP = new HashMap<>(5);
static {
MOTOR_VEH_MAP.put(1, 1);
MOTOR_VEH_MAP.put(2, 3);
MOTOR_VEH_MAP.put(3, 4);
MOTOR_VEH_MAP.put(4, 5);
MOTOR_VEH_MAP.put(5, 6);
}
private final CrossPhaseLightsMapper crossPhaseLightsMapper; private final CrossPhaseLightsMapper crossPhaseLightsMapper;
public CrossConfigServiceImpl(CrossDirInfoMapper crossDirInfoMapper, LaneInfoMapper laneInfoMapper, CrossLaneLightsMapper crossLaneLightsMapper, LaneSegmentMapper laneSegmentMapper, CrossLightsMapper crossLightsMapper, CrossPhaseLightsMapper crossPhaseLightsMapper) { public CrossConfigServiceImpl(CrossDirInfoMapper crossDirInfoMapper, LaneInfoMapper laneInfoMapper, CrossLaneLightsMapper crossLaneLightsMapper, LaneSegmentMapper laneSegmentMapper, CrossLightsMapper crossLightsMapper, CrossPhaseLightsMapper crossPhaseLightsMapper) {
...@@ -158,7 +182,7 @@ public class CrossConfigServiceImpl implements CrossConfigService { ...@@ -158,7 +182,7 @@ public class CrossConfigServiceImpl implements CrossConfigService {
crossLightsPO.setType(20); crossLightsPO.setType(20);
} else if (address >= 100 && address % 10 == 1) { // 三位数为二次过街,个位是1表示出口 } else if (address >= 100 && address % 10 == 1) { // 三位数为二次过街,个位是1表示出口
crossLightsPO.setType(22); crossLightsPO.setType(22);
} else if (address >= 100 && address % 10 == 2) { // 三位数为二次过街,个位是2表示 } else if (address >= 100 && address % 10 == 2) { // 三位数为二次过街,个位是2表示
crossLightsPO.setType(21); crossLightsPO.setType(21);
} }
} }
...@@ -208,6 +232,65 @@ public class CrossConfigServiceImpl implements CrossConfigService { ...@@ -208,6 +232,65 @@ 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);
// 构造dirList
buildDirList(crossId, saveLaneInfoDTO);
// 构造ledConfigList
buildLedConfigList(crossId, saveLaneInfoDTO);
return saveLaneInfoDTO;
}
private void buildLedConfigList(String crossId, SaveLaneInfoDTO saveLaneInfoDTO) {
saveLaneInfoDTO.setLedConfigList(new ArrayList<>());
List<LedConfigListElement> ledConfigList = saveLaneInfoDTO.getLedConfigList();
// 获取灯组数据
List<CrossLightsPO> crossLightsPOList = crossLightsMapper.selectByCrossId(crossId);
// 赋值给ledConfigList
for (CrossLightsPO crossLightsPO : crossLightsPOList) {
LedConfigListElement ledConfigListElement = new LedConfigListElement();
ledConfigListElement.setOrder(crossLightsPO.getSort());
ledConfigListElement.setCode(crossLightsPO.getLightsNo());
// 处理type
Integer type = crossLightsPO.getType();
if (type > 0 && type < 10) { // 机动车灯
ledConfigListElement.setType(1);
Integer signalType = MOTOR_VEH_MAP.get(type);
ledConfigListElement.setSignalType(signalType);
} else if (type >= 10 && type < 20) { // 非机动车灯
ledConfigListElement.setType(2);
ledConfigListElement.setSignalType(2);
} else if (type >= 20 && type < 30) { // 行人灯
ledConfigListElement.setType(4);
ledConfigListElement.setSignalType(8);
} else if (type == 30) { // 公交专用灯
ledConfigListElement.setType(3);
ledConfigListElement.setSignalType(7);
}
// 灯组放行方向转换为灯组位置
Integer dir = crossLightsPO.getDir();
Integer address = DIR_ADDRESS_MAP.get(dir);
if (type < 20 || type >= 30) { // 非行人灯
ledConfigListElement.setAddress(address);
} else if (type == 20) { // 一次过街
String s = "" + address + 1;
int i = Integer.parseInt(s);
ledConfigListElement.setAddress(i);
} else if (type == 22) { // 二次过街-出口
String s = "" + address + 21;
int i = Integer.parseInt(s);
ledConfigListElement.setAddress(i);
} else if (type == 21) { // 二次过街-进口
String s = "" + address + 22;
int i = Integer.parseInt(s);
ledConfigListElement.setAddress(i);
}
ledConfigList.add(ledConfigListElement);
}
// 根据灯组序号排序
ledConfigList.sort(Comparator.comparing(LedConfigListElement::getOrder));
}
private void buildDirList(String crossId, SaveLaneInfoDTO saveLaneInfoDTO) {
saveLaneInfoDTO.setDirList(new ArrayList<>()); saveLaneInfoDTO.setDirList(new ArrayList<>());
List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectBycrossId(crossId); List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectBycrossId(crossId);
Map<Integer, List<LaneInfoPO>> collect = laneInfoPOList.stream() Map<Integer, List<LaneInfoPO>> collect = laneInfoPOList.stream()
...@@ -228,13 +311,32 @@ public class CrossConfigServiceImpl implements CrossConfigService { ...@@ -228,13 +311,32 @@ public class CrossConfigServiceImpl implements CrossConfigService {
laneListElement.setDirection(laneInfoPO.getTurn()); laneListElement.setDirection(laneInfoPO.getTurn());
laneListElement.setLaneType(laneInfoPO.getCategory()); laneListElement.setLaneType(laneInfoPO.getCategory());
laneListElement.setName(laneInfoPO.getCode()); laneListElement.setName(laneInfoPO.getCode());
// 根据laneId获取灯组代码
String laneId = laneInfoPO.getId();
String lightsCode = crossLaneLightsMapper.selectLightsCodeByLaneId(laneId);
laneListElement.setLedNum(lightsCode);
laneListElementList.add(laneListElement); laneListElementList.add(laneListElement);
} }
dirListElement.setLaneList(laneListElementList); dirListElement.setLaneList(laneListElementList);
// 构造行人过街数据
List<CrossLightsPO> crossLightsPOList = crossLightsMapper.selectByCrossIdAndDir(crossId, key);
for (CrossLightsPO crossLightsPO : crossLightsPOList) {
Integer type = crossLightsPO.getType();
String lightsNo = crossLightsPO.getLightsNo();
if (type == 20) { // 一次过街
dirListElement.setPersonCrossType("oneCross");
dirListElement.setOneCross(lightsNo);
} else if (type == 22) { // 二次过街出口灯
dirListElement.setPersonCrossType("twiceCross");
dirListElement.setTwiceCrossOut(lightsNo);
} else if (type == 21) { // 二次过街进口灯
dirListElement.setPersonCrossType("twiceCross");
dirListElement.setTwiceCrossIn(lightsNo);
}
}
List<DirListElement> dirList = saveLaneInfoDTO.getDirList(); List<DirListElement> dirList = saveLaneInfoDTO.getDirList();
dirList.add(dirListElement); dirList.add(dirListElement);
} }
return saveLaneInfoDTO;
} }
private static String getId(String crossId, DirListElement dirListElement) { private static String getId(String crossId, DirListElement dirListElement) {
......
...@@ -29,9 +29,19 @@ ...@@ -29,9 +29,19 @@
</delete> </delete>
<delete id="deleteByCrossId"> <delete id="deleteByCrossId">
delete from t_base_cross_lane_lights delete
from t_base_cross_lane_lights
where cross_id = #{crossId} where cross_id = #{crossId}
</delete> </delete>
<select id="selectLightsCodeByLaneId" resultType="java.lang.String">
select t2.lights_no
from t_base_cross_lane_lights t1
join t_base_cross_lights t2
join t_base_lane_info t3
on t1.lane_id = t3.id and t1.lights_id = t2.id
where t3.id = #{laneId}
</select>
</mapper> </mapper>
...@@ -34,5 +34,18 @@ ...@@ -34,5 +34,18 @@
where cross_id = #{crossId} and lights_no = #{ledNum} where cross_id = #{crossId} and lights_no = #{ledNum}
</select> </select>
<select id="selectByCrossId" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
from t_base_cross_lights
where cross_id = #{crossId}
</select>
<select id="selectByCrossIdAndDir" resultMap="BaseResultMap">
select
id,lights_no,type,dir,sort,cross_id,gmt_create,gmt_modified
from t_base_cross_lights
where cross_id = #{crossId} and dir = #{dir}
</select>
</mapper> </mapper>
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