data/db_tab.sql | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/entity/all/BaseEntity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/entity/all/BaseGeoEntity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/entity/md/MdGdcgEntity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/entity/md/MdZxcgEntity.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/mapper/all/GeomBaseMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/mapper/md/MdZxcgMapper.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 | |
src/main/java/com/lf/server/service/data/DataLoaderService.java | ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史 |
data/db_tab.sql
@@ -970,10 +970,17 @@ create_user integer, create_time timestamp(6) without time zone default now(), update_user integer, update_time timestamp(6) without time zone update_time timestamp(6) without time zone, geom geometry(Point, 4490) ); create index if not exists md_zxcg_geom_idx on md.md_zxcg using gist (geom); drop index if exists md_zxcg_geom_idx cascade; comment on table md.md_zxcg is 'ä¸çº¿ææè¡¨'; vacuum analyze md.md_zxcg; insert into md.md_zxcg (zh, geom) values ('A01', ST_GeomFromText('POINT(95.80461853400004 34.13862467200005)')); insert into md.md_zxcg (zh, geom) values ('A02', ST_GeomFromText('POINT(119.873000 39.392000)')); select gid,zh,ST_ASText(geom) from md.md_zxcg; select * from md.md_zxcg; -- drop table if exists md.md_gdcg; src/main/java/com/lf/server/entity/all/BaseEntity.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,63 @@ package com.lf.server.entity.all; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import java.sql.Timestamp; /** * åºç¡å®ä½ç±» * @author WWW */ public class BaseEntity { @TableId(type = IdType.AUTO) private Integer gid; private Integer createUser; private Timestamp createTime; private Integer updateUser; private Timestamp updateTime; public Integer getGid() { return gid; } public void setGid(Integer gid) { this.gid = gid; } public Integer getCreateUser() { return createUser; } public void setCreateUser(Integer createUser) { this.createUser = createUser; } public Timestamp getCreateTime() { return createTime; } public void setCreateTime(Timestamp createTime) { this.createTime = createTime; } public Integer getUpdateUser() { return updateUser; } public void setUpdateUser(Integer updateUser) { this.updateUser = updateUser; } public Timestamp getUpdateTime() { return updateTime; } public void setUpdateTime(Timestamp updateTime) { this.updateTime = updateTime; } } src/main/java/com/lf/server/entity/all/BaseGeoEntity.java
¶Ô±ÈÐÂÎļþ @@ -0,0 +1,20 @@ package com.lf.server.entity.all; import com.baomidou.mybatisplus.annotation.TableField; /** * 空é´åºç¡å®ä½ç±» * @author WWW */ public class BaseGeoEntity extends BaseEntity { @TableField(select = false) private String geom; public String getGeom() { return geom; } public void setGeom(String geom) { this.geom = geom; } } src/main/java/com/lf/server/entity/md/MdGdcgEntity.java
@@ -1,16 +1,15 @@ package com.lf.server.entity.md; import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.lf.server.annotation.ExcelHead; import com.lf.server.entity.all.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.io.Serializable; import java.sql.Timestamp; /** * ç®¡éææè¡¨ @@ -21,11 +20,9 @@ @AllArgsConstructor @TableName("md.md_gdcg") @ExcelHead(headRows = 3,excludeSheets = "å°é¢,ç®å½") public class MdGdcgEntity implements Serializable { @EqualsAndHashCode(callSuper = true) public class MdGdcgEntity extends BaseEntity implements Serializable { private static final long serialVersionUID = -221347663194025408L; @TableId(type = IdType.AUTO) private Integer gid; @ExcelProperty(index = 0) private String bh; @@ -80,14 +77,6 @@ @ExcelProperty(index = 17) private String bz; private Integer createUser; private Timestamp createTime; private Integer updateUser; private Timestamp updateTime; public String getBh() { return bh; @@ -231,45 +220,5 @@ public void setBz(String bz) { this.bz = bz; } public Integer getGid() { return gid; } public void setGid(Integer gid) { this.gid = gid; } public Integer getCreateUser() { return createUser; } public void setCreateUser(Integer createUser) { this.createUser = createUser; } public Timestamp getCreateTime() { return createTime; } public void setCreateTime(Timestamp createTime) { this.createTime = createTime; } public Integer getUpdateUser() { return updateUser; } public void setUpdateUser(Integer updateUser) { this.updateUser = updateUser; } public Timestamp getUpdateTime() { return updateTime; } public void setUpdateTime(Timestamp updateTime) { this.updateTime = updateTime; } } src/main/java/com/lf/server/entity/md/MdZxcgEntity.java
@@ -1,16 +1,15 @@ package com.lf.server.entity.md; import com.alibaba.excel.annotation.ExcelProperty; import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.lf.server.annotation.ExcelHead; import com.lf.server.entity.all.BaseGeoEntity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.EqualsAndHashCode; import lombok.NoArgsConstructor; import java.io.Serializable; import java.sql.Timestamp; /** * ä¸çº¿ææè¡¨ @@ -21,11 +20,9 @@ @AllArgsConstructor @TableName("md.md_zxcg") @ExcelHead(headRows = 1) public class MdZxcgEntity implements Serializable { @EqualsAndHashCode(callSuper = true) public class MdZxcgEntity extends BaseGeoEntity implements Serializable { private static final long serialVersionUID = 686714648588893312L; @TableId(type = IdType.AUTO) private Integer gid; @ExcelProperty(index = 0) private String zh; @@ -44,14 +41,6 @@ @ExcelProperty(index = 5) private Double z; private Integer createUser; private Timestamp createTime; private Integer updateUser; private Timestamp updateTime; public String getZh() { return zh; @@ -99,45 +88,5 @@ public void setZ(Double z) { this.z = z; } public Integer getGid() { return gid; } public void setGid(Integer gid) { this.gid = gid; } public Integer getCreateUser() { return createUser; } public void setCreateUser(Integer createUser) { this.createUser = createUser; } public Timestamp getCreateTime() { return createTime; } public void setCreateTime(Timestamp createTime) { this.createTime = createTime; } public Integer getUpdateUser() { return updateUser; } public void setUpdateUser(Integer updateUser) { this.updateUser = updateUser; } public Timestamp getUpdateTime() { return updateTime; } public void setUpdateTime(Timestamp updateTime) { this.updateTime = updateTime; } } src/main/java/com/lf/server/mapper/all/GeomBaseMapper.java
@@ -2,6 +2,7 @@ import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Select; import org.apache.ibatis.annotations.Update; /** * 空é´åºç¡Mapper @@ -27,4 +28,15 @@ */ @Select("select ST_SRID(geom) from ${tab} limit 1") public Integer selectSrid(@Param("tab") String tab); /** * æ´æ°ç©ºé´ä½ç½® * * @param tab 表å * @param gid GID * @param geom 空é´ä½ç½® * @return å½±åè¡æ° */ @Update("update ${tab} set geom = ST_GeomFromText('${geom}') where gid = #{gid}") public Integer updateGeom(@Param("tab") String tab, @Param("gid") Integer gid, @Param("geom") String geom); } src/main/java/com/lf/server/mapper/md/MdZxcgMapper.java
@@ -1,7 +1,7 @@ package com.lf.server.mapper.md; import com.lf.server.entity.md.MdZxcgEntity; import com.lf.server.mapper.all.BasicMapper; import com.lf.server.mapper.all.GeomBaseMapper; import org.apache.ibatis.annotations.Mapper; import org.springframework.stereotype.Repository; @@ -11,5 +11,5 @@ */ @Mapper @Repository public interface MdZxcgMapper extends BasicMapper<MdZxcgEntity> { public interface MdZxcgMapper extends GeomBaseMapper<MdZxcgEntity> { } src/main/java/com/lf/server/service/data/DataLoaderService.java
@@ -7,6 +7,7 @@ import com.lf.server.helper.ClassHelper; import com.lf.server.helper.ExcelHelper; import com.lf.server.helper.FileHelper; import com.lf.server.mapper.all.GeomBaseMapper; import com.lf.server.service.all.BaseUploadService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; @@ -211,6 +212,11 @@ rows += baseMapper.insert(list.get(i)); } if (baseMapper instanceof GeomBaseMapper) { GeomBaseMapper geomBaseMapper = (GeomBaseMapper) baseMapper; updateGeom(geomBaseMapper, list); } return rows; } @@ -224,9 +230,36 @@ cuField.setAccessible(true); cuField.set(t, mfe.getCreateUser()); Field cuTime = t.getClass().getDeclaredField("createTime"); cuTime.setAccessible(true); cuTime.set(t, mfe.getCreateTime()); Field ctField = t.getClass().getDeclaredField("createTime"); ctField.setAccessible(true); ctField.set(t, mfe.getCreateTime()); } } catch (Exception ex) { log.error(ex.getMessage(), ex); } } /** * 设置空é´ä¿¡æ¯ */ private <T> void updateGeom(GeomBaseMapper geomBaseMapper, List<T> list) { try { for (T t : list) { Field xField = t.getClass().getDeclaredField("x"); xField.setAccessible(true); double x = (double) xField.get(t); Field yField = t.getClass().getDeclaredField("y"); yField.setAccessible(true); double y = (double) yField.get(t); String wkt = String.format("POINT(%f %f)", x, y); Field gField = t.getClass().getDeclaredField("geom"); gField.setAccessible(true); gField.set(t, wkt); //Integer gid= } } catch (Exception ex) { log.error(ex.getMessage(), ex);