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
package com.landtool.lanbase.modules.res.controller;
 
import com.alibaba.fastjson.JSONObject;
import com.landtool.lanbase.modules.res.entity.Res_DiyLayerInfo;
import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl;
import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService;
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
import org.apache.commons.lang3.StringUtils;
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 java.util.List;
 
/**
 * @Author: lizhao
 * @Date: 2018-03-05 15:49
 * @Description:5资源支持协议与地址(RES_EXTMAPURL)
 *
 */
@Controller
@RequestMapping("/res/ResExtMapUrl")
public class ResExtMapUrlController {
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
    @Autowired
    private ResDiyLayerInfoService resDiyLayerInfoService;
 
    /**
     * 根据id 删除资源支持协议与地址列表功能
     */
    @ResponseBody
    @RequestMapping("deleteByPrimaryKey")
    public int deleteByPrimaryKey(int urlid) {
        return resExtMapUrlService.deleteByPrimaryKey(urlid);
    }
 
    /**
     * 插入资源支持协议与地址列表功能(所有元素不能为空)
     */
    @ResponseBody
    @RequestMapping("insert")
    public int insert(Res_ExtMapUrl record) {
        return resExtMapUrlService.insert(record);
    }
 
    /**
     * 插入资源支持协议与地址列表功能(可以只填写必填字段)
     */
    @ResponseBody
    @RequestMapping("insertSelective")
    public int insertSelective(Res_ExtMapUrl record) {
        return resExtMapUrlService.insertSelective(record);
    }
 
    /**
     * 根据id查询资源支持协议与地址列表
     */
    @ResponseBody
    @RequestMapping("selectByPrimaryKey")
    public Res_ExtMapUrl selectByPrimaryKey(int urlid) {
        return resExtMapUrlService.selectByPrimaryKey(urlid);
    }
 
    /**
     * 根据id更新资源支持协议与地址列表(更新部分数据)
     */
    @ResponseBody
    @RequestMapping("updateByPrimaryKeySelective")
    public int updateByPrimaryKeySelective(Res_ExtMapUrl record) {
        return resExtMapUrlService.updateByPrimaryKeySelective(record);
    }
 
    /**
     * 根据id更新资源支持协议与地址列表(更新所有数据)
     */
    @ResponseBody
    @RequestMapping("updateByPrimaryKey")
    public int updateByPrimaryKey(Res_ExtMapUrl record) {
        return resExtMapUrlService.updateByPrimaryKey(record);
    }
 
    /**
     * 更新服务路径及diylayerinfo里的content
     */
    @ResponseBody
    @RequestMapping("updateUrlByPrimaryKey")
    public String updateUrlByPrimaryKey(Res_ExtMapUrl extMapUrl, String oldurl,Integer isUpdateDiy) {
        int result = 0;
        Res_ExtMapUrl urlmodel = resExtMapUrlService.selectByPrimaryKey(extMapUrl.getUrlid());
        if (urlmodel != null) {
            urlmodel.setServerurl(extMapUrl.getServerurl());
            if(extMapUrl.getEsbid() != null && extMapUrl.getEsbid() != 0){
                urlmodel.setEsbid(extMapUrl.getEsbid());
            }
            if(extMapUrl.getOldserverurl() != null && extMapUrl.getOldserverurl().length() != 0){
                urlmodel.setOldserverurl(extMapUrl.getOldserverurl());
            }
            urlmodel.setContextpath(extMapUrl.getContextpath());
            urlmodel.setSublayer(extMapUrl.getSublayer());
            urlmodel.setAgentserverurl(extMapUrl.getAgentserverurl());
            result = resExtMapUrlService.updateByPrimaryKey(urlmodel);
            List<Res_DiyLayerInfo> diyinfoList = resDiyLayerInfoService.selectByResourceid(extMapUrl.getResourceid());
            if (isUpdateDiy == 1 && diyinfoList != null && diyinfoList.size() > 0) {
                for (Res_DiyLayerInfo info : diyinfoList) {
                    if (info.getContent().indexOf(oldurl) != -1) {//存在则替换
                        String content = info.getContent().replace(oldurl, extMapUrl.getServerurl());
                        info.setContent(content);
                        resDiyLayerInfoService.updateByPrimaryKeySelective(info);
                    }
                }
            }
        }
        return "{'result':'" + result + "'}";
    }
 
    /**
     * 检查上下文地址是否唯一
     */
    @ResponseBody
    @RequestMapping("isExistContextPath")
    public int isExistContextPath(Res_ExtMapUrl extMapUrl) {
        int result = resExtMapUrlService.isExistContextPath(extMapUrl.getContextpath());
        return result;
    }
 
    @ResponseBody
    @RequestMapping("queryResourceId")
    public String queryResourceId(String serverurl) {
        // 处理serverurl的show问题
        if (serverurl.contains("MapServer")){
            String [] split = serverurl.split("/");
            if (null != split && split.length > 0){
                String lastStr = (String)split[split.length-1];
                if (StringUtils.isNumeric(lastStr)){
                    serverurl = serverurl.replace("MapServer/"+lastStr,"MapServer"+"?layers=show:"+lastStr);
                }
            }
        }
        Res_ExtMapUrl res_extMapUrl = new Res_ExtMapUrl();
        res_extMapUrl.setServerurl(serverurl);
        Res_ExtMapUrl result = resExtMapUrlService.queryResourceId( res_extMapUrl);
        return JSONObject.toJSONString(result);
    }
}