浏览代码

实现分析设置配置和查询

欧阳劲驰 4 月之前
父节点
当前提交
9d52751404
共有 28 个文件被更改,包括 2813 次插入54 次删除
  1. 1 1
      sql.properties
  2. 115 0
      src/main/java/com/shkpr/service/alambizplugin/apiparam/DmaAnalySettingLossTargetParams.java
  3. 109 0
      src/main/java/com/shkpr/service/alambizplugin/apiparam/DmaAnalySettingParams.java
  4. 17 0
      src/main/java/com/shkpr/service/alambizplugin/constants/ApiURI.java
  5. 103 0
      src/main/java/com/shkpr/service/alambizplugin/constants/DataType.java
  6. 27 0
      src/main/java/com/shkpr/service/alambizplugin/constants/DmaAnalySettingType.java
  7. 1 0
      src/main/java/com/shkpr/service/alambizplugin/constants/LogFlagBusiType.java
  8. 890 0
      src/main/java/com/shkpr/service/alambizplugin/controller/ApiDmaAnalySettingController.java
  9. 7 0
      src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTBizFilterMgr.java
  10. 55 0
      src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTDmaAnalySettingBizFilter.java
  11. 24 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/DmaAnalySettingDefineMapper.java
  12. 109 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/DmaAnalySettingLossTargetMapper.java
  13. 93 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/DmaAnalySettingMapper.java
  14. 0 53
      src/main/java/com/shkpr/service/alambizplugin/dbdao/pgtype/JSONTypeHandlerPg.java
  15. 104 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/pgtype/JsonTypeHandlerPg.java
  16. 35 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/DmaAnalySettingDefineServiceImpl.java
  17. 131 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/DmaAnalySettingLossTargetServiceImpl.java
  18. 202 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/DmaAnalySettingServiceImpl.java
  19. 21 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/DmaAnalySettingDefineService.java
  20. 71 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/DmaAnalySettingLossTargetService.java
  21. 57 0
      src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/DmaAnalySettingService.java
  22. 43 0
      src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySetting.java
  23. 33 0
      src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySettingDefault.java
  24. 57 0
      src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySettingDefine.java
  25. 100 0
      src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySettingLossTarget.java
  26. 20 0
      src/main/resources/mapper/DmaAnalySettingDefineMapper.xml
  27. 248 0
      src/main/resources/mapper/DmaAnalySettingLossTargetMapper.xml
  28. 140 0
      src/main/resources/mapper/DmaAnalySettingMapper.xml

+ 1 - 1
sql.properties

@@ -1,4 +1,4 @@
-spring.datasource.data.jdbc-url=jdbc:postgresql://140.246.183.164:5432/water_smart_develop_branch?useSSL=false&useAffectedRows=false&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai
+spring.datasource.data.jdbc-url=jdbc:postgresql://140.246.183.164:5432/water_smart_develop_branch?useSSL=false&useAffectedRows=false&allowMultiQueries=true&rewriteBatchedStatements=true&serverTimezone=Asia/Shanghai&stringtype=unspecified
 spring.datasource.data.username=postgres
 spring.datasource.data.password=kpr.23417.postgres
 

+ 115 - 0
src/main/java/com/shkpr/service/alambizplugin/apiparam/DmaAnalySettingLossTargetParams.java

@@ -0,0 +1,115 @@
+package com.shkpr.service.alambizplugin.apiparam;
+
+import com.shkpr.service.alambizplugin.commtools.BeanUtil;
+import com.shkpr.service.alambizplugin.constants.DmaAnalySettingType;
+import com.shkpr.service.alambizplugin.controllervalid.CommonParamValidSK;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget;
+import lombok.Getter;
+import lombok.Setter;
+import org.apache.commons.lang3.ObjectUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.Objects;
+
+/**
+ * 漏控目标入参
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Getter
+@Setter
+public class DmaAnalySettingLossTargetParams {
+    /**
+     * 分区ID
+     */
+    @NotNull(groups = {CommonParamValidSK.class})
+    @Size(max = 64, groups = {CommonParamValidSK.class})
+    private String zoneId;
+
+    /**
+     * 设置类型 (0-通用设置, 1-专用设置)
+     */
+    @NotNull(groups = {CommonParamValidSK.class})
+    private Short settingType;
+
+    /**
+     * 目标年份
+     */
+    @NotNull(groups = {CommonParamValidSK.class})
+    private Short targetYear;
+
+    /**
+     * 年产销差率 (%)
+     */
+    private Double annualNrwRatio;
+
+    /**
+     * 年产销差率下降值 (%)
+     */
+    private Double annualNrwRatioReduce;
+
+    /**
+     * 月产销差率下降值 (%)
+     */
+    private Double monthlyNrwRatioReduce;
+
+    /**
+     * 年漏损率 (%)
+     */
+    private Double annualLossRatio;
+
+    /**
+     * 年漏损率下降值 (%)
+     */
+    private Double annualLossRatioReduce;
+
+    /**
+     * 月漏损率下降值 (%)
+     */
+    private Double monthlyLossRatioReduce;
+
+    /**
+     * 年漏失率 (%)
+     */
+    private Double annualLossLeakRatio;
+
+    /**
+     * 年漏失率下降值 (%)
+     */
+    private Double annualLossLeakRatioReduce;
+
+    /**
+     * 月漏失率下降值 (%)
+     */
+    private Double monthlyLossLeakRatioReduce;
+
+    /**
+     * 入参校验
+     *
+     * @return 校验状态
+     */
+    public boolean checkValid() {
+        //必填项
+        if (StringUtils.isBlank(zoneId) || zoneId.length() > 64 || settingType == null || targetYear == null)
+            return false;
+        //通用类型,全必填
+        if (Objects.equals(DmaAnalySettingType.COMMON.getCode(), settingType)) {
+            return ObjectUtils.allNotNull(annualNrwRatio, annualNrwRatioReduce, monthlyNrwRatioReduce,
+                    annualLossRatio, annualLossRatioReduce, monthlyLossRatioReduce,
+                    annualLossLeakRatio, annualLossLeakRatioReduce, monthlyLossLeakRatioReduce);
+        }
+        return true;
+    }
+
+    /**
+     * 转dto
+     *
+     * @return dto
+     */
+    public DmaAnalySettingLossTarget toDto() {
+        return BeanUtil.copy(this, DmaAnalySettingLossTarget.class);
+    }
+}

+ 109 - 0
src/main/java/com/shkpr/service/alambizplugin/apiparam/DmaAnalySettingParams.java

@@ -0,0 +1,109 @@
+package com.shkpr.service.alambizplugin.apiparam;
+
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.shkpr.service.alambizplugin.constants.DataType;
+import com.shkpr.service.alambizplugin.constants.DmaAnalySettingType;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySetting;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefine;
+import lombok.Data;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.IOException;
+import java.util.List;
+import java.util.Objects;
+
+/**
+ * 分析设置入参
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Data
+public class DmaAnalySettingParams {
+    private final static ObjectMapper objectMapper = new ObjectMapper();
+    /**
+     * 分区id,通用为:common
+     */
+    private String zoneId;
+    /**
+     * 设置类型,0-通用设置, 1-专用设置
+     */
+    private Short settingType;
+    /**
+     * 种类
+     */
+    private String kind;
+    /**
+     * 设置项
+     */
+    private List<Setting> settings;
+
+    /**
+     * 校验
+     *
+     * @return 校验状态
+     */
+    public Boolean checkValid(List<DmaAnalySettingDefine> defines) {
+        //必填项
+        if (StringUtils.isAnyBlank(zoneId, kind) || zoneId.length() > 64 || settingType == null)
+            return false;
+        //通用类型
+        if (Objects.equals(DmaAnalySettingType.COMMON.getCode(), settingType)) {
+            return CollectionUtils.isNotEmpty(settings) && settings.size() == defines.size();
+        }
+        //检查数据类型
+        for (DmaAnalySettingDefine define : defines) {
+            //设置
+            DmaAnalySettingParams.Setting setting = settings.stream()
+                    .filter(it -> define.getKey().equals(it.getKey())).findFirst().orElse(null);
+            if (setting == null) continue;
+            //验证数据
+            if (!DataType.valueOf(define.getDataType().toUpperCase()).valida(setting.getValue())) return false;
+        }
+        return true;
+    }
+
+    /**
+     * 设置
+     */
+    @Data
+    public static class Setting {
+        /**
+         * 设置key
+         */
+        private String key;
+        /**
+         * 值
+         */
+        private String value;
+
+        /**
+         * 转dto
+         *
+         * @param zoneId      分区id
+         * @param settingType 设置类型
+         * @param kind        种类
+         * @param define      定义
+         * @return dto
+         */
+        public DmaAnalySetting toDto(String zoneId, Short settingType, String kind, DmaAnalySettingDefine define) throws IOException {
+            //构建dto
+            DmaAnalySetting dmaAnalySetting = new DmaAnalySetting();
+            dmaAnalySetting.setZoneId(zoneId);
+            dmaAnalySetting.setSettingType(settingType);
+            dmaAnalySetting.setKind(kind);
+            dmaAnalySetting.setKey(key);
+
+            //json不兼容处理
+            DataType dataType = DataType.valueOf(define.getDataType().toUpperCase());
+            if (dataType == DataType.STRING || dataType == DataType.TIME || dataType == DataType.DATE || dataType == DataType.DATETIME) {
+                dmaAnalySetting.setValue(objectMapper.readTree("\"" + value + "\""));
+            } else {
+                dmaAnalySetting.setValue(objectMapper.readTree(value));
+            }
+            return dmaAnalySetting;
+        }
+    }
+}

+ 17 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/ApiURI.java

