Browse Source

"获取分区水量;批量绑定分区用户"

yangjunfeng 1 week ago
parent
commit
15c8d2d107

+ 1 - 1
ylsw-gis/src/main/java/com/tofly/xrtygis/custom/entity/Customize.java

@@ -26,7 +26,7 @@ import java.util.Date;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @TableName(value = "TF_YWPN_CUSTOMIZE_W", resultMap = "customizeMap")
-@KeySequence("TF_YWPN_CUSTOMIZE_W_SEQ")
+@KeySequence("TF_YWPN_CUSTOMIZE_W")
 @ApiModel
 public class Customize extends Model<Customize> {
     private static final long serialVersionUID = 1L;

+ 5 - 0
ylsw-gis/src/main/java/com/tofly/xrtygis/custom/mapper/CustomTheMapMapper.java

@@ -52,5 +52,10 @@ public interface CustomTheMapMapper {
 
     List<Map> getPartition(@Param("level") String level);
 
+    List<Map<String, Object>> getRegionWater(@Param("dmaId") Long dmaId,
+                                             @Param("indexType") String indexType,
+                                             @Param("years") String years,
+                                             @Param("months") String months);
+
     List<Map> getAllUseWater(@Param("sql") String sql);
 }

+ 9 - 12
ylsw-gis/src/main/java/com/tofly/xrtygis/custom/service/dma/impl/YhBingAreaServiceImpl.java

@@ -107,19 +107,17 @@ public class YhBingAreaServiceImpl implements YhBingAreaService {
                 dmausertableList.addAll(queryExistYhbh);
             }
             Map<String, String> yhAndDma = new HashMap<>(16);
-            dmausertableList.forEach(v -> {
-                yhAndDma.put(v.getYhbh(), v.getDmaIds());
-            });
+            dmausertableList.forEach(v -> yhAndDma.put(v.getYhbh(), v.getDmaIds()));
 
             //如果查询出来的个数与传入的个数不相等,那么会有用户输入编号错误的情况,将对这些编号进行筛选出来
-            if (!(size == dmausertableList.size())) {
-                //过滤用户编号输入错误的
-                List<String> errorYhbh = yhbhList.stream().filter(m -> !yhAndDma.containsKey(m)).collect(Collectors.toList());
-                if (errorYhbh.size() > 0) {
-                    String error = StringUtil.join(errorYhbh, ",");
-                    throw new ToflyDeniedException("以下用户编号填写错误:" + error + "请重新填写");
-                }
-            }
+//            if (!(size == dmausertableList.size())) {
+//                //过滤用户编号输入错误的
+//                List<String> errorYhbh = yhbhList.stream().filter(m -> !yhAndDma.containsKey(m)).collect(Collectors.toList());
+//                if (errorYhbh.size() > 0) {
+//                    String error = StringUtil.join(errorYhbh, ",");
+//                    throw new ToflyDeniedException("以下用户编号填写错误:" + error + "请重新填写");
+//                }
+//            }
             //存放用户和绑定分区的GUID
             Map<String, String> updateYhAndDma = new HashMap<>(16);
             //过滤已经绑定了该分区的用户
@@ -136,7 +134,6 @@ public class YhBingAreaServiceImpl implements YhBingAreaService {
                     updateYhAndDma.put(k, guid);
                 }
             });
