Bladeren bron

第三方导出增加超出约束检查

欧阳劲驰 3 weken geleden
bovenliggende
commit
27941e99db

+ 4 - 0
src/main/java/com/shkpr/service/alambizplugin/apiparam/GisSurveyThirdImportParams.java

@@ -40,6 +40,10 @@ public class GisSurveyThirdImportParams {
      */
     private Boolean resetNo;
     /**
+     * 是否检查约束
+     */
+    private Boolean checkConstraint;
+    /**
      * 忽略失败
      */
     private Boolean ignoreFail;

+ 25 - 10
src/main/java/com/shkpr/service/alambizplugin/components/GisSurveyThirdImporter.java

@@ -21,8 +21,10 @@ import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisMetadataLayerTemplateService;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyJobInfoService;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyLayerApplyThirdCopyService;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyProjectInfoService;
 import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
 import com.shkpr.service.alambizplugin.dto.GisMetadataPropertyTemplate;
+import com.shkpr.service.alambizplugin.dto.GisSurveyCondition;
 import com.shkpr.service.alambizplugin.dto.GisSurveyLayerApplyThirdCopy;
 import com.shkpr.service.alambizplugin.dto.GisSurveyPropertyValueThirdCopy;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement;
@@ -72,24 +74,31 @@ public class GisSurveyThirdImporter {
     private final String mStrClassName;
     private final String mBizType;
     private final GeometryFactory geometryFactory;
+    private final GisSurveyProjectInfoService projectInfoService;
+    private final GisSurveyJobInfoService jobInfoService;
     private final GisMetadataLayerTemplateService layerTemplateService;
-    private final GisSurveyLayerApplyThirdCopyService gisSurveyLayerApplyThirdCopyService;
+    private final GisSurveyLayerApplyThirdCopyService layerApplyThirdCopyService;
     private final DuplicatePointsFinder duplicatePointsFinder;
     private final InvalidLinesFinder invalidLinesFinder;
     private final InvalidPropertiesFinder invalidPropertiesFinder;
-    private final GisSurveyJobInfoService gisSurveyJobInfoService;
 
-    public GisSurveyThirdImporter(GisMetadataLayerTemplateService layerTemplateService, GisSurveyLayerApplyThirdCopyService gisSurveyLayerApplyThirdCopyService
-            , DuplicatePointsFinder duplicatePointsFinder, InvalidLinesFinder invalidLinesFinder, InvalidPropertiesFinder invalidPropertiesFinder, GisSurveyJobInfoService gisSurveyJobInfoService) {
+    public GisSurveyThirdImporter(GisSurveyProjectInfoService projectInfoService
+            , GisSurveyJobInfoService jobInfoService
+            , GisMetadataLayerTemplateService layerTemplateService
+            , GisSurveyLayerApplyThirdCopyService layerApplyThirdCopyService
+            , DuplicatePointsFinder duplicatePointsFinder
+            , InvalidLinesFinder invalidLinesFinder
+            , InvalidPropertiesFinder invalidPropertiesFinder) {
         mStrClassName = "GisSurveyThirdImporter";
         mBizType = LogFlagBusiType.BUSI_GIS_SURVEY.toStrValue();
         geometryFactory = new GeometryFactory(new PrecisionModel(), 4490);
+        this.projectInfoService = projectInfoService;
+        this.jobInfoService = jobInfoService;
         this.layerTemplateService = layerTemplateService;
-        this.gisSurveyLayerApplyThirdCopyService = gisSurveyLayerApplyThirdCopyService;
+        this.layerApplyThirdCopyService = layerApplyThirdCopyService;
         this.duplicatePointsFinder = duplicatePointsFinder;
         this.invalidLinesFinder = invalidLinesFinder;
         this.invalidPropertiesFinder = invalidPropertiesFinder;
-        this.gisSurveyJobInfoService = gisSurveyJobInfoService;
     }
 
     /**
@@ -128,6 +137,8 @@ public class GisSurveyThirdImporter {
             //解析excel
             parseExcel(inputStreams, points, lines);
 
+            //项目约束条件
+            List<GisSurveyCondition> projectConstraints = projectInfoService.findConstraintsByJobId(params.getJobId());
             //提取图层名
             List<String> pointLayerNames = getLayerNames(points, GisSurveyExcelDefine.FILE.POINT_LAYER);
             List<String> lineLayerNames = getLayerNames(lines, GisSurveyExcelDefine.FILE.LINE_LAYER);
@@ -136,7 +147,8 @@ public class GisSurveyThirdImporter {
             List<GisMetadataLayerTemplate> lineLayerTemplates = layerTemplateService.findByNatureAndNameIn(params.getNature(), lineLayerNames);
 
             //无效属性检查
-            invalidPropertiesFuture = invalidPropertiesFinder.findInvalidProperties(points, lines, pointLayerTemplates, lineLayerTemplates);
+            invalidPropertiesFuture = invalidPropertiesFinder.findInvalidProperties(points, lines
+                    , pointLayerTemplates, lineLayerTemplates, params.getCheckConstraint(), projectConstraints);
             //重复点检查
             duplicatePointsFuture = duplicatePointsFinder.findDuplicatePoints(points, pointLayerTemplates);
             //无效线检查
@@ -154,6 +166,7 @@ public class GisSurveyThirdImporter {
             result.setMissingRequirementsResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.MISSING_REQUIREMENTS));
             result.setInvalidTypesResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.INVALID_TYPES));
             result.setOutRangesResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.OUT_RANGES));
+            result.setOutConstraintResult(untarInvalidProperties(invalidPropertiesResult, GisSurveyExcelDefine.RESULT.OUT_CONSTRAINT));
             //存入重复点结果
             result.setDuplicatePointsResult(duplicatePointsFuture.get());
             //存入无效线结果
@@ -182,7 +195,7 @@ public class GisSurveyThirdImporter {
             if (params.getResetNo()) resetNo(params.getJobId(), layerApplyList);
 
             //批量写入
-            Boolean saved = gisSurveyLayerApplyThirdCopyService.saveAll(params.getJobId(), layerApplyList);
+            Boolean saved = layerApplyThirdCopyService.saveAll(params.getJobId(), layerApplyList);
             if (!saved) {
                 result.setCompleteTime(LocalDateTime.now());
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -315,12 +328,14 @@ public class GisSurveyThirdImporter {
         List<GisSurveyThirdImportElement> missingRequirements = result.getMissingRequirementsResult().getResults();
         List<GisSurveyThirdImportElement> invalidTypesResult = result.getInvalidTypesResult().getResults();
         List<GisSurveyThirdImportElement> outRanges = result.getOutRangesResult().getResults();
+        List<GisSurveyThirdImportElement> outConstraint = result.getOutConstraintResult().getResults();
         List<GisSurveyThirdImportElement> duplicatePoints = result.getDuplicatePointsResult().getResults();
         List<GisSurveyThirdImportElement> invalidLines = result.getInvalidLinesResult().getResults();
         //检查是否都为空
         return CollectionUtils.isEmpty(invalidLayers) && CollectionUtils.isEmpty(missingRequirements) &&
                 CollectionUtils.isEmpty(invalidTypesResult) && CollectionUtils.isEmpty(outRanges) &&
-                CollectionUtils.isEmpty(duplicatePoints) && CollectionUtils.isEmpty(invalidLines);
+                CollectionUtils.isEmpty(outConstraint) && CollectionUtils.isEmpty(duplicatePoints) &&
+                CollectionUtils.isEmpty(invalidLines);
     }
 
     /**
@@ -548,7 +563,7 @@ public class GisSurveyThirdImporter {
         long begin = System.currentTimeMillis();
 
         //点号规则
-        final List<RuleFormatSetting> ruleFormat = gisSurveyJobInfoService.findRuleFormat(jobId);
+        final List<RuleFormatSetting> ruleFormat = jobInfoService.findRuleFormat(jobId);
         //点号映射
         Map<String, String> noMapping = new ConcurrentHashMap<>();
 

+ 116 - 23
src/main/java/com/shkpr/service/alambizplugin/components/checker/InvalidPropertiesFinder.java

@@ -2,6 +2,7 @@ package com.shkpr.service.alambizplugin.components.checker;
 
 import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.alambizplugin.commtools.BeanUtil;
 import com.shkpr.service.alambizplugin.commtools.GeomUtil;
 import com.shkpr.service.alambizplugin.commtools.ThirdImportTemplateUtils;
 import com.shkpr.service.alambizplugin.constants.GisMetadataDefine;
@@ -9,8 +10,10 @@ import com.shkpr.service.alambizplugin.constants.GisSurveyExcelDefine;
 import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
 import com.shkpr.service.alambizplugin.dto.GisMetadataLayerTemplate;
 import com.shkpr.service.alambizplugin.dto.GisMetadataPropertyTemplate;
+import com.shkpr.service.alambizplugin.dto.GisSurveyCondition;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportElement;
 import com.shkpr.service.alambizplugin.dto.GisSurveyThirdImportResultDetail;
+import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.math.NumberUtils;
 import org.springframework.scheduling.annotation.Async;
@@ -23,6 +26,7 @@ import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 /**
  * 无效属性查找器
@@ -57,12 +61,14 @@ public class InvalidPropertiesFinder {
      * @param lines               线集合
      * @param pointLayerTemplates 点图层模版集合
      * @param lineLayerTemplates  线图层模版集合
+     * @param checkConstraint     检查约束
+     * @param projectConstraints  项目约束条件
      * @return 重复点
      */
     @Async
     public ListenableFuture<GisSurveyThirdImportResultDetail<Map<String, List<GisSurveyThirdImportElement>>>> findInvalidProperties(
             List<Map<String, String>> points, List<Map<String, String>> lines, List<GisMetadataLayerTemplate> pointLayerTemplates
-            , List<GisMetadataLayerTemplate> lineLayerTemplates) throws InterruptedException {
+            , List<GisMetadataLayerTemplate> lineLayerTemplates, Boolean checkConstraint, List<GisSurveyCondition> projectConstraints) throws InterruptedException {
         LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, "开始执行寻找无效属性   ======>");
         long begin = System.currentTimeMillis();
 
@@ -74,6 +80,8 @@ public class InvalidPropertiesFinder {
         List<GisSurveyThirdImportElement> invalidTypesResult = new ArrayList<>();
         //超出范围结果
         List<GisSurveyThirdImportElement> outRangesResult = new ArrayList<>();
+        //超出约束结果
+        List<GisSurveyThirdImportElement> outConstraintResult = new ArrayList<>();
         //检查点属性
         for (Map<String, String> point : points) {
             //响应中断
@@ -91,7 +99,7 @@ public class InvalidPropertiesFinder {
                 ));
             else
                 //图层存在则检查图层
-                checkLayer(point, layerTemplate, missingRequirementsResult, invalidTypesResult);
+                checkLayer(point, layerTemplate, checkConstraint, projectConstraints, missingRequirementsResult, invalidTypesResult, outConstraintResult);
             //检查坐标超出范围
             if (checkOutRanges(point, layerTemplate))
                 outRangesResult.add(
@@ -121,7 +129,7 @@ public class InvalidPropertiesFinder {
                 ));
             else
                 //图层存在则检查图层
-                checkLayer(line, layerTemplate, missingRequirementsResult, invalidTypesResult);
+                checkLayer(line, layerTemplate, checkConstraint, projectConstraints, missingRequirementsResult, invalidTypesResult, outConstraintResult);
         }
 
         long end = System.currentTimeMillis();
@@ -138,6 +146,7 @@ public class InvalidPropertiesFinder {
         result.put(GisSurveyExcelDefine.RESULT.MISSING_REQUIREMENTS, missingRequirementsResult);
         result.put(GisSurveyExcelDefine.RESULT.INVALID_TYPES, invalidTypesResult);
         result.put(GisSurveyExcelDefine.RESULT.OUT_RANGES, outRangesResult);
+        result.put(GisSurveyExcelDefine.RESULT.OUT_CONSTRAINT, outConstraintResult);
         return new AsyncResult<>(new GisSurveyThirdImportResultDetail<>(true, result));
     }
 
@@ -167,39 +176,123 @@ public class InvalidPropertiesFinder {
      *
      * @param data                      数据
      * @param layerTemplate             图层模版
+     * @param checkConstraint           检查超出约束
+     * @param projectConstraints        项目约束
      * @param missingRequirementsResult 缺少必填结果
      * @param invalidTypesResult        无效类型结果
+     * @param outConstraintResult       超出约束结果
      */
     public void checkLayer(Map<String, String> data, GisMetadataLayerTemplate layerTemplate
-            , List<GisSurveyThirdImportElement> missingRequirementsResult
-            , List<GisSurveyThirdImportElement> invalidTypesResult) {
+            , Boolean checkConstraint, List<GisSurveyCondition> projectConstraints, List<GisSurveyThirdImportElement> missingRequirementsResult
+            , List<GisSurveyThirdImportElement> invalidTypesResult, List<GisSurveyThirdImportElement> outConstraintResult) {
+        //项目约束映射
+        Map<String, GisSurveyCondition> projectConstraintsMapping = projectConstraints.stream()
+                .collect(Collectors.toMap(GisSurveyCondition::getProperty, it -> it));
         //遍历图层属性模版
         for (GisMetadataPropertyTemplate propertyTemplate : layerTemplate.getPropertyTemplates()) {
-            //排除非必填
-            if (propertyTemplate.getRequired() != 1 || propertyTemplate.getStatus() != 1)
-                continue;
             //排除编码
             if (Objects.equals(GisSurveyExcelDefine.TEMPLATE.CODE, propertyTemplate.getKey())
                     || Objects.equals(GisSurveyExcelDefine.TEMPLATE.UP_NODE, propertyTemplate.getKey())
                     || Objects.equals(GisSurveyExcelDefine.TEMPLATE.DOWN_NODE, propertyTemplate.getKey()))
                 continue;
-            //模版名称
-            String templateName = propertyTemplate.getName();
-            //必填不存在则存入缺少必填
-            if (data.get(templateName) == null || StringUtils.isBlank(data.get(templateName))) {
-                GisSurveyThirdImportElement gisSurveyThirdImportElement = GisSurveyThirdImportElement.create(data,
-                        layerTemplate,
-                        propertyTemplate.getName()
+            //当前属性值
+            String value = data.get(propertyTemplate.getName());
+            //必填
+            if (propertyTemplate.getRequired() == 1 && propertyTemplate.getStatus() == 1) {
+                //值不存在则存入缺少必填
+                if (StringUtils.isBlank(value)) {
+                    GisSurveyThirdImportElement gisSurveyThirdImportElement = GisSurveyThirdImportElement.create(data,
+                            layerTemplate,
+                            propertyTemplate.getName()
+                    );
+                    missingRequirementsResult.add(gisSurveyThirdImportElement);
+                    //值存在
+                } else {
+                    //判断超出约束
+                    checkOutConstraint(
+                            projectConstraintsMapping.get(propertyTemplate.getKey()),
+                            data, layerTemplate, propertyTemplate, value, outConstraintResult
+                    );
+                    //判断数字类型
+                    if ((GisSurveyExcelDefine.DATA_TYPE.INT.equals(propertyTemplate.getType()) ||
+                            GisSurveyExcelDefine.DATA_TYPE.DOUBLE.equals(propertyTemplate.getType()))
+                            && !NumberUtils.isParsable(value)) {
+                        invalidTypesResult.add(GisSurveyThirdImportElement.create(data,
+                                layerTemplate,
+                                propertyTemplate.getName()
+                        ));
+                    }
+                }
+            }
+            //非必填
+            else {
+                //判断超出约束
+                if (checkConstraint && StringUtils.isNotBlank(value)) checkOutConstraint(
+                        projectConstraintsMapping.get(propertyTemplate.getKey()),
+                        data, layerTemplate, propertyTemplate, value, outConstraintResult
                 );
-                missingRequirementsResult.add(gisSurveyThirdImportElement);
-            } else if ((GisSurveyExcelDefine.DATA_TYPE.INT.equals(propertyTemplate.getType()) ||
-                    GisSurveyExcelDefine.DATA_TYPE.DOUBLE.equals(propertyTemplate.getType()))
-                    && !NumberUtils.isParsable(data.get(templateName)))
-                //存在且类型为数字,则判断数字类型
-                invalidTypesResult.add(GisSurveyThirdImportElement.create(data,
-                        layerTemplate,
-                        propertyTemplate.getName()
+            }
+        }
+    }
+
+    /**
+     * 检查超出约束
+     *
+     * @param projectConstraint   项目约束
+     * @param data                数据
+     * @param layerTemplate       图层模版
+     * @param propertyTemplate    属性模版
+     * @param value               值
+     * @param outConstraintResult 超出约束结果
+     */
+    public void checkOutConstraint(GisSurveyCondition projectConstraint, Map<String, String> data
+            , GisMetadataLayerTemplate layerTemplate, GisMetadataPropertyTemplate propertyTemplate
+            , String value, List<GisSurveyThirdImportElement> outConstraintResult) {
+        GisSurveyCondition constraint = null;
+        //模版约束
+        if (StringUtils.isNotBlank(propertyTemplate.getMode()) && CollectionUtils.isNotEmpty(propertyTemplate.getRanges())) {
+            constraint = BeanUtil.copy(propertyTemplate, GisSurveyCondition.class);
+        }
+        //项目约束
+        if (projectConstraint != null) {
+            constraint = projectConstraint;
+        }
+        if (constraint == null || StringUtils.isBlank(value)) return;
+        //约束模式
+        String mode = constraint.getMode();
+        //约束范围
+        List<String> ranges = constraint.getRanges();
+        if (StringUtils.isBlank(mode) || CollectionUtils.isEmpty(ranges)) return;
+        //列表约束
+        if (Objects.equals("list", constraint.getMode())) {
+            //如列表不包含值,则超出约束
+            if (!ranges.contains(value)) {
+                outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
+                        propertyTemplate.getName(), value, constraint
                 ));
+            }
+        }
+        //极值约束
+        else if (Objects.equals("extremum", constraint.getMode())) {
+            if (ranges.size() != 2) return;
+            //最小值判断
+            String minStr = ranges.get(0);
+            if (StringUtils.isNotBlank(minStr) && NumberUtils.isParsable(minStr)) {
+                double min = Double.parseDouble(minStr);
+                if (!NumberUtils.isParsable(value) || Double.parseDouble(value) < min) {
+                    outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
+                            propertyTemplate.getName(), value, constraint));
+                }
+            }
+            //最大值判断
+            String maxStr = ranges.get(1);
+            if (StringUtils.isNotBlank(maxStr) && NumberUtils.isParsable(maxStr)) {
+                double max = Double.parseDouble(maxStr);
+                if (!NumberUtils.isParsable(value) || Double.parseDouble(value) > max) {
+                    outConstraintResult.add(GisSurveyThirdImportElement.create(data, layerTemplate,
+                            propertyTemplate.getName(), value, constraint));
+                }
+            }
         }
     }
 }

+ 1 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/GisSurveyExcelDefine.java

@@ -70,5 +70,6 @@ public interface GisSurveyExcelDefine {
         String MISSING_REQUIREMENTS = "missingRequirementsResult";
         String INVALID_TYPES = "invalidTypesResult";
         String OUT_RANGES = "outRangesResult";
+        String OUT_CONSTRAINT = "outConstraint";
     }
 }

+ 2 - 1
src/main/java/com/shkpr/service/alambizplugin/controller/ApiGisSurveyController.java

@@ -279,6 +279,7 @@ public class ApiGisSurveyController {
             , @RequestParam(value = "jobId", required = false) String jobId
             , @RequestParam(value = "nature", required = false) String nature
             , @RequestParam(value = "resetNo", required = false) Boolean resetNo
+            , @RequestParam(value = "checkConstraint", required = false, defaultValue = "false") Boolean checkConstraint
             , @RequestParam(value = "ignoreFail", required = false, defaultValue = "false") String ignoreFail) throws SelfException {
         //入参校验
         final String URI_PATH = request.getRequestURI();
@@ -293,7 +294,7 @@ public class ApiGisSurveyController {
                     , ResponseCode.STATUS_ERROR_PARAM_FORMAT.toStrMsg()));
         }
         //构建入参数