@@ -46,6 +46,20 @@ public class ApiURI {
     public static final String URI_XXX_WARING_INFO_LIST = "waring-info-list";
     public static final String URI_XXX_WARING_INFO_REMOVE = "waring-info-remove";
 
+    public static final String URI_XXX_ANALY_SETTING_DEFINE_LIST = "analy-setting-define-list";
+
+    public static final String URI_XXX_ANALY_SETTING_UPSERT = "analy-setting-upsert";
+    public static final String URI_XXX_ANALY_SETTING_DEFAULT_LIST = "analy-setting-default-list";
+    public static final String URI_XXX_ANALY_SETTING_LIST = "analy-setting-list";
+    public static final String URI_XXX_ANALY_SETTING_DEFAULT_DETAIL = "analy-setting-default-detail";
+
+    public static final String URI_XXX_LOSS_TARGET_UPSERT = "loss-target-upsert";
+    public static final String URI_XXX_LOSS_TARGET_DEFAULT_LIST = "loss-target-default-list";
+    public static final String URI_XXX_LOSS_TARGET_LIST = "loss-target-list";
+    public static final String URI_XXX_LOSS_TARGET_DEFAULT_DETAIL = "loss-target-default-detail";
+    public static final String URI_XXX_LOSS_TARGET_DETAIL = "loss-target-detail";
+    public static final String URI_XXX_LOSS_TARGET_DEL = "loss-target-del";
+
     public static final String URI_XXX_TEMP_FILES = "temp-files";
     public static final String URI_XXX_ASYNC_RESULTS = "async-results";
 
@@ -61,6 +75,9 @@ public class ApiURI {
     public static final String URI_PIPE_BURST_H = "/kpr-plugin/pipe_burst";
     public static final String URI_PIPE_BURST_XXX = URI_PIPE_BURST_H + "/**";
 
+    public static final String URI_DMA_ANALY_SETTING_H = "/kpr-plugin/dma-analy-setting";
+    public static final String URI_DMA_ANALY_SETTING_XXX = URI_DMA_ANALY_SETTING_H + "/**";
+
     public static final String URI_USERS_H = "/kpr-plugin/users";
     public static final String URI_USERS_XXX = URI_USERS_H + "/**";
 

+ 103 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/DataType.java

@@ -0,0 +1,103 @@
+package com.shkpr.service.alambizplugin.constants;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.commons.lang3.StringUtils;
+
+import java.io.IOException;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.format.DateTimeFormatter;
+import java.time.format.DateTimeParseException;
+
+/**
+ * 数据类型
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+public enum DataType {
+    /**
+     * 数组
+     */
+    ARRAY,
+    /**
+     * 布尔
+     */
+    BOOLEAN,
+    /**
+     * 数字
+     */
+    NUMBER,
+    /**
+     * 对象
+     */
+    OBJECT,
+    /**
+     * 字符串
+     */
+    STRING,
+    /**
+     * 时间
+     */
+    TIME,
+    /**
+     * 日期
+     */
+    DATE,
+    /**
+     * 日期时间
+     */
+    DATETIME,
+    ;
+
+    private final static ObjectMapper OBJECT_MAPPER = new ObjectMapper();
+
+    /**
+     * 验证
+     *
+     * @param value 值
+     * @return 验证状态
+     */
+    public Boolean valida(String value) {
+        if (StringUtils.isBlank(value)) return false;
+        try {
+            switch (this) {
+                case ARRAY:
+                    return OBJECT_MAPPER.readTree(value).isArray();
+                case BOOLEAN:
+                    return OBJECT_MAPPER.readTree(value).isBoolean();
+                case NUMBER:
+                    return OBJECT_MAPPER.readTree(value).isNumber();
+                case OBJECT:
+                    return OBJECT_MAPPER.readTree(value).isObject();
+                case STRING:
+                    return OBJECT_MAPPER.readTree(value).isTextual();
+                case TIME:
+                    try {
+                        LocalTime.parse(value, DateTimeFormatter.ofPattern("HH:mm:ss"));
+                        return true;
+                    } catch (DateTimeParseException e) {
+                        return false;
+                    }
+                case DATE:
+                    try {
+                        LocalDate.parse(value, DateTimeFormatter.ofPattern("yyyy-MM-dd"));
+                        return true;
+                    } catch (DateTimeParseException e) {
+                        return false;
+                    }
+                case DATETIME:
+                    try {
+                        LocalDateTime.parse(value, DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
+                        return true;
+                    } catch (DateTimeParseException e) {
+                        return false;
+                    }
+            }
+            return false;
+        } catch (IOException e) {
+            return false;
+        }
+    }
+}

+ 27 - 0
src/main/java/com/shkpr/service/alambizplugin/constants/DmaAnalySettingType.java

@@ -0,0 +1,27 @@
+package com.shkpr.service.alambizplugin.constants;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+/**
+ * DMA分析设置类型枚举
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@AllArgsConstructor
+@Getter
+public enum DmaAnalySettingType {
+    /**
+     * 通用
+     */
+    COMMON((short) 0),
+    /**
+     * 专用
+     */
+    SPECIFIC((short) 1);
+    /**
+     * code
+     */
+    public final Short code;
+}

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

@@ -40,6 +40,7 @@ public enum  LogFlagBusiType {
     BUSI_GIS_SURVEY_PROJECT_BIZ(36,"Gis Survey Project Biz"),
     BUSI_GIS_SURVEY(37,"Gis Survey Biz"),
     BUSI_PIPE_BURST(38,"Pipe Burst Biz"),
+    BUSI_DMA_ANALY(39,"DMA Analy Biz"),
 
     BUSI_INTERNAL(99,"Internal Busi"),
 

+ 890 - 0
src/main/java/com/shkpr/service/alambizplugin/controller/ApiDmaAnalySettingController.java

@@ -0,0 +1,890 @@
+package com.shkpr.service.alambizplugin.controller;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.global.base.log.LogLevelFlag;
+import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.alambizplugin.apiparam.DmaAnalySettingLossTargetParams;
+import com.shkpr.service.alambizplugin.apiparam.DmaAnalySettingParams;
+import com.shkpr.service.alambizplugin.commtools.CommTool;
+import com.shkpr.service.alambizplugin.constants.ApiURI;
+import com.shkpr.service.alambizplugin.constants.DmaAnalySettingType;
+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.controllervalid.CommonParamValidSK;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.DmaAnalySettingDefineService;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.DmaAnalySettingLossTargetService;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.DmaAnalySettingService;
+import com.shkpr.service.alambizplugin.dto.*;
+import com.shkpr.service.alambizplugin.exception.SelfException;
+import org.apache.commons.lang3.StringUtils;
+import org.springframework.validation.BindingResult;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * dma分析设置controller
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@RequestMapping(ApiURI.URI_DMA_ANALY_SETTING_H)
+@RestController
+public class ApiDmaAnalySettingController {
+    /**
+     * log
+     */
+    private final static String mStrClassName = "ApiDmaAnalySettingController";
+    private final static String mBizType = LogFlagBusiType.BUSI_DMA_ANALY.toStrValue();
+
+    final
+    ObjectMapper objectMapper;
+    final
+    DmaAnalySettingDefineService analySettingDefineService;
+    final
+    DmaAnalySettingService analySettingService;
+    final
+    DmaAnalySettingLossTargetService analySettingLossTargetService;
+
+    /**
+     * 计数器
+     */
+    private final AtomicInteger mSeqAnalySettingDefineListReq;
+    private final AtomicInteger mSeqAnalySettingUpsertReq;
+    private final AtomicInteger mSeqAnalySettingDefaultListReq;
+    private final AtomicInteger mSeqAnalySettingListReq;
+    private final AtomicInteger mSeqAnalySettingDefaultDetailReq;
+    private final AtomicInteger mSeqLossTargetUpsertReq;
+    private final AtomicInteger mSeqLossTargetDefaultListReq;
+    private final AtomicInteger mSeqLossTargetListReq;
+    private final AtomicInteger mSeqLossTargetDefaultDetailReq;
+    private final AtomicInteger mSeqLossTargetDetailReq;
+    private final AtomicInteger mSeqLossTargetDelReq;
+
+    public ApiDmaAnalySettingController(ObjectMapper objectMapper, DmaAnalySettingDefineService analySettingDefineService, DmaAnalySettingService analySettingService, DmaAnalySettingLossTargetService analySettingLossTargetService) {
+        this.mSeqAnalySettingDefineListReq = new AtomicInteger(0);
+        this.mSeqAnalySettingUpsertReq = new AtomicInteger(0);
+        this.mSeqAnalySettingDefaultListReq = new AtomicInteger(0);
+        this.mSeqAnalySettingListReq = new AtomicInteger(0);
+        this.mSeqAnalySettingDefaultDetailReq = new AtomicInteger(0);
+        this.mSeqLossTargetUpsertReq = new AtomicInteger(0);
+        this.mSeqLossTargetDefaultListReq = new AtomicInteger(0);
+        this.mSeqLossTargetListReq = new AtomicInteger(0);
+        this.mSeqLossTargetDefaultDetailReq = new AtomicInteger(0);
+        this.mSeqLossTargetDetailReq = new AtomicInteger(0);
+        this.mSeqLossTargetDelReq = new AtomicInteger(0);
+        this.objectMapper = objectMapper;
+        this.analySettingDefineService = analySettingDefineService;
+        this.analySettingService = analySettingService;
+        this.analySettingLossTargetService = analySettingLossTargetService;
+    }
+
+    /**
+     * 分析设置定义列表
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @return 分析设置定义列表
+     */
+    @GetMapping(value = ApiURI.URI_XXX_ANALY_SETTING_DEFINE_LIST)
+    public ResponseRes<String> analySettingDefineList(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "kind", required = false) String kind) {
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+
+        //begin
+        long llReqBefore = System.currentTimeMillis();
+        String strRunSeq = String.format("%d-%d", llReqBefore, mSeqAnalySettingDefineListReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        List<DmaAnalySettingDefine> pageResponse = analySettingDefineService.findAll(kind);
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (pageResponse != null) pageStr = objectMapper.writeValueAsString(pageResponse);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+    /**
+     * 合并分析设置
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param oJsonParam    参数
+     * @return 合并状态
+     * @throws SelfException selfException
+     */
+    @PostMapping(value = ApiURI.URI_XXX_ANALY_SETTING_UPSERT)
+    public ResponseRes<String> analySettingUpsert(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}) DmaAnalySettingParams oJsonParam
+            , BindingResult bindRes) throws SelfException {
+        //定义
+        List<DmaAnalySettingDefine> defines = new ArrayList<>();
+        if (oJsonParam != null && StringUtils.isNotEmpty(oJsonParam.getKind())) {
+            defines = analySettingDefineService.findAll(oJsonParam.getKind());
+        }
+        //入参校验
+        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 || !oJsonParam.checkValid(defines) || bindRes.hasErrors())
+            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, mSeqAnalySettingUpsertReq.incrementAndGet());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
+                , String.format("%s:%s seq:{%s} param:%s begin====>"
+                        , strPlatform
+                        , URI_PATH
+                        , strRunSeq
+                        , oJsonParam));
+
+        //构建result
+        ResponseRes<String> resResult = new ResponseRes<>();
+        resResult.setRescode(ResponseCode.RESULT_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+
+        //执行
+        Boolean result = analySettingService.upsertAll(oJsonParam, defines);
+        String resultStr = null;
+        try {
+            if (result != null) resultStr = objectMapper.writeValueAsString(result);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+
+        //执行成功
+        if (resultStr != null && result) {
+            resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+            resResult.setResdata(resultStr);
+        }
+        //执行失败
+        if (resultStr != null && !result) 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;
+    }
+
+    /**
+     * 分析设置默认列表
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param zoneId        分区id
+     * @param kind          种类
+     * @param offset        偏移数据
+     * @param limit         分页大小
+     * @return 分析设置列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_ANALY_SETTING_DEFAULT_LIST)
+    public ResponseRes<String> analySettingDefaultList(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "kind", required = false) String kind
+            , @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset
+            , @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) throws Exception {
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(zoneId) || limit > 200)
+            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, mSeqAnalySettingDefaultListReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        PageResponse<DmaAnalySettingDefault> pageResponse = analySettingService.findDefaultAll(zoneId, kind, PageRequest.of(offset, limit));
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (pageResponse != null) pageStr = objectMapper.writeValueAsString(pageResponse);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+
+    /**
+     * 分析设置列表
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param settingType   设置类型
+     * @param zoneId        分区id
+     * @param kind          种类
+     * @param offset        偏移数据
+     * @param limit         分页大小
+     * @return 分析设置列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_ANALY_SETTING_LIST)
+    public ResponseRes<String> analySettingList(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "settingType", required = false) Short settingType
+            , @RequestParam(value = "kind", required = false) String kind
+            , @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset
+            , @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) throws Exception {
+
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(zoneId) || settingType == null || limit > 200)
+            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, mSeqAnalySettingListReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        PageResponse<DmaAnalySetting> pageResponse = analySettingService.findAll(zoneId, settingType, kind, PageRequest.of(offset, limit));
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (pageResponse != null) pageStr = objectMapper.writeValueAsString(pageResponse);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+    /**
+     * 分析设置默认详情
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param zoneId        分区id
+     * @param kind          种类
+     * @return 分析设置列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_ANALY_SETTING_DEFAULT_DETAIL)
+    public ResponseRes<String> analySettingDefaultDetail(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "kind", required = false) String kind) throws Exception {
+        //入参校验
+        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(zoneId, kind) || zoneId.length() > 64 || kind.length() > 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, mSeqAnalySettingDefaultDetailReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        DmaAnalySettingDefault data = analySettingService.findDefaultOne(zoneId, kind);
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (data != null) pageStr = objectMapper.writeValueAsString(data);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+    /**
+     * 合并漏控目标
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param oJsonParam    参数
+     * @return 合并状态
+     * @throws SelfException selfException
+     */
+    @PostMapping(value = ApiURI.URI_XXX_LOSS_TARGET_UPSERT)
+    public ResponseRes<String> lossTargetUpsert(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}) DmaAnalySettingLossTargetParams 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 || !oJsonParam.checkValid() || bindRes.hasErrors())
+            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, mSeqLossTargetUpsertReq.incrementAndGet());
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName, strUserId
+                , String.format("%s:%s seq:{%s} param:%s begin====>"
+                        , strPlatform
+                        , URI_PATH
+                        , strRunSeq
+                        , oJsonParam));
+
+        //构建result
+        ResponseRes<String> resResult = new ResponseRes<>();
+        resResult.setRescode(ResponseCode.RESULT_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+
+        //执行
+        Boolean result = analySettingLossTargetService.upsert(oJsonParam.toDto());
+        String resultStr = null;
+        try {
+            if (result != null) resultStr = objectMapper.writeValueAsString(result);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+
+        //执行成功
+        if (resultStr != null && result) {
+            resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+            resResult.setResdata(resultStr);
+        }
+        //执行失败
+        if (resultStr != null && !result) 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;
+    }
+
+    /**
+     * 漏控目标默认列表
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param zoneId        分区id
+     * @param targetYear    目标年
+     * @param offset        偏移数据
+     * @param limit         分页大小
+     * @return 漏控目标列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_LOSS_TARGET_DEFAULT_LIST)
+    public ResponseRes<String> lossTargetDefaultList(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "targetYear", required = false) Short targetYear
+            , @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset
+            , @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) throws Exception {
+
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(zoneId) || limit > 200)
+            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, mSeqLossTargetDefaultListReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        PageResponse<DmaAnalySettingLossTarget> pageResponse = analySettingLossTargetService.findDefaultAll(zoneId, targetYear, PageRequest.of(offset, limit));
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (pageResponse != null) pageStr = objectMapper.writeValueAsString(pageResponse);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+
+    /**
+     * 漏控目标列表
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param settingType   设置类型
+     * @param zoneId        分区id
+     * @param targetYear    目标年
+     * @param offset        偏移数据
+     * @param limit         分页大小
+     * @return 漏控目标列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_LOSS_TARGET_LIST)
+    public ResponseRes<String> lossTargetList(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "settingType", required = false) Short settingType
+            , @RequestParam(value = "targetYear", required = false) Short targetYear
+            , @RequestParam(value = "offset", required = false, defaultValue = "0") Integer offset
+            , @RequestParam(value = "limit", required = false, defaultValue = "20") Integer limit) throws Exception {
+
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(zoneId) || settingType == null || limit > 200)
+            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, mSeqLossTargetListReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        PageResponse<DmaAnalySettingLossTarget> pageResponse = analySettingLossTargetService.findAll(zoneId, settingType, targetYear, PageRequest.of(offset, limit));
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (pageResponse != null) pageStr = objectMapper.writeValueAsString(pageResponse);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+    /**
+     * 漏控目标默认详情
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param zoneId        分区id
+     * @param targetYear    目标年
+     * @return 漏控目标列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_LOSS_TARGET_DEFAULT_DETAIL)
+    public ResponseRes<String> lossTargetDefaultDetail(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "targetYear", required = false) Short targetYear) throws Exception {
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(zoneId) || targetYear == null)
+            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, mSeqLossTargetDefaultDetailReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        DmaAnalySettingLossTarget data = analySettingLossTargetService.findDefaultOne(zoneId, targetYear);
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (data != null) pageStr = objectMapper.writeValueAsString(data);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+
+    /**
+     * 漏控目标详情
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param settingType   设置类型
+     * @param zoneId        分区id
+     * @param targetYear    目标年
+     * @return 漏控目标列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_LOSS_TARGET_DETAIL)
+    public ResponseRes<String> lossTargetDetail(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "settingType", required = false) Short settingType
+            , @RequestParam(value = "targetYear", required = false) Short targetYear) throws Exception {
+
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(zoneId) || settingType == null || targetYear == null)
+            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, mSeqLossTargetDetailReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //查询
+        DmaAnalySettingLossTarget data = analySettingLossTargetService.findOne(zoneId, settingType, targetYear);
+        resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+        String pageStr = null;
+        try {
+            if (data != null) pageStr = objectMapper.writeValueAsString(data);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+        resResult.setResdata(pageStr);
+
+        //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;
+    }
+
+    /**
+     * 删除漏控目标
+     *
+     * @param request       request
+     * @param strClientType 客户端类型
+     * @param strUserAgent  用户信息
+     * @param settingType   设置类型
+     * @param zoneId        分区id
+     * @param targetYear    目标年
+     * @return 漏控目标列表
+     * @throws SelfException selfException
+     */
+    @GetMapping(value = ApiURI.URI_XXX_LOSS_TARGET_DEL)
+    public ResponseRes<String> lossTargetDel(HttpServletRequest request
+            , @RequestHeader(value = ApiURI.HEADER_CLIENT_TYPE, required = false) String strClientType
+            , @RequestHeader(value = ApiURI.HEADER_USER_AGENT, required = false) String strUserAgent
+            , @RequestParam(value = "zoneId", required = false) String zoneId
+            , @RequestParam(value = "settingType", required = false) Short settingType
+            , @RequestParam(value = "targetYear", required = false) Short targetYear) throws Exception {
+
+        //入参校验
+        final String URI_PATH = request.getRequestURI();
+        final String strPlatform = CommTool.getPlatformByAgent(strClientType, strUserAgent);
+        final String strUserId = (String) request.getAttribute(TokenAuthenticationService.HEADER_USERID);
+        if (StringUtils.isBlank(zoneId) || settingType == null || targetYear == null ||
+                DmaAnalySettingType.COMMON.getCode().equals(settingType))
+            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, mSeqLossTargetDelReq.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_BAD.toStrCode());
+        resResult.setResmsg(ResponseCode.RESULT_BAD.toStrMsg());
+
+        //执行
+        Boolean result = analySettingLossTargetService.delete(zoneId, settingType, targetYear);
+        String resultStr = null;
+        try {
+            if (result != null) resultStr = objectMapper.writeValueAsString(result);
+        } catch (JsonProcessingException e) {
+            LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                    , String.format("Json序列化异常: error:%s", e));
+        }
+
+        //执行成功
+        if (resultStr != null && result) {
+            resResult.setRescode(ResponseCode.RESULT_NORMAL.toStrCode());
+            resResult.setResmsg(ResponseCode.RESULT_NORMAL.toStrMsg());
+            resResult.setResdata(resultStr);
+        }
+        //执行失败
+        if (resultStr != null && !result) 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;
+    }
+}

