Browse Source

Merge remote-tracking branch 'origin/main'

main
ZhaoYang 20 hours ago
parent
commit
2db708cdd3
  1. 61
      chenhai-system/src/main/java/com/chenhai/system/domain/MapFeatures.java
  2. 119
      chenhai-system/src/main/java/com/chenhai/system/service/impl/MapFeaturesServiceImpl.java
  3. 37
      chenhai-system/src/main/resources/mapper/system/MapFeaturesMapper.xml

61
chenhai-system/src/main/java/com/chenhai/system/domain/MapFeatures.java

@ -1,7 +1,7 @@
package com.chenhai.system.domain; package com.chenhai.system.domain;
import java.math.BigDecimal;
import java.util.Date; import java.util.Date;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
@ -10,7 +10,7 @@ import com.chenhai.common.core.domain.BaseEntity;
/** /**
* 地图配套标注管理对象 map_features * 地图配套标注管理对象 map_features
*
*
* @author ruoyi * @author ruoyi
* @date 2026-04-17 * @date 2026-04-17
*/ */
@ -31,73 +31,87 @@ public class MapFeatures extends BaseEntity
/** 经度 */ /** 经度 */
@Excel(name = "经度") @Excel(name = "经度")
private BigDecimal longitude;
private String longitude;
/** 纬度 */ /** 纬度 */
@Excel(name = "纬度") @Excel(name = "纬度")
private BigDecimal latitude;
private String latitude;
/** 经纬度坐标(合并存储,支持数组格式) */
@Excel(name = "经纬度坐标")
private Object coordinates; // 改为 Object 类型支持 String List
/** 创建时间 */ /** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd")
private Date createdAt; private Date createdAt;
public void setId(Long id)
public void setId(Long id)
{ {
this.id = id; this.id = id;
} }
public Long getId()
public Long getId()
{ {
return id; return id;
} }
public void setName(String name)
public void setName(String name)
{ {
this.name = name; this.name = name;
} }
public String getName()
public String getName()
{ {
return name; return name;
} }
public void setType(String type)
public void setType(String type)
{ {
this.type = type; this.type = type;
} }
public String getType()
public String getType()
{ {
return type; return type;
} }
public void setLongitude(BigDecimal longitude)
public void setLongitude(String longitude)
{ {
this.longitude = longitude; this.longitude = longitude;
} }
public BigDecimal getLongitude()
public String getLongitude()
{ {
return longitude; return longitude;
} }
public void setLatitude(BigDecimal latitude)
public void setLatitude(String latitude)
{ {
this.latitude = latitude; this.latitude = latitude;
} }
public BigDecimal getLatitude()
public String getLatitude()
{ {
return latitude; return latitude;
} }
public void setCreatedAt(Date createdAt)
public void setCoordinates(Object coordinates)
{
this.coordinates = coordinates;
}
public Object getCoordinates()
{
return coordinates;
}
public void setCreatedAt(Date createdAt)
{ {
this.createdAt = createdAt; this.createdAt = createdAt;
} }
public Date getCreatedAt()
public Date getCreatedAt()
{ {
return createdAt; return createdAt;
} }
@ -105,12 +119,13 @@ public class MapFeatures extends BaseEntity
@Override @Override
public String toString() { public String toString() {
return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
.append("id", getId())
.append("name", getName())
.append("type", getType())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.append("createdAt", getCreatedAt())
.toString();
.append("id", getId())
.append("name", getName())
.append("type", getType())
.append("longitude", getLongitude())
.append("latitude", getLatitude())
.append("coordinates", getCoordinates())
.append("createdAt", getCreatedAt())
.toString();
} }
} }

119
chenhai-system/src/main/java/com/chenhai/system/service/impl/MapFeaturesServiceImpl.java

@ -1,5 +1,6 @@
package com.chenhai.system.service.impl; package com.chenhai.system.service.impl;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -9,67 +10,78 @@ import com.chenhai.system.service.IMapFeaturesService;
/** /**
* 地图配套标注管理Service业务层处理 * 地图配套标注管理Service业务层处理
*
*
* @author ruoyi * @author ruoyi
* @date 2026-04-17 * @date 2026-04-17
*/ */
@Service @Service
public class MapFeaturesServiceImpl implements IMapFeaturesService
public class MapFeaturesServiceImpl implements IMapFeaturesService
{ {
@Autowired @Autowired
private MapFeaturesMapper mapFeaturesMapper; private MapFeaturesMapper mapFeaturesMapper;
/** /**
* 查询地图配套标注管理 * 查询地图配套标注管理
*
*
* @param id 地图配套标注管理主键 * @param id 地图配套标注管理主键
* @return 地图配套标注管理 * @return 地图配套标注管理
*/ */
@Override @Override
public MapFeatures selectMapFeaturesById(Long id) public MapFeatures selectMapFeaturesById(Long id)
{ {
return mapFeaturesMapper.selectMapFeaturesById(id);
MapFeatures mapFeatures = mapFeaturesMapper.selectMapFeaturesById(id);
convertCoordinatesToArray(mapFeatures);
return mapFeatures;
} }
/** /**
* 查询地图配套标注管理列表 * 查询地图配套标注管理列表
*
*
* @param mapFeatures 地图配套标注管理 * @param mapFeatures 地图配套标注管理
* @return 地图配套标注管理 * @return 地图配套标注管理
*/ */
@Override @Override
public List<MapFeatures> selectMapFeaturesList(MapFeatures mapFeatures) public List<MapFeatures> selectMapFeaturesList(MapFeatures mapFeatures)
{ {
return mapFeaturesMapper.selectMapFeaturesList(mapFeatures);
List<MapFeatures> list = mapFeaturesMapper.selectMapFeaturesList(mapFeatures);
// 转换每条记录的坐标格式
for (MapFeatures item : list) {
convertCoordinatesToArray(item);
}
return list;
} }
/** /**
* 新增地图配套标注管理 * 新增地图配套标注管理
*
*
* @param mapFeatures 地图配套标注管理 * @param mapFeatures 地图配套标注管理
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertMapFeatures(MapFeatures mapFeatures) public int insertMapFeatures(MapFeatures mapFeatures)
{ {
// 如果是数组格式转换为逗号分隔的字符串存储
convertArrayToCoordinates(mapFeatures);
return mapFeaturesMapper.insertMapFeatures(mapFeatures); return mapFeaturesMapper.insertMapFeatures(mapFeatures);
} }
/** /**
* 修改地图配套标注管理 * 修改地图配套标注管理
*
*
* @param mapFeatures 地图配套标注管理 * @param mapFeatures 地图配套标注管理
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateMapFeatures(MapFeatures mapFeatures) public int updateMapFeatures(MapFeatures mapFeatures)
{ {
// 如果是数组格式转换为逗号分隔的字符串存储
convertArrayToCoordinates(mapFeatures);
return mapFeaturesMapper.updateMapFeatures(mapFeatures); return mapFeaturesMapper.updateMapFeatures(mapFeatures);
} }
/** /**
* 批量删除地图配套标注管理 * 批量删除地图配套标注管理
*
*
* @param ids 需要删除的地图配套标注管理主键 * @param ids 需要删除的地图配套标注管理主键
* @return 结果 * @return 结果
*/ */
@ -81,7 +93,7 @@ public class MapFeaturesServiceImpl implements IMapFeaturesService
/** /**
* 删除地图配套标注管理信息 * 删除地图配套标注管理信息
*
*
* @param id 地图配套标注管理主键 * @param id 地图配套标注管理主键
* @return 结果 * @return 结果
*/ */
@ -90,4 +102,91 @@ public class MapFeaturesServiceImpl implements IMapFeaturesService
{ {
return mapFeaturesMapper.deleteMapFeaturesById(id); return mapFeaturesMapper.deleteMapFeaturesById(id);
} }
/**
* 将逗号分隔的坐标字符串转换为数组格式
* 输入: "105.70587,38.83020,105.73710,38.83981"
* 输出: [[105.70587, 38.83020], [105.73710, 38.83981]]
*
* @param mapFeatures 地图标注对象
*/
private void convertCoordinatesToArray(MapFeatures mapFeatures) {
if (mapFeatures == null || mapFeatures.getCoordinates() == null) {
return;
}
Object coordinates = mapFeatures.getCoordinates();
// 如果是字符串格式
if (coordinates instanceof String) {
String coordStr = (String) coordinates;
if (coordStr == null || coordStr.trim().isEmpty()) {
return;
}
// 按逗号分割支持中英文逗号
String[] parts = coordStr.split("[,,]+");
// 检查坐标数量是否为偶数经度纬度成对出现
if (parts.length >= 2 && parts.length % 2 == 0) {
List<List<Double>> coordArray = new ArrayList<>();
for (int i = 0; i < parts.length; i += 2) {
try {
double lng = Double.parseDouble(parts[i].trim());
double lat = Double.parseDouble(parts[i + 1].trim());
List<Double> point = new ArrayList<>();
point.add(lng);
point.add(lat);
coordArray.add(point);
} catch (NumberFormatException e) {
// 解析失败保持原样
return;
}
}
mapFeatures.setCoordinates(coordArray);
}
}
}
/**
* 将数组格式的坐标转换为逗号分隔的字符串
* 输入: [[105.70587, 38.83020], [105.73710, 38.83981]]
* 输出: "105.70587,38.83020,105.73710,38.83981"
*
* @param mapFeatures 地图标注对象
*/
private void convertArrayToCoordinates(MapFeatures mapFeatures) {
if (mapFeatures == null || mapFeatures.getCoordinates() == null) {
return;
}
Object coordinates = mapFeatures.getCoordinates();
// 如果是 List 格式数组
if (coordinates instanceof List) {
List<?> coordList = (List<?>) coordinates;
if (coordList.isEmpty()) {
return;
}
StringBuilder sb = new StringBuilder();
for (Object item : coordList) {
if (item instanceof List) {
List<?> point = (List<?>) item;
if (point.size() >= 2) {
Object lng = point.get(0);
Object lat = point.get(1);
if (sb.length() > 0) {
sb.append(",");
}
sb.append(lng).append(",").append(lat);
}
}
}
if (sb.length() > 0) {
mapFeatures.setCoordinates(sb.toString());
}
}
}
} }

