| | |
| | | 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.HttpHelper; |
| | | import com.lf.server.helper.PathHelper; |
| | | import com.lf.server.helper.StringHelper; |
| | | import com.lf.server.service.data.FmeService; |
| | | import io.swagger.annotations.ApiImplicitParam; |
| | |
| | | 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; |
| | | |
| | |
| | | return fail("id不能为空"); |
| | | } |
| | | |
| | | Object obj = fmeService.getTaskStatus(id, req); |
| | | |
| | | return obj; |
| | | return fmeService.getTaskStatus(id, req); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | if (!StringHelper.isEmpty(id)) { |
| | | String url = fmeService.getDownloadUrl(id, req); |
| | | res.sendRedirect(url); |
| | | |
| | | 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) { |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | | @SysLog() |
| | | @ApiOperation(value = "查询元数据检查") |
| | | @ApiOperation(value = "查询源数据检查") |
| | | @GetMapping(value = "/selectCheckMeta") |
| | | public ResponseMsg<Object> selectCheckMeta(HttpServletRequest req) { |
| | | try { |
| | |
| | | fme.name = StringHelper.getGuid(); |
| | | fme.xmmc = "西气东输四线天然气管道工程(吐鲁番-中卫)(00116BT02)"; |
| | | fme.sjzy = "测量专业"; |
| | | fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\元数据检查.zip"; |
| | | fme.zipPath = "D:\\Project\\Data\\LF\\temp\\20230107010101\\源数据检查.zip"; |
| | | |
| | | String rs = fmeService.checkMeta(fme, req); |
| | | if (StringHelper.isEmpty(rs)) { |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | return success(rs); |
| | | } catch (Exception ex) { |
| | | return fail(ex.getMessage(), null); |
| | | return fail(ex, null); |
| | | } |
| | | } |
| | | }*/ |
| | | } |