+ 7 - 0
src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTBizFilterMgr.java

@@ -18,11 +18,13 @@ public class ApiJWTBizFilterMgr extends JWTAuthenticationFilter {
     private RequestMatcher mRequestMatcherForCommon = null;
     private RequestMatcher mRequestMatcherForGisSurvey = null;
     private RequestMatcher mRequestMatcherForPipeBurst = null;
+    private RequestMatcher mRequestMatcherForDmaAnalySetting = null;
 
     private ApiJWTUserBizFilter mFilterForUser = null;
     private ApiJWTCommonBizFilter mFilterForCommon = null;
     private ApiJWTGisSurveyBizFilter mFilterForGisSurvey = null;
     private ApiJWTPipeBurstBizFilter mFilterForPipeBurst = null;
+    private ApiJWTDmaAnalySettingBizFilter mFilterForDmaAnalySetting = null;
 
     public ApiJWTBizFilterMgr(AuthenticationManager authenticationManager) {
         this(null, authenticationManager);
@@ -36,11 +38,13 @@ public class ApiJWTBizFilterMgr extends JWTAuthenticationFilter {
         mRequestMatcherForCommon = new AntPathRequestMatcher(ApiURI.URI_COMMON_XXX);
         mRequestMatcherForGisSurvey = new AntPathRequestMatcher(ApiURI.URI_GIS_SURVEY_XXX);
         mRequestMatcherForPipeBurst = new AntPathRequestMatcher(ApiURI.URI_PIPE_BURST_XXX);
+        mRequestMatcherForDmaAnalySetting = new AntPathRequestMatcher(ApiURI.URI_DMA_ANALY_SETTING_XXX);
 
         mFilterForUser = new ApiJWTUserBizFilter(ApiURI.URI_USERS_XXX, authenticationManager);
         mFilterForCommon = new ApiJWTCommonBizFilter(ApiURI.URI_COMMON_XXX, authenticationManager);
         mFilterForGisSurvey = new ApiJWTGisSurveyBizFilter(ApiURI.URI_GIS_SURVEY_XXX, authenticationManager);
         mFilterForPipeBurst = new ApiJWTPipeBurstBizFilter(ApiURI.URI_PIPE_BURST_XXX, authenticationManager);
+        mFilterForDmaAnalySetting = new ApiJWTDmaAnalySettingBizFilter(ApiURI.URI_DMA_ANALY_SETTING_XXX, authenticationManager);
         //setControllerCheck(null);
     }
 
@@ -60,6 +64,9 @@ public class ApiJWTBizFilterMgr extends JWTAuthenticationFilter {
             } else if (mRequestMatcherForPipeBurst!= null && mRequestMatcherForPipeBurst.matches(request)){
                 TraceLogMgr.setTraceIdByBusinessType("PIPE.BURST");
                 mFilterForPipeBurst.doFilterInternal(request, response, chain);
+            }else if (mRequestMatcherForDmaAnalySetting!= null && mRequestMatcherForDmaAnalySetting.matches(request)){
+                TraceLogMgr.setTraceIdByBusinessType("DMA.ANALY.SETTING");
+                mFilterForDmaAnalySetting.doFilterInternal(request, response, chain);
             }
             else {
                 TraceLogMgr.setTraceIdByBusinessType("OTH");

+ 55 - 0
src/main/java/com/shkpr/service/alambizplugin/controllerfilter/third/ApiJWTDmaAnalySettingBizFilter.java

@@ -0,0 +1,55 @@
+package com.shkpr.service.alambizplugin.controllerfilter.third;
+
+import com.shkpr.service.alambizplugin.constants.ApiURI;
+import com.shkpr.service.alambizplugin.controllercheck.ApiUserControllerCheck;
+import com.shkpr.service.alambizplugin.controllercheck.JWTControllerCheck;
+import com.shkpr.service.alambizplugin.controllerfilter.JWTAuthenticationFilter;
+import org.springframework.security.authentication.AuthenticationManager;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+public class ApiJWTDmaAnalySettingBizFilter extends JWTAuthenticationFilter {
+    private static final Map<String, String> msMapURI2Method;
+
+    static {
+        msMapURI2Method = new HashMap<String, String>();
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_ANALY_SETTING_DEFINE_LIST), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_ANALY_SETTING_UPSERT), "POST");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_ANALY_SETTING_DEFAULT_LIST), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_ANALY_SETTING_LIST), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_ANALY_SETTING_DEFAULT_DETAIL), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_LOSS_TARGET_UPSERT), "POST");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_LOSS_TARGET_DEFAULT_LIST), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_LOSS_TARGET_LIST), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_LOSS_TARGET_DEFAULT_DETAIL), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_LOSS_TARGET_DETAIL), "GET");
+        msMapURI2Method.put(String.format("%s/%s", ApiURI.URI_DMA_ANALY_SETTING_H, ApiURI.URI_XXX_LOSS_TARGET_DEL), "GET");
+    }
+
+    private JWTControllerCheck mControllerCheck = null;
+
+    public ApiJWTDmaAnalySettingBizFilter(String url, AuthenticationManager authenticationManager) {
+        super(url, authenticationManager);
+        this.mStrThisSampleName = this.getClass().getSimpleName();
+        this.mControllerCheck = new ApiUserControllerCheck(msMapURI2Method);
+        setControllerCheck(this.mControllerCheck);
+    }
+
+    public ApiJWTDmaAnalySettingBizFilter(AuthenticationManager authenticationManager) {
+        super(authenticationManager);
+        this.mStrThisSampleName = this.getClass().getSimpleName();
+        this.mControllerCheck = new ApiUserControllerCheck(msMapURI2Method);
+        setControllerCheck(this.mControllerCheck);
+    }
+
+    @Override
+    public void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
+        super.doFilterInternal(request, response, chain);
+    }
+}

