McBasicCmtyMapper.xml 32.7 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
<?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.chinagas.modules.schsf.mapper.McBasicCmtyMapper">

    <resultMap type="com.chinagas.modules.schsf.domain.McBasicCmty" id="McBasicCmtyResult">
        <result property="id"    column="id"    />
        <result property="fiscalYear"    column="fiscal_year"    />
        <result property="regionName"    column="region_name"    />
        <result property="groupName"    column="group_name"    />
        <result property="companyName"    column="company_name"    />
        <result property="companyCode"    column="company_code"    />
        <result property="province"    column="province"    />
        <result property="city"    column="city"    />
        <result property="district"    column="district"    />
        <result property="street"    column="street"    />
        <result property="vlgOrCmty"    column="vlg_or_cmty"    />
        <result property="respPerson"    column="resp_person"    />
        <result property="urbRurCls"    column="urb_rur_cls"    />
        <result property="projectTypeName"    column="project_type_name"    />
        <result property="commHh"    column="comm_hh"    />
        <result property="acctFyStartConf"    column="acct_fy_start_conf"    />
        <result property="acctPrevRecov"    column="acct_prev_recov"    />
        <result property="acctPrevCharged"    column="acct_prev_charged"    />
        <result property="currFyNewRecovered"    column="curr_fy_new_recovered"    />
        <result property="totalCharged"    column="total_charged"    />
        <result property="qtrTargetCompany"    column="qtr_target_company"    />
        <result property="hhGsgCharged"    column="hh_gsg_charged"    />
        <result property="hhGsgUncharged"    column="hh_gsg_uncharged"    />
        <result property="hhGsgTotal"    column="hh_gsg_total"    />
        <result property="hhNewFull"    column="hh_new_full"    />
        <result property="hhNewInstall"    column="hh_new_install"    />
        <result property="hhPrevFull"    column="hh_prev_full"    />
        <result property="hhPrevInstDp"    column="hh_prev_inst_dp"    />
        <result property="hhUnchg"    column="hh_unchg"    />
        <result property="hhUnchgConf"    column="hh_unchg_conf"    />
        <result property="hhUnchgScan"    column="hh_unchg_scan"    />
        <result property="hhEvCumPaid"    column="hh_ev_cum_paid"    />
        <result property="hhEvInst"    column="hh_ev_inst"    />
        <result property="hhEvFull"    column="hh_ev_full"    />
        <result property="hhEvIgnite"    column="hh_ev_ignite"    />
        <result property="hhEvCumSetup"    column="hh_ev_cum_setup"    />
        <result property="hhEvCumGas"    column="hh_ev_cum_gas"    />
        <result property="remark"    column="remark"    />
        <result property="createTime"    column="create_time"    />
        <result property="createBy"    column="create_by"    />
        <result property="updateTime"    column="update_time"    />
        <result property="updateBy"    column="update_by"    />
        <result property="defFlag"    column="def_flag"    />
    </resultMap>

    <sql id="selectMcBasicCmtyVo">
        select m.id, m.fiscal_year, m.region_name, m.group_name, m.company_name, m.company_code, m.province, m.city, m.district, m.street, m.vlg_or_cmty, m.resp_person, m.urb_rur_cls, m.project_type_name, m.comm_hh, m.acct_fy_start_conf, m.acct_prev_recov, m.acct_prev_charged, m.curr_fy_new_recovered, m.total_charged, m.qtr_target_company, m.hh_gsg_charged, m.hh_gsg_uncharged, m.hh_gsg_total, m.hh_new_full, m.hh_new_install, m.hh_prev_full, m.hh_prev_inst_dp, m.hh_unchg, m.hh_unchg_conf,
               m.hh_unchg_scan, m.hh_ev_cum_paid, m.hh_ev_inst, m.hh_ev_full, m.hh_ev_ignite, m.hh_ev_cum_setup, m.hh_ev_cum_gas, m.remark, m.create_time, m.create_by, m.update_time, m.update_by, m.def_flag
        FROM mc_basic_cmty m
        left join sys_user u on u.user_id = m.create_by
        left join sys_dept d on d.dept_id = m.company_code
    </sql>

    <select id="selectMcBasicCmtyList" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo" resultMap="McBasicCmtyResult">
        <include refid="selectMcBasicCmtyVo"/>
        where 1=1
            <if test="fiscalYear != null "> and fiscal_year = #{fiscalYear}</if>
            <if test="regionName != null  and regionName != ''"> and region_name like concat('%', #{regionName}, '%')</if>
            <if test="groupName != null  and groupName != ''"> and group_name like concat('%', #{groupName}, '%')</if>
            <if test="companyName != null  and companyName != ''"> and company_name like concat('%', #{companyName}, '%')</if>
            <if test="companyCode != null  and companyCode != ''"> and company_code = #{companyCode}</if>
            <if test="province != null  and province != ''"> and province = #{province}</if>
            <if test="city != null  and city != ''"> and city = #{city}</if>
            <if test="district != null  and district != ''"> and district = #{district}</if>
            <if test="street != null  and street != ''"> and street = #{street}</if>
            <if test="vlgOrCmty != null  and vlgOrCmty != ''"> and vlg_or_cmty = #{vlgOrCmty}</if>
            <if test="respPerson != null  and respPerson != ''"> and resp_person = #{respPerson}</if>
            <if test="urbRurCls != null  and urbRurCls != ''"> and urb_rur_cls = #{urbRurCls}</if>
            <if test="projectTypeName != null  and projectTypeName != ''"> and project_type_name like concat('%', #{projectTypeName}, '%')</if>
            <if test="commHh != null "> and comm_hh = #{commHh}</if>
            <if test="acctFyStartConf != null "> and acct_fy_start_conf = #{acctFyStartConf}</if>
            <if test="acctPrevRecov != null "> and acct_prev_recov = #{acctPrevRecov}</if>
            <if test="acctPrevCharged != null "> and acct_prev_charged = #{acctPrevCharged}</if>
            <if test="currFyNewRecovered != null "> and curr_fy_new_recovered = #{currFyNewRecovered}</if>
            <if test="totalCharged != null "> and total_charged = #{totalCharged}</if>
            <if test="qtrTargetCompany != null "> and qtr_target_company = #{qtrTargetCompany}</if>
            <if test="hhGsgCharged != null "> and hh_gsg_charged = #{hhGsgCharged}</if>
            <if test="hhGsgUncharged != null "> and hh_gsg_uncharged = #{hhGsgUncharged}</if>
            <if test="hhGsgTotal != null "> and hh_gsg_total = #{hhGsgTotal}</if>
            <if test="hhNewFull != null "> and hh_new_full = #{hhNewFull}</if>
            <if test="hhNewInstall != null "> and hh_new_install = #{hhNewInstall}</if>
            <if test="hhPrevFull != null "> and hh_prev_full = #{hhPrevFull}</if>
            <if test="hhPrevInstDp != null "> and hh_prev_inst_dp = #{hhPrevInstDp}</if>
            <if test="hhUnchg != null "> and hh_unchg = #{hhUnchg}</if>
            <if test="hhUnchgConf != null "> and hh_unchg_conf = #{hhUnchgConf}</if>
            <if test="hhUnchgScan != null "> and hh_unchg_scan = #{hhUnchgScan}</if>
            <if test="hhEvCumPaid != null "> and hh_ev_cum_paid = #{hhEvCumPaid}</if>
            <if test="hhEvInst != null "> and hh_ev_inst = #{hhEvInst}</if>
            <if test="hhEvFull != null "> and hh_ev_full = #{hhEvFull}</if>
            <if test="hhEvIgnite != null "> and hh_ev_ignite = #{hhEvIgnite}</if>
            <if test="hhEvCumSetup != null "> and hh_ev_cum_setup = #{hhEvCumSetup}</if>
            <if test="hhEvCumGas != null "> and hh_ev_cum_gas = #{hhEvCumGas}</if>
            <if test="defFlag != null  and defFlag != ''"> and m.def_flag = #{defFlag}</if>
            <if test="startFiscalYear != null  and startFiscalYear != ''"> and m.fiscal_year &gt;= #{startFiscalYear}</if>
            <if test="finishFiscalYear != null  and finishFiscalYear != ''"> and m.fiscal_year &lt;= #{finishFiscalYear}</if>
            <!-- 数据范围过滤 -->
            ${params.dataScope}
        order by m.update_time desc
    </select>

    <select id="selectMcBasicCmtyById" parameterType="Long" resultMap="McBasicCmtyResult">
        <include refid="selectMcBasicCmtyVo"/>
        where id = #{id}
    </select>

    <insert id="insertMcBasicCmty" parameterType="com.chinagas.modules.schsf.domain.McBasicCmty"    useGeneratedKeys="true" keyProperty="id">
        insert into mc_basic_cmty
        <trim prefix="(" suffix=")" suffixOverrides=",">
            <if test="id != null">id,</if>
            <if test="fiscalYear != null">fiscal_year,</if>
            <if test="regionName != null and regionName != ''">region_name,</if>
            <if test="groupName != null and groupName != ''">group_name,</if>
            <if test="companyName != null and companyName != ''">company_name,</if>
            <if test="companyCode != null and companyCode != ''">company_code,</if>
            <if test="province != null">province,</if>
            <if test="city != null">city,</if>
            <if test="district != null">district,</if>
            <if test="street != null">street,</if>
            <if test="vlgOrCmty != null">vlg_or_cmty,</if>
            <if test="respPerson != null">resp_person,</if>
            <if test="urbRurCls != null">urb_rur_cls,</if>
            <if test="projectTypeName != null">project_type_name,</if>
            <if test="commHh != null">comm_hh,</if>
            <if test="acctFyStartConf != null">acct_fy_start_conf,</if>
            <if test="acctPrevRecov != null">acct_prev_recov,</if>
            <if test="acctPrevCharged != null">acct_prev_charged,</if>
            <if test="currFyNewRecovered != null">curr_fy_new_recovered,</if>
            <if test="totalCharged != null">total_charged,</if>
            <if test="qtrTargetCompany != null">qtr_target_company,</if>
            <if test="hhGsgCharged != null">hh_gsg_charged,</if>
            <if test="hhGsgUncharged != null">hh_gsg_uncharged,</if>
            <if test="hhGsgTotal != null">hh_gsg_total,</if>
            <if test="hhNewFull != null">hh_new_full,</if>
            <if test="hhNewInstall != null">hh_new_install,</if>
            <if test="hhPrevFull != null">hh_prev_full,</if>
            <if test="hhPrevInstDp != null">hh_prev_inst_dp,</if>
            <if test="hhUnchg != null">hh_unchg,</if>
            <if test="hhUnchgConf != null">hh_unchg_conf,</if>
            <if test="hhUnchgScan != null">hh_unchg_scan,</if>
            <if test="hhEvCumPaid != null">hh_ev_cum_paid,</if>
            <if test="hhEvInst != null">hh_ev_inst,</if>
            <if test="hhEvFull != null">hh_ev_full,</if>
            <if test="hhEvIgnite != null">hh_ev_ignite,</if>
            <if test="hhEvCumSetup != null">hh_ev_cum_setup,</if>
            <if test="hhEvCumGas != null">hh_ev_cum_gas,</if>
            <if test="remark != null">remark,</if>
            <if test="createTime != null">create_time,</if>
            <if test="createBy != null and createBy != ''">create_by,</if>
            <if test="updateTime != null">update_time,</if>
            <if test="updateBy != null and updateBy != ''">update_by,</if>
            <if test="defFlag != null and defFlag != ''">def_flag,</if>
         </trim>
        <trim prefix="values (" suffix=")" suffixOverrides=",">
            <if test="id != null">#{id},</if>
            <if test="fiscalYear != null">#{fiscalYear},</if>
            <if test="regionName != null and regionName != ''">#{regionName},</if>
            <if test="groupName != null and groupName != ''">#{groupName},</if>
            <if test="companyName != null and companyName != ''">#{companyName},</if>
            <if test="companyCode != null and companyCode != ''">#{companyCode},</if>
            <if test="province != null">#{province},</if>
            <if test="city != null">#{city},</if>
            <if test="district != null">#{district},</if>
            <if test="street != null">#{street},</if>
            <if test="vlgOrCmty != null">#{vlgOrCmty},</if>
            <if test="respPerson != null">#{respPerson},</if>
            <if test="urbRurCls != null">#{urbRurCls},</if>
            <if test="projectTypeName != null">#{projectTypeName},</if>
            <if test="commHh != null">#{commHh},</if>
            <if test="acctFyStartConf != null">#{acctFyStartConf},</if>
            <if test="acctPrevRecov != null">#{acctPrevRecov},</if>
            <if test="acctPrevCharged != null">#{acctPrevCharged},</if>
            <if test="currFyNewRecovered != null">#{currFyNewRecovered},</if>
            <if test="totalCharged != null">#{totalCharged},</if>
            <if test="qtrTargetCompany != null">#{qtrTargetCompany},</if>
            <if test="hhGsgCharged != null">#{hhGsgCharged},</if>
            <if test="hhGsgUncharged != null">#{hhGsgUncharged},</if>
            <if test="hhGsgTotal != null">#{hhGsgTotal},</if>
            <if test="hhNewFull != null">#{hhNewFull},</if>
            <if test="hhNewInstall != null">#{hhNewInstall},</if>
            <if test="hhPrevFull != null">#{hhPrevFull},</if>
            <if test="hhPrevInstDp != null">#{hhPrevInstDp},</if>
            <if test="hhUnchg != null">#{hhUnchg},</if>
            <if test="hhUnchgConf != null">#{hhUnchgConf},</if>
            <if test="hhUnchgScan != null">#{hhUnchgScan},</if>
            <if test="hhEvCumPaid != null">#{hhEvCumPaid},</if>
            <if test="hhEvInst != null">#{hhEvInst},</if>
            <if test="hhEvFull != null">#{hhEvFull},</if>
            <if test="hhEvIgnite != null">#{hhEvIgnite},</if>
            <if test="hhEvCumSetup != null">#{hhEvCumSetup},</if>
            <if test="hhEvCumGas != null">#{hhEvCumGas},</if>
            <if test="remark != null">#{remark},</if>
            <if test="createTime != null">#{createTime},</if>
            <if test="createBy != null and createBy != ''">#{createBy},</if>
            <if test="updateTime != null">#{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">#{updateBy},</if>
            <if test="defFlag != null and defFlag != ''">#{defFlag},</if>
         </trim>
    </insert>

    <update id="updateMcBasicCmty" parameterType="com.chinagas.modules.schsf.domain.McBasicCmty">
        update mc_basic_cmty
        <trim prefix="SET" suffixOverrides=",">
            <if test="fiscalYear != null">fiscal_year = #{fiscalYear},</if>
            <if test="regionName != null and regionName != ''">region_name = #{regionName},</if>
            <if test="groupName != null and groupName != ''">group_name = #{groupName},</if>
            <if test="companyName != null and companyName != ''">company_name = #{companyName},</if>
            <if test="companyCode != null and companyCode != ''">company_code = #{companyCode},</if>
            <if test="province != null">province = #{province},</if>
            <if test="city != null">city = #{city},</if>
            <if test="district != null">district = #{district},</if>
            <if test="street != null">street = #{street},</if>
            <if test="vlgOrCmty != null">vlg_or_cmty = #{vlgOrCmty},</if>
            <if test="respPerson != null">resp_person = #{respPerson},</if>
            <if test="urbRurCls != null">urb_rur_cls = #{urbRurCls},</if>
            <if test="projectTypeName != null">project_type_name = #{projectTypeName},</if>
            <if test="commHh != null">comm_hh = #{commHh},</if>
            <if test="acctFyStartConf != null">acct_fy_start_conf = #{acctFyStartConf},</if>
            <if test="acctPrevRecov != null">acct_prev_recov = #{acctPrevRecov},</if>
            <if test="acctPrevCharged != null">acct_prev_charged = #{acctPrevCharged},</if>
            <if test="currFyNewRecovered != null">curr_fy_new_recovered = #{currFyNewRecovered},</if>
            <if test="totalCharged != null">total_charged = #{totalCharged},</if>
            <if test="qtrTargetCompany != null">qtr_target_company = #{qtrTargetCompany},</if>
            <if test="hhGsgCharged != null">hh_gsg_charged = #{hhGsgCharged},</if>
            <if test="hhGsgUncharged != null">hh_gsg_uncharged = #{hhGsgUncharged},</if>
            <if test="hhGsgTotal != null">hh_gsg_total = #{hhGsgTotal},</if>
            <if test="hhNewFull != null">hh_new_full = #{hhNewFull},</if>
            <if test="hhNewInstall != null">hh_new_install = #{hhNewInstall},</if>
            <if test="hhPrevFull != null">hh_prev_full = #{hhPrevFull},</if>
            <if test="hhPrevInstDp != null">hh_prev_inst_dp = #{hhPrevInstDp},</if>
            <if test="hhUnchg != null">hh_unchg = #{hhUnchg},</if>
            <if test="hhUnchgConf != null">hh_unchg_conf = #{hhUnchgConf},</if>
            <if test="hhUnchgScan != null">hh_unchg_scan = #{hhUnchgScan},</if>
            <if test="hhEvCumPaid != null">hh_ev_cum_paid = #{hhEvCumPaid},</if>
            <if test="hhEvInst != null">hh_ev_inst = #{hhEvInst},</if>
            <if test="hhEvFull != null">hh_ev_full = #{hhEvFull},</if>
            <if test="hhEvIgnite != null">hh_ev_ignite = #{hhEvIgnite},</if>
            <if test="hhEvCumSetup != null">hh_ev_cum_setup = #{hhEvCumSetup},</if>
            <if test="hhEvCumGas != null">hh_ev_cum_gas = #{hhEvCumGas},</if>
            <if test="remark != null">remark = #{remark},</if>
            <if test="createTime != null">create_time = #{createTime},</if>
            <if test="createBy != null and createBy != ''">create_by = #{createBy},</if>
            <if test="updateTime != null">update_time = #{updateTime},</if>
            <if test="updateBy != null and updateBy != ''">update_by = #{updateBy},</if>
            <if test="defFlag != null and defFlag != ''">def_flag = #{defFlag},</if>
        </trim>
        where id = #{id}
    </update>

    <delete id="deleteMcBasicCmtyById" parameterType="Long">
        delete from mc_basic_cmty where id = #{id}
    </delete>

    <delete id="deleteMcBasicCmtyByIds" parameterType="String">
        delete from mc_basic_cmty where id in
        <foreach item="id" collection="array" open="(" separator="," close=")">
            #{id}
        </foreach>
    </delete>

    <select id="getDistinctRegionList" resultType="com.chinagas.modules.schsf.domain.dto.CompanyDto"
            parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT t.region_name as 'value',t.region_name as 'label'
        FROM mc_basic_cmty t
        left join sys_user u on u.user_id = t.create_by
        left join sys_dept d on d.dept_id = t.company_code
        WHERE 1=1
        <if test="defFlag != null  and defFlag != ''"> and t.def_flag = #{defFlag}</if>
        <if test="fiscalYear != null "> and t.fiscal_year = #{fiscalYear}</if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="getDistinctGroupList" resultType="com.chinagas.modules.schsf.domain.dto.CompanyDto"
            parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT t.group_name as 'value',t.group_name as 'label'
        FROM mc_basic_cmty t
        left join sys_user u on u.user_id = t.create_by
        left join sys_dept d on d.dept_id = t.company_code
        WHERE 1=1
        <if test="regionName != null  and regionName != ''"> and t.region_name = #{regionName}</if>
        <if test="defFlag != null  and defFlag != ''"> and t.def_flag = #{defFlag}</if>
        <if test="fiscalYear != null "> and t.fiscal_year = #{fiscalYear}</if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}

    </select>

    <select id="getDistinctCompanyList" resultType="com.chinagas.modules.schsf.domain.McBasicCmty"
            parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT
        t.company_code as 'companyCode',
        t.company_name as 'companyName'
        FROM mc_basic_cmty t
                 left join sys_user u on u.user_id = t.create_by
                 left join sys_dept d on d.dept_id = t.company_code
        WHERE 1 = 1
        <if test="groupName != null  and groupName != ''">
            and t.group_name = #{groupName}
        </if>
        <if test="regionName != null  and regionName != ''">
            and t.region_name = #{regionName}
        </if>
        <if test="defFlag != null  and defFlag != ''">
            and t.def_flag = #{defFlag}
        </if>
        <if test="fiscalYear != null">
            and t.fiscal_year = #{fiscalYear}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectVlgOrCmtyList" resultMap="McBasicCmtyResult" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT DISTINCT t.vlg_or_cmty,t.urb_rur_cls,t.province,t.city,t.district,t.street
        FROM mc_basic_cmty t
                 left join sys_user u on u.user_id = t.create_by
                 left join sys_dept d on d.dept_id = t.company_code
        WHERE 1 = 1
        <if test="groupName != null  and groupName != ''">
            and t.group_name = #{groupName}
        </if>
        <if test="regionName != null  and regionName != ''">
            and t.region_name = #{regionName}
        </if>
        <if test="defFlag != null  and defFlag != ''">
            and t.def_flag = #{defFlag}
        </if>
        <if test="fiscalYear != null">
            and t.fiscal_year = #{fiscalYear}
        </if>
        <if test="companyName != null  and companyName != ''">
            and t.company_name = #{companyName}
        </if>
        <if test="companyCode != null  and companyCode != ''">
            and t.company_code = #{companyCode}
        </if>
        <!-- 数据范围过滤 -->
        ${params.dataScope}
    </select>

    <select id="selectMcBasicCmtyByData" resultMap="McBasicCmtyResult" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        <include refid="selectMcBasicCmtyVo"/>
        where 1=1
        and m.fiscal_year = #{fiscalYear}
        and m.region_name = #{regionName}
        and m.group_name =  #{groupName}
        and m.company_name = #{companyName}
        and m.company_code = #{companyCode}
        and m.province = #{province}
        and m.city = #{city}
        and m.district = #{district}
        and m.street = #{street}
        and m.vlg_or_cmty = #{vlgOrCmty}
    </select>

    <select id="selectVisitDeptList" resultMap="McBasicCmtyResult" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        <include refid="selectMcBasicCmtyVo"/>
        WHERE 1 = 1
          and m.group_name = #{groupName}
          and m.region_name = #{regionName}
          and m.company_name = #{companyName}
          and m.company_code = #{companyCode}
          and m.vlg_or_cmty = #{vlgOrCmty}
    </select>

    <select id="selectMcBasicCmtySummaryList" resultMap="McBasicCmtyResult" parameterType="com.chinagas.modules.schsf.domain.vo.McBasicCmtyVo">
        SELECT d.fiscal_year, d.region_name, d.group_name, d.company_name, d.company_code,
               d.province, d.city, d.district, d.street, d.vlg_or_cmty, d.resp_person, d.urb_rur_cls,
               d.project_type_name,
               d.comm_hh,d.acct_fy_start_conf,(d.hh_prev_full+ d.hh_prev_inst_dp) as acct_prev_recov,d.acct_prev_charged,
               (d.hh_new_full +	d.hh_new_install) as curr_fy_new_recovered,
               (d.hh_new_full +	d.hh_new_install+d.hh_prev_full +	d.acct_prev_charged) as total_charged,
               d.qtr_target_company,d.hh_gsg_charged,d.hh_gsg_uncharged,(IFNULL(d.hh_gsg_charged,0)+ IFNULL(d.hh_gsg_uncharged,0)) as hh_gsg_total,
               d.hh_new_full	,d.hh_new_install	,d.hh_prev_full	,d.hh_prev_inst_dp,
               (IFNULL(d.acct_fy_start_conf,0) - d.hh_prev_full	- d.hh_prev_inst_dp) as hh_unchg,
               d.hh_unchg_conf,d.hh_unchg_scan,
               (d.hh_new_full +	d.hh_new_install+d.hh_prev_full +	d.hh_prev_inst_dp) as hh_ev_cum_paid,
               (d.hh_new_install  +	d.hh_prev_inst_dp) as hh_ev_inst,
               (d.hh_new_full  +	d.hh_prev_full) as hh_ev_full,
               d.hh_ev_ignite,
               ((d.hh_new_full +	d.hh_new_install+d.hh_prev_full +	d.acct_prev_charged) / d.comm_hh) as hh_ev_cum_setup,
               ((d.hh_new_full  +	d.hh_prev_full) / d.comm_hh) as hh_ev_cum_gas
        FROM (
                select m.id,m.update_time,m.fiscal_year, m.region_name, m.group_name, m.company_name, m.company_code,
                m.province, m.city, m.district, m.street, m.vlg_or_cmty, m.resp_person, m.urb_rur_cls,
                m.project_type_name,
                (IFNULL(m.comm_hh,0) + IFNULL(hs.comm_hh,0)) AS comm_hh,
                m.acct_fy_start_conf,
                (IFNULL(m.hh_new_full,0)+ IFNULL(qkhs.hh_new_full,0)) as hh_new_full,
                (IFNULL(m.hh_new_install,0) + IFNULL(fqhs.hh_new_install,0)) as hh_new_install,
                m.hh_prev_full,m.hh_prev_inst_dp,
                (IFNULL(m.hh_ev_ignite,0) + IFNULL(dhhs.hh_ev_ignite,0)) as hh_ev_ignite,
                null as acct_prev_recov,
                m.acct_prev_charged,
                null as curr_fy_new_recovered,
                null as total_charged,
                m.qtr_target_company,
                m.hh_gsg_charged,
                m.hh_gsg_uncharged,
                null as hh_gsg_total,
                null as hh_unchg,
                m.hh_unchg_conf,
                m.hh_unchg_scan,

                null as hh_ev_cum_paid,
                null as hh_ev_inst,
                null as hh_ev_full,
                null as hh_ev_cum_setup,
                null as hh_ev_cum_gas

                FROM mc_basic_cmty m
                left join sys_user u on u.user_id = m.create_by
                left join sys_dept d on d.dept_id = m.company_code
                left join (
                        SELECT 	fiscal_year, company_code, urb_rur_cls,
                        user_province, user_city, user_district, user_street, vlg_or_cmty,
                        COUNT(DISTINCT user_name,user_phone) AS comm_hh
                        FROM
                        mc_visit
                        GROUP BY
                        fiscal_year, company_code, urb_rur_cls,
                        user_province, user_city, user_district, user_street, vlg_or_cmty
                        ) hs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
                and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
                left join (
                        SELECT 	fiscal_year, company_code, urb_rur_cls,
                        user_province, user_city, user_district, user_street, vlg_or_cmty,
                        COUNT(DISTINCT user_name,user_phone) AS hh_new_full
                        FROM mc_visit
                        WHERE 1=1
                        AND charge_type='2'
                        AND status_code NOT IN ('CANCEL')
                        GROUP BY
                        fiscal_year, company_code, urb_rur_cls,
                        user_province, user_city, user_district, user_street, vlg_or_cmty
                        ) qkhs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
                and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
                left join (
                        SELECT 	fiscal_year, company_code, urb_rur_cls,
                        user_province, user_city, user_district, user_street, vlg_or_cmty,
                        COUNT(DISTINCT user_name,user_phone) AS hh_new_install
                        FROM mc_visit
                        WHERE 1=1
                        AND charge_type in ("1","4")
                        AND status_code NOT IN ('CANCEL')
                        GROUP BY
                        fiscal_year, company_code, urb_rur_cls,
                        user_province, user_city, user_district, user_street, vlg_or_cmty
                        ) fqhs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
                and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
                left join (
                        SELECT v.fiscal_year, i.company_code, i.urb_rur_cls,i.user_province, i.user_city, i.user_district, i.user_street, i.vlg_or_cmty,COUNT(DISTINCT i.id) as hh_ev_ignite
                        FROM mc_ignition i
                        INNER JOIN mc_visit v on i.visit_id= v.id
                        WHERE i.status_code in ('MAINTENANCE_YES','MAINTENANCE_NO')
                        GROUP BY v.fiscal_year, i.company_code, i.urb_rur_cls,i.user_province, i.user_city, i.user_district, i.user_street, i.vlg_or_cmty
                        ) dhhs on hs.fiscal_year = m.fiscal_year and hs.company_code=m.company_code and hs.urb_rur_cls=m.urb_rur_cls
                and hs.user_province=m.province and hs.user_city=m.city and hs.user_district=m.district and hs.user_street=m.street and hs.vlg_or_cmty=m.vlg_or_cmty
                where 1=1
                <if test="fiscalYear != null "> and m.fiscal_year = #{fiscalYear}</if>
                <if test="regionName != null  and regionName != ''"> and m.region_name like concat('%', #{regionName}, '%')</if>
                <if test="groupName != null  and groupName != ''"> and m.group_name like concat('%', #{groupName}, '%')</if>
                <if test="companyName != null  and companyName != ''"> and m.company_name like concat('%', #{companyName}, '%')</if>
                <if test="companyCode != null  and companyCode != ''"> and m.company_code = #{companyCode}</if>
                <if test="province != null  and province != ''"> and m.province = #{province}</if>
                <if test="city != null  and city != ''"> and m.city = #{city}</if>
                <if test="district != null  and district != ''"> and m.district = #{district}</if>
                <if test="street != null  and street != ''"> and m.street = #{street}</if>
                <if test="vlgOrCmty != null  and vlgOrCmty != ''"> and m.vlg_or_cmty = #{vlgOrCmty}</if>
                <if test="respPerson != null  and respPerson != ''"> and m.resp_person = #{respPerson}</if>
                <if test="urbRurCls != null  and urbRurCls != ''"> and m.urb_rur_cls = #{urbRurCls}</if>
                <if test="projectTypeName != null  and projectTypeName != ''"> and m.project_type_name like concat('%', #{projectTypeName}, '%')</if>
                <if test="commHh != null "> and m.comm_hh = #{commHh}</if>
                <if test="acctFyStartConf != null "> and m.acct_fy_start_conf = #{acctFyStartConf}</if>
                <if test="acctPrevRecov != null "> and m.acct_prev_recov = #{acctPrevRecov}</if>
                <if test="acctPrevCharged != null "> and m.acct_prev_charged = #{acctPrevCharged}</if>
                <if test="currFyNewRecovered != null "> and m.curr_fy_new_recovered = #{currFyNewRecovered}</if>
                <if test="totalCharged != null "> and m.total_charged = #{totalCharged}</if>
                <if test="qtrTargetCompany != null "> and m.qtr_target_company = #{qtrTargetCompany}</if>
                <if test="hhGsgCharged != null "> and m.hh_gsg_charged = #{hhGsgCharged}</if>
                <if test="hhGsgUncharged != null "> and m.hh_gsg_uncharged = #{hhGsgUncharged}</if>
                <if test="hhGsgTotal != null "> and m.hh_gsg_total = #{hhGsgTotal}</if>
                <if test="hhNewFull != null "> and m.hh_new_full = #{hhNewFull}</if>
                <if test="hhNewInstall != null "> and m.hh_new_install = #{hhNewInstall}</if>
                <if test="hhPrevFull != null "> and m.hh_prev_full = #{hhPrevFull}</if>
                <if test="hhPrevInstDp != null "> and m.hh_prev_inst_dp = #{hhPrevInstDp}</if>
                <if test="hhUnchg != null "> and m.hh_unchg = #{hhUnchg}</if>
                <if test="hhUnchgConf != null "> and m.hh_unchg_conf = #{hhUnchgConf}</if>
                <if test="hhUnchgScan != null "> and m.hh_unchg_scan = #{hhUnchgScan}</if>
                <if test="hhEvCumPaid != null "> and m.hh_ev_cum_paid = #{hhEvCumPaid}</if>
                <if test="hhEvInst != null "> and m.hh_ev_inst = #{hhEvInst}</if>
                <if test="hhEvFull != null "> and m.hh_ev_full = #{hhEvFull}</if>
                <if test="hhEvIgnite != null "> and m.hh_ev_ignite = #{hhEvIgnite}</if>
                <if test="hhEvCumSetup != null "> and m.hh_ev_cum_setup = #{hhEvCumSetup}</if>
                <if test="hhEvCumGas != null "> and m.hh_ev_cum_gas = #{hhEvCumGas}</if>
                <if test="defFlag != null  and defFlag != ''"> and m.def_flag = #{defFlag}</if>
                <if test="startFiscalYear != null  and startFiscalYear != ''"> and m.fiscal_year &gt;= #{startFiscalYear}</if>
                <if test="finishFiscalYear != null  and finishFiscalYear != ''"> and m.fiscal_year &lt;= #{finishFiscalYear}</if>
                ${params.dataScope}
             ) d
        ORDER BY d.update_time desc
    </select>
</mapper>