-
             if (updateYhAndDma.size() > 0) {
                 //修改用户绑定分区
                 dmausertableService.updateBingDma(updateYhAndDma);

+ 24 - 23
ylsw-gis/src/main/java/com/tofly/xrtygis/custom/service/impl/CustomTheMapServiceImpl.java

@@ -11,6 +11,7 @@ import com.tofly.xrtygis.custom.mapper.CustomTheMapMapper;
 import com.tofly.xrtygis.custom.service.CustomTheMapService;
 import com.tofly.xrtygis.custom.util.CallAPIUtil;
 import com.tofly.xrtygis.custom.util.CommonMethod;
+import com.tofly.xrtygis.em.IndexTypeInfoEnum;
 import com.tofly.xrtygis.entity.Itemtyperato;
 import com.tofly.xrtygis.entity.Scadastaitem;
 import com.tofly.xrtygis.entity.Scadastation;
@@ -252,32 +253,32 @@ public class CustomTheMapServiceImpl implements CustomTheMapService {
     @Override
     public Map<Long, Object> getAreaWater(String level, String year, String month) {
         List<Map> partitions = customTheMapMapper.getPartition(level);
-        String[] years = year.split(",");
-        List<String> collect = Arrays.stream(month.split(",")).sorted().collect(Collectors.toList());
-        if (collect.size() < 2) {
-            collect.add(collect.get(0));
-        }
+//        String[] years = year.split(",");
+//        List<String> collect = Arrays.stream(month.split(",")).sorted().collect(Collectors.toList());
+//        if (collect.size() < 2) {
+//            collect.add(collect.get(0));
+//        }
         Map<Long, Object> result = new HashMap<>();
 
-        StringBuilder sb;
+//        StringBuilder sb;
         for (Map p : partitions) {
-            sb = new StringBuilder();
-            for (int i = 0; i < years.length; i++) {
-                String sql = " select cwyf, sum(ysl) ysl\n" +
-                        "        from TF_YWPN_DMAUSERTABLE_W a,\n" +
-                        "             TF_YWPN_DMAUSERWATER_W b\n" +
-                        "        where a.yhbh = b.yhbh\n" +
-                        "          and CWYF between '" + years[i] + collect.get(0) + "' and '" + years[i] + collect.get(1) + "'\n" +
-                        "          and instr(dma_ids,'" + p.get("dmaGid").toString() + "') > 0\n" +
-                        "        group by cwyf ";
-
-                if (i == years.length - 1) {
-                    sb.append(sql);
-                } else {
-                    sb.append(sql).append(" union all ");
-                }
-            }
-            result.put(Long.parseLong(p.get("id").toString()), customTheMapMapper.getAllUseWater(sb.toString()));
+//            sb = new StringBuilder();
+//            for (int i = 0; i < years.length; i++) {
+//                String sql = " select cwyf, sum(ysl) ysl\n" +
+//                        "        from TF_YWPN_DMAUSERTABLE_W a,\n" +
+//                        "             TF_YWPN_DMAUSERWATER_W b\n" +
+//                        "        where a.yhbh = b.yhbh\n" +
+//                        "          and CWYF between '" + years[i] + collect.get(0) + "' and '" + years[i] + collect.get(1) + "'\n" +
+//                        "          and instr(dma_ids,'" + p.get("dmaGid").toString() + "') > 0\n" +
+//                        "        group by cwyf ";
+//
+//                if (i == years.length - 1) {
+//                    sb.append(sql);
+//                } else {
+//                    sb.append(sql).append(" union all ");
+//                }
+//            }
+            result.put(Long.parseLong(p.get("id").toString()), customTheMapMapper.getRegionWater(Long.parseLong(p.get("id").toString()), IndexTypeInfoEnum.CUM_FLOW.getId(), year, month));
         }
         return result;
     }

+ 1 - 1
ylsw-gis/src/main/java/com/tofly/xrtygis/entity/DmaStatistical.java

@@ -26,7 +26,7 @@ import java.util.Date;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @TableName(value = "TF_DMA_STATISTICAL", resultMap = "dmaStatisticalMap")
-@KeySequence("TF_DMA_STATISTICAL_SEQ")
+@KeySequence("TF_DMA_STATISTICAL")
 @ApiModel
 public class DmaStatistical extends Model<DmaStatistical> {
     private static final long serialVersionUID = 1L;

+ 1 - 1
ylsw-gis/src/main/java/com/tofly/xrtygis/entity/IndicatorCorrection.java

@@ -26,7 +26,7 @@ import java.util.Date;
 @Data
 @EqualsAndHashCode(callSuper = true)
 @TableName(value = "TF_YWPN_INDICATOR_CORRECTION_W", resultMap = "indicatorCorrectionMap")
-@KeySequence("INDICATOR_CORRECTION_SEQ")
+@KeySequence("TF_YWPN_INDICATOR_CORRECTION_W")
 @ApiModel
 public class IndicatorCorrection extends Model<IndicatorCorrection> {
     private static final long serialVersionUID = 1L;

+ 5 - 6
ylsw-gis/src/main/resources/custom/CustomDisplayMapper.xml

@@ -601,15 +601,14 @@
     <select id="getSomeDayWater" resultType="map">
         SELECT
             NVL(SUM(a.MAX - a.MIN), 0) diff,
-            c.ID device_id
+            b.DEVICE_ID
         FROM STATISTICS_SCADA a
-                 LEFT JOIN TF_INDEX_ALLOCATION b on b.VARIABLE_CODE = a.CODE
-                 LEFT JOIN TF_DEVICE_ARCHIVE_MANAGE c on c.ID = b.DEVICE_ID
+            LEFT JOIN TF_INDEX_ALLOCATION b on b.VARIABLE_CODE = a.CODE
         WHERE
             a.STATISTICS_TYPE = 0
-          AND a.DATA_TYPE = #{indexType}
-          AND TO_CHAR(a.START_TIME,'yyyy-MM-dd') = #{day}
+            AND a.DATA_TYPE = #{indexType}
+            AND TO_CHAR(a.START_TIME,'yyyy-MM-dd') = #{day}
         GROUP BY
-            c.ID
+            b.DEVICE_ID
     </select>
 </mapper>

+ 26 - 0
ylsw-gis/src/main/resources/custom/CustomTheMapMapper.xml

@@ -65,6 +65,32 @@
         where partition_level = #{level}
     </select>
 
+    <select id="getRegionWater" resultType="map">
+        SELECT to_char(a.START_TIME, 'yyyyMM') cwyf,
+               sum(a.MAX - a.MIN) ysl
+        FROM STATISTICS_SCADA a
+            LEFT JOIN TF_INDEX_ALLOCATION b ON a.CODE = b.VARIABLE_CODE
+            LEFT JOIN TF_YWPN_DMAANDOBSER_W d ON d.TABLE_ID = b.DEVICE_ID
+        WHERE
+            d.DMA_ID = #{dmaId}
+            AND b.TYPE = #{indexType}
+            AND a.STATISTICS_TYPE = 1
+            AND d.ISOUT = '0'
+        <if test="years != null and years != '' ">
+            AND to_char(a.START_TIME, 'yyyy') IN
+            <foreach collection="years.split(',')" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        <if test="months != null and months != '' ">
+            AND to_char(a.START_TIME, 'MM') IN
+            <foreach collection="months.split(',')" item="id" open="(" separator="," close=")">
+                #{id}
+            </foreach>
+        </if>
+        GROUP BY to_char(a.START_TIME, 'yyyyMM')
+    </select>
+
     <select id="getAllUseWater" resultType="map">
         ${sql}
     </select>