霍林河露天煤矿生产一体化平台
1
13693261870
2023-04-07 f49bf428e37110c2d26dc00eaeae0940b907af07
src/main/java/com/terra/coal/controller/MainController.java
@@ -1,14 +1,21 @@
package com.terra.coal.controller;
import com.terra.coal.entity.ResponseMsg;
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;
/**
 * CoalController
@@ -18,6 +25,9 @@
@RestController
@RequestMapping("/main")
public class MainController extends BaseController {
    @Autowired
    MainService mainService;
    @ApiOperation(value = "跳转首页")
    @GetMapping({"/", "/toIndex"})
    public ModelAndView toIndex(ModelAndView mv, HttpServletRequest req) {
@@ -34,4 +44,29 @@
        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);
        }
    }
}