霍林河露天煤矿生产一体化平台
1
13693261870
2023-04-10 dd50418315218979f8d596f34f185ae4a28adc4a
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
package com.terra.coal.controller;
 
import com.terra.coal.entity.CountEntity;
import com.terra.coal.entity.ResponseMsg;
import com.terra.coal.entity.StaticData;
import com.terra.coal.helper.StringHelper;
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 org.springframework.web.servlet.ModelAndView;
import com.terra.coal.service.MainService;
 
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.util.List;
 
/**
 * CoalController
 * @author WWW
 */
@Api(tags = "主控制器")
@RestController
@RequestMapping("/main")
public class MainController extends BaseController {
    @Autowired
    MainService mainService;
 
    @ApiOperation(value = "跳转首页")
    @GetMapping({"/", "/toIndex"})
    public ModelAndView toIndex(ModelAndView mv, HttpServletRequest req) {
        mv.setViewName("index");
 
        return mv;
    }
 
    @ApiOperation(value = "数据库监控")
    @GetMapping(value = "/toDruid")
    public ModelAndView toDruid(HttpServletRequest req, HttpServletResponse res) {
        ModelAndView mv = new ModelAndView();
        mv.setViewName("druid");
 
        return mv;
    }
 
    @ApiOperation(value = "加载54数据(入库)")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "txtPath", value = "块体数据文件路径", dataType = "String", paramType = "query", example = "D:\\块体数据.txt")
    })
    @GetMapping(value = "/load54Data")
    public ResponseMsg<Integer> load54Data(String txtPath) {
        try {
            if (StringHelper.isEmpty(txtPath)) {
                return fail("请选择‘块体数据.txt’", null);
            }
 
            File f = new File(txtPath);
            if (!f.exists() || f.isDirectory()) {
                return fail("文件不存在", null);
            }
 
            Integer rows = mainService.load54Data(f);
 
            return success("成功", rows);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return fail(ex.getMessage(), null);
        }
    }
 
    @ApiOperation(value = "根据范围统计")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "wkt", value = "WKT文本", dataType = "String", paramType = "query", example = "POLYGON ((113.5807 45.4897,113.5898 45.4893,113.5857 45.4837,113.5807 45.4897))"),
            @ApiImplicitParam(name = "z", value = "高度", dataType = "double", paramType = "query", example = "640"),
            @ApiImplicitParam(name = "deep", value = "深度", dataType = "double", paramType = "query", example = "50")
    })
    @GetMapping(value = "/countByRange")
    public ResponseMsg<Object> countByRange(String wkt, double z, double deep) {
        try {
            if (StringHelper.isEmpty(wkt)) {
                return fail("请输入查询范围(WKT字符串)", null);
            }
            if (z < StaticData.MINUS_ONE_THOUSAND || z > StaticData.NINE_THOUSAND) {
                return fail("高度值超出范围(-1000~9000)", null);
            }
            if (deep < 1) {
                return fail("开挖深度过小", null);
            }
 
            List<CountEntity> rs = mainService.countByRange("'" + wkt + "'", z, z + deep);
 
            return success("成功", rs);
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
            return fail(ex.getMessage(), null);
        }
    }
}