+ 24 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/DmaAnalySettingDefineMapper.java

@@ -0,0 +1,24 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefine;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+
+import java.util.List;
+
+/**
+ * dma分析设置定义mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Mapper
+public interface DmaAnalySettingDefineMapper {
+    /**
+     * 根据种类查询
+     *
+     * @param kind 种类
+     * @return 实体集合
+     */
+    List<DmaAnalySettingDefine> findAllByKind(@Param("kind") String kind);
+}

+ 109 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/DmaAnalySettingLossTargetMapper.java

@@ -0,0 +1,109 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * dma分析设置漏损目标mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Mapper
+public interface DmaAnalySettingLossTargetMapper {
+    /**
+     * 合并
+     *
+     * @param record 对象
+     * @return 保存数量
+     */
+    int upsert(DmaAnalySettingLossTarget record);
+
+    /**
+     * 合并当前年
+     * @return 合并项
+     */
+    int upsertCurrentYear();
+
+    /**
+     * 根据分区id,设置类型,目标年份查询默认集合
+     *
+     * @param zoneId     分区id
+     * @param targetYear 目标年份
+     * @param pageable   分页
+     * @return 实体
+     */
+    List<DmaAnalySettingLossTarget> findAllDefaultByZoneIdAndSettingTypeAndTargetYear(@Param("zoneId") String zoneId
+            , @Param("targetYear") Short targetYear, @Param("pageable") Pageable pageable);
+
+    /**
+     * 根据分区id,设置类型,目标年份查询集合
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @param pageable    分页
+     * @return 实体
+     */
+    List<DmaAnalySettingLossTarget> findAllByZoneIdAndSettingTypeAndTargetYear(@Param("zoneId") String zoneId
+            , @Param("settingType") Short settingType, @Param("targetYear") Short targetYear
+            , @Param("pageable") Pageable pageable);
+
+    /**
+     * 根据分区id,设置类型,目标年份查询默认
+     *
+     * @param zoneId     分区id
+     * @param targetYear 目标年份
+     * @return 实体
+     */
+    DmaAnalySettingLossTarget findOneDefaultByZoneIdAndSettingTypeAndTargetYear(@Param("zoneId") String zoneId
+            , @Param("targetYear") Short targetYear);
+
+    /**
+     * 根据分区id,设置类型,目标年份查询
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @return 实体
+     */
+    DmaAnalySettingLossTarget findOneByZoneIdAndSettingTypeAndTargetYear(@Param("zoneId") String zoneId
+            , @Param("settingType") Short settingType, @Param("targetYear") Short targetYear);
+
+    /**
+     * 根据分区id,设置类型,目标年份查询默认设置总数
+     *
+     * @param zoneId     分区id
+     * @param targetYear 目标年份
+     * @return 总数
+     */
+    long countDefaultByZoneIdAndSettingTypeAndTargetYear(@Param("zoneId") String zoneId
+            , @Param("targetYear") Short targetYear);
+
+    /**
+     * 根据分区id,设置类型,目标年份查询总数
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @return 总数
+     */
+    long countByZoneIdAndSettingTypeAndTargetYear(@Param("zoneId") String zoneId
+            , @Param("settingType") Short settingType, @Param("targetYear") Short targetYear);
+
+    /**
+     * 根据分区id,设置类型,目标年份删除
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @return 删除项
+     */
+    int deleteByZoneIdAndSettingTypeAndTargetYear(@Param("zoneId") String zoneId
+            , @Param("settingType") Short settingType, @Param("targetYear") Short targetYear);
+
+}

+ 93 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/mapper/DmaAnalySettingMapper.java

@@ -0,0 +1,93 @@
+package com.shkpr.service.alambizplugin.dbdao.mapper;
+
+import com.shkpr.service.alambizplugin.dto.DmaAnalySetting;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefault;
+import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * dma分析设置mapper
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Mapper
+public interface DmaAnalySettingMapper {
+    /**
+     * 合并
+     *
+     * @param record 对象
+     * @return 保存数量
+     */
+    int upsert(DmaAnalySetting record);
+
+    /**
+     * 根据分区id,设置类型,种类查询默认集合
+     *
+     * @param zoneId   分区id
+     * @param kind     种类
+     * @param pageable 分页
+     * @return 实体
+     */
+    List<DmaAnalySettingDefault> findAllDefaultByZoneIdAndSettingTypeAndKind(@Param("zoneId") String zoneId
+            , @Param("kind") String kind, @Param("pageable") Pageable pageable);
+
+    /**
+     * 根据分区id,设置类型,种类查询集合
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param kind        种类
+     * @param pageable    分页
+     * @return 实体
+     */
+    List<DmaAnalySetting> findAllByZoneIdAndSettingTypeAndKind(@Param("zoneId") String zoneId
+            , @Param("settingType") Short settingType, @Param("kind") String kind
+            , @Param("pageable") Pageable pageable);
+
+    /**
+     * 根据分区id,设置类型,种类查询默认
+     *
+     * @param zoneId 分区id
+     * @param kind   种类
+     * @return 实体
+     */
+    DmaAnalySettingDefault findOneDefaultByZoneIdAndSettingTypeAndKind(@Param("zoneId") String zoneId
+            , @Param("kind") String kind);
+
+    /**
+     * 根据分区id,设置类型,种类查询默认设置总数
+     *
+     * @param zoneId 分区id
+     * @param kind   种类
+     * @return 总数
+     */
+    long countDefaultByZoneIdAndSettingTypeAndKind(@Param("zoneId") String zoneId
+            , @Param("kind") String kind);
+
+    /**
+     * 根据分区id,设置类型,种类查询总数
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param kind        种类
+     * @return 总数
+     */
+    long countByZoneIdAndSettingTypeAndKind(@Param("zoneId") String zoneId
+            , @Param("settingType") Short settingType, @Param("kind") String kind);
+
+    /**
+     * 根据分区id,设置类型,设置键删除
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param kind        种类
+     * @param keys        key集合
+     * @return 删除数量
+     */
+    int deleteByZoneIdAndSettingTypeAndKey(@Param("zoneId") String zoneId
+            , @Param("settingType") Short settingType, @Param("kind") String kind, @Param("keys") List<String> keys);
+}

+ 0 - 53
src/main/java/com/shkpr/service/alambizplugin/dbdao/pgtype/JSONTypeHandlerPg.java

@@ -1,53 +0,0 @@
-package com.shkpr.service.alambizplugin.dbdao.pgtype;
-import com.global.base.tools.FastJsonUtil;
-import org.apache.ibatis.type.BaseTypeHandler;
-import org.apache.ibatis.type.JdbcType;
-import org.apache.ibatis.type.MappedJdbcTypes;
-import org.apache.ibatis.type.MappedTypes;
-
-import java.sql.CallableStatement;
-import java.sql.PreparedStatement;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import org.postgresql.util.*;
-
-/**
- * 读取时,将数据库中的jsonb转换为json object并返回
- *         使用:@Results({@Result(property = "字段", column = "字段", javaType = Object.class ,jdbcType = JdbcType.OTHER, typeHandler = JSONTypeHandlerPg.class)})
- * 写入时,将json object转换为jsonb并写入
- *         使用:#{字段,javaType=Object,jdbcType=OTHER,typeHandler=com.sqlmybatis.test.pgtype.JSONTypeHandlerPg}
- *
- *  1.@MappedJdbcTypes定义的是JdbcType类型,这里的类型不可自己随意定义,
- *      必须要是枚举类org.apache.ibatis.type.JdbcType所枚举的数据类型。
- *  2.@MappedTypes定义的是JavaType的数据类型,描述了哪些Java类型可被拦截
- */
-@MappedJdbcTypes(JdbcType.OTHER)
-@MappedTypes(Object.class)
-public class JSONTypeHandlerPg extends BaseTypeHandler<Object> {
-    @Override
-    public void setNonNullParameter(PreparedStatement preparedStatement, int i, Object o, JdbcType jdbcType) throws SQLException {
-        if (o == null){
-            preparedStatement.setString(i, "");
-            return;
-        }
-        PGobject jsonObject = new PGobject();
-        jsonObject.setType("jsonb");
-        jsonObject.setValue(FastJsonUtil.toJSON(o));
-        preparedStatement.setObject(i, jsonObject);
-    }
-
-    @Override
-    public Object getNullableResult(ResultSet resultSet, String s) throws SQLException {
-        return FastJsonUtil.fromJSON(resultSet.getString(s), Object.class);
-    }
-
-    @Override
-    public Object getNullableResult(ResultSet resultSet, int i) throws SQLException {
-        return FastJsonUtil.fromJSON(resultSet.getString(i), Object.class);
-    }
-
-    @Override
-    public Object getNullableResult(CallableStatement callableStatement, int i) throws SQLException {
-        return FastJsonUtil.fromJSON(callableStatement.getString(i), Object.class);
-    }
-}

