月球大数据地理空间分析展示平台-【后端】-月球后台服务
13693261870
2023-06-02 c31e03f0e51214a524d3fc34d30f3459698ff625
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
package com.moon.server.controller.all;
 
import com.moon.server.annotation.SysLog;
import com.moon.server.entity.all.ResponseMsg;
import com.moon.server.entity.all.StaticData;
import com.moon.server.entity.data.DirEntity;
import com.moon.server.entity.data.MetaEntity;
import com.moon.server.helper.HttpHelper;
import com.moon.server.helper.StringHelper;
import com.moon.server.service.data.DirService;
import com.moon.server.service.data.FmeService;
import com.moon.server.service.data.MetaService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.List;
 
/**
 * CRDS系统接口
 * @author WWW
 */
@Api(tags = "系统对接\\CRDS")
@RestController
@RequestMapping("/crds")
public class CrdsController extends BaseController {
    @Autowired
    DirService dirService;
 
    @Autowired
    FmeService fmeService;
 
    @Autowired
    MetaService metaService;
 
    @SysLog()
    @ApiOperation(value = "查询项目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "西")
    })
    @GetMapping(value = "/selectProject")
    public ResponseMsg<List<DirEntity>> selectProject(String name) {
        try {
            List<DirEntity> list = dirService.selectProject(name);
 
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询项目目录树")
    @GetMapping(value = "/selectDirsForPrj")
    public ResponseMsg<List<DirEntity>> selectDirsForPrj() {
        try {
            List<DirEntity> list = dirService.selectDirsForPrj();
 
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询任务状态")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "任务ID", dataType = "String", paramType = "query", example = "29db09ee-2aae-4c62-bec0-0b5c5d8084e4")
    })
    @GetMapping(value = "/selectTaskStatus")
    public Object selectTaskStatus(String id, HttpServletRequest req) {
        try {
            if (StringHelper.isEmpty(id)) {
                return fail("id不能为空");
            }
 
            return fmeService.getTaskStatus(id, req);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "请求打包")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dirCode", value = "目录编码", dataType = "String", paramType = "01"),
            @ApiImplicitParam(name = "major", value = "专业", dataType = "String", paramType = "穿跨越"),
            @ApiImplicitParam(name = "isCut", value = "是否裁剪", dataType = "String", paramType = "NO")
    })
    @GetMapping(value = "/uploadReqPackaging")
    public ResponseMsg<Object> uploadReqPackaging(String dirCode, String major, String isCut, HttpServletRequest req) {
        try {
            boolean isMajor = StaticData.CROSSING.equals(major) || StaticData.ROUTE.equals(major);
            if (!isMajor) {
                return fail("专业只能是“穿跨越”或“线路”");
            }
 
            boolean bCut = StaticData.YES.equals(isCut) || StaticData.NO.equals(isCut);
            if (!bCut) {
                return fail("是否裁剪只能是“YES”或“NO”");
            }
 
            if (StringHelper.isEmpty(dirCode)) {
                return fail("目录编码不能为空");
            }
            DirEntity dir = dirService.selectByCode(dirCode);
            if (null == dir) {
                return fail("目录编码为" + dirCode + "的目录不存在");
            }
 
            String id = fmeService.crdsPackaging(dirCode, major, isCut, req);
 
            return success(id);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "下载文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "任务ID", dataType = "String", paramType = "query", example = "29db09ee-2aae-4c62-bec0-0b5c5d8084e4")
    })
    @GetMapping(value = "/downloadFile")
    public void downloadResult(String id, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (!StringHelper.isEmpty(id)) {
                String url = fmeService.getDownloadUrl(id, req);
 
                HttpHelper httpHelper = new HttpHelper();
                httpHelper.service(req, res, url, null);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "根据目录编码查询元数据文件")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "dircode", value = "目录编码", dataType = "String", paramType = "query", example = "01")
    })
    @GetMapping(value = "/selectMetasByDirCode")
    public ResponseMsg<Object> selectMetasByDirCode(String dircode) {
        try {
            if (StringHelper.isEmpty(dircode)) {
                return fail("目录编码不能为空");
            }
 
            List<MetaEntity> list = metaService.selectMetasByDirCode(dircode);
 
            return success(null == list ? 0 : list.size(), list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
}