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
package com.landtool.lanbase.modules.api.controller;
 
import com.alibaba.excel.EasyExcel;
import com.alibaba.fastjson.JSONObject;
import com.landtool.lanbase.modules.res.entity.Res_ExtMapUrl;
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
import com.landtool.lanbase.modules.terra.GisService;
import com.landtool.lanbase.modules.terra.GisServiceListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;
 
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
import java.util.*;
import java.util.function.Consumer;
 
@RestController
@RequestMapping("/manage")
@CrossOrigin
public class ManagerController {
    
 
    @Autowired
    ResExtMapUrlService ResExtMapUrlService;
 
 
    // http://www.nmsmp.com:8082/res/ziYuanInsert
     @RequestMapping(value="/batchRegister",method = RequestMethod.GET)
     public @ResponseBody void batchRegister(HttpServletRequest request,HttpServletResponse httpresponse) throws IOException, URISyntaxException
     {
     
 
        
     }     
     @RequestMapping(value="/test",method = RequestMethod.POST)
    public @ResponseBody String batchimportUser(@RequestParam(value="file") MultipartFile uploadfile,String tgc,String jsession) throws Exception {
          if(uploadfile.isEmpty()){
              return "file is empty";
          }
          String filename=uploadfile.getOriginalFilename();
          String suffixname=filename.substring(filename.lastIndexOf("."));
          filename=UUID.randomUUID()+suffixname;
          File file =new File("D:/upload/"+filename);
          uploadfile.transferTo(file);
         EasyExcel.read(file, GisService.class,new GisServiceListener(tgc,jsession)).doReadAll();
        
        return "操作成功" ;
    }
    @RequestMapping(value="/ok",method = RequestMethod.GET)
    public @ResponseBody String ok(HttpServletResponse httpresponse,String tgc,String jsession) throws Exception {
        Cookie cookie=new Cookie("TGC", tgc);
        cookie.setPath("/cas/");
        cookie.setMaxAge(86400);
        
        httpresponse.addCookie(cookie);
        Cookie cookie1=new Cookie("JSESSIONID", jsession);
        
        cookie.setMaxAge(86400);
        
        httpresponse.addCookie(cookie1);
        
        return "操作成功" ;
    }
    
    
    @RequestMapping(value="/batchProxyUpdate",method = RequestMethod.GET)
    public @ResponseBody String updateResource(HttpServletResponse httpresponse,String resids) throws Exception {
        //获取数据库数据
        List<Integer> list=new ArrayList<>();
        List<Map> urls=new ArrayList<>();
        String[] resarray=resids.split(",");
        for (String str : resarray) {
            list.add(Integer.valueOf(str));
        }
        if(!list.isEmpty()){
        urls=ResExtMapUrlService.selectBatchUrl(list);
     
        urls.forEach(new Consumer<Map>() {
 
            @Override
            public void accept(Map t) {
                
                   layersProxy( t);
            }
        });
        }
        
      
        return "操作成功" ;
    }
    public void layersProxy(Map t){
          Map<String,Object>  map=new HashMap<>();
           map.put("zyid", Integer.valueOf(t.get("RESOURCEID").toString()));
           map.put("serverUrl", t.get("SERVERURL"));
           map.put("contextPath", "");
           map.put("urlid",t.get("URLID") );
           map.put("isPublic", 1);
           map.put("suffix", 0); 
           map.put("fromsys", "HYJGPT"); 
           map.put("servername", t.get("TITLE")); 
           
           JSONObject json=  getProxyUrl(map);
           Res_ExtMapUrl res=new Res_ExtMapUrl();
           res.setUrlid(Integer.valueOf(t.get("URLID").toString()));
           res.setEsbid( json.getInteger("id"));
           res.setResourceid(Integer.valueOf(t.get("RESOURCEID").toString()));
           res.setServerurl(json.getString("proxyurl"));
           ResExtMapUrlService.updateByPrimaryKey(res);
        
    }
    
    public JSONObject getProxyUrl(Map<String,Object> map){
            JSONObject json=new JSONObject();
            try {
                String  res=com.landtool.lanbase.common.utils.HttpUtils.get("http://71.3.21.232:8066"+"/serverRegister/addArcGisServer",map);
                 json=JSONObject.parseObject(res);
                
            } catch (Exception e) {
        
                e.printStackTrace();
            }
            return json; 
             
        }
    
}