+ 104 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/pgtype/JsonTypeHandlerPg.java

@@ -0,0 +1,104 @@
+package com.shkpr.service.alambizplugin.dbdao.pgtype;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import org.apache.ibatis.type.BaseTypeHandler;
+import org.apache.ibatis.type.JdbcType;
+import org.apache.ibatis.type.MappedJdbcTypes;
+import org.apache.ibatis.type.MappedTypes;
+
+import java.io.IOException;
+import java.sql.CallableStatement;
+import java.sql.PreparedStatement;
+import java.sql.ResultSet;
+import java.sql.SQLException;
+
+/**
+ * json类型处理器
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@MappedTypes({JsonNode.class})
+@MappedJdbcTypes(JdbcType.VARCHAR)
+public class JsonTypeHandlerPg extends BaseTypeHandler<JsonNode> {
+    private static final ObjectMapper objectMapper = new ObjectMapper();
+
+    /**
+     * 解析
+     *
+     * @param str 字符串
+     * @return 数据
+     * @throws SQLException sql异常
+     */
+    public static JsonNode parseString(String str) throws SQLException {
+        //非空校验
+        if (str == null || str.isEmpty()) return null;
+        try {
+            //序列化
+            return objectMapper.readTree(str);
+        } catch (IOException e) {
+            throw new SQLException("json格式无效: " + str);
+        }
+    }
+
+    /**
+     * 转字符串
+     *
+     * @param data 数据
+     * @return 字符串
+     * @throws SQLException sql异常
+     */
+    public static String toString(JsonNode data) throws SQLException {
+        if (data == null) return null;
+        try {
+            //反序列化
+            return objectMapper.writeValueAsString(data);
+        } catch (IOException e) {
+            throw new SQLException("json格式无效: " + data);
+        }
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public void setNonNullParameter(PreparedStatement ps, int i, JsonNode jsonNode, JdbcType jdbcType)
+            throws SQLException {
+        if (jsonNode != null) {
+            //将点序列化化为字符串
+            String lineStr = toString(jsonNode);
+            if (lineStr != null) {
+                ps.setString(i, lineStr);
+                return;
+            }
+        }
+        //处理空值
+        ps.setNull(i, JdbcType.VARCHAR.TYPE_CODE);
+
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonNode getNullableResult(ResultSet rs, String columnName) throws SQLException {
+        return rs.wasNull() ? null : parseString(rs.getString(columnName));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonNode getNullableResult(ResultSet rs, int columnIndex) throws SQLException {
+        return rs.wasNull() ? null : parseString(rs.getString(columnIndex));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Override
+    public JsonNode getNullableResult(CallableStatement cs, int columnIndex) throws SQLException {
+        return cs.wasNull() ? null : parseString(cs.getString(columnIndex));
+    }
+}

+ 35 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/DmaAnalySettingDefineServiceImpl.java

@@ -0,0 +1,35 @@
+package com.shkpr.service.alambizplugin.dbdao.services;
+
+import com.shkpr.service.alambizplugin.dbdao.mapper.DmaAnalySettingDefineMapper;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.DmaAnalySettingDefineService;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefine;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * dma分析设置定义service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Service
+public class DmaAnalySettingDefineServiceImpl implements DmaAnalySettingDefineService {
+    final
+    DmaAnalySettingDefineMapper dmaAnalySettingDefineMapper;
+
+    public DmaAnalySettingDefineServiceImpl(DmaAnalySettingDefineMapper dmaAnalySettingDefineMapper) {
+        this.dmaAnalySettingDefineMapper = dmaAnalySettingDefineMapper;
+    }
+
+    /**
+     * 查询列表
+     *
+     * @param kind 定义
+     * @return 实体集合
+     */
+    @Override
+    public List<DmaAnalySettingDefine> findAll(String kind) {
+        return dmaAnalySettingDefineMapper.findAllByKind(kind);
+    }
+}

+ 131 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/DmaAnalySettingLossTargetServiceImpl.java

@@ -0,0 +1,131 @@
+package com.shkpr.service.alambizplugin.dbdao.services;
+
+import com.shkpr.service.alambizplugin.dbdao.mapper.DmaAnalySettingLossTargetMapper;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.DmaAnalySettingLossTargetService;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget;
+import com.shkpr.service.alambizplugin.dto.PageResponse;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.util.List;
+
+/**
+ * dma分析设置漏损目标service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Service
+public class DmaAnalySettingLossTargetServiceImpl implements DmaAnalySettingLossTargetService {
+    final
+    DmaAnalySettingLossTargetMapper analySettingLossTargetMapper;
+
+    public DmaAnalySettingLossTargetServiceImpl(DmaAnalySettingLossTargetMapper analySettingLossTargetMapper) {
+        this.analySettingLossTargetMapper = analySettingLossTargetMapper;
+    }
+
+    /**
+     * 合并
+     *
+     * @param lossTarget 漏损目标
+     * @return 保存状态
+     */
+    @Override
+    @Transactional("mainDbTransactionManager")
+    public Boolean upsert(DmaAnalySettingLossTarget lossTarget) {
+        return analySettingLossTargetMapper.upsert(lossTarget) > 0;
+    }
+
+    /**
+     * 查询默认列表
+     *
+     * @param zoneId     分区id
+     * @param targetYear 目标年份
+     * @param pageable   分页
+     * @return 实体集合
+     */
+    @Transactional("mainDbTransactionManager")
+    @Override
+    public PageResponse<DmaAnalySettingLossTarget> findDefaultAll(String zoneId, Short targetYear, Pageable pageable) {
+        //合并今年通用设置
+        analySettingLossTargetMapper.upsertCurrentYear();
+
+        //查询数据
+        List<DmaAnalySettingLossTarget> data = analySettingLossTargetMapper.findAllDefaultByZoneIdAndSettingTypeAndTargetYear(zoneId, targetYear, pageable);
+        long total = analySettingLossTargetMapper.countDefaultByZoneIdAndSettingTypeAndTargetYear(zoneId, targetYear);
+
+        return PageResponse.of(data, total, pageable);
+    }
+
+    /**
+     * 查询列表
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @param pageable    分页
+     * @return 实体集合
+     */
+    @Transactional("mainDbTransactionManager")
+    @Override
+    public PageResponse<DmaAnalySettingLossTarget> findAll(String zoneId, Short settingType, Short targetYear, Pageable pageable) {
+        //合并今年通用设置
+        analySettingLossTargetMapper.upsertCurrentYear();
+
+        //查询数据
+        List<DmaAnalySettingLossTarget> data = analySettingLossTargetMapper.findAllByZoneIdAndSettingTypeAndTargetYear(zoneId, settingType, targetYear, pageable);
+        long total = analySettingLossTargetMapper.countByZoneIdAndSettingTypeAndTargetYear(zoneId, settingType, targetYear);
+
+        return PageResponse.of(data, total, pageable);
+    }
+
+    /**
+     * 查询默认
+     *
+     * @param zoneId     分区id
+     * @param targetYear 目标年份
+     * @return 实体
+     */
+    @Transactional("mainDbTransactionManager")
+    @Override
+    public DmaAnalySettingLossTarget findDefaultOne(String zoneId, Short targetYear) {
+        //合并今年通用设置
+        analySettingLossTargetMapper.upsertCurrentYear();
+
+        //查询数据
+        return analySettingLossTargetMapper.findOneDefaultByZoneIdAndSettingTypeAndTargetYear(zoneId, targetYear);
+    }
+
+    /**
+     * 查询
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @return 实体
+     */
+    @Transactional("mainDbTransactionManager")
+    @Override
+    public DmaAnalySettingLossTarget findOne(String zoneId, Short settingType, Short targetYear) {
+        //合并今年通用设置
+        analySettingLossTargetMapper.upsertCurrentYear();
+
+        //查询数据
+        return analySettingLossTargetMapper.findOneByZoneIdAndSettingTypeAndTargetYear(zoneId, settingType, targetYear);
+    }
+
+    /**
+     * 硬删除
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @return 删除状态
+     */
+    @Transactional("mainDbTransactionManager")
+    @Override
+    public Boolean delete(String zoneId, Short settingType, Short targetYear) {
+        return analySettingLossTargetMapper.deleteByZoneIdAndSettingTypeAndTargetYear(zoneId, settingType, targetYear) > 0;
+    }
+}

+ 202 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/DmaAnalySettingServiceImpl.java

@@ -0,0 +1,202 @@
+package com.shkpr.service.alambizplugin.dbdao.services;
+
+import com.global.base.log.LogLevelFlag;
+import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.alambizplugin.apiparam.DmaAnalySettingParams;
+import com.shkpr.service.alambizplugin.constants.LogFlagBusiType;
+import com.shkpr.service.alambizplugin.dbdao.mapper.DmaAnalySettingMapper;
+import com.shkpr.service.alambizplugin.dbdao.services.intef.DmaAnalySettingService;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySetting;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefault;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefine;
+import com.shkpr.service.alambizplugin.dto.PageResponse;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.ibatis.session.ExecutorType;
+import org.apache.ibatis.session.SqlSession;
+import org.apache.ibatis.session.SqlSessionFactory;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.data.domain.Pageable;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.io.IOException;
+import java.sql.Connection;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * dma分析设置漏损目标service实现
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Service
+public class DmaAnalySettingServiceImpl implements DmaAnalySettingService {
+    /**
+     * log
+     */
+    private final String mStrClassName;
+    private final String mBizType;
+
+    private final SqlSessionFactory mainSqlSessionFactory;
+    private final DmaAnalySettingMapper analySettingMapper;
+
+    public DmaAnalySettingServiceImpl(@Qualifier("mainSqlSessionFactory") SqlSessionFactory mainSqlSessionFactory, DmaAnalySettingMapper analySettingMapper) {
+        mStrClassName = "PipeBurstDataPressCurServiceImpl";
+        mBizType = LogFlagBusiType.BUSI_PIPE_BURST.toStrValue();
+        this.mainSqlSessionFactory = mainSqlSessionFactory;
+        this.analySettingMapper = analySettingMapper;
+    }
+
+    /**
+     * 批量合并
+     *
+     * @param params  参数
+     * @param defines 定义
+     * @return 保存状态
+     */
+    @Transactional("mainDbTransactionManager")
+    @Override
+    public Boolean upsertAll(DmaAnalySettingParams params, List<DmaAnalySettingDefine> defines) {
+        //参数
+        String zoneId = params.getZoneId();
+        Short settingType = params.getSettingType();
+        String kind = params.getKind();
+
+        //数据
+        List<DmaAnalySetting> dates = new ArrayList<>();
+        //需要删除的
+        List<String> toDelete = new ArrayList<>();
+        //设置项
+        List<DmaAnalySettingParams.Setting> settings = params.getSettings();
+
+        //遍历设置定义
+        for (DmaAnalySettingDefine define : defines) {
+            //获取设置
+            DmaAnalySettingParams.Setting setting = settings.stream()
+                    .filter(it -> define.getKey().equals(it.getKey())).findFirst().orElse(null);
+            //无设置则删除
+            if (setting == null) {
+                toDelete.add(define.getKey());
+                continue;
+            }
+
+            try {
+                //转dto
+                DmaAnalySetting dto = setting.toDto(zoneId, settingType, kind, define);
+                //填入数据
+                dates.add(dto);
+            } catch (IOException e) {
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                        , String.format(
+                                "数据转换失败 error:%s"
+                                , e
+                        )
+                );
+                return false;
+            }
+        }
+
+
+        LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                , String.format(
+                        "开始批量合并分析设置,开启批处理 数据量:%s"
+                        , dates.size()
+                )
+        );
+        long begin = System.currentTimeMillis();
+
+        //开启批处理
+        try (SqlSession sqlSession = mainSqlSessionFactory.openSession(ExecutorType.BATCH, false)) {
+            try {
+                //设置手动提交
+                Connection conn = sqlSession.getConnection();
+                conn.setAutoCommit(false);
+
+                //从session获取mapper
+                DmaAnalySettingMapper mapper = sqlSession.getMapper(DmaAnalySettingMapper.class);
+
+                //删除不存在的设置
+                if (CollectionUtils.isNotEmpty(toDelete))
+                    mapper.deleteByZoneIdAndSettingTypeAndKey(zoneId, settingType, kind, toDelete);
+
+                //批量合并
+                if (CollectionUtils.isNotEmpty(dates)) dates.forEach(mapper::upsert);
+
+                //发送sql至数据库
+                sqlSession.flushStatements();
+                //提交
+                sqlSession.commit();
+                conn.commit();
+
+                long end = System.currentTimeMillis();
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
+                        , String.format(
+                                "结束批量合并分析设置,提交并关闭批处理 用时(毫秒):%d"
+                                , (end - begin)
+                        )
+                );
+                return true;
+            } catch (Exception e) {
+                //回滚
+                sqlSession.rollback();
+
+                LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName
+                        , String.format(
+                                "批量合并分析设置,回滚操作 error:%s"
+                                , e
+                        )
+                );
+
+                return false;
+            }
+        }
+    }
+
+    /**
+     * 查询默认列表
+     *
+     * @param zoneId   分区id
+     * @param kind     种类
+     * @param pageable 分页
+     * @return 实体集合
+     */
+    @Override
+    public PageResponse<DmaAnalySettingDefault> findDefaultAll(String zoneId, String kind, Pageable pageable) {
+        //查询数据
+        List<DmaAnalySettingDefault> data = analySettingMapper.findAllDefaultByZoneIdAndSettingTypeAndKind(zoneId, kind, pageable);
+        long total = analySettingMapper.countDefaultByZoneIdAndSettingTypeAndKind(zoneId, kind);
+
+        return PageResponse.of(data, total, pageable);
+    }
+
+    /**
+     * 查询列表
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param kind        种类
+     * @param pageable    分页
+     * @return 实体集合
+     */
+    @Override
+    public PageResponse<DmaAnalySetting> findAll(String zoneId, Short settingType, String kind, Pageable pageable) {
+        //查询数据
+        List<DmaAnalySetting> data = analySettingMapper.findAllByZoneIdAndSettingTypeAndKind(zoneId, settingType, kind, pageable);
+        long total = analySettingMapper.countByZoneIdAndSettingTypeAndKind(zoneId, settingType, kind);
+
+        return PageResponse.of(data, total, pageable);
+    }
+
+    /**
+     * 查询默认
+     *
+     * @param zoneId 分区id
+     * @param kind   种类
+     * @return 实体
+     */
+    @Override
+    public DmaAnalySettingDefault findDefaultOne(String zoneId, String kind) {
+        return analySettingMapper.findOneDefaultByZoneIdAndSettingTypeAndKind(zoneId, kind);
+    }
+}

