Commit 83a93397 authored by hanbing's avatar hanbing

[add] 路口管理,新增/修改子区

parent f877d5c4
package net.wanji.opt.bo;
package net.wanji.web.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......@@ -16,13 +16,15 @@ import java.util.List;
public class AddOrUpdateAreaBO {
@ApiModelProperty(value = "子区ID")
private Integer areaId;
@ApiModelProperty(value = "子区名称")
@ApiModelProperty(value = "子区名称", required = true)
@Pattern(regexp = "^[\\u4E00-\\u9FA5\\w\\-]{0,20}$", message = "子区名称只能包含中文、英文、数字、下划线和中横线,0~20个字符")
private String areaName;
@Pattern(regexp = "^[\\u4E00-\\u9FA5\\w\\-]{0,200}$", message = "子区名称只能包含中文、英文、数字、下划线和中横线,0~200个字符")
@ApiModelProperty(value = "备注")
@ApiModelProperty(value = "备注", required = true)
private String remark;
@ApiModelProperty(value = "路口ID数组")
@ApiModelProperty(value = "路口ID数组", required = true)
private List<String> crossIdList;
@ApiModelProperty(value = "区域坐标")
private String wkt;
}
package net.wanji.opt.bo;
package net.wanji.web.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
package net.wanji.opt.controller;
package net.wanji.web.controller;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.opt.bo.AddOrUpdateAreaBO;
import net.wanji.opt.bo.PolygonBO;
import net.wanji.opt.service.impl.CrossManageServiceImpl;
import net.wanji.opt.vo.CrossIdAndNameVO;
import net.wanji.web.bo.AddOrUpdateAreaBO;
import net.wanji.web.bo.PolygonBO;
import net.wanji.web.service.impl.CrossManageServiceImpl;
import net.wanji.web.vo.CrossIdAndNameVO;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
......@@ -22,14 +22,14 @@ import java.util.List;
*
* @author Kent HAN
*/
@Api(value = "CrossController", description = "路口管理")
@Api(value = "CrossManageController", description = "路口管理")
@RequestMapping("/crossManage")
@RestController
public class CrossController {
public class CrossManageController {
private final CrossManageServiceImpl crossManageService;
public CrossController(CrossManageServiceImpl crossManageService) {
public CrossManageController(CrossManageServiceImpl crossManageService) {
this.crossManageService = crossManageService;
}
......
package net.wanji.opt.service;
package net.wanji.web.service;
import net.wanji.opt.bo.AddOrUpdateAreaBO;
import net.wanji.opt.bo.PolygonBO;
import net.wanji.opt.vo.CrossIdAndNameVO;
import net.wanji.web.bo.AddOrUpdateAreaBO;
import net.wanji.web.bo.PolygonBO;
import net.wanji.web.vo.CrossIdAndNameVO;
import java.util.List;
......
package net.wanji.opt.service.impl;
package net.wanji.web.service.impl;
import cn.hutool.core.util.ObjectUtil;
import lombok.extern.slf4j.Slf4j;
......@@ -6,11 +6,12 @@ import net.wanji.common.gts.GeometryUtil;
import net.wanji.common.utils.tool.CrossUtil;
import net.wanji.databus.dao.mapper.BaseAreaInfoMapper;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.po.BaseAreaInfoPO;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.opt.bo.AddOrUpdateAreaBO;
import net.wanji.opt.bo.PolygonBO;
import net.wanji.opt.service.CrossManageService;
import net.wanji.opt.vo.CrossIdAndNameVO;
import net.wanji.web.bo.AddOrUpdateAreaBO;
import net.wanji.web.bo.PolygonBO;
import net.wanji.web.service.CrossManageService;
import net.wanji.web.vo.CrossIdAndNameVO;
import org.locationtech.jts.geom.Geometry;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
......@@ -65,15 +66,31 @@ public class CrossManageServiceImpl implements CrossManageService {
String areaName = addOrUpdateAreaBO.getAreaName();
String remark = addOrUpdateAreaBO.getRemark();
List<String> crossIdList = addOrUpdateAreaBO.getCrossIdList();
String wkt = addOrUpdateAreaBO.getWkt();
if (ObjectUtil.isNotEmpty(areaId)) {
// 修改
// 修改子区名称和备注
baseAreaInfoMapper.updateAreaNameAndRemark(areaName, remark, areaId);
// 修改子区关联路口
List<String> oldIds = crossInfoMapper.selectIdsByAreaId(areaId);
crossInfoMapper.deleteAreaId(oldIds);
crossInfoMapper.updateAreaId(crossIdList, areaId);
} else {
// 新增
// 新增子区
BaseAreaInfoPO baseAreaInfoPO = new BaseAreaInfoPO();
baseAreaInfoPO.setCode(0);
baseAreaInfoPO.setName(areaName);
baseAreaInfoPO.setType(5);
baseAreaInfoPO.setParentCode(0);
baseAreaInfoPO.setLocation("");
baseAreaInfoPO.setPolylines(wkt);
baseAreaInfoPO.setRemark(remark);
baseAreaInfoMapper.insertOne(baseAreaInfoPO);
Integer newAreaId = baseAreaInfoPO.getId();
// 关联子区路口
crossInfoMapper.updateAreaId(crossIdList, newAreaId);
}
}
}
package net.wanji.opt.vo;
package net.wanji.web.vo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
......
package net.wanji.databus.dao.mapper;
import net.wanji.databus.po.BaseAreaInfoPO;
import org.springframework.stereotype.Repository;
/**
......@@ -11,4 +12,6 @@ import org.springframework.stereotype.Repository;
public interface BaseAreaInfoMapper {
void updateAreaNameAndRemark(String name, String remark, Integer id);
void insertOne(BaseAreaInfoPO baseAreaInfoPO);
}
......@@ -50,4 +50,10 @@ public interface BaseCrossInfoMapper extends BaseMapper<TBaseCrossInfo> {
Integer countSelectAll(CrossInfoVO crossInfoVO);
List<CrossDeviceStatusInfoOutVO> listCrossDeviceStatusInfo();
void deleteAreaId(List<String> ids);
List<String> selectIdsByAreaId(Integer areaId);
void updateAreaId(List<String> ids, Integer areaId);
}
package net.wanji.databus.po;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.Date;
/**
* @author duanruiming
* @date 2023/03/10 17:27
*/
@Data
@ApiModel(value = "BaseAreaInfoPO", description = "区域基础信息")
public class BaseAreaInfoPO {
/** 主键 */
@ApiModelProperty(value = "主键",notes = "")
private Integer id ;
/** 行政区划代码 */
@ApiModelProperty(value = "行政区划代码",notes = "")
private Integer code ;
/** 区域名称 */
@ApiModelProperty(value = "区域名称",notes = "")
private String name ;
/** 区划类型:1行政区划;2交警辖区;3商圈;4交通小区;5热点区域;6道路 */
@ApiModelProperty(value = "区划类型:1行政区划;2交警辖区;3商圈;4交通小区;5热点区域;6道路",notes = "")
private Integer type ;
/** 父节点 */
@ApiModelProperty(value = "父节点",notes = "")
private Integer parentCode ;
/** 区域中心点 */
@ApiModelProperty(value = "区域中心点",notes = "")
private String location ;
/** 区域边界 */
@ApiModelProperty(value = "区域边界",notes = "")
private String polylines ;
/** 备注 */
@ApiModelProperty(value = "备注",notes = "")
private String remark ;
/** 创建时间 */
@ApiModelProperty(value = "创建时间",notes = "")
private Date gmtCreate ;
/** 修改时间 */
@ApiModelProperty(value = "修改时间",notes = "")
private Date gmtModified ;
}
......@@ -2,6 +2,15 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="net.wanji.databus.dao.mapper.BaseAreaInfoMapper">
<sql id="baseColumnList">
code,name,type,parent_code,location,polylines,remark
</sql>
<insert id="insertOne" keyProperty="id" useGeneratedKeys="true">
insert into t_base_area_info (<include refid="baseColumnList"/>)
values (#{code},#{name},#{type},#{parentCode},#{location},#{polylines},#{remark})
</insert>
<update id="updateAreaNameAndRemark">
update t_base_area_info
<set>
......
......@@ -44,6 +44,16 @@
from t_base_cross_info
where id = #{id,jdbcType=CHAR}
</delete>
<update id="deleteAreaId">
update t_base_cross_info
set area_id = 0
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</update>
<insert id="insert" parameterType="net.wanji.databus.po.TBaseCrossInfo">
insert into t_base_cross_info (id, name, type,
level, area_id, location,
......@@ -177,6 +187,16 @@
gmt_modified = #{gmtModified,jdbcType=TIMESTAMP}
where id = #{id,jdbcType=CHAR}
</update>
<update id="updateAreaId">
update t_base_cross_info
set area_id = #{areaId}
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</update>
<select id="selectAll" parameterType="net.wanji.databus.vo.CrossInfoPageVO" resultMap="SelectAllMap">
<bind name="startNum" value="(pageNum - 1) * pageSize"/>
select c.id,c.name,c.type,c.level,c.area_id,a.name
......@@ -272,4 +292,10 @@
from t_base_cross_info
where name = #{name}
</select>
<select id="selectIdsByAreaId" resultType="java.lang.String">
select id from t_base_cross_info
where area_id = #{areaId}
</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