/*
 * Author: wangjian
 * 生成mapper
 */
package com.tofly.xrtygis.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.tofly.xrtygis.entity.Warn;
import com.tofly.xrtygis.entity.dto.MeterReadingNumberDto;
import com.tofly.xrtygis.entity.dto.WarnInfoDto;
import com.tofly.xrtygis.entity.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 报警实时信息表
 *
 * @author admin
 * @date Wed Mar 10 00:00:00 CST 2021
 */
public interface WarnMapper extends BaseMapper<Warn> {

    String getWarnTypeName(@Param("warnType") String warnType);

    @Select("SELECT " +
            "B.ID stationId, " +
            "B.STNM stationName," +
            "B.RANGEID rangeId," +
            "P.ID ID," +
            "P.ITCD itcd," +
            "N.CNAME warnType," +
            "P.ISLOC isloc," +
            "P.NOTES notes," +
            "P.ADDRESS address," +
            "P.DURATION duration," +
            "P.NUM num," +
            "P.ISCONFIRM isconfirm," +
            "P.ISCLEAR isclear," +
            "P.CONFIRM_TIME confirmTime," +
            "P.CONFIRM_USER confirmUser," +
            "P.SCADA_TIME scadaTime " +
            "FROM " +
            "TF_YWPN_WARN_W P " +
            "LEFT JOIN TF_YWPN_SCADASTAITEM_W M ON P.ITCD = M.ITCD " +
            "LEFT JOIN TF_YWPN_SCADASTATION_B B ON B.ID = M.STATION_ID " +
            "LEFT JOIN TF_YWPN_SYSCHILDCODE_D N ON P.WARN_TYPE = N.CCODE " +
            "${ew.customSqlSegment} " +
            "order by rangeId DESC, scadaTime DESC")
    Page<WarnInfoVo> searchWeeklyPage(Page<WarnInfoVo> page, @Param(Constants.WRAPPER) QueryWrapper<WarnInfoDto> queryWrapper);

    @Select("SELECT " +
            " n.planMeterReadingNumber planMeterReadingNumber, " +
            " n.meterReadingNumber meterReadingNumber, " +
            " n.notMeterReadingNumber notMeterReadingNumber, " +
            " n.planDownloadNumber planDownloadNumber, " +
            " n.downloadNumber downloadNumber, " +
            " n.notDownloadNumber notDownloadNumber, " +
            " n.planAllotment planAllotment, " +
            " n.allotment allotment, " +
            " ( " +
            "  n.planAllotment - n.allotment " +
            " ) notAllotment " +
            "FROM " +
            " ( " +
            "  SELECT " +
            "   M .planMeterReadingNumber, " +
            "   M .meterReadingNumber, " +
            "   M .notMeterReadingNumber, " +
            "   M .planDownloadNumber, " +
            "   M .downloadNumber, " +
            "   M .notDownloadNumber, " +
            "   ( " +
            "    SELECT " +
            "     NVL (COUNT(*), 0) " +
            "    FROM " +
            "     TF_YWPN_QFCBQFMX_W " +
            "   ) planAllotment, " +
            "   ( " +
            "    SELECT " +
            "     NVL (COUNT(*), 0) " +
            "    FROM " +
            "     TF_YWPN_QFCBQFMX_W A " +
            "    RIGHT JOIN TF_YWPN_YHBINGQY_W b ON A .YHBH = b.YHBH " +
            "   ) allotment " +
            "  FROM " +
            "   ( " +
            "    SELECT " +
            "     COUNT (B.CBBZ) planMeterReadingNumber, " +
            "     NVL ( " +
            "      SUM ( " +
            "       CASE " +
            "       WHEN B.CBBZ = '1' THEN " +
            "        1 " +
            "       ELSE " +
            "        0 " +
            "       END " +
            "      ), " +
            "      0 " +
            "     ) meterReadingNumber, " +
            "     NVL ( " +
            "      SUM ( " +
            "       CASE " +
            "       WHEN B.CBBZ = '0' THEN " +
            "        1 " +
            "       ELSE " +
            "        0 " +
            "       END " +
            "      ), " +
            "      0 " +
            "     ) notMeterReadingNumber, " +
            "     COUNT (B.XZBS) planDownloadNumber, " +
            "     NVL ( " +
            "      SUM ( " +
            "       CASE " +
            "       WHEN B.XZBS = '1' THEN " +
            "        1 " +
            "       ELSE " +
            "        0 " +
            "       END " +
            "      ), " +
            "      0 " +
            "     ) downloadNumber, " +
            "     NVL ( " +
            "      SUM ( " +
            "       CASE " +
            "       WHEN B.XZBS = '0' THEN " +
            "        1 " +
            "       ELSE " +
            "        0 " +
            "       END " +
            "      ), " +
            "      0 " +
            "     ) notDownloadNumber " +
            "    FROM " +
            "     TF_YWPN_YHBINGQY_W A " +
            "    LEFT JOIN TF_YWPN_QFCBQFMX_W B ON A .YHBH = B.YHBH " +
            "    LEFT JOIN TF_YWPN_CBQYDBM_W C ON C.QYDBM = A .QYDBM " +
            "    LEFT JOIN TF_YWPN_CBQYBM_W D ON C.QYBM = D .QYBM " +
            "    " +
            "    ${ew.customSqlSegment}  " +
            "   ) M " +
            " ) n" +
            "")
    MeterReadingNumberVo getMeterReadingMonthNum(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);