+ 21 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/DmaAnalySettingDefineService.java

@@ -0,0 +1,21 @@
+package com.shkpr.service.alambizplugin.dbdao.services.intef;
+
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefine;
+
+import java.util.List;
+
+/**
+ * dma分析设置定义service
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+public interface DmaAnalySettingDefineService {
+    /**
+     * 查询列表
+     *
+     * @param kind 定义
+     * @return 实体集合
+     */
+    List<DmaAnalySettingDefine> findAll(String kind);
+}

+ 71 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/DmaAnalySettingLossTargetService.java

@@ -0,0 +1,71 @@
+package com.shkpr.service.alambizplugin.dbdao.services.intef;
+
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget;
+import com.shkpr.service.alambizplugin.dto.PageResponse;
+import org.springframework.data.domain.Pageable;
+
+/**
+ * dma分析设置漏损目标service
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+public interface DmaAnalySettingLossTargetService {
+    /**
+     * 合并
+     *
+     * @param lossTarget 漏损目标
+     * @return 保存状态
+     */
+    Boolean upsert(DmaAnalySettingLossTarget lossTarget);
+
+    /**
+     * 查询默认列表
+     *
+     * @param zoneId     分区id
+     * @param targetYear 目标年份
+     * @param pageable   分页
+     * @return 实体集合
+     */
+    PageResponse<DmaAnalySettingLossTarget> findDefaultAll(String zoneId, Short targetYear, Pageable pageable);
+
+    /**
+     * 查询列表
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @param pageable    分页
+     * @return 实体集合
+     */
+    PageResponse<DmaAnalySettingLossTarget> findAll(String zoneId, Short settingType, Short targetYear, Pageable pageable);
+
+    /**
+     * 查询默认
+     *
+     * @param zoneId     分区id
+     * @param targetYear 目标年份
+     * @return 实体
+     */
+    DmaAnalySettingLossTarget findDefaultOne(String zoneId, Short targetYear);
+
+    /**
+     * 查询
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @return 实体
+     */
+    DmaAnalySettingLossTarget findOne(String zoneId, Short settingType, Short targetYear);
+
+    /**
+     * 硬删除
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param targetYear  目标年份
+     * @return 删除状态
+     */
+    Boolean delete(String zoneId, Short settingType, Short targetYear);
+}

+ 57 - 0
src/main/java/com/shkpr/service/alambizplugin/dbdao/services/intef/DmaAnalySettingService.java

@@ -0,0 +1,57 @@
+package com.shkpr.service.alambizplugin.dbdao.services.intef;
+
+import com.shkpr.service.alambizplugin.apiparam.DmaAnalySettingParams;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySetting;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefault;
+import com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefine;
+import com.shkpr.service.alambizplugin.dto.PageResponse;
+import org.springframework.data.domain.Pageable;
+
+import java.util.List;
+
+/**
+ * dma分析设置service
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+public interface DmaAnalySettingService {
+    /**
+     * 批量合并
+     *
+     * @param params  参数
+     * @param defines 定义
+     * @return 保存状态
+     */
+    Boolean upsertAll(DmaAnalySettingParams params, List<DmaAnalySettingDefine> defines);
+
+    /**
+     * 查询默认列表
+     *
+     * @param zoneId   分区id
+     * @param kind     种类
+     * @param pageable 分页
+     * @return 实体集合
+     */
+    PageResponse<DmaAnalySettingDefault> findDefaultAll(String zoneId, String kind, Pageable pageable);
+
+    /**
+     * 查询列表
+     *
+     * @param zoneId      分区id
+     * @param settingType 设置类型
+     * @param kind        种类
+     * @param pageable    分页
+     * @return 实体集合
+     */
+    PageResponse<DmaAnalySetting> findAll(String zoneId, Short settingType, String kind, Pageable pageable);
+
+    /**
+     * 查询默认
+     *
+     * @param zoneId 分区id
+     * @param kind   种类
+     * @return 实体
+     */
+    DmaAnalySettingDefault findDefaultOne(String zoneId, String kind);
+}

+ 43 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySetting.java

@@ -0,0 +1,43 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.Data;
+
+/**
+ * 分析设置表
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Data
+public class DmaAnalySetting {
+    /**
+     * 分区id,通用为:common
+     */
+    private String zoneId;
+
+    /**
+     * 设置类型,0-通用设置, 1-专用设置
+     */
+    private Short settingType;
+
+    /**
+     * 种类
+     */
+    private String kind;
+
+    /**
+     * 设置key
+     */
+    private String key;
+
+    /**
+     * 值
+     */
+    private JsonNode value;
+
+    /**
+     * 激活状态
+     */
+    private Boolean enabled;
+}

+ 33 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySettingDefault.java

@@ -0,0 +1,33 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import com.fasterxml.jackson.databind.JsonNode;
+import lombok.Data;
+
+/**
+ * 分析设置默认信息
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Data
+public class DmaAnalySettingDefault {
+    /**
+     * 分区id,通用为0
+     */
+    private String zoneId;
+
+    /**
+     * 设置类型,0-通用设置, 1-专用设置
+     */
+    private Short settingType;
+
+    /**
+     * 种类
+     */
+    private String kind;
+
+    /**
+     * 设置项
+     */
+    private JsonNode settings;
+}

+ 57 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySettingDefine.java

@@ -0,0 +1,57 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import lombok.Data;
+
+/**
+ * 分析设置定义表
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Data
+public class DmaAnalySettingDefine {
+    /**
+     * 设置key
+     */
+    private String key;
+
+    /**
+     * 种类
+     */
+    private String kind;
+
+    /**
+     * 名称
+     */
+    private String name;
+
+    /**
+     * 数据类型
+     */
+    private String dataType;
+
+    /**
+     * 单位
+     */
+    private String unit;
+
+    /**
+     * 描述
+     */
+    private String description;
+
+    /**
+     * 预留参数1
+     */
+    private String param1;
+
+    /**
+     * 预留参数2
+     */
+    private String param2;
+
+    /**
+     * 排序
+     */
+    private Short ordering;
+}

+ 100 - 0
src/main/java/com/shkpr/service/alambizplugin/dto/DmaAnalySettingLossTarget.java