-        GisSurveyThirdImportParams params = new GisSurveyThirdImportParams(files, operator, jobId, nature, resetNo, Boolean.parseBoolean(ignoreFail));
+        GisSurveyThirdImportParams params = new GisSurveyThirdImportParams(files, operator, jobId, nature, resetNo, checkConstraint, Boolean.parseBoolean(ignoreFail));
         //begin
         long llReqBefore = System.currentTimeMillis();
         String strRunSeq = String.format("%d-%d", llReqBefore, mSeqThirdImportReq.incrementAndGet());

+ 11 - 1
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/GisSurveyProjectInfoMapper.java

@@ -1,9 +1,11 @@
 package com.shkpr.service.alambizplugin.dbdao.mapper;
 
+import com.shkpr.service.alambizplugin.dto.GisSurveyCondition;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * 采集项目基本信息mapper
@@ -22,11 +24,19 @@ public interface GisSurveyProjectInfoMapper {
     LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
 
     /**
+     * 根据uid查询约束
+     *
+     * @param jobId 任务id
+     * @return 约束条件
+     */
+    List<GisSurveyCondition> findConstraintsByJobId(@Param("jobId") String jobId);
+
+    /**
      * 根据任务id更新刷新时间
      *
      * @param jobId       任务id
      * @param refreshTime 刷新时间
      * @return 刷新时间
      */
-    int updateRefreshTimeByUid(@Param("jobId") String jobId, @Param("refreshTime") Long refreshTime);
+    int updateRefreshTimeByJobId(@Param("jobId") String jobId, @Param("refreshTime") Long refreshTime);
 }

