Kaynağa Gözat

增加江津版本兼容

欧阳劲驰 1 ay önce
ebeveyn
işleme
e39f548e99

+ 2 - 0
sql.properties

@@ -8,6 +8,8 @@ spring.datasource.data.driver-class-name=org.postgis.DriverWrapper
 spring.datasource.oracle.jdbc-url=jdbc:oracle:thin:@10.127.16.117:1521/ORCLPDB1
 spring.datasource.oracle.username=v_cqzls
 spring.datasource.oracle.password=CQzls#2025
+#spring.datasource.oracle.username=v_jiangjin
+#spring.datasource.oracle.password=JiangJin@1127
 spring.datasource.oracle.driver-class-name=oracle.jdbc.driver.OracleDriver
 
 #pgsql ˮ��Ԥ�����ݿ�Դ

+ 16 - 5
src/main/java/com/shkpr/service/aimodelpower/bizmgr/WaterVolumeBizMgr.java

@@ -1,5 +1,6 @@
 package com.shkpr.service.aimodelpower.bizmgr;
 
+import com.shkpr.service.aimodelpower.commproperties.CollectProperties;
 import com.shkpr.service.aimodelpower.components.WaterVolumeCollector;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.annotation.Scheduled;
@@ -19,10 +20,15 @@ public class WaterVolumeBizMgr {
     final
     ThreadPoolTaskExecutor taskScheduler;
     final
+    CollectProperties collectProperties;
+    final
     WaterVolumeCollector waterVolumeCollector;
 
-    public WaterVolumeBizMgr(@Qualifier("taskExecutor") ThreadPoolTaskExecutor taskScheduler, WaterVolumeCollector waterVolumeCollector) {
+    public WaterVolumeBizMgr(@Qualifier("taskExecutor") ThreadPoolTaskExecutor taskScheduler
+            , CollectProperties collectProperties
+            , WaterVolumeCollector waterVolumeCollector) {
         this.taskScheduler = taskScheduler;
+        this.collectProperties = collectProperties;
         this.waterVolumeCollector = waterVolumeCollector;
     }
 
@@ -32,10 +38,13 @@ public class WaterVolumeBizMgr {
     @PostConstruct
     public void init() {
         //采集4天数据
-        taskScheduler.execute(() -> waterVolumeCollector.collectBusinessMinuteData(4 * 24));
+        if (collectProperties.getBusinessCollected()) {
+            taskScheduler.execute(() -> waterVolumeCollector.collectBusinessMinuteData(4 * 24));
+            taskScheduler.execute(() -> waterVolumeCollector.collectBusinessHourData(4 * 24));
+        }
         taskScheduler.execute(() -> waterVolumeCollector.collectDifferenceMinuteData(4 * 24));
-        taskScheduler.execute(() -> waterVolumeCollector.collectBusinessHourData(4 * 24));
         taskScheduler.execute(() -> waterVolumeCollector.collectDifferenceHourData(4 * 24));
+        taskScheduler.execute(() -> waterVolumeCollector.collectRawData(4 * 24));
     }
 
     /**
@@ -44,7 +53,8 @@ public class WaterVolumeBizMgr {
     @Scheduled(cron = "0 */10 * * * *")
     public void minuteTask() {
         //采集营业所1小时的分钟数据
-        taskScheduler.execute(() -> waterVolumeCollector.collectBusinessMinuteData(1));
+        if (collectProperties.getBusinessCollected())
+            taskScheduler.execute(() -> waterVolumeCollector.collectBusinessMinuteData(1));
         //采集1小时的分钟数据
         taskScheduler.execute(() -> waterVolumeCollector.collectDifferenceMinuteData(1));
     }
@@ -55,7 +65,8 @@ public class WaterVolumeBizMgr {
     @Scheduled(cron = "0 5 * * * *")
     public void hourTask() {
         //采集营业所2小时的小时数据
-        taskScheduler.execute(() -> waterVolumeCollector.collectBusinessHourData(2));
+        if (collectProperties.getBusinessCollected())
+            taskScheduler.execute(() -> waterVolumeCollector.collectBusinessHourData(2));
         //采集2小时的小时数据
         taskScheduler.execute(() -> waterVolumeCollector.collectDifferenceHourData(2));
     }

+ 25 - 1
src/main/java/com/shkpr/service/aimodelpower/commproperties/CollectProperties.java

@@ -23,6 +23,19 @@ import java.util.stream.Collectors;
 @ToString
 public class CollectProperties {
     /**
+     * 视图名称
+     * <p>
+     * <li> 该视图用于采集历史数据</li>
+     * <li> 命名格式为[模式名].[视图名],例如:cqda.v_shizilaishui_history2</li>
+     * </p>
+     * <p>
+     * <b>关于$符号拼接的特别说明:</b>
+     * <li> 在MyBatis XML中使用时,需要通过${viewName}方式引用</li>
+     * <li> ${}是直接字符串替换,有SQL注入风险</li>
+     * </p>
+     */
+    private String viewName;
+    /**
      * 最大水量
      */
     private Double maxWater = 20000d;
@@ -31,6 +44,10 @@ public class CollectProperties {
      */
     private Double minWater = -20000d;
     /**
+     * 营业所采集
+     */
+    private Boolean businessCollected = false;
+    /**
      * 关闭标签
      */
     private List<String> closeTags;
@@ -48,7 +65,14 @@ public class CollectProperties {
     private List<CollectTagAttr> supplyOutTags;
 
     public Map<String, List<String>> getSupplySelfTagsMap() {
-        return supplySelfTags.stream().collect(Collectors.toMap(CollectProperties.CollectTagAttr::getName, CollectProperties.CollectTagAttr::getValues));
+        return supplySelfTags.stream()
+                .peek(it -> it.setValues(
+                        it.getValues().stream()
+                                //过滤关闭的标签
+                                .filter(it1 -> !closeTags.contains(it1))
+                                .collect(Collectors.toList())
+                ))
+                .collect(Collectors.toMap(CollectProperties.CollectTagAttr::getName, CollectProperties.CollectTagAttr::getValues));
     }
 
     public Map<String, List<String>> getSupplyInTagsMap() {

+ 23 - 18
src/main/java/com/shkpr/service/aimodelpower/components/WaterPumpCollector.java

@@ -4,16 +4,15 @@ import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.aimodelpower.constants.LogFlagBusiType;
 import com.shkpr.service.aimodelpower.constants.WaterPumpStandard;
-import com.shkpr.service.aimodelpower.dbdao.services.intef.ShizilaishuiHistoryService;
+import com.shkpr.service.aimodelpower.dbdao.services.intef.CollectHistoryService;
 import com.shkpr.service.aimodelpower.dbdao.services.intef.WaterPumpCollectionConfigService;
 import com.shkpr.service.aimodelpower.dbdao.services.intef.WaterPumpCollectionRecordService;
-import com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory;
+import com.shkpr.service.aimodelpower.dto.CollectHistory;
 import com.shkpr.service.aimodelpower.dto.WaterPumpCollectionConfig;
 import com.shkpr.service.aimodelpower.dto.WaterPumpCollectionRecord;
 import com.shkpr.service.aimodelpower.dto.WaterPumpEnergyConfig;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Qualifier;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Component;
@@ -50,16 +49,22 @@ public class WaterPumpCollector {
      */
     private final static String HOUR_ALIGN_UNIT = "hh";
 
-    @Autowired
-    @Qualifier("taskExecutor")
+    final
     ThreadPoolTaskExecutor taskScheduler;
-    @Autowired
+    final
     WaterPumpCollectionConfigService waterPumpCollectionConfigService;
-    @Autowired
-    ShizilaishuiHistoryService shizilaishuiHistoryService;
-    @Autowired
+    final
+    CollectHistoryService collectHistoryService;
+    final
     WaterPumpCollectionRecordService waterPumpCollectionRecordService;
 
+    public WaterPumpCollector(@Qualifier("taskExecutor") ThreadPoolTaskExecutor taskScheduler, WaterPumpCollectionConfigService waterPumpCollectionConfigService, CollectHistoryService collectHistoryService, WaterPumpCollectionRecordService waterPumpCollectionRecordService) {
+        this.taskScheduler = taskScheduler;
+        this.waterPumpCollectionConfigService = waterPumpCollectionConfigService;
+        this.collectHistoryService = collectHistoryService;
+        this.waterPumpCollectionRecordService = waterPumpCollectionRecordService;
+    }
+
     /**
      * 采集数据
      *
@@ -88,7 +93,7 @@ public class WaterPumpCollector {
                 List<String> tags = new ArrayList<>(tagMap.keySet());
 
                 //查询总数,排除总数小于等于0的数据
-                Long count = shizilaishuiHistoryService.findCount(startTime, endTime, tags);
+                Long count = collectHistoryService.findCount(startTime, endTime, tags);
                 if (CollectionUtils.isEmpty(tags) || count <= 0) return;
 
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -96,31 +101,31 @@ public class WaterPumpCollector {
                 long begin = System.currentTimeMillis();
 
                 //读取数据
-                List<ShizilaishuiHistory> shizilaishuiHistories = shizilaishuiHistoryService.findAlign(startTime, endTime
+                List<CollectHistory> collectHistories = collectHistoryService.findAlign(startTime, endTime
                         , 1, HOUR_UNIT, HOUR_ALIGN_UNIT, tags);
 
                 //遍历原始数据,构建采集数据
-                List<WaterPumpCollectionRecord> dates = shizilaishuiHistories.stream()
+                List<WaterPumpCollectionRecord> dates = collectHistories.stream()
                         //根据时间分组
-                        .collect(Collectors.groupingBy(ShizilaishuiHistory::getTime))
+                        .collect(Collectors.groupingBy(CollectHistory::getTime))
                         .entrySet().stream()
                         .map(it -> {
                             WaterPumpCollectionRecord data = new WaterPumpCollectionRecord();
                             data.setDeviceCode(configEntry.getKey());
                             data.setTime(it.getKey());
                             //遍历同一台设备原始数据
-                            for (ShizilaishuiHistory shizilaishuiHistory : it.getValue()) {
-                                WaterPumpCollectionConfig config = tagMap.get(shizilaishuiHistory.getTagCode());
+                            for (CollectHistory collectHistory : it.getValue()) {
+                                WaterPumpCollectionConfig config = tagMap.get(collectHistory.getTagCode());
                                 //根据标准模式设置对应字段
                                 if (config != null) switch (config.getStandardCode()) {
                                     case WaterPumpStandard.ACTIVE_ENERGY:
-                                        data.setActiveEnergy(shizilaishuiHistory.getVal());
+                                        data.setActiveEnergy(collectHistory.getVal());
                                         break;
                                     case WaterPumpStandard.STARTUP_STATE:
-                                        data.setStartupState(shizilaishuiHistory.getVal() != null ? shizilaishuiHistory.getVal().shortValue() : null);
+                                        data.setStartupState(collectHistory.getVal() != null ? collectHistory.getVal().shortValue() : null);
                                         break;
                                     case WaterPumpStandard.PHASE_A_CURRENT:
-                                        data.setStartupState((short) (shizilaishuiHistory.getVal() == null || shizilaishuiHistory.getVal() == 0 ? 0 : 1));
+                                        data.setStartupState((short) (collectHistory.getVal() == null || collectHistory.getVal() == 0 ? 0 : 1));
                                         break;
                                 }
                             }

+ 37 - 37
src/main/java/com/shkpr/service/aimodelpower/components/WaterVolumeCollector.java

@@ -6,10 +6,10 @@ import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
 import com.shkpr.service.aimodelpower.commproperties.CollectProperties;
 import com.shkpr.service.aimodelpower.constants.LogFlagBusiType;
-import com.shkpr.service.aimodelpower.dbdao.services.intef.ShizilaishuiHistoryService;
+import com.shkpr.service.aimodelpower.dbdao.services.intef.CollectHistoryService;
 import com.shkpr.service.aimodelpower.dbdao.services.intef.WaterVolumeCollectionConfigService;
 import com.shkpr.service.aimodelpower.dbdao.services.intef.WaterVolumeCollectionRecordService;
-import com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory;
+import com.shkpr.service.aimodelpower.dto.CollectHistory;
 import com.shkpr.service.aimodelpower.dto.WaterVolumeCollectionConfig;
 import com.shkpr.service.aimodelpower.dto.WaterVolumeCollectionRecord;
 import org.apache.commons.collections4.CollectionUtils;
@@ -66,19 +66,19 @@ public class WaterVolumeCollector {
     final
     WaterVolumeCollectionConfigService waterVolumeCollectionConfigService;
     final
-    ShizilaishuiHistoryService shizilaishuiHistoryService;
+    CollectHistoryService collectHistoryService;
     final
     WaterVolumeCollectionRecordService waterVolumeCollectionRecordService;
 
 
     public WaterVolumeCollector(CollectProperties collectProperties, @Qualifier("taskExecutor") ThreadPoolTaskExecutor taskScheduler
             , ObjectMapper objectMapper, WaterVolumeCollectionConfigService waterVolumeCollectionConfigService
-            , ShizilaishuiHistoryService shizilaishuiHistoryService, WaterVolumeCollectionRecordService waterVolumeCollectionRecordService) {
+            , CollectHistoryService collectHistoryService, WaterVolumeCollectionRecordService waterVolumeCollectionRecordService) {
         this.collectProperties = collectProperties;
         this.taskScheduler = taskScheduler;
         this.objectMapper = objectMapper;
         this.waterVolumeCollectionConfigService = waterVolumeCollectionConfigService;
-        this.shizilaishuiHistoryService = shizilaishuiHistoryService;
+        this.collectHistoryService = collectHistoryService;
         this.waterVolumeCollectionRecordService = waterVolumeCollectionRecordService;
     }
 
@@ -108,7 +108,7 @@ public class WaterVolumeCollector {
                 List<String> outTags = outTagsMap.get(collectTag.getName());
 
                 //查询总数,排除总数小于2的数据
-                Long count = shizilaishuiHistoryService.findCount(startTime, endTime, selfTags);
+                Long count = collectHistoryService.findCount(startTime, endTime, selfTags);
                 if (CollectionUtils.isEmpty(selfTags) || count < 2) return;
 
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -116,22 +116,22 @@ public class WaterVolumeCollector {
                 long begin = System.currentTimeMillis();
 
                 //读取数据
-                List<ShizilaishuiHistory> shizilaishuiHistories = shizilaishuiHistoryService.findDifference(
+                List<CollectHistory> collectHistories = collectHistoryService.findDifference(
                         startTime, endTime, 1, HOUR_UNIT, selfTags, inTags, outTags);
 
                 //最新值
                 Double last = null;
                 //遍历原始数据,构建采集数据
                 List<WaterVolumeCollectionRecord> dates = new ArrayList<>();
-                for (ShizilaishuiHistory shizilaishuiHistory : shizilaishuiHistories) {
+                for (CollectHistory collectHistory : collectHistories) {
                     //构建数据,时间步长到下一个整点
                     WaterVolumeCollectionRecord data = new WaterVolumeCollectionRecord(
-                            collectTag.getName(), LocalDateTime.parse(shizilaishuiHistory.getTime(), dateTimeFormatter)
+                            collectTag.getName(), LocalDateTime.parse(collectHistory.getTime(), dateTimeFormatter)
                             .truncatedTo(ChronoUnit.HOURS).plusHours(1)
                             .format(dateTimeFormatter), VALUE_TAG, "");
 
                     //取值
-                    Double value = shizilaishuiHistory.getVal();
+                    Double value = collectHistory.getVal();
                     //数据异常值判断,使用上一条数据
                     if (value == null || (value > collectProperties.getMaxWater() || value < collectProperties.getMinWater())) {
                         //上一次空值处理
@@ -142,7 +142,7 @@ public class WaterVolumeCollector {
                         value = last;
                     }
                     //正常数据缓存上一条
-                    else last = shizilaishuiHistory.getVal();
+                    else last = collectHistory.getVal();
 
                     //设置数据值
                     data.setValue(BigDecimal.valueOf(value).toPlainString());
@@ -195,7 +195,7 @@ public class WaterVolumeCollector {
                 List<String> outTags = outTagsMap.get(collectTag.getName());
 
                 //查询总数,排除总数小于2的数据
-                Long count = shizilaishuiHistoryService.findCount(startTime, endTime, selfTags);
+                Long count = collectHistoryService.findCount(startTime, endTime, selfTags);
                 if (CollectionUtils.isEmpty(selfTags) || count < 2) return;
 
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -203,16 +203,16 @@ public class WaterVolumeCollector {
                 long begin = System.currentTimeMillis();
 
                 //读取数据
-                List<ShizilaishuiHistory> shizilaishuiHistories = shizilaishuiHistoryService.findDifference(
+                List<CollectHistory> collectHistories = collectHistoryService.findDifference(
                         startTime, endTime, 15, MINUTE_UNIT, selfTags, inTags, outTags);
 
                 //最新值
                 Double last = null;
                 //遍历原始数据,构建采集数据
                 List<WaterVolumeCollectionRecord> dates = new ArrayList<>();
-                for (ShizilaishuiHistory shizilaishuiHistory : shizilaishuiHistories) {
+                for (CollectHistory collectHistory : collectHistories) {
                     //解析时间
-                    LocalDateTime time = LocalDateTime.parse(shizilaishuiHistory.getTime(), dateTimeFormatter);
+                    LocalDateTime time = LocalDateTime.parse(collectHistory.getTime(), dateTimeFormatter);
                     //分钟
                     final int minute = time.getMinute();
                     //构建数据,时间步长到下一个15分钟
@@ -222,7 +222,7 @@ public class WaterVolumeCollector {
                             VALUE_TAG, "");
 
                     //取值
-                    Double value = shizilaishuiHistory.getVal();
+                    Double value = collectHistory.getVal();
                     //数据异常值判断,使用上一条数据
                     if (value == null || (value > collectProperties.getMaxWater() || value < collectProperties.getMinWater())) {
                         //上一次空值处理
@@ -233,7 +233,7 @@ public class WaterVolumeCollector {
                         value = last;
                     }
                     //正常数据缓存上一条
-                    else last = shizilaishuiHistory.getVal();
+                    else last = collectHistory.getVal();
 
                     //设置数据和值
                     data.setValue(BigDecimal.valueOf(value).toPlainString());
@@ -290,7 +290,7 @@ public class WaterVolumeCollector {
                 }
 
                 //查询总数,排除总数小于2的数据
-                Long count = shizilaishuiHistoryService.findCount(startTime, endTime, tags);
+                Long count = collectHistoryService.findCount(startTime, endTime, tags);
                 if (CollectionUtils.isEmpty(tags) || count < 2) return;
 
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -298,21 +298,21 @@ public class WaterVolumeCollector {
                 long begin = System.currentTimeMillis();
 
                 //读取数据
-                List<ShizilaishuiHistory> shizilaishuiHistories = shizilaishuiHistoryService.findDifference(
+                List<CollectHistory> collectHistories = collectHistoryService.findDifference(
                         startTime, endTime, 1, HOUR_UNIT, tags, null, null);
 
                 //最新值
                 Double last = null;
                 //遍历原始数据,构建采集数据
                 List<WaterVolumeCollectionRecord> dates = new ArrayList<>();
-                for (ShizilaishuiHistory shizilaishuiHistory : shizilaishuiHistories) {
+                for (CollectHistory collectHistory : collectHistories) {
                     //构建数据,时间取截止时间
                     WaterVolumeCollectionRecord data = new WaterVolumeCollectionRecord(
-                            config.getKey(), LocalDateTime.parse(shizilaishuiHistory.getTime(), dateTimeFormatter)
+                            config.getKey(), LocalDateTime.parse(collectHistory.getTime(), dateTimeFormatter)
                             .plusHours(1).format(dateTimeFormatter), VALUE_TAG, configStr);
 
                     //取值
-                    Double value = shizilaishuiHistory.getVal();
+                    Double value = collectHistory.getVal();
                     //数据异常值判断,使用上一条数据
                     if (value == null || (value > collectProperties.getMaxWater() || value < collectProperties.getMinWater())) {
                         //上一次空值处理
@@ -323,7 +323,7 @@ public class WaterVolumeCollector {
                         value = last;
                     }
                     //正常数据缓存上一条
-                    else last = shizilaishuiHistory.getVal();
+                    else last = collectHistory.getVal();
 
                     //设置数据值
                     data.setValue(BigDecimal.valueOf(value).toPlainString());
@@ -384,7 +384,7 @@ public class WaterVolumeCollector {
                 }
 
                 //查询总数,排除总数小于2的数据
-                Long count = shizilaishuiHistoryService.findCount(startTime, endTime, tags);
+                Long count = collectHistoryService.findCount(startTime, endTime, tags);
                 if (CollectionUtils.isEmpty(tags) || count < 2) return;
 
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -392,16 +392,16 @@ public class WaterVolumeCollector {
                 long begin = System.currentTimeMillis();
 
                 //读取数据
-                List<ShizilaishuiHistory> shizilaishuiHistories = shizilaishuiHistoryService.findDifference(
+                List<CollectHistory> collectHistories = collectHistoryService.findDifference(
                         startTime, endTime, 15, MINUTE_UNIT, tags, null, null);
 
                 //最新值
                 Double last = null;
                 //遍历原始数据,构建采集数据
                 List<WaterVolumeCollectionRecord> dates = new ArrayList<>();
-                for (ShizilaishuiHistory shizilaishuiHistory : shizilaishuiHistories) {
+                for (CollectHistory collectHistory : collectHistories) {
                     //解析时间
-                    LocalDateTime time = LocalDateTime.parse(shizilaishuiHistory.getTime(), dateTimeFormatter);
+                    LocalDateTime time = LocalDateTime.parse(collectHistory.getTime(), dateTimeFormatter);
                     //分钟
                     final int minute = time.getMinute();
                     //构建数据,时间步长到下一个15分钟
@@ -411,7 +411,7 @@ public class WaterVolumeCollector {
                             VALUE_TAG, configStr);
 
                     //取值
-                    Double value = shizilaishuiHistory.getVal();
+                    Double value = collectHistory.getVal();
                     //数据异常值判断,使用上一条数据
                     if (value == null || (value > collectProperties.getMaxWater() || value < collectProperties.getMinWater())) {
                         //上一次空值处理
@@ -422,7 +422,7 @@ public class WaterVolumeCollector {
                         value = last;
                     }
                     //正常数据缓存上一条
-                    else last = shizilaishuiHistory.getVal();
+                    else last = collectHistory.getVal();
 
                     //设置数据值
                     data.setValue(BigDecimal.valueOf(value).toPlainString());
@@ -473,7 +473,7 @@ public class WaterVolumeCollector {
                         .map(WaterVolumeCollectionConfig::getCollcationTag).collect(Collectors.toList());
 
                 //查询总数,排除总数小于等于0的数据
-                Long count = shizilaishuiHistoryService.findCount(startTime, endTime, tags);
+                Long count = collectHistoryService.findCount(startTime, endTime, tags);
                 if (CollectionUtils.isEmpty(tags) || count <= 0) return;
 
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName
@@ -481,20 +481,20 @@ public class WaterVolumeCollector {
                 long begin = System.currentTimeMillis();
 
                 //读取数据
-                List<ShizilaishuiHistory> shizilaishuiHistories = shizilaishuiHistoryService.findAl(startTime, endTime, tags);
+                List<CollectHistory> collectHistories = collectHistoryService.findAl(startTime, endTime, tags);
 
                 //遍历原始数据,构建采集数据
-                List<WaterVolumeCollectionRecord> dates = shizilaishuiHistories.stream().map(shizilaishuiHistory -> {
+                List<WaterVolumeCollectionRecord> dates = collectHistories.stream().map(collectHistory -> {
                     WaterVolumeCollectionRecord data = new WaterVolumeCollectionRecord();
-                    data.setTime(String.valueOf(LocalDateTime.parse(shizilaishuiHistory.getTime(), dateTimeFormatter)
+                    data.setTime(String.valueOf(LocalDateTime.parse(collectHistory.getTime(), dateTimeFormatter)
                             .atZone(ZoneId.systemDefault())
                             .toInstant().toEpochMilli()));
-                    data.setUpdateTime(String.valueOf(LocalDateTime.parse(shizilaishuiHistory.getUpdateTime(), dateTimeFormatter)
+                    data.setUpdateTime(String.valueOf(LocalDateTime.parse(collectHistory.getUpdateTime(), dateTimeFormatter)
                             .atZone(ZoneId.systemDefault())
                             .toInstant().toEpochMilli()));
-                    data.setOrgName(shizilaishuiHistory.getName());
-                    data.setCollectionTag(shizilaishuiHistory.getTagCode());
-                    data.setValue(BigDecimal.valueOf(shizilaishuiHistory.getVal()).toPlainString());
+                    data.setOrgName(collectHistory.getName());
+                    data.setCollectionTag(collectHistory.getTagCode());
+                    data.setValue(BigDecimal.valueOf(collectHistory.getVal()).toPlainString());
                     return data;
                 }).collect(Collectors.toList());
 

+ 18 - 9
src/main/java/com/shkpr/service/aimodelpower/dbdao/mapperoracle/ShizilaishuiHistoryMapper.java

@@ -1,6 +1,6 @@
 package com.shkpr.service.aimodelpower.dbdao.mapperoracle;
 
-import com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory;
+import com.shkpr.service.aimodelpower.dto.CollectHistory;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.cursor.Cursor;
@@ -8,16 +8,17 @@ import org.apache.ibatis.cursor.Cursor;
 import java.util.List;
 
 /**
- * 市自来水历史mapper
+ * 采集历史mapper
  *
  * @author 欧阳劲驰
  * @serial 1.0.4
  */
 @Mapper
-public interface ShizilaishuiHistoryMapper {
+public interface CollectHistoryMapper {
     /**
      * 根据采集标签查询差值
      *
+     * @param viewName     视图名称
      * @param beginTime    开始时间
      * @param endTime      结束时间
      * @param interval     采集间隔
@@ -27,7 +28,8 @@ public interface ShizilaishuiHistoryMapper {
      * @param outTags      供出标签
      * @return 历史数据
      */
-    Cursor<ShizilaishuiHistory> findDifferenceByTimeAndTags(
+    Cursor<CollectHistory> findDifferenceByTimeAndTags(
+            @Param("viewName") String viewName,
             @Param("beginTime") String beginTime,
             @Param("endTime") String endTime,
             @Param("interval") String interval,
@@ -39,6 +41,7 @@ public interface ShizilaishuiHistoryMapper {
     /**
      * 根据采集标签查询对齐值
      *
+     * @param viewName     视图名称
      * @param beginTime    开始时间
      * @param endTime      结束时间
      * @param interval     采集间隔
@@ -47,7 +50,8 @@ public interface ShizilaishuiHistoryMapper {
      * @param selfTags     自供标签
      * @return 历史数据
      */
-    Cursor<ShizilaishuiHistory> findAlignByTimeAndTags(
+    Cursor<CollectHistory> findAlignByTimeAndTags(
+            @Param("viewName") String viewName,
             @Param("beginTime") String beginTime,
             @Param("endTime") String endTime,
             @Param("interval") String interval,
@@ -59,12 +63,14 @@ public interface ShizilaishuiHistoryMapper {
     /**
      * 根据采集标签查询
      *
+     * @param viewName  视图名称
      * @param beginTime 开始时间
      * @param endTime   结束时间
      * @param selfTags  自供标签
      * @return 历史数据
      */
-    Cursor<ShizilaishuiHistory> findAllByTimeAndTags(
+    Cursor<CollectHistory> findAllByTimeAndTags(
+            @Param("viewName") String viewName,
             @Param("beginTime") String beginTime,
             @Param("endTime") String endTime,
             @Param("selfTags") List<String> selfTags);
@@ -73,13 +79,16 @@ public interface ShizilaishuiHistoryMapper {
     /**
      * 根据采集标签查询条数
      *
+     * @param viewName  视图名称
      * @param beginTime 开始时间
      * @param endTime   结束时间
      * @param selfTags  自供标签
      * @return 条数
      */
-    Long findCountByTimeAndTags(@Param("beginTime") String beginTime,
-                                @Param("endTime") String endTime,
-                                @Param("selfTags") List<String> selfTags);
+    Long findCountByTimeAndTags(
+            @Param("viewName") String viewName,
+            @Param("beginTime") String beginTime,
+            @Param("endTime") String endTime,
+            @Param("selfTags") List<String> selfTags);
 
 }

+ 43 - 35
src/main/java/com/shkpr/service/aimodelpower/dbdao/services/ShizilaishuiHistoryServiceImpl.java

@@ -2,10 +2,11 @@ package com.shkpr.service.aimodelpower.dbdao.services;
 
 import com.global.base.log.LogLevelFlag;
 import com.global.base.log.LogPrintMgr;
+import com.shkpr.service.aimodelpower.commproperties.CollectProperties;
 import com.shkpr.service.aimodelpower.constants.LogFlagBusiType;
-import com.shkpr.service.aimodelpower.dbdao.mapperoracle.ShizilaishuiHistoryMapper;
-import com.shkpr.service.aimodelpower.dbdao.services.intef.ShizilaishuiHistoryService;
-import com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory;
+import com.shkpr.service.aimodelpower.dbdao.mapperoracle.CollectHistoryMapper;
+import com.shkpr.service.aimodelpower.dbdao.services.intef.CollectHistoryService;
+import com.shkpr.service.aimodelpower.dto.CollectHistory;
 import org.apache.ibatis.cursor.Cursor;
 import org.apache.ibatis.session.SqlSession;
 import org.apache.ibatis.session.SqlSessionFactory;
@@ -20,17 +21,17 @@ import java.util.ArrayList;
 import java.util.List;
 
 /**
- * 市自来水历史service实现
+ * 采集历史service实现
  *
  * @author 欧阳劲驰
  * @serial 1.0.4
  */
 @Service
-public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryService {
+public class CollectHistoryServiceImpl implements CollectHistoryService {
     /**
      * log
      */
-    private final static String mStrClassName = "ShizilaishuiHistoryServiceImpl";
+    private final static String mStrClassName = "CollectHistoryServiceImpl";
     private final static String mBizType = LogFlagBusiType.BUSI_DATA_COLLECT.toStrValue();
 
     /**
@@ -41,11 +42,16 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
     final
     SqlSessionFactory oracleSqlSessionFactory;
     final
-    ShizilaishuiHistoryMapper shizilaishuiHistoryMapper;
+    CollectProperties collectProperties;
+    final
+    CollectHistoryMapper collectHistoryMapper;
 
-    public ShizilaishuiHistoryServiceImpl(@Qualifier("oracleSqlSessionFactory") SqlSessionFactory oracleSqlSessionFactory, ShizilaishuiHistoryMapper shizilaishuiHistoryMapper) {
+    public CollectHistoryServiceImpl(@Qualifier("oracleSqlSessionFactory") SqlSessionFactory oracleSqlSessionFactory,
+                                     CollectProperties collectProperties
+            , CollectHistoryMapper collectHistoryMapper) {
+        this.collectProperties = collectProperties;
         this.oracleSqlSessionFactory = oracleSqlSessionFactory;
-        this.shizilaishuiHistoryMapper = shizilaishuiHistoryMapper;
+        this.collectHistoryMapper = collectHistoryMapper;
     }
 
     /**
@@ -62,29 +68,29 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
      */
     @Override
     @Transactional(transactionManager = "oracleDbTransactionManager")
-    public List<ShizilaishuiHistory> findDifference(LocalDateTime beginTime, LocalDateTime endTime
+    public List<CollectHistory> findDifference(LocalDateTime beginTime, LocalDateTime endTime
             , Integer interval, String intervalUnit, List<String> selfTags, List<String> inTags, List<String> outTags) {
         //获取session和mapper
         try (SqlSession session = oracleSqlSessionFactory.openSession()) {
-            ShizilaishuiHistoryMapper mapper = session.getMapper(ShizilaishuiHistoryMapper.class);
+            CollectHistoryMapper mapper = session.getMapper(CollectHistoryMapper.class);
 
-            //市自来水历史集合
-            List<ShizilaishuiHistory> shizilaishuiHistories = new ArrayList<>();
+            //采集历史集合
+            List<CollectHistory> collectHistories = new ArrayList<>();
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName,
                     String.format("开始根据时间和标签查询自来水差值数据, 开启事务和游标 开始时间:%s, 结束时间:%s, 间隔:%d, 间隔单位:%s, 采集标签:%s",
                             beginTime, endTime, interval, intervalUnit, selfTags));
             long begin = System.currentTimeMillis();
 
             //获取游标
-            try (Cursor<ShizilaishuiHistory> cursor = mapper.findDifferenceByTimeAndTags(
+            try (Cursor<CollectHistory> cursor = mapper.findDifferenceByTimeAndTags(collectProperties.getViewName(),
                     beginTime.format(dateTimeFormatter), endTime.format(dateTimeFormatter),
                     interval.toString(), intervalUnit, selfTags, inTags, outTags)) {
                 //迭代游标
-                for (ShizilaishuiHistory shizilaishuiHistory : cursor) {
+                for (CollectHistory collectHistory : cursor) {
                     //检查游标完成
                     if (cursor.isConsumed()) break;
                     //填入数据
-                    shizilaishuiHistories.add(shizilaishuiHistory);
+                    collectHistories.add(collectHistory);
                 }
             } catch (IOException e) {
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName, String.format("关闭游标失败  error:%s", e));
@@ -95,7 +101,7 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
                     String.format("完成根据时间和标签查询自来水差值数据, 关闭事务和游标 开始时间:%s, 结束时间:%s, 间隔:%d, 间隔单位:%s, 用时(毫秒):%d",
                             beginTime, endTime, interval, intervalUnit, (end - begin)));
 
-            return shizilaishuiHistories;
+            return collectHistories;
         }
     }
 
@@ -112,28 +118,29 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
      */
     @Override
     @Transactional(transactionManager = "oracleDbTransactionManager")
-    public List<ShizilaishuiHistory> findAlign(LocalDateTime beginTime, LocalDateTime endTime
+    public List<CollectHistory> findAlign(LocalDateTime beginTime, LocalDateTime endTime
             , Integer interval, String intervalUnit, String alignUnit, List<String> selfTags) {
         //获取session和mapper
         try (SqlSession session = oracleSqlSessionFactory.openSession()) {
-            ShizilaishuiHistoryMapper mapper = session.getMapper(ShizilaishuiHistoryMapper.class);
+            CollectHistoryMapper mapper = session.getMapper(CollectHistoryMapper.class);
 
-            //市自来水历史集合
-            List<ShizilaishuiHistory> shizilaishuiHistories = new ArrayList<>();
+            //采集历史集合
+            List<CollectHistory> collectHistories = new ArrayList<>();
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName,
                     String.format("开始根据时间和标签查询自来水对齐数据, 开启事务和游标 开始时间:%s, 结束时间:%s, 间隔:%d, 间隔单位:%s ,对齐单位:%s, 采集标签:%s",
                             beginTime, endTime, interval, intervalUnit, alignUnit, selfTags));
             long begin = System.currentTimeMillis();
 
             //获取游标
-            try (Cursor<ShizilaishuiHistory> cursor = mapper.findAlignByTimeAndTags(beginTime.format(dateTimeFormatter),
-                    endTime.format(dateTimeFormatter), interval.toString(), intervalUnit, alignUnit, selfTags)) {
+            try (Cursor<CollectHistory> cursor = mapper.findAlignByTimeAndTags(collectProperties.getViewName(),
+                    beginTime.format(dateTimeFormatter), endTime.format(dateTimeFormatter),
+                    interval.toString(), intervalUnit, alignUnit, selfTags)) {
                 //迭代游标
-                for (ShizilaishuiHistory shizilaishuiHistory : cursor) {
+                for (CollectHistory collectHistory : cursor) {
                     //检查游标完成
                     if (cursor.isConsumed()) break;
                     //填入数据
-                    shizilaishuiHistories.add(shizilaishuiHistory);
+                    collectHistories.add(collectHistory);
                 }
             } catch (IOException e) {
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName, String.format("关闭游标失败  error:%s", e));
@@ -144,7 +151,7 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
                     String.format("完成根据时间和标签查询自来水对齐数据, 关闭事务和游标 开始时间:%s, 结束时间:%s, 间隔:%d, 间隔单位:%s, 用时(毫秒):%d",
                             beginTime, endTime, interval, intervalUnit, (end - begin)));
 
-            return shizilaishuiHistories;
+            return collectHistories;
         }
     }
 
@@ -158,26 +165,26 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
      */
     @Override
     @Transactional(transactionManager = "oracleDbTransactionManager")
-    public List<ShizilaishuiHistory> findAl(LocalDateTime beginTime, LocalDateTime endTime, List<String> selfTags) {
+    public List<CollectHistory> findAl(LocalDateTime beginTime, LocalDateTime endTime, List<String> selfTags) {
         //获取session和mapper
         try (SqlSession session = oracleSqlSessionFactory.openSession()) {
-            ShizilaishuiHistoryMapper mapper = session.getMapper(ShizilaishuiHistoryMapper.class);
+            CollectHistoryMapper mapper = session.getMapper(CollectHistoryMapper.class);
 
-            //市自来水历史集合
-            List<ShizilaishuiHistory> shizilaishuiHistories = new ArrayList<>();
+            //采集历史集合
+            List<CollectHistory> collectHistories = new ArrayList<>();
             LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_INFO, mBizType, mStrClassName,
                     String.format("开始根据时间和标签查询自来水历史数据, 开启事务和游标 开始时间:%s, 结束时间:%s, 采集标签:%s", beginTime, endTime, selfTags));
             long begin = System.currentTimeMillis();
 
             //获取游标
-            try (Cursor<ShizilaishuiHistory> cursor = mapper.findAllByTimeAndTags(
+            try (Cursor<CollectHistory> cursor = mapper.findAllByTimeAndTags(collectProperties.getViewName(),
                     beginTime.format(dateTimeFormatter), endTime.format(dateTimeFormatter), selfTags)) {
                 //迭代游标
-                for (ShizilaishuiHistory shizilaishuiHistory : cursor) {
+                for (CollectHistory collectHistory : cursor) {
                     //检查游标完成
                     if (cursor.isConsumed()) break;
                     //填入数据
-                    shizilaishuiHistories.add(shizilaishuiHistory);
+                    collectHistories.add(collectHistory);
                 }
             } catch (IOException e) {
                 LogPrintMgr.getInstance().printLogMsg(LogLevelFlag.LOG_ERROR, mBizType, mStrClassName, String.format("关闭游标失败  error:%s", e));
@@ -188,7 +195,7 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
                     String.format("完成根据时间和标签查询自来水历史数据, 关闭事务和游标 开始时间:%s, 结束时间:%s, 用时(毫秒):%d",
                             beginTime, endTime, (end - begin)));
 
-            return shizilaishuiHistories;
+            return collectHistories;
         }
     }
 
@@ -202,6 +209,7 @@ public class ShizilaishuiHistoryServiceImpl implements ShizilaishuiHistoryServic
      */
     @Override
     public Long findCount(LocalDateTime beginTime, LocalDateTime endTime, List<String> selfTags) {
-        return shizilaishuiHistoryMapper.findCountByTimeAndTags(beginTime.format(dateTimeFormatter), endTime.format(dateTimeFormatter), selfTags);
+        return collectHistoryMapper.findCountByTimeAndTags(collectProperties.getViewName(),
+                beginTime.format(dateTimeFormatter), endTime.format(dateTimeFormatter), selfTags);
     }
 }

+ 6 - 6
src/main/java/com/shkpr/service/aimodelpower/dbdao/services/intef/ShizilaishuiHistoryService.java

@@ -1,17 +1,17 @@
 package com.shkpr.service.aimodelpower.dbdao.services.intef;
 
-import com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory;
+import com.shkpr.service.aimodelpower.dto.CollectHistory;
 
 import java.time.LocalDateTime;
 import java.util.List;
 
 /**
- * 市自来水历史service
+ * 采集历史service
  *
  * @author 欧阳劲驰
  * @serial 1.0.4
  */
-public interface ShizilaishuiHistoryService {
+public interface CollectHistoryService {
     /**
      * 查询差值
      *
@@ -24,7 +24,7 @@ public interface ShizilaishuiHistoryService {
      * @param outTags      供出标签
      * @return 历史数据
      */
-    List<ShizilaishuiHistory> findDifference(LocalDateTime beginTime, LocalDateTime endTime, Integer interval
+    List<CollectHistory> findDifference(LocalDateTime beginTime, LocalDateTime endTime, Integer interval
             , String intervalUnit, List<String> selfTags, List<String> inTags, List<String> outTags);
 
     /**
@@ -38,7 +38,7 @@ public interface ShizilaishuiHistoryService {
      * @param selfTags     自供标签
      * @return 历史数据
      */
-    List<ShizilaishuiHistory> findAlign(LocalDateTime beginTime, LocalDateTime endTime, Integer interval
+    List<CollectHistory> findAlign(LocalDateTime beginTime, LocalDateTime endTime, Integer interval
             , String intervalUnit, String alignUnit, List<String> selfTags
     );
 
@@ -50,7 +50,7 @@ public interface ShizilaishuiHistoryService {
      * @param selfTags  自供标签
      * @return 历史数据
      */
-    List<ShizilaishuiHistory> findAl(LocalDateTime beginTime, LocalDateTime endTime, List<String> selfTags);
+    List<CollectHistory> findAl(LocalDateTime beginTime, LocalDateTime endTime, List<String> selfTags);
 
     /**
      * 查询条数

+ 2 - 2
src/main/java/com/shkpr/service/aimodelpower/dto/ShizilaishuiHistory.java

@@ -3,13 +3,13 @@ package com.shkpr.service.aimodelpower.dto;
 import lombok.Data;
 
 /**
- * 市自来水历史表
+ * 采集历史表
  *
  * @author 欧阳劲驰
  * @serial 1.0.4
  */
 @Data
-public class ShizilaishuiHistory {
+public class CollectHistory {
     /**
      * 采集标签
      */

+ 5 - 0
src/main/resources/application.properties

@@ -149,6 +149,9 @@ in.sub.type=wp_room_in_src
 #供水
 out.sub.type=wp_room
 #====================采集配置====================
+#视图名称
+collect.view-name=cqda.v_shizilaishui_history2
+#collect.view-name=cqda.v_jiangjin_history
 #最大水量
 collect.max-water=30000.0
 #最小水量
@@ -156,6 +159,8 @@ collect.min-water=-30000.0
 #关闭标签
 collect.close-tags=FSBSC_MAS.MAS.TOTALFLOWD,fsbsc_mas.mas.totalflowg
 #==========营业所标签:自供+(供入-供出)==========
+#营业所采集
+collect.business-collected=false
 #自供-沙坪坝营业所
 collect.supply-self-tags[0].name=\u6c99\u576a\u575d\u8425\u4e1a\u6240
 collect.supply-self-tags[0].values=SPB.SSWD.total_flow1,SPB.SSWD.total_flow2,JKSC.SS.accflow9,JKSC.SS.accflow8,SS.SS.HYL_LJLL

+ 18 - 11
src/main/resources/mapper/ShizilaishuiHistoryMapper.xml

@@ -1,7 +1,7 @@
 <?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.aimodelpower.dbdao.mapperoracle.ShizilaishuiHistoryMapper">
-    <select id="findDifferenceByTimeAndTags" resultType="com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory"
+<mapper namespace="com.shkpr.service.aimodelpower.dbdao.mapperoracle.CollectHistoryMapper">
+    <select id="findDifferenceByTimeAndTags" resultType="com.shkpr.service.aimodelpower.dto.CollectHistory"
             fetchSize="3000">
         with time_seq (start_time, end_time)
         as (select to_date(#{beginTime,jdbcType=VARCHAR}, 'yyyy-mm-dd hh24:mi:ss') as start_time,
@@ -25,7 +25,7 @@
         max(val) keep (dense_rank first order by qcquisition_time)
         ) as water_usage,
         tag_code
-        from cqda.v_shizilaishui_history2
+        from ${viewName}
         where tag_code in
         <foreach collection="selfTags" open="(" close=")" separator="," item="tag">
             #{tag,jdbcType=VARCHAR}
@@ -42,7 +42,7 @@
             max(val) keep (dense_rank first order by qcquisition_time)
             ) as water_usage,
             tag_code
-            from cqda.v_shizilaishui_history2
+            from ${viewName}
             where tag_code in
             <foreach collection="inTags" open="(" close=")" separator="," item="tag">
                 #{tag,jdbcType=VARCHAR}
@@ -61,7 +61,7 @@
             max(val) keep (dense_rank first order by qcquisition_time)
             ) as water_usage,
             tag_code
-            from cqda.v_shizilaishui_history2
+            from ${viewName}
             where tag_code in
             <foreach collection="outTags" open="(" close=")" separator="," item="tag">
                 #{tag,jdbcType=VARCHAR}
@@ -76,7 +76,8 @@
         order by ts.start_time
     </select>
 
-    <select id="findAlignByTimeAndTags" resultType="com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory" fetchSize="3000">
+    <select id="findAlignByTimeAndTags" resultType="com.shkpr.service.aimodelpower.dto.CollectHistory"
+            fetchSize="3000">
         with time_seq (start_time)
         as (select to_date(#{beginTime,jdbcType=VARCHAR}, 'yyyy-mm-dd hh24:mi:ss') as start_time
         from dual
@@ -91,7 +92,7 @@
         left join (select tag_code, val,trunc(qcquisition_time, #{alignUnit,jdbcType=VARCHAR}) as hour_trunc,
         row_number() over (partition by trunc(qcquisition_time, #{alignUnit,jdbcType=VARCHAR}), tag_code
         order by abs(qcquisition_time - trunc(qcquisition_time, #{alignUnit,jdbcType=VARCHAR}))) as rn
-        from cqda.v_shizilaishui_history2
+        from ${viewName}
         where tag_code in
         <foreach collection="selfTags" open="(" close=")" separator="," item="tag">
             #{tag,jdbcType=VARCHAR}
@@ -102,13 +103,19 @@
         order by ts.start_time
     </select>
 
-    <select id="findAllByTimeAndTags" resultType="com.shkpr.service.aimodelpower.dto.ShizilaishuiHistory" fetchSize="3000">
+    <select id="findAllByTimeAndTags" resultType="com.shkpr.service.aimodelpower.dto.CollectHistory"
+            fetchSize="3000">
         select tag_code,
-        name,
+        <if test="viewName == 'cqda.v_shizilaishui_history2'">
+            name,
+        </if>
+        <if test="viewName == 'cqda.v_jiangjin_history'">
+            org_name as name,
+        </if>
         val,
         to_char(qcquisition_time, 'yyyy-mm-dd hh24:mi:ss') as time,
         to_char(update_time, 'yyyy-mm-dd hh24:mi:ss') as update_time
-        from cqda.v_shizilaishui_history2
+        from ${viewName}
         where tag_code in
         <foreach collection="selfTags" open="(" close=")" separator="," item="tag">
             #{tag,jdbcType=VARCHAR}
@@ -118,7 +125,7 @@
     </select>
 
     <select id="findCountByTimeAndTags" resultType="java.lang.Long">
-        select count(1) from cqda.v_shizilaishui_history2
+        select count(1) from ${viewName}
         where tag_code in
         <foreach collection="selfTags" open="(" close=")" separator="," item="tag">
             #{tag,jdbcType=VARCHAR}