    @Select("SELECT m.planRepairOrderNumber planRepairOrderNumber,m.repairOrderNumber repairOrderNumber,(m.planRepairOrderNumber-m.repairOrderNumber)notRepairOrderNumber " +
            "FROM " +
            "(SELECT " +
            " NVL ( " +
            "  SUM ( " +
            "   CASE " +
            "   WHEN LCJD = '1' THEN " +
            "    1 " +
            "   ELSE " +
            "    0 " +
            "   END " +
            "  ), " +
            "  0 " +
            " ) planRepairOrderNumber, " +
            "  NVL ( " +
            "  SUM ( " +
            "   CASE " +
            "   WHEN LCJD = '7' THEN " +
            "    1 " +
            "   ELSE " +
            "    0 " +
            "   END " +
            "  ), " +
            "  0 " +
            " ) repairOrderNumber " +
            "FROM " +
            " TF_YWPN_GDINFO_W" +
            " ${ew.customSqlSegment} )m")
    RepairOrderNumberVo getRepairOrderNum(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);


    @Select("SELECT t1.totalWaterMeterNumber,t1.waterMeterOutboundNumber,t1.notWaterMeterOutboundNumber, " +
            "t2.installationNumber,t2.outboundNumber,t2.withdrawingNumber, " +
            "t3.oldTransferNumber,t3.newTransferNumber,t3.totalTransferNumber, " +
            "t4.weeklyNumber,t4.faultSamplingNumber,t4.totalSamplingNumber " +
            "FROM " +
            "(SELECT NVL(sum(BW_KCZS),0) totalWaterMeterNumber,NVL(sum(BW_SYSL),0) waterMeterOutboundNumber,NVL(sum(BW_KCSL),0)notWaterMeterOutboundNumber FROM " +
            "TF_YWPN_BWRKTOTAL_W)t1, " +
            "(SELECT t.installationNumber,t.outboundNumber,(t.outboundNumber-t.installationNumber)withdrawingNumber " +
            "FROM " +
            "(SELECT  " +
            "(SELECT count(*) FROM " +
            "TF_YWPN_BWRKSBDATAIL_W) installationNumber, " +
            "(SELECT NVL(sum(BW_KCSL),0) FROM " +
            "TF_YWPN_BWRKTOTAL_W) outboundNumber " +
            "FROM " +
            "dual)t)t2, " +
            "(SELECT t.oldTransferNumber,t.newTransferNumber,(t.oldTransferNumber+t.newTransferNumber)totalTransferNumber " +
            "FROM " +
            "(SELECT NVL(sum(case when bw_sbzt = '62' then 1 else 0 end),0) newTransferNumber, " +
            "       NVL(sum(case when bw_sbzt = '61' then 1 else 0 end),0) oldTransferNumber  FROM " +
            "TF_YWPN_BWRKSBDATAIL_W) t)t3, " +
            "(SELECT t.weeklyNumber,t.faultSamplingNumber,(t.weeklyNumber+t.faultSamplingNumber) totalSamplingNumber " +
            "FROM " +
            "(SELECT  " +
            "(SELECT count(*) FROM " +
            "TF_YWPN_BWZJBCJDATAIL_W) weeklyNumber, " +
            "(SELECT count(*) FROM " +
            "TF_YWPN_BWGZBCJDATAIL_W) faultSamplingNumber " +
            "FROM " +
            "dual)t)t4 " )
    WaterMeterNumberVo getWaterMeterNumberNum();
    @Select("SELECT " +
            "t.BW_SBCJ, " +
            "n.CNAME, " +
            "NVL (SUM(t.BW_KCZS), 0) totalWaterMeterNumber " +
            "FROM " +
            "TF_YWPN_BWRKTOTAL_W t LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.BW_SBCJ = n.id " +
            "GROUP BY t.BW_SBCJ,n.CNAME")
    List<WaterMeterPutStorageStatisticalVo> getWaterMeterPutStorageStatistical();
    @Select("SELECT t.BW_SBCJ, n.CNAME, count(t.BW_AZRY) totalNumber FROM  " +
            "TF_YWPN_BWRKSBDATAIL_W t  LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.BW_SBCJ = n.id " +
            "WHERE t.BW_AZRY IS NOT NULL " +
            "GROUP BY t.BW_SBCJ,n.CNAME ")
    List<WaterMeterInstallationStatisticalVo> getWaterMeterInstallationStatistical();
    @Select("SELECT t.BW_SBCJ, n.CNAME, count(t.CK_ID) totalNumber FROM  " +
            "TF_YWPN_BWRKSBDATAIL_W t  LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.BW_SBCJ = n.id " +
            "WHERE t.CK_ID IS not NULL " +
            "GROUP BY t.BW_SBCJ,n.CNAME")
    List<WaterMeterOutboundStatisticalVo> getWaterMeterOutboundStatistical();
    @Select("SELECT " +
            "t.BW_SBCJ,n.CNAME,NVL ( SUM ( CASE WHEN t.bw_sbzt = '61' THEN 1 ELSE 0 END ), 0 ) totalNumber " +
            "FROM " +
            "TF_YWPN_BWRKSBDATAIL_W t  LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.BW_SBCJ = n.id " +
            "GROUP BY t.BW_SBCJ,n.CNAME")
    List<WaterMeterOldTransferStatisticalVo> getWaterMeterOldTransferStatistical();

