月球大数据地理空间分析展示平台-【后端】-月球后台服务
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
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
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
package com.moon.server.controller.data.upload;
 
import com.moon.server.annotation.SysLog;
import com.moon.server.controller.all.BaseController;
import com.moon.server.entity.all.ResponseMsg;
import com.moon.server.entity.all.StaticData;
import com.moon.server.entity.ctrl.FmeReqEntity;
import com.moon.server.entity.ctrl.RegisterEntity;
import com.moon.server.helper.HttpHelper;
import com.moon.server.helper.PathHelper;
import com.moon.server.helper.StringHelper;
import com.moon.server.service.data.FmeService;
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.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.ResponseBody;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
 
/**
 * 检查控制器
 * @author WWW
 */
public class CheckController extends BaseController {
    @Autowired
    protected PathHelper pathHelper;
 
    @Autowired
    protected FmeService fmeService;
 
    @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 = "id", value = "任务ID", dataType = "String", paramType = "query", example = "29db09ee-2aae-4c62-bec0-0b5c5d8084e4")
    })
    @GetMapping(value = "/downloadResult")
    public void downloadResult(String id, HttpServletRequest req, HttpServletResponse res) {
        try {
            if (!StringHelper.isEmpty(id)) {
                String url = fmeService.getDownloadUrl(id, req);
 
                HttpHelper httpHelper = new HttpHelper();
                // res.sendRedirect(url)
                httpHelper.service(req, res, url, null);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "提交数据质检")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "entity", value = "FME请求实体类", dataType = "FmeReqEntity", paramType = "body")
    })
    @ResponseBody
    @PostMapping(value = "/uploadChecks")
    public ResponseMsg<Object> uploadChecks(@RequestBody FmeReqEntity entity, HttpServletRequest req) {
        try {
            if (StringHelper.isEmpty(entity.names)) {
                return fail("任务名称不能为空");
            }
            if (StringHelper.isEmpty(entity.zipPath)) {
                return fail("请选择待质检的zip文件");
            }
 
            entity.zipPath = getFullPath(entity.zipPath);
            if (!isZipFile(entity.zipPath)) {
                return fail("待质检的zip文件不存在");
            }
            if (entity.names.contains(StaticData.CHECK_MAIN)) {
                entity.wbsPath = getFullPath(entity.wbsPath);
                if (!isXlsFile(entity.wbsPath)) {
                    return fail("待质检的WBS文件不存在");
                }
            }
 
            List<String> list = new ArrayList<>();
            for (String name : entity.names.split(StaticData.COMMA)) {
                String guid = invoke(name, entity, req);
                list.add(guid);
            }
 
            return success(list);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    /**
     * 获取文件路径
     */
    private String getFullPath(String filePath) {
        return null == filePath ? null : pathHelper.getConfig().getTempPath() + File.separator + filePath;
    }
 
    /**
     * 是/否为Zip文件
     */
    private boolean isZipFile(String filePath) {
        if (null == filePath || !filePath.toLowerCase().endsWith(StaticData.ZIP)) {
            return false;
        }
 
        File zipFile = new File(filePath);
 
        return zipFile.exists() && !zipFile.isDirectory();
    }
 
    /**
     * 是/否为Excel文件
     */
    private boolean isXlsFile(String filePath) {
        if (null == filePath) {
            return false;
        }
        if (!(filePath.toLowerCase().endsWith(StaticData.XLS) || filePath.toLowerCase().endsWith(StaticData.XLSX))) {
            return false;
        }
 
        File zipFile = new File(filePath);
 
        return zipFile.exists() && !zipFile.isDirectory();
    }
 
    /**
     * 方法调用
     */
    private String invoke(String name, FmeReqEntity entity, HttpServletRequest req) throws Exception {
        Method method;
        try {
            method = FmeService.class.getDeclaredMethod(name, FmeReqEntity.class, HttpServletRequest.class);
        } catch (Exception ex) {
            throw new Exception(name + ",该检查方法不存在");
        }
 
        Object obj = method.invoke(fmeService, entity, req);
 
        return null == obj ? null : obj.toString();
    }
 
    /*@SysLog()
    @ApiOperation(value = "查询OSGB检查")
    @GetMapping(value = "/selectCheckOsgb")
    public ResponseMsg<Object> selectCheckOsgb(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\OSGB检查.zip";
            fme.imgResolution = 0.2;
 
            String rs = fmeService.checkOsgb(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询表格数据检查")
    @GetMapping(value = "/selectCheckXls")
    public ResponseMsg<Object> selectCheckXls(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\表格数据检查.zip";
 
            String rs = fmeService.checkXls(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询点云检查")
    @GetMapping(value = "/selectCheckLaz")
    public ResponseMsg<Object> selectCheckLaz(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\点云检查.zip";
            fme.lazDensity = 1;
 
            String rs = fmeService.checkLaz(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询高程检查")
    @GetMapping(value = "/selectCheckDem")
    public ResponseMsg<Object> selectCheckDem(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\高程检查.zip";
            fme.demTolerance = 5;
            fme.demChangeRate = 200;
 
            String rs = fmeService.checkDem(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询属性检查")
    @GetMapping(value = "/selectCheckAttrs")
    public ResponseMsg<Object> selectCheckAttrs(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\属性检查.zip";
 
            String rs = fmeService.checkAttrs(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询拓扑检查")
    @GetMapping(value = "/selectCheckTopology")
    public ResponseMsg<Object> selectCheckTopology(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\拓扑检查.zip";
            fme.polyTolerance = 0.001;
            fme.lineTolerance = 0.001;
            fme.pointTolerance = 0.001;
            fme.gcdOffset = 20;
            fme.kzdOffset = 100;
            fme.rangeOffset = 200;
            fme.xgMax = 0.005;
 
            String rs = fmeService.checkTopology(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询图面整饰检查")
    @GetMapping(value = "/selectCheckDecorate")
    public ResponseMsg<Object> selectCheckDecorate(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\图面整饰检查.zip";
            fme.xlsList = "D:\\Project\\Data\\LF\\temp\\20230107010101\\文件清单.xlsx";
 
            String rs = fmeService.checkDecorate(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询原点检查")
    @GetMapping(value = "/selectCheckOrigin")
    public ResponseMsg<Object> selectCheckOrigin(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\原点检查.zip";
 
            String rs = fmeService.checkOrigin(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询栅格检查")
    @GetMapping(value = "/selectCheckDom")
    public ResponseMsg<Object> selectCheckDom(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\栅格检查.zip";
            fme.coordinateSystem = "CGCS2000/GK3d-93E_FME";
            fme.imgResolution = 0.2;
 
            String rs = fmeService.checkDom(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询数学基础检查")
    @GetMapping(value = "/selectCheckMath")
    public ResponseMsg<Object> selectCheckMath(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\数学基础检查.zip";
 
            String rs = fmeService.checkMath(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询元数据检查")
    @GetMapping(value = "/selectCheckMeta")
    public ResponseMsg<Object> selectCheckMeta(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\元数据检查.zip";
 
            String rs = fmeService.checkMeta(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "查询总质检")
    @GetMapping(value = "/selectCheckMain")
    public ResponseMsg<Object> selectCheckMain(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02).7z";
            fme.wbsPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\项目WBS导出.xlsx";
            fme.isDiZai = "NO";
            fme.diZaiType = "NO";
 
            String rs = fmeService.checkMain(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "逻辑一致性检查")
    @GetMapping(value = "/checkLogical")
    public ResponseMsg<Object> checkLogical(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.zipPath = "D:\\LF\\temp\\20230411\\数字化成果.zip";
 
            String rs = fmeService.checkLogical(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "单项成果完整性检查")
    @GetMapping(value = "/checkSingleIntegrity")
    public ResponseMsg<Object> checkSingleIntegrity(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.sjzy = "测量专业";
            fme.sjfl = "数字化成果";
            fme.zipPath = "D:\\LF\\temp\\20230411\\数字化成果.zip";
 
            String rs = fmeService.checkSingleIntegrity(fme, req);
            if (StringHelper.isEmpty(rs)) {
                return fail("检查失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }*/
 
    @SysLog()
    @ApiOperation(value = "服务注册")
    @GetMapping(value = "/selectServerRegister")
    public ResponseMsg<Object> selectServerRegister(HttpServletRequest req) {
        try {
            RegisterEntity rs = fmeService.serverRegister("西气东输四线天然气管道工程(吐鲁番-中卫)(00116DT02)", "http://127.0.0.1/LFData/2d/tiles/01/{z}/{x}/{y}.png", "DOM", req);
            if (null == rs || StringHelper.isEmpty(rs.getSerialnum())) {
                return fail("失败");
            }
 
            return success(rs);
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "服务申请")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务ID", dataType = "String", paramType = "query", example = "195f77eb-19dd-4e34-afc1-fcff8f758f7b"),
            @ApiImplicitParam(name = "pubid", value = "发布ID", dataType = "Integer", paramType = "query", example = "1"),
    })
    @GetMapping(value = "/selectServerApply")
    public ResponseMsg<Object> selectServerApply(String id, Integer pubid, HttpServletRequest req) {
        try {
            fmeService.serverApply(id, pubid, req);
 
            return success("OK");
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
 
    @SysLog()
    @ApiOperation(value = "删除资源")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "服务ID", dataType = "String", paramType = "query", example = "6f4b6783-4b98-4d46-a0d9-43cdb5f339dc")
    })
    @GetMapping(value = "/selectDeleteRes")
    public ResponseMsg<Object> selectDeleteRes(String id, HttpServletRequest req) {
        try {
            fmeService.deleteRes(id, req);
 
            return success("OK");
        } catch (Exception ex) {
            return fail(ex, null);
        }
    }
}