@@ -0,0 +1,100 @@
+package com.shkpr.service.alambizplugin.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.time.LocalDateTime;
+
+/**
+ * 分析设置漏损目标表
+ *
+ * @author 欧阳劲驰
+ * @since 1.3.0
+ */
+@Data
+public class DmaAnalySettingLossTarget {
+    /**
+     * 分区ID
+     */
+    private String zoneId;
+
+    /**
+     * 设置类型 (0-通用设置, 1-专用设置)
+     */
+    private Short settingType;
+
+    /**
+     * 目标年份
+     */
+    private Short targetYear;
+
+    /**
+     * 年产销差率 (%)
+     */
+    private Double annualNrwRatio;
+
+    /**
+     * 年产销差率下降值 (%)
+     */
+    private Double annualNrwRatioReduce;
+
+    /**
+     * 月产销差率下降值 (%)
+     */
+    private Double monthlyNrwRatioReduce;
+
+    /**
+     * 年漏损率 (%)
+     */
+    private Double annualLossRatio;
+
+    /**
+     * 年漏损率下降值 (%)
+     */
+    private Double annualLossRatioReduce;
+
+    /**
+     * 月漏损率下降值 (%)
+     */
+    private Double monthlyLossRatioReduce;
+
+    /**
+     * 年漏失率 (%)
+     */
+    private Double annualLossLeakRatio;
+
+    /**
+     * 年漏失率下降值 (%)
+     */
+    private Double annualLossLeakRatioReduce;
+
+    /**
+     * 月漏失率下降值 (%)
+     */
+    private Double monthlyLossLeakRatioReduce;
+
+    /**
+     * 预留参数1
+     */
+    private String param1;
+
+    /**
+     * 预留参数2
+     */
+    private String param2;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime createdTime;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", locale = "zh_CN", timezone = "Asia/Shanghai")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private LocalDateTime updatedTime;
+}

+ 20 - 0
src/main/resources/mapper/DmaAnalySettingDefineMapper.xml

@@ -0,0 +1,20 @@
+<?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.DmaAnalySettingDefineMapper">
+    <select id="findAllByKind" resultType="com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefine">
+        select id,
+        key,
+        kind,
+        name,
+        data_type,
+        unit,
+        description,
+        param1,
+        param2,
+        ordering
+        from k1_pgn_dma_analy_setting_define
+        <where>
+            <if test="kind != null and kind != ''">kind = #{kind,jdbcType=VARCHAR}</if>
+        </where>
+    </select>
+</mapper>

+ 248 - 0
src/main/resources/mapper/DmaAnalySettingLossTargetMapper.xml