    @Select("SELECT t.BW_SBCJ manufacturer,n.CNAME cname,t.BW_KCZS waterMeterNumber FROM TF_YWPN_BWRKTOTAL_W t LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.BW_SBCJ = n.id  " +
            "GROUP BY t.BW_SBCJ,t.BW_KCZS ,n.CNAME")
    List<WaterMeterEnterpriseVo> getWaterMeterEnterprise();
    @Select("SELECT t.BW_SBCJ,n.CNAME cname,COUNT (t.BW_SBCJ)totalNumber " +
            "FROM " +
            "TF_YWPN_BWGZBCJDATAIL_W t  LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.BW_SBCJ = n.id " +
            "GROUP BY t.BW_SBCJ,n.CNAME")
    List<WaterMeteFaultTableStatisticalVo> getWaterMeteFaultTableStatistical();
    @Select("SELECT t.BW_SBCJ,n.CNAME cname,COUNT (t.BW_SBCJ)totalNumber " +
            "FROM " +
            "TF_YWPN_BWZJBCJDATAIL_W t  LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.BW_SBCJ = n.id " +
            "GROUP BY t.BW_SBCJ,n.CNAME")
    List<WaterMeteWeeklyCheckStatisticalVo> getWaterMeteWeeklyCheckStatistical();
    @Select("SELECT nvl((t.totalBuild - t.completedBuild),0) unfinishedTrouble, " +
            "decode(t.totalBuild,0,0,round((t.completedBuild/t.totalBuild)*100,2)) troubleRatea, " +
            "nvl((t.totalBuild-t.completedBuild),0) unfinishedBuild, " +
            "decode(t.totalBuild,0,0,round((t.completedBuild/t.totalBuild)*100,2)) buildRate, " +
            "nvl((t.totalOrder-t.completedOrder),0) unfinishedOrder, " +
            "decode(t.totalOrder,0,0,round((t.completedOrder/t.totalOrder)*100,2)) orderRate, " +
            "t.* " +
            "FROM " +
            "(SELECT " +
            "(SELECT count(1)  " +
            "FROM TF_YWPN_BUILD_W) totalBuild, " +
            " " +
            "(SELECT count(1)  " +
            "FROM TF_YWPN_BUILD_W " +
            "WHERE STATE = '2') completedBuild, " +
            " " +
            "(SELECT count(1)  " +
            "FROM TF_YWPN_TROUBLE_W)totalTrouble, " +
            " " +
            "(SELECT count(1)  " +
            "FROM TF_YWPN_TROUBLE_W " +
            "WHERE STATE = '2') completedTrouble, " +
            " " +
            "(SELECT count(1)  " +
            "FROM TF_YWPN_REPAIRORDER_W) totalOrder, " +
            " " +
            "(SELECT count(1)  " +
            "FROM TF_YWPN_REPAIRORDER_W " +
            "WHERE STATE = '4') completedOrder " +
            "FROM " +
            "dual)t ")
    InspectionStatisticalVo getInspectionStatistical();

    @Select("SELECT  t.num1 completeNum,t.num2 unfinishedNum FROM " +
            "(SELECT sum(case when PLAN_STATE = '4' then 1 else 0 end)num1,sum(PLAN_STATE)num2 FROM " +
            "TF_YWPN_PLAN_W " +
            "${ew.customSqlSegment} " +
            ")t ")
    List<InspectionTypeStatisticalVo> getNowInspectionStatistical(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);

    @Select("SELECT nvl(count(SIGN_TYPE),0) clockNum, nvl(sum(case when SIGN_TYPE = '1' then 1 else 0 end),0)onlineNum FROM " +
            "TF_YWPN_PDASIGN_W " +
            "${ew.customSqlSegment}")
    InspectionUserStateStatisticalVo getInspectionUserStateNum(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);

    @Select("SELECT case  " +
            "when n.orderSource = '0' then '计划'  " +
            "when n.orderSource = '1' then '自建'  " +
            "when n.orderSource = '2' then '热线' else '未指定'  " +
            "end regionName ,n.totalOrder,n.completedOrder,(n.totalOrder-n.completedOrder)unfinishedOrder,decode(n.totalOrder,0,0,round((n.completedOrder/n.totalOrder)*100,2))orderRate  " +
            "FROM " +
            "(SELECT  " +
            " t2.ORDER_SOURCE orderSource,nvl(count(t1.PLAN_NUM),0) totalOrder, " +
            "nvl(SUM ( CASE WHEN t2.STATE = '4' THEN 1 ELSE 0 END ),0) completedOrder  " +
            "FROM " +
            "TF_YWPN_REPAIRUSER_W t1 LEFT JOIN TF_YWPN_REPAIRORDER_W t2 on T1.REPAIR_ID = T2.ID " +
            "WHERE t2.START_TIME between #{startTime}  and #{endTime}  " +
            "or t2.END_TIME between #{startTime}  and #{endTime}  " +
            "GROUP BY t2.ORDER_SOURCE  " +
            ")n " )
    List<RepairOrderStatisticalVo> getRepairOrderStatistical(@Param("startTime") Date startTime,@Param("endTime")Date endTime);

    @Select("select t.AREANO groupAreaName,sum(t.PIPELENGTH) totalPipeLength " +
            "FROM " +
            "((select AREANO ,sum(PIPELENGTH) PIPELENGTH from sde_ly.TF_JSJS_PIPE_B  " +
            "GROUP BY AREANO) " +
            "union  " +
            "(select AREANO,sum(PIPELENGTH) PIPELENGTH from sde_ly.TF_JSJS_STANDPIPE_B  " +
            "GROUP BY AREANO))t " +
            " " +
            "group by AREANO  ")
    List<GroupAreaPipeLengthStatisticalVo> getGroupAreaPipeLengthStatistical();

