fix:修改getTifByRegionAndTime拼接url

main
xlp 6 months ago
parent 8032a8db91
commit de9589f00a

@ -76,8 +76,6 @@ public class DataImportServiceImpl implements DataImportService {
radi_chn_mul_horMapper radichnmulhorMapper; radi_chn_mul_horMapper radichnmulhorMapper;
@Override @Override
public List<String> upLoadProjectLedgerBySingleFile(MultipartFile file) throws IOException { public List<String> upLoadProjectLedgerBySingleFile(MultipartFile file) throws IOException {
return null; return null;
@ -89,7 +87,6 @@ public class DataImportServiceImpl implements DataImportService {
} }
/** /**
* Excel * Excel
* *
@ -128,7 +125,7 @@ public class DataImportServiceImpl implements DataImportService {
}); });
//将list插入数据库 //将list插入数据库
Integer integer = tSamplingDataDetailsMapper.insertByBatch(list); Integer integer = tSamplingDataDetailsMapper.insertByBatch(list);
log.info("成功插入 {} 条数据",integer); log.info("成功插入 {} 条数据", integer);
} catch (IOException e) { } catch (IOException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
@ -245,15 +242,15 @@ public class DataImportServiceImpl implements DataImportService {
} }
@Override @Override
public List<String> upLoadRailwayStaUAVTifData(MultipartFile[] railwayStaUAVTifDataFile){ public List<String> upLoadRailwayStaUAVTifData(MultipartFile[] railwayStaUAVTifDataFile) {
//设置时间格式 //设置时间格式
SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd" ); SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
//1、处理文件位置 //1、处理文件位置
//文件存放位置 //文件存放位置
String realPath = "data"; String realPath = "data";
//按照时间格式划分 //按照时间格式划分
String format = sdf.format(new Date()); String format = sdf.format(new Date());
String path = realPath + File.separator+ format+ File.separator + UUID.randomUUID()+ File.separator; String path = realPath + File.separator + format + File.separator + UUID.randomUUID() + File.separator;
// String path = realPath + File.separator + UUID.randomUUID()+ File.separator; // String path = realPath + File.separator + UUID.randomUUID()+ File.separator;
// String path = realPath; // String path = realPath;
@ -264,7 +261,6 @@ public class DataImportServiceImpl implements DataImportService {
} }
String objPath = System.getProperty("user.dir") + File.separator + path; String objPath = System.getProperty("user.dir") + File.separator + path;
// 2、保存文件到指定路径存文件到指定路径 // 2、保存文件到指定路径存文件到指定路径
for (MultipartFile file : railwayStaUAVTifDataFile) { for (MultipartFile file : railwayStaUAVTifDataFile) {
@ -298,17 +294,6 @@ public class DataImportServiceImpl implements DataImportService {
return retMsg; return retMsg;
// //设置时间格式 // //设置时间格式
// SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd" ); // SimpleDateFormat sdf = new SimpleDateFormat( "yyyyMMdd" );
// //1、处理文件位置 // //1、处理文件位置
@ -363,6 +348,7 @@ public class DataImportServiceImpl implements DataImportService {
/** /**
* *
*
* @param folder * @param folder
* @return * @return
*/ */
@ -391,32 +377,32 @@ public class DataImportServiceImpl implements DataImportService {
@Override @Override
public List<TGeoserverinfo> getRefionInfo() { public List<TGeoserverinfo> getRefionInfo() {
try { try {
List<TGeoserverinfo> regionInfo = tGeoserverinfoMapper.getRefionInfo(); List<TGeoserverinfo> regionInfo = tGeoserverinfoMapper.getRefionInfo();
if (regionInfo != null) { if (regionInfo != null) {
for (TGeoserverinfo info : regionInfo) { for (TGeoserverinfo info : regionInfo) {
info.setUrl(geoServerPubService.getMapBox3857RasterWmsUrl(info.getId())); info.setUrl(geoServerPubService.getMapBox3857RasterWmsUrl(info.getId()));
}
} }
return regionInfo;
} catch (ParamsException e) {
// 这里可以记录日志或者处理异常
throw new RuntimeException("Failed to get region info", e);
} }
return regionInfo;
} catch (ParamsException e) {
// 这里可以记录日志或者处理异常
throw new RuntimeException("Failed to get region info", e);
}
} }
@Override @Override
public List<TGeoserverinfo> getTifByRegion(String region) { public List<TGeoserverinfo> getTifByRegion(String region) {
try{ try {
List<TGeoserverinfo> tifByRegion = tGeoserverinfoMapper.getTifByRegion(region); List<TGeoserverinfo> tifByRegion = tGeoserverinfoMapper.getTifByRegion(region);
if (tifByRegion != null) { if (tifByRegion != null) {
for (TGeoserverinfo info : tifByRegion) { for (TGeoserverinfo info : tifByRegion) {
info.setUrl(geoServerPubService.getMapBox3857RasterWmsUrl(info.getId())); info.setUrl(geoServerPubService.getMapBox3857RasterWmsUrl(info.getId()));
}
} }
}
return tifByRegion; return tifByRegion;
}catch (ParamsException e){ } catch (ParamsException e) {
throw new RuntimeException("Failed to get region info", e); throw new RuntimeException("Failed to get region info", e);
} }
@ -424,338 +410,340 @@ public class DataImportServiceImpl implements DataImportService {
@Override @Override
public TGeoserverinfo getTifByRegionAndTime(String region) { public TGeoserverinfo getTifByRegionAndTime(String region) {
try{ try {
TGeoserverinfo tGeoserverinfo = new TGeoserverinfo(); TGeoserverinfo tGeoserverinfo = new TGeoserverinfo();
tGeoserverinfo = tGeoserverinfoMapper.getTifByRegionAndTime(region); tGeoserverinfo = tGeoserverinfoMapper.getTifByRegionAndTime(region);
if (tGeoserverinfo != null) {
tGeoserverinfo.setUrl(geoServerPubService.getMapBox3857RasterWmsUrl(tGeoserverinfo.getId()));
}
return tGeoserverinfo; return tGeoserverinfo;
}catch (ParamsException e){ }catch(ParamsException e){
throw new RuntimeException("数据库获取失败", e); throw new RuntimeException("数据库获取失败", e);
} }
} }
@Override
public List<String> getLayer () {
try {
List<String> layer = new ArrayList<>();
layer.add("城市三维模型");
layer.add("居民点");
return layer;
} catch (ParamsException e) {
return null;
}
}
@Override @Override
public List<String> getLayer() { public List<String> getTifByLayer (String layer){
try{ List<String> tifUrls;
List<String> layer = new ArrayList<>(); try {
layer.add("城市三维模型"); tifUrls = new ArrayList<>();
layer.add("居民点"); switch (layer) {
return layer; case "城市三维模型":
}catch (ParamsException e){ tifUrls.add("http://111.42.18.66:8089/api/c3dserver/");
return null; break;
case "居民点":
tifUrls.add("http://111.42.18.66:8089/api/c3dserver/");
break;
default:
// 如果输入的城市名称不在已知列表中可以返回一个空列表或者null
tifUrls = null;
break;
}
} catch (ParamsException e) {
return null;
}
return tifUrls;
} }
}
@Override @Override
public List<String> getTifByLayer(String layer) { public List<ElementRet> getElementInfo () {
List<String> tifUrls; try {
try { List<ElementRet> elementInfo = new ArrayList<>();
tifUrls = new ArrayList<>(); elementInfo = radichnmulhorMapper.getElementInfo();
switch (layer) { return elementInfo;
case "城市三维模型": } catch (ParamsException e) {
tifUrls.add("http://111.42.18.66:8089/api/c3dserver/"); return null;
break;
case "居民点":
tifUrls.add("http://111.42.18.66:8089/api/c3dserver/");
break;
default:
// 如果输入的城市名称不在已知列表中可以返回一个空列表或者null
tifUrls = null;
break;
} }
} catch (ParamsException e) {
return null;
} }
return tifUrls;
}
@Override @Override
public List<ElementRet> getElementInfo() { public List<ElementValue> getValueByElement (String element){
try { Map<String, String> elementMap = new HashMap<String, String>() {{
List<ElementRet> elementInfo = new ArrayList<>(); put("总辐射辐照度", "V14311");
elementInfo = radichnmulhorMapper.getElementInfo(); put("净辐射辐照度", "V14312");
return elementInfo; put("直接辐射辐照度", "V14313");
}catch (ParamsException e){ put("散射辐射辐照度", "V14314");
put("反射辐射辐照度", "V14315");
}};
try {
List<ElementValue> retValue = new ArrayList<>();
// 检查传入的中文element是否在映射关系中
String mappedElementCode = elementMap.get(element);
if (mappedElementCode != null) {
// 如果在映射关系中,使用对应的英文代码去查询数据库
retValue = tSamplingDataDetailsMapper.getValueByElement(element); // 这里传入的是中文元素名称
}
if (retValue != null && !retValue.isEmpty()) {
return retValue;
}
} catch (ParamsException e) {
throw new RuntimeException("Failed to get element info", e);
}
return null; return null;
} }
}
@Override @Override
public List<ElementValue> getValueByElement(String element) { public List<MonitorRet> getMonitorInfo () {
Map<String, String> elementMap = new HashMap<String, String>() {{ List<MonitorRet> monitorInfoList = new ArrayList<>();
put("总辐射辐照度", "V14311"); try {
put("净辐射辐照度", "V14312"); Map<String, String> monitorMap = new HashMap<>();
put("直接辐射辐照度", "V14313"); monitorMap.put("监测点1", "50");
put("散射辐射辐照度", "V14314"); monitorMap.put("监测点2", "45");
put("反射辐射辐照度", "V14315"); monitorMap.put("监测点3", "40");
}}; monitorMap.put("监测点4", "35");
monitorMap.put("监测点5", "30");
try { monitorMap.put("监测点6", "25");
List<ElementValue> retValue = new ArrayList<>(); monitorMap.put("监测点7", "20");
// 检查传入的中文element是否在映射关系中 monitorMap.put("监测点8", "15");
String mappedElementCode = elementMap.get(element); monitorMap.put("监测点9", "10");
if (mappedElementCode != null) { monitorMap.put("监测点10", "5");
// 如果在映射关系中,使用对应的英文代码去查询数据库
retValue = tSamplingDataDetailsMapper.getValueByElement(element); // 这里传入的是中文元素名称 monitorInfoList.add(new MonitorRet("监测点1", 104.06, 30.67, "50")); // 成都
monitorInfoList.add(new MonitorRet("监测点2", 104.76, 31.46, "45")); // 绵阳
monitorInfoList.add(new MonitorRet("监测点3", 105.06, 30.87, "40")); // 德阳
monitorInfoList.add(new MonitorRet("监测点4", 105.36, 30.57, "35")); // 广元
monitorInfoList.add(new MonitorRet("监测点5", 106.06, 29.37, "30")); // 遂宁
monitorInfoList.add(new MonitorRet("监测点6", 106.76, 29.07, "25")); // 内江
monitorInfoList.add(new MonitorRet("监测点7", 107.06, 28.77, "20")); // 乐山
monitorInfoList.add(new MonitorRet("监测点8", 107.36, 28.47, "15")); // 眉山
monitorInfoList.add(new MonitorRet("监测点9", 107.66, 28.17, "10")); // 宜宾
monitorInfoList.add(new MonitorRet("监测点10", 107.96, 27.87, "5")); // 泸州
// 使用Collections.sort和自定义的Comparator进行排序
Collections.sort(monitorInfoList, new Comparator<MonitorRet>() {
@Override
public int compare(MonitorRet o1, MonitorRet o2) {
// 提取值并转换为整数
int value1 = Integer.parseInt(o1.getMonitorValue());
int value2 = Integer.parseInt(o2.getMonitorValue());
// 降序排序
return Integer.compare(value2, value1);
}
});
} catch (Exception e) {
e.printStackTrace();
return null;
}
return monitorInfoList;
} }
if (retValue != null && !retValue.isEmpty()) {
return retValue; @Override
public List<String> getCurrentTime () {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 定义时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化当前时间为字符串
String formattedTime = now.format(formatter);
// 返回包含当前时间字符串的列表
return Arrays.asList(formattedTime);
} }
} catch (ParamsException e) {
throw new RuntimeException("Failed to get element info", e);
}
return null;
}
@Override @Override
public List<MonitorRet> getMonitorInfo() { public List<BaseMapVoRet> getBaseMapList () {
List<MonitorRet> monitorInfoList = new ArrayList<>(); List<BaseMapVoRet> baseMapVoRetList = new ArrayList<>();
try { //配置文件中定义的
Map<String, String> monitorMap = new HashMap<>(); List<BaseMapVoRet> basemapConfigList = layerDispConfig.getBasemap();
monitorMap.put("监测点1", "50"); if (!CollectionUtils.isEmpty(basemapConfigList)) {
monitorMap.put("监测点2", "45"); baseMapVoRetList.addAll(basemapConfigList);
monitorMap.put("监测点3", "40");
monitorMap.put("监测点4", "35");
monitorMap.put("监测点5", "30");
monitorMap.put("监测点6", "25");
monitorMap.put("监测点7", "20");
monitorMap.put("监测点8", "15");
monitorMap.put("监测点9", "10");
monitorMap.put("监测点10", "5");
monitorInfoList.add(new MonitorRet("监测点1", 104.06, 30.67,"50")); // 成都
monitorInfoList.add(new MonitorRet("监测点2", 104.76, 31.46,"45")); // 绵阳
monitorInfoList.add(new MonitorRet("监测点3", 105.06, 30.87,"40")); // 德阳
monitorInfoList.add(new MonitorRet("监测点4", 105.36, 30.57,"35")); // 广元
monitorInfoList.add(new MonitorRet("监测点5", 106.06, 29.37,"30")); // 遂宁
monitorInfoList.add(new MonitorRet("监测点6", 106.76, 29.07,"25")); // 内江
monitorInfoList.add(new MonitorRet("监测点7", 107.06, 28.77,"20")); // 乐山
monitorInfoList.add(new MonitorRet("监测点8", 107.36, 28.47,"15")); // 眉山
monitorInfoList.add(new MonitorRet("监测点9", 107.66, 28.17,"10")); // 宜宾
monitorInfoList.add(new MonitorRet("监测点10", 107.96, 27.87,"5")); // 泸州
// 使用Collections.sort和自定义的Comparator进行排序
Collections.sort(monitorInfoList, new Comparator<MonitorRet>() {
@Override
public int compare(MonitorRet o1, MonitorRet o2) {
// 提取值并转换为整数
int value1 = Integer.parseInt(o1.getMonitorValue());
int value2 = Integer.parseInt(o2.getMonitorValue());
// 降序排序
return Integer.compare(value2, value1);
} }
});
} catch (Exception e) {
e.printStackTrace();
return null;
}
return monitorInfoList;
}
@Override
public List<String> getCurrentTime() {
// 获取当前时间
LocalDateTime now = LocalDateTime.now();
// 定义时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 格式化当前时间为字符串
String formattedTime = now.format(formatter);
// 返回包含当前时间字符串的列表
return Arrays.asList(formattedTime);
}
@Override List<TGeoserverinfo> geoBasedatageoserverinfos = tGeoserverinfoMapper.selectList(null);
public List<BaseMapVoRet> getBaseMapList() { if (!CollectionUtils.isEmpty(geoBasedatageoserverinfos)) {
List<BaseMapVoRet> baseMapVoRetList = new ArrayList<>(); for (int i = 0; i < geoBasedatageoserverinfos.size(); i++) {
//配置文件中定义的 TGeoserverinfo geoBasedatageoserverinfo = geoBasedatageoserverinfos.get(i);
List<BaseMapVoRet> basemapConfigList = layerDispConfig.getBasemap(); BaseMapVoRet baseMapVoRet = new BaseMapVoRet();
if (!CollectionUtils.isEmpty(basemapConfigList)) { baseMapVoRet.setName(geoBasedatageoserverinfo.getGeoserverlayers());
baseMapVoRetList.addAll(basemapConfigList); //http://121.37.165.19:8082/geoserver/cztl/wms?service=WMS&version=1.1.0&request=GetMap&layers=cztl:SAT_RTD_JS_00_CPC_20230405_202304250000&bbox=494883.5,3398883.5,496536.5,3400386.5&width=768&height=698&srs=EPSG:32647&styles=cztl:style_cpc&format=application/openlayers
} //取3857坐标系地址
String url = getURL(geoBasedatageoserverinfo);
List<TGeoserverinfo> geoBasedatageoserverinfos = tGeoserverinfoMapper.selectList(null); baseMapVoRet.setUrl(url);
if (!CollectionUtils.isEmpty(geoBasedatageoserverinfos)) { baseMapVoRet.setDefaultonoff("off");
for (int i = 0; i < geoBasedatageoserverinfos.size(); i++) { baseMapVoRetList.add(baseMapVoRet);
TGeoserverinfo geoBasedatageoserverinfo = geoBasedatageoserverinfos.get(i); }
BaseMapVoRet baseMapVoRet = new BaseMapVoRet();
baseMapVoRet.setName(geoBasedatageoserverinfo.getGeoserverlayers());
//http://121.37.165.19:8082/geoserver/cztl/wms?service=WMS&version=1.1.0&request=GetMap&layers=cztl:SAT_RTD_JS_00_CPC_20230405_202304250000&bbox=494883.5,3398883.5,496536.5,3400386.5&width=768&height=698&srs=EPSG:32647&styles=cztl:style_cpc&format=application/openlayers
//取3857坐标系地址
String url = getURL(geoBasedatageoserverinfo);
baseMapVoRet.setUrl(url);
baseMapVoRet.setDefaultonoff("off");
baseMapVoRetList.add(baseMapVoRet);
} }
return baseMapVoRetList;
} }
return baseMapVoRetList;
}
@Override @Override
public List<ElementValueRet> getElementStatus(String element) { public List<ElementValueRet> getElementStatus (String element){
Map<String, String> elementMap = new HashMap<String, String>() {{ Map<String, String> elementMap = new HashMap<String, String>() {{
put("总辐射辐照度", "V14311"); put("总辐射辐照度", "V14311");
put("净辐射辐照度", "V14312"); put("净辐射辐照度", "V14312");
put("直接辐射辐照度", "V14313"); put("直接辐射辐照度", "V14313");
put("散射辐射辐照度", "V14314"); put("散射辐射辐照度", "V14314");
put("反射辐射辐照度", "V14315"); put("反射辐射辐照度", "V14315");
}}; }};
try { try {
List<ElementValueRet> retValue = new ArrayList<>(); List<ElementValueRet> retValue = new ArrayList<>();
// 检查传入的中文element是否在映射关系中 // 检查传入的中文element是否在映射关系中
String mappedElementCode = elementMap.get(element); String mappedElementCode = elementMap.get(element);
if (mappedElementCode == null) { if (mappedElementCode == null) {
// 如果映射关系中没有对应的代码,返回空列表或者抛出异常 // 如果映射关系中没有对应的代码,返回空列表或者抛出异常
return retValue; // 或者抛出一个自定义异常 return retValue; // 或者抛出一个自定义异常
} }
// 如果在映射关系中,使用对应的英文代码去查询数据库 // 如果在映射关系中,使用对应的英文代码去查询数据库
List<ElementValueRet> dbValues = tSamplingDataDetailsMapper.getElementStatus(mappedElementCode); List<ElementValueRet> dbValues = tSamplingDataDetailsMapper.getElementStatus(mappedElementCode);
if (dbValues != null) { if (dbValues != null) {
for (ElementValueRet value : dbValues) { for (ElementValueRet value : dbValues) {
if (value != null) { if (value != null) {
// 设置status为"正常" // 设置status为"正常"
value.setStatus("正常"); value.setStatus("正常");
retValue.add(value); retValue.add(value);
}
}
} }
return retValue;
} catch (ParamsException e) {
throw new RuntimeException("Failed to get element info", e);
} }
} }
return retValue;
} catch (ParamsException e) {
throw new RuntimeException("Failed to get element info", e);
}
}
@Override @Override
public PageVo<SiteListVoRet> getSiteListInfo(SiteListVoReq siteListVoReq) { public PageVo<SiteListVoRet> getSiteListInfo (SiteListVoReq siteListVoReq){
Page<SiteListVoRet> page = new Page<>(siteListVoReq.getCurrent(), siteListVoReq.getSize()); Page<SiteListVoRet> page = new Page<>(siteListVoReq.getCurrent(), siteListVoReq.getSize());
if (siteListVoReq.getDataType().equals("总辐射辐照度")) { if (siteListVoReq.getDataType().equals("总辐射辐照度")) {
page = radichnmulhorMapper.getSiteListInfo1(page, siteListVoReq.getDataType()); page = radichnmulhorMapper.getSiteListInfo1(page, siteListVoReq.getDataType());
} }
if (siteListVoReq.getDataType().equals("净辐射辐照度")) { if (siteListVoReq.getDataType().equals("净辐射辐照度")) {
page = radichnmulhorMapper.getSiteListInfo2(page, siteListVoReq.getDataType()); page = radichnmulhorMapper.getSiteListInfo2(page, siteListVoReq.getDataType());
} }
if (siteListVoReq.getDataType().equals("直接辐射辐照度")) { if (siteListVoReq.getDataType().equals("直接辐射辐照度")) {
page = radichnmulhorMapper.getSiteListInfo3(page, siteListVoReq.getDataType()); page = radichnmulhorMapper.getSiteListInfo3(page, siteListVoReq.getDataType());
} }
if (siteListVoReq.getDataType().equals("散射辐射辐照度")) { if (siteListVoReq.getDataType().equals("散射辐射辐照度")) {
page = radichnmulhorMapper.getSiteListInfo4(page, siteListVoReq.getDataType()); page = radichnmulhorMapper.getSiteListInfo4(page, siteListVoReq.getDataType());
} }
if (siteListVoReq.getDataType().equals("反射辐射辐照度")) { if (siteListVoReq.getDataType().equals("反射辐射辐照度")) {
page = radichnmulhorMapper.getSiteListInfo5(page, siteListVoReq.getDataType()); page = radichnmulhorMapper.getSiteListInfo5(page, siteListVoReq.getDataType());
} }
//将records数据取出来 //将records数据取出来
return new PageVo<>(page); return new PageVo<>(page);
}
private String getURL(TGeoserverinfo geoBasedatageoserverinfo) {
String url = "";
String geoServerURL = "";
geoServerURL = mygeoServerConfig.getGeoserverapiurl();
String workspaces = "";
if (!StringUtils.isEmpty(geoBasedatageoserverinfo.getGeoserverworkspaces())) {
workspaces = geoBasedatageoserverinfo.getGeoserverworkspaces();
} else {
workspaces = geoBasedatageoserverinfo.getGeoserverworkspaces();
}
String layer = "";
if (!StringUtils.isEmpty(geoBasedatageoserverinfo.getGeoserverlayers())) {
layer = geoBasedatageoserverinfo.getGeoserverlayers();
}
String styles = "";
if (!StringUtils.isEmpty(geoBasedatageoserverinfo.getGeoserverstyles())) {
styles = geoBasedatageoserverinfo.getGeoserverstyles();
} }
String srs = "EPSG:3857";
if (StringUtils.isEmpty(geoServerURL) || StringUtils.isEmpty(layer) || StringUtils.isEmpty(workspaces)) { private String getURL (TGeoserverinfo geoBasedatageoserverinfo){
return null; String url = "";
} String geoServerURL = "";
if (geoServerURL.endsWith("/")) { geoServerURL = mygeoServerConfig.getGeoserverapiurl();
geoServerURL = geoServerURL.substring(0, geoServerURL.length() - 1); String workspaces = "";
} if (!StringUtils.isEmpty(geoBasedatageoserverinfo.getGeoserverworkspaces())) {
url = geoServerURL + "/" + workspaces + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=" + workspaces + ":" + layer + "&width=768&height=698&srs=" + srs; workspaces = geoBasedatageoserverinfo.getGeoserverworkspaces();
if (!StringUtils.isEmpty(styles)) { } else {
url += "&styles=" + workspaces + ":" + styles; workspaces = geoBasedatageoserverinfo.getGeoserverworkspaces();
}
String layer = "";
if (!StringUtils.isEmpty(geoBasedatageoserverinfo.getGeoserverlayers())) {
layer = geoBasedatageoserverinfo.getGeoserverlayers();
}
String styles = "";
if (!StringUtils.isEmpty(geoBasedatageoserverinfo.getGeoserverstyles())) {
styles = geoBasedatageoserverinfo.getGeoserverstyles();
}
String srs = "EPSG:3857";
if (StringUtils.isEmpty(geoServerURL) || StringUtils.isEmpty(layer) || StringUtils.isEmpty(workspaces)) {
return null;
}
if (geoServerURL.endsWith("/")) {
geoServerURL = geoServerURL.substring(0, geoServerURL.length() - 1);
}
url = geoServerURL + "/" + workspaces + "/wms?service=WMS&version=1.1.0&request=GetMap&layers=" + workspaces + ":" + layer + "&width=768&height=698&srs=" + srs;
if (!StringUtils.isEmpty(styles)) {
url += "&styles=" + workspaces + ":" + styles;
}
url += "&FORMAT=image/png&TRANSPARENT=true";
return url;
} }
url += "&FORMAT=image/png&TRANSPARENT=true";
return url;
}
/** /**
* Excel * Excel
* *
* @param coordsExcelFile Excel * @param coordsExcelFile Excel
* @return List<DataManageExcelModel> * @return List<DataManageExcelModel>
*/ */
private List<DataManageExcelModel> readExcelSheets(MultipartFile coordsExcelFile) { private List<DataManageExcelModel> readExcelSheets (MultipartFile coordsExcelFile){
List<DataManageExcelModel> list = new ArrayList<>(); List<DataManageExcelModel> list = new ArrayList<>();
// 坐标数据读入 // 坐标数据读入
try (InputStream fis = coordsExcelFile.getInputStream()) { try (InputStream fis = coordsExcelFile.getInputStream()) {
// 一个文件一个reader // 一个文件一个reader
ExcelReader excelReader = EasyExcel.read(fis).extraRead(CellExtraTypeEnum.MERGE).build(); ExcelReader excelReader = EasyExcel.read(fis).extraRead(CellExtraTypeEnum.MERGE).build();
List<ReadSheet> sheetList = excelReader.excelExecutor().sheetList(); List<ReadSheet> sheetList = excelReader.excelExecutor().sheetList();
log.info("开始读取坐标点Excel数据....."); log.info("开始读取坐标点Excel数据.....");
if (!sheetList.isEmpty()) { if (!sheetList.isEmpty()) {
sheetList.forEach(eachSheet -> { sheetList.forEach(eachSheet -> {
ImportExcelListener<DataManageExcelModel> importExcelListener = new ImportExcelListener<>(2); ImportExcelListener<DataManageExcelModel> importExcelListener = new ImportExcelListener<>(2);
ReadSheet sheet = EasyExcel.readSheet(eachSheet.getSheetNo()) ReadSheet sheet = EasyExcel.readSheet(eachSheet.getSheetNo())
.head(DataManageExcelModel.class) .head(DataManageExcelModel.class)
.registerReadListener(importExcelListener) .registerReadListener(importExcelListener)
.headRowNumber(2) .headRowNumber(2)
.build(); .build();
log.info("开始读取sheet[{}]坐标点Excel数据.....", eachSheet.getSheetName()); log.info("开始读取sheet[{}]坐标点Excel数据.....", eachSheet.getSheetName());
excelReader.read(sheet); excelReader.read(sheet);
List<DataManageExcelModel> data = importExcelListener.getList(); List<DataManageExcelModel> data = importExcelListener.getList();
log.info("*************************************************************************"); log.info("*************************************************************************");
log.info("sheet[{}] 读取到{}行数据...", eachSheet.getSheetName(), data.size()); log.info("sheet[{}] 读取到{}行数据...", eachSheet.getSheetName(), data.size());
log.info(String.valueOf(data)); log.info(String.valueOf(data));
list.addAll(data); list.addAll(data);
}); });
}
excelReader.finish();
log.info("坐标点Excel数据读取完成");
} catch (Exception e) {
e.printStackTrace();
} }
excelReader.finish(); return list;
log.info("坐标点Excel数据读取完成");
} catch (Exception e) {
e.printStackTrace();
} }
return list;
}
public Map readExcel(MultipartFile file) throws IOException { public Map readExcel (MultipartFile file) throws IOException {
Map map = new HashMap<>(); Map map = new HashMap<>();
// public List<DataManageExcelModel> readExcel() throws IOException { // public List<DataManageExcelModel> readExcel() throws IOException {
//读取Excel中的数据 //读取Excel中的数据
// File file = ResourceUtils.getFile("classpath:" + File.separator + "excel" + File.separator + "2014年-2021年一亿棵梭梭项目台账(全).xlsx"); // File file = ResourceUtils.getFile("classpath:" + File.separator + "excel" + File.separator + "2014年-2021年一亿棵梭梭项目台账(全).xlsx");
ExcelReader excelReader1 = EasyExcel.read(file.getInputStream()).extraRead(CellExtraTypeEnum.MERGE).build(); ExcelReader excelReader1 = EasyExcel.read(file.getInputStream()).extraRead(CellExtraTypeEnum.MERGE).build();
List<ReadSheet> sheetList = excelReader1.excelExecutor().sheetList(); List<ReadSheet> sheetList = excelReader1.excelExecutor().sheetList();
List<DataManageExcelModel> list = new ArrayList<>(); List<DataManageExcelModel> list = new ArrayList<>();
LinkedHashSet<DataManageExcelModel> DataManageExcelModels = new LinkedHashSet<>(); LinkedHashSet<DataManageExcelModel> DataManageExcelModels = new LinkedHashSet<>();
List<String> messageList = new ArrayList<String>(); List<String> messageList = new ArrayList<String>();
if (!sheetList.isEmpty()) { if (!sheetList.isEmpty()) {
try { try {
for (ReadSheet eachSheet : sheetList) { for (ReadSheet eachSheet : sheetList) {
log.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++正在解析{}的台账表", eachSheet.getSheetName()); log.info("++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++正在解析{}的台账表", eachSheet.getSheetName());
ImportExcelListener<DataManageExcelModel> importExcelListener = new ImportExcelListener<>(1); ImportExcelListener<DataManageExcelModel> importExcelListener = new ImportExcelListener<>(1);
ReadSheet sheet = EasyExcel.readSheet(eachSheet.getSheetNo()).head(DataManageExcelModel.class).registerReadListener(importExcelListener) ReadSheet sheet = EasyExcel.readSheet(eachSheet.getSheetNo()).head(DataManageExcelModel.class).registerReadListener(importExcelListener)
.headRowNumber(1).build(); .headRowNumber(1).build();
excelReader1.read(sheet); excelReader1.read(sheet);
DataManageExcelModels.addAll(importExcelListener.getList()); DataManageExcelModels.addAll(importExcelListener.getList());
} }
} catch (ExcelAnalysisException e) { } catch (ExcelAnalysisException e) {
StringTokenizer st = new StringTokenizer(e.getMessage(), "|"); StringTokenizer st = new StringTokenizer(e.getMessage(), "|");
while (st.hasMoreElements()) { while (st.hasMoreElements()) {
messageList.add(st.nextElement().toString()); messageList.add(st.nextElement().toString());
}
} }
} }
excelReader1.finish();
list = new ArrayList<>(DataManageExcelModels);
System.out.println(list);
map.put("msg", messageList);
map.put("list", list);
return map;
} }
excelReader1.finish();
list = new ArrayList<>(DataManageExcelModels);
System.out.println(list);
map.put("msg", messageList);
map.put("list", list);
return map;
}
} }

Loading…
Cancel
Save