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
package com.landtool.lanbase.modules.api.controller.MapPortal;
 
import java.util.ArrayList;
import java.util.HashMap;
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.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
 
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.landtool.lanbase.modules.api.utils.PageBean;
import com.landtool.lanbase.modules.res.entity.Res_Template;
import com.landtool.lanbase.modules.res.service.ResTemplateService;
 
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
 
@Controller
@RequestMapping("api/maptemplate")
@Api(value = "", tags = {"专题制图地图出图打印模板接口"})
public class MapTemplateController {
    @Autowired
    private ResTemplateService resTemplateService;
    
    @ResponseBody
    @GetMapping("getTemplateList")
    @ApiOperation(value = "获取出图模板信息", notes = "")
    public String getTemplateList(HttpServletRequest request, PageBean pageBean, Res_Template resTemplate, String scal) {
        if (scal != null && !"".equals(scal)) {
            String[] scale = scal.split("-");
            Integer scalemin = Integer.valueOf(scale[0]);
            Integer scalemax = Integer.valueOf(scale[1]);
            resTemplate.setScalemin(scalemin);
            resTemplate.setScalemax(scalemax);
        }
        String callbackFunName = request.getParameter("callback");
        if (callbackFunName == null || callbackFunName.isEmpty()) {
            callbackFunName = "callback";
        }
        pageBean.setLimit(10);
        PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());//设置当前页数及每页条数
        List<Res_Template> resTemplateList = resTemplateService.selectResTemplate(resTemplate);
        int countNums = (int) ((Page) resTemplateList).getTotal();//获取记录总数
        PageBean<Res_Template> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(resTemplateList);
        
        List<Map<String, Object>> templateList = new LinkedList<>();
        List list = new ArrayList();
        //rsb.append("[");
        for (int i = 0; i < resTemplateList.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("rtid", resTemplateList.get(i).getRtid());
            map.put("rtname", resTemplateList.get(i).getRtname());
            map.put("businesstype", resTemplateList.get(i).getBusinesstype());
            map.put("scalemin", resTemplateList.get(i).getScalemin());
            map.put("scalemax", resTemplateList.get(i).getScalemax());
            map.put("paperstyle", resTemplateList.get(i).getPaperstyle());
            map.put("paperdirection", resTemplateList.get(i).getPaperdirection());
            map.put("chartcontent", resTemplateList.get(i).getChartcontent());
            map.put("mapsize", resTemplateList.get(i).getMapsize());
            map.put("templatetype", resTemplateList.get(i).getTemplatetype());
            templateList.add(map);
            boolean flag = true;
            for (int j = 0; j < list.size(); j++) {
                if (list.get(j).toString().equals(resTemplateList.get(i).getScalemin() + "-" + resTemplateList.get(i).getScalemax())) {
                    flag = false;
                }
            }
            if (flag || list.size() == 0) {
                list.add(resTemplateList.get(i).getScalemin() + "-" + resTemplateList.get(i).getScalemax());
            }
        }
        Map<String, Object> result = new HashMap<>();
        result.put("Count", countNums);
        result.put("Page", pageBean.getPage());
        result.put("ShuJu", templateList);
        result.put("Scal", list);
        
        return callbackFunName + "(" + JSON.toJSONString(result, SerializerFeature.WriteMapNullValue) + ")";
    }
    
    @ResponseBody
    @GetMapping("getTemplateById")
    @ApiOperation(value = "获取出图模板信息", notes = "")
    public String getTemplateById(Integer rtid) {
        Res_Template resTemplate = resTemplateService.selectResTemplateByRtId(rtid);
        List<Map<String, Object>> maps = new LinkedList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("paperdirection", resTemplate.getPaperdirection());
        map.put("rtname", resTemplate.getRtname());
        map.put("scale", resTemplate.getScalemin() + "-" + resTemplate.getScalemax());
        map.put("paperstyle", resTemplate.getPaperstyle());
        map.put("chartcontent", resTemplate.getChartcontent());
        map.put("templatetype", resTemplate.getTemplatetype());
        maps.add(map);
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    @ResponseBody
    @GetMapping("selectTemplate")
    public String selectTemplate(Res_Template resTemplate) {
        List<Res_Template> resTemplates = resTemplateService.selectResTemplate(resTemplate);
        List<Map<String, Object>> list = new LinkedList<>();
        for (int i = 0; i < resTemplates.size(); i++) {
            Map<String, Object> map = new HashMap<>();
            map.put("rtid", resTemplates.get(i).getRtid());
            map.put("rtname", resTemplates.get(i).getRtname());
            map.put("businesstype", resTemplates.get(i).getBusinesstype());
            map.put("scalemin", resTemplates.get(i).getScalemin());
            map.put("scalemax", resTemplates.get(i).getScalemax());
            map.put("paperstyle", resTemplates.get(i).getPaperstyle());
            map.put("paperdirection", resTemplates.get(i).getPaperdirection());
            map.put("chartcontent", resTemplates.get(i).getChartcontent());
            list.add(map);
        }
        
        return JSON.toJSONString(list, SerializerFeature.WriteMapNullValue);
    }
}