+ 1 - 1
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyLayerApplyServiceImpl.java

@@ -347,7 +347,7 @@ public class GisSurveyLayerApplyServiceImpl implements GisSurveyLayerApplyServic
 
                 //更新刷新时间
                 long timestamp = System.currentTimeMillis();
-                int projectUpdated = projectInfoMapper.updateRefreshTimeByUid(jobId, timestamp);
+                int projectUpdated = projectInfoMapper.updateRefreshTimeByJobId(jobId, timestamp);
                 int jobUpdated = jobInfoMapper.updateRefreshTimeActionStatusByUid(jobId, timestamp, timestamp,
                         GisSurveyExcelDefine.DEFAULT_VALUE.ACTION, GisSurveyExcelDefine.DEFAULT_VALUE.STATUS);
                 //写入任务状态

+ 13 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/GisSurveyProjectInfoServiceImpl.java

@@ -2,9 +2,11 @@ package com.shkpr.service.alambizplugin.dbdao.services;
 
 import com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper;
 import com.shkpr.service.alambizplugin.dbdao.services.intef.GisSurveyProjectInfoService;
+import com.shkpr.service.alambizplugin.dto.GisSurveyCondition;
 import org.springframework.stereotype.Service;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * 采集项目基本信息service实现
@@ -31,4 +33,15 @@ public class GisSurveyProjectInfoServiceImpl implements GisSurveyProjectInfoServ
     public LocalDateTime findRefreshTimeByUid(String uid) {
         return projectInfoMapper.findRefreshTimeByUid(uid);
     }
