zhoulisky 7 months ago
parent
commit
5381a09168

+ 1 - 1
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmMapper.java

@@ -50,7 +50,7 @@ public interface XmMapper extends BaseMapper<XmEntity> {
 	 * @return List<XmVO>
 	 */
 	@TenantIgnore
-	List<XmSummary> summaryPage(IPage<XmSummary> page, @Param("ew") XmDTO xm);
+ 	List<XmSummary> summaryPage(IPage<XmSummary> page, @Param("ew") XmDTO xm);
 
 	/**
 	 * 获取项目预算总表

+ 13 - 17
kd-service/kd-scientific/src/main/java/org/sky/scientific/mapper/XmMapper.xml

@@ -109,17 +109,16 @@
 <!--    </select>-->
 
     <select id="summaryPage" resultType="org.sky.scientific.pojo.vo.XmSummary">
+
         SELECT
-        xm.id, xm.xmbh,
-        COALESCE(bgXmmc.BGHDZ, xm.XMMC) AS xmmc,
-        COALESCE( (SELECT BGHDZ FROM kd_xm_bgrz bgrz WHERE XM_ID = xm.id AND ZDMC = 'XMFZR' AND (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and bgrz.BGSXSJ <![CDATA[<=]]> now())) ORDER BY BGSXSJ DESC,bgrz.create_time desc LIMIT 1), xm.XMFZR) as xmfzr,
-        tech.name AS xmfzrxm,
-        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMSQDWID' AND (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and bgrz.BGSXSJ <![CDATA[<=]]> now())) ORDER BY bgrz.BGSXSJ DESC,bgrz.create_time desc LIMIT 1),xm.XMSQDWID) AS xmsqdwid,
+        xm.id, xm.xmbh,xm.xmkssj,
+        COALESCE(get_xm_info(xm.id, 'XMMC', #{ew.yearAndMonth}), xm.XMMC) AS xmmc,
+        COALESCE(get_xm_info(xm.id, 'XMFZR', #{ew.yearAndMonth}), xm.XMFZR) AS xmfzr,
+        COALESCE(get_xm_info(xm.id, 'XMSQDWID', #{ew.yearAndMonth}), xm.XMSQDWID) AS xmsqdwid,
         CONCAT_WS('/',(SELECT name FROM kd_department d2 WHERE d2.id = d.parent_id), d.`name`) as xmsqdw,
-        xm.xmkssj,
-        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMJSSJ' AND (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and bgrz.BGSXSJ <![CDATA[<=]]> now())) ORDER BY bgrz.BGSXSJ DESC,bgrz.create_time desc LIMIT 1),xm.XMJSSJ) AS xmjssj,
-        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMYSZEMX' AND (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and bgrz.BGSXSJ <![CDATA[<=]]> now())) ORDER BY bgrz.BGSXSJ DESC,bgrz.create_time desc LIMIT 1),xm.XMYSZEMX) AS xmyszemx,
-        COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'STATUS' AND (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and bgrz.BGSXSJ <![CDATA[<=]]> now())) ORDER BY bgrz.BGSXSJ DESC,bgrz.create_time desc LIMIT 1),xm.status) AS status,
+        COALESCE(get_xm_info(xm.id, 'XMJSSJ', #{ew.yearAndMonth}), xm.XMJSSJ) AS xmjssj,
+        COALESCE(get_xm_info(xm.id, 'XMYSZEMX', #{ew.yearAndMonth}), xm.XMYSZEMX) AS xmyszemx,
+        COALESCE(get_xm_info(xm.id, 'STATUS', #{ew.yearAndMonth}), xm.STATUS) AS status,
         LXBG as lxbg,
         (select count(*) from kd_xm_jdxbg jdxbg where jdxbg.xm_id = xm.id and date_format(jdxbg.fill_date,'%Y%m') between concat(left(#{ew.yearAndMonth},4),'01') and #{ew.yearAndMonth}) as jdxbgCount,
         (select count(*) from kd_xm_jtb jtb where jtb.xm_id = xm.id and date_format(jtb.tbsj,'%Y%m') between concat(left(#{ew.yearAndMonth},4),'01') and #{ew.yearAndMonth}) as ysbgCount,
@@ -131,18 +130,15 @@
         (select count(*) from kd_cg_qt qt where qt.xm_id = xm.id  and date_format(qt.SHOUQUAN_RQ,'%Y%m') between concat(left(#{ew.yearAndMonth},4),'01') and #{ew.yearAndMonth}) as qtCount,
         (select ifnull(sum(WWFYJE), 0) from kd_xm_wwxm ww where ww.XM_ID = xm.id and ww.year_and_month = left(#{ew.yearAndMonth}, 4)) as wwAmount
         FROM kd_xm xm
-        LEFT JOIN (
-            <include refid="org.sky.scientific.mapper.XmBgrzMapper.sql_getXmmc"><property name="yearAndMonth" value="${ew.yearAndMonth}"/></include>
-        )bgXmmc on bgXmmc.xm_id = xm.id
-
-        LEFT JOIN kd_technician tech ON tech.id = COALESCE( (SELECT BGHDZ FROM kd_xm_bgrz bgrz WHERE XM_ID = xm.id AND ZDMC = 'XMFZR' AND (DATE_FORMAT(BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and BGSXSJ <![CDATA[<=]]> now())) ORDER BY BGSXSJ DESC,create_time desc LIMIT 1), xm.XMFZR)
-        LEFT JOIN kd_department d on d.id = COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'XMSQDWID' AND (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and bgrz.BGSXSJ <![CDATA[<=]]> now())) ORDER BY bgrz.BGSXSJ DESC,bgrz.create_time desc LIMIT 1),xm.XMSQDWID)
+        LEFT JOIN kd_technician tech ON tech.id = COALESCE(get_xm_info(xm.id, 'XMFZR', #{ew.yearAndMonth}), xm.XMFZR)
+        LEFT JOIN kd_department d on d.id = COALESCE(get_xm_info(xm.id, 'XMSQDWID', #{ew.yearAndMonth}), xm.XMSQDWID)
         WHERE xm.tenant_id = #{ew.tenantId} and DATE_FORMAT(xm.XMKSSJ, '%Y%m') <![CDATA[<=]]> #{ew.yearAndMonth}
         <if test="ew.xmbh!=null and ew.xmbh!=''">and xm.XMBH like concat('%',#{ew.xmbh},'%')</if>
-        <if test="ew.xmmc!=null and ew.xmmc!=''">and COALESCE(bgXmmc.BGHDZ, xm.XMMC) like concat('%',#{ew.xmmc},'%')</if>
+        <if test="ew.xmmc!=null and ew.xmmc!=''">and COALESCE(get_xm_info(xm.id, 'XMMC', #{ew.yearAndMonth}), xm.XMMC) like concat('%',#{ew.xmmc},'%')</if>
         <if test="ew.xmfzrxm!=null and ew.xmfzrxm!=''">and tech.name like concat('%', #{ew.xmfzrxm},'%')</if>
         <if test="ew.xmsqdw!=null and ew.xmsqdw!=''">and CONCAT_WS('/',(SELECT name FROM kd_department d2 WHERE d2.id = d.parent_id), d.`name`) like concat('%',#{ew.xmsqdw},'%')</if>
-        <if test="ew.status!=null">and COALESCE( (SELECT bgrz.BGHDZ FROM kd_xm_bgrz bgrz WHERE bgrz.XM_ID = xm.id AND bgrz.ZDMC = 'STATUS' AND (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') <![CDATA[<]]>  #{ew.yearAndMonth} or (DATE_FORMAT(bgrz.BGSXSJ, '%Y%m') =#{ew.yearAndMonth} and bgrz.BGSXSJ <![CDATA[<=]]> now())) ORDER BY bgrz.BGSXSJ DESC,bgrz.create_time desc LIMIT 1),xm.status) = #{ew.status}</if>
+        <if test="ew.status!=null">and COALESCE(get_xm_info(xm.id, 'STATUS', #{ew.yearAndMonth}), xm.STATUS) = #{ew.status}</if>
+
     </select>
 
     <select id="selectYszb" resultType="org.sky.scientific.pojo.vo.XmYszbVO">