From 62c8530fbf44749c7fe709bf8897a791bc7f0ef4 Mon Sep 17 00:00:00 2001
From: yxm <zhp1521624>
Date: Tue, 16 Jul 2024 11:36:53 +0800
Subject: [PATCH] 项目进度上报逻辑优化和待办添加区域条件筛选v0.8

---
 skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml |   92 +++++++++++++++++++++++++++++++++++----------
 1 files changed, 71 insertions(+), 21 deletions(-)

diff --git a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml
index f885d95..593d9df 100644
--- a/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml
+++ b/skjcmanager/skjcmanager-service/skjcmanager-sm/src/main/java/cn/gistack/sm/sg/mapper/SgProjectInfoMapper.xml
@@ -30,30 +30,63 @@
     </select>
     <select id="queryStepByProject" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
         SELECT
+        b.id,
+        b.project_name,
+        b.gxId,
+        b.gx_name,
+        b.device_name,
+        b.device_type,
+        b.typeName,
+        b.dId,
+        b.gx_step_name,
+        b.gx_step_num,
+        b.stepId,
+        b.reportStatus,
+        b.deviceStatus,
+        b.projectStatus,
+        b.reportId,
+        b.lon_lat
+        FROM
+        (
+        SELECT
         pro.id,
         pro.project_name,
-        gx.id as gxId,
+        gx.id AS gxId,
         gx.gx_name,
         d.device_name,
         d.device_type,
-        dict."DICT_VALUE" as typeName,
-        d.id as dId,
+        dict."DICT_VALUE" AS typeName,
+        d.id AS dId,
         step.gx_step_name,
         step.gx_step_num,
-        step.id as stepId,
-        re.STATUS as reportStatus,
-        d.STATUS as deviceStatus,
-        pro.STATUS as projectStatus,
-        re.id as reportId,
-        pro.lon_lat
+        step.id AS stepId,
+        re.STATUS AS reportStatus,
+        d.STATUS AS deviceStatus,
+        pro.STATUS AS projectStatus,
+        re.id AS reportId,
+        pro.lon_lat,
+        dria."county_cd" AS countyCode,
+        att."guid" AS cityCode,
+        ad."ad_code" AS provinceCode
         FROM
         ywxt.sg_project_info pro
         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.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 and re.gx_device_id = d.id
-        where 1=1
+        LEFT JOIN ywxt.sg_progress_report re ON re.gx_step_id = step.id
+        AND re.gx_device_id = d.id
+        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"
+        ) b
+        LEFT JOIN YWXT."att_ad_base" a ON (
+        ( b.countyCode = a."guid" )
+        OR ( b.cityCode = a."guid" )
+        OR ( b.provinceCode = a."guid" ))
+        where a."p_ad_code" = #{dto.adCode}
         <if test="dto.projectId != null and dto.projectId != ''">
             and pro.id = #{dto.projectId}
         </if>
@@ -71,18 +104,35 @@
         </if>
     </select>
     <select id="progressList" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
-        SELECT
-            pro.id,
-            pro.project_name,
-            pro.lon_lat,
-            pro.status
+        select  b.id,
+        b.project_name,
+        b.lon_lat,
+        b.status from
+        (SELECT
+        pro.id,
+        pro.project_name,
+        pro.lon_lat,
+        pro.status,
+        dria."county_cd" AS countyCode,
+        att."guid" AS cityCode,
+        ad."ad_code" AS provinceCode
         FROM
-            ywxt.sg_project_info pro where 1=1
-    <if test="dto.status != null">
-        and pro.status = #{dto.status}
+        ywxt.sg_project_info pro
+        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")b
+        LEFT JOIN YWXT."att_ad_base" a ON (
+        ( b.countyCode = a."guid" )
+        OR ( b.cityCode = a."guid" )
+        OR ( b.provinceCode = a."guid" ))
+        WHERE
+        a."p_ad_code" = #{dto.adCode}
+        <if test="dto.status != null">
+        and b.status = #{dto.status}
     </if>
      <if test="dto.projectName != null and dto.projectName != ''">
-         and pro.project_name like CONCAT(CONCAT('%',#{dto.projectName}),'%')
+         and b.project_name like CONCAT(CONCAT('%',#{dto.projectName}),'%')
      </if>
     </select>
     <select id="getSgstatiss" resultType="cn.gistack.sm.sg.VO.SgStatisticsVO">

--
Gitblit v1.9.3