|
@@ -2,16 +2,18 @@ package com.shkpr.service.alambizplugin.controller;
|
|
|
|
|
|
import com.fasterxml.jackson.core.JsonProcessingException;
|
|
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
|
|
+import com.fasterxml.jackson.databind.module.SimpleModule;
|
|
|
import com.global.base.log.LogLevelFlag;
|
|
|
import com.global.base.log.LogPrintMgr;
|
|
|
+import com.shkpr.service.alambizplugin.apiparam.GisSurveyCRSParams;
|
|
|
import com.shkpr.service.alambizplugin.apiparam.GisSurveyCheckParams;
|
|
|
import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdExportParams;
|
|
|
import com.shkpr.service.alambizplugin.apiparam.GisSurveyThirdImportParams;
|
|
|
-import com.shkpr.service.alambizplugin.bizservice.GisSurveyCRSBizService;
|
|
|
import com.shkpr.service.alambizplugin.bizservice.GisSurveyCadConvertBizService;
|
|
|
import com.shkpr.service.alambizplugin.bizservice.GisSurveySystemCheckBizService;
|
|
|
import com.shkpr.service.alambizplugin.bizservice.GisSurveyThirdExportBizService;
|
|
|
import com.shkpr.service.alambizplugin.bizservice.GisSurveyThirdImportBizService;
|
|
|
+import com.shkpr.service.alambizplugin.commtools.CRSUtil;
|
|
|
import com.shkpr.service.alambizplugin.commtools.CommTool;
|
|
|
import com.shkpr.service.alambizplugin.constants.ApiURI;
|
|
|
import com.shkpr.service.alambizplugin.constants.CadEnum;
|
|
@@ -21,6 +23,7 @@ import com.shkpr.service.alambizplugin.constants.GisSurveyImportStatusEnum;
|
|
|
import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
|
|
|
import com.shkpr.service.alambizplugin.constants.ResponseCode;
|
|
|
import com.shkpr.service.alambizplugin.controllerfilter.TokenAuthenticationService;
|
|
|
+import com.shkpr.service.alambizplugin.controllerserializer.GeometrySerializer;
|
|
|
import com.shkpr.service.alambizplugin.controllervalid.CommonParamValidSK;
|
|
|
import com.shkpr.service.alambizplugin.dbdao.services.GisSurveyLayerApplyThirdCopyServiceImpl;
|
|
|
import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyService;
|
|
@@ -34,6 +37,7 @@ import com.shkpr.service.alambizplugin.dto.ResponseRes;
|
|
|
import com.shkpr.service.alambizplugin.exception.SelfException;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.locationtech.jts.geom.Geometry;
|
|
|
import org.springframework.data.domain.Pageable;
|
|
|
import org.springframework.data.web.PageableDefault;
|
|
|
import org.springframework.validation.BindingResult;
|
|
@@ -76,7 +80,6 @@ public class ApiGisSurveyController {
|
|
|
|
|
|
private final ObjectMapper objectMapper;
|
|
|
|
|
|
- private final GisSurveyCRSBizService crsBizService;
|
|
|
private final GisSurveySystemCheckBizService systemCheckBizService;
|
|
|
private final GisSurveyThirdImportBizService thirdImportBizService;
|
|
|
private final GisSurveyThirdExportBizService thirdExportBizService;
|
|
@@ -85,7 +88,6 @@ public class ApiGisSurveyController {
|
|
|
private final GisSurveyLayerApplyThirdCopyServiceImpl layerApplyThirdCopyService;
|
|
|
|
|
|
public ApiGisSurveyController(ObjectMapper objectMapper
|
|
|
- , GisSurveyCRSBizService crsBizService
|
|
|
, GisSurveySystemCheckBizService systemCheckBizService
|
|
|
, GisSurveyThirdImportBizService thirdImportBizService
|
|
|
, GisSurveyThirdExportBizService thirdExportBizService
|
|
@@ -108,7 +110,6 @@ public class ApiGisSurveyController {
|
|
|
mSeqCrsGetListReq = new AtomicInteger(0);
|
|
|
mSeqCrsGetInfoReq = new AtomicInteger(0);
|
|
|
this.objectMapper = objectMapper;
|
|
|
- this.crsBizService = crsBizService;
|
|
|
this.systemCheckBizService = systemCheckBizService;
|
|
|
this.thirdImportBizService = thirdImportBizService;
|
|
|
this.thirdExportBizService = thirdExportBizService;
|
|
@@ -991,7 +992,7 @@ public class ApiGisSurveyController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取crs列表
|
|
|
+ * 获取坐标系列表
|
|
|
*
|
|
|
* @param request request
|
|
|
* @param strClientType 客户端类型
|
|
@@ -1023,10 +1024,10 @@ public class ApiGisSurveyController {
|
|
|
resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrMsg());
|
|
|
|
|
|
//获取crs列表
|
|
|
- List<GisSurveyCRSBizService.Item> result = crsBizService.getCRSList();
|
|
|
+ List<CRSUtil.Item> result = CRSUtil.getList();
|
|
|
String resultStr = null;
|
|
|
try {
|
|
|
- if (result != null) resultStr = objectMapper.writeValueAsString(result);
|
|
|
+ if (CollectionUtils.isNotEmpty(result)) resultStr = objectMapper.writeValueAsString(result);
|
|
|
} catch (JsonProcessingException e) {
|
|
|
LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
|
, String.format("Json序列化异常: error:%s", e));
|
|
@@ -1053,7 +1054,7 @@ public class ApiGisSurveyController {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 获取crs信息
|
|
|
+ * 获取坐标系信息
|
|
|
*
|
|
|
* @param request request
|
|
|
* @param strClientType 客户端类型
|
|
@@ -1092,8 +1093,8 @@ public class ApiGisSurveyController {
|
|
|
resResult.setRescode(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrCode());
|
|
|
resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrMsg());
|
|
|
|
|
|
- //获取crs列表
|
|
|
- CommCRSInfo result = crsBizService.getCRSInfo(code);
|
|
|
+ //获取crs信息
|
|
|
+ CommCRSInfo result = CRSUtil.getInfo(code);
|
|
|
String resultStr = null;
|
|
|
try {
|
|
|
if (result != null) resultStr = objectMapper.writeValueAsString(result);
|
|
@@ -1121,4 +1122,83 @@ public class ApiGisSurveyController {
|
|
|
, resResult.getTimestamp() - llReqBefore));
|
|
|
return resResult;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 坐标系转换
|
|
|
+ *
|
|
|
+ * @param request request
|
|
|
+ * @param strClientType 客户端类型
|
|
|
+ * @param strUserAgent 用户信息
|
|
|
+ * @return crs信息
|
|
|
+ */
|
|
|
+ @PostMapping(value = ApiURI.URI_XXX_CRS_TRANSFORM)
|
|
|
+ public ResponseRes<String> crsTransform(HttpServletRequest request
|
|
|
+ , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
|
|
|
+ , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
|
|
|
+ , @RequestBody(required = false) @Validated(value = {CommonParamValidSK.class}) GisSurveyCRSParams oJsonParam
|
|
|
+ , BindingResult bindRes) 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 (oJsonParam == null || bindRes.hasErrors() || oJsonParam.getGeometry()==null) {
|
|
|
+ throw new SelfException(ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrCode()
|
|
|
+ , String.format(ApiURI.EXCEPTION_FORMAT
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , ResponseCode.STATUS_ERROR_JSON_FORMAT.toStrMsg()));
|
|
|
+ }
|
|
|
+
|
|
|
+ //begin
|
|
|
+ long llReqBefore = System.currentTimeMillis();
|
|
|
+ String strRunSeq = String.format("%d-%d", llReqBefore, mSeqCrsGetInfoReq.incrementAndGet());
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
|
|
|
+ , String.format("%s:%s seq:{%s} begin====>"
|
|
|
+ , strPlatform
|
|
|
+ , URI_PATH
|
|
|
+ , strRunSeq));
|
|
|
+
|
|
|
+ //构建result
|
|
|
+ ResponseRes<String> resResult = new ResponseRes<>();
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrCode());
|
|
|
+ resResult.setResmsg(ResponseCode.RESULT_ASYNC_TASK_FAILED.toStrMsg());
|
|
|
+
|
|
|
+ //转换坐标系
|
|
|
+ Geometry result = CRSUtil.transform(oJsonParam.getGeometry(), oJsonParam.getSourceCRSCode(), oJsonParam.getTargetCRSCode());
|
|
|
+ String resultStr = null;
|
|
|
+ try {
|
|
|
+ if (result != null) {
|
|
|
+ //创建objectMapper,并注册geo序列化
|
|
|
+ ObjectMapper objectMapper = new ObjectMapper();
|
|
|
+ SimpleModule module = new SimpleModule();
|
|
|
+ module.addSerializer(Geometry.class, new GeometrySerializer());
|
|
|
+ objectMapper.registerModule(module);
|
|
|
+
|
|
|
+ resultStr = objectMapper.writeValueAsString(result);
|
|
|
+ }
|
|
|
+ } catch (JsonProcessingException e) {
|
|
|
+ LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
|
|
|
+ , String.format("Json序列化异常: error:%s", e));
|
|
|
+ }
|
|
|
+
|
|
|
+ //执行成功
|
|
|
+ if (resultStr != null) {
|
|
|
+ resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
|
|
|
+ resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
|
|
|
+ resResult.setResdata(resultStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ //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;
|
|
|
+ }
|
|
|
}
|