ke
2024-12-03 bfe4e6e49ea341c8443d7b4b70cb66de0f1aadab
skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml
@@ -9,17 +9,57 @@
        dria."county_nm",
        dria."town_nm",
        dria."eng_scal",
        dria."bas_guid"
        dria."bas_guid",
        dria."oth_reg_cd"
        FROM
        YWXT.SG_PROJECT_INFO info
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        WHERE
        1 =1
        <if test="dto.selfUnit != null and dto.selfUnit.size>0 ">
            and
            <foreach collection="dto.selfUnit" item="item" index="index" open="(" separator="or" close=")">
                info.CONSTRUCTION_UNIT Like  CONCAT(CONCAT('%', #{item}), '%') or   info.SELF_UNIT Like  CONCAT(CONCAT('%', #{item}), '%')
            </foreach>
        </if>
        <if test="dto.userUnit != null and dto.userUnit.size>0">
            and
            <foreach collection="dto.userUnit" item="item" index="index" open="(" separator="or" close=")">
                info.CONTROL_UNIT Like  CONCAT(CONCAT('%', #{item}), '%')
            </foreach>
        </if>
        <if test="dto.countryUnit != null and dto.countryUnit.size>0">
            and dria."county_cd" in
            <foreach collection="dto.countryUnit" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="dto.projectName != null and dto.projectName != ''">
            and info.project_name like concat( concat ('%',#{dto.projectName}),'%')
        </if>
        <if test="dto.skName != null and dto.skName != ''">
            and info.sk_name like concat(concat('%',#{dto.skName}),'%')
        </if>
        <if test="dto.lot != null and dto.lot != ''">
            and info.lot = #{dto.lot}
        </if>
        <if test="dto.resCd != null and dto.resCd != '' ">
            and info.sk_id like CONCAT(CONCAT('%', #{dto.resCd}), '%')
        </if>
        <if test="dto.engScal != null and dto.engScal != '' ">
            and dria."eng_scal" like CONCAT(CONCAT('%', #{dto.engScal}), '%')
        </if>
        <if test="dto.status != null">
            and info.status = #{dto.status}
        </if>
        <if test="dto.isBegin != null and dto.isBegin == 1">
            and info.status in(1,2)
        </if>
        <if test="dto.isBegin != null and dto.isBegin == 2">
            and info.status = 0
        </if>
        <if test="dto.buildStage != null and dto.buildStage != ''">
            and info.build_stage = #{dto.buildStage}
        </if>
        <if test="dto.projectIds != null and dto.projectIds.size > 0">
            and info.id in
@@ -27,7 +67,70 @@
             #{id}
         </foreach>
        </if>
        <if test="dto.sgCodeS != null and dto.sgCodeS.size > 0">
            and (dria."province_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
                or dria."city_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
                or dria."county_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
                or dria."town_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>)
        </if>
        <!--<if test="dto.deptId != null and dto.deptId !=''">
            and (info.control_unit = #{dto.deptId} or info.construction_unit = #{dto.deptId})
        </if>-->
        <if test="dto.adCode != null and dto.adCode !=''">
            and dria."county_cd" = #{dto.adCode}
        </if>
        <if test="dto.othRegCd != null and dto.othRegCd !=''">
            and dria."oth_reg_cd" = #{dto.othRegCd}
        </if>
       <if test="dto.projectSort == null">
            ORDER BY TO_NUMBER(info.project_progress) desc NULLS LAST,info.status desc
        </if>
        <!--
       <if test="dto.projectSort ==1">
           ORDER BY info.project_progress desc NULLS LAST
       </if>
       <if test="dto.projectSort != null and dto.projectSort ==2">
           ORDER BY info.sk_id asc
       </if>-->
        <if test="dto.projectSort != null and dto.projectSort ==3">
            ORDER BY TO_NUMBER(SUBSTR(info.surface_progress, 1, LENGTH(info.surface_progress) - 1))  desc NULLS LAST
        </if>
        <if test="dto.projectSort != null and dto.projectSort ==4">
            ORDER BY TO_NUMBER(SUBSTR(info.video_progress, 1, LENGTH(info.video_progress) - 1))  desc NULLS LAST
        </if>
        <if test="dto.projectSort != null and dto.projectSort ==5">
            ORDER BY TO_NUMBER(SUBSTR(info.trans_progress, 1, LENGTH(info.trans_progress) - 1))  desc NULLS LAST
        </if>
        <if test="dto.projectSort != null and dto.projectSort ==6">
            ORDER BY TO_NUMBER(SUBSTR(info.seepage_progress , 1, LENGTH(info.seepage_progress ) - 1))  desc NULLS LAST
        </if>
    </select>
    <sql id="sgCodeCondition">
        <if test="dto.sgCodeS != null and dto.sgCodeS.size() > 0">
            AND (
            <foreach collection="dto.sgCodeS" item="id" separator="OR" open="(" close=")">
                dria.province_cd = #{id}
                OR dria.city_cd = #{id}
                OR dria.county_cd = #{id}
                or dria.town_cd = #{id}
            </foreach>
            )
        </if>
    </sql>
    <select id="queryStepByProject" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
        SELECT
@@ -36,6 +139,8 @@
        gx.id AS gxId,
        gx.gx_name,
        d.device_name,
        Pdict.dict_key as Ptype,
        Pdict.dict_value as PtypeName,
        d.device_type,
        dict."DICT_VALUE" AS typeName,
        d.id AS dId,
@@ -46,12 +151,17 @@
        d.STATUS AS deviceStatus,
        pro.STATUS AS projectStatus,
        re.id AS reportId,
        pro.lon_lat
        pro.lon_lat,
        re.resubmit,
        COALESCE(d.price, 99) as price,
        COALESCE(Pdict.sort, 0)  as sort,
        COALESCE(dict.sort, 0)  as dSort
        FROM
        ywxt.sg_project_info pro
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = pro.sk_id
        LEFT JOIN ywxt.sg_device d ON pro.id = d.program_id
        LEFT JOIN YWXT."BLADE_DICT_BIZ" AS dict ON d.device_type = dict.DICT_KEY
        AND dict.CODE = 'SG_DEVICE_TYPE'
        LEFT JOIN YWXT."BLADE_DICT_BIZ" AS dict ON d.device_type = dict.DICT_KEY AND dict.CODE = 'SG_DEVICE_TYPE'
        LEFT JOIN YWXT."BLADE_DICT_BIZ" Pdict on dict.parent_id = Pdict.id
        LEFT JOIN ywxt.sg_gx gx ON d.device_type = gx.gx_type
        LEFT JOIN ywxt.sg_gx_step step ON gx.id = step.gx_info_id
        LEFT JOIN ywxt.sg_progress_report re ON re.gx_step_id = step.id
@@ -72,6 +182,15 @@
                #{id}
            </foreach>
        </if>
        <if test="dto.lot != null and dto.lot != ''">
            and pro.lot like CONCAT(CONCAT('%',#{dto.lot}),'%')
        </if>
        <if test="dto.buildStage != null and dto.buildStage != ''">
            and pro.build_stage like CONCAT(CONCAT('%',#{dto.buildStage}),'%')
        </if>
        <include refid="queryBySgCodeS"></include>
       ORDER BY pro.status desc ,pro.project_progress desc,step.gx_step_num asc
    </select>
    <select id="progressList" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
       SELECT
@@ -88,6 +207,16 @@
     <if test="dto.projectName != null and dto.projectName != ''">
         and pro.project_name like CONCAT(CONCAT('%',#{dto.projectName}),'%')
     </if>
     <if test="dto.lot != null and dto.lot != ''">
         and pro.lot like CONCAT(CONCAT('%',#{dto.lot}),'%')
     </if>
     <if test="dto.buildStage != null and dto.buildStage != ''">
         and pro.build_stage like CONCAT(CONCAT('%',#{dto.buildStage}),'%')
     </if>
     <if test="dto.deptId != null and dto.deptId !=''">
         and (pro.control_unit = #{dto.deptId} or pro.construction_unit = #{dto.deptId})
     </if>
        ORDER BY pro.project_progress desc NULLS LAST
    </select>
    <select id="getSgstatiss" resultType="cn.gistack.sm.sg.VO.SgStatisticsVO">
        SELECT
@@ -101,7 +230,7 @@
           1 = 1
        <if test="grad == 0">
            AND
            dria."bas_name" = #{code}
            info.lot = #{code}
        </if>
        <if test="grad == 2">
            AND
@@ -120,14 +249,18 @@
   a."ad_code" CODE,
   a."ad_name" NAME,
   SUM( CASE WHEN b.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum,
   count( b.STATUS ) projectSum
   count( b.STATUS ) projectSum,
    LISTAGG(b.id, ',') as proIds,
    b.build_stage
FROM
   (
   SELECT
      dria."county_cd" AS countyCode,
      att."guid" AS cityCode,
      ad."ad_code" AS provinceCode,
      info.STATUS
      info.STATUS,
      info.id,
      info.build_stage
   FROM
      YWXT.SG_PROJECT_INFO info
      LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
@@ -143,22 +276,26 @@
   a."p_ad_code" = #{code}
GROUP BY
   a."ad_code",
   a."ad_name"
   a."ad_name",
    b.build_stage
    </select>
    <select id="getsgStatisticsZero" resultType="cn.gistack.sm.sg.VO.SgStatisProVO">
        SELECT
   dria."city_cd" code, dria."city_nm" name ,
   sum( CASE WHEN info.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum,
   count( info.STATUS ) projectSum
        FROM
   count( info.STATUS ) projectSum,
    LISTAGG(info.id, ',') as proIds,
    info.build_stage as buildStage
    FROM
   YWXT.SG_PROJECT_INFO info
   LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        WHERE
    WHERE
   1 = 1
        AND
   dria."bas_name" =#{code}
   Group By dria."city_cd",dria."city_nm"
    <if test="code != null and code != ''">
        AND   info.lot =#{code}
    </if>
   Group By dria."city_cd",dria."city_nm",info.build_stage
   HAVING
    dria."city_cd" IS NOT NULL AND
    dria."city_nm" IS NOT NULL
@@ -166,21 +303,26 @@
    <select id="getsgStatisticsOne" resultType="cn.gistack.sm.sg.VO.SgStatisProVO">
     SELECT
   dria."bas_name" AS code,
   dria."bas_guid" AS name,
<!--   dria."bas_name" AS code,
   dria."bas_guid" AS name,-->
    info.lot as code,
    info.lot as name,
   sum( CASE WHEN info.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum,
   count( info.STATUS ) AS projectSum
   count( info.STATUS ) AS projectSum,
    LISTAGG(info.id, ',') as proIds,
    info.build_stage
FROM
   YWXT.SG_PROJECT_INFO info
   LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
WHERE
   1 = 1
GROUP BY
   dria."bas_guid",
   dria."bas_name"
     info.lot,info.build_stage
 <!--   dria."bas_guid", dria."bas_name" -->
   HAVING
    dria."bas_guid" IS NOT NULL AND
    dria."bas_name" IS NOT NULL
 <!--   dria."bas_guid" IS NOT NULL AND
    dria."bas_name" IS NOT NULL -->
       info.lot is not null
    </select>
    <select id="getProjectId" resultType="java.lang.String">
@@ -231,19 +373,25 @@
        select DISTINCT  "bas_guid"  from SJZT_DW."dim_res_info_a" where "bas_name" = #{code}
    </select>
    <select id="progressList1" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
        select pro.id,
        select DISTINCT pro.id,
        pro.project_name,
        pro.lon_lat,
        pro.status
        pro.status,
        pro.project_progress
        from
        (SELECT
        pro.id,
        pro.project_name,
        pro.lon_lat,
        pro.status,
        pro.lot,
        pro.build_stage,
        dria."county_cd" AS countyCode,
        att."guid" AS cityCode,
        ad."ad_code" AS provinceCode
        ad."ad_code" AS provinceCode,
        pro.project_progress,
        pro.control_unit,
        pro.construction_unit
        FROM
        ywxt.sg_project_info pro
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = pro.sk_id
@@ -254,13 +402,23 @@
        ( pro.countyCode = a."guid" )
        OR ( pro.cityCode = a."guid" )
        OR ( pro.provinceCode = a."guid" ))
        WHERE 1=1 and a."p_ad_code" = #{dto.adCode}
        WHERE 1=1 and (a."p_ad_code" = #{dto.adCode} or a."ad_code" = #{dto.adCode})
        <if test="dto.status != null">
            and pro.status = #{dto.status}
        </if>
        <if test="dto.projectName != null and dto.projectName != ''">
            and pro.project_name like CONCAT(CONCAT('%',#{dto.projectName}),'%')
        </if>
        <if test="dto.lot != null and dto.lot != ''">
            and pro.lot like CONCAT(CONCAT('%',#{dto.lot}),'%')
        </if>
        <if test="dto.buildStage != null and dto.buildStage != ''">
            and pro.build_stage like CONCAT(CONCAT('%',#{dto.buildStage}),'%')
        </if>
        <if test="dto.deptId != null and dto.deptId !=''">
            and (pro.control_unit = #{dto.deptId} or pro.construction_unit = #{dto.deptId})
        </if>
        order by pro.project_progress desc NULLS LAST
    </select>
    <select id="queryStepByProject1" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
    select
@@ -279,8 +437,9 @@
        pro.deviceStatus,
        pro.projectStatus,
        pro.reportId,
        pro.lon_lat
    from
        pro.lon_lat,
        pro.project_progress
        from
        (SELECT
        pro.id,
        pro.project_name,
@@ -300,7 +459,10 @@
        pro.lon_lat,
        dria."county_cd" AS countyCode,
        att."guid" AS cityCode,
        ad."ad_code" AS provinceCode
        ad."ad_code" AS provinceCode,
        pro.project_progress,
        pro.lot,
        pro.build_stage
        FROM
        ywxt.sg_project_info pro
        LEFT JOIN ywxt.sg_device d ON pro.id = d.program_id
@@ -313,12 +475,15 @@
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = pro.sk_id
        LEFT JOIN YWXT."att_ad_base" att ON att."ad_code" = dria."city_cd"
        LEFT JOIN YWXT."att_ad_base" ad ON att."p_ad_code" = ad."ad_code"
        LEFT JOIN YWXT."att_ad_base" aad ON aad."ad_code" = ad."p_ad_code") pro
        LEFT JOIN YWXT."att_ad_base" aad ON aad."ad_code" = ad."p_ad_code"
        where 1=1
        <include refid="queryBySgCodeS"></include>
        ) pro
        LEFT JOIN YWXT."att_ad_base" a ON (
        ( pro.countyCode = a."guid" )
        OR ( pro.cityCode = a."guid" )
        OR ( pro.provinceCode = a."guid" ))
        WHERE 1=1 and a."p_ad_code" = #{dto.adCode}
        WHERE 1=1 and (a."p_ad_code" = #{dto.adCode} or a."ad_code" = #{dto.adCode})
        <if test="dto.projectId != null and dto.projectId != ''">
            and pro.id = #{dto.projectId}
        </if>
@@ -334,8 +499,168 @@
                #{id}
            </foreach>
        </if>
        <if test="dto.lot != null and dto.lot != ''">
            and pro.lot like CONCAT(CONCAT('%',#{dto.lot}),'%')
        </if>
        <if test="dto.buildStage != null and dto.buildStage != ''">
            and pro.build_stage like CONCAT(CONCAT('%',#{dto.buildStage}),'%')
        </if>
        ORDER BY pro.projectStatus desc ,pro.project_progress desc
    </select>
    <!--    <select id="getProjectIds" resultType="java.lang.String">-->
<!--    </select>-->
    <sql id="queryBySgCodeS">
        <if test="dto.selfUnit != null and dto.selfUnit.size>0">
            and
            <foreach collection="dto.selfUnit" item="item" index="index" open="(" separator="or" close=")">
                pro.CONSTRUCTION_UNIT Like  CONCAT(CONCAT('%', #{item}), '%') or  pro.SELF_UNIT Like  CONCAT(CONCAT('%', #{item}), '%')
            </foreach>
        </if>
        <if test="dto.userUnit != null and dto.userUnit.size>0">
            and
            <foreach collection="dto.userUnit" item="item" index="index" open="(" separator="or" close=")">
                pro.CONTROL_UNIT Like  CONCAT(CONCAT('%', #{item}), '%')
            </foreach>
        </if>
        <if test="dto.countryUnit != null and dto.countryUnit.size>0">
            and dria."county_cd" in
            <foreach collection="dto.countryUnit" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
        <if test="dto.sgCodeS != null and dto.sgCodeS.size > 0">
            and (dria."province_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
            or dria."city_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
            or dria."county_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
            or dria."town_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>)
        </if>
    </sql>
    <select id="selectVOById" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
        select * from  ywxt.sg_project_info pro where pro.id = #{proframId}
    </select>
    <select id="getDeviceTypes" resultType="cn.gistack.sm.sg.VO.SgStatisDeviceVO">
        SELECT
            count( d.id) AS deviceCount,
            sum( CASE WHEN d.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END) deviceStart,
            Pdict.DICT_KEY as pType
        FROM
            ywxt.sg_device d
                LEFT JOIN ywxt.blade_dict_biz dict ON d.device_type = dict.DICT_KEY
                LEFT JOIN YWXT."BLADE_DICT_BIZ" Pdict ON dict.parent_id = Pdict.id
        WHERE program_id IN ${s}
        GROUP BY
            Pdict.DICT_KEY
    </select>
    <select id="getSgCodeByUser" resultType="java.lang.String">
       <!-- SELECT
            dp."SG_CODE"
        FROM
            ywxt.BLADE_USER u
                LEFT JOIN ywxt.blade_dept dp ON u.dept_id = cast( dp.id AS VARCHAR )
        WHERE u.id = #{userId} -->
        SELECT
        distinct dp."SG_CODE"
        FROM
        ywxt.BLADE_USER u
        LEFT JOIN ywxt.blade_dept dp ON   u.dept_id  Like  CONCAT('%',  dp.id , '%')
        WHERE u.id =  #{userId}  and   dp."SG_CODE"  is not null  and <![CDATA[dp."SG_CODE" <>'' ]]>   limit 1
    </select>
    <select id="queryDept" resultType="cn.gistack.sm.sg.VO.SgAllDeptOrUser">
        select id,full_name as name from "YWXT"."BLADE_DEPT"
    </select>
    <select id="queryUser" resultType="cn.gistack.sm.sg.VO.SgAllDeptOrUser">
        select id,real_name as name from "YWXT"."BLADE_USER";
    </select>
    <select id="projectTree" resultType="cn.gistack.sm.sg.VO.SgProjectTreeVO">
        SELECT
       <!--  TOP 200 -->
        info.id,
        info.lot,
        dria."province_nm",
        dria."city_nm",
        dria."county_nm",
        dria."town_nm",
        dria."res_nm"
        FROM
        YWXT.SG_PROJECT_INFO info
                LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        WHERE
            1 =1
        <if test="dto.buildStage != null and dto.buildStage != ''">
            and info.build_stage = #{dto.buildStage}
        </if>
        <if test="dto.selfUnit != null and dto.selfUnit.size>0 ">
            and
            <foreach collection="dto.selfUnit" item="item" index="index" open="(" separator="or" close=")">
                info.CONSTRUCTION_UNIT Like  CONCAT(CONCAT('%', #{item}), '%') or info.SELF_UNIT Like  CONCAT(CONCAT('%', #{item}), '%')
            </foreach>
        </if>
        <if test="dto.userUnit != null and dto.userUnit.size>0">
            and
            <foreach collection="dto.userUnit" item="item" index="index" open="(" separator="or" close=")">
                info.CONTROL_UNIT Like  CONCAT(CONCAT('%', #{item}), '%')
            </foreach>
        </if>
        <if test="dto.sgCodeS != null and dto.sgCodeS.size > 0">
            and (dria."province_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
            or dria."city_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
            or dria."county_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
            or dria."town_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>)
        </if>
        <if test="dto.adCode != null and dto.adCode !=''">
            and dria."county_cd" = #{dto.adCode}
        </if>
    </select>
    <select id="getUserS" resultType="java.lang.String">
        SELECT
            user_id
        FROM
            "YWXT"."BLADE_USER_DEPT"
        WHERE 1=1
        <if test="list != null and list.size>0">
            and dept_id in
            <foreach collection="list" item="item" index="index" open="(" separator="," close=")">
                #{item}
            </foreach>
        </if>
    </select>
    <select id="resList" resultType="cn.gistack.sm.sg.VO.ResVO">
        select dria.* from "SJZT_DW"."dim_res_info_a" dria where 1=1
        <if test="dto.adCode != null and dto.adCode != ''">
           and (dria."province_cd" = #{dto.adCode} or dria."city_cd" = #{dto.adCode} or dria."county_cd" = #{dto.adCode})
        </if>
        <if test="dto.skName != null and dto.skName != ''">
            and dria."res_nm" like CONCAT(CONCAT('%', #{dto.skName}), '%')
        </if>
        <include refid="queryBySgCodeS"></include>
    </select>
</mapper>