37
chenhai-system/src/main/resources/mapper/system/MapFeaturesMapper.xml

@ -1,7 +1,7 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper <!DOCTYPE mapper
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.chenhai.system.mapper.MapFeaturesMapper"> <mapper namespace="com.chenhai.system.mapper.MapFeaturesMapper">
<resultMap type="MapFeatures" id="MapFeaturesResult"> <resultMap type="MapFeatures" id="MapFeaturesResult">
@ -10,21 +10,23 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<result property="type" column="type" /> <result property="type" column="type" />
<result property="longitude" column="longitude" /> <result property="longitude" column="longitude" />
<result property="latitude" column="latitude" /> <result property="latitude" column="latitude" />
<result property="coordinates" column="coordinates" />
<result property="createdAt" column="created_at" /> <result property="createdAt" column="created_at" />
</resultMap> </resultMap>
<sql id="selectMapFeaturesVo"> <sql id="selectMapFeaturesVo">
select id, name, type, longitude, latitude, created_at from map_features
select id, name, type, longitude, latitude, coordinates, created_at from map_features
</sql> </sql>
<select id="selectMapFeaturesList" parameterType="MapFeatures" resultMap="MapFeaturesResult"> <select id="selectMapFeaturesList" parameterType="MapFeatures" resultMap="MapFeaturesResult">
<include refid="selectMapFeaturesVo"/> <include refid="selectMapFeaturesVo"/>
<where> <where>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="longitude != null "> and longitude = #{longitude}</if>
<if test="latitude != null "> and latitude = #{latitude}</if>
<if test="createdAt != null "> and created_at = #{createdAt}</if>
<if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
<if test="type != null and type != ''"> and type = #{type}</if>
<if test="longitude != null and longitude != ''"> and longitude = #{longitude}</if>
<if test="latitude != null and latitude != ''"> and latitude = #{latitude}</if>
<if test="coordinates != null and coordinates != ''"> and coordinates = #{coordinates}</if>
<if test="createdAt != null"> and created_at = #{createdAt}</if>
</where> </where>
</select> </select>
@ -38,17 +40,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="(" suffix=")" suffixOverrides=","> <trim prefix="(" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">name,</if> <if test="name != null and name != ''">name,</if>
<if test="type != null and type != ''">type,</if> <if test="type != null and type != ''">type,</if>
<if test="longitude != null">longitude,</if>
<if test="latitude != null">latitude,</if>
<if test="longitude != null and longitude != ''">longitude,</if>
<if test="latitude != null and latitude != ''">latitude,</if>
<if test="coordinates != null and coordinates != ''">coordinates,</if>
<if test="createdAt != null">created_at,</if> <if test="createdAt != null">created_at,</if>
</trim>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=","> <trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="name != null and name != ''">#{name},</if> <if test="name != null and name != ''">#{name},</if>
<if test="type != null and type != ''">#{type},</if> <if test="type != null and type != ''">#{type},</if>
<if test="longitude != null">#{longitude},</if>
<if test="latitude != null">#{latitude},</if>
<if test="longitude != null and longitude != ''">#{longitude},</if>
<if test="latitude != null and latitude != ''">#{latitude},</if>
<if test="coordinates != null and coordinates != ''">#{coordinates},</if>
<if test="createdAt != null">#{createdAt},</if> <if test="createdAt != null">#{createdAt},</if>
</trim>
</trim>
</insert> </insert>
<update id="updateMapFeatures" parameterType="MapFeatures"> <update id="updateMapFeatures" parameterType="MapFeatures">
@ -56,8 +60,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<trim prefix="SET" suffixOverrides=","> <trim prefix="SET" suffixOverrides=",">
<if test="name != null and name != ''">name = #{name},</if> <if test="name != null and name != ''">name = #{name},</if>
<if test="type != null and type != ''">type = #{type},</if> <if test="type != null and type != ''">type = #{type},</if>
<if test="longitude != null">longitude = #{longitude},</if>
<if test="latitude != null">latitude = #{latitude},</if>
<if test="longitude != null and longitude != ''">longitude = #{longitude},</if>
<if test="latitude != null and latitude != ''">latitude = #{latitude},</if>
<if test="coordinates != null and coordinates != ''">coordinates = #{coordinates},</if>
<if test="createdAt != null">created_at = #{createdAt},</if> <if test="createdAt != null">created_at = #{createdAt},</if>
</trim> </trim>
where id = #{id} where id = #{id}

Loading…
Cancel
Save