package com.landtool.lanbase.modules.res.controller;
|
|
import java.util.HashMap;
|
import java.util.LinkedHashMap;
|
import java.util.LinkedList;
|
import java.util.List;
|
import java.util.Map;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Controller;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.ResponseBody;
|
|
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.serializer.SerializerFeature;
|
import com.github.pagehelper.Page;
|
import com.github.pagehelper.PageHelper;
|
import com.landtool.lanbase.common.utils.CommonUtils;
|
import com.landtool.lanbase.config.SysTemPropertyConfig;
|
import com.landtool.lanbase.modules.api.utils.PageBean;
|
import com.landtool.lanbase.modules.org.service.OrgUnitService;
|
import com.landtool.lanbase.modules.org.service.OrgUserService;
|
import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo;
|
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_OneMap_Catalog;
|
import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService;
|
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
|
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
|
import com.landtool.lanbase.modules.res.service.ResOnemapCatalogResourceService;
|
import com.landtool.lanbase.modules.res.service.ResOnemapCatalogService;
|
import com.landtool.lanbase.modules.sys.controller.AbstractController;
|
import com.landtool.lanbase.modules.sys.service.SysFieldvalueService;
|
|
@Controller
|
@RequestMapping("/res/OneMap")
|
public class OneMapController extends AbstractController {
|
@Autowired
|
private SysTemPropertyConfig sysConfig;
|
|
@Autowired
|
private ResMainInfoService resMainInfoService;
|
|
@Autowired
|
private ResExtMapUrlService resExtMapUrlService;
|
|
@Autowired
|
private ResDiyLayerInfoService resDiyLayerInfoService;
|
|
@Autowired
|
private OrgUserService orgUserService;
|
|
@Autowired
|
private OrgUnitService orgUnitService;
|
|
@Autowired
|
private SysFieldvalueService FieldUtils;
|
|
@Autowired
|
private ResOnemapCatalogService resOnemapCatalogService;
|
|
@Autowired
|
private ResOnemapCatalogResourceService resOnemapCatalogResourceService;
|
|
/**
|
* 检查一张图业务主题是否存在自定义目录
|
* @param themeId 业务主题ID
|
* @param type 自定义目录类型
|
* @param request
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("checkDiyCatalog")
|
public String checkDiyCatalog(Integer themeId, String type, HttpServletRequest request) {
|
String callbackFunName = request.getParameter("callback");
|
if (callbackFunName == null || callbackFunName.isEmpty()) {
|
callbackFunName = "callback";
|
}
|
|
Long userId = getUserId(); //获取用户ID
|
|
StringBuilder resCatalogJson = new StringBuilder();
|
Map<String, Object> map = new HashMap<>();
|
map.put("themeid", themeId); //业务主题ID
|
map.put("catlogtype", type); //目录树类型
|
|
int CatlogNum = resOnemapCatalogService.checkDiyCatalog(map);// 检查是否存在自定义目录
|
|
return callbackFunName + "({ success:" + (CatlogNum > 0) + "})";
|
}
|
|
/**
|
* 获取一张图业务主题自定义目录业务图层、专题地图列表
|
* @param themeId 一张图业务主题ID
|
* @param parentid 父节点ID
|
* @param type 目录树类型(专题地图、业务图层)
|
* @return
|
*/
|
@ResponseBody
|
@RequestMapping("GetDiyCatalogList")
|
public String GetDiyCatalogList(Integer themeId, String parentid, String type, HttpServletRequest request) {
|
String callbackFunName = request.getParameter("callback");
|
if (callbackFunName == null || callbackFunName.isEmpty()) {
|
callbackFunName = "callback";
|
}
|
|
Long userId = getUserId(); //获取用户ID
|
|
StringBuilder resCatalogJson = new StringBuilder();
|
if (parentid.indexOf("ZiYuan_") == -1) {
|
Map<String, Object> map = new HashMap<>();
|
map.put("themeid", themeId); //业务主题ID
|
map.put("parentid", parentid); //父节点ID
|
map.put("catlogtype", type); //目录树类型
|
|
List<Res_OneMap_Catalog> resOneMapCatalogs = resOnemapCatalogService.getCatalogExistsResource(map);// 获取子目录列表
|
// 循环构造子目录节点
|
for (Res_OneMap_Catalog resOneMapCatalog : resOneMapCatalogs) {
|
if (!"".equals(resCatalogJson.toString())) {
|
resCatalogJson.append(',');
|
}
|
resCatalogJson.append("{id: " + resOneMapCatalog.getCatlogid() + ",name:'" + resOneMapCatalog.getTitle() + "', isParent: true,iconOpen:'./images/classicons/folderOpen.png',iconClose:'./images/classicons/folder.png'}");
|
}
|
// 获取资源类型列表
|
List<Res_MainInfo> resMainInfos = resOnemapCatalogResourceService.getCatalogResourceByCatalogID(Integer.parseInt(parentid)); // 获取目录下业务图层资源列表
|
// 循环构造资源节点
|
for (Res_MainInfo resMainInfo : resMainInfos) {
|
if (!"".equals(resCatalogJson.toString())) {
|
resCatalogJson.append(',');
|
}
|
List<Res_ExtMapUrl> urlList = resExtMapUrlService.selectByCondition(resMainInfo.getResourceid());
|
boolean isMapUrl = urlList.size() == 0 ? false : true;
|
String title = resMainInfo.getTitle();
|
if (resMainInfo.getTitle().length() > 16) {
|
title = resMainInfo.getTitle().substring(0, 16) + "..";
|
}
|
String icon = "";
|
if (resMainInfo.getResourceclass().equals("KJ_ZTDT")) {
|
icon = "KJ_JCDT";
|
} else if (resMainInfo.getResourceclass().equals("KJ_JCDT")) {
|
icon = "JCDT";
|
} else {
|
icon = resMainInfo.getResourceclass();
|
}
|
String FaBuRen = orgUserService.getChinesename(resMainInfo.getCreateuserid());//发布人
|
String FaBuDanWei = orgUnitService.getUnitName((long) resMainInfo.getPubunitid());//发布单位
|
resCatalogJson.append("{icon:'./images/classicons/" + icon + ".png',id: 'ZiYuan_" + resMainInfo.getResourceid() + "',name:'" + title + "', title: '" + resMainInfo.getTitle() + "|" + FaBuDanWei + "|" + FaBuRen + "',isParent:false, hidtxt: '', isMapUrl: " + isMapUrl + ", ResourceClass: '" + resMainInfo.getResourceclass() + "'}");
|
}
|
} else {
|
String idstr = parentid.substring(parentid.indexOf("_") + 1, parentid.length());
|
Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(Integer.parseInt(idstr));
|
List<Res_ExtMapUrl> urlList = resExtMapUrlService.selectByCondition(Integer.parseInt(idstr));//获取资源协议信息列表
|
if (urlList.size() != 0) {
|
LinkedHashMap<String, String> 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 + "',ResourceClass:'" + resMainInfo.getResourceclass() + "', hidtxt: ''}");
|
}
|
}
|
Res_DiyLayerInfo resDiyLayerInfo = new Res_DiyLayerInfo();
|
resDiyLayerInfo.setResourceid(Integer.parseInt(idstr));
|
resDiyLayerInfo.setIsshare(1);
|
resDiyLayerInfo.setResourceid(Integer.parseInt(idstr));
|
List<Res_DiyLayerInfo> resDiyLayerInfoList = resDiyLayerInfoService.queryApiList(resDiyLayerInfo);// 获取自定义图层信息列表
|
if (resDiyLayerInfoList.size() > 0) {
|
for (Res_DiyLayerInfo item : resDiyLayerInfoList) {
|
if (!"".equals(resCatalogJson.toString())) {
|
resCatalogJson.append(',');
|
}
|
String ChineseName = orgUserService.getChinesename(item.getDiyuserid());
|
resCatalogJson.append("{id: 'Diy_" + item.getDiyid() + "', resourceId: " + idstr + ",name:'" + item.getTitle() + "(" + ChineseName + ")', hidtxt: '', showDelBtn: " + (item.getDiyuserid() == userId.intValue() ? true : false) + "}");
|
}
|
}
|
}
|
return callbackFunName + "([" + resCatalogJson.toString() + "])";
|
}
|
|
/**
|
* 获取一张图业务主题自定义目录
|
*/
|
@ResponseBody
|
@RequestMapping("getThemeCataLog")
|
public String getThemeCataLog(Integer themeId, String catlogType, Integer catlogId, HttpServletRequest request) {
|
String callbackFunName = request.getParameter("callback");
|
if (callbackFunName == null || callbackFunName.isEmpty()) {
|
callbackFunName = "callback";
|
}
|
|
Map<String, Object> map = new HashMap<>();
|
map.put("themeid", themeId); //业务主题ID
|
map.put("catlogtype", catlogType); //自定义目录类型
|
map.put("parentid", catlogId); //目录ID
|
List<Res_OneMap_Catalog> resOneMapCatalogs = resOnemapCatalogService.getThemeCataLog(map);
|
StringBuilder sb = new StringBuilder();
|
sb.append("[");
|
int i = 0;
|
List<Map<String, Object>> maps = new LinkedList<>();
|
for (Res_OneMap_Catalog resOneMapCatalog : resOneMapCatalogs) {
|
String title = resOneMapCatalog.getTitle();
|
if (title.length() > 15) {
|
title = CommonUtils.subStringUtils(title, 30);
|
}
|
Map<String, Object> remap = new HashMap<>();
|
remap.put("id", resOneMapCatalog.getCatlogid());
|
remap.put("title", title);
|
remap.put("fulltitle", resOneMapCatalog.getTitle());
|
maps.add(remap);
|
|
// if (i > 0) sb.append(",");
|
// sb.append("{");
|
// sb.append("id: " + resOneMapCatalog.getCatlogid());
|
//
|
// sb.append(", title: '" + title + "'");
|
// sb.append(", fulltitle: '" + resOneMapCatalog.getTitle() + "'");
|
// sb.append("}");
|
i++;
|
}
|
sb.append("]");
|
return callbackFunName + "(" + JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue) + ")";
|
}
|
|
/**
|
* 获取一张图业务主题自定义目录资源列表
|
*/
|
@ResponseBody
|
@RequestMapping("getCatalogResourceList")
|
public String getCatalogResourceList(Integer catlogId, String catlogType, Integer themeId, PageBean pageBean, HttpServletRequest request) {
|
String callbackFunName = request.getParameter("callback");
|
if (callbackFunName == null || callbackFunName.isEmpty()) {
|
callbackFunName = "callback";
|
}
|
pageBean.setLimit(10);
|
|
PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());//设置当前页数及每页条数
|
Map<String, Object> map = new HashMap<>();
|
map.put("catlogid", catlogId); //目录ID
|
map.put("catlogtype", catlogType); //目录类型
|
map.put("themeid", themeId); //业务专题ID
|
List<Res_MainInfo> resMainInfos = resOnemapCatalogResourceService.getCatalogResourceList(map);// 获取目录下(包含下级目录)资源列表
|
int countNums = (int) ((Page) resMainInfos).getTotal();//获取记录总数
|
PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
|
pageData.setItems(resMainInfos);
|
StringBuilder sb = new StringBuilder();
|
sb.append("[");
|
int i = 0;
|
|
List<Map<String, Object>> maps = new LinkedList<>();
|
for (Res_MainInfo resMainInfo : resMainInfos) {
|
String title = resMainInfo.getTitle();
|
if (title.length() > 15) {
|
title = CommonUtils.subStringUtils(title, 30);
|
}
|
Map<String, Object> remap = new HashMap<>();
|
remap.put("id", resMainInfo.getResourceid());
|
remap.put("title", title);
|
remap.put("fulltitle", resMainInfo.getTitle());
|
maps.add(remap);
|
|
// if (i > 0) sb.append(",");
|
// sb.append("{");
|
// sb.append("id: " + resMainInfo.getResourceid());
|
//
|
// sb.append(", title: '" + title + "'");
|
// sb.append(", fulltitle: '" + resMainInfo.getTitle() + "'");
|
// sb.append("}");
|
i++;
|
}
|
sb.append("]");
|
// StringBuilder rsb1 = new StringBuilder();
|
// rsb1.append("{");
|
// rsb1.append("Count:" + countNums);
|
// rsb1.append(",Page:" + pageBean.getPage());
|
// rsb1.append(",ShuJu:" + sb.toString());
|
// rsb1.append("}");
|
Map<String, Object> newmap = new HashMap<>();
|
newmap.put("Count", countNums);
|
newmap.put("Page", pageBean.getPage());
|
newmap.put("ShuJu", maps);
|
return callbackFunName + "(" + JSON.toJSONString(newmap, SerializerFeature.WriteMapNullValue) + ")";
|
}
|
}
|