package com.landtool.lanbase.modules.api.controller; import java.util.HashMap; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; 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.RequestMapping; import org.springframework.web.bind.annotation.ResponseBody; import com.github.pagehelper.Page; import com.github.pagehelper.PageHelper; import com.landtool.lanbase.config.SysTemPropertyConfig; import com.landtool.lanbase.modules.api.utils.PageBean; import com.landtool.lanbase.modules.res.entity.Res_Catalog; import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo; 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_MainInfo; import com.landtool.lanbase.modules.res.entity.Res_Theme; import com.landtool.lanbase.modules.res.entity.Res_Theme_Module; import com.landtool.lanbase.modules.res.service.ResCatalogService; import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService; import com.landtool.lanbase.modules.res.service.ResExtIntegrateService; import com.landtool.lanbase.modules.res.service.ResExtMapUrlService; import com.landtool.lanbase.modules.res.service.ResMainInfoService; import com.landtool.lanbase.modules.res.service.ResThemeModuleService; import com.landtool.lanbase.modules.res.service.ResThemeRelationService; import com.landtool.lanbase.modules.res.service.ResThemeService; import com.landtool.lanbase.modules.sys.service.SysFieldvalueService; import io.swagger.annotations.Api; @Controller @RequestMapping("/api/res") @Api(value = "", tags = { "地图相关接口" }) public class ResMapApiController { @Autowired private ResMainInfoService resMainInfoService; @Autowired private ResCatalogService resCatalogService; @Autowired private ResExtMapUrlService resExtMapUrlService; @Autowired private ResDiyLayerInfoService resDiyLayerInfoService; @Autowired private ResExtIntegrateService resExtIntegrateService; @Autowired private ResThemeService resThemeService; @Autowired private ResThemeModuleService resThemeModuleService; @Autowired private ResThemeRelationService resThemeRelationService; @Autowired private SysFieldvalueService FieldUtils; @Autowired private SysTemPropertyConfig sysConfig; // 查询专题地图对应的title @ResponseBody @GetMapping("selectZTDTList") public List selectZTDTList(Integer userid, PageBean pageBean) { PageHelper.startPage(pageBean.getPage(), pageBean.getLimit()); Map map = new HashMap<>(); map.put("leixiId", "KJ_ZTDT"); map.put("userid", userid); List res_mainInfos = resMainInfoService.selectZTDTList(map); int countNums = (int) ((Page) res_mainInfos).getTotal(); PageBean pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums); pageData.setItems(res_mainInfos); // 查询基础底图 return res_mainInfos; } // 查询资源目录对应的资源 @ResponseBody @GetMapping("selectTitlefromZiYuan") public String selectTitlefromZiYuan(String parentid, Res_MainInfo info) { StringBuilder resCatalogJson = new StringBuilder(); if (parentid.indexOf("ZiYuan_") == -1) { String leixiId = "KJ_YWTC"; Res_MainInfo resMainInfoTWO = new Res_MainInfo(); resMainInfoTWO.setResourceclass(leixiId); resMainInfoTWO.setCParentid(Integer.parseInt(parentid)); resMainInfoTWO.setCatlogid(Integer.parseInt(parentid)); resMainInfoTWO.setTitle(info.getTitle()); resMainInfoTWO.setCreateuserid(info.getCreateuserid()); resMainInfoTWO.setPubdateBegin(info.getPubdateBegin()); resMainInfoTWO.setPubdatefinish(info.getPubdatefinish()); resMainInfoTWO.setIscollect(info.getIscollect()); List resCatalogList = resCatalogService.selectFilterResCatalogToParentid(resMainInfoTWO);// 获取子目录列表 // 循环构造子目录节点 for (Res_Catalog resCatalog : resCatalogList) { if (!"".equals(resCatalogJson.toString())) { resCatalogJson.append(','); } resCatalogJson.append( "{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "', isParent: true}"); } // 获取资源类型列表 List resMainInfo = resMainInfoService.selectTwtcForZiYuan(resMainInfoTWO); // 获取目录下业务图层资源列表 // 循环构造资源节点 for (Res_MainInfo resMainInfo1 : resMainInfo) { if (!"".equals(resCatalogJson.toString())) { resCatalogJson.append(','); } List urlList = resExtMapUrlService.selectByCondition(resMainInfo1.getResourceid()); boolean isMapUrl = urlList.size() == 0 ? false : true; String title = resMainInfo1.getTitle(); if (resMainInfo1.getTitle().length() > 16) { title = resMainInfo1.getTitle().substring(0, 16) + ".."; } resCatalogJson.append("{icon:'./images/classicons/" + resMainInfo1.getResourceclass() + ".png',id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + title + "', title: '" + resMainInfo1.getTitle() + "',isParent:false, hidtxt: '', isMapUrl: " + isMapUrl + "}"); } } else { String idstr = parentid.substring(parentid.indexOf("_") + 1, parentid.length()); List urlList = resExtMapUrlService.selectByCondition(Integer.parseInt(idstr)); if (urlList.size() != 0) { LinkedHashMap TypeAndURLList = FieldUtils.getFieldListByKey("TypeAndURL"); for (Res_ExtMapUrl urlitem : urlList) { if (!"".equals(resCatalogJson.toString())) { resCatalogJson.append(','); } String name = TypeAndURLList.get(urlitem.getTypeandurl()); resCatalogJson.append("{id: 'Url_" + urlitem.getUrlid() + "', resourceId: " + idstr + ",name:'" + name + "', hidtxt: ''}"); } } Res_DiyLayerInfo resDiyLayerInfo = new Res_DiyLayerInfo(); resDiyLayerInfo.setResourceid(Integer.parseInt(idstr)); resDiyLayerInfo.setIsshare(1); resDiyLayerInfo.setResourceid(Integer.parseInt(idstr)); List resDiyLayerInfoList = resDiyLayerInfoService.queryApiList(resDiyLayerInfo);// 获取制图信息列表 if (resDiyLayerInfoList.size() > 0) { for (Res_DiyLayerInfo item : resDiyLayerInfoList) { if (!"".equals(resCatalogJson.toString())) { resCatalogJson.append(','); } resCatalogJson.append("{id: 'Diy_" + item.getDiyid() + "', resourceId: " + idstr + ",name:'" + item.getTitle() + "', hidtxt: " + item.getContent() + "}"); } } } return "[" + resCatalogJson.toString() + "]"; } /** * 获取业务集成定制目录树 * @param id 目录ID * @return */ @ResponseBody @GetMapping("getYWJCCustomTreeData") public String getYWJCCustomTreeData(String id) { StringBuilder resCatalogJson = new StringBuilder(); Res_MainInfo resMainInfoTWO = new Res_MainInfo(); resMainInfoTWO.setResourceclass("YWJC"); resMainInfoTWO.setCParentid(Integer.parseInt(id)); resMainInfoTWO.setCatlogid(Integer.parseInt(id)); List resCatalogList = resCatalogService.getYWJCMuLuTree(Integer.parseInt(id));// 获取子目录列表 // 循环构造子目录节点 for (Res_Catalog resCatalog : resCatalogList) { if (!"".equals(resCatalogJson.toString())) { resCatalogJson.append(','); } resCatalogJson.append( "{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "', isParent: true}"); } // 获取资源类型列表 List resMainInfo = resMainInfoService.getYWJCTreeData(resMainInfoTWO); // 获取目录下业务集成--页面集成--Iframe区块资源列表 // 循环构造资源节点 for (Res_MainInfo resMainInfo1 : resMainInfo) { Res_ExtIntegrate res_extIntegrate = resExtIntegrateService.selectByPrimaryKey(resMainInfo1.getResourceid());// 获取业务集成拓展信息 if (!"".equals(resCatalogJson.toString())) { resCatalogJson.append(','); } String title = resMainInfo1.getTitle(); if (resMainInfo1.getTitle().length() > 16) { title = resMainInfo1.getTitle().substring(0, 16) + ".."; } String serverUrl = res_extIntegrate.getServerurl(); if (serverUrl == null) serverUrl = ""; resCatalogJson.append("{id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + title + "', title: '" + resMainInfo1.getTitle() + "',isParent:false, ServerUrl: '" + serverUrl + "'}"); } return "[" + resCatalogJson.toString() + "]"; } /** * 获取专题列表(业务专题) */ @ResponseBody @GetMapping("getAllThemeList") public String getAllThemeList(Integer userId,PageBean pageBean) { pageBean.setLimit(10); PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());//设置当前页数及每页条数 List resThemeList = resThemeService.getAllThemeList(userId);// 获取业务专题默认专题列表,临时去除用户过滤 int countNums = (int) ((Page) resThemeList).getTotal();//获取记录总数 PageBean pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums); pageData.setItems(resThemeList); StringBuilder sb = new StringBuilder(); sb.append("["); for (Res_Theme resTheme : resThemeList) { if (sb.toString().length() > 0) sb.append(","); sb.append("{"); sb.append("id: " + resTheme.getThemeid()); sb.append(", title: '" + resTheme.getTitle() + "'"); sb.append("}"); } sb.append("]"); StringBuilder rsb1 = new StringBuilder(); rsb1.append("{"); rsb1.append("Count:"+countNums); rsb1.append(",Page:"+pageBean.getPage()); rsb1.append(",ShuJu:"+sb.toString()); rsb1.append("}"); return "(" + rsb1.toString() + ")"; } /** * 获取业务专题所选模块列表(前4个) * @param themeId * 业务专题Id * @return */ @ResponseBody @GetMapping("getThemeModuleList") public String getThemeModuleList(Integer themeId) { Map map = new HashMap<>(); map.put("themeid", themeId); List resThemeModuleList = resThemeModuleService.getThemeModuleList(map); StringBuilder rsb = new StringBuilder(); for (int i = 0; i < resThemeModuleList.size(); i++) { if (i != 0) { rsb.append(","); } rsb.append("{'moduleid':'" + resThemeModuleList.get(i).getModuleid() + "'"); // 模块ID rsb.append(",'title':'" + resThemeModuleList.get(i).getTitle() + "'"); // 模块名称 rsb.append(",'mapresid':'" + resThemeModuleList.get(i).getMapresid() + "'"); // 地图资源ID rsb.append(",'panelresid':'" + resThemeModuleList.get(i).getPanelresid() + "'"); // 面板ID Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resThemeModuleList.get(i).getPanelresid()); if (resExtIntegrate != null) { rsb.append(",'serverurl':'" + resExtIntegrate.getServerurl() + "'"); // 发布单位id } else { rsb.append(",'serverurl':''"); // 发布单位id } rsb.append("}"); } return "[" + rsb.toString() + "]"; } /** * 获取模块列表(排除业务专题已选择模块) * @param themeid 业务专题Id * @param title 模块名称 * @param moduleIdList 业务专题已展示模块ID * @return */ @ResponseBody @GetMapping("getModuleList") public String getModuleList(Integer themeid, String title, String moduleIdList, PageBean pageBean) { Page page = PageHelper.startPage(pageBean.getPage(), pageBean.getLimit()); Map map = new HashMap<>(); map.put("themeid", themeid); map.put("title", title); map.put("moduleIdList", moduleIdList); List resThemeModuleList1 = resThemeModuleService.getIgnoreThemeModuleList(map); int countNums = (int) ((Page) resThemeModuleList1).getTotal(); PageBean pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums); pageData.setItems(resThemeModuleList1); StringBuilder rsb = new StringBuilder(); rsb.append("{'totalCount':'" + countNums); rsb.append("','topics':["); for (int i = 0; i < resThemeModuleList1.size(); i++) { if (i != 0) { rsb.append(","); } rsb.append("{'moduleid':'" + resThemeModuleList1.get(i).getModuleid() + "'"); // 模块ID rsb.append(",'title':'" + resThemeModuleList1.get(i).getTitle() + "'"); // 模块名称 rsb.append("}"); } rsb.append("]}"); return rsb.toString(); } /** * 定制业务专题模块 * @param new_moduleId 新模块ID * @return */ @ResponseBody @GetMapping("ThemeModuleEdit") public String ThemeModuleEdit(Integer new_moduleId) { //resThemeRelationService.deleteByThemeIdAndModuleId(resThemeRelation); // 删除旧模块关联记录 // 新增新模块关联记录 //Res_Theme_Relation resThemeRelation1 = new Res_Theme_Relation(); //resThemeRelation1.setThemeid(resThemeRelation.getThemeid()); //resThemeRelation1.setModuleid(new_moduleId); //resThemeRelationService.insert(resThemeRelation1); // 查询新模块信息 Res_Theme_Module resThemeModule = resThemeModuleService.selectByid(new_moduleId); StringBuilder rsb = new StringBuilder(); if(resThemeModule != null) { rsb.append("{'moduleid':'" + resThemeModule.getModuleid() + "'"); // 模块ID rsb.append(",'title':'" + resThemeModule.getTitle() + "'"); // 模块名称 rsb.append(",'mapresid':'" + resThemeModule.getMapresid() + "'"); // 地图资源ID rsb.append(",'panelresid':'" + resThemeModule.getPanelresid() + "'"); // 面板ID Res_ExtIntegrate resExtIntegrate = resExtIntegrateService.selectByPrimaryKey(resThemeModule.getPanelresid()); if (resExtIntegrate != null) { rsb.append(",'serverurl':'" + resExtIntegrate.getServerurl() + "'"); // 发布单位id } else { rsb.append(",'serverurl':''"); // 发布单位id } rsb.append("}"); } return rsb.toString(); } /** * 获取第一个默认专题(业务专题) */ @ResponseBody @GetMapping("getFirstDefaultTheme") public String getFirstDefaultTheme(Integer userId) { List resThemeList = resThemeService.getDefaultThemeList(userId);// 获取业务专题默认专题,临时去除用户过滤 StringBuilder sb = new StringBuilder(); int i = 0; for (Res_Theme resTheme : resThemeList) { if(i == 0) { sb.append("{"); sb.append("id: " + resTheme.getThemeid()); sb.append(", title: '" + resTheme.getTitle() + "'"); sb.append("}"); i += 1; } } return "(" + sb.toString() + ")"; } }