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
package com.landtool.lanbase.modules.res.controller;
 
import java.io.IOException;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
 
import javax.servlet.http.HttpServletRequest;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.landtool.lanbase.common.utils.HttpOperateUtils;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.org.entity.OrgUnit;
import com.landtool.lanbase.modules.org.service.OrgUnitService;
import com.landtool.lanbase.modules.org.service.OrgUserService;
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_ExtMapUrl;
import com.landtool.lanbase.modules.res.entity.Res_MainInfo;
import com.landtool.lanbase.modules.res.service.KeShiHuaFuWuService;
import com.landtool.lanbase.modules.res.service.ResDiyLayerInfoService;
import com.landtool.lanbase.modules.res.service.ResExtMapUrlService;
import com.landtool.lanbase.modules.res.service.ResMainInfoService;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
import com.landtool.lanbase.modules.sys.service.SysFieldvalueService;
 
@Controller
@RequestMapping("/res/KeShiHuaFuWu")
public class KeShiHuaFuWuController extends AbstractController {
    @Autowired
    private SysTemPropertyConfig sysConfig;
 
    @Autowired
    private ResMainInfoService resMainInfoService;
 
    @Autowired
    private KeShiHuaFuWuService keShiHuaFuWuService;
 
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
 
    @Autowired
    private ResDiyLayerInfoService resDiyLayerInfoService;
 
    @Autowired
    private OrgUserService orgUserService;
 
    @Autowired
    private OrgUnitService orgUnitService;
 
    @Autowired
    private SysFieldvalueService FieldUtils;
 
    @RequestMapping("Index")
    public String index(Model model) {
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("systemName", sysConfig.getAppFullName());
        model.addAttribute("gisPortal", sysConfig.getGisPortal());
        model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
        return "KeShiHuaFuWu/Index";
    }
 
    /**
     * 获取业务图层、专题地图列表
     * @param parentid 父节点ID
     * @param type     目录树类型(0:专题地图、业务集成  1:业务图层 2:基础底图)
     * @param info     查询条件
     * @return
     */
    @ResponseBody
    @RequestMapping("GetYWTCAndZTDTList")
    public String getYWTCList(String parentid, Integer type, Res_MainInfo info, HttpServletRequest request) {
        String callbackFunName = request.getParameter("callback");
        if (callbackFunName == null || callbackFunName.isEmpty()) {
            callbackFunName = "callback";
        }
 
        //alert ykm 2019/01/23  根据用户输入的信息获取相关的用户ID
        if(info.getCreateuserid() == null && info.getFaburen() != null && !info.getFaburen().equals("")) {
            String name = getUserIds(info.getFaburen());
            info.setFaburen(name);
        }
        if(info.getCreateuserid() != null) {
            info.setFaburen(null);
        }
 
        Long userId = getUserId(); //获取用户ID
 
        StringBuilder resCatalogJson = new StringBuilder();
 
        List<Map<String, Object>> maps = new LinkedList<>(); //alert 2019/01/23
        if (parentid.indexOf("ZiYuan_") == -1) {
            Map<String, Object> map = new HashMap<>();
            map.put("parentid", parentid);
            map.put("title", info.getTitle());                  //资源名称
            map.put("createuserid", info.getCreateuserid());    //发布人
            map.put("pubdateBegin", info.getPubdateBegin());    //发布起始时间
            map.put("pubdatefinish", info.getPubdatefinish());  //发布结束时间
            map.put("iscollect", info.getIscollect());          //是否收藏
            map.put("userid", userId);                          //用户ID
 
            map.put("faburen", info.getFaburen());  //用户自己输入的发布人信息获取到的ID
 
            OrgUnit orgUnit = getUnit();                        //获取登录用户所属单位
            if (orgUnit != null) {
                map.put("unitid", orgUnit.getUnitid());         //用户单位ID
            }
            //map.put("departID", "1,2,3");                     //获取用户所属部门ID(暂无)
            map.put("type", type);                              //目录树类型
 
            List<Res_Catalog> resCatalogList = keShiHuaFuWuService.getYWTCAndZTDTCataLogList(map);// 获取子目录列表
            // 循环构造子目录节点
            for (Res_Catalog resCatalog : resCatalogList) {
                Map<String, Object> catalogmap = new HashMap<>();
                catalogmap.put("id", resCatalog.getCatlogid());
                catalogmap.put("name", resCatalog.getTitle());
                catalogmap.put("isParent", true);
                catalogmap.put("iconOpen", "./images/classicons/folderOpen.png");
                catalogmap.put("iconClose", "./images/classicons/folder.png");
                maps.add(catalogmap);
 
 
//                if (!"".equals(resCatalogJson.toString())) {
//                    resCatalogJson.append(',');
//                }
//                resCatalogJson.append("{id: " + resCatalog.getCatlogid() + ",name:'" + resCatalog.getTitle() + "', isParent: true,iconOpen:'./images/classicons/folderOpen.png',iconClose:'./images/classicons/folder.png'}");
            }
            // 获取资源类型列表
            List<Res_MainInfo> resMainInfo = keShiHuaFuWuService.getCatalogZiYuanList(map); // 获取目录下业务图层资源列表
            // 循环构造资源节点
            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) + "..";
                }
                String icon = "";
                if (resMainInfo1.getResourceclass().equals("KJ_ZTDT")) {
                    icon = "KJ_JCDT";
                } else if (resMainInfo1.getResourceclass().equals("KJ_JCDT")) {
                    icon = "JCDT";
                } else {
                    icon = resMainInfo1.getResourceclass();
                }
                String FaBuRen = orgUserService.getChinesename(resMainInfo1.getCreateuserid());//发布人
                String FaBuDanWei = orgUnitService.getUnitName((long) resMainInfo1.getPubunitid());//发布单位
 