+
+    /**
+     * 根据uid查询约束
+     *
+     * @param jobId 任务id
+     * @return 约束条件
+     */
+    @Override
+    public List<GisSurveyCondition> findConstraintsByJobId(String jobId) {
+        return projectInfoMapper.findConstraintsByJobId(jobId);
+    }
 }

+ 10 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/GisSurveyProjectInfoService.java

@@ -1,8 +1,10 @@
 package com.shkpr.service.alambizplugin.dbdao.services.intef;
 
+import com.shkpr.service.alambizplugin.dto.GisSurveyCondition;
 import org.apache.ibatis.annotations.Param;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * 采集项目基本信息service
@@ -18,4 +20,12 @@ public interface GisSurveyProjectInfoService {
      * @return 刷新时间
      */
     LocalDateTime findRefreshTimeByUid(@Param("uid") String uid);
+
+    /**
+     * 根据uid查询约束
+     *
+     * @param jobId 任务id
+     * @return 约束条件
+     */
+    List<GisSurveyCondition> findConstraintsByJobId(String jobId);
 }

+ 7 - 1
src/main/java/com/shkpr/service/alambizplugin/dto/GisMetadataPropertyTemplate.java

@@ -3,6 +3,7 @@ package com.shkpr.service.alambizplugin.dto;
 import lombok.Data;
 
 import java.time.LocalDateTime;