    @Select("select MATERIAL material,round(sum(num),2) num " +
            "FROM " +
            "((select  MATERIAL ,round(sum(PIPELENGTH),2) num from sde_ly.TF_JSJS_PIPE_B  " +
            "  where material is not null GROUP BY MATERIAL) " +
            "union  " +
            "(select MATERIAL ,round(sum(PIPELENGTH),2) num from sde_ly.TF_JSJS_STANDPIPE_B  " +
            "GROUP BY MATERIAL))t " +
            "group by MATERIAL  ")
    List<PipeMaterialStatisticalVo> getPipeMaterialStatistical();

//    @Select("select MATERIAL material,sum(num) num " +
//            "FROM " +
//            "((select  MATERIAL ,sum(PIPELENGTH) num from TF_JSJS_PIPE_B@ LINK_TF_GEO  where (to_number(to_char(sysdate,'yyyy')) - to_number(to_char(to_date(BURYYEAR)),'yyyy')) > 5 " +
//            "GROUP BY MATERIAL) " +
//            "union  " +
//            "(select MATERIAL ,sum(PIPELENGTH) num from TF_JSJS_STANDPIPE_B@ LINK_TF_GEO where (to_number(to_char(sysdate,'yyyy')) - to_number(to_char(to_date(BURYYEAR)),'yyyy')) > 5 " +
//            "GROUP BY MATERIAL))t " +
//            "group by MATERIAL  ")
    @Select("select MATERIAL,PIPELENGTH NUM,DIAMETER " +
        "FROM " +
        "((select MATERIAL,PIPELENGTH,DIAMETER from sde_ly.TF_JSJS_PIPE_B) " +
        "union  " +
        "(select MATERIAL,PIPELENGTH,DIAMETER from sde_ly.TF_JSJS_STANDPIPE_B))t")
    List<PipeMaterialStatisticalVo> getPipeMaterialMoreYearCensus();

    @Select("select DIAMETER diameter,round(sum(num),2) num " +
            "FROM " +
            "((select  DIAMETER ,round(sum(PIPELENGTH),2) num from sde_ly.TF_JSJS_PIPE_B  " +
            "GROUP BY DIAMETER) " +
            "union  " +
            "(select DIAMETER ,round(sum(PIPELENGTH),2) num from sde_ly.TF_JSJS_STANDPIPE_B " +
            "GROUP BY DIAMETER))t " +
            "group by DIAMETER  " +
            "ORDER BY diameter")
    List<PipeMaterialStatisticalVo> getPipeCaliberCensus();

    @Select("SELECT t.CERTIFICATION_PROJECT,n.CNAME,to_char(t.DISPATCH_TIME,'yyyy-mm') dateTime,count(CERTIFICATION_PROJECT) num " +
            "FROM TF_YWPN_ZLRZ_W t LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON t.CERTIFICATION_PROJECT = n.id  " +
            "${ew.customSqlSegment}" +
            "GROUP BY " +
            "t.CERTIFICATION_PROJECT,n.CNAME,to_char(t.DISPATCH_TIME,'yyyy-mm')  " +
            "ORDER BY dateTime")
    List<QualityCertificationStatisticalVo> getQualityCertificationStatistical(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);

    @Select("SELECT t1.qualifiedNum,decode(t1.totalNum1,0,0,round((t1.qualifiedNum/t1.totalNum1)*100,2)) qualifiedRate, " +
            " t2.timeoutNum,decode(t2.totalNum2,0,0,round((t2.timeoutNum/t2.totalNum2)*100,2)) timeoutRate " +
            "FROM " +
            "( " +
            "SELECT count(id) totalNum1, NVL(sum(case when IS_QUALIFIED = '0' then 1 else 0 end),0) qualifiedNum " +
            "FROM TF_YWPN_ZLRZ_W " +
            "${ew.customSqlSegment})t1, " +
            " " +
            "(SELECT count(id) totalNum2, (NVL(sum(case when ORDER_EXCEPTION_STATUS = '1' then 1 else 0 end),0)+NVL(sum(case when ORDER_EXCEPTION_STATUS = '3' then 1 else 0 end),0)) timeoutNum " +
            "FROM TF_YWPN_ZLRZ_W " +
            "${ew.customSqlSegment})t2")
    QualityQualifiedTimeoutStatisticalVo getQualityQualifiedTimeoutStatistical(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);
    @Select("select zg.RECTIFY_TYPE,n.cname typeName,count(1) socialBenefitNum,nvl(sum(zg.INCREASE_PROFIT),0) economicBenefitsSum " +
            "from TF_YWPN_ZLZG_W zg left join TF_YWPN_ZLRZ_W rz on zg.CERTIFICATION_NUMBER = rz.CERTIFICATION_NUMBER LEFT JOIN TF_YWPN_SYSCHILDCODE_D n ON zg.RECTIFY_TYPE = n.id  " +
            "${ew.customSqlSegment} " +
            "group by zg.RECTIFY_TYPE,n.cname ")
    List<QualityBenefitStatisticalVo> getQualityBenefitStatistical(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);

    @Select("SELECT nvl(t1.totalInbound,0) totalInbound,nvl(t1.inboundNum,0) inboundNum,nvl((t1.totalInbound-t1.inboundNum),0) inboundLossNum " +
            "FROM " +
            "(SELECT count(CALL_TYPE) totalInbound ,sum(case when CALL_RESULT = '1' then 1 else 0 end) inboundNum  " +
            "FROM TF_YWPN_PFRECORD_W " +
            "${ew.customSqlSegment} )t1 " )
    HotlineInboundLossStatisticalVo getHotlineTrafficFlowStatistical(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);
    @Select("SELECT nvl(t2.totalOut,0) totalOut,nvl(t2.OutNum,0) OutNum,nvl((t2.totalOut-t2.OutNum),0) outLossNum " +
            "FROM " +
            "(SELECT count(CALL_TYPE) totalOut ,sum(case when CALL_RESULT = '2' then 1 else 0 end) OutNum  " +
            "FROM TF_YWPN_PFRECORD_W " +
            "${ew.customSqlSegment} )t2")
    HotlineOutLossStatisticalVo getHotlineOutLossStatistical(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);
    @Select("SELECT count(RETURN_RESLUT) totalReturn,  " +
            "nvl(sum(case when RETURN_RESLUT = '3' then 1 else 0 end),0) greatSatisfactionNum, " +
            "nvl(sum(case when RETURN_RESLUT = '2' then 1 else 0 end),0) satisfactionNum,  " +
            "nvl(sum(case when RETURN_RESLUT = '1' then 1 else 0 end),0) generalNum, " +
            "nvl(sum(case when RETURN_RESLUT = '0' then 1 else 0 end),0) dissatisfactionNum FROM " +
            "TF_YWPN_GDRETURN_W " +
            "${ew.customSqlSegment}")
    HotlineSatisfactionStatisticalVo getHotlineSatisfactionStatistical(@Param(Constants.WRAPPER) QueryWrapper<MeterReadingNumberDto> queryWrapper);

