|
@@ -37,6 +37,7 @@ import org.opengis.feature.simple.SimpleFeatureType;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import java.io.*;
|
|
@@ -62,15 +63,6 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
@Autowired
|
|
|
QcJzxxMapper qcJzxxMapper;
|
|
|
|
|
|
- //if (map.get("info") instanceof Clob) {
|
|
|
- // Clob clob = (Clob) map.get("info");
|
|
|
- // try {
|
|
|
- // result.setInfo(clob.getSubString((long) 1, (int) clob.length()));
|
|
|
- // } catch (SQLException throwables) {
|
|
|
- // throwables.printStackTrace();
|
|
|
- // }
|
|
|
- //}
|
|
|
-
|
|
|
@Override
|
|
|
public ArrayList<GeoAnalysis> DrawMap(List<ZYFXPZB> zyfxpzb, String shape) {
|
|
|
ArrayList list = new ArrayList();
|
|
@@ -96,21 +88,24 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
result.setObjectid(map.get("objectid").toString());
|
|
|
result.setInfo(map.get("info").toString());
|
|
|
//增加地块编号
|
|
|
- if (null!=map.get("dkbh")){
|
|
|
+ if (null != map.get("dkbh")) {
|
|
|
result.setDkbh(map.get("dkbh").toString());
|
|
|
//根据zfghyt判断价值,单位(亩),地块可能涉及到多块
|
|
|
- QcJzxx qcJzxx=qcJzxxMapper.queryDkInfo(result.getDkbh());
|
|
|
- if (null!=qcJzxx){
|
|
|
+ QcJzxx qcJzxx = qcJzxxMapper.queryDkInfo(result.getDkbh());
|
|
|
+ if (null != qcJzxx) {
|
|
|
//计算地块和土地面积价值 面积单位是公顷, 地块价值面积单位是亩
|
|
|
- //类型
|
|
|
result.setZfghyt(qcJzxx.getZfghyt());
|
|
|
+ result.setZfghytString(qcJzxx.getRemark());
|
|
|
+ result.setRemark("面积单位:亩,价值单位:元");
|
|
|
//价值计算公顷转换成亩
|
|
|
- try{
|
|
|
- Float f=Float.parseFloat(result.getArea());
|
|
|
- result.setTdjz(f*15*qcJzxx.getJz());
|
|
|
- }catch (Exception e){
|
|
|
- result.setRemark("土地价值无法计算");
|
|
|
+ try {
|
|
|
+ result.setTdjz(Float.parseFloat(result.getArea()) * 15 * qcJzxx.getJz());
|
|
|
+ } catch (Exception e) {
|
|
|
+ result.setRemark("土地面积数据异常");
|
|
|
}
|
|
|
+ } else {
|
|
|
+ //查不到地块的情况
|
|
|
+ result.setRemark("该地块没有分类信息");
|
|
|
}
|
|
|
}
|
|
|
result.setAtableenam(atableenam);
|
|
@@ -121,6 +116,7 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public ZYFXPZB SelectByTbs(String MTABLENAME, String atableename) {
|
|
|
return geoAnalysisMapper.SelectByTbs(MTABLENAME, atableename);
|
|
@@ -187,16 +183,14 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public Boolean exportShps(HttpServletResponse response,String id) {
|
|
|
+ public Boolean exportShps(HttpServletResponse response, String id) {
|
|
|
List<Map<String, Object>> list = geoAnalysisMapper.exportShp(id);
|
|
|
boolean b = exportShp(response, list);
|
|
|
- return b ;
|
|
|
+ return b;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
-
|
|
|
* 导出Shp
|
|
|
-
|
|
|
*/
|
|
|
|
|
|
public static boolean exportShp(HttpServletResponse response, List<Map<String, Object>> list) {
|
|
@@ -207,11 +201,11 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
|
|
|
String id = UUID.randomUUID().toString();
|
|
|
|
|
|
- String tempPath = "D:"+"/temp/"+ id + "/" ;
|
|
|
+ String tempPath = "D:" + "/temp/" + id + "/";
|
|
|
|
|
|
String shpFilePath = tempPath + id + ".shp";//临时文件
|
|
|
|
|
|
- String zippath = "D:" + "/temp/" + id + ".zip";//压缩包,把xls文件压缩到zip中,在浏览器下载
|
|
|
+ String zippath = "D:" + "/temp/" + id + ".zip";//压缩包,把xls文件压缩到zip中,在浏览器下载
|
|
|
|
|
|
File dir = new File(tempPath);
|
|
|
|
|
@@ -230,7 +224,6 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
try {
|
|
|
|
|
|
|
|
|
-
|
|
|
//定义属性
|
|
|
|
|
|
final SimpleFeatureType TYPE = DataUtilities.createType("Location",
|
|
@@ -241,15 +234,15 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
|
|
|
);
|
|
|
|
|
|
- /* SimpleFeatureCollection collection = FeatureCollections.newCollection();*/
|
|
|
+ /* SimpleFeatureCollection collection = FeatureCollections.newCollection();*/
|
|
|
List<SimpleFeature> features = new ArrayList<>();
|
|
|
SimpleFeatureBuilder featureBuilder = new SimpleFeatureBuilder(TYPE);
|
|
|
|
|
|
for (Map<String, Object> row : list) {
|
|
|
- if(row.get("GEOM") instanceof Clob){
|
|
|
- Clob clob=(Clob) row.get("GEOM");
|
|
|
- try{
|
|
|
- row.put("GEOM",clob.getSubString((long)1,(int)clob.length()));
|
|
|
+ if (row.get("GEOM") instanceof Clob) {
|
|
|
+ Clob clob = (Clob) row.get("GEOM");
|
|
|
+ try {
|
|
|
+ row.put("GEOM", clob.getSubString((long) 1, (int) clob.length()));
|
|
|
} catch (SQLException throwables) {
|
|
|
throwables.printStackTrace();
|
|
|
}
|
|
@@ -259,7 +252,7 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
WKTReader wktReader = new WKTReader();
|
|
|
Geometry geometry = null;
|
|
|
try {
|
|
|
- geometry = wktReader.read(wkt);
|
|
|
+ geometry = wktReader.read(wkt);
|
|
|
|
|
|
//geometry.setSRID(4326);
|
|
|
} catch (Exception e) {
|
|
@@ -268,7 +261,7 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
featureBuilder.add(geometry);
|
|
|
- System.out.println("78888888888888888888888"+row.get("DKMC"));
|
|
|
+ System.out.println("78888888888888888888888" + row.get("DKMC"));
|
|
|
featureBuilder.add(row.get("DKMC"));
|
|
|
|
|
|
SimpleFeature feature = featureBuilder.buildFeature(null);
|
|
@@ -279,7 +272,7 @@ public class GeoAnalysisServiceImpl extends ServiceImpl<GeoAnalysisMapper, GeoAn
|
|
|
collection.add(feature);*/
|
|
|
|
|
|
}
|
|
|
- SimpleFeatureCollection collection = new ListFeatureCollection(TYPE,features);
|
|
|
+ SimpleFeatureCollection collection = new ListFeatureCollection(TYPE, features);
|
|
|
|
|
|
|
|
|
ShapefileDataStoreFactory dataStoreFactory = new ShapefileDataStoreFactory();
|
|
@@ -297,7 +290,6 @@ collection.add(feature);*/
|
|
|
newDataStore.forceSchemaCRS(DefaultGeographicCRS.WGS84);
|
|
|
|
|
|
|
|
|
-
|
|
|
Transaction transaction = new DefaultTransaction("create");
|
|
|
|
|
|
String typeName = newDataStore.getTypeNames()[0];
|
|
@@ -305,7 +297,6 @@ collection.add(feature);*/
|
|
|
SimpleFeatureSource featureSource = newDataStore.getFeatureSource(typeName);
|
|
|
|
|
|
|
|
|
-
|
|
|
if (featureSource instanceof SimpleFeatureStore) {
|
|
|
|
|
|
SimpleFeatureStore featureStore = (SimpleFeatureStore) featureSource;
|
|
@@ -360,51 +351,26 @@ collection.add(feature);*/
|
|
|
log.error("【shp导出失败】" + e.getMessage());
|
|
|
|
|
|
} finally {
|
|
|
-
|
|
|
if (fileOutputStream != null) {
|
|
|
-
|
|
|
try {
|
|
|
-
|
|
|
fileOutputStream.close();
|
|
|
-
|
|
|
} catch (Exception e) {
|
|
|
-
|
|
|
log.error("【shp导出流关闭失败】" + e.getMessage());
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
File filedir = new File(tempPath);
|
|
|
-
|
|
|
if (filedir.exists() && filedir.isDirectory()) {
|
|
|
-
|
|
|
File[] files = filedir.listFiles();
|
|
|
-
|
|
|
for (File f : files) {
|
|
|
-
|
|
|
if (f.exists()) {
|
|
|
-
|
|
|
f.delete();
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
filedir.delete();
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
if (zipfile.exists()) {
|
|
|
-
|
|
|
zipfile.delete();
|
|
|
-
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
return flag;
|
|
|
|