2
13693261870
2022-09-16 653761a31dfeb50dd3d007e892d69c90bf0cdafc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
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<Res_MainInfo> selectZTDTList(Integer userid, PageBean pageBean) {
        PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
        Map<String, Object> map = new HashMap<>();
        map.put("leixiId", "KJ_ZTDT");
        map.put("userid", userid);
        List<Res_MainInfo> res_mainInfos = resMainInfoService.selectZTDTList(map);
        int countNums = (int) ((Page) res_mainInfos).getTotal();
        PageBean<Res_MainInfo> 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<Res_Catalog> 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<Res_MainInfo> resMainInfo = resMainInfoService.selectTwtcForZiYuan(resMainInfoTWO); // 获取目录下业务图层资源列表
            // 循环构造资源节点
            for (Res_MainInfo resMainInfo1 : resMainInfo) {
                if (!"".equals(resCatalogJson.toString())) {
                    resCatalogJson.append(',');
                }
                List<Res_ExtMapUrl> 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<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 + "', 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(',');
                    }
                    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<Res_Catalog> 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<Res_MainInfo> 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<Res_Theme> resThemeList = resThemeService.getAllThemeList(userId);// 获取业务专题默认专题列表,临时去除用户过滤
        int countNums = (int) ((Page) resThemeList).getTotal();//获取记录总数
        PageBean<Res_Theme> 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<String, Object> map = new HashMap<>();
        map.put("themeid", themeId);
        List<Res_Theme_Module> 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<Res_Theme_Module> page = PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());
        Map<String, Object> map = new HashMap<>();
        map.put("themeid", themeid);
        map.put("title", title);
        map.put("moduleIdList", moduleIdList);
        List<Res_Theme_Module> resThemeModuleList1 = resThemeModuleService.getIgnoreThemeModuleList(map);
        int countNums = (int) ((Page) resThemeModuleList1).getTotal();
        PageBean<Res_Theme_Module> 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<Res_Theme> 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() + ")";
    }
}