    @Select("SELECT nvl(t1.totalCumulative,0) totalCumulative,nvl(t2.totalBudget,0) totalBudget " +
            "FROM " +
            "(SELECT sum(GSL_TOTAL) totalCumulative FROM " +
            "TF_YWPN_COSTRLWATER_W " +
            "WHERE " +
            "to_char(UP_DATE,'yyyy') = #{year} " +
            ")t1, " +
            "(SELECT sum(GSL_TOTAL) totalBudget FROM " +
            "TF_YWPN_COSTBGWATER_W " +
            "WHERE " +
            "SUBSTR(month, 1, 4) = #{year} " +
            ")t2")
    ProductionMarketingPoorStatisticalVo getProductionMarketingPoorStatistical(@Param("year")String year);

    @Select("SELECT t1.dateTime,nvl(t1.totalBudget,0) totalBudget,nvl(t2.totalCumulative,0) totalCumulative " +
            "FROM " +
            "(SELECT MONTH dateTime,sum(GSL_TOTAL) totalBudget  " +
            "FROM " +
            "TF_YWPN_COSTBGWATER_W  " +
            "where SUBSTR(month, 1, 4) = #{year} " +
            "GROUP BY MONTH " +
            ")t1  " +
            "LEFT JOIN  " +
            "(SELECT to_char(UP_DATE,'yyyy-mm') dateTime,sum(GSL_TOTAL) totalCumulative  " +
            "FROM " +
            "TF_YWPN_COSTRLWATER_W  " +
            "GROUP BY to_char(UP_DATE,'yyyy-mm') " +
            ") t2   " +
            "ON t1.dateTime = t2.dateTime " +
            "ORDER BY t1.dateTime")
    List<ProductionMarketingPoorMonthVo> getProductionMarketingPoorMonth(@Param("year")String year);

    @Select("SELECT nvl(t2.totalCumulative,0) totalCumulative,nvl(t1.totalBudget,0) totalBudget " +
            "FROM " +
            "(SELECT t.cumulativeValue-(t.salesValue+t.notDiskValue) totalBudget " +
            "FROM " +
            "(select decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) cumulativeValue , " +
            "decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL)) salesValue, " +
            "decode(sum(WSPSL), null, 0, sum(WSPSL)) notDiskValue                     " +
            "from TF_YWPN_COSTBGWATER_W " +
            "where SUBSTR(month, 1, 4) = #{year} ) t)t1, " +
            "(SELECT t.cumulativeValue-(t.salesValue+t.notDiskValue) totalCumulative " +
            "FROM " +
            "(select decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) cumulativeValue , " +
            "decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL)) salesValue, " +
            "decode(sum(WSPSL), null, 0, sum(WSPSL)) notDiskValue " +
            "from TF_YWPN_COSTRLWATER_W " +
            "where to_char(UP_DATE,'yyyy') = #{year} )t)t2")
    LeakageStatisticalVo getLeakageStatistical(@Param("year") String year);

    @Select("SELECT n.dateTime,nvl(n.totalBudget,0) totalBudget,nvl(m.totalCumulative,0) totalCumulative " +
            "FROM  " +
            "(SELECT t1.dateTime,t1.totalBudget " +
            "FROM " +
            "(SELECT t.dateTime,t.cumulativeValue-(t.salesValue+t.notDiskValue) totalBudget " +
            "FROM " +
            "(select MONTH dateTime,decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) cumulativeValue , " +
            "decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL)) salesValue, " +
            "decode(sum(WSPSL), null, 0, sum(WSPSL)) notDiskValue     " +
            "from TF_YWPN_COSTBGWATER_W " +
            "WHERE SUBSTR(month, 1, 4) = #{year}  " +
            "GROUP BY MONTH " +
            ")t)t1)n LEFT JOIN  " +
            "(SELECT t2.dateTime,t2.totalCumulative " +
            "FROM " +
            "(SELECT t.dateTime,t.cumulativeValue-(t.salesValue+t.notDiskValue) totalCumulative " +
            "FROM " +
            "(select to_char(UP_DATE,'yyyy-mm') dateTime,decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) cumulativeValue , " +
            "decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL)) salesValue, " +
            "decode(sum(WSPSL), null, 0, sum(WSPSL)) notDiskValue     " +
            "from TF_YWPN_COSTRLWATER_W " +
            "GROUP BY to_char(UP_DATE,'yyyy-mm') " +
            ")t)t2) m " +
            "on n.dateTime = m.dateTime " +
            "ORDER BY n.dateTime")
    List<LeakageMonthVo> getLeakageMonthVo(@Param("year") String year);

    @Select("SELECT nvl(t1.expectWaterSupplyValue,0) expectWaterSupplyValue,nvl(t1.expectWaterSalesValue,0) expectWaterSalesValue,nvl(t2.cumulativeWaterSupplyValue,0) cumulativeWaterSupplyValue,nvl(t2.cumulativeWaterSalesValue,0) cumulativeWaterSalesValue " +
            "FROM " +
            "(SELECT decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) expectWaterSupplyValue,decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL))  expectWaterSalesValue FROM " +
            "TF_YWPN_COSTBGWATER_W " +
            "where SUBSTR(month, 1, 4) =  #{year} )t1, " +
            "(SELECT decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) cumulativeWaterSupplyValue,decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL))  cumulativeWaterSalesValue FROM " +
            "TF_YWPN_COSTRLWATER_W " +
            "where to_char(UP_DATE,'yyyy')= #{year} )t2")
    FeedSaleStatisticalVo getFeedSaleStatistical(@Param("year") String year);