+import java.util.List;
 
 /**
  * gis元数据图层属性定义模板
@@ -42,7 +43,12 @@ public class GisMetadataPropertyTemplate {
     /**
      * 取值范围列表
      */
-    private String ranges;
+    private List<String> ranges;
+
+    /**
+     * 元素属性约束方式,如:list/extremum
+     */
+    private String mode;
 
     /**
      * 控件输入类型

+ 39 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyCondition.java

@@ -0,0 +1,39 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * 约束条件
+ *
+ * @author 欧阳劲驰
+ * @since 1.0.0
+ */
+@Data
+public class GisSurveyCondition {
+    /**
+     * 元素类别,如:point/line/face
+     */
+    private String kind;
+    /**
+     * 元素属性标识符key
+     */
+    private String property;
+    /**
+     * 元素属性取值类型,如:string/double/int
+     */
+    private String type;
+    /**
+     * 元素属性约束方式,如:list/extremum
+     */
+    private String mode;
+    /**
+     * 元素属性取值单位
+     */
+    private String unit;
+    /**
+     * 元素属性取值约束列表
+     */
+    private List<String> ranges;
+}

+ 19 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyThirdImportElement.java

@@ -41,6 +41,16 @@ public class GisSurveyThirdImportElement {
      */
     private String propertyName;
 
+    /**
+     * 约束条件
+     */
+    private GisSurveyCondition condition;
+
+    /**
+     * 值
+     */
+    private String value;
+
     public GisSurveyThirdImportElement(String kind, String no, String layerName, String propertyName) {
         this.kind = kind;
         this.no = no;
@@ -74,4 +84,13 @@ public class GisSurveyThirdImportElement {
         }
         return null;
     }
+
+    public static GisSurveyThirdImportElement create(Map<String, String> data, GisMetadataLayerTemplate layerTemplate
+            , String propertyName, String value, GisSurveyCondition condition) {
+        GisSurveyThirdImportElement element = create(data, layerTemplate, propertyName);
+        if (element == null) return null;
+        element.setValue(value);
+        element.setCondition(condition);
+        return element;
+    }
 }

