Commit 1f991c9a authored by hanbing's avatar hanbing

[update] 恢复行政区划编号

parent 83a93397
......@@ -12,7 +12,7 @@ import java.util.List;
* @date 2023/6/9 13:52
*/
@Data
@ApiModel(value = "AddOrUpdateAreaBO", description = "新增/修改子区")
@ApiModel(value = "AddOrUpdateAreaBO", description = "子区新增/修改")
public class AddOrUpdateAreaBO {
@ApiModelProperty(value = "子区ID")
private Integer areaId;
......@@ -24,7 +24,7 @@ public class AddOrUpdateAreaBO {
private String remark;
@ApiModelProperty(value = "路口ID数组", required = true)
private List<String> crossIdList;
@ApiModelProperty(value = "区域坐标")
@ApiModelProperty(value = "坐标")
private String wkt;
}
package net.wanji.web.bo;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.Pattern;
import java.util.List;
/**
* @author Kent HAN
* @date 2023/6/9 13:52
*/
@Data
@ApiModel(value = "AddOrUpdateAreaBO", description = "辖区新增/修改")
public class AddOrUpdateJurisdictionBO {
@ApiModelProperty(value = "父辖区ID")
private Integer parentId;
@ApiModelProperty(value = "辖区ID")
private Integer areaId;
@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 = "备注", required = true)
private String remark;
@ApiModelProperty(value = "路口ID数组", required = true)
private List<String> crossIdList;
@ApiModelProperty(value = "坐标")
private String wkt;
}
......@@ -6,6 +6,7 @@ import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.web.bo.AddOrUpdateAreaBO;
import net.wanji.web.bo.AddOrUpdateJurisdictionBO;
import net.wanji.web.bo.PolygonBO;
import net.wanji.web.service.impl.CrossManageServiceImpl;
import net.wanji.web.vo.CrossIdAndNameVO;
......@@ -45,7 +46,7 @@ public class CrossManageController {
return JsonViewObject.newInstance().success(res);
}
@ApiOperation(value = "新增/修改子区", notes = "新增/修改子区,传ID为修改,不传ID为新增", response = JsonViewObject.class,
@ApiOperation(value = "子区新增/修改", notes = "子区新增/修改,传ID为修改,不传ID为新增", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/addOrUpdateArea",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
......@@ -57,4 +58,16 @@ public class CrossManageController {
return JsonViewObject.newInstance().success();
}
@ApiOperation(value = "辖区新增/修改", notes = "辖区新增/修改,传ID为修改,不传ID为新增", response = JsonViewObject.class,
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@PostMapping(value = "/addOrUpdateJurisdiction",
produces = MediaType.APPLICATION_JSON, consumes = MediaType.APPLICATION_JSON)
@ApiResponses({
@ApiResponse(code = 200, message = "OK", response = JsonViewObject.class),
})
public JsonViewObject addOrUpdateJurisdiction(@RequestBody AddOrUpdateJurisdictionBO addOrUpdateJurisdictionBO) {
crossManageService.addOrUpdateJurisdiction(addOrUpdateJurisdictionBO);
return JsonViewObject.newInstance().success();
}
}
\ No newline at end of file
......@@ -18,8 +18,8 @@ import java.util.List;
@ApiModel(value = "树形区域目录实体", description = "树形区域目录实体")
public class AreaTreePO {
@ApiModelProperty(value = "区域ID")
private Integer areaId;
@ApiModelProperty(value = "行政区划代码")
private Integer areaCode;
@ApiModelProperty(value = "行政区划名称")
private String areaName;
......
......@@ -3,6 +3,7 @@ package net.wanji.web.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import net.wanji.common.framework.rest.JsonViewObject;
import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.po.CrossInfoPO;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.databus.po.TBaseCrossInfo;
import net.wanji.databus.vo.CrossInfoVO;
......@@ -48,8 +49,10 @@ public class CrossInfoService {
* @param crossInfoVO 查询路口管理输入参数
*/
public JsonViewObject selectAll(CrossInfoVO crossInfoVO) {
PageResultPO<CrossInfoPO> page = new PageResultPO<>();
PageResultPO<BaseCrossInfoPO> page = new PageResultPO<>();
Integer count = baseCrossInfoMapper.countSelectAll(crossInfoVO);
List<CrossInfoPO> list = baseCrossInfoMapper.selectAll(crossInfoVO);
List<BaseCrossInfoPO> list = baseCrossInfoMapper.selectAll(crossInfoVO);
page.setPageNum(crossInfoVO.getPageNum());
page.setPageSize(crossInfoVO.getPageSize());
......@@ -106,18 +109,18 @@ public class CrossInfoService {
IdWorker idWorker = new IdWorker(0, 0);
crossInfoPO.setId(String.valueOf(idWorker.nextId()));
}
if (crossInfoPO.getAreaId() == null) {
if (crossInfoPO.getAreaCode() == null) {
QueryWrapper<TBaseAreaInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().like(TBaseAreaInfo::getName, crossInfoPO.getAreaName());
// 查询areaId
// 查询areaCode
List<TBaseAreaInfo> tBaseAreaInfos = areaInfoMapper.selectList(queryWrapper);
if (tBaseAreaInfos != null && tBaseAreaInfos.size() > 0) {
crossInfoPO.setAreaId(tBaseAreaInfos.get(0).getId());
crossInfoPO.setAreaCode(tBaseAreaInfos.get(0).getCode());
}
}
if (crossInfoPO.getAreaName() == null) {
QueryWrapper<TBaseAreaInfo> queryWrapper = new QueryWrapper<>();
queryWrapper.lambda().eq(TBaseAreaInfo::getCode, crossInfoPO.getAreaId());
queryWrapper.lambda().eq(TBaseAreaInfo::getCode, crossInfoPO.getAreaCode());
List<TBaseAreaInfo> tBaseAreaInfos = areaInfoMapper.selectList(queryWrapper);
if (tBaseAreaInfos != null && tBaseAreaInfos.size() > 0) {
crossInfoPO.setAreaName(tBaseAreaInfos.get(0).getName());
......@@ -168,7 +171,7 @@ public class CrossInfoService {
Map<Integer, List<AreaTreePO>> parentCodeMap = infos.stream().collect(Collectors.groupingBy(AreaTreePO::getParentCode));
for (AreaTreePO info : infos) {
for (Integer parentCode : parentCodeMap.keySet()) {
if (info.getAreaId().equals(parentCode)) {
if (info.getAreaCode().equals(parentCode)) {
info.setChildren(parentCodeMap.get(parentCode));
break;
}
......@@ -178,3 +181,4 @@ public class CrossInfoService {
return infos;
}
}
package net.wanji.web.service;
import net.wanji.web.bo.AddOrUpdateAreaBO;
import net.wanji.web.bo.AddOrUpdateJurisdictionBO;
import net.wanji.web.bo.PolygonBO;
import net.wanji.web.vo.CrossIdAndNameVO;
......@@ -15,4 +16,6 @@ public interface CrossManageService {
List<CrossIdAndNameVO> selectCrossesByPolygon(PolygonBO polygonBO);
void addOrUpdateArea(AddOrUpdateAreaBO addOrUpdateAreaBO);
void addOrUpdateJurisdiction(AddOrUpdateJurisdictionBO addOrUpdateJurisdictionBO);
}
......@@ -9,6 +9,7 @@ import net.wanji.databus.dao.mapper.BaseCrossInfoMapper;
import net.wanji.databus.po.BaseAreaInfoPO;
import net.wanji.databus.po.BaseCrossInfoPO;
import net.wanji.web.bo.AddOrUpdateAreaBO;
import net.wanji.web.bo.AddOrUpdateJurisdictionBO;
import net.wanji.web.bo.PolygonBO;
import net.wanji.web.service.CrossManageService;
import net.wanji.web.vo.CrossIdAndNameVO;
......@@ -93,4 +94,39 @@ public class CrossManageServiceImpl implements CrossManageService {
crossInfoMapper.updateAreaId(crossIdList, newAreaId);
}
}
@Override
public void addOrUpdateJurisdiction(AddOrUpdateJurisdictionBO addOrUpdateJurisdictionBO) {
Integer parentId = addOrUpdateJurisdictionBO.getParentId();
Integer areaId = addOrUpdateJurisdictionBO.getAreaId();
String areaName = addOrUpdateJurisdictionBO.getAreaName();
String remark = addOrUpdateJurisdictionBO.getRemark();
List<String> crossIdList = addOrUpdateJurisdictionBO.getCrossIdList();
String wkt = addOrUpdateJurisdictionBO.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);
}
}
}
......@@ -49,9 +49,9 @@ public class BaseCrossInfoVO {
/**
* 行政区划代码
*/
@ApiModelProperty(value = "区域ID")
@ApiModelProperty(value = "行政区划代码")
//@NotNull(message = "行政区划代码不可为空", groups = {Save.class, Update.class})
private Integer areaId;
private Integer areaCode;
/**
* 行政区划名称
......
......@@ -25,8 +25,8 @@ public class CrossInfoDTO {
@ApiModelProperty(name = "路口级别",notes = "")
private Integer level;
@ApiModelProperty(name = "区域Id",notes = "")
private Integer areaId;
@ApiModelProperty(name = "行政区划代码",notes = "")
private Integer areaCode;
@ApiModelProperty(name = "路口位置",notes = "")
private String location;
......
......@@ -38,7 +38,7 @@ public class BaseCrossInfoPO {
/**
* 行政区划代码
*/
private Integer areaId;
private Integer areaCode;
/**
* 行政区划名称
......
......@@ -53,8 +53,8 @@ public class TBaseCrossInfo implements Serializable {
/**
* 行政区划代码
*/
@TableField("area_id")
private Integer areaId;
@TableField("area_code")
private Integer areaCode;
/**
* 路口位置
......
......@@ -21,8 +21,8 @@ public class CrossInfoVO {
/**
* 行政区划代码
*/
@ApiModelProperty(value = "区域ID", required = true)
private Integer areaId;
@ApiModelProperty(value = "行政区划代码", required = true)
private Integer areaCode;
/**
* 行政区划名称
......
......@@ -6,7 +6,7 @@
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="TINYINT"/>
<result column="level" property="level" jdbcType="TINYINT"/>
<result column="area_id" property="areaId" jdbcType="INTEGER"/>
<result column="area_code" property="areaCode" jdbcType="INTEGER"/>
<result column="location" property="location" jdbcType="VARCHAR"/>
<result column="is_signal" property="isSignal" jdbcType="TINYINT"/>
<result column="is_start" property="isStart" jdbcType="TINYINT"/>
......@@ -19,7 +19,7 @@
<result column="name" property="name" jdbcType="VARCHAR"/>
<result column="type" property="type" jdbcType="TINYINT"/>
<result column="level" property="level" jdbcType="TINYINT"/>
<result column="area_id" property="areaId" jdbcType="INTEGER"/>
<result column="area_code" property="areaCode" jdbcType="INTEGER"/>
<result column="area_name" property="areaName" jdbcType="VARCHAR"/>
<result column="location" property="location" jdbcType="VARCHAR"/>
<result column="is_signal" property="isSignal" jdbcType="TINYINT"/>
......@@ -30,12 +30,12 @@
</resultMap>
<sql id="baseColumn">
id, name, type, level, area_id, location, is_signal, is_start, is_send, gmt_create, gmt_modified
id, name, type, level, area_code, location, is_signal, is_start, is_send, gmt_create, gmt_modified
</sql>
<select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String">
select
<include refid="baseColumn"/>
<include refid="baseColumn"/>
from t_base_cross_info
where id = #{id,jdbcType=CHAR}
</select>
......@@ -44,23 +44,13 @@
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,
level, area_code, location,
is_signal, is_start, is_send,
gmt_create, gmt_modified)
values (#{id,jdbcType=CHAR}, #{name,jdbcType=VARCHAR}, #{type,jdbcType=TINYINT},
#{level,jdbcType=TINYINT}, #{areaId,jdbcType=INTEGER}, #{location,jdbcType=VARCHAR},
#{level,jdbcType=TINYINT}, #{areaCode,jdbcType=INTEGER}, #{location,jdbcType=VARCHAR},
#{isSignal,jdbcType=TINYINT}, #{isStart,jdbcType=TINYINT}, #{isSend,jdbcType=TINYINT},
#{gmtCreate,jdbcType=TIMESTAMP}, #{gmtModified,jdbcType=TIMESTAMP})
</insert>
......@@ -79,8 +69,8 @@
<if test="level != null">
level,
</if>
<if test="areaId != null">
area_id,
<if test="areaCode != null">
area_code,
</if>
<if test="location != null">
location,
......@@ -114,8 +104,8 @@
<if test="level != null">
#{level,jdbcType=TINYINT},
</if>
<if test="areaId != null">
#{areaId,jdbcType=INTEGER},
<if test="areaCode != null">
#{areaCode,jdbcType=INTEGER},
</if>
<if test="location != null">
#{location,jdbcType=VARCHAR},
......@@ -149,8 +139,8 @@
<if test="level != null">
level = #{level,jdbcType=TINYINT},
</if>
<if test="areaId != null">
area_id = #{areaId,jdbcType=INTEGER},
<if test="areaCode != null">
area_code = #{areaCode,jdbcType=INTEGER},
</if>
<if test="location != null">
location = #{location,jdbcType=VARCHAR},
......@@ -178,7 +168,7 @@
set name = #{name,jdbcType=VARCHAR},
type = #{type,jdbcType=TINYINT},
level = #{level,jdbcType=TINYINT},
area_id = #{areaId,jdbcType=INTEGER},
area_code = #{areaCode,jdbcType=INTEGER},
location = #{location,jdbcType=VARCHAR},
is_signal = #{isSignal,jdbcType=TINYINT},
is_start = #{isStart,jdbcType=TINYINT},
......@@ -187,28 +177,18 @@
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
select c.id,c.name,c.type,c.level,c.area_code,a.name
area_name,c.location,c.is_signal,c.is_start,c.is_send,c.gmt_create,c.gmt_modified
from t_base_cross_info c
left join t_base_area_info a on c.area_id=a.code
left join t_base_area_info a on c.area_code=a.code
<where>
<if test="name != null and name != ''">
and c.name like concat('%',#{name},'%')
</if>
<if test="areaId != null and areaId != ''">
and a.id = #{areaId}
<if test="areaCode != null and areaCode != ''">
and a.code = #{areaCode}
</if>
<if test="areaName != null and areaName != ''">
and a.name = #{areaName}
......@@ -230,13 +210,13 @@
<select id="countSelectAll" parameterType="net.wanji.databus.vo.CrossInfoPageVO" resultType="integer">
select count(1)
from t_base_cross_info c
left join t_base_area_info a on c.area_id=a.id
left join t_base_area_info a on c.area_code=a.code
<where>
<if test="name != null and name != ''">
and c.name like concat('%',#{name},'%')
</if>
<if test="areaId != null and areaId != ''">
and a.id = #{areaId}
<if test="areaCode != null and areaCode != ''">
and a.code = #{areaCode}
</if>
<if test="areaName != null and areaName != ''">
and a.name = #{areaName}
......@@ -272,9 +252,9 @@
select <include refid="baseColumn"/>
from t_base_cross_info
where id in
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
<foreach collection="ids" item="id" separator="," open="(" close=")">
#{id}
</foreach>
</select>
<select id="selectById" resultType="net.wanji.databus.po.BaseCrossInfoPO">
......@@ -292,10 +272,4 @@
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
......@@ -60,12 +60,12 @@
<include refid="Base_Column_List"/>
from t_base_rid_info
<where>
<if test="startCrossId != null and startCrossId != ''">
and start_cross_id = #{startCrossId}
</if>
<if test="endCrossId != null and endCrossId != ''">
and end_cross_id = #{endCrossId}
</if>
<if test="startCrossId != null and startCrossId != ''">
and start_cross_id = #{startCrossId}
</if>
<if test="endCrossId != null and endCrossId != ''">
and end_cross_id = #{endCrossId}
</if>
</where>
</select>
......
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