|
@@ -4,10 +4,13 @@ import com.global.base.log.LogLevelFlag;
|
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
import com.shkpr.service.alambizplugin.apiparam.GisSurveyCheckParams;
|
|
|
import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdImportParams;
|
|
|
+import com.shkpr.service.alambizplugin.bizservice.GisSurveyCadConvertBizService;
|
|
|
import com.shkpr.service.alambizplugin.bizservice.GisSurveySystemCheckBizService;
|
|
|
import com.shkpr.service.alambizplugin.bizservice.GisSurveyThirdImportBizService;
|
|
|
import com.shkpr.service.alambizplugin.commtools.CommTool;
|
|
|
import com.shkpr.service.alambizplugin.constants.ApiURI;
|
|
|
+import com.shkpr.service.alambizplugin.constants.CadEnum;
|
|
|
+import com.shkpr.service.alambizplugin.constants.GisSurveConvertStatusEnum;
|
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyCheckStatusEnum;
|
|
|
import com.shkpr.service.alambizplugin.constants.GisSurveyImportStatusEnum;
|
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
@@ -16,6 +19,7 @@ import com.shkpr.service.alambizplugin.controllerfilter.TokenAuthenticationServi
|
|
|
import com.shkpr.service.alambizplugin.controllervalid.CommonParamValidSK;
|
|
|
import com.shkpr.service.alambizplugin.dbdao.services.GisSurveyLayerApplyThirdCopyServiceImpl;
|
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
|
|
|
+import com.shkpr.service.alambizplugin.dto.GisSurveyCadConvertResult;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveySystemCheckResult;
|
|
|
import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResult;
|
|
@@ -55,14 +59,18 @@ public class ApiGisSurveyController {
|
|
|
private final AtomicInteger mSeqThirdImportCancelReq;
|
|
|
private final AtomicInteger mSeqThirdImportPreviewReq;
|
|
|
private final AtomicInteger mSeqThirdImportCommitReq;
|
|
|
+ private final AtomicInteger mSeqCadConvertReq;
|
|
|
+ private final AtomicInteger mSeqCadConvertResultReq;
|
|
|
|
|
|
private final GisSurveySystemCheckBizService systemCheckBizService;
|
|
|
private final GisSurveyThirdImportBizService thirdImportBizService;
|
|
|
+ private final GisSurveyCadConvertBizService cadConvertBizService;
|
|
|
private final GisSurveyLayerApplyService layerApplyService;
|
|
|
private final GisSurveyLayerApplyThirdCopyServiceImpl layerApplyThirdCopyService;
|
|
|
|
|
|
public ApiGisSurveyController(GisSurveySystemCheckBizService systemCheckBizService
|
|
|
- , GisSurveyThirdImportBizService thirdImportBizService, GisSurveyLayerApplyService layerApplyService
|
|
|
+ , GisSurveyThirdImportBizService thirdImportBizService, GisSurveyCadConvertBizService cadConvertBizService
|
|
|
+ , GisSurveyLayerApplyService layerApplyService
|
|
|
, GisSurveyLayerApplyThirdCopyServiceImpl layerApplyThirdCopyService) {
|
|
|
mStrClassName = "ApiGisSurveyController";
|
|
|
mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
|
|
@@ -72,8 +80,11 @@ public class ApiGisSurveyController {
|
|
|
mSeqThirdImportCancelReq = new AtomicInteger(0);
|
|
|
mSeqThirdImportPreviewReq = new AtomicInteger(0);
|
|
|
mSeqThirdImportCommitReq = new AtomicInteger(0);
|
|
|
+ mSeqCadConvertReq = new AtomicInteger(0);
|
|
|
+ mSeqCadConvertResultReq = new AtomicInteger(0);
|
|
|
this.systemCheckBizService = systemCheckBizService;
|
|
|
this.thirdImportBizService = thirdImportBizService;
|
|
|
+ this.cadConvertBizService = cadConvertBizService;
|
|
|
this.layerApplyService = layerApplyService;
|
|
|
this.layerApplyThirdCopyService = layerApplyThirdCopyService;
|
|
|
}
|
|
@@ -491,4 +502,179 @@ public class ApiGisSurveyController {
|
|
|
, resResult.getTimestamp() - llReqBefore));
|
|
|
return resResult;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 执行cad转换
|
|
|
+ *
|
|
|
+ * @param request request
|
|
|
+ * @param strClientType 客户端类型
|
|
|
+ * @param strUserAgent 用户信息
|
|
|
+ * @param file 文件
|
|
|
+ * @param convertId 转换id
|
|
|
+ * @param outputExtension 输出扩展名
|
|
|
+ * @return cad转换结果
|
|
|
+ */
|
|
|
+ @PostMapping(value = ApiURI.URI_XXX_CAD_CONVERT)
|
|
|
+ public ResponseRes<GisSurveyCadConvertResult> cadConvert(HttpServletRequest request
|
|
|
+ , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
|
|
|
+ , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
|
|
|
+ , @RequestParam(value = "file", required = false) MultipartFile file
|
|
|
+ , @RequestParam(value = "convertId", required = false) String convertId
|
|
|
+ , @RequestParam(value = "outputExtension", required = false) String outputExtension) throws SelfException {
|
|
|
+ //入参校验
|
|
|
+ final String URI_PATH = request.getRequestURI();
|
|
|
+ final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
|
|
|
+ final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
|
|
|
+ if (StringUtils.isAnyBlank(convertId) || StringUtils.length(convertId) > 64) {
|
|
|
+ throw new SelfException(ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrCode()
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrMsg()));
|
|
|
+ }
|
|
|
+ //文件校验
|
|
|
+ if (file == null || file.isEmpty()) {
|
|
|
+ throw new SelfException(ResponseCode.RESULT_FILE_EMPTY_ROWS.toStrCode()
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , ResponseCode.RESULT_FILE_EMPTY_ROWS.toStrMsg()));
|
|
|
+ }
|
|
|
+ String originalFilename = file.getOriginalFilename();
|
|
|
+ if (originalFilename == null) {
|
|
|
+ throw new SelfException(ResponseCode.RESULT_FILE_EMPTY_ROWS.toStrCode()
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , ResponseCode.RESULT_FILE_EMPTY_ROWS.toStrMsg()));
|
|
|
+ }
|
|
|
+ //文件类型校验
|
|
|
+ String inputExtension = originalFilename
|
|
|
+ .substring(originalFilename.lastIndexOf(".") + 1)
|
|
|
+ .toLowerCase();
|
|
|
+ CadEnum inputCadEnum = CadEnum.getCadEnum(inputExtension);
|
|
|
+ CadEnum outCadEnum = CadEnum.getCadEnum(outputExtension);
|
|
|
+ if (inputCadEnum == null || outCadEnum == null
|
|
|
+ || !inputCadEnum.getInput() || !outCadEnum.getOutput()) {
|
|
|
+ throw new SelfException(ResponseCode.RESULT_FILE_INVALID_TYPE.toStrCode()
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , ResponseCode.RESULT_FILE_INVALID_TYPE.toStrMsg()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //begin
|
|
|
+ long llReqBefore = System.currentTimeMillis();
|
|
|
+ String strRunSeq = String.format("%d-%d", llReqBefore, mSeqCadConvertReq.incrementAndGet());
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
|
|
|
+ , String.format("%s:%s seq:{%s} param:%s begin====>"
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , strRunSeq
|
|
|
+ , convertId));
|
|
|
+
|
|
|
+ //构建result
|
|
|
+ ResponseRes<GisSurveyCadConvertResult> resResult = new ResponseRes<>();
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrCode());
|
|
|
+ resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrMsg());
|
|
|
+
|
|
|
+ //执行cad转换
|
|
|
+ GisSurveyCadConvertResult result = cadConvertBizService.cadConvert(file, convertId, outCadEnum);
|
|
|
+
|
|
|
+ //执行成功
|
|
|
+ if (result != null && !Objects.equals(result.getConvertStatus(), GisSurveConvertStatusEnum.FAIL.getCode())) {
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
+ resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
|
+ resResult.setResdata(result);
|
|
|
+ }
|
|
|
+ //执行失败
|
|
|
+ if (result != null && Objects.equals(result.getConvertStatus(), GisSurveConvertStatusEnum.FAIL.getCode())) {
|
|
|
+ resResult.setResdata(result);
|
|
|
+ }
|
|
|
+
|
|
|
+ //end
|
|
|
+ resResult.setTimestamp(System.currentTimeMillis());
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
|
|
|
+ , String.format("%s:%s seq:{%s} rescode:{%s} resmsg:{%s} time:{%d ms} end<===="
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , strRunSeq
|
|
|
+ , resResult.getRescode()
|
|
|
+ , resResult.getResmsg()
|
|
|
+ , resResult.getTimestamp() - llReqBefore));
|
|
|
+ return resResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取cad转换结果
|
|
|
+ *
|
|
|
+ * @param request request
|
|
|
+ * @param strClientType 客户端类型
|
|
|
+ * @param strUserAgent 用户信息
|
|
|
+ * @param convertId 转换id
|
|
|
+ * @return cad转换结果
|
|
|
+ */
|
|
|
+ @GetMapping(value = ApiURI.URI_XXX_CAD_CONVERT_GET)
|
|
|
+ public ResponseRes<GisSurveyCadConvertResult> cadConvertResult(HttpServletRequest request
|
|
|
+ , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
|
|
|
+ , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
|
|
|
+ , @RequestParam(value = "convertId", required = false) String convertId) throws SelfException {
|
|
|
+ //入参校验
|
|
|
+ final String URI_PATH = request.getRequestURI();
|
|
|
+ final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
|
|
|
+ final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
|
|
|
+ if (StringUtils.isAnyBlank(convertId) || StringUtils.length(convertId) > 64) {
|
|
|
+ throw new SelfException(ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrCode()
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrMsg()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //begin
|
|
|
+ long llReqBefore = System.currentTimeMillis();
|
|
|
+ String strRunSeq = String.format("%d-%d", llReqBefore, mSeqCadConvertResultReq.incrementAndGet());
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
|
|
|
+ , String.format("%s:%s seq:{%s} param:%s begin====>"
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , strRunSeq
|
|
|
+ , convertId));
|
|
|
+
|
|
|
+ //构建result
|
|
|
+ ResponseRes<GisSurveyCadConvertResult> resResult = new ResponseRes<>();
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrCode());
|
|
|
+ resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrMsg());
|
|
|
+
|
|
|
+ //执行cad转换
|
|
|
+ GisSurveyCadConvertResult result = cadConvertBizService.getResult(convertId);
|
|
|
+
|
|
|
+ //执行成功
|
|
|
+ if (result != null && !Objects.equals(result.getConvertStatus(), GisSurveConvertStatusEnum.FAIL.getCode())) {
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
+ resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
|
+ resResult.setResdata(result);
|
|
|
+ }
|
|
|
+ //执行失败
|
|
|
+ if (result != null && Objects.equals(result.getConvertStatus(), GisSurveConvertStatusEnum.FAIL.getCode())) {
|
|
|
+ resResult.setResdata(result);
|
|
|
+ }
|
|
|
+ //不存在
|
|
|
+ if (result == null) {
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_ASYNC_TASK_NOT_FOUND.toStrCode());
|
|
|
+ resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_NOT_FOUND.toStrMsg());
|
|
|
+ }
|
|
|
+
|
|
|
+ //end
|
|
|
+ resResult.setTimestamp(System.currentTimeMillis());
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
|
|
|
+ , String.format("%s:%s seq:{%s} rescode:{%s} resmsg:{%s} time:{%d ms} end<===="
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , strRunSeq
|
|
|
+ , resResult.getRescode()
|
|
|
+ , resResult.getResmsg()
|
|
|
+ , resResult.getTimestamp() - llReqBefore));
|
|
|
+ return resResult;
|
|
|
+ }
|
|
|
}
|