shiyunteng
2026-10-30 145580fd820bb31334f2e71643413e846b7ce904
platformx-business-finance-biz/src/main/resources/mapper/ContractSubjectMatterMapper.xml
@@ -37,4 +37,195 @@
        <result property="updateTime" column="update_time"/>
        <result property="delFlag" column="del_flag"/>
  </resultMap>
    <select id="gcpbkwcqk" resultType="com.by4cloud.platformx.business.vo.GcpbkwcqkItemVo">
      SELECT
         d.dict_name AS bkmc,
         IFNULL(sum(c.unit_price*c.quantity),0) AS wc
      FROM
         bip_dict d
            LEFT JOIN
         contract_subject_matter c
         ON
            d.dict_code = c.product_section and c.del_flag = '0'
            LEFT JOIN
         contract c1
         ON
            c.contract_id = c1.id and c1.del_flag = '0'
               and c1.sign_date &gt;= #{monstart}
               and c1.sign_date &lt;= #{monend}
      WHERE
         d.dict_key = 'zb-cpbk'
      GROUP BY
         d.dict_name, d.dict_key;
   </select>
   <select id="gcpbkwcqkBySK" resultType="com.by4cloud.platformx.business.vo.GcpbkwcqkItemVo">
      SELECT
         d.dict_name AS bkmc,
         IFNULL(ROUND(SUM(
                            IFNULL(pay.total_paid, 0) *
                            (agg.sub_total / NULLIF(IFNULL(c1.amount, 0), 0))
                      ), 2), 0) AS wc
      FROM
         bip_dict d
            LEFT JOIN (
            SELECT
               c.product_section,
               c.contract_id,
               SUM(c.unit_price * c.quantity) AS sub_total
            FROM
               contract_subject_matter c
            WHERE
               c.del_flag = '0'
            GROUP BY
               c.product_section, c.contract_id
         ) agg ON d.dict_code = agg.product_section
            LEFT JOIN
         contract c1
         ON
                  agg.contract_id = c1.id
               AND c1.del_flag = '0'
            LEFT JOIN (
            SELECT
               contract_id,
               SUM(payment_amount) AS total_paid
            FROM
               payment_slip
            WHERE
               del_flag = '0'
              and payment_time &gt;= #{monstart}
              and payment_time &lt;= #{monend}
            GROUP BY
               contract_id
         ) pay ON c1.id = pay.contract_id
      WHERE
         d.dict_key = 'zb-cpbk'
      GROUP BY
         d.dict_name;
   </select>
   <select id="sckfzdgzwcqk" resultType="com.by4cloud.platformx.business.vo.GcpbkwcqkItemVo">
      SELECT
         '石煤机' dw,
         d.dict_code `code`,
         d.dict_name AS xm,
         IFNULL(sum(c.unit_price*c.quantity),0) AS wc
      FROM
         bip_dict d
            LEFT JOIN
         contract_subject_matter c
         ON
                  d.dict_code = c.product_section and c.del_flag = '0'
               AND (c.comp_id = 2089995177814495234 or c.comp_id = 2089996921978040321 or c.comp_id = 2089997578009128962 or c.comp_id = 2101966257365045249)
            LEFT JOIN
         contract c1
         ON
            c.contract_id = c1.id and c1.del_flag = '0'
               and c1.sign_date &gt;= #{monstart}
               and c1.sign_date &lt;= #{monend}
      WHERE
         d.dict_key = 'zb-ywxm'
        AND (d.comp_id = 2089995177814495234 or d.comp_id = 2089996921978040321 or d.comp_id = 2089997578009128962 or d.comp_id = 2101966257365045249)
      GROUP BY
         d.dict_name,d.dict_code, d.dict_key
      union all
      SELECT
         '石工泵' dw,
         d.dict_code `code`,
         d.dict_name AS bkmc,
         IFNULL(sum(c.unit_price*c.quantity),0) AS wc
      FROM
         bip_dict d
            LEFT JOIN
         contract_subject_matter c
         ON
                  d.dict_code = c.product_section and c.del_flag = '0'
               AND c.comp_id = 2056556196124250113
            LEFT JOIN
         contract c1
         ON
            c.contract_id = c1.id and c1.del_flag = '0'
               and c1.sign_date &gt;= #{monstart}
               and c1.sign_date &lt;= #{monend}
      WHERE
         d.dict_key = 'zb-ywxm'
        AND d.comp_id = 2056556196124250113
      GROUP BY
         d.dict_name,d.dict_code, d.dict_key
      union all
      SELECT
         '邢台厂' dw,
         d.dict_code `code`,
         d.dict_name AS bkmc,
         IFNULL(sum(c.unit_price*c.quantity),0) AS wc
      FROM
         bip_dict d
            LEFT JOIN
         contract_subject_matter c
         ON
                  d.dict_code = c.product_section and c.del_flag = '0'
               AND c.comp_id = 2056556317461270529
            LEFT JOIN
         contract c1
         ON
            c.contract_id = c1.id and c1.del_flag = '0'
               and c1.sign_date &gt;= #{monstart}
               and c1.sign_date &lt;= #{monend}
      WHERE
         d.dict_key = 'zb-ywxm'
        AND d.comp_id = 2056556317461270529
      GROUP BY
         d.dict_name,d.dict_code, d.dict_key
      union all
      SELECT
         '通方厂' dw,
         d.dict_code `code`,
         d.dict_name AS bkmc,
         IFNULL(sum(c.unit_price*c.quantity),0) AS wc
      FROM
         bip_dict d
            LEFT JOIN
         contract_subject_matter c
         ON
                  d.dict_code = c.product_section and c.del_flag = '0'
               AND c.comp_id = 2056556421857497090
            LEFT JOIN
         contract c1
         ON
            c.contract_id = c1.id and c1.del_flag = '0'
               and c1.sign_date &gt;= #{monstart}
               and c1.sign_date &lt;= #{monend}
      WHERE
         d.dict_key = 'zb-ywxm'
        AND d.comp_id = 2056556421857497090
      GROUP BY
         d.dict_name,d.dict_code, d.dict_key
   </select>
   <select id="cpxzhtwcqk" resultType="com.by4cloud.platformx.business.vo.CpxssrwcqkItemVo">
      SELECT
         d.dict_name AS xm,
         IFNULL( sum( c.quantity ), 0 ) AS xsl,
         IFNULL( sum( c.unit_price * c.quantity ), 0 ) AS xssr
      FROM
         bip_dict d
            LEFT JOIN contract_subject_matter c ON d.dict_code = c.product_category
            AND c.del_flag = '0'
            LEFT JOIN contract c1 ON c.contract_id = c1.id
            AND c1.del_flag = '0'
            and c1.sign_date &gt;= #{monstart}
            and c1.sign_date &lt;= #{monend}
      WHERE
         d.dict_key = 'zb-cpmc'
           and d.comp_id = 2089995177814495234
      GROUP BY
         d.dict_name,
         d.dict_key;
   </select>
</mapper>