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
package com.landtool.lanbase.modules.res.controller;
 
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
 
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 com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.landtool.lanbase.common.utils.HttpOperateUtils;
import com.landtool.lanbase.config.SysTemPropertyConfig;
import com.landtool.lanbase.modules.api.utils.PageBean;
import com.landtool.lanbase.modules.org.entity.OrgUser;
import com.landtool.lanbase.modules.org.service.OrgUnitService;
import com.landtool.lanbase.modules.org.service.OrgUserService;
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.entity.SimpleZiYuan;
import com.landtool.lanbase.modules.res.service.JiChuDiTuService;
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.ZiYuanMuLuService;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
import com.landtool.lanbase.modules.sys.service.SysFieldvalueService;
 
/**
 * 前台展示 - 资源目录
 */
@Controller
@RequestMapping("res/jichuditu")
public class JiChuDiTuController extends AbstractController {
 
    @Autowired
    private SysTemPropertyConfig sysConfig;
 
    @Autowired
    public ZiYuanMuLuService ziYuanMuLuService;
 
    @Autowired
    private SysFieldvalueService fieldUtils;
 
    @Autowired
    private ResMainInfoService resMainInfoService;
 
    @Autowired
    private OrgUserService orgUserService;
 
    @Autowired
    private OrgUnitService orgUnitService;
 
    @Autowired
    private JiChuDiTuService jiChuDiTuService;
 
    @Autowired
    private SysTemPropertyConfig sysTemPropertyConfig;
 
    @Autowired
    private ResExtThemeMapService resExtThemeMapService;
 
    @Autowired
    private ResExtMapUrlService resExtMapUrlService;
 
    @RequestMapping("/indexbak")
    public String index(Model model) {
        LinkedHashMap<String, String> ResourceTypeList = fieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
        String ResourceTypeListJson = "";
        for (Map.Entry<String, String> entry : ResourceTypeList.entrySet()) {
            if (ResourceTypeListJson != "")
                ResourceTypeListJson += ",";
            if(entry.getKey().indexOf("KJ_") != -1) {
                int countNums = 0;
                Res_MainInfo rmodel = new Res_MainInfo();
                rmodel.setResourceclass(entry.getKey());
                List<Res_MainInfo> mainInfoJoinCatalogList = jiChuDiTuService.selectResMainInfo(rmodel);
                countNums = mainInfoJoinCatalogList.size();
                ResourceTypeListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "',zycount:'" + countNums + "'}";
            }
        }
        model.addAttribute("ResourceTypeListJson", "[" + ResourceTypeListJson + "]");
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
        model.addAttribute("systemName", sysConfig.getAppFullName());
        model.addAttribute("gisPortal", sysConfig.getGisPortal());
        return "jichuditu/index";
    }
 
    @RequestMapping("/dataList")
    public String dataList(Res_MainInfo resMainInfo, Model model, PageBean pageBean) {
        //update:dsh(2018/12/05)
        Page<Res_MainInfo> page = PageHelper.startPage(pageBean.getPage(), 14);
        List<Res_MainInfo> List = jiChuDiTuService.selectResMainInfo(resMainInfo);
        OrgUser user = getUser();
        Long unitid = orgUserService.getDefaultUnit(user.getUserid()).getUnitid();
        int countNums = (int) ((Page) List).getTotal();
        PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(List);
        LinkedHashMap<String, String> ResourceTypeList = fieldUtils.getFieldListByKey("ResourceType");
        List<SimpleZiYuan> simpleZiYuans = new ArrayList<SimpleZiYuan>();
        for (Integer j = 0; j < List.size(); j++) {
            Res_MainInfo zy = List.get(j);
            SimpleZiYuan model1 = new SimpleZiYuan();
            model1.setResourceid(zy.getResourceid());
            model1.setTitle(zy.getTitle());
            model1.setCreateuserid(zy.getCreateuserid());
            String chinesename = orgUserService.getChinesename(zy.getCreateuserid());// 查询发布人id对应的 name
            String unitname = orgUnitService.getUnitName((long) zy.getPubunitid());
            model1.setCreateusername(chinesename);
            model1.setDatasources(zy.getDatasources());
            model1.setPubunitid(zy.getPubunitid());
            model1.setPubunitname(unitname);
 
            model1.setStatus(zy.getResourcestatus());
 
            model1.setKeywords(zy.getKeywords()!=null?zy.getKeywords():"");
            model1.setSecuritylev(zy.getSecuritylev());
            model1.setResourceclass(ResourceTypeList.get(zy.getResourceclass()));
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            model1.setPubdate(sdf.format(zy.getPubdate()));
            model1.setReadcount(zy.getReadcount() == null ? 0 : zy.getReadcount());
            model1.setApplycount(zy.getApplycount() == null ? 0 :zy.getApplycount());
            model1.setAuditstatusname(getNameByAuditstatus(zy.getAuditstatus()));
            model1.setResourcetype(zy.getResourceclass());
            //图片
            String imgUrl = "";
            String defClassImg = "/image/classimg/"+zy.getResourceclass()+".gif";  //默认资源类型图片
            if (zy.getImgurl() != null && zy.getImgurl().length() != 0) {
                if(zy.getImgurl().startsWith("Atkas")){//图集
                    imgUrl = "/image/" + zy.getImgurl();
                    File file = new File(System.getProperty("user.dir")+ "\\src\\main\\resources\\static" + ("/image/"+zy.getImgurl()).replace("/","\\"));
                    if (!file.exists()) {  //判断物理路径是否存在,不存在则默认
                        imgUrl = defClassImg;
                    }
                }else {
                    imgUrl = "/uploadPath/" + zy.getImgurl();
                    File file = new File(sysTemPropertyConfig.getUploadPath() + zy.getImgurl());
                    if (!file.exists()) {  //判断物理路径是否存在,不存在则默认
                        imgUrl = defClassImg;
                    }
                }
            }
            else {
                imgUrl = defClassImg;
            }
            model1.setImgurl(imgUrl);
            //关键字
            List list=new ArrayList();
            if(zy.getKeywords()!=""){
                String keywords=zy.getKeywords();
                if(keywords != null && !keywords.equals("")) {
                    String key[] = keywords.split(",");
                    for (int i = 0; i < key.length; i++) {
                        String s = key[i];
                        list.add(s);
                    }
                }
            }
            model1.setList(list);
            //判断是否有权限
            Map<String, Object> map = new HashMap<>();
            map.put("resourceid", zy.getResourceid());
            map.put("userid", getUserId());
            map.put("unitid", unitid );
            int count = resMainInfoService.checkZiYuanQuanXian(map);
            //有权限查看(1有,0没有)
            if(count>0){
                model1.setIsquanxian(1);
            }else {
                model1.setIsquanxian(0);
            }
            model1.setFirstmapurl(getZTDTByPortalMapUrl(zy.getResourceid(),zy.getResourceclass()));
            simpleZiYuans.add(model1);
        }
        model.addAttribute("ZyList", simpleZiYuans);
        model.addAttribute("Count", countNums);
        model.addAttribute("Page", pageBean.getPage());
        model.addAttribute("userid", getUserId());
        model.addAttribute("gisPortal", sysConfig.getGisPortal());
        return "jichuditu/dataList";
    }
 
