管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-01-08 44e70ea1f80b048c80eec4a2dc7b3679ac3e3ccb
src/main/java/com/lf/server/controller/data/upload/CheckController.java
@@ -3,14 +3,21 @@
import com.lf.server.annotation.SysLog;
import com.lf.server.controller.all.BaseController;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.ctrl.FmeReqEntity;
import com.lf.server.helper.StringHelper;
import com.lf.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 javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.List;
/**
 * 检查控制器
@@ -21,6 +28,124 @@
    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不能为空");
            }
            Object obj = fmeService.getTaskStatus(id, req);
            return obj;
        } catch (Exception ex) {
            return fail(ex.getMessage(), 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);
                res.sendRedirect(url);
            }
        } catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        }
    }
    @SysLog()
    @ApiOperation(value = "提交数据质检")
    @GetMapping(value = "/uploadChecks")
    public ResponseMsg<Object> uploadChecks(FmeReqEntity entity, HttpServletRequest req) {
        try {
            if (StringHelper.isEmpty(entity.names)) {
                return fail("任务名称不能为空");
            }
            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.getMessage(), null);
        }
    }
    /**
     * 方法调用
     */
    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.name = StringHelper.getGuid();
            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.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询表格数据检查")
    @GetMapping(value = "/selectCheckXls")
    public ResponseMsg<Object> selectCheckXls(HttpServletRequest req) {
        try {
            FmeReqEntity fme = new FmeReqEntity();
            fme.name = StringHelper.getGuid();
            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.getMessage(), null);
        }
    }
    @SysLog()
    @ApiOperation(value = "查询点云检查")
    @GetMapping(value = "/selectCheckLaz")
    public ResponseMsg<Object> selectCheckLaz(HttpServletRequest req) {
@@ -28,7 +153,7 @@
            FmeReqEntity fme = new FmeReqEntity();
            fme.name = StringHelper.getGuid();
            fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\高程检查.zip";
            fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\点云检查.zip";
            fme.lazDensity = 1;
            String rs = fmeService.checkLaz(fme, req);
@@ -249,5 +374,5 @@
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
        }
    }
    }*/
}