Commit 8a44ad2f authored by hanbing's avatar hanbing

方案管理-路口配置-保存渠化配置

parent a143e240
...@@ -5,9 +5,8 @@ import io.swagger.annotations.ApiOperation; ...@@ -5,9 +5,8 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse; import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses; import io.swagger.annotations.ApiResponses;
import net.wanji.web.common.entity.JsonViewObject; import net.wanji.web.common.entity.JsonViewObject;
import net.wanji.web.dto.CrossIdDTO; import net.wanji.web.dto.SaveLaneInfoDTO;
import net.wanji.web.service.scheme.impl.CrossConfigServiceImpl; import net.wanji.web.service.scheme.impl.CrossConfigServiceImpl;
import net.wanji.web.vo.scheme.CrossDirsVO;
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.RequestMapping;
...@@ -29,18 +28,17 @@ public class CrossConfigController { ...@@ -29,18 +28,17 @@ public class CrossConfigController {
this.crossConfigServiceImpl = crossConfigServiceImpl; this.crossConfigServiceImpl = crossConfigServiceImpl;
} }
@ApiOperation(value = "获取路口方向列表", notes = "获取路口方向列表", response = JsonViewObject.class, @ApiOperation(value = "保存渠化配置", notes = "保存渠化配置", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/listCrossDirs", @PostMapping(value = "/saveLaneInfo",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON) produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({ @ApiResponses({
@ApiResponse(code = 200, message = "OK", response = CrossDirsVO.class), @ApiResponse(code = 200, message = "OK", response = JsonViewObject.class),
}) })
public JsonViewObject listCrossDirs(@RequestBody CrossIdDTO crossIdDTO) { public JsonViewObject saveLaneInfo(@RequestBody SaveLaneInfoDTO saveLaneInfoDTO) {
String crossId = crossIdDTO.getCrossId(); crossConfigServiceImpl.saveLaneInfo(saveLaneInfoDTO);
CrossDirsVO crossDirsVO = crossConfigServiceImpl.listCrossDirs(crossId);
JsonViewObject jsonViewObject = JsonViewObject.newInstance(); JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(crossDirsVO); return jsonViewObject.success();
} }
} }
...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
/** /**
* 方案管理-路口配置-获取路口方向列表输入参数
*
* @author Kent HAN * @author Kent HAN
* @date 2022/12/20 10:17 * @date 2022/12/20 10:17
*/ */
......
package net.wanji.web.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@NoArgsConstructor
@Data
public class DirListElement {
/**
* dir : 1
* laneList : [{"direction":1,"name":"01","laneType":1}]
*/
@ApiModelProperty(value = "车道进口方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北", required = true)
private Integer dir;
@ApiModelProperty(value = "是否有行人过街:0否;1是", required = true)
private Integer isPersonCross;
private List<LaneListElement> laneList;
}
\ No newline at end of file
package net.wanji.web.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
@NoArgsConstructor
@Data
public class LaneListElement {
/**
* direction : 1
* name : 01
* laneType : 1
*/
@ApiModelProperty(value = "0无方向 箭头 1:直行2:左转,3:右转,4:掉头,5:左直,6:右直,7:左转掉头,8:左直掉头, 9:左直右, 10:左右转 11:左弯 12:右弯", required = true)
private Integer direction;
@ApiModelProperty(value = "车道代码", required = true)
private String name;
@ApiModelProperty(value = "1机动车;2非机动车;3公交专用;4可变;5潮汐", required = true)
private Integer laneType;
}
\ No newline at end of file
package net.wanji.web.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
/**
* 方案管理-路口配置-保存渠化配置输入参数
*
* @author Kent HAN
* @date 2022/12/20 10:17
*/
@NoArgsConstructor
@Data
public class SaveLaneInfoDTO {
/**
* crossId : 13FNK0C6790
* dirList : [{"dir":1,"laneList":[{"direction":1,"name":"01","laneType":1}]}]
*/
@ApiModelProperty(value = "路口ID,如:c7e7b1f352dd4acab4a60088eb391cca", required = true)
private String crossId;
private List<DirListElement> dirList;
}
...@@ -4,13 +4,15 @@ import io.lettuce.core.dynamic.annotation.Param; ...@@ -4,13 +4,15 @@ import io.lettuce.core.dynamic.annotation.Param;
import net.wanji.web.po.scheme.CrossDirInfoPO; import net.wanji.web.po.scheme.CrossDirInfoPO;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
import java.util.List;
/** /**
* @author Kent HAN * @author Kent HAN
* @date 2022/12/20 10:32 * @date 2022/12/20 10:32
*/ */
@Repository @Repository
public interface CrossDirInfoMapper { public interface CrossDirInfoMapper {
List<CrossDirInfoPO> listByCrossID(@Param("crossId") String crossId); void deleteInByDirType(@Param("crossId") String crossId, @Param("dir") Integer dir);
void insertOne(CrossDirInfoPO crossDirInfoPO);
void updateIsPedestrian(@Param("isPersonCross") Integer isPersonCross, @Param("id") String id);
} }
package net.wanji.web.mapper.scheme;
import io.lettuce.core.dynamic.annotation.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/12/20 10:32
*/
@Repository
public interface CrossLaneLightsMapper {
void deleteByLaneIds(@Param("ids") List<String> ids);
}
package net.wanji.web.mapper.scheme;
import io.lettuce.core.dynamic.annotation.Param;
import net.wanji.web.po.scheme.LaneInfoPO;
import org.springframework.stereotype.Repository;
import java.util.List;
/**
* @author Kent HAN
* @date 2022/12/20 10:32
*/
@Repository
public interface LaneInfoMapper {
List<LaneInfoPO> selectByCrossIdAndDir(@Param("crossId") String crossId, @Param("dir") Integer dir);
void deleteByCrossIdAndDir(@Param("crossId") String crossId, @Param("dir") Integer dir);
void insertBatch(@Param("entities") List<LaneInfoPO> laneInfoPOListForInsert);
}
...@@ -26,6 +26,9 @@ public class CrossDirInfoPO { ...@@ -26,6 +26,9 @@ public class CrossDirInfoPO {
/** 方向路段长度 */ /** 方向路段长度 */
@ApiModelProperty(name = "方向路段长度",notes = "") @ApiModelProperty(name = "方向路段长度",notes = "")
private Double length ; private Double length ;
/** 是否有行人过街:0否;1是 */
@ApiModelProperty(name = "是否有行人过街:0否;1是",notes = "")
private Integer isPedestrian ;
/** 创建时间 */ /** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "") @ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ; private Date gmtCreate ;
......
package net.wanji.web.po.scheme;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/12/29 9:17
*/
@Data
public class CrossLaneLightsPO {
/** 主键 */
@ApiModelProperty(name = "主键",notes = "")
private Integer id ;
/** 灯组ID */
@ApiModelProperty(name = "灯组ID",notes = "")
private Integer lightsId ;
/** 车道ID */
@ApiModelProperty(name = "车道ID",notes = "")
private String laneId ;
/** 路口ID */
@ApiModelProperty(name = "路口ID",notes = "")
private String crossId ;
/** 创建时间 */
@ApiModelProperty(name = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(name = "修改时间",notes = "")
private Date gmtModified ;
}
package net.wanji.web.po.scheme;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author Kent HAN
* @date 2022/12/28 17:45
*/
@Data
public class LaneInfoPO {
/**
* 车道ID(路口ID_方向_序号)
*/
@ApiModelProperty(name = "车道ID(路口ID_方向_序号)", notes = "")
private String id;
/**
* 车道代码
*/
@ApiModelProperty(name = "车道代码", notes = "")
private String code;
/**
* 车道序号;从左车道开始编号11、12、13...
*/
@ApiModelProperty(name = "车道序号", notes = "从左车道开始编号11、12、13...")
private Integer sort;
/**
* 车道方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北
*/
@ApiModelProperty(name = "车道方向:1北;2东北;3东;4东南;5南;6西南;7西;8西北", notes = "")
private Integer dir;
/**
* 车道转向:1左转;2直行;3右转;4掉头;5左直;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头
*/
@ApiModelProperty(name = "0无方向 车道转向:1左转;2直行;3右转;4掉头;5左直;6直右;7左直右;8左右;9左转掉头;10直行掉头;11右转掉头;12左直掉头;13直右掉头;14左直右掉头;15左右掉头; ", notes = "")
private Integer turn;
/**
* 车道类别:1机动车;2非机动车;3公交专用;4可变;5潮汐
*/
@ApiModelProperty(name = "车道类别:1机动车;2非机动车;3公交专用;4可变;5潮汐", notes = "")
private Integer category;
/**
* 路口ID
*/
@ApiModelProperty(name = "路口ID", notes = "")
private String crossId;
/**
* 路段编号
*/
@ApiModelProperty(name = "路段编号", notes = "")
private String rid;
/**
* 车道长度
*/
@ApiModelProperty(name = "车道长度", notes = "")
private Double length;
/**
* 车道宽度
*/
@ApiModelProperty(name = "车道宽度", notes = "")
private Double width;
/**
* 创建时间
*/
@ApiModelProperty(name = "创建时间", notes = "")
private Date gmtCreate;
/**
* 修改时间
*/
@ApiModelProperty(name = "修改时间", notes = "")
private Date gmtModified;
}
\ No newline at end of file
package net.wanji.web.service.scheme; package net.wanji.web.service.scheme;
import net.wanji.web.vo.scheme.CrossDirsVO; import net.wanji.web.dto.SaveLaneInfoDTO;
/** /**
* @author Kent HAN * @author Kent HAN
* @date 2022/12/20 10:26 * @date 2022/12/20 10:26
*/ */
public interface CrossConfigService { public interface CrossConfigService {
CrossDirsVO listCrossDirs(String crossId); void saveLaneInfo(SaveLaneInfoDTO saveLaneInfoDTO);
} }
package net.wanji.web.service.scheme.impl; package net.wanji.web.service.scheme.impl;
import net.wanji.web.common.enums.CrossDirEnum; import net.wanji.web.dto.DirListElement;
import net.wanji.web.common.enums.CrossInOutEnum; import net.wanji.web.dto.LaneListElement;
import net.wanji.web.dto.SaveLaneInfoDTO;
import net.wanji.web.mapper.scheme.CrossDirInfoMapper; import net.wanji.web.mapper.scheme.CrossDirInfoMapper;
import net.wanji.web.mapper.scheme.CrossLaneLightsMapper;
import net.wanji.web.mapper.scheme.LaneInfoMapper;
import net.wanji.web.po.scheme.CrossDirInfoPO; import net.wanji.web.po.scheme.CrossDirInfoPO;
import net.wanji.web.po.scheme.LaneInfoPO;
import net.wanji.web.service.scheme.CrossConfigService; import net.wanji.web.service.scheme.CrossConfigService;
import net.wanji.web.vo.scheme.CrossDirsVO;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList; import java.util.ArrayList;
...@@ -18,28 +21,110 @@ import java.util.List; ...@@ -18,28 +21,110 @@ import java.util.List;
@Service @Service
public class CrossConfigServiceImpl implements CrossConfigService { public class CrossConfigServiceImpl implements CrossConfigService {
private final CrossDirInfoMapper crossDirInfoMapper; private final CrossDirInfoMapper crossDirInfoMapper;
private final LaneInfoMapper laneInfoMapper;
private final CrossLaneLightsMapper crossLaneLightsMapper;
public CrossConfigServiceImpl(CrossDirInfoMapper crossDirInfoMapper) { public CrossConfigServiceImpl(CrossDirInfoMapper crossDirInfoMapper, LaneInfoMapper laneInfoMapper, CrossLaneLightsMapper crossLaneLightsMapper) {
this.crossDirInfoMapper = crossDirInfoMapper; this.crossDirInfoMapper = crossDirInfoMapper;
this.laneInfoMapper = laneInfoMapper;
this.crossLaneLightsMapper = crossLaneLightsMapper;
} }
@Override @Override
public CrossDirsVO listCrossDirs(String crossId) { public void saveLaneInfo(SaveLaneInfoDTO saveLaneInfoDTO) {
List<CrossDirInfoPO> crossDirInfoPOList = crossDirInfoMapper.listByCrossID(crossId); String crossId = saveLaneInfoDTO.getCrossId();
CrossDirsVO crossDirsVO = new CrossDirsVO(); List<DirListElement> dirList = saveLaneInfoDTO.getDirList();
crossDirsVO.setCrossId(crossId); for (DirListElement dirListElement : dirList) {
ArrayList<String> dirs = new ArrayList<>(); // 获取数据库中已有数据
for (CrossDirInfoPO crossDirInfoPO : crossDirInfoPOList) { Integer dir = dirListElement.getDir();
Integer inOutTypeCode = crossDirInfoPO.getInOutType(); List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectByCrossIdAndDir(crossId, dir);
if (inOutTypeCode == 1) { // 只取进口 // 按车道代码排序
Integer dirTypeCode = crossDirInfoPO.getDirType(); List<LaneListElement> laneListFromClient = dirListElement.getLaneList();
String dirType = CrossDirEnum.getMsgByCode(dirTypeCode); laneListFromClient.sort((x,y) -> String.CASE_INSENSITIVE_ORDER.compare(x.getName(), y.getName()));
String inOutType = CrossInOutEnum.getMsgByCode(inOutTypeCode); List<LaneListElement> laneListFromDb = buildLaneListFromDb(laneInfoPOList);
String dir = dirType + inOutType; laneListFromDb.sort((x,y) -> String.CASE_INSENSITIVE_ORDER.compare(x.getName(), y.getName()));
dirs.add(dir); // 比较入参数据与已有数据
} if (!laneListFromClient.equals(laneListFromDb)) {
} // 删除车道表数据
crossDirsVO.setCrossDirs(dirs); laneInfoMapper.deleteByCrossIdAndDir(crossId, dir);
return crossDirsVO; // 删除路口方向表数据
crossDirInfoMapper.deleteInByDirType(crossId, dir);
// 删除灯组-车道关系表数据
List<String> laneIds = getLaneIds(laneInfoPOList);
crossLaneLightsMapper.deleteByLaneIds(laneIds);
// 插入进口信息
List<LaneInfoPO> laneInfoPOListForInsert = getLaneInfoPOListForInsert(
crossId, dirListElement, dir, laneListFromClient);
laneInfoMapper.insertBatch(laneInfoPOListForInsert);
// 插入路口方向
CrossDirInfoPO crossDirInfoPO = getCrossDirInfoPO(crossId, dirListElement);
crossDirInfoMapper.insertOne(crossDirInfoPO);
}
// 更新是否有行人道
String id = getId(crossId, dirListElement);
crossDirInfoMapper.updateIsPedestrian(dirListElement.getIsPersonCross(), id);
}
}
private static String getId(String crossId, DirListElement dirListElement) {
CrossDirInfoPO crossDirInfoPO = new CrossDirInfoPO();
Integer dir = dirListElement.getDir();
String id = crossId + dir + 1 + 0;// todo 暂无主辅路序号,赋值0
return id;
}
private static CrossDirInfoPO getCrossDirInfoPO(String crossId, DirListElement dirListElement) {
CrossDirInfoPO crossDirInfoPO = new CrossDirInfoPO();
Integer dir = dirListElement.getDir();
crossDirInfoPO.setId(crossId + dir + 1 + 0); // todo 暂无主辅路序号,赋值0
crossDirInfoPO.setDirType(dir);
crossDirInfoPO.setInOutType(1);
crossDirInfoPO.setCrossId(crossId);
crossDirInfoPO.setLength(0D); // todo 暂无长度,赋值0
crossDirInfoPO.setIsPedestrian(dirListElement.getIsPersonCross());
return crossDirInfoPO;
}
private static List<LaneInfoPO> getLaneInfoPOListForInsert(String crossId, DirListElement dirListElement,
Integer dir, List<LaneListElement> laneListFromClient) {
List<LaneInfoPO> laneInfoPOListForInsert = new ArrayList<>();
for (LaneListElement laneListElement : laneListFromClient) {
LaneInfoPO laneInfoPO = new LaneInfoPO();
// 序号
String name = laneListElement.getName(); // 01
String substring = name.substring(name.length() - 1);// 1
String s = 1 + substring;
int sort = Integer.parseInt(s);
laneInfoPO.setId(crossId + dirListElement.getDir() + sort);
laneInfoPO.setCode(name);
laneInfoPO.setSort(sort);
laneInfoPO.setDir(dir);
laneInfoPO.setTurn(laneListElement.getDirection());
laneInfoPO.setCategory(laneListElement.getLaneType());
laneInfoPO.setCrossId(crossId);
laneInfoPOListForInsert.add(laneInfoPO);
}
return laneInfoPOListForInsert;
}
private List<String> getLaneIds(List<LaneInfoPO> laneInfoPOList) {
List<String> laneIds = new ArrayList<>();
for (LaneInfoPO laneInfoPO : laneInfoPOList) {
String id = laneInfoPO.getId();
laneIds.add(id);
}
return laneIds;
}
private List<LaneListElement> buildLaneListFromDb(List<LaneInfoPO> laneInfoPOList) {
List<LaneListElement> laneListElements = new ArrayList<>();
for (LaneInfoPO laneInfoPO : laneInfoPOList) {
LaneListElement laneListElement = new LaneListElement();
laneListElement.setDirection(laneInfoPO.getTurn());
laneListElement.setName(laneInfoPO.getCode());
laneListElement.setLaneType(laneInfoPO.getCategory());
laneListElements.add(laneListElement);
}
return laneListElements;
} }
} }
...@@ -9,16 +9,24 @@ ...@@ -9,16 +9,24 @@
<result property="inOutType" column="in_out_type"/> <result property="inOutType" column="in_out_type"/>
<result property="crossId" column="cross_id"/> <result property="crossId" column="cross_id"/>
<result property="length" column="length"/> <result property="length" column="length"/>
<result property="isPedestrian" column="is_pedestrian"/>
<result property="gmtCreate" column="gmt_create"/> <result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/> <result property="gmtModified" column="gmt_modified"/>
</resultMap> </resultMap>
<select id="listByCrossID" resultMap="BaseResultMap"> <insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
select insert into t_base_cross_dir_info(id,dir_type,in_out_type,cross_id,length,is_pedestrian)
id,dir_type,in_out_type,cross_id,length,gmt_create,gmt_modified values (#{id},#{dirType},#{inOutType},#{crossId},#{length},#{isPedestrian})
from t_base_cross_dir_info </insert>
where cross_id = #{crossId}
</select>
<update id="updateIsPedestrian">
update t_base_cross_dir_info
set is_pedestrian = #{isPersonCross}
where id = #{id}
</update>
<delete id="deleteInByDirType">
delete from t_base_cross_dir_info
where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir}
</delete>
</mapper> </mapper>
<?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.scheme.CrossLaneLightsMapper">
<!-- 通用查询映射结果 -->
<resultMap type="net.wanji.web.po.scheme.CrossLaneLightsPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="lightsId" column="lights_id"/>
<result property="laneId" column="lane_id"/>
<result property="crossId" column="cross_id"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<delete id="deleteByLaneIds">
delete from t_base_cross_lane_lights
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</delete>
</mapper>
<?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.scheme.LaneInfoMapper">
<!-- 通用查询映射结果 -->
<resultMap type="net.wanji.web.po.scheme.LaneInfoPO" id="BaseResultMap">
<result property="id" column="id"/>
<result property="code" column="code"/>
<result property="sort" column="sort"/>
<result property="dir" column="dir"/>
<result property="turn" column="turn"/>
<result property="category" column="category"/>
<result property="crossId" column="cross_id"/>
<result property="rid" column="rid"/>
<result property="length" column="length"/>
<result property="width" column="width"/>
<result property="gmtCreate" column="gmt_create"/>
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
insert into t_base_lane_info(id,code,sort,dir,turn,category,cross_id)
values
<foreach collection="entities" item="entity" separator=",">
(#{entity.id},#{entity.code},#{entity.sort},#{entity.dir},#{entity.turn},#{entity.category},#{entity.crossId})
</foreach>
</insert>
<delete id="deleteByCrossIdAndDir">
delete from t_base_lane_info
where cross_id = #{crossId} and dir = #{dir}
</delete>
<select id="selectByCrossIdAndDir" resultMap="BaseResultMap">
select
id,code,sort,dir,turn,category,cross_id,rid,length,width,gmt_create,gmt_modified
from t_base_lane_info
where cross_id = #{crossId} and dir = #{dir}
</select>
</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