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
371
372
373
374
375
376
377
package com.landtool.lanbase.modules.api.controller.MapPortal;
 
import java.io.File;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
 
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.landtool.lanbase.common.utils.JpinyinUtils;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.org.entity.OrgUnit;
import com.landtool.lanbase.modules.org.service.OrgUserService;
import com.landtool.lanbase.modules.res.entity.Res_ExtBusinessLayer;
import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl;
import com.landtool.lanbase.modules.res.entity.Res_ExtThemeMap;
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
import com.landtool.lanbase.modules.res.service.ResActionRecordService;
import com.landtool.lanbase.modules.res.service.ResApplyRecommendService;
import com.landtool.lanbase.modules.res.service.ResAuditService;
import com.landtool.lanbase.modules.res.service.ResBusinessRefService;
import com.landtool.lanbase.modules.res.service.ResEvaluationService;
import com.landtool.lanbase.modules.res.service.ResExtBusinessLayerService;
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
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 io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
 
/**
 * @author 刘小波
 * @Description: 专题制图相关接口
 * @date 2018-05-26
 */
 
@Controller
@RequestMapping("/api/thememaping/")
@Api(value = "", tags = { "专题制图相关接口" })
public class ThemeMappingController {
    @Autowired
    private ResExtThemeMapService resExtThemeMapService;
    @Autowired
    private ResMainInfoService resMainInfoService;
    @Autowired
    private OrgUserService orgUserService;
 
    @Autowired
    private ResExtBusinessLayerService resExtBusinessLayerService;
 
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
 
    @Autowired
    private ResActionRecordService resActionRecordService;
 
    @Autowired
    private ResApplyRecommendService resApplyRecommendService;
 
    @Autowired
    private ResAuditService resAuditService;
 
    @Autowired
    private ResBusinessRefService resBusinessRefService;
 
    @Autowired
    private ResQueryAroundService resQueryAroundService;
 
    @Autowired
    private ResEvaluationService resEvaluationService;
 
    @Autowired
    private SysTemPropertyConfig sysConfig;
    
    /**
     * 新增系统资源扩展(专题地图)
     */
    @PostMapping(path = "/addMap")
    @ApiOperation(value = "新增系统资源扩展(专题地图)", notes = "")
    @ResponseBody
    public int addMap(
            // @ApiParam(name="catlogid",value="资源目录Id",required=true)
            // @RequestParam(name="catlogid")int catlogid,
            @ApiParam(name = "resourceid", value = "资源Id") Integer resourceid,
            @ApiParam(name = "title", value = "资源名称", required = true) @RequestParam(name = "title") String title,
            @ApiParam(name = "resourceclass", value = "资源类型代码") String resourceclass,
            @ApiParam(name = "catlogcode", value = "所属目录编码") String catlogcode,
            @ApiParam(name = "publishsoft", value = "发布平台") String publishsoft,
            @ApiParam(name = "layername", value = "原图层名称") String layername,
            @ApiParam(name = "portalguid", value = "Portal资源GUID") String portalguid,
            @ApiParam(name = "legeendurl", value = "自定义图例") String legeendurl,
            @ApiParam(name = "sublayerset", value = "子图层设置") String sublayerset,
            @ApiParam(name = "defaultlayerset", value = "默认底图设置") Integer defaultlayerset,
            @ApiParam(name = "initxmin", value = "初始化地图范围最小的X坐标值") Double initxmin,
            @ApiParam(name = "initxmax", value = "初始化地图范围最大的X坐标值") Double initxmax,
            @ApiParam(name = "initymin", value = "初始化地图范围最小的Y坐标值") Double initymin,
            @ApiParam(name = "initymax", value = "初始化地图范围最大的Y坐标值") Double initymax,
            @ApiParam(name = "fullxmin", value = "地图覆盖范围最小的X坐标值") Double fullxmin,
            @ApiParam(name = "fullxmax", value = "地图覆盖范围最大的X坐标值") Double fullxmax,
            @ApiParam(name = "fullymin", value = "地图覆盖范围最小的Y坐标值") Double fullymin,
            @ApiParam(name = "fullymax", value = "地图覆盖范围最大的Y坐标值") Double fullymax,
            @ApiParam(name = "type", value = "专题类型") String type,
            @ApiParam(name = "mapjson", value = "地图JSON", required = true) String mapjson,
            @ApiParam(name = "userid", value = "创建用户ID", required = true) Long userid) {
        if (resourceid == null)
            resourceid = -1;
 
        Res_MainInfo main = resMainInfoService.selectByPrimaryKey(resourceid);
        if (main != null) {
            main.setTitle(title);
            main.setAbbreviation(title);
            main.setResourceclass("KJ_ZTDT");// 暂时先赋值0
            main.setCatlogcode("0");// 暂时先赋值0
            main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase());
            Timestamp time = new Timestamp(new Date().getTime());
            main.setLasteditdate(time);
            resMainInfoService.updateByPrimaryKeySelective(main);
            Res_ExtThemeMap info = resExtThemeMapService.selectByPrimaryKey(resourceid);
            if (info != null) {
                info.setPublishsoft(publishsoft);
                info.setLayername(layername);
                info.setSublayerset(sublayerset);
                info.setDefaultlayerset(defaultlayerset);
                info.setInitxmin(initxmin == null ? 0 : initxmin);
                info.setInitxmax(initxmax == null ? 0 : initxmax);
                info.setInitymin(initymin == null ? 0 : initymin);
                info.setInitymax(initymax == null ? 0 : initymax);
                info.setType(type == null ? "系统制作" : type);
                info.setMapjson(mapjson);
                resExtThemeMapService.updateByPrimaryKeySelective(info);
            }
        } else {
            main = new Res_MainInfo();
            main.setTitle(title);
            main.setAbbreviation(title);
            main.setCatlogid(0);// 默认设置0
            main.setResourceclass("KJ_ZTDT");// 暂时先赋值0
            main.setCatlogcode("0");// 暂时先赋值0
            main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase());
            Timestamp time = new Timestamp(new Date().getTime());
            main.setPubdate(time);
 