                Map<String, Object> catalogmap = new HashMap<>();
                catalogmap.put("id", "ZiYuan_" + resMainInfo1.getResourceid());
                catalogmap.put("name", title);
                catalogmap.put("title", resMainInfo1.getTitle() + "|" + FaBuDanWei + "|" + FaBuRen);
                catalogmap.put("isParent", false);
                catalogmap.put("hidtxt", "");
                catalogmap.put("isMapUrl", isMapUrl);
                catalogmap.put("ResourceClass", resMainInfo1.getResourceclass());
                catalogmap.put("icon", "./images/classicons/" + icon + ".png");
                maps.add(catalogmap);
//                resCatalogJson.append("{icon:'./images/classicons/" + icon
//                        + ".png',id: 'ZiYuan_" + resMainInfo1.getResourceid() + "',name:'" + title + "', title: '"
//                        + resMainInfo1.getTitle() + "|" + FaBuDanWei + "|" + FaBuRen
//                        + "',isParent:false, hidtxt: '', isMapUrl: " + isMapUrl + ", ResourceClass: '" + resMainInfo1.getResourceclass() + "'}");
            }
        } else {
            String idstr = parentid.substring(parentid.indexOf("_") + 1, parentid.length());
            Res_MainInfo resMainInfo = resMainInfoService.selectByPrimaryKey(Integer.parseInt(idstr));
            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 + "',ResourceClass:'" + resMainInfo.getResourceclass() + "', hidtxt: ''}");
 
                    Map<String, Object> catalogmap = new HashMap<>();
                    catalogmap.put("id", "Url_" + urlitem.getUrlid());
                    catalogmap.put("resourceId", idstr);
                    catalogmap.put("name", name);
                    catalogmap.put("hidtxt", "");
                    catalogmap.put("ResourceClass", resMainInfo.getResourceclass());
                    maps.add(catalogmap);
                }
            }
            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(',');
                    }
                    String ChineseName = orgUserService.getChinesename(item.getDiyuserid());
//                    resCatalogJson.append("{id: 'Diy_" + item.getDiyid() + "', resourceId: " + idstr + ",name:'"
//                            + item.getTitle() + "(" + ChineseName + ")', hidtxt: '', showDelBtn: " + (item.getDiyuserid() == userId.intValue() ? true : false) + "}");
 
                    Map<String, Object> catalogmap = new HashMap<>();
                    catalogmap.put("id", "Diy_" + item.getDiyid());
                    catalogmap.put("resourceId", idstr);
                    catalogmap.put("name", item.getTitle() + "(" + ChineseName + ")");
                    catalogmap.put("hidtxt", "");
                    catalogmap.put("showDelBtn", (item.getDiyuserid() == userId.intValue() ? true : false));
                    maps.add(catalogmap);
                }
            }
        }
        return callbackFunName + "(" + JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue) + ")";
//        return callbackFunName + "([" + resCatalogJson.toString() + "])";
    }
 
 
    //根据输入的用户名获取用户ID
    private String getUserIds(String name) {
        String url = sysConfig.getApiServer() + "/api/org/user/findUserByWord/" + URLEncoder.encode(URLEncoder.encode(name));
 
        String username = null;
        try {
            username = HttpOperateUtils.httpGet(url);
        } catch (IOException e) {
            e.printStackTrace();
        }
        JSONArray object = JSONArray.parseArray(username);
        StringBuilder t = new StringBuilder();
        if(!name.equals( "%")) {
            for (int i = 0; i < object.size(); i++) {
                if (i != 0) t.append(",");
                t.append(object.getJSONObject(i).getString("id"));
            }
        }
        if(t.toString().equals("") && !name.equals( "%")) {
            t.append("-1");
        }
        return t.toString();
    }
}