    @Select("SELECT t1.dateTime,nvl(t1.expectWaterSupplyValue,0) expectWaterSupplyValue,nvl(t1.expectWaterSalesValue,0) expectWaterSalesValue,nvl(t2.cumulativeWaterSupplyValue,0) cumulativeWaterSupplyValue,nvl(t2.cumulativeWaterSalesValue,0) cumulativeWaterSalesValue " +
            "FROM " +
            "(SELECT month dateTime,decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) expectWaterSupplyValue,decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL))  expectWaterSalesValue FROM " +
            "TF_YWPN_COSTBGWATER_W " +
            "where SUBSTR(month, 1, 4) = #{year} " +
            "GROUP BY month " +
            ")t1 LEFT JOIN  " +
            "(SELECT to_char(UP_DATE,'yyyy-mm') dateTime,decode(sum(GSL_TOTAL), null, 0, sum(GSL_TOTAL)) cumulativeWaterSupplyValue,decode(sum(SSL_TOTAL), null, 0, sum(SSL_TOTAL))  cumulativeWaterSalesValue FROM " +
            "TF_YWPN_COSTRLWATER_W " +
            "GROUP BY to_char(UP_DATE,'yyyy-mm') " +
            ")t2  " +
            "ON t1.dateTime = t2.dateTime " +
            "ORDER BY t1.dateTime")
    List<FeedSaleMonthVo> getFeedSaleMonth(@Param("year") String year);

    @Select("SELECT nvl(t1.totalCumulative,0) totalCumulative,nvl(t2.totalBudget,0) totalBudget " +
            "FROM " +
            "(SELECT nvl(sum(DWCB_TOTAL),0) totalCumulative " +
            "FROM " +
            "TF_YWPN_COSTRLFIXED_W " +
            "where to_char(UP_DATE,'yyyy')= #{year})t1, " +
            "(SELECT nvl(sum(DWCB_TOTAL),0) totalBudget " +
            "FROM " +
            "TF_YWPN_COSTBGFIXED_W " +
            "where SUBSTR(MOUTH, 1, 4) = #{year} )t2")
    UnitVariableCostStatisticalVo getUnitVariableCostStatistical(@Param("year") String year);

    @Select("SELECT t1.dateTime,nvl(t1.totalBudget,0) totalBudget,nvl(t2.totalCumulative,0) totalCumulative " +
            "FROM  " +
            "(SELECT MOUTH dateTime,sum(DWCB_TOTAL) totalBudget " +
            "FROM " +
            "TF_YWPN_COSTBGFIXED_W " +
            "where SUBSTR(MOUTH, 1, 4) = #{year} " +
            "GROUP BY MOUTH " +
            ")t1  " +
            "LEFT JOIN " +
            "(SELECT to_char(UP_DATE,'yyyy-mm') dateTime,sum(DWCB_TOTAL) totalCumulative " +
            "FROM " +
            "TF_YWPN_COSTRLFIXED_W " +
            "GROUP BY to_char(UP_DATE,'yyyy-mm') " +
            ")t2 " +
            "ON t1.dateTime = t2.dateTime " +
            "ORDER BY t1.dateTime")
    List<UnitVariableCostMonthVo> getUnitVariableCostMonth(@Param("year") String year);

    @Select("SELECT to_char(UP_DATE,'yyyy-mm') dateTime,decode(sum(GSL_ONE), null, 0, sum(GSL_ONE)) waterSupplyValue, " +
            "decode(sum(ZYSL_ONE), null, 0, sum(ZYSL_ONE)) waterIntakingValue FROM " +
            "TF_YWPN_COSTRLWATER_W " +
            "where to_char(UP_DATE,'yyyy')= #{year} " +
            "GROUP BY to_char(UP_DATE,'yyyy-mm') " +
            "ORDER BY dateTime")
    List<OneFactoryTakingWaterSupplyStatisticalVo> getOneFactoryTakingWaterSupplyStatistical(@Param("year") String year);

    @Select("SELECT to_char(UP_DATE,'yyyy-mm') dateTime,decode(sum(GSL_TWO), null, 0, sum(GSL_TWO)) waterSupplyValue, " +
            "decode(sum(ZYSL_TWO), null, 0, sum(ZYSL_TWO))  waterIntakingValue FROM " +
            "TF_YWPN_COSTRLWATER_W " +
            "where to_char(UP_DATE,'yyyy')= #{year} " +
            "GROUP BY to_char(UP_DATE,'yyyy-mm') " +
            "ORDER BY dateTime")
    List<TwoFactoryTakingWaterSupplyStatisticalVo> getTwoFactoryTakingWaterSupplyStatistical(@Param("year") String year);

