13693261870
昨天 542a030a93de7dbc39e185d4ce355c5894e3cd5b
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
package com.terra.system.controller.show;
 
import com.terra.common.annotation.SysLog;
import com.terra.system.controller.all.BaseQueryController;
import com.terra.common.entity.all.HttpStatus;
import com.terra.common.entity.all.ResponseMsg;
import com.terra.common.entity.all.StaticData;
import com.terra.system.entity.ctrl.DownloadTileEntity;
import com.terra.system.entity.ctrl.ShpRecordEntity;
import com.terra.system.entity.data.DownloadEntity;
import com.terra.system.entity.data.MetaFileEntity;
import com.terra.system.entity.data.PublishEntity;
import com.terra.system.entity.sys.UserEntity;
import com.terra.system.helper.AesHelper;
import com.terra.common.helper.StringHelper;
import com.terra.common.helper.WebHelper;
import com.terra.system.service.all.BaseUploadService;
import com.terra.system.service.data.DownloadService;
import com.terra.system.service.data.PublishService;
import com.terra.system.service.show.InquiryService;
import com.terra.system.service.sys.TokenService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import javax.annotation.Resource;
 
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
/**
 * 查询
 * @author WWW
 */
@Tag(name = "综合展示\\查询")
@RestController
@RequestMapping("/inquiry")
public class InquiryController extends BaseQueryController {
    @Resource
    TokenService tokenService;
 
    @Resource
    BaseUploadService baseUploadService;
 
    @Resource
    InquiryService inquiryService;
 
    @Resource
    PublishService publishService;
 
    @SysLog()
    @Operation(summary = "上传Shp文件读取第一条记录的WKT")
    @ResponseBody
    @PostMapping(value = "/uploadShp")
    public ResponseMsg<ShpRecordEntity> uploadShp(HttpServletRequest req, HttpServletResponse res) {
        try {
            UserEntity ue = tokenService.getCurrentUser(req);
            if (ue == null) {
                return fail("用户未登录", null);
            }
 
            List<MetaFileEntity> list = baseUploadService.uploadData(null, null, false, req, res);
            if (list == null || list.size() < StaticData.FOUR) {
                return fail("没有找到已上传的数据或不完整", null);
            }
 
            ShpRecordEntity sr = inquiryService.readShpFirstRecord(list);
            if (sr != null && !StringHelper.isEmpty(sr.getWkt())) {
                sr.setWkt(AesHelper.encrypt(sr.getWkt()));
            }
 
            return success(sr);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @Operation(summary = "下载瓦片")
    @Parameters({
            @Parameter(name = "dt", description = "下载瓦片实体类")
    })
    @ResponseBody
    @PostMapping(value = "/downloadTiles")
    public ResponseMsg<Object> downloadTiles(@RequestBody DownloadTileEntity dt, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (null == dt || null == dt.getPubid() || StringHelper.isEmpty(dt.getPwd())) {
                return fail("发布ID和密码不能为空");
            }
            String err = dt.verifyCoords();
            if (null != err) {
                return fail(err);
            }
            if (!DownloadService.decryptPwd(dt)) {
                return fail("密码解密失败", null);
            }
 
            PublishEntity pub = publishService.selectById(dt.getPubid());
            if (null == pub) {
                return fail("发布数据不存在");
            }
 
            UserEntity ue = tokenService.getCurrentUser(req);
            String guid = inquiryService.zipTiles(dt, pub, ue);
            if (null == guid) {
                return fail("没有瓦片需要打包下载");
            }
 
            return success(guid);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @Operation(summary = "下载文件")
    @Parameters({
            @Parameter(name = "guid", description = "文件GUID", in = ParameterIn.QUERY)
    })
    @ResponseBody
    @GetMapping(value = "/downloadFile")
    public void downloadFile(String guid, HttpServletRequest req, HttpServletResponse res) {
        try {
            DownloadEntity de = downloadService.selectByGuid(guid);
            if (null == de) {
                WebHelper.writeInfo(HttpStatus.NOT_FOUND, "文件不存在", res);
                return;
            }
 
            UserEntity ue = tokenService.getCurrentUser(req);
            downlogService.updateInfos(ue, de, req);
 
            String filePath = downloadService.getDownloadFilePath(de);
            WebHelper.download(filePath, de.getName(), res);
        } catch (Exception ex) {
            WebHelper.writeInfo(HttpStatus.ERROR, ex.getMessage(), res);
        }
    }
}