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
package com.landtool.lanbase.modules.api.controller.MapPortal;
 
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.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_TempPrint;
import com.landtool.lanbase.modules.res.entity.Res_Template;
import com.landtool.lanbase.modules.res.service.ResTempPrintService;
import com.landtool.lanbase.modules.res.service.ResTemplateService;
import com.landtool.lanbase.modules.sys.controller.AbstractController;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
 
import javax.servlet.http.HttpServletRequest;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.*;
 
@Controller
@RequestMapping("/api/maptempprint/")
@Api(value = "", tags = {"专题制图地图出图打印接口"})
public class MapTempPrintController extends AbstractController {
    @Autowired
    private ResTempPrintService resTempPrintService;
    
    @Autowired
    private OrgUserService orgUserService;
    
    @Autowired
    private OrgUnitService orgUnitService;
    
    @Autowired
    private ResTemplateService resTemplateService;
    
    /**
     * 新增地图出图打印信息
     */
    @PostMapping(path = "/addMapTempPrint")
    @ApiOperation(value = "新增地图出图打印信息", notes = "")
    @ResponseBody
    public int addMapTempPrint(@ApiParam(name = "userid", value = "用户ID", required = true) @RequestParam(name = "userid") int userid, @ApiParam(name = "rtid", value = "模板ID") @RequestParam(name = "rtid") Integer rtid, @ApiParam(name = "title", value = "标题", required = true) @RequestParam(name = "title") String title, @ApiParam(name = "mapcontent", value = "地图内容", required = true) @RequestParam(name = "mapcontent") String mapcontent, @ApiParam(name = "chartcontent", value = "制图信息") @RequestParam(name = "chartcontent") String chartcontent, @ApiParam(name = "isshowlegend", value = "是否显示图例", required = true) @RequestParam(name = "isshowlegend") int isshowlegend, @ApiParam(name = "chartstyle", value = "出图格式", required = true) @RequestParam(name = "chartstyle") String chartstyle, @ApiParam(name = "chartscale", value = "出图比例", required = true) @RequestParam(name = "chartscale") String chartscale, @ApiParam(name = "chartextent", value = "出图范围") @RequestParam(name = "chartextent") String chartextent, @ApiParam(name = "isscalelocked", value = "是否锁定比例尺") @RequestParam(name = "isscalelocked") Integer isscalelocked) {
        title = title.replaceAll("\'","'").replaceAll("\"", """);
        chartcontent = chartextent.replaceAll("\'","'").replaceAll("\"", """);
        mapcontent = mapcontent.replaceAll("\'","'").replaceAll("\"", """);
        Res_TempPrint resTempPrint = new Res_TempPrint();
        resTempPrint.setUserid(userid);//用户ID
        if (rtid != null) {
            resTempPrint.setRtid(rtid);//模板ID
        }
        
        resTempPrint.setTitle(title);//标题
        if (chartcontent != null && !chartcontent.isEmpty()) {
            resTempPrint.setChartcontent(chartcontent);//制图信息
        }
        resTempPrint.setMapcontent(mapcontent);//地图内容
        resTempPrint.setIsshowlegend(isshowlegend);//是否显示图例
        resTempPrint.setChartstyle(chartstyle);//出图格式
        resTempPrint.setChartscale(chartscale);//出图比例
        resTempPrint.setAuditstatus(3); //新增添加未提交状态
        if (chartextent != null && !chartextent.isEmpty()) {
            resTempPrint.setChartextent(chartextent);//出图范围
        }
        if (isscalelocked != null) {
            resTempPrint.setIsscalelocked(isscalelocked);//是否锁定比例尺
        }
        
        Timestamp time = new Timestamp(new Date().getTime());
        resTempPrint.setChartdate(time);
        resTempPrintService.insertSelective(resTempPrint);//新增地图出图打印信息
        int objectid = resTempPrintService.queryResTempPrintIdentCurrent();//获取新增信息ID
        
        return objectid;
    }
    
    /**
     * 更新地图出图打印信息
     */
    @PostMapping("updateMapTemPrint")
    @ApiOperation(value = "更新地图出图打印信息", notes = "")
    @ResponseBody
    public int updateMapTemPrint(Res_TempPrint resTempPrint) {
        resTempPrintService.updateByPrimaryKeySelective(resTempPrint);
        return resTempPrint.getObjectid();
    }
    
    /**
     * 提交地图出图打印信息
     */
    @PostMapping("sumbitMapTemPrint")
    @ApiOperation(value = "提交地图出图打印信息", notes = "")
    @ResponseBody
    public String sumbitMapTemPrint(int objectid) {
        Res_TempPrint resTempPrint = resTempPrintService.selectByPrimaryKey(objectid);
        Map<String, Object> map = new HashMap<>();
        if (resTempPrint != null) {
            resTempPrint.setAuditstatus(2);
            resTempPrintService.updateByPrimaryKeySelective(resTempPrint);
            map.put("success", true);
            map.put("msg", "提交成功!");
        } else {
            map.put("success", false);
            map.put("msg", "提交失败!提示:出图打印信息不存在!");
        }
        
        return JSON.toJSONString(map, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 根据ID获取地图出图信息
     */
    @GetMapping("getMapPrintById")
    @ResponseBody
    public String getMapPrintById(int objid) {
        Res_TempPrint resTempPrint = resTempPrintService.selectByPrimaryKey(objid);
        OrgUser user = orgUserService.queryObject(resTempPrint.getUserid().longValue());
        String name = user.getChinesename();
        String unit = orgUserService.getDefaultUnit(user.getUserid()).getUnitname();
        //获取审核人中文名
        String auditUserName = "";
        if (resTempPrint.getAudituserid() != null) {
            OrgUser auditUser = orgUserService.queryObject(resTempPrint.getAudituserid().longValue());
            if (auditUser != null) {
                auditUserName = auditUser.getChinesename();
            }
        }
        
        Res_Template resTemplate = new Res_Template();
        if (resTempPrint.getRtid() != null) {
            resTemplate = resTemplateService.selectResTemplateByRtId(resTempPrint.getRtid());
        }
        String rtname = "";
        String templatetype = "";
        if (resTemplate != null) {
            rtname = resTemplate.getRtname();
            templatetype = resTemplate.getTemplatetype();
        } else if (resTempPrint.getRtid() == 0) {
            rtname = "MAP_ONLY";
            templatetype = "MAP_ONLY";
        }
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        List<Map<String, Object>> maps = new LinkedList<>();
        Map<String, Object> map = new HashMap<>();
        map.put("userid", resTempPrint.getUserid());
        map.put("rtid", resTempPrint.getRtid());
        map.put("rtname", rtname);
        map.put("templatetype", templatetype);
        map.put("title", resTempPrint.getTitle());
        map.put("auditstatus", resTempPrint.getAuditstatus());
        map.put("audituser", auditUserName);
        map.put("mapcontent", JSON.parseObject(resTempPrint.getMapcontent()));
        map.put("chartcontent", JSON.parseArray(resTempPrint.getChartcontent()));
        map.put("chartextent", resTempPrint.getChartextent());
        map.put("isshowlegend", resTempPrint.getIsshowlegend());
        map.put("isscalelocked", resTempPrint.getIsscalelocked());
        map.put("chartstyle", resTempPrint.getChartstyle());
        map.put("chartscale", resTempPrint.getChartscale());
        map.put("chartdate", sdf.format(resTempPrint.getChartdate()));
        map.put("username", name);
        map.put("userunit", unit);
        maps.add(map);
        
        return JSON.toJSONString(maps, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 审核地图出图打印信息
     */
    @PostMapping(path = "/auditMapTempPrint")
    @ApiOperation(value = "审核地图出图打印信息", notes = "")
    @ResponseBody
    public String auditMapTempPrint(@ApiParam(name = "objectid", value = "出图打印信息ID", required = true) @RequestParam(name = "objectid") int objectid, @ApiParam(name = "audituserid", value = "审核人ID", required = true) @RequestParam(name = "audituserid") int audituserid, @ApiParam(name = "auditopinion", value = "审核意见") String auditopinion, @ApiParam(name = "auditstatus", value = "审核结果", required = true) @RequestParam(name = "auditstatus") int auditstatus) {
        Res_TempPrint resTempPrint = resTempPrintService.selectByPrimaryKey(objectid);
        Map<String, Object> map = new HashMap<>();
        if (resTempPrint != null) {
            try {
                resTempPrint.setAudituserid(audituserid);//审核人
                resTempPrint.setAuditopinion(auditopinion);//审核意见
                resTempPrint.setAuditstatus(auditstatus);//审核结果
                Timestamp time = new Timestamp(new Date().getTime());
                resTempPrint.setAuditdate(time);//审核时间
                resTempPrintService.updateByPrimaryKeySelective(resTempPrint);
                map.put("success", true);
                map.put("msg", "审核成功!");
            } catch (Exception e) {
                map.put("success", false);
                map.put("msg", e.getMessage());
            }
        } else {
            map.put("success", false);
            map.put("msg", "出图打印信息不存在!");
        }
        
        return JSON.toJSONString(map, SerializerFeature.WriteMapNullValue);
    }
    
    /**
     * 获取出图审核信息 发布人可看自己出图审核状态,审核人可看自己及其他用户出图资源并可做审核
     * @return
     */
    @GetMapping("/getChuTuList")
    @ResponseBody
    @ApiOperation(value = "获取出图审核信息", notes = "")
    public String selectInfoList(HttpServletRequest request, PageBean pageBean) {
        String callbackFunName = request.getParameter("callback");
        String userprintaudit = request.getParameter("userprintaudit");//用户出图审核权限
        String userid = request.getParameter("userid");//用户ID
        if (callbackFunName == null || callbackFunName.isEmpty()) {
            callbackFunName = "callback";
        }
        pageBean.setLimit(10);
        PageHelper.startPage(pageBean.getPage(), pageBean.getLimit());//设置当前页数及每页条数
        
        List<Res_TempPrint> resTempPrints = null;
        Res_TempPrint res_tempPrint = new Res_TempPrint();
        String admin = "true";
        // 查询当前登陆用户是否具备出图审核权限 是:查所有 不是:查自己的
        if (userprintaudit == "false") {
            // 如果具备出图审核权限,不添加用户id,查询所有。如果不是 添加id 查询单个
            admin = "false";
            res_tempPrint.setUserid(Integer.parseInt(userid));
        }
        resTempPrints = resTempPrintService.getList(res_tempPrint);
        
        int countNums = (int) ((Page) resTempPrints).getTotal();//获取记录总数
        PageBean<Res_TempPrint> pageData = new PageBean<>(pageBean.getPage(), pageBean.getLimit(), countNums);
        pageData.setItems(resTempPrints);
        
        StringBuilder rsb = new StringBuilder();
        rsb.append("[");
        List<Map<String, Object>> maps = new LinkedList<>();
        for (int i = 0; i < resTempPrints.size(); i++) {
            Map<String, Object> remap = new HashMap<>();
            remap.put("objectid", resTempPrints.get(i).getObjectid());
            remap.put("title", resTempPrints.get(i).getTitle());
            remap.put("auditstatus", resTempPrints.get(i).getAuditstatus());
            maps.add(remap);
        }
        
        Map<String, Object> newmap = new HashMap<>();
        newmap.put("Count", countNums);
        newmap.put("Page", pageBean.getPage());
        newmap.put("isAdmin", admin);
        newmap.put("ShuJu", maps);
        
        return callbackFunName + "(" + JSON.toJSONString(newmap, SerializerFeature.WriteMapNullValue) + ")";
    }
    
    /**
     * 删除出图记录
     */
    @GetMapping("/delTempPrint")
    @ResponseBody
    @ApiOperation(value = "获取出图审核信息", notes = "")
    public String selectInfoList(@ApiParam(name = "objectid", value = "出图打印信息ID", required = true) @RequestParam(name = "objectid") int objectid) {
        Map<String, Object> map = new HashMap<>();
        try {
            resTempPrintService.deleteByPrimaryKey(objectid);
            map.put("success", true);
            map.put("msg", "删除成功!");
        } catch (Exception e) {
            map.put("success", false);
            map.put("msg", "删除失败!错误提示:" + e.getMessage());
        }
        return JSON.toJSONString(map, SerializerFeature.WriteMapNullValue);
    }
}