    @Select("select  create_time dateTime,nvl(itval,0) waterSupplyValue " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '净水厂\\yn.PV' " +
            "and create_time between #{startTime} and #{endTime} " +
            "order by create_time")
    List<OneFactoryWaterQualityYLStatisticalVo> getOneFactoryWaterQualityYLStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("SELECT t1.create_time dateTime,nvl(t1.itval,0) zd1,nvl(t2.itval,0) zd2,nvl(t3.itval,0) zd3  " +
            "FROM " +
            "(select  create_time,itval " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水一厂\\沉淀池\\1_8_ZD.PV' " +
            "and create_time between #{startTime} and #{endTime}  " +
            "       )t1  " +
            "LEFT JOIN  " +
            "(select  create_time,itval " +
            "        from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水一厂\\沉淀池\\9_12_ZD.PV' " +
            ")t2 " +
            "on t1.create_time = t2.create_time   " +
            "LEFT JOIN  " +
            "(select  create_time,itval " +
            "        from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水一厂\\沉淀池\\13_16_ZD.PV' " +
            " )t3 " +
            "on t1.create_time = t3.create_time " +
            "ORDER BY t1.create_time")
    List<OneFactoryWaterQualityZDStatisticalVo> getOneFactoryWaterQualityZDStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("select create_time dateTime, nvl(itval,0) waterSupplyValue " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水二厂\\CP1\\CL101_Out_VAL.PV' " +
            "and create_time between #{startTime} and #{endTime}  " +
            "order by create_time")
    List<TwoFactoryWaterQualityYLStatisticalVo> getTwoFactoryWaterQualityYLStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("select create_time dateTime, nvl(itval,0) zd " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水二厂\\CP1\\TU101_Out_VAL.PV' " +
            "and create_time between #{startTime} and #{endTime} " +
            "order by create_time ")
    List<TwoFactoryWaterQualityZDStatisticalVo> getTwoFactoryWaterQualityZDStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("select create_time dateTime,nvl(itval,0) sy " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '净水厂\\ssyl.PV' " +
            "and create_time between #{startTime} and #{endTime} " +
            "order by create_time ")
    List<OneFactoryWaterPressureStatisticalVo> getOneFactoryWaterPressureStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("SELECT t1.create_time dateTime,nvl(t1.itval,0) sy1,nvl(t2.itval,0) sy2 " +
            "FROM " +
            "(select create_time, itval " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水二厂\\CP1\\P101_Out_VAL.PV' " +
            "and create_time between #{startTime} and #{endTime} " +
            "        )t1 " +
            "LEFT JOIN " +
            "(select create_time, itval " +
            "        from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水二厂\\CP1\\P102_Out_VAL.PV' " +
            "        )t2 " +
            "ON t1.create_time = t2.create_time " +
            "order by t1.create_time")
    List<TwoFactoryWaterPressureStatisticalVo> getTwoFactoryWaterPressureStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("SELECT nvl(a.pac,0) pac,nvl(a.sydh,0) sydh,nvl(a.dh,0) dh,nvl(b.waterSupplyValue,0) waterSupplyValue,nvl(b.waterIntakingValue,0) waterIntakingValue,nvl(d.yl,0) yl,nvl(e.zd1,0) zd1,nvl(e.zd2,0) zd2,nvl(e.zd3,0) zd3 " +
            "FROM " +
            "(SELECT nvl(sum(PACDH_ONE),0) pac,nvl(sum(SYDH_ONE),0) sydh, nvl(sum(DH_ONE),0) dh " +
            "FROM " +
            "TF_YWPN_COSTRLUNIT_W " +
            "where UP_DATE between #{startTime} and #{endTime}  " +
            ")a, " +
            "(SELECT decode(sum(GSL_ONE), null, 0, sum(GSL_ONE)) waterSupplyValue, " +
            "decode(sum(ZYSL_ONE), null, 0, sum(ZYSL_ONE))  waterIntakingValue FROM " +
            "TF_YWPN_COSTRLWATER_W " +
            "where UP_DATE between #{startTime} and #{endTime} )b, " +
            "(select  itval yl " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '净水厂\\yn.PV' " +
            "and rownum<=1 " +
            "order by create_time DESC)d, " +
            "(SELECT t1.create_time,t1.itval zd1,t2.itval zd2,t3.itval zd3  " +
            "FROM " +
            "(select  create_time,itval " +
            "        from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水一厂\\沉淀池\\1_8_ZD.PV' " +
            "       )t1  " +
            "LEFT JOIN  " +
            "(select  create_time,itval " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水一厂\\沉淀池\\9_12_ZD.PV' " +
            ")t2 " +
            "on t1.create_time = t2.create_time   " +
            "LEFT JOIN  " +
            "(select  create_time,itval " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水一厂\\沉淀池\\13_16_ZD.PV' " +
            " )t3 " +
            "on t1.create_time = t3.create_time " +
            "WHERE rownum <=1 " +
            "ORDER BY t1.create_time DESC)e")
    OneFactoryKeyIndexStatisticalVo getOneFactoryKeyIndexStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("select nvl(itval,0) itval " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '净水厂\\ssyl.PV' " +
            "and rownum<=1 " +
            "order by create_time DESC")
    BigDecimal getOneFactoryCCSY();

    @Select("SELECT nvl(a.pac,0) pac,nvl(a.yldh,0) yldh,nvl(a.dh,0) dh,nvl(b.waterSupplyValue,0) waterSupplyValue,nvl(b.waterIntakingValue,0) waterIntakingValue,nvl(d.yl,0) yl,nvl(e.zd,0) zd " +
            "FROM " +
            "(SELECT sum(PACDH_TWO) pac,sum(YLDH_TWO) yldh, sum(DH_TWO) dh " +
            "FROM " +
            "TF_YWPN_COSTRLUNIT_W " +
            "where UP_DATE between #{startTime} and #{endTime}  " +
            ")a, " +
            "(SELECT decode(sum(GSL_TWO), null, 0, sum(GSL_TWO)) waterSupplyValue, " +
            "decode(sum(ZYSL_TWO), null, 0, sum(ZYSL_TWO))  waterIntakingValue FROM " +
            "TF_YWPN_COSTRLWATER_W " +
            "where UP_DATE between #{startTime} and #{endTime}  )b, " +
            "(select  itval yl " +
            "from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水二厂\\CP1\\CL101_Out_VAL.PV' " +
            "and rownum<=1 " +
            "order by create_time DESC)d, " +
            "(SELECT itval zd " +
            "FROM " +
            "TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水一厂\\沉淀池\\1_8_ZD.PV' " +
            "and rownum <=1 " +
            "ORDER BY create_time DESC)e ")
    TwoFactoryKeyIndexStatisticalVo getTwoFactoryKeyIndexStatistical(@Param("startTime")Date startTime,@Param("endTime") Date endTime);

