查询项目的行政区域信息接口,项目相关管理接口逻辑完善,行政区划管理相关接口逻辑完善

This commit is contained in:
mi9688
2024-10-25 18:08:22 +08:00
parent 9912eb5671
commit c19a08f78c
14 changed files with 425 additions and 59 deletions

View File

@ -16,55 +16,66 @@ import com.fastbee.common.core.domain.BaseEntity;
* 行政区划对象 sys_district
*
* @author kerwincui
* @date 2024-10-18
* @date 2024-10-25
*/
@ApiModel(value = "SysDistrict",description = "行政区划 sys_district")
@Data
@EqualsAndHashCode(callSuper = true)
public class SysDistrict extends BaseEntity
{
private static final long serialVersionUID = 1L;
{
private static final long serialVersionUID = 1L;
/** */
private Long id;
/** 城市id */
@Excel(name = "城市id")
@ApiModelProperty("城市id")
@Excel(name = "城市id")
@ApiModelProperty("城市id")
private Long adcode;
/** 省市级别 */
@Excel(name = "省市级别")
@ApiModelProperty("省市级别")
@Excel(name = "省市级别")
@ApiModelProperty("省市级别")
private Long level;
/** 父级id */
@Excel(name = "父级id")
@ApiModelProperty("父级id")
/** 父级id(指向adcode字段) */
@Excel(name = "父级id(指向adcode字段)")
@ApiModelProperty("父级id(指向adcode字段)")
private Long parentId;
/** 简称 */
@Excel(name = "简称")
@ApiModelProperty("简称")
@Excel(name = "简称")
@ApiModelProperty("简称")
private String name;
/** 全称 */
@Excel(name = "全称")
@ApiModelProperty("全称")
@Excel(name = "全称")
@ApiModelProperty("全称")
private String fullName;
/** 经度 */
@Excel(name = "经度")
@ApiModelProperty("经度")
@Excel(name = "经度")
@ApiModelProperty("经度")
private BigDecimal lng;
/** 纬度 */
@Excel(name = "纬度")
@ApiModelProperty("纬度")
@Excel(name = "纬度")
@ApiModelProperty("纬度")
private BigDecimal lat;
/** 删除标志0代表存在 2代表删除 */
private String delFlag;
/** 行政区域地图轮廓json数据 */
@Excel(name = "行政区域地图轮廓json数据")
@ApiModelProperty("行政区域地图轮廓json数据")
private String mapOutline;
/** 行政区域地图轮廓json数据url */
@Excel(name = "行政区域地图轮廓json数据url")
@ApiModelProperty("行政区域地图轮廓json数据url")
private String mapOutlineUrl;
private List<SysDistrict> children;
}

View File

@ -1,13 +1,17 @@
package com.fastbee.system.service.impl;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.stream.Collectors;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONException;
import cn.hutool.json.JSONObject;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
import com.fastbee.common.exception.ServiceException;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.fastbee.system.mapper.SysDistrictMapper;
@ -72,9 +76,46 @@ public class SysDistrictServiceImpl implements ISysDistrictService
@Override
public int updateSysDistrict(SysDistrict sysDistrict)
{
String mapOutlineUrl = sysDistrict.getMapOutlineUrl();
//未上传行政区划轮廓不做处理
if(StringUtils.isBlank(mapOutlineUrl)){
return sysDistrictMapper.updateSysDistrict(sysDistrict);
}
//判断行政区划轮廓json文件路url是否是完整url还是相对url
if((mapOutlineUrl.contains("http://") || mapOutlineUrl.contains("https://"))){
//如果不是是相对url则代表修改过行政区划轮廓数据
String jsonData = HttpUtil.get(mapOutlineUrl);
System.err.println("获取到行政区划轮廓json:"+jsonData);
//读取文件内容
if (Objects.isNull(jsonData)) {
throw new ServiceException("上传行政区划地图轮廓json数据为空");
}
//校验文件内容是否是json格式
if (!isValidJson(jsonData)) {
throw new ServiceException("json格式不正确");
}
int startIndex = mapOutlineUrl.indexOf("/profile/upload/");
String relativeUrl = mapOutlineUrl.substring(startIndex);
sysDistrict.setMapOutlineUrl(relativeUrl);
sysDistrict.setMapOutline(jsonData);
}
return sysDistrictMapper.updateSysDistrict(sysDistrict);
}
/**
* 验证字符串是否是json格式
*/
public boolean isValidJson(String jsonStr) {
try {
JSONUtil.parseObj(jsonStr);
} catch (JSONException e) {
return false;
}
return true;
}
/**
* 批量删除行政区划
*

View File

@ -14,10 +14,12 @@
<result property="lng" column="lng" />
<result property="lat" column="lat" />
<result property="delFlag" column="del_flag" />
<result property="mapOutline" column="map_outline" />
<result property="mapOutlineUrl" column="map_outline_url" />
</resultMap>
<sql id="selectSysDistrictVo">
select id, adcode, level, parent_id, name, full_name, lng, lat, del_flag from sys_district
select id, adcode, level, parent_id, name, full_name, lng, lat, del_flag, map_outline, map_outline_url from sys_district
</sql>
<select id="selectSysDistrictList" parameterType="SysDistrict" resultMap="SysDistrictResult">
@ -30,6 +32,8 @@
<if test="fullName != null and fullName != ''"> and full_name like concat('%', #{fullName}, '%')</if>
<if test="lng != null "> and lng = #{lng}</if>
<if test="lat != null "> and lat = #{lat}</if>
<if test="mapOutline != null and mapOutline != ''"> and map_outline = #{mapOutline}</if>
<if test="mapOutlineUrl != null and mapOutlineUrl != ''"> and map_outline_url = #{mapOutlineUrl}</if>
</where>
</select>
@ -49,6 +53,8 @@
<if test="lng != null">lng,</if>
<if test="lat != null">lat,</if>
<if test="delFlag != null">del_flag,</if>
<if test="mapOutline != null">map_outline,</if>
<if test="mapOutlineUrl != null">map_outline_url,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="adcode != null">#{adcode},</if>
@ -59,6 +65,8 @@
<if test="lng != null">#{lng},</if>
<if test="lat != null">#{lat},</if>
<if test="delFlag != null">#{delFlag},</if>
<if test="mapOutline != null">#{mapOutline},</if>
<if test="mapOutlineUrl != null">#{mapOutlineUrl},</if>
</trim>
</insert>
@ -73,6 +81,8 @@
<if test="lng != null">lng = #{lng},</if>
<if test="lat != null">lat = #{lat},</if>
<if test="delFlag != null">del_flag = #{delFlag},</if>
<if test="mapOutline != null">map_outline = #{mapOutline},</if>
<if test="mapOutlineUrl != null">map_outline_url = #{mapOutlineUrl},</if>
</trim>
where id = #{id}
</update>