+ 6 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/GisSurveyThirdImportResult.java

@@ -65,6 +65,11 @@ public class GisSurveyThirdImportResult {
     private GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>> outRangesResult = new GisSurveyThirdImportResultDetail<>();
 
     /**
+     * 超出约束结果
+     */
+    private GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>> outConstraintResult = new GisSurveyThirdImportResultDetail<>();
+
+    /**
      * 重复点号结果
      */
     private GisSurveyThirdImportResultDetail<List<GisSurveyThirdImportElement>> duplicatePointsResult = new GisSurveyThirdImportResultDetail<>();
@@ -88,6 +93,7 @@ public class GisSurveyThirdImportResult {
                 result.getMissingRequirementsResult().setDone(subtask.getInvalidPropertiesFuture().isDone());
                 result.getInvalidTypesResult().setDone(subtask.getInvalidPropertiesFuture().isDone());
                 result.getOutRangesResult().setDone(subtask.getInvalidPropertiesFuture().isDone());
+                result.getOutConstraintResult().setDone(subtask.getInvalidPropertiesFuture().isDone());
             }
             if (subtask.getDuplicatePointsFuture() != null)
                 result.getDuplicatePointsResult().setDone(subtask.getDuplicatePointsFuture().isDone());

+ 5 - 1
src/main/resources/mapper/GisMetadataLayerTemplateMapper.xml

@@ -26,7 +26,9 @@
             <result column="property_id" jdbcType="BIGINT" property="id"/>
             <result column="property_name" jdbcType="VARCHAR" property="name"/>
             <result column="property_type" jdbcType="VARCHAR" property="type"/>
-            <result column="property_ranges" jdbcType="VARCHAR" property="ranges"/>
+            <result column="property_ranges" jdbcType="VARCHAR" property="ranges"
+                    typeHandler="com.shkpr.service.alambizplugin.dbdao.pgtype.ListStrTypeHandlerPg"/>
+            <result column="property_mode" jdbcType="VARCHAR" property="mode"/>
             <result column="property_widget" jdbcType="VARCHAR" property="widget"/>
             <result column="property_defaults" jdbcType="VARCHAR" property="defaults"/>
             <result column="property_required" jdbcType="SMALLINT" property="required"/>
@@ -66,6 +68,7 @@
         mpt.name as property_name,
         mpt.type as property_type,
         mpt.ranges as property_ranges,
+        mpt.mode as property_mode,
         mpt.widget as property_widget,
         mpt.defaults as property_defaults,
         mpt.required as property_required,
@@ -113,6 +116,7 @@
         mpt.name as property_name,
         mpt.type as property_type,
         mpt.ranges as property_ranges,
+        mpt.mode as property_mode,
         mpt.widget as property_widget,
         mpt.defaults as property_defaults,
         mpt.required as property_required,

+ 27 - 1
src/main/resources/mapper/GisSurveyProjectInfoMapper.xml

@@ -1,13 +1,39 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.shkpr.service.alambizplugin.dbdao.mapper.GisSurveyProjectInfoMapper">
+    <resultMap id="GisSurveyCondition" type="com.shkpr.service.alambizplugin.dto.GisSurveyCondition">
+        <result property="kind" column="kind"/>
+        <result property="property" column="property"/>
+        <result property="type" column="type"/>
+        <result property="mode" column="mode"/>
+        <result property="unit" column="unit"/>
+        <result property="ranges" column="ranges" jdbcType="VARCHAR"
+                    typeHandler="com.shkpr.service.alambizplugin.dbdao.pgtype.ListStrTypeHandlerPg"/>
+    </resultMap>
+
     <select id="findRefreshTimeByUid" resultType="java.time.LocalDateTime">
         select to_timestamp(refresh_time / 1000.0) AT TIME ZONE 'PRC'
         from k3_gis_survey_project_info
         where uid = #{uid,jdbcType=VARCHAR};
     </select>
 
-    <update id="updateRefreshTimeByUid">
+    <select id="findConstraintsByJobId" resultMap="GisSurveyCondition">
+        select c ->> 'kind' as kind,
+        c ->> 'property' as property,
+        c ->> 'type' as type,
+        c ->> 'mode' as mode,
+        c ->> 'unit' as unit,
+        c ->> 'ranges' as ranges
+        from k3_gis_survey_job_info ji
+        join k3_gis_survey_project_info pit on ji.proj_id = pit.uid,
+        jsonb_array_elements((coalesce(
+        nullif(pit.constraints, '')::jsonb,
+        '[]'::jsonb
+        ))) as c
+        where ji.uid = #{jobId,jdbcType=VARCHAR};
+    </select>
+
+    <update id="updateRefreshTimeByJobId">
         update k3_gis_survey_project_info pi
         set refresh_time = #{refreshTime,jdbcType=BIGINT}
         where exists (select 1 from k3_gis_survey_job_info ji where ji.uid=#{jobId,jdbcType=VARCHAR} )