            // 查询发布人对应的单位ID
            OrgUnit orgUnit = orgUserService.getDefaultUnit(userid);
            if(orgUnit != null) {
                main.setPubunitid(orgUnit.getUnitid().intValue());
            } else {
                main.setPubunitid(0);
            }
            main.setCreateuserid(userid);
            main.setCreatedate(time);
            main.setLasteditdate(time);
 
            main.setSharprotocol("完全公开");
            main.setEspproxy(0);
            main.setResourcestatus(0);
            main.setAuditstatus(0);
            main.setDisplayby2d(0);
            main.setDisplayby3d(0);
 
            resMainInfoService.insertSelective(main);
            resourceid = resMainInfoService.queryResMainInfoIdentCurrent();
            Res_ExtThemeMap info = new Res_ExtThemeMap();
            info.setResourceid(resourceid);
            info.setPublishsoft(publishsoft);
            info.setLayername(layername);
            info.setPortalguid(portalguid);
            info.setSublayerset(sublayerset);
            info.setDefaultlayerset(defaultlayerset);
            info.setInitxmin(initxmin == null ? 0 : initxmin);
            info.setInitxmax(initxmax == null ? 0 : initxmax);
            info.setInitymin(initymin == null ? 0 : initymin);
            info.setInitymax(initymax == null ? 0 : initymax);
            info.setType(type == null ? "系统制作" : type);
            info.setMapjson(mapjson);
            resExtThemeMapService.insert(info);
        }
        return resourceid;
    }
 
    /**
     * 编辑系统资源扩展(专题地图)地图JSON
     */
    @PostMapping(path = "/updateMap")
    @ApiOperation(value = "编辑系统资源扩展(专题地图)地图JSON", notes = "")
    @ResponseBody
    public int updateExtThemeMap(
            @ApiParam(name = "resourceid", value = "信息资源Id", required = true) @RequestParam(name = "resourceid") int resourceid,
            @ApiParam(name = "title", value = "资源名称") @RequestParam(name = "title") String title,
            @ApiParam(name = "mapjson", value = "地图JSON") @RequestParam(name = "mapjson") String mapjson) {
        Res_MainInfo resMainInfo = new Res_MainInfo();
        resMainInfo.setResourceid(resourceid);
        resMainInfo.setTitle(title);
        resMainInfoService.updateByPrimaryKeySelective(resMainInfo);
 
        Res_ExtThemeMap info = new Res_ExtThemeMap();
        info.setResourceid(resourceid);
        info.setMapjson(mapjson);
 
        resExtThemeMapService.updateByPrimaryKeySelective(info);
        return resourceid;
    }
 
    @ResponseBody
    @GetMapping("/info/{resourceid}")
    @ApiOperation(value = "获取系统资源扩展(专题地图)", notes = "")
    public Res_ExtThemeMap queryExtThemeMap(
            @ApiParam(name = "resourceid", value = "信息资源Id") @PathVariable("resourceid") int resourceid) {
        return resExtThemeMapService.selectByPrimaryKey(resourceid);
    }
 
    @ResponseBody
    @PostMapping("/del")
    @ApiOperation(value = "删除我的制图相关信息", notes = "")
    public String delExtThemeMap(
            @ApiParam(name = "resourceid", value = "信息资源Id") @RequestParam(name ="resourceid") int resourceid) {
        Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
        if (resExtThemeMap != null) {
            if(resExtThemeMap.getLegendurl() != null) {
                String path = sysConfig.getUploadPath() + "ResExtThemMapServer/" + resExtThemeMap.getLegendurl();
                File file = new File(path);
                if(file.exists()) {
                    file.delete();
                }
            }
            resExtThemeMapService.deleteByPrimaryKey(resourceid);
        }
        //资源协议与地址
        List<Res_ExtMapUrl> resExtMapUrlList = resExtMapUrlService.selectByCondition(resourceid);
        if(resExtMapUrlList != null && resExtMapUrlList.size() > 0){
            resExtMapUrlService.deleteByResourceId(resourceid);
        }
        //资源操作记录
        int resActionRecordCount = resActionRecordService.selectCountByResourceid(resourceid);
        if(resActionRecordCount > 0){
            resActionRecordService.deleteByResourceid(resourceid);
        }
        //资源申请/推荐
        int resApplyRecommendCount = resApplyRecommendService.selectCountByResourceid(resourceid);
        if(resApplyRecommendCount > 0){
            resApplyRecommendService.deleteByResourceid(resourceid);
        }
        //资源发布注销变更审核
        int resAuditCount = resAuditService.selectCountByResourceid(resourceid);
        if(resAuditCount > 0){
            resAuditService.deleteByResourceid(resourceid);
        }
        //业务关联分析
        int resBusinessrefCount = resBusinessRefService.selectCountByResourceid(resourceid);
        if(resBusinessrefCount > 0){
            resBusinessRefService.deleteByResourceid(resourceid);
        }
        //业务关联周边查询
        int resQueryAroundCount = resQueryAroundService.selectCountByResourceid(resourceid);
        if(resQueryAroundCount > 0 ){
            resQueryAroundService.deleteByResourceid(resourceid);
        }
        //资源评价
        int resEvaluationCount = resEvaluationService.selectCountByResourceid(resourceid);
        if(resEvaluationCount > 0){
            resEvaluationService.deleteByResourceid(resourceid);
        }
        resMainInfoService.deleteByPrimaryKey(resourceid);
        return "删除成功";
    }
 
    /**
     * 新增系统资源扩展(业务图层)
     */
    @PostMapping(path = "/addBusinessLayer")
    @ApiOperation(value = "新增系统资源扩展(业务图层)", notes = "")
    @ResponseBody
    public int addBusinessLayer(
            // @ApiParam(name="catlogid",value="资源目录Id",required=true)
            // @RequestParam(name="catlogid")int catlogid,
            @ApiParam(name = "resourceid", value = "资源Id") Integer resourceid,
            @ApiParam(name = "title", value = "资源名称", required = true) @RequestParam(name = "title") String title,
            @ApiParam(name = "resourceclass", value = "资源类型代码") String resourceclass,
            @ApiParam(name = "catlogcode", value = "所属目录编码") String catlogcode,
            @ApiParam(name = "publishsoft", value = "发布平台", required = true) @RequestParam(name = "publishsoft") String publishsoft,
            @ApiParam(name = "layername", value = "原图层名称") String layername,
            @ApiParam(name = "dataloadtype", value = "加载方式(按需(MODE_ONDEMAND)、快照(MODE_SNAPSHOT))") String dataloadtype,
            @ApiParam(name = "advancequeryurl", value = "自定义高级查询地址") String advancequeryurl,
            @ApiParam(name = "diyqueryurl", value = "自定义查询列表") String diyqueryurl,
            @ApiParam(name = "diybubbleurl", value = "自定义气泡路径") String diybubbleurl,
            @ApiParam(name = "typeandurl", value = "地理参考信息", required = true) @RequestParam(name = "typeandurl") String typeandurl,
            @ApiParam(name = "serverurl", value = "服务地址", required = true) @RequestParam(name = "serverurl") String serverurl,
            @ApiParam(name = "userid", value = "创建用户ID", required = true) @RequestParam(name = "userid") Long userid) {
        if (resourceid == null)
            resourceid = -1;
 
        Res_MainInfo main = resMainInfoService.selectByPrimaryKey(resourceid);
        if (main != null) {
            main.setTitle(title);
            main.setAbbreviation(title);
            main.setResourceclass("KJ_YWTC");// 暂时先赋值0
            main.setCatlogcode("0");// 暂时先赋值0
            main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase());
            Timestamp time = new Timestamp(new Date().getTime());
            main.setLasteditdate(time);
            resMainInfoService.updateByPrimaryKeySelective(main);
            Res_ExtBusinessLayer info = resExtBusinessLayerService.selectByPrimaryKey(resourceid);
            if (info != null) {
                info.setPublishsoft(publishsoft);
                info.setLayername(layername);
                info.setAdvancequeryurl(advancequeryurl);
                info.setDataloadtype(dataloadtype);
                info.setDiybubbleurl(diybubbleurl);
                info.setDiyqueryurl(diyqueryurl);
                resExtBusinessLayerService.updateByPrimaryKeySelective(info);
            }
 
            Res_ExtMapUrl res_extMapUrl = new Res_ExtMapUrl();
            res_extMapUrl.setResourceid(resourceid);
            res_extMapUrl.setServerurl(serverurl);
            res_extMapUrl.setTypeandurl(typeandurl);
            resExtMapUrlService.insertSelective(res_extMapUrl);
        } else {
            main = new Res_MainInfo();
            main.setTitle(title);
            main.setAbbreviation(title);
            main.setCatlogid(0);// 默认设置0
            main.setResourceclass("KJ_YWTC");// 暂时先赋值0
            main.setCatlogcode("0");// 暂时先赋值0
            main.setPingyinfiirst(JpinyinUtils.changeToGetShortPinYin(title).toUpperCase());
            Timestamp time = new Timestamp(new Date().getTime());
            main.setPubdate(time);
 
            // 查询发布人对应的单位ID
            OrgUnit orgUnit = orgUserService.getDefaultUnit(userid);
            if(orgUnit != null) {
                main.setPubunitid(orgUnit.getUnitid().intValue());
            } else {
                main.setPubunitid(0);
            }
 
            main.setCreateuserid(userid);
            main.setCreatedate(time);
            main.setLasteditdate(time);
 
            main.setSharprotocol("完全公开");
            main.setEspproxy(0);
            main.setResourcestatus(0);
            main.setAuditstatus(0);
            main.setDisplayby2d(0);
            main.setDisplayby3d(0);
 
            resMainInfoService.insertSelective(main);
            resourceid = resMainInfoService.queryResMainInfoIdentCurrent();
            Res_ExtBusinessLayer info = new Res_ExtBusinessLayer();
            info.setResourceid(resourceid);
            info.setPublishsoft(publishsoft);
            info.setLayername(layername);
            info.setAdvancequeryurl(advancequeryurl);
            info.setDataloadtype(dataloadtype);
            info.setDiyqueryurl(diyqueryurl);
            info.setDiybubbleurl(diybubbleurl);
            resExtBusinessLayerService.insert(info);
 
            Res_ExtMapUrl res_extMapUrl = new Res_ExtMapUrl();
            res_extMapUrl.setResourceid(resourceid);
            res_extMapUrl.setServerurl(serverurl);
            res_extMapUrl.setTypeandurl(typeandurl);
            resExtMapUrlService.insertSelective(res_extMapUrl);
        }
        return resourceid;
    }
}