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
package com.landtool.lanbase.modules.res.service.impl;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import com.landtool.lanbase.common.utils.HttpUtils;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.res.entity.Res_ExtBaseMap;
import com.qiniu.util.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
 
import com.landtool.lanbase.modules.res.dao.Res_ExtMapUrlMapper;
import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl;
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
 
@Service("resExtMapUrlService")
public class ResExtMapUrlServiceImpl implements ResExtMapUrlService {
    @Autowired
    private Res_ExtMapUrlMapper resExtMapUrlMapper;
 
    @Autowired
    private SysTemPropertyConfig sysConfig;
    @Override
    public int deleteByPrimaryKey(int urlid) {
        return resExtMapUrlMapper.deleteByPrimaryKey(urlid);
    }
 
    @Override
    public int insert(Res_ExtMapUrl record) {
        return resExtMapUrlMapper.insert(record);
    }
 
    @Override
    public int insertSelective(Res_ExtMapUrl record) {
        return resExtMapUrlMapper.insertSelective(record);
    }
 
    
    @Override
    public Res_ExtMapUrl selectByPrimaryKey(int urlid) {
        return resExtMapUrlMapper.selectByPrimaryKey(urlid);
    }
 
    @Override
    public int updateByPrimaryKeySelective(Res_ExtMapUrl record) {
        return resExtMapUrlMapper.updateByPrimaryKeySelective(record);
    }
 
    @Override
    public int updateByPrimaryKey(Res_ExtMapUrl record) {
        return resExtMapUrlMapper.updateByPrimaryKey(record);
    }
 
    @Override
    public List<Res_ExtMapUrl> selectByCondition(Integer resourceid){return resExtMapUrlMapper.selectByCondition(resourceid);}
 
    @Override
    public int deleteByResourceId(Integer resourceId){return resExtMapUrlMapper.deleteByResourceId(resourceId);}
    
    @Override
    public Res_ExtMapUrl queryFirstOrderByResId(Integer resourceId) {
        return resExtMapUrlMapper.queryFirstOrderByResId(resourceId);
    }
 
    /**获取第一条服务地址*/
    @Override
    public String getFirstServerUrl(Integer resourceid) {
        String url  ="";
        List<Res_ExtMapUrl> urlList = resExtMapUrlMapper.selectByCondition(resourceid);
        if(urlList != null && urlList.size() > 0){
            url = urlList.get(0).getServerurl();
        }
        return url;
    }
 
    /**从空间服务Controller提取出来,插入资源支持协议与地址表**/
    @Override
    public void deleteAndInsertMapUrlArray(Integer resourceid,String extMapUrlStr){
        System.out.println("extMapUrlStr = " + extMapUrlStr);
        resExtMapUrlMapper.deleteByResourceId(resourceid);
        if (!extMapUrlStr.equals("")) {
//            String[] extMapUrlArray = extMapUrlStr.split("\\|");
            //插入资源支持协议与地址表
//            for (int i = 0; i < extMapUrlArray.length; i++) {
//                String[] extMapUrlArray2 = extMapUrlArray[i].split(",");
                String[] extMapUrlArray2 = extMapUrlStr.split(",");
                String typeAndUrl = extMapUrlArray2[0];
                String serverUrl = extMapUrlArray2[1];
                Integer esbid = Integer.parseInt(extMapUrlArray2[2].toString());
                Res_ExtMapUrl resExtMapUrl = new Res_ExtMapUrl();
                resExtMapUrl.setResourceid(resourceid);
                resExtMapUrl.setTypeandurl(typeAndUrl);
                if(extMapUrlArray2.length>4){
                String layertype=extMapUrlArray2[3];
                String layername=extMapUrlArray2[4];
                resExtMapUrl.setLayertype(layertype);
                resExtMapUrl.setLayername(layername);
                }
                resExtMapUrl.setServerurl(serverUrl);
                resExtMapUrl.setServername(extMapUrlStr.split("=").length>1?extMapUrlStr.split("=")[1]:"");
                if(esbid != 0) resExtMapUrl.setEsbid(esbid);
                resExtMapUrl.setIsPublic(esbid);
                String proxyurl = getProxyurl(resExtMapUrl, resourceid);
                resExtMapUrl.setServerurl(proxyurl);
                resExtMapUrl.setOldserverurl(serverUrl);
                System.out.println("resExtMapUrl = " + resExtMapUrl);
                resExtMapUrlMapper.insertSelective(resExtMapUrl);
            }
 
    }
 
    /**根据资源id获取REBids(英文逗号,分隔)**/
    @Override
    public String queryRsbidsByResourceid(Integer resourceid) {
        String oldesbids = "";
        List<Res_ExtMapUrl> oldMapUrlList = resExtMapUrlMapper.selectByCondition(resourceid);
        if (oldMapUrlList != null && oldMapUrlList.size() > 0) {
            for (int i = 0; i < oldMapUrlList.size(); i++) {
                if (oldMapUrlList.get(i).getEsbid() != null && oldMapUrlList.get(i).getEsbid() != 0) {
                    if (oldesbids.length() != 0) {
                        oldesbids += "," + oldMapUrlList.get(i).getEsbid();
                    } else {
                        oldesbids += oldMapUrlList.get(i).getEsbid();
                    }
                }
            }
        }
        return oldesbids;
    }
 
    @Override
    public int isExistContextPath(String contextPth){
        return resExtMapUrlMapper.isExistContextPath(contextPth);
    }
 
    @Override
    public List<Res_ExtMapUrl> selectAllUrl() {
        return resExtMapUrlMapper.selectAllUrl();
    }
 
    @Override
    public List<Map> selectBatchUrl(List<Integer> resourceids) {
       
        return resExtMapUrlMapper.selectBatchUrl(resourceids);
    }
 
    private   String getProxyurl(Res_ExtMapUrl record, Integer resourceid) {
        String proxyUrl=sysConfig.getProxyUrl()+"/serverRegister/addArcGisServer";
        String resourceIdStr="zyid="+resourceid;
        String serverUrlStr="serverUrl="+record.getServerurl();
        String isPublicStr= "isPublic="+record.getIsPublic();
        String fromsys= "fromsys=HYJGPT";
        String enable="enable=1";
        String servername="servername="+record.getServername();
        String s = null;
        try {
            s = HttpUtils.get(proxyUrl+"?"+
                    resourceIdStr+"&"+
                    serverUrlStr+"&"+
                    isPublicStr+"&"+
                    fromsys+"&"+
                    enable+"&"+
                    servername
            );
        } catch (Exception e) {
            e.printStackTrace();
        }
        HashMap<String,Object> result= Json.decode(s,HashMap.class);
        return (String)result.get("proxyurl");
    }
 
    @Override
    public List<Res_ExtMapUrl> checkAllUrls() {
        return resExtMapUrlMapper.checkAllUrls();
    }
 
    public static void main(String[] args) {
 
        String str="DYNAMIC,http://192.168.20.106:8066/test/2,0,,ditu,|";
        String[] split = str.split(",");
 
 
    }
 
    @Override
    public Res_ExtMapUrl queryResourceId(Res_ExtMapUrl extMapUrl) {
        return resExtMapUrlMapper.queryResourceId(extMapUrl);
    }
 
    @Override
    public void updateSpcStatus(Map<String, Object> param) {
        resExtMapUrlMapper.updateSpcStatus(param);
    }
}