Commit abf01b7c authored by hanbing's avatar hanbing

方案管理-路口配置-渠化配置列表

parent 8a44ad2f
......@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
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 org.springframework.web.bind.annotation.PostMapping;
......@@ -41,4 +42,18 @@ public class CrossConfigController {
return jsonViewObject.success();
}
@ApiOperation(value = "渠化配置列表", notes = "渠化配置列表", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/listLaneInfo",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = JsonViewObject.class),
})
public JsonViewObject listLaneInfo(@RequestBody CrossIdDTO crossIdDTO) {
SaveLaneInfoDTO saveLaneInfoDTO = crossConfigServiceImpl.listLaneInfo(crossIdDTO);
JsonViewObject jsonViewObject = JsonViewObject.newInstance();
return jsonViewObject.success(saveLaneInfoDTO);
}
}
......@@ -16,7 +16,7 @@ import java.util.List;
@Data
public class SaveLaneInfoDTO {
/**
* crossId : 13FNK0C6790
* crossId : c7e7b1f352dd4acab4a60088eb391cca
* dirList : [{"dir":1,"laneList":[{"direction":1,"name":"01","laneType":1}]}]
*/
@ApiModelProperty(value = "路口ID,如:c7e7b1f352dd4acab4a60088eb391cca", required = true)
......
......@@ -15,4 +15,6 @@ public interface CrossDirInfoMapper {
void insertOne(CrossDirInfoPO crossDirInfoPO);
void updateIsPedestrian(@Param("isPersonCross") Integer isPersonCross, @Param("id") String id);
CrossDirInfoPO selectByCrossIdAndDirType(@Param("crossId") String crossId, @Param("dirType") Integer dirType);
}
......@@ -11,5 +11,5 @@ import java.util.List;
*/
@Repository
public interface CrossLaneLightsMapper {
void deleteByLaneIds(@Param("ids") List<String> ids);
void deleteByLaneIds(@Param("laneIds") List<String> laneIds);
}
package net.wanji.web.mapper.scheme;
import io.lettuce.core.dynamic.annotation.Param;
import net.wanji.web.po.scheme.LaneInfoPO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
......@@ -17,4 +17,6 @@ public interface LaneInfoMapper {
void deleteByCrossIdAndDir(@Param("crossId") String crossId, @Param("dir") Integer dir);
void insertBatch(@Param("entities") List<LaneInfoPO> laneInfoPOListForInsert);
List<LaneInfoPO> selectBycrossId(@Param("crossId") String crossId);
}
package net.wanji.web.service.scheme;
import net.wanji.web.dto.CrossIdDTO;
import net.wanji.web.dto.SaveLaneInfoDTO;
/**
......@@ -8,4 +9,6 @@ import net.wanji.web.dto.SaveLaneInfoDTO;
*/
public interface CrossConfigService {
void saveLaneInfo(SaveLaneInfoDTO saveLaneInfoDTO);
SaveLaneInfoDTO listLaneInfo(CrossIdDTO crossIdDTO);
}
package net.wanji.web.service.scheme.impl;
import net.wanji.web.dto.CrossIdDTO;
import net.wanji.web.dto.DirListElement;
import net.wanji.web.dto.LaneListElement;
import net.wanji.web.dto.SaveLaneInfoDTO;
......@@ -13,6 +14,8 @@ import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author Kent HAN
......@@ -51,7 +54,9 @@ public class CrossConfigServiceImpl implements CrossConfigService {
crossDirInfoMapper.deleteInByDirType(crossId, dir);
// 删除灯组-车道关系表数据
List<String> laneIds = getLaneIds(laneInfoPOList);
if (laneIds.size()!=0){
crossLaneLightsMapper.deleteByLaneIds(laneIds);
}
// 插入进口信息
List<LaneInfoPO> laneInfoPOListForInsert = getLaneInfoPOListForInsert(
crossId, dirListElement, dir, laneListFromClient);
......@@ -66,6 +71,40 @@ public class CrossConfigServiceImpl implements CrossConfigService {
}
}
@Override
public SaveLaneInfoDTO listLaneInfo(CrossIdDTO crossIdDTO) {
String crossId = crossIdDTO.getCrossId();
SaveLaneInfoDTO saveLaneInfoDTO = new SaveLaneInfoDTO();
saveLaneInfoDTO.setCrossId(crossId);
saveLaneInfoDTO.setDirList(new ArrayList<>());
List<LaneInfoPO> laneInfoPOList = laneInfoMapper.selectBycrossId(crossId);
Map<Integer, List<LaneInfoPO>> collect = laneInfoPOList.stream()
.collect(Collectors.groupingBy(LaneInfoPO::getDir));
for (Map.Entry<Integer, List<LaneInfoPO>> entry : collect.entrySet()) {
Integer key = entry.getKey();
DirListElement dirListElement = new DirListElement();
dirListElement.setDir(key);
// 获取是否有行人道
CrossDirInfoPO crossDirInfoPO = crossDirInfoMapper.selectByCrossIdAndDirType(crossId, key);
Integer isPedestrian = crossDirInfoPO.getIsPedestrian();
dirListElement.setIsPersonCross(isPedestrian);
// 构造内层List
List<LaneInfoPO> value = entry.getValue();
List<LaneListElement> laneListElementList = new ArrayList<>();
for (LaneInfoPO laneInfoPO : value) {
LaneListElement laneListElement = new LaneListElement();
laneListElement.setDirection(laneInfoPO.getTurn());
laneListElement.setLaneType(laneInfoPO.getCategory());
laneListElement.setName(laneInfoPO.getCode());
laneListElementList.add(laneListElement);
}
dirListElement.setLaneList(laneListElementList);
List<DirListElement> dirList = saveLaneInfoDTO.getDirList();
dirList.add(dirListElement);
}
return saveLaneInfoDTO;
}
private static String getId(String crossId, DirListElement dirListElement) {
CrossDirInfoPO crossDirInfoPO = new CrossDirInfoPO();
Integer dir = dirListElement.getDir();
......@@ -76,7 +115,7 @@ public class CrossConfigServiceImpl implements CrossConfigService {
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.setId(crossId + "_" + dir + "_" + 1 + "_" + 0); // todo 暂无主辅路序号,赋值0
crossDirInfoPO.setDirType(dir);
crossDirInfoPO.setInOutType(1);
crossDirInfoPO.setCrossId(crossId);
......@@ -95,7 +134,7 @@ public class CrossConfigServiceImpl implements CrossConfigService {
String substring = name.substring(name.length() - 1);// 1
String s = 1 + substring;
int sort = Integer.parseInt(s);
laneInfoPO.setId(crossId + dirListElement.getDir() + sort);
laneInfoPO.setId(crossId + "_" + dirListElement.getDir() + "_" + sort);
laneInfoPO.setCode(name);
laneInfoPO.setSort(sort);
laneInfoPO.setDir(dir);
......
......@@ -14,7 +14,7 @@
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
<insert id="insertOne" keyProperty="id">
insert into t_base_cross_dir_info(id,dir_type,in_out_type,cross_id,length,is_pedestrian)
values (#{id},#{dirType},#{inOutType},#{crossId},#{length},#{isPedestrian})
</insert>
......@@ -29,4 +29,11 @@
delete from t_base_cross_dir_info
where cross_id = #{crossId} and in_out_type = 1 and dir_type = #{dir}
</delete>
<select id="selectByCrossIdAndDirType" resultMap="BaseResultMap">
select
id,dir_type,in_out_type,cross_id,length,is_pedestrian,gmt_create,gmt_modified
from t_base_cross_dir_info
where cross_id = #{crossId} and dir_type = #{dirType}
</select>
</mapper>
......@@ -14,9 +14,9 @@
<delete id="deleteByLaneIds">
delete from t_base_cross_lane_lights
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
where lane_id in
<foreach collection="laneIds" item="laneId" separator="," open="(" close=")">
#{laneId}
</foreach>
</delete>
......
......@@ -18,7 +18,7 @@
<result property="gmtModified" column="gmt_modified"/>
</resultMap>
<insert id="insertBatch" keyProperty="id" useGeneratedKeys="true">
<insert id="insertBatch">
insert into t_base_lane_info(id,code,sort,dir,turn,category,cross_id)
values
<foreach collection="entities" item="entity" separator=",">
......@@ -38,4 +38,11 @@
where cross_id = #{crossId} and dir = #{dir}
</select>
<select id="selectBycrossId" 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}
</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