package com.landtool.lanbase.modules.api.controller.MapPortal; import java.io.File; import java.io.IOException; import java.sql.Timestamp; import java.util.Date; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import javax.servlet.http.HttpServletRequest; import com.alibaba.fastjson.JSONObject; import com.google.gson.JsonObject; import com.landtool.lanbase.common.utils.HttpUtils; import com.qiniu.util.Json; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.ResponseBody; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.serializer.SerializerFeature; import com.landtool.lanbase.common.map.EsbToken; import com.landtool.lanbase.common.utils.HttpOperateUtils; import com.landtool.lanbase.config.SysTemPropertyConfig; import com.landtool.lanbase.modules.org.entity.OrgUser; import com.landtool.lanbase.modules.org.service.OrgUserService; import com.landtool.lanbase.modules.res.entity.Res_BookMarks; import com.landtool.lanbase.modules.res.entity.Res_BusinessRef; import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo; import com.landtool.lanbase.modules.res.entity.Res_ExtBaseMap; import com.landtool.lanbase.modules.res.entity.Res_ExtBusinessLayer; import com.landtool.lanbase.modules.res.entity.Res_ExtFileSource; import com.landtool.lanbase.modules.res.entity.Res_ExtIntegrate; import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl; import com.landtool.lanbase.modules.res.entity.Res_ExtSpaceServer; import com.landtool.lanbase.modules.res.entity.Res_ExtThemeMap; import com.landtool.lanbase.modules.res.entity.Res_MainInfo; import com.landtool.lanbase.modules.res.entity.Res_QueryAround; import com.landtool.lanbase.modules.res.entity.Res_SpacesParam; import com.landtool.lanbase.modules.res.entity.Res_SymbolLibrary; import com.landtool.lanbase.modules.res.entity.Res_User_LayerExtent; import com.landtool.lanbase.modules.res.entity.UserDefined.UserDef_BaseMap; import com.landtool.lanbase.modules.res.entity.UserDefined.UserDef_SpaceServer; import com.landtool.lanbase.modules.res.entity.ViewModels.LayerObject; import com.landtool.lanbase.modules.res.service.ResBookMarksService; import com.landtool.lanbase.modules.res.service.ResBusinessRefService; import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService; import com.landtool.lanbase.modules.res.service.ResExtBaseMapService; import com.landtool.lanbase.modules.res.service.ResExtBusinessLayerService; import com.landtool.lanbase.modules.res.service.ResExtFileSourceService; import com.landtool.lanbase.modules.res.service.ResExtIntegrateService; import com.landtool.lanbase.modules.res.service.ResExtMapUrlService; import com.landtool.lanbase.modules.res.service.ResExtSpaceServerService; import com.landtool.lanbase.modules.res.service.ResExtThemeMapService; import com.landtool.lanbase.modules.res.service.ResMainInfoService; import com.landtool.lanbase.modules.res.service.ResQueryAroundService; import com.landtool.lanbase.modules.res.service.ResSpacesParamService; import com.landtool.lanbase.modules.res.service.ResSymbolLibraryService; import com.landtool.lanbase.modules.res.service.ResUserLayerExtentService; import com.landtool.lanbase.modules.res.service.ZhuanTiZhiTuService; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiParam; /** * @author 刘小波 * @Description: 前端地图展示通用接口,获取底图、获取资源协议或自定义风格信息 * @date 2018-05-26 */ @Controller @RequestMapping("/api/mapcommon/") @Api(value = "", tags = {"前端地图展示通用接口"}) public class MapCommonController { @Autowired private ResExtBaseMapService resExtBaseMapService; @Autowired private ResExtMapUrlService resExtMapUrlService; @Autowired private ZhuanTiZhiTuService zhuanTiZhiTuService; @Autowired private OrgUserService orgUserService; @Autowired private SysTemPropertyConfig sysConfig; @Autowired private ResDiyLayerInfoService resDiyLayerInfoService; @Autowired private ResBusinessRefService resBusinessRefService; @Autowired private ResQueryAroundService resQueryAroundService; @Autowired private ResExtThemeMapService resExtThemeMapService; @Autowired private ResExtIntegrateService resExtIntegrateService; @Autowired private ResBookMarksService resBookMarksService; @Autowired private ResExtBusinessLayerService resExtBusinessLayerService; @Autowired private ResMainInfoService resMainInfoService; @Autowired private ResSymbolLibraryService resSymbolLibraryService; @Autowired private ResExtFileSourceService resExtFileSourceService; @Autowired private ResExtSpaceServerService resExtSpaceServerService; @Autowired private ResSpacesParamService resSpacesParamService; @Autowired private ResUserLayerExtentService resUserLayerExtentService; /** * 专题制图 - 底图切换 -- 获取基础底图列表 */ @ResponseBody @GetMapping("/basemaplist") @ApiOperation(value = "查询已审核的基础底图信息列表", notes = "") public List> getBaseMapList(Long userid, String type, Boolean supportDynamic, HttpServletRequest request) { List list = zhuanTiZhiTuService.getBaseMapList(type, supportDynamic); StringBuilder str = new StringBuilder(); str.append("["); List> maps = new LinkedList<>(); for (int i = 0; i < list.size(); i++) { //查询是否是专题地图,是专题地图则获取相关子图层ID String subzyids = ""; boolean isPubzy = false; if (list.get(i).getSharprotocol().equals("完全公开")) { isPubzy = true; } Map map = new HashMap<>(); map.put("resourceId", list.get(i).getResourceid()); map.put("title", list.get(i).getTitle()); map.put("imgurl", list.get(i).getImgurl()); map.put("serverUrl", EsbToken.getEsbUrl(list.get(i).getServerurl(), userid.intValue(), request.getRemoteAddr(), list.get(i).getResourceid(), list.get(i).getEspproxy(), sysConfig, subzyids, isPubzy, list.get(i).getToken(), false)); if (list.get(i).getRefmarkinfid() != null) { //判断关联标注图资源ID是否为空 Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(list.get(i).getRefmarkinfid()); if (resExtBaseMap != null) { Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(list.get(i).getRefmarkinfid()); Map refmap = new HashMap<>(); refmap.put("resourceId", resExtBaseMap.getResourceid()); refmap.put("title", resMainInfo.getTitle()); refmap.put("publishsoft", resExtBaseMap.getPublishsoft()); Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getResourceid());// 获取资源支持协议与地址 if (resExtMapUrl != null) { refmap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), userid.intValue(), request.getRemoteAddr(), resExtBaseMap.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, list.get(i).getToken(), false)); } else { refmap.put("serverUrl", null); } map.put("AnnoLayer", refmap); } else { map.put("AnnoLayer", null); } } else { map.put("AnnoLayer", null); } maps.add(map); } str.append("]"); return maps; } /** * 地图对比 -- 获取基础底图列表 */ @ResponseBody @GetMapping("/incisionMap/basemaplist") @ApiOperation(value = "获取地图对比基础底图列表", notes = "") public String getIncisionMapBaseList(Long userid, HttpServletRequest request) { String[] typeList = new String[]{"矢量", "低精", "高精", "其它"}; StringBuilder sb = new StringBuilder(); List> maps = new LinkedList<>(); for (int i = 0; i < typeList.length; i++) { List list = zhuanTiZhiTuService.getBaseMapList(typeList[i], false); Map map = new HashMap<>(); map.put("name", typeList[i]); map.put("nocheck", true); if (i > 0) sb.append(","); sb.append("{name: '" + typeList[i] + "', nocheck: true,children:["); List> child = new LinkedList<>(); for (int j = 0; j < list.size(); j++) { Map newmap = new HashMap<>(); newmap.put("name", list.get(j).getTitle()); newmap.put("id", list.get(j).getResourceid()); newmap.put("checked", false); child.add(newmap); } map.put("children", child); maps.add(map); } return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue); } /** * @Description: 获取资源服务地址信息 * @Author: xiaoxuan.xie * @Date: 09:30 2018/3/31 * @return: String * @see Res_MainInfo */ @ResponseBody @GetMapping(path = {"layerinfo/{resourceid}/{userid}", "layerinfo/{resourceid}/{userid}/{diyid}"}) @ApiOperation(value = "获取资源服务地址信息", notes = "") public String GetLayerObject(@ApiParam(name = "resourceid", value = "资源Id", required = true) @PathVariable(name = "resourceid") int resourceid, @ApiParam(name = "userid", value = "用户Id", required = true) @PathVariable(name = "userid") Integer userid, @ApiParam(name = "diyid", value = "自定义风格Id") @PathVariable(name = "diyid", required = false) Integer diyid, HttpServletRequest request) throws Exception { Map maps = new HashMap<>(); String Json = ""; OrgUser orgUser = orgUserService.queryObject(Long.parseLong(userid.toString())); if (resourceid > 0) { Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源主表信息 if (resMainInfo != null) { String resourceType = resMainInfo.getResourceclass();// 获取资源类型 if (resourceType == null) resourceType = ""; LayerObject layer = null; switch (resourceType) { case "KJ_YWTC": case "KJ_JCDT": String username = request.getRemoteUser(); Boolean GuanLian = false;//业务关联 Boolean ZhouBian = false;//周边查询 if (resourceType.equals("KJ_YWTC")) { Res_BusinessRef res_businessRef = new Res_BusinessRef(); res_businessRef.setResourceid(resourceid); List resBusinessRefList = resBusinessRefService.selectResBusinesssRef(res_businessRef);//获取业务图层关联分析信息 if (resBusinessRefList.size() > 0) GuanLian = true; List resQueryAroundList = resQueryAroundService.getZhouBianList(resourceid);//获取资源周边查询列表 if (resQueryAroundList.size() > 0) ZhouBian = true; } // 获取用户定义JSON Res_DiyLayerInfo resDiyLayerInfo; if (diyid != null && diyid > 0) { resDiyLayerInfo = resDiyLayerInfoService.getById(diyid);//获取自定义风格信息 } else { resDiyLayerInfo = resDiyLayerInfoService.queryUserObject(userid, resourceid, null); } if (resDiyLayerInfo != null) { maps.put("diyId", resDiyLayerInfo.getDiyid()); maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); maps.put("content", JSON.parseObject(resDiyLayerInfo.getContent())); maps.put("resourceclass", resourceType); maps.put("GuanLian", GuanLian); maps.put("ZhouBian", ZhouBian); } else { // 获取管理员定义JSON resDiyLayerInfo = resDiyLayerInfoService.queryUserObject(userid, resourceid, 1); if (resDiyLayerInfo != null) { maps.put("diyId", resDiyLayerInfo.getDiyid()); maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); maps.put("content", JSON.parseObject(resDiyLayerInfo.getContent())); maps.put("resourceclass", resourceType); maps.put("GuanLian", GuanLian); maps.put("ZhouBian", ZhouBian); } else { // 获取资源支持协议与地址 Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resourceid); //查询是否是专题地图,是专题地图则获取相关子图层ID //Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid); String subzyids = ""; boolean isPubzy = false; Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid); if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) { isPubzy = true; } if (resExtMapUrl != null) { maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); maps.put("typeandurl", resExtMapUrl.getTypeandurl()); maps.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false)); maps.put("resourceclass", resourceType); maps.put("GuanLian", GuanLian); maps.put("ZhouBian", ZhouBian); } else { maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); maps.put("typeandurl", ""); maps.put("serverUrl", ""); maps.put("resourceclass", resourceType); maps.put("GuanLian", GuanLian); maps.put("ZhouBian", ZhouBian); } } } if (resourceType.equals("KJ_JCDT")) { Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resourceid);//获取基础底图拓展信息 if (resExtBaseMap.getRefmarkinfid() != null) { Res_MainInfo AnnoMainInfo = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid()); Res_ExtBaseMap AnnoLayer = resExtBaseMapService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid()); if (AnnoLayer != null) { Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid); String subzyids = ""; if (resExtThemeMap != null) { subzyids = resExtThemeMap.getSublayerset(); } boolean isPubzy = false; Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid); if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) { isPubzy = true; } Map AnnoLayerMap = new HashMap<>(); AnnoLayerMap.put("resourceId", AnnoLayer.getResourceid()); AnnoLayerMap.put("title", AnnoMainInfo.getTitle()); AnnoLayerMap.put("publishsoft", AnnoLayer.getPublishsoft()); Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(AnnoLayer.getResourceid());// 获取资源支持协议与地址 if (resExtMapUrl != null) { AnnoLayerMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), AnnoLayer.getResourceid(), AnnoMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, AnnoMainInfo.getToken(), false)); } else { AnnoLayerMap.put("serverUrl", null); } maps.put("AnnoLayer", AnnoLayerMap); } else { maps.put("AnnoLayer", null); } } else { maps.put("AnnoLayer", null); } } else { Integer IsExistServiceConfig = 0; Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(resourceid); if (resExtBusinessLayer != null && resExtBusinessLayer.getServiceConfig() != null && !resExtBusinessLayer.getServiceConfig().equals("")) { IsExistServiceConfig = 1; } maps.put("IsExistServiceConfig", IsExistServiceConfig); } break; case "KJ_ZTDT"://专题地图 Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);// 获取专题地图拓展信息 if (resExtThemeMap != null) { Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resourceid);// 获取资源支持协议与地址 String typeandurl = null; String serverurl = null; if (resExtMapUrl != null) { typeandurl = resExtMapUrl.getTypeandurl(); serverurl = resExtMapUrl.getServerurl(); } maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("mapjson", resExtThemeMap.getType() != null && resExtThemeMap.getType().equals("系统制作") ? JSON.parseObject(resExtThemeMap.getMapjson()) : null); maps.put("resourceclass", "KJ_ZTDT"); maps.put("childclass", resExtThemeMap.getType()); maps.put("publishsoft", resExtThemeMap.getPublishsoft()); maps.put("typeandurl", typeandurl); maps.put("desurl", resMainInfo.getDesurl()); maps.put("legendUrl", resExtThemeMap.getLegendurl()); maps.put("serverUrl", EsbToken.getEsbUrl(serverurl, orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, resExtThemeMap.getSublayerset(), resMainInfo != null && resMainInfo.getSharprotocol().equals("完全公开"), resMainInfo.getToken(), false)); if (resExtThemeMap.getType().equals("ArcMap") && resExtThemeMap.getDefaultlayerset() != null) { Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resExtThemeMap.getDefaultlayerset());//获取关联底图信息 Res_ExtThemeMap resExtThemeMap1 = resExtThemeMapService.selectByPrimaryKey(resourceid); String subzyids = ""; if (resExtThemeMap1 != null) { subzyids = resExtThemeMap1.getSublayerset(); } boolean isPubzy = false; Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid); if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) { isPubzy = true; } if (resExtBaseMap != null) { Map BaseMapLayerObjectMap = new HashMap<>(); Res_ExtMapUrl resExtMapUrl2 = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getResourceid());// 获取资源支持协议与地址 if (resExtMapUrl2 != null) { BaseMapLayerObjectMap.put("typeandurl", resExtMapUrl2.getTypeandurl()); BaseMapLayerObjectMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl2.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resExtBaseMap.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false)); } else { BaseMapLayerObjectMap.put("typeandurl", ""); BaseMapLayerObjectMap.put("serverUrl", ""); } Res_MainInfo baseMap = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getResourceid()); BaseMapLayerObjectMap.put("label", baseMap.getTitle());//底图名称 BaseMapLayerObjectMap.put("basemaptype", resExtBaseMap.getBasemaptype());//底图类型 BaseMapLayerObjectMap.put("displaylev", resExtBaseMap.getDisplaylev());//切片级别 //关联标注图 if (resExtBaseMap.getRefmarkinfid() != null) { Res_ExtBaseMap biaozhu = resExtBaseMapService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());//获取关联底图标注图信息 if (biaozhu != null) { Map AnnoLayerMap = new HashMap<>(); Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid()); AnnoLayerMap.put("resourceId", res_mainInfo.getResourceid());//标注图ID AnnoLayerMap.put("label", res_mainInfo.getTitle());//标注图标题 Res_ExtMapUrl resExtMapUrl1 = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getRefmarkinfid());// 获取资源支持协议与地址 if (resExtMapUrl1 != null) { AnnoLayerMap.put("typeandurl", resExtMapUrl1.getTypeandurl());//协议服务类型--BaseMapType AnnoLayerMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl1.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), biaozhu.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//协议服务地址--layerUrl } else { AnnoLayerMap.put("typeandurl", "");//协议服务类型--BaseMapType AnnoLayerMap.put("serverUrl", "");//协议服务地址--layerUrl } AnnoLayerMap.put("basemaptype", biaozhu.getBasemaptype());//底图类型--layerType AnnoLayerMap.put("displaylev", biaozhu.getDisplaylev());//切片级别--displayLevels BaseMapLayerObjectMap.put("AnnoLayer", AnnoLayerMap); } else { BaseMapLayerObjectMap.put("AnnoLayer", null); } } maps.put("BaseMapLayerObject", BaseMapLayerObjectMap); } else { maps.put("BaseMapLayerObject", null); } } else { maps.put("BaseMapLayerObject", null); } } else { maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("mapjson", null); maps.put("resourceclass", "KJ_ZTDT"); maps.put("childclass", null); maps.put("publishsoft", null); maps.put("typeandurl", null); maps.put("desurl", resMainInfo.getDesurl()); maps.put("legendUrl", null); maps.put("serverUrl", null); } break; case "YWJC": Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resourceid);//获取业务集成拓展信息 maps.put("resourceId", resourceid);//业务集成服务地址 if (resMainInfo != null) { maps.put("title", resMainInfo.getTitle());//业务集成资源名称 maps.put("desurl", resMainInfo.getDesurl()); } else { maps.put("title", "");//业务集成资源名称 maps.put("desurl", null); } if (resExtIntegrate != null) { maps.put("serverUrl", resExtIntegrate.getServerurl());//业务集成服务地址 //获取统计图表配置 try { if (resExtIntegrate.getIntegratetype().equals("数据集成") && resExtIntegrate.getServerurl() != null && !resExtIntegrate.getServerurl().isEmpty()) { maps.put("jieShouContent", HttpOperateUtils.httpGet(resExtIntegrate.getServerurl())); } else { maps.put("jieShouContent", null); } } catch (IOException e) { maps.put("jieShouContent", null); } maps.put("reflayerfield", resExtIntegrate.getReflayerfield());//业务图层关联字段 maps.put("integratetype", resExtIntegrate.getIntegratetype());//业务集成集成类型 maps.put("showmodel", resExtIntegrate.getShowmodel());//业务集成页面展示方式 maps.put("rendermode", resExtIntegrate.getRendermode());//业务集成渲染方式 maps.put("refbasemapid", resExtIntegrate.getRefbasemapid());//关联底图资源ID if (resExtIntegrate.getRefbasemapid() != null) { Res_ExtBaseMap resExtBaseMap = resExtBaseMapService.selectByPrimaryKey(resExtIntegrate.getRefbasemapid());//获取关联底图信息 if (resExtBaseMap != null) { Map BaseMapLayerObjectMap = new HashMap<>(); Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getResourceid());// 获取资源支持协议与地址 Res_ExtThemeMap resExtThemeMap1 = resExtThemeMapService.selectByPrimaryKey(resourceid); String subzyids = ""; if (resExtThemeMap1 != null) { subzyids = resExtThemeMap1.getSublayerset(); } boolean isPubzy = false; Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid); if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) { isPubzy = true; } if (resExtMapUrl != null) { BaseMapLayerObjectMap.put("typeandurl", resExtMapUrl.getTypeandurl());//协议服务类型 BaseMapLayerObjectMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resExtBaseMap.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//协议服务地址 } else { BaseMapLayerObjectMap.put("typeandurl", "");//协议服务类型 BaseMapLayerObjectMap.put("serverUrl", "");//协议服务地址 } Res_MainInfo baseMap = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getResourceid()); BaseMapLayerObjectMap.put("label", baseMap.getTitle());//底图名称 BaseMapLayerObjectMap.put("basemaptype", resExtBaseMap.getBasemaptype());//底图类型 BaseMapLayerObjectMap.put("displaylev", resExtBaseMap.getDisplaylev());//切片级别 //关联标注图 if (resExtBaseMap.getRefmarkinfid() != null) { Res_ExtBaseMap biaozhu = resExtBaseMapService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid());//获取关联底图标注图信息 if (biaozhu != null) { Map AnnoLayerMap = new HashMap<>(); Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resExtBaseMap.getRefmarkinfid()); AnnoLayerMap.put("resourceId", res_mainInfo.getResourceid());//标注图ID AnnoLayerMap.put("label", res_mainInfo.getTitle());//标注图标题 Res_ExtMapUrl resExtMapUrl1 = resExtMapUrlService.queryFirstOrderByResId(resExtBaseMap.getRefmarkinfid());// 获取资源支持协议与地址 if (resExtMapUrl1 != null) { AnnoLayerMap.put("typeandurl", resExtMapUrl1.getTypeandurl());//协议服务类型--BaseMapType AnnoLayerMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl1.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), biaozhu.getResourceid(), resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//协议服务地址--layerUrl } else { AnnoLayerMap.put("typeandurl", "");//协议服务类型--BaseMapType AnnoLayerMap.put("serverUrl", "");//协议服务地址--layerUrl } AnnoLayerMap.put("basemaptype", biaozhu.getBasemaptype());//底图类型--layerType AnnoLayerMap.put("displaylev", biaozhu.getDisplaylev());//切片级别--displayLevels BaseMapLayerObjectMap.put("AnnoLayer", AnnoLayerMap); } else { BaseMapLayerObjectMap.put("AnnoLayer", null); } } maps.put("BaseMapLayerObject", BaseMapLayerObjectMap); } else { maps.put("BaseMapLayerObject", null); } } else { maps.put("BaseMapLayerObject", null); } if (resExtIntegrate.getReflayerid() != null) { Res_ExtBusinessLayer resExtBusinessLayer = resExtBusinessLayerService.selectByPrimaryKey(resExtIntegrate.getReflayerid());//获取关联业务图层信息 if (resExtBusinessLayer != null) { Res_MainInfo res_mainInfo = resMainInfoService.selectByPrimaryKey(resExtBusinessLayer.getResourceid()); Map YwtcLayerObjectMap = new HashMap<>(); YwtcLayerObjectMap.put("resourceId", res_mainInfo.getResourceid());//关联业务图层资源ID YwtcLayerObjectMap.put("label", res_mainInfo.getTitle());//关联业务图层标题 YwtcLayerObjectMap.put("dataloadtype", resExtBusinessLayer.getDataloadtype());//加载方式 YwtcLayerObjectMap.put("resourceclass", res_mainInfo.getResourceclass());//资源类型 Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.queryFirstOrderByResId(resExtBusinessLayer.getResourceid());// 获取资源支持协议与地址 Res_ExtThemeMap resExtThemeMap1 = resExtThemeMapService.selectByPrimaryKey(resourceid); String subzyids = ""; if (resExtThemeMap1 != null) { subzyids = resExtThemeMap1.getSublayerset(); } boolean isPubzy = false; Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid); if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) { isPubzy = true; } if (resExtMapUrl != null) { YwtcLayerObjectMap.put("typeandurl", resExtMapUrl.getTypeandurl());//底图类型 YwtcLayerObjectMap.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false));//服务地址 } else { YwtcLayerObjectMap.put("typeandurl", "");//底图类型 YwtcLayerObjectMap.put("serverUrl", "");//服务地址 } YwtcLayerObjectMap.put("layerName", resExtBusinessLayer.getLayername());//原图层名称 maps.put("YwtcLayerObject", YwtcLayerObjectMap); } else { maps.put("YwtcLayerObject", null); } } else { maps.put("YwtcLayerObject", null); } } else { maps.put("serverUrl", null);//业务集成服务地址 maps.put("jieShouContent", null); maps.put("reflayerfield", null);//业务图层关联字段 maps.put("integratetype", null);//业务集成集成类型 maps.put("showmodel", null);//业务集成页面展示方式 maps.put("rendermode", null);//业务集成渲染方式 maps.put("refbasemapid", null);//关联底图资源ID maps.put("BaseMapLayerObject", null); maps.put("YwtcLayerObject", null); } maps.put("resourceclass", "YWJC"); break; case "SJWJ": Res_ExtFileSource model = resExtFileSourceService.selectByPrimaryKey(resourceid); maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("resourceclass", "SJWJ"); if (model != null) { maps.put("flag", "nc"); if (model.getSourcetype().equals("文件")) { maps.put("serverUrl", model.getServerurl() != null ? (model.getServerurl().substring(0, model.getServerurl().indexOf("."))) : ""); String[] filename = {model.getFilename() != null ? model.getFilename().substring(0, model.getFilename().indexOf(".")) : ""}; maps.put("filename", filename); } else { maps.put("serverUrl", model.getServerurl() != null ? model.getServerurl() : ""); File file = new File(sysConfig.getUploadPath() + model.getServerurl()); String[] fileLists = file.list(); if (fileLists != null) { String[] filename = new String[fileLists.length]; for (int i = 0; i < fileLists.length; i++) { File file1 = new File(fileLists[i]); filename[i] = file1.getName().substring(0, file1.getName().indexOf(".")); } maps.put("filename", filename); } else { maps.put("filename", null); } } maps.put("ncconfig", model.getNcconfig() != null ? model.getNcconfig() : ""); maps.put("ncjsonpath", model.getNcjsonpath() != null ? model.getNcjsonpath() : ""); maps.put("ncjsonattribute", model.getNcjsonattribute() != null ? model.getNcjsonattribute() : ""); } break; case "KJ_KJFX": maps.put("resourceId", resourceid); if (resMainInfo != null) { maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); } else { maps.put("title", "");//业务集成资源名称 maps.put("desurl", null); } maps.put("resourceclass", "KJ_KJFX"); Res_ExtSpaceServer spaceServer = resExtSpaceServerService.selectByPrimaryKey(resourceid); if (spaceServer != null) { maps.put("serverUrl", spaceServer.getServerurl()); maps.put("postType", spaceServer.getPosttype()); maps.put("diyParamUrl", spaceServer.getDiyparamurl()); } //Json += ",spaceParams: ["; List> spaceParamsMaps = new LinkedList<>(); List resSpacesParams = resSpacesParamService.selectByResSourceId(resourceid); if (resSpacesParams != null && resSpacesParams.size() > 0) { for (int i = 0; i < resSpacesParams.size(); i++) { Map spaceParamsMap = new HashMap<>(); spaceParamsMap.put("paramId", resSpacesParams.get(i).getParamid()); spaceParamsMap.put("orderIndex", resSpacesParams.get(i).getOrderindex()); spaceParamsMap.put("paramType", resSpacesParams.get(i).getParamtype()); spaceParamsMap.put("paramName", resSpacesParams.get(i).getParamname()); spaceParamsMap.put("dataType", resSpacesParams.get(i).getDatatype()); spaceParamsMap.put("paramAlias", resSpacesParams.get(i).getParamalias()); spaceParamsMap.put("layerStyle", resSpacesParams.get(i).getLayerstyle() == null ? "" : resSpacesParams.get(i).getLayerstyle()); spaceParamsMaps.add(spaceParamsMap); } } break; } String serverUrl =(String) maps.get("serverUrl"); String content =(String) maps.get("content"); String url=null; if(null!=content){ url = JSONObject.parseObject(content).getString("url"); } serverUrl=serverUrl==null?url:serverUrl; if(null!=serverUrl&&serverUrl.contains("104:8066")&& !StringUtils.equals("完全公开",resMainInfo.getSharprotocol())){ String param="resourceid="+resourceid+"&isPubzy=0&"+"appId=0&"+"applyuserid="+userid; String data = HttpUtils.get(sysConfig.getProxyUrl()+"/genToken" + "?" + param); JSONObject jsonObject = JSON.parseObject(data); String token = jsonObject.get("data").toString(); maps.put("serverUrl", serverUrl+"?token="+token); } } } return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue); } /** * @Description: 获取资源服务协议与地址信息 * @Author: xiaoxuan.xie * @Date: 09:30 2018/4/2 * @return: String * @see Res_MainInfo */ @ResponseBody @GetMapping(path = "resurlinfo/{userid}/{resourceid}/{type}/{id}") @ApiOperation(value = "获取资源服务协议与地址信息", notes = "") public String GetMapUrlObject(@ApiParam(name = "userid", value = "用户ID", required = true) @PathVariable(name = "userid") Long userid, @ApiParam(name = "resourceid", value = "资源Id", required = true) @PathVariable(name = "resourceid") Integer resourceid, @ApiParam(name = "type", value = "type", required = true) @PathVariable(name = "type") String type, @ApiParam(name = "id", value = "id", required = true) @PathVariable(name = "id") Integer id, HttpServletRequest request) { String Json = ""; Map maps = new HashMap<>(); Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(resourceid);// 获取资源主表信息 if (type.equals("Url")) { Res_ExtMapUrl resExtMapUrl = resExtMapUrlService.selectByPrimaryKey(id);// 获取资源支持协议与地址 Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid); String subzyids = ""; if (resExtThemeMap != null) { subzyids = resExtThemeMap.getSublayerset(); } boolean isPubzy = false; Res_MainInfo resMainInfo1 = resMainInfoService.selectByPrimaryKey(resourceid); if (resMainInfo1 != null && resMainInfo1.getSharprotocol().equals("完全公开")) { isPubzy = true; } if (resExtMapUrl != null) { OrgUser orgUser = orgUserService.queryObject(userid); maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); maps.put("typeandurl", resExtMapUrl.getTypeandurl()); maps.put("serverUrl", EsbToken.getEsbUrl(resExtMapUrl.getServerurl(), orgUser.getUserid().intValue(), request.getRemoteAddr(), resourceid, resMainInfo.getEspproxy(), sysConfig, subzyids, isPubzy, resMainInfo.getToken(), false)); } else { maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); maps.put("typeandurl", ""); maps.put("serverUrl", ""); } } else { Res_DiyLayerInfo resDiyLayerInfo = resDiyLayerInfoService.getById(id);// 获取自定义风格信息 if (resDiyLayerInfo != null) { maps.put("diyId", resDiyLayerInfo.getDiyid()); maps.put("resourceId", resourceid); maps.put("title", resMainInfo.getTitle()); maps.put("desurl", resMainInfo.getDesurl()); maps.put("content", JSON.parseObject(resDiyLayerInfo.getContent())); } else { maps.put("diyId", id); maps.put("resourceId", resourceid); maps.put("title", ""); maps.put("desurl", resMainInfo.getDesurl()); maps.put("content", null); } } return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue); } /** * 根据用户ID查询书签列表 */ @ResponseBody @GetMapping(path = "getBookmarksList/{userid}") @ApiOperation(value = "根据用户ID查询书签列表", notes = "") public String GetBookmarksList(@ApiParam(name = "userid", value = "用户ID", required = true) @PathVariable(name = "userid") Integer userid) { List resBookMarksList = resBookMarksService.getBookMarksByUserid(userid); StringBuilder sb = new StringBuilder(); List> maps = new LinkedList<>(); for (int i = 0; i < resBookMarksList.size(); i++) { Map map = new HashMap<>(); map.put("OBJECTID", resBookMarksList.get(i).getObjectid()); map.put("name", resBookMarksList.get(i).getTitle()); map.put("extent", JSON.parseObject(resBookMarksList.get(i).getExtent())); maps.add(map); } return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue); } /** * 书签新增、修改 */ @PostMapping(path = "/addBookMark") @ApiOperation(value = "新增、修改地图书签", notes = "") @ResponseBody public int addMap(@ApiParam(name = "objectid", value = "标签ID") Integer objectid, @ApiParam(name = "userid", value = "用户Id", required = true) Integer userid, @ApiParam(name = "title", value = "标签名称", required = true) String title, @ApiParam(name = "extent", value = "标签地图范围", required = true) String extent) { if (objectid == null) objectid = -1; int id = 0; Res_BookMarks resBookMarks = resBookMarksService.getById(objectid); if (resBookMarks != null) { resBookMarks.setTitle(title); resBookMarksService.updateByPrimaryKey(resBookMarks); id = resBookMarks.getObjectid(); } else { resBookMarks = new Res_BookMarks(); resBookMarks.setTitle(title); resBookMarks.setCreateuserid(userid); resBookMarks.setExtent(extent); Timestamp time = new Timestamp(new Date().getTime()); resBookMarks.setAddtime(time); resBookMarksService.insert(resBookMarks); id = resBookMarksService.getCurrentObjectId(); } return id; } /** * 标签删除 */ @ResponseBody @GetMapping(path = "delBookMark") @ApiOperation(value = "删除地图书签", notes = "") public String delBookMark(@ApiParam(name = "objectid", value = "书签ID", required = true) @RequestParam(name = "objectid") Integer objectid) { resBookMarksService.deleteByPrimaryKey(objectid); return "删除成功"; } /** * 获取符号库对应空间类型符号风格列表 * @return */ @ResponseBody @GetMapping(path = "symbolLibrary/list/{geotype}") @ApiOperation(value = "获取符号库对应空间类型符号风格列表", notes = "") public String getSymbolLibraryList(@ApiParam(name = "geotype", value = "空间类型", required = true) @PathVariable(name = "geotype") String geotype) { List list = resSymbolLibraryService.getListByGeoType(geotype); Map maps = new HashMap<>(); maps.put("success", true); List> SymbolLibraryMaps = new LinkedList<>(); for (int i = 0; i < list.size(); i++) { Map SymbolLibraryMap = new HashMap<>(); SymbolLibraryMap.put(list.get(i).getFhid(), list.get(i).getSymbol()); SymbolLibraryMaps.add(SymbolLibraryMap); } maps.put("data", SymbolLibraryMaps); return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue); } /** * 获取空间分析列表接口 */ @ResponseBody @GetMapping(path = {"spaceserverlist", "spaceserverlist/{userid}"}) @ApiOperation(value = "查询已审核的空间分析信息列表", notes = "") public String getSpaceServerList(@ApiParam(name = "userid", value = "userid") @PathVariable(name = "userid", required = false) Integer userid, HttpServletRequest request) { Map paramMap = new HashMap(); paramMap.put("userid", userid); List list = zhuanTiZhiTuService.getSpaceServerList(paramMap); List> listMaps = new LinkedList<>(); for (int i = 0; i < list.size(); i++) { String subzyids = ""; boolean isPubzy = false; if (list.get(i).getSharprotocol().equals("完全公开")) { isPubzy = true; } Map map = new HashMap<>(); map.put("resourceId", list.get(i).getResourceid()); map.put("title", list.get(i).getTitle()); map.put("imgurl", list.get(i).getImgurl()); map.put("serverUrl", list.get(i).getServerurl()); map.put("postType", list.get(i).getPosttype()); map.put("diyParamUrl", list.get(i).getDiyparamurl()); map.put("createuserid", list.get(i).getCreateuserid()); List> spaceParamsMaps = new LinkedList<>(); List resSpacesParams = resSpacesParamService.selectByResSourceId(list.get(i).getResourceid()); if (resSpacesParams != null && resSpacesParams.size() > 0) { for (int j = 0; j < resSpacesParams.size(); j++) { Map spaceParams = new HashMap<>(); spaceParams.put("paramId", resSpacesParams.get(j).getParamid()); spaceParams.put("orderIndex", resSpacesParams.get(j).getOrderindex()); spaceParams.put("paramType", resSpacesParams.get(j).getParamtype()); spaceParams.put("paramName", resSpacesParams.get(j).getParamname()); spaceParams.put("dataType", resSpacesParams.get(j).getDatatype()); spaceParams.put("paramAlias", resSpacesParams.get(j).getParamalias()); spaceParams.put("required", resSpacesParams.get(j).getRequired()); spaceParams.put("defaultValue", resSpacesParams.get(j).getDefaultValue()); spaceParams.put("layerStyle", resSpacesParams.get(j).getLayerstyle() == null ? "" : resSpacesParams.get(j).getLayerstyle()); spaceParamsMaps.add(spaceParams); } } map.put("spaceParams", spaceParamsMaps); listMaps.add(map); } return JSON.toJSONString(listMaps, SerializerFeature.WriteMapNullValue); } /** * 新增/修改用户图层范围 */ @PostMapping(path = "/addUserLayerExtent") @ApiOperation(value = "新增/修改用户图层范围", notes = "") @ResponseBody public int addUserLayerExtent(@ApiParam(name = "id", value = "ID") Integer id, @ApiParam(name = "userid", value = "用户Id", required = true) Integer userid, @ApiParam(name = "resourceid", value = "资源Id", required = true) Integer resourceid, @ApiParam(name = "title", value = "名称", required = true) String title, @ApiParam(name = "extent", value = "范围", required = true) String extent) { if (id == null) id = -1; int newid = 0; Res_User_LayerExtent resUserLayerExtent = resUserLayerExtentService.selectByPrimaryKey(id); if (resUserLayerExtent != null) { resUserLayerExtent.setTitle(title); resUserLayerExtent.setExtent(extent); resUserLayerExtentService.updateByPrimaryKeySelective(resUserLayerExtent); newid = resUserLayerExtent.getId(); } else { resUserLayerExtent = new Res_User_LayerExtent(); resUserLayerExtent.setTitle(title); resUserLayerExtent.setUserid(userid); resUserLayerExtent.setExtent(extent); resUserLayerExtent.setResourceid(resourceid); resUserLayerExtentService.insertSelective(resUserLayerExtent); newid = resUserLayerExtentService.getCurrentObjectId(); } return newid; } /** * 根据用户ID和资源ID查询图层范围列表 */ @ResponseBody @GetMapping(path = "getLayerExtentList/{userid}/{resourceid}") @ApiOperation(value = "根据用户ID和资源ID查询图层范围列表", notes = "") public String getLayerExtentList(@ApiParam(name = "userid", value = "用户ID", required = true) @PathVariable(name = "userid") Integer userid, @ApiParam(name = "resourceid", value = "资源ID", required = true) @PathVariable(name = "resourceid") Integer resourceid) { Res_User_LayerExtent resUserLayerExtent = new Res_User_LayerExtent(); resUserLayerExtent.setResourceid(resourceid); resUserLayerExtent.setUserid(userid); List resUserLayerExtents = resUserLayerExtentService.selectByResidAndUserid(resUserLayerExtent); List> maps = new LinkedList<>(); for (int i = 0; i < resUserLayerExtents.size(); i++) { Map map = new HashMap<>(); map.put("id", resUserLayerExtents.get(i).getId()); map.put("title", resUserLayerExtents.get(i).getTitle()); map.put("userid", resUserLayerExtents.get(i).getUserid()); map.put("resourceid", resUserLayerExtents.get(i).getResourceid()); map.put("extent", resUserLayerExtents.get(i).getExtent()); maps.add(map); } return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue); } /** * 根据ID查询图层范围 */ @ResponseBody @GetMapping(path = "getLayerExtentInfo/{id}") @ApiOperation(value = "根据ID查询图层范围", notes = "") public String getLayerExtentInfo(@ApiParam(name = "id", value = "ID", required = true) @PathVariable(name = "id") Integer id) { Res_User_LayerExtent resUserLayerExtent = resUserLayerExtentService.selectByPrimaryKey(id); Map map = new HashMap<>(); if (resUserLayerExtent != null) { map.put("id", resUserLayerExtent.getId()); map.put("title", resUserLayerExtent.getTitle()); map.put("userid", resUserLayerExtent.getUserid()); map.put("resourceid", resUserLayerExtent.getResourceid()); map.put("extent", resUserLayerExtent.getExtent()); } return JSON.toJSONString(map, SerializerFeature.WriteMapNullValue); } }