    //获取用户或单位Map
    private LinkedHashMap<String, String> queryUserOrUnitList(String gettype){
        String url = sysConfig.getApiServer() + (gettype == "unit"? "/api/org/unit/queryAllList": "/api/org/user/queryAllList");
        LinkedHashMap<String, String> map = new LinkedHashMap<String, String>();
        try {
            String jsonStr = HttpOperateUtils.httpGet(url.trim());
            if(jsonStr.length() != 0){
                JSONArray list = JSON.parseArray(jsonStr);
                for(int i = 0 ;i<list.size();i++){
                    Map maps = (Map)JSON.parse(list.get(i).toString());
                    map.put(maps.get("id").toString(),maps.get("name").toString());
                }
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return map;
    }
 
    //获取状态名称
    private String getNameByAuditstatus(Integer status){
        String name = "";
        switch (status){
            case 0:
                name="未提交";
                break;
            case 1:
                name="待审核";
                break;
            case 2:
                name="已通过";
                break;
            case 3:
                name="未通过";
                break;
        }
        return name;
    }
 
    //类型为专题地图portal专题类型获取首笔协议服务路径
    private String getZTDTByPortalMapUrl(Integer resourceid,String resourceclass){
        String firstMapUrl = "";
        if(resourceid != null && resourceclass != null) {
            if (resourceclass.equals("KJ_ZTDT")) {
                Res_ExtThemeMap resExtThemeMap = resExtThemeMapService.selectByPrimaryKey(resourceid);
                if (resExtThemeMap != null && resExtThemeMap.getType() != null && resExtThemeMap.getType().equals("Portal专题")) {
                    List<Res_ExtMapUrl> urlList = resExtMapUrlService.selectByCondition(resourceid);
                    if (urlList != null && urlList.size() > 0 && urlList.get(0).getServerurl() != null)
                        firstMapUrl = urlList.get(0).getServerurl();
                }
            }
        }
        return firstMapUrl;
    }
 
 
    /**
     * 新设计
     */
 
    @RequestMapping("/index")
    public String indexNew(Model model) {
        LinkedHashMap<String, String> ResourceTypeList = fieldUtils.getFieldListByKey("ResourceType");// 获取资源类型列表
        String ResourceTypeListJson = "";
        for (Map.Entry<String, String> entry : ResourceTypeList.entrySet()) {
            if (ResourceTypeListJson != "")
                ResourceTypeListJson += ",";
            if(entry.getKey().indexOf("KJ_") != -1) {
                int countNums = 0;
                Res_MainInfo rmodel = new Res_MainInfo();
                rmodel.setResourceclass(entry.getKey());
                List<Res_MainInfo> mainInfoJoinCatalogList = jiChuDiTuService.selectResMainInfo(rmodel);
                countNums = mainInfoJoinCatalogList.size();
                ResourceTypeListJson += "{key:'" + entry.getKey() + "',value:'" + entry.getValue() + "',zycount:'" + countNums + "'}";
            }
        }
        model.addAttribute("ResourceTypeListJson", "[" + ResourceTypeListJson + "]");
        model.addAttribute("pubzyWebRoot", sysConfig.getPubzyWebRoot());
        model.addAttribute("backstageWebRoot", sysConfig.getApiServer() + "/");
        model.addAttribute("systemName", sysConfig.getAppFullName());
        model.addAttribute("gisPortal", sysConfig.getGisPortal());
 
        model.addAttribute("logourl","jichuditutitle");
        return "jichuditu/index_New";
    }
 
    @RequestMapping("/dataListNew")
    public String dataListNew(Res_MainInfo resMainInfo, Model model, PageBean pageBean) {
        //update:dsh(2018/12/05)
        Page<Res_MainInfo> page = PageHelper.startPage(pageBean.getPage(), 14);
        List<Res_MainInfo> List = jiChuDiTuService.selectResMainInfo(resMainInfo);
        OrgUser user = getUser();
        Long unitid = orgUserService.getDefaultUnit(user.getUserid()).getUnitid();
        int countNums = (int) ((Page) List).getTotal();
        PageBean<Res_MainInfo> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(List);
        LinkedHashMap<String, String> ResourceTypeList = fieldUtils.getFieldListByKey("ResourceType");
        List<SimpleZiYuan> simpleZiYuans = new ArrayList<SimpleZiYuan>();
        for (Integer j = 0; j < List.size(); j++) {
            Res_MainInfo zy = List.get(j);
            SimpleZiYuan model1 = new SimpleZiYuan();
            model1.setResourceid(zy.getResourceid());
            model1.setTitle(zy.getTitle());
            model1.setCreateuserid(zy.getCreateuserid());
            String chinesename = orgUserService.getChinesename(zy.getCreateuserid());// 查询发布人id对应的 name
            String unitname = orgUnitService.getUnitName((long) zy.getPubunitid());
            model1.setCreateusername(chinesename);
            model1.setDatasources(zy.getDatasources());
            model1.setPubunitid(zy.getPubunitid());
            model1.setPubunitname(unitname);
 
            model1.setStatus(zy.getResourcestatus());
 
            model1.setKeywords(zy.getKeywords()!=null?zy.getKeywords():"");
            model1.setSecuritylev(zy.getSecuritylev());
            model1.setResourceclass(ResourceTypeList.get(zy.getResourceclass()));
            SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
            model1.setPubdate(sdf.format(zy.getPubdate()));
            model1.setReadcount(zy.getReadcount() == null ? 0 : zy.getReadcount());
            model1.setApplycount(zy.getApplycount() == null ? 0 :zy.getApplycount());
            model1.setAuditstatusname(getNameByAuditstatus(zy.getAuditstatus()));
            model1.setResourcetype(zy.getResourceclass());
            //图片
            String imgUrl = "";
            String defClassImg = "/image/classimg/"+zy.getResourceclass()+".gif";  //默认资源类型图片
            if (zy.getImgurl() != null && zy.getImgurl().length() != 0) {
                if(zy.getImgurl().startsWith("Atkas")){//图集
                    imgUrl = "/image/" + zy.getImgurl();
                    File file = new File(System.getProperty("user.dir")+ "\\src\\main\\resources\\static" + ("/image/"+zy.getImgurl()).replace("/","\\"));
                    if (!file.exists()) {  //判断物理路径是否存在,不存在则默认
                        imgUrl = defClassImg;
                    }
                }else {
                    imgUrl = "/uploadPath/" + zy.getImgurl();
                    File file = new File(sysTemPropertyConfig.getUploadPath() + zy.getImgurl());
                    if (!file.exists()) {  //判断物理路径是否存在,不存在则默认
                        imgUrl = defClassImg;
                    }
                }
            }
            else {
                imgUrl = defClassImg;
            }
            model1.setImgurl(imgUrl);
            //关键字
            List list=new ArrayList();
            if(zy.getKeywords()!=""){
                String keywords=zy.getKeywords();
                if(keywords != null && !keywords.equals("")) {
                    String key[] = keywords.split(",");
                    for (int i = 0; i < key.length; i++) {
                        String s = key[i];
                        list.add(s);
                    }
                }
            }
            model1.setList(list);
            //判断是否有权限
            Map<String, Object> map = new HashMap<>();
            map.put("resourceid", zy.getResourceid());
            map.put("userid", getUserId());
            map.put("unitid", unitid );
            int count = resMainInfoService.checkZiYuanQuanXian(map);
            //有权限查看(1有,0没有)
            if(count>0){
                model1.setIsquanxian(1);
            }else {
                model1.setIsquanxian(0);
            }
            model1.setFirstmapurl(getZTDTByPortalMapUrl(zy.getResourceid(),zy.getResourceclass()));
            simpleZiYuans.add(model1);
        }
        model.addAttribute("ZyList", simpleZiYuans);
        model.addAttribute("Count", countNums);
        model.addAttribute("Page", pageBean.getPage());
        model.addAttribute("userid", getUserId());
        model.addAttribute("gisPortal", sysConfig.getGisPortal());
        return "jichuditu/dataList_New";
    }
}