@@ -0,0 +1,248 @@
+<?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.DmaAnalySettingLossTargetMapper">
+    <insert id="upsert">
+        insert into k1_pgn_dma_analy_setting_loss_target
+        (zone_id,
+         setting_type,
+         target_year,
+         updated_time,
+         annual_nrw_ratio,
+         annual_nrw_ratio_reduce,
+         monthly_nrw_ratio_reduce,
+         annual_loss_ratio,
+         annual_loss_ratio_reduce,
+         monthly_loss_ratio_reduce,
+         annual_loss_leak_ratio,
+         annual_loss_leak_ratio_reduce,
+         monthly_loss_leak_ratio_reduce)
+        values (#{zoneId,jdbcType=VARCHAR},
+                #{settingType,jdbcType=SMALLINT},
+                #{targetYear,jdbcType=SMALLINT},
+                localtimestamp(0),
+                #{annualNrwRatio,jdbcType=DOUBLE},
+                #{annualNrwRatioReduce,jdbcType=DOUBLE},
+                #{monthlyNrwRatioReduce,jdbcType=DOUBLE},
+                #{annualLossRatio,jdbcType=DOUBLE},
+                #{annualLossRatioReduce,jdbcType=DOUBLE},
+                #{monthlyLossRatioReduce,jdbcType=DOUBLE},
+                #{annualLossLeakRatio,jdbcType=DOUBLE},
+                #{annualLossLeakRatioReduce,jdbcType=DOUBLE},
+                #{monthlyLossLeakRatioReduce,jdbcType=DOUBLE})
+        on conflict (zone_id, setting_type, target_year)
+            do update set updated_time                   = excluded.updated_time,
+                          annual_nrw_ratio               = excluded.annual_nrw_ratio,
+                          annual_nrw_ratio_reduce        = excluded.annual_nrw_ratio_reduce,
+                          monthly_nrw_ratio_reduce       = excluded.monthly_nrw_ratio_reduce,
+                          annual_loss_ratio              = excluded.annual_loss_ratio,
+                          annual_loss_ratio_reduce       = excluded.annual_loss_ratio_reduce,
+                          monthly_loss_ratio_reduce      = excluded.monthly_loss_ratio_reduce,
+                          annual_loss_leak_ratio         = excluded.annual_loss_leak_ratio,
+                          annual_loss_leak_ratio_reduce  = excluded.annual_loss_leak_ratio_reduce,
+                          monthly_loss_leak_ratio_reduce = excluded.monthly_loss_leak_ratio_reduce
+    </insert>
+
+    <insert id="upsertCurrentYear">
+        with source_data as (select zone_id,
+                                    setting_type,
+                                    extract(year from current_date) as current_year,
+                                    annual_nrw_ratio,
+                                    annual_nrw_ratio_reduce,
+                                    monthly_nrw_ratio_reduce,
+                                    annual_loss_ratio,
+                                    annual_loss_ratio_reduce,
+                                    monthly_loss_ratio_reduce,
+                                    annual_loss_leak_ratio,
+                                    annual_loss_leak_ratio_reduce,
+                                    monthly_loss_leak_ratio_reduce,
+                                    param1,
+                                    param2,
+                                    target_year
+                             from k1_pgn_dma_analy_setting_loss_target
+                             where zone_id = 'common'
+                               and setting_type = 0
+                               and target_year = (select max(target_year)
+                                                  from k1_pgn_dma_analy_setting_loss_target
+                                                  where zone_id = 'common'
+                                                    and setting_type = 0))
+        insert
+        into k1_pgn_dma_analy_setting_loss_target (zone_id, setting_type, target_year,
+                                                   annual_nrw_ratio, annual_nrw_ratio_reduce, monthly_nrw_ratio_reduce,
+                                                   annual_loss_ratio, annual_loss_ratio_reduce,
+                                                   monthly_loss_ratio_reduce,
+                                                   annual_loss_leak_ratio, annual_loss_leak_ratio_reduce,
+                                                   monthly_loss_leak_ratio_reduce,
+                                                   param1, param2)
+        select zone_id,
+               setting_type,
+               current_year,
+               annual_nrw_ratio,
+               annual_nrw_ratio_reduce,
+               monthly_nrw_ratio_reduce,
+               annual_loss_ratio,
+               annual_loss_ratio_reduce,
+               monthly_loss_ratio_reduce,
+               annual_loss_leak_ratio,
+               annual_loss_leak_ratio_reduce,
+               monthly_loss_leak_ratio_reduce,
+               param1,
+               param2
+        from source_data
+        where not exists (select 1
+                          from k1_pgn_dma_analy_setting_loss_target
+                          where zone_id = 'common'
+                            and setting_type = 0
+                            and target_year = source_data.current_year);
+    </insert>
+    <select id="findAllDefaultByZoneIdAndSettingTypeAndTargetYear"
+            resultType="com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget">
+        select coalesce(specific.zone_id, common.zone_id) as zone_id,
+        coalesce(specific.setting_type, common.setting_type) as setting_type,
+        coalesce(specific.target_year, common.target_year) as target_year,
+        coalesce(specific.annual_nrw_ratio, common.annual_nrw_ratio) as annual_nrw_ratio,
+        coalesce(specific.annual_nrw_ratio_reduce,
+        common.annual_nrw_ratio_reduce) as annual_nrw_ratio_reduce,
+        coalesce(specific.monthly_nrw_ratio_reduce,
+        common.monthly_nrw_ratio_reduce) as monthly_nrw_ratio_reduce,
+        coalesce(specific.annual_loss_ratio, common.annual_loss_ratio) as annual_loss_ratio,
+        coalesce(specific.annual_loss_ratio_reduce,
+        common.annual_loss_ratio_reduce) as annual_loss_ratio_reduce,
+        coalesce(specific.monthly_loss_ratio_reduce,
+        common.monthly_loss_ratio_reduce) as monthly_loss_ratio_reduce,
+        coalesce(specific.annual_loss_leak_ratio,
+        common.annual_loss_leak_ratio) as annual_loss_leak_ratio,
+        coalesce(specific.annual_loss_leak_ratio_reduce,
+        common.annual_loss_leak_ratio_reduce) as annual_loss_leak_ratio_reduce,
+        coalesce(specific.monthly_loss_leak_ratio_reduce,
+        common.monthly_loss_leak_ratio_reduce) as monthly_loss_leak_ratio_reduce,
+        coalesce(specific.param1, common.param1) as param1,
+        coalesce(specific.param2, common.param2) as param2,
+        coalesce(specific.created_time, common.created_time) as created_time,
+        coalesce(specific.updated_time, common.updated_time) as updated_time
+        from (select * from k1_pgn_dma_analy_setting_loss_target where zone_id = 'common' and setting_type = 0) common
+        left join (select * from v_k1_pgn_dma_analy_setting_loss_target
+        <where>
+            zone_id = #{zoneId,jdbcType=VARCHAR}
+            <if test="targetYear != null">and target_year =#{targetYear,jdbcType=SMALLINT}</if>
+        </where>
+        ) specific on common.target_year = specific.target_year
+        <where>
+            <if test="targetYear != null">common.target_year =#{targetYear,jdbcType=SMALLINT}</if>
+        </where>
+        limit #{pageable.pageSize} offset #{pageable.offset}
+    </select>
+    <select id="findAllByZoneIdAndSettingTypeAndTargetYear"
+            resultType="com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget">
+        select
+        zone_id,
+        setting_type,
+        target_year,
+        annual_nrw_ratio,
+        annual_nrw_ratio_reduce,
+        monthly_nrw_ratio_reduce,
+        annual_loss_ratio,
+        annual_loss_ratio_reduce,
+        monthly_loss_ratio_reduce,
+        annual_loss_leak_ratio,
+        annual_loss_leak_ratio_reduce,
+        monthly_loss_leak_ratio_reduce,
+        param1,
+        param2,
+        created_time,
+        updated_time
+        from k1_pgn_dma_analy_setting_loss_target
+        <where>
+            zone_id = #{zoneId,jdbcType=VARCHAR}
+            and setting_type = #{settingType,jdbcType=SMALLINT}
+            <if test="targetYear != null">and target_year = #{targetYear,jdbcType=SMALLINT}</if>
+        </where>
+        limit #{pageable.pageSize} offset #{pageable.offset}
+    </select>
+    <select id="findOneDefaultByZoneIdAndSettingTypeAndTargetYear"
+            resultType="com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget">
+        select coalesce(specific.zone_id, common.zone_id)                     as zone_id,
+               coalesce(specific.setting_type, common.setting_type)           as setting_type,
+               coalesce(specific.target_year, common.target_year)             as target_year,
+               coalesce(specific.annual_nrw_ratio, common.annual_nrw_ratio)   as annual_nrw_ratio,
+               coalesce(specific.annual_nrw_ratio_reduce,
+                        common.annual_nrw_ratio_reduce)                       as annual_nrw_ratio_reduce,
+               coalesce(specific.monthly_nrw_ratio_reduce,
+                        common.monthly_nrw_ratio_reduce)                      as monthly_nrw_ratio_reduce,
+               coalesce(specific.annual_loss_ratio, common.annual_loss_ratio) as annual_loss_ratio,
+               coalesce(specific.annual_loss_ratio_reduce,
+                        common.annual_loss_ratio_reduce)                      as annual_loss_ratio_reduce,
+               coalesce(specific.monthly_loss_ratio_reduce,
+                        common.monthly_loss_ratio_reduce)                     as monthly_loss_ratio_reduce,
+               coalesce(specific.annual_loss_leak_ratio,
+                        common.annual_loss_leak_ratio)                        as annual_loss_leak_ratio,
+               coalesce(specific.annual_loss_leak_ratio_reduce,
+                        common.annual_loss_leak_ratio_reduce)                 as annual_loss_leak_ratio_reduce,
+               coalesce(specific.monthly_loss_leak_ratio_reduce,
+                        common.monthly_loss_leak_ratio_reduce)                as monthly_loss_leak_ratio_reduce,
+               coalesce(specific.param1, common.param1)                       as param1,
+               coalesce(specific.param2, common.param2)                       as param2,
+               coalesce(specific.created_time, common.created_time)           as created_time,
+               coalesce(specific.updated_time, common.updated_time)           as updated_time
+        from (select * from k1_pgn_dma_analy_setting_loss_target where zone_id = 'common' and setting_type = 0) common
+                 left join (select *
+                            from v_k1_pgn_dma_analy_setting_loss_target
+                            where zone_id = #{zoneId,jdbcType=VARCHAR}
+                              and target_year = #{targetYear,jdbcType=SMALLINT}) specific
+                           on common.target_year = specific.target_year
+        where common.target_year = #{targetYear,jdbcType=SMALLINT}
+    </select>
+    <select id="findOneByZoneIdAndSettingTypeAndTargetYear"
+            resultType="com.shkpr.service.alambizplugin.dto.DmaAnalySettingLossTarget">
+        select zone_id,
+               setting_type,
+               target_year,
+               annual_nrw_ratio,
+               annual_nrw_ratio_reduce,
+               monthly_nrw_ratio_reduce,
+               annual_loss_ratio,
+               annual_loss_ratio_reduce,
+               monthly_loss_ratio_reduce,
+               annual_loss_leak_ratio,
+               annual_loss_leak_ratio_reduce,
+               monthly_loss_leak_ratio_reduce,
+               param1,
+               param2,
+               created_time,
+               updated_time
+        from k1_pgn_dma_analy_setting_loss_target
+        where zone_id = #{zoneId,jdbcType=VARCHAR}
+          and setting_type = #{settingType,jdbcType=SMALLINT}
+          and target_year = #{targetYear,jdbcType=SMALLINT}
+    </select>
+    <select id="countDefaultByZoneIdAndSettingTypeAndTargetYear" resultType="java.lang.Long">
+        select count(*)
+        from (select * from k1_pgn_dma_analy_setting_loss_target where zone_id = 'common' and setting_type = 0) common
+        left join (select * from v_k1_pgn_dma_analy_setting_loss_target
+        <where>
+            zone_id = #{zoneId,jdbcType=VARCHAR}
+            <if test="targetYear != null">and target_year =#{targetYear,jdbcType=SMALLINT}</if>
+        </where>
+        ) specific on common.target_year = specific.target_year
+        <where>
+            <if test="targetYear != null">common.target_year =#{targetYear,jdbcType=SMALLINT}</if>
+        </where>
+    </select>
+    <select id="countByZoneIdAndSettingTypeAndTargetYear" resultType="java.lang.Long">
+        select count(*)
+        from k1_pgn_dma_analy_setting_loss_target
+        <where>
+            zone_id = #{zoneId,jdbcType=VARCHAR}
+            and setting_type = #{settingType,jdbcType=SMALLINT}
+            <if test="targetYear != null">and target_year = #{targetYear,jdbcType=SMALLINT}</if>
+        </where>
+    </select>
+    <delete id="deleteByZoneIdAndSettingTypeAndTargetYear">
+        delete
+        from k1_pgn_dma_analy_setting_loss_target
+        where zone_id != 'common'
+          and setting_type != 0
+          and zone_id = #{zoneId,jdbcType=VARCHAR}
+          and setting_type = #{settingType,jdbcType=SMALLINT}
+          and target_year = #{targetYear,jdbcType=SMALLINT}
+    </delete>
+</mapper>

+ 140 - 0
src/main/resources/mapper/DmaAnalySettingMapper.xml

@@ -0,0 +1,140 @@
+<?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.DmaAnalySettingMapper">
+    <resultMap id="BaseResultMap" type="com.shkpr.service.alambizplugin.dto.DmaAnalySetting">
+        <id column="zone_id" jdbcType="VARCHAR" property="zoneId"/>
+        <id column="setting_type" jdbcType="SMALLINT" property="settingType"/>
+        <result column="kind" jdbcType="VARCHAR" property="kind"/>
+        <result column="key" jdbcType="VARCHAR" property="key"/>
+        <result column="value" jdbcType="VARCHAR" property="value"
+                typeHandler="com.shkpr.service.alambizplugin.dbdao.pgtype.JsonTypeHandlerPg"/>
+        <result column="enabled" jdbcType="BOOLEAN" property="enabled"/>
+    </resultMap>
+    <resultMap id="DefaultResultMap" type="com.shkpr.service.alambizplugin.dto.DmaAnalySettingDefault">
+        <id column="zone_id" jdbcType="VARCHAR" property="zoneId"/>
+        <id column="setting_type" jdbcType="SMALLINT" property="settingType"/>
+        <result column="kind" jdbcType="VARCHAR" property="kind"/>
+        <result column="settings" jdbcType="VARCHAR" property="settings"
+                typeHandler="com.shkpr.service.alambizplugin.dbdao.pgtype.JsonTypeHandlerPg"/>
+    </resultMap>
+    <insert id="upsert">
+        <trim prefix="insert into k1_pgn_dma_analy_setting (" suffix=")" suffixOverrides=",">
+            zone_id,
+            setting_type,
+            kind,
+            key,
+            value,
+            <if test="enabled != null">enabled,</if>
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            #{zoneId,jdbcType=VARCHAR},
+            #{settingType,jdbcType=SMALLINT},
+            #{kind,jdbcType=VARCHAR},
+            #{key,jdbcType=VARCHAR},
+            #{value,jdbcType=VARCHAR,typeHandler=com.shkpr.service.alambizplugin.dbdao.pgtype.JsonTypeHandlerPg},
+            <if test="enabled != null">#{enabled,jdbcType=BOOLEAN},</if>
+        </trim>
+        on conflict (zone_id, setting_type, kind, key) do update set
+        <trim suffixOverrides=",">
+            value = excluded.value,
+            <if test="enabled != null">enabled = excluded.enabled,</if>
+        </trim>
+    </insert>
+    <select id="findAllDefaultByZoneIdAndSettingTypeAndKind" resultMap="DefaultResultMap">
+        select coalesce(specific.zone_id, common.zone_id) as zone_id,
+        coalesce(specific.setting_type, common.setting_type) as setting_type,
+        coalesce(specific.kind, common.kind) as kind,
+        coalesce(specific.settings, common.settings) as settings
+        from (select zone_id, setting_type, kind, settings
+        from v_k1_pgn_dma_analy_setting where zone_id = 'common' and setting_type = 0) common
+        left join (select zone_id, setting_type, kind, settings
+        from v_k1_pgn_dma_analy_setting
+        <where>
+            zone_id = #{zoneId,jdbcType=VARCHAR}
+            <if test="kind != null">and kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+        ) specific on common.kind = specific.kind
+        <where>
+            <if test="kind != null">common.kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+        limit #{pageable.pageSize} offset #{pageable.offset}
+    </select>
+    <select id="findAllByZoneIdAndSettingTypeAndKind" resultMap="BaseResultMap">
+        select
+        coalesce(specific.zone_id, common.zone_id) as zone_id,
+        coalesce(specific.setting_type, common.setting_type) as setting_type,
+        coalesce(specific.kind, common.kind) as kind,
+        coalesce(specific.key, common.key) as key,
+        coalesce(specific.value, common.value) as value,
+        coalesce(specific.enabled, common.enabled) as enabled
+        from (select id, zone_id, setting_type, key, kind, value, enabled
+        from k1_pgn_dma_analy_setting where zone_id = 'common' and setting_type = 0) common
+        left join (select id, zone_id, setting_type, key, kind, value, enabled
+        from k1_pgn_dma_analy_setting
+        <where>
+            zone_id = 'common_test'
+            <if test="kind != null">and kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+        ) specific on common.kind = specific.kind and common.key = specific.key
+        <where>
+            <if test="kind != null">common.kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+        limit #{pageable.pageSize} offset #{pageable.offset}
+    </select>
+    <select id="findOneDefaultByZoneIdAndSettingTypeAndKind" resultMap="DefaultResultMap">
+        select coalesce(specific.zone_id, common.zone_id)           as zone_id,
+               coalesce(specific.setting_type, common.setting_type) as setting_type,
+               coalesce(specific.kind, common.kind)                 as kind,
+               coalesce(specific.settings, common.settings)         as settings
+        from (select zone_id, setting_type, kind, settings
+              from v_k1_pgn_dma_analy_setting
+              where zone_id = 'common'
+                and setting_type = 0) common
+                 left join (select zone_id, setting_type, kind, settings
+                            from v_k1_pgn_dma_analy_setting
+                            where zone_id = #{zoneId,jdbcType=VARCHAR}
+                              and kind = #{kind,jdbcType=VARCHAR}) specific on common.kind = specific.kind
+        where common.kind = #{kind,jdbcType=VARCHAR}
+    </select>
+    <select id="countDefaultByZoneIdAndSettingTypeAndKind" resultType="java.lang.Long">
+        select count(*)
+        from (select zone_id, setting_type, kind, settings
+        from v_k1_pgn_dma_analy_setting where zone_id = 'common' and setting_type = 0) common
+        left join (select zone_id, setting_type, kind, settings
+        from v_k1_pgn_dma_analy_setting
+        <where>
+            zone_id = #{zoneId,jdbcType=VARCHAR}
+            <if test="kind != null">and kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+        ) specific on common.kind = specific.kind
+        <where>
+            <if test="kind != null">common.kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+    </select>
+    <select id="countByZoneIdAndSettingTypeAndKind" resultType="java.lang.Long">
+        select count(*)
+        from (select id, zone_id, setting_type, key, kind, value, enabled
+        from k1_pgn_dma_analy_setting where zone_id = 'common' and setting_type = 0) common
+        left join (select id, zone_id, setting_type, key, kind, value, enabled
+        from k1_pgn_dma_analy_setting
+        <where>
+            zone_id = 'common_test'
+            <if test="kind != null">and kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+        ) specific on common.kind = specific.kind and common.key = specific.key
+        <where>
+            <if test="kind != null">common.kind =#{kind,jdbcType=VARCHAR}</if>
+        </where>
+    </select>
+    <delete id="deleteByZoneIdAndSettingTypeAndKey">
+        delete
+        from k1_pgn_dma_analy_setting
+        where zone_id = #{zoneId,jdbcType=VARCHAR}
+        and setting_type = #{settingType,jdbcType=SMALLINT}
+        and kind = #{kind,jdbcType=VARCHAR}
+        and key in
+        <foreach collection="keys" open="(" close=")" separator="," item="key">
+            #{key,jdbcType=VARCHAR}
+        </foreach>
+    </delete>
+</mapper>