    @Select("SELECT nvl(t1.sy1,0) syq,nvl(t2.sy2,0) sy2 " +
            "FROM " +
            "(select itval sy1 " +
            "   from TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水二厂\\CP1\\P101_Out_VAL.PV' " +
            "and rownum<=1 " +
            "order by create_time DESC)t1, " +
            "(SELECT itval sy2 " +
            "FROM TF_YWPN_ITEMRATO_W_VIEW " +
            "WHERE itcd = '自来水二厂\\CP1\\P102_Out_VAL.PV' " +
            "and rownum<=1 " +
            "order by create_time DESC)t2")
    TwoFactoryKeyIndexStatisticalVo getTwoFactoryCCSY();

    @Select("SELECT " +
            " q2.favorableRate, " +
            " q2.individualRanking " +
            "FROM " +
            " ( " +
            "  SELECT " +
            "   n.favorableRate, " +
            "   n.individualRanking " +
            "  FROM " +
            "   ( " +
            "    SELECT " +
            "     M .PF_ZXRY, " +
            "     M .favorableRate, " +
            "     RANK () OVER (ORDER BY M .favorableRate DESC) individualRanking " +
            "    FROM " +
            "     ( " +
            "      SELECT " +
            "       T .PF_ZXRY, " +
            "       DECODE ( " +
            "        T .num, " +
            "        0, " +
            "        0, " +
            "        ROUND ( " +
            "         ((T .my1 + T .my2) / T .num) * 100, " +
            "         2 " +
            "        ) " +
            "       ) favorableRate " +
            "      FROM " +
            "       ( " +
            "        SELECT " +
            "         PF_ZXRY, " +
            "         SUM ( " +
            "          CASE " +
            "          WHEN QUALITY_RESLUT = '2' THEN " +
            "           1 " +
            "          ELSE " +
            "           0 " +
            "          END " +
            "         ) my1, " +
            "         SUM ( " +
            "          CASE " +
            "          WHEN QUALITY_RESLUT = '3' THEN " +
            "           1 " +
            "          ELSE " +
            "           0 " +
            "          END " +
            "         ) my2, " +
            "         COUNT (1) num " +
            "        FROM " +
            "         TF_YWPN_PFRECORD_W " +
            "        WHERE " +
            "         CALL_RESULT = '1' and CONNECT_TIME between #{startTime} and #{endTime} " +
            "        GROUP BY " +
            "         PF_ZXRY " +
            "       ) T " +
            "     ) M " +
            "   ) n " +
            "  WHERE " +
            "   n.PF_ZXRY = #{userName}" +
            " ) q2 where rownum = 1")
    IndividualRankingVo getIndividualRankingOne(@Param("startTime")Date startTime,@Param("endTime") Date endTime,@Param("userName") String userName);
    @Select("SELECT " +
            " q1.inboundNumber, " +
            " q1.callSeveral " +
            "FROM " + "( " +
            "  SELECT " +
            "   SUM ( " +
            "    CASE " +
            "    WHEN CALL_TYPE = '1' THEN " +
            "     1 " +
            "    ELSE " +
            "     0 " +
            "    END " +
            "   ) inboundNumber, " +
            "   SUM ( " +
            "    CASE " +
            "    WHEN CALL_TYPE = '2' THEN " +
            "     1 " +
            "    ELSE " +
            "     0 " +
            "    END " +
            "   ) callSeveral " +
            "  FROM " +
            "   TF_YWPN_PFRECORD_W " +
            "  WHERE " +
            "   PF_ZXRY = #{userName} " +
            "   and CONNECT_TIME between #{startTime} and #{endTime} " +
            " ) q1 where rownum = 1")
    IndividualRankingVo getIndividualRankingTwo(@Param("startTime")Date startTime,@Param("endTime") Date endTime,@Param("userName") String userName);
    @Select("SELECT " +
            " q3.sendSingular, " +
            " q3.numberVisit " +
            " FROM " +
            "( " +
            "  SELECT " +
            "   COUNT (1) sendSingular, " +
            "   SUM (GDHF_CS) numberVisit " +
            "  FROM " +
            "   TF_YWPN_GDINFO_W " +
            "  WHERE " +
            "   IS_RXLX = '1' " +
            "  AND DJRY = #{userId} " +
            "  and DJSJ between #{startTime} and #{endTime}" +
            "  GROUP BY " +
            "   GDLX " +
            " ) q3 where rownum = 1")
    IndividualRankingVo getIndividualRankingThree(@Param("startTime")Date startTime,@Param("endTime") Date endTime,@Param("userId") Long userId);

    @Select("select " +
            "sum(case when INSTALLDATE is null then pipelength else 0 end) as type5, " +
            "sum(case when to_date(INSTALLDATE,'yyyy-MM-dd') between add_months(sysdate,-1200) and add_months(sysdate,-180) then pipelength else 0 end) type4, " +
            "sum(case when to_date(INSTALLDATE,'yyyy-MM-dd') between add_months(sysdate,-180) and add_months(sysdate,-120) then pipelength else 0 end) type3, " +
            "sum(case when to_date(INSTALLDATE,'yyyy-MM-dd') between add_months(sysdate,-120) and add_months(sysdate,-60) then pipelength else 0 end) type2, " +
            "sum(case when to_date(INSTALLDATE,'yyyy-MM-dd') between add_months(sysdate,-60) and add_months(sysdate,0) then pipelength else 0 end) type1 " +
            "from njsw_sde.tf_jsjs_pipe_b t " +
            "where t.enabled=1")
    Map<String,Object> getPipeReport();

}
