<?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="org.jeecg.modules.zrzyqc.qyxx.mapper.QcQyxxMapper">
    <select id="selectqyxx" resultType="String">
        /*   select count(1) xfrwsl  from qc_qyxx where  sys_org_code like 'A02%'*/
        select count(1) xfrwsl
        from sys_depart
        where org_code like 'A04A%'
    </select>
    <select id="yxdls" resultType="String">
        select count(1) yxdls
        from qc_qyxx
        where qymc is not null
          and tyshxybm is not null
          and qylx is not null
          and sys_org_code like 'A04%'
    </select>
    <select id="sbdksAdmin" resultType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where sys_org_code like 'A04%'
    </select>
    <!--    上报地块面积-->
    <select id="sbdksMjAdmin" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj * 0.0015), 2) as sjmj
        from qc_ssgqzysytdqk_gzv
        where sys_org_code like 'A04%'
    </select>

    <select id="sbdks" resultType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where create_by = #{username}
    </select>
    <!--  面积-->
    <select id="sbdksMj" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj * 0.0015), 2) as sjmj
        from qc_ssgqzysytdqk_gzv
        where create_by = #{username}
    </select>

    <select id="wsh" resultType="String" parameterType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where create_by = #{username}
    </select>
    <select id="tgsh" resultType="String" parameterType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where shzt = '通过'
          and create_by = #{username}
    </select>
    <select id="btgsh" resultType="String" parameterType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where shzt = '不通过'
          and create_by = #{username}
    </select>
    <select id="tgshAdmin" resultType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where shzt = '通过'
          and sys_org_code like 'A04%'
    </select>
    <select id="wshAdmin" resultType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where  sys_org_code like 'A04%'
    </select>
    <select id="btgshAdmin" resultType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where shzt = '不通过'
          and sfsb = 4
          and sys_org_code like 'A04%'
    </select>
    <select id="dqsbs" resultType="String" parameterType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where create_by = #{username}
          and sfsb = 1
    </select>
    <select id="cwth" resultType="String" parameterType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where sfsb = 4
          and create_by = #{username}
    </select>
    <!--    审核通过-->
    <select id="shmj" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj), 2) as sjmj
        from qc_ssgqzysytdqk_gzv
        where shzt = '通过'
          and create_by = #{username}
    </select>
    <!--    审核不通过-->
    <select id="shmjNot" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj), 2) as sjmj
        from qc_ssgqzysytdqk_gzv
        where shzt = '不通过'
          and create_by = #{username}
    </select>
    <!--    已审核-->
    <select id="wshsl" resultType="String" parameterType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where create_by = #{username}
          and sfsb in (1)
    </select>
    <!--  未审核  -->
    <select id="wshslMJ" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj * 0.0015), 2) as sjmj
        from qc_ssgqzysytdqk_gzv
        where create_by = #{username}
          and sfsb in (1)
    </select>

    <!--sfsb 是否上报-->
    <select id="wshslAdmin" resultType="String" parameterType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where sfsb in (1, 2)
          and sys_org_code like 'A04%'
    </select>
    <select id="wshslAdminMJ" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj * 0.0015), 2) AS mj
        from qc_ssgqzysytdqk_gzv
        where sfsb in (1, 2)
          and sys_org_code like 'A04%'
    </select>


    <select id="shzsl" resultType="String" parameterType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where create_by = #{username}
          and sfsb in (2)
    </select>
    <select id="shzslAdmin" resultType="String" parameterType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where sfsb = 2
          and sys_org_code like 'A04%'
    </select>
    <update id="upSfsb" parameterType="String">
        update qc_qyxx
        set sfsb=1
        where id = #{id}
          and sfsb = 0
    </update>
    <update id="updatePid" parameterType="String">
        UPDATE sys_depart
        SET PARENT_ID=#{PARENT_ID}
        WHERE ORG_CODE = #{ORG_CODE}
    </update>
    <select id="getPWDlog" resultType="Integer">
        select count(1)
        from SYS_log l
        where l.log_content like concat('修改密码%', #{username}, '%')
    </select>


    <!--省直单位信息-->
    <select id="selectdwxx" resultType="String">
        select count(1) xfrwsl
        from sys_user
        where org_code like 'A03%'
    </select>
    <select id="sydwyxdls" resultType="String">
        select count(1) yxdls
        from qc_qyxx
        where qymc is not null
          and qylx is not null
          and sys_org_code like 'A03%'
    </select>
    <select id="sydwsbdksAdmin" resultType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where sys_org_code like 'A03%'
    </select>
    <!--省直上报面积-->
    <select id="sydwsbdksAdminMj" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj * 0.0015), 2) as sjmj
        from qc_ssgqzysytdqk_gzv
        where sys_org_code like 'A03%'
    </select>

    <select id="sydwwshAdminWshMj" resultType="java.lang.String">
        select ROUND(sum(sjzytdmj * 0.0015), 2) as sjmj
        from qc_ssgqzysytdqk_gzv
        where shzt = '未审核'
          and sys_org_code like 'A03%'
    </select>

    <!--饼图-->
    <select id="sydwtgshAdmin" resultType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where shzt = '通过'
          and sfsb = 3
          and sys_org_code like 'A03%'
    </select>
    <select id="sydwwshAdmin" resultType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where sys_org_code like 'A03%'
    </select>
    <select id="sydwbtgshAdmin" resultType="String">
        select count(1) shzt
        from qc_ssgqzysytdqk_gzv
        where shzt = '不通过'
          and sfsb = 4
          and sys_org_code like 'A03%'
    </select>
    <select id="sydwshzslAdmin" resultType="String" parameterType="String">
        select count(1) sbdk
        from qc_ssgqzysytdqk_gzv
        where sfsb = 2
          and sys_org_code like 'A03%'
    </select>


    <select id="sjyttjsz" resultType="java.util.HashMap">
        select count(a.pzyt) as "value", b.name as "name",b.id as "code",ROUND(sum(SJZYTDMJ * 0.0015), 2) as "mj"
        from qc_ssgqzysytdqk_gzv a
        LEFT JOIN SYS_CATEGORY b
        on a.pzyt = b.id
        where a.SYS_ORG_CODE like 'A03%'
        <if test="xzqh !=null">
            and xzqh like CONCAT( #{xzqh},'%')
        </if>
        GROUP BY b.name,b.id
    </select>
    <select id="dtdktjByxq" resultType="java.util.HashMap" parameterType="String">
        select count(b.XJXZQHDM) as "value", b.XJXZQHMC as "name",b.XJXZQHDM as "xzqhdm",b.sjxzqhdm as "sjxzqhdm",
        <if test="orgCode=='A04'">
            ROUND(sum(CAST(sjzytdmj AS DECIMAL(16,2))*0.0015),2) as "value2"
        </if>
        <if test="orgCode=='A03'">
            ROUND(sum(SJZYTDMJ*0.0015),2) as "value2"
        </if>
        from qc_ssgqzysytdqk_gzv a
        right JOIN (select * from XZQH) b
        on a.xzqh=b.XJXZQHDM
        where SYS_ORG_CODE like concat(#{orgCode}, '%') and xzqh like concat(#{xzqh}, '%')
        GROUP BY b.XJXZQHDM, b.XJXZQHMC, b.sjxzqhdm ORDER BY b.XJXZQHDM DESC
    </select>

    <select id="dtdktj" resultType="java.util.HashMap" parameterType="String">

        select count(b.sjxzqhdm) as "value", b.SJXZQHMC as "name",b.SJXZQHDM as "xzqhdm",
        <if test="orgCode=='A04'">
            ROUND(sum(CAST(sjzytdmj AS DECIMAL(16,2))*0.0015),2) as "value2"
        </if>
        <if test="orgCode=='A03'">
            ROUND(sum(SJZYTDMJ*0.0015),2) as "value2"
        </if>
        from QC_SSGQZYSYTDQK_GZV a
        LEFT JOIN (select DISTINCT SJXZQHDM, SJXZQHMC from XZQH) b
        on a.xzqh like b.SJXZQHDM||'%'
        where SYS_ORG_CODE like concat(#{orgCode}, '%')
        GROUP BY b.sjxzqhdm, b.SJXZQHMC ORDER BY b.sjxzqhdm
    </select>
    <select id="sjyttjss" resultType="java.util.HashMap">
        select count(a.sjyt) as "value", b.name as "name", b.id as "code",ROUND(sum(SJZYTDMJ * 0.0015), 2) as "mj"
        from qc_ssgqzysytdqk_gzv a
        LEFT JOIN SYS_CATEGORY b
        on a.sjyt = b.id
        where a.SYS_ORG_CODE like 'A04%'
        <if test="xzqh !=null">
            and xzqh like CONCAT( #{xzqh},'%')
        </if>
        GROUP BY b.name, b.id
    </select>
    <select id="ssdkmj" resultType="java.util.HashMap">
        select VA as "value", NA as "name", VA2 as "value2", numb as "numb", numb2 as "numb2"
        from (
                 select ROUND(sum(CAST(sjzytdmj AS DECIMAL(16, 2)) * 0.0015), 2) VA,
                        b.SJXZQHMC                                               na,
                        b.SJXZQHDM                                               xzqh,
                        count(*) as                                              numb
                 from qc_ssgqzysytdqk_gzv a
                          LEFT JOIN (select DISTINCT SJXZQHDM, SJXZQHMC from XZQH) b
                                    on a.xzqh like b.SJXZQHDM || '%'
                 where SYS_ORG_CODE like 'A04%'
                 GROUP BY b.SJXZQHDM, b.SJXZQHMC
             ) c
                 LEFT JOIN (select ROUND(sum(CAST(sjzytdmj AS DECIMAL(16, 2)) * 0.0015), 2) VA2,
                                   b.SJXZQHDM as                                            xzqh2,
                                   count(*)   as                                            numb2
                            from qc_ssgqzysytdqk_gzv a
                                     LEFT JOIN (select DISTINCT SJXZQHDM, SJXZQHMC from XZQH) b
                                               on a.xzqh like b.SJXZQHDM || '%'
                            where TDSYXZ = '闲置低效土地'
                              and SYS_ORG_CODE like 'A04%'
                            GROUP BY b.SJXZQHDM) d on c.xzqh = d.xzqh2
                            order by c.xzqh
    </select>
    <select id="ssdkmjbyqx" resultType="java.util.HashMap">
        select VA as "value", NA as "name", VA2 as "value2", numb as "numb", numb2 as "numb2"
        from (
                 select ROUND(sum(CAST(sjzytdmj AS DECIMAL(16, 2)) * 0.0015), 2) VA,
                        b.XJXZQHMC                                               na,
                        b.XJXZQHDM                                               xzqh,
                        b.SJXZQHDM,
                        count(*) as                                              numb
                 from qc_ssgqzysytdqk_gzv a
                          LEFT JOIN (select * from XZQH) b
                                    on a.xzqh = b.XJXZQHDM
                 where SYS_ORG_CODE like 'A04%'
                   and xzqh like CONCAT(#{xzqh}, '%')
                 GROUP BY b.XJXZQHDM, b.XJXZQHMC, b.SJXZQHDM
             ) c
                 LEFT JOIN (select ROUND(sum(CAST(sjzytdmj AS DECIMAL(16, 2)) * 0.0015), 2) VA2,
                                   b.XJXZQHDM as                                            xzqh2,
                                   count(*)   as                                            numb2
                            from qc_ssgqzysytdqk_gzv a
                                     LEFT JOIN (select * from XZQH) b
                                               on a.xzqh = b.XJXZQHDM
                            where TDSYXZ = '闲置低效土地'
                              and SYS_ORG_CODE like 'A04%'
                              and xzqh like CONCAT(#{xzqh}, '%')
                            GROUP BY b.XJXZQHDM) d on c.xzqh = d.xzqh2
                            order by c.xzqh
    </select>
    <select id="szdkmj" resultType="java.util.HashMap">
        select VA as "value", NA as "name", VA2 as "value2", numb as "numb", numb2 as "numb2"
        from (
                 select ROUND(sum(SJZYTDMJ * 0.0015), 2) VA, b.SJXZQHMC na, b.SJXZQHDM xzqh, count(*) as numb
                 from qc_ssgqzysytdqk_gzv a
                          LEFT JOIN (select DISTINCT SJXZQHDM, SJXZQHMC from XZQH) b
                                    on a.xzqh like b.SJXZQHDM || '%'
                 where SYS_ORG_CODE like 'A03%'
                 GROUP BY b.SJXZQHDM, b.SJXZQHMC
             ) c
                 LEFT JOIN (select ROUND(sum(SJZYTDMJ * 0.0015), 2) VA2, b.SJXZQHDM as xzqh2, count(*) as numb2
                            from qc_ssgqzysytdqk_gzv a
                                     LEFT JOIN (select DISTINCT SJXZQHDM, SJXZQHMC from XZQH) b
                                               on a.xzqh like b.SJXZQHDM || '%'
                            where TDSYXZ = '闲置低效土地'
                              and SYS_ORG_CODE like 'A03%'
                            GROUP BY b.SJXZQHDM) d on c.xzqh = d.xzqh2
                            order by c.xzqh
    </select>
    <select id="szdkmjByqx" resultType="java.util.HashMap">
        select VA as "value", NA as "name", VA2 as "value2", numb as "numb", numb2 as "numb2"
        from (
                 select ROUND(sum(SJZYTDMJ * 0.0015), 2) VA,
                        b.XJXZQHMC                       na,
                        b.XJXZQHDM                       xzqh,
                        b.SJXZQHDM,
                        count(*) as                      numb
                 from qc_ssgqzysytdqk_gzv a
                          RIGHT JOIN (select * from XZQH) b
                                     on a.xzqh = b.XJXZQHDM
                 where SYS_ORG_CODE like 'A03%'
                   and xzqh like CONCAT(#{xzqh}, '%')
                 GROUP BY b.XJXZQHDM, b.XJXZQHMC, b.SJXZQHDM
             ) c
                 LEFT JOIN (select ROUND(sum(SJZYTDMJ * 0.0015), 2) VA2, b.XJXZQHDM as xzqh2, count(*) as numb2
                            from qc_ssgqzysytdqk_gzv a
                                     RIGHT JOIN (select * from XZQH) b
                                                on a.xzqh = b.XJXZQHDM
                            where TDSYXZ = '闲置低效土地'
                              and SYS_ORG_CODE like 'A03%'
                              and xzqh like CONCAT(#{xzqh}, '%')
                            GROUP BY b.XJXZQHDM) d on c.xzqh = d.xzqh2
                            order by c.xzqh
    </select>
    <!--一级单位用地亩-->
    <select id="yjdwhz" resultType="java.util.HashMap">
        select a.depart_name as "name", ROUND(sum(b.area), 2) as "value",sum(b.couts) as "number"
        from (select id, depart_name, org_code from sys_depart where org_type = '2' and org_code like 'A04%') a
        LEFT JOIN (
        select ROUND(sum(CAST(sjzytdmj AS DECIMAL(16,2)))*0.0015,2) as area, sys_ORG_CODE as orgcode,
        count(*) as couts
        FROM qc_ssgqzysytdqk_gzv
        where sys_ORG_CODE like 'A04A%'
        <if test="xzqh !=null">
            and xzqh like CONCAT( #{xzqh},'%')
        </if>
        GROUP BY SYS_ORG_CODE) b on b.orgcode like a.org_code || '%'
        GROUP BY a.depart_name
    </select>
    <!--查询入库的年份-->
    <select id="queryYears" resultType="java.lang.String">
        SELECT TO_CHAR(create_time, 'YYYY') AS YEAR
        FROM
            qc_ssgqzysytdqk_gzv
        GROUP BY
            YEAR
        ORDER BY
            YEAR DESC
    </select>
    <select id="getXzdx" resultType="org.jeecg.modules.zrzyqc.qyxx.entity.XzdxVO">
        select count(*) as xzdxNum, round(sum(sjzytdmj)* 0.0015,2) as xzdxArea
        from qc_ssgqzysytdqk_gzv
        where tdsyxz='闲置低效土地' and sys_org_code like 'A04%'
        <if test="userName!='' and userName!=null">
            and create_by = #{username}
        </if>
    </select>
    <select id="getXzdxSz" resultType="org.jeecg.modules.zrzyqc.qyxx.entity.XzdxVO">
        select count(*) as xzdxNum, round(sum(sjzytdmj) * 0.0015, 2) as xzdxArea
        from qc_ssgqzysytdqk_gzv
        where tdsyxz = '闲置低效土地'
          and sys_org_code like 'A03%'
    </select>
    <select id="getFirstOrgNames" resultType="java.util.Map">
        select sys_org_code AS key,qymc AS value
        from qc_qyxx
        where org_type='2' and sys_org_code like 'A04%'
        GROUP BY key, value
    </select>
</mapper>
