管道基础大数据平台系统开发-【后端】-Server
1
13693261870
2023-02-27 cec8c5738686bd16d17ae37455b85069e6babe29
src/main/java/com/lf/server/controller/all/CrdsController.java
@@ -2,18 +2,23 @@
import com.lf.server.annotation.SysLog;
import com.lf.server.entity.all.ResponseMsg;
import com.lf.server.entity.all.StaticData;
import com.lf.server.entity.data.DirEntity;
import com.lf.server.helper.HttpHelper;
import com.lf.server.helper.StringHelper;
import com.lf.server.service.data.DirService;
import com.lf.server.service.sys.RoleService;
import com.lf.server.service.sys.TokenService;
import com.lf.server.service.sys.UserService;
import com.lf.server.service.data.FmeService;
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;
/**
@@ -25,27 +30,24 @@
@RequestMapping("/crds")
public class CrdsController extends BaseController {
    @Autowired
    UserService userService;
    @Autowired
    RoleService roleService;
    @Autowired
    TokenService tokenService;
    @Autowired
    DirService dirService;
    @Autowired
    FmeService fmeService;
    @SysLog()
    @ApiOperation(value = "查询项目")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "name", value = "名称", dataType = "String", paramType = "query", example = "西")
    })
    @GetMapping(value = "/selectProject")
    public ResponseMsg<List<DirEntity>> selectProject() {
    public ResponseMsg<List<DirEntity>> selectProject(String name) {
        try {
            List<DirEntity> list = dirService.selectProject();
            List<DirEntity> list = dirService.selectProject(name);
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            return fail(ex, null);
        }
    }
@@ -58,7 +60,80 @@
            return success(list);
        } catch (Exception ex) {
            return fail(ex.getMessage(), null);
            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);
        }
    }
}