platformx-business-finance-biz/src/main/resources/mapper/ContractMapper.xml
@@ -74,8 +74,8 @@
      <if test="queryDTO.partyA !=null and queryDTO.partyA !=''">
         and t.party_a LIKE CONCAT('%', #{queryDTO.partyA}, '%')
      </if>
      <if test="queryDTO.queryArea !=null and queryDTO.queryArea !=''">
         AND t1.class_id =  #{queryDTO.queryArea}
      <if test="queryDTO.queryProvince !=null and queryDTO.queryProvince !=''">
         AND t1.province =  #{queryDTO.queryProvince}
      </if>
      <if test="queryDTO.queryServiceAttr !=null and queryDTO.queryServiceAttr !=''">
         AND t1.export_service_attr =  #{queryDTO.queryServiceAttr}
@@ -173,6 +173,33 @@
      UNION ALL
      SELECT
      '石煤机公司' AS party_b_name,
      SUM(CASE WHEN MONTH(sign_date) = 1 THEN amount ELSE 0 END) AS m01,
      SUM(CASE WHEN MONTH(sign_date) = 2 THEN amount ELSE 0 END) AS m02,
      SUM(CASE WHEN MONTH(sign_date) = 3 THEN amount ELSE 0 END) AS m03,
      SUM(CASE WHEN MONTH(sign_date) = 4 THEN amount ELSE 0 END) AS m04,
      SUM(CASE WHEN MONTH(sign_date) = 5 THEN amount ELSE 0 END) AS m05,
      SUM(CASE WHEN MONTH(sign_date) = 6 THEN amount ELSE 0 END) AS m06,
      SUM(CASE WHEN MONTH(sign_date) = 7 THEN amount ELSE 0 END) AS m07,
      SUM(CASE WHEN MONTH(sign_date) = 8 THEN amount ELSE 0 END) AS m08,
      SUM(CASE WHEN MONTH(sign_date) = 9 THEN amount ELSE 0 END) AS m09,
      SUM(CASE WHEN MONTH(sign_date) = 10 THEN amount ELSE 0 END) AS m10,
      SUM(CASE WHEN MONTH(sign_date) = 11 THEN amount ELSE 0 END) AS m11,
      SUM(CASE WHEN MONTH(sign_date) = 12 THEN amount ELSE 0 END) AS m12,
      SUM(amount) AS total_amt
      FROM contract
      WHERE
      del_flag = '0'
      AND amount IS NOT NULL
      AND sign_date IS NOT NULL
      AND YEAR(sign_date) = #{queryDTO.year}
      AND   party_b_id IN (2089995177814495234,2089996921978040321,2089997578009128962,2101966257365045249)
      GROUP BY party_b_id, party_b
      UNION ALL
      SELECT
         '总计' AS party_b_name,
         SUM(CASE WHEN MONTH(sign_date) = 1 THEN amount ELSE 0 END),
         SUM(CASE WHEN MONTH(sign_date) = 2 THEN amount ELSE 0 END),
@@ -193,10 +220,6 @@
            AND amount IS NOT NULL
            AND sign_date IS NOT NULL
            AND YEAR(sign_date) = #{queryDTO.year}
      AND   party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
      </foreach>
            ) AS pivot_table
         GROUP BY party_b_name
         ORDER BY
@@ -338,6 +361,7 @@
                     and c.del_flag = '0'
                     and bc.del_flag = '0'
                     and bc.area_id = b.area_id
                     AND YEAR( c.sign_date ) = #{queryDTO.year}
                     and party_b_id IN
                     <foreach collection="compIds" item="id" open="(" close=")" separator=",">
                        #{id}
@@ -357,6 +381,7 @@
                        and c.del_flag = '0'
                        and bc.del_flag = '0'
                        and bc.area_id = b.area_id
                        AND YEAR( c.sign_date ) = #{queryDTO.year}
                        and party_b_id IN
                        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
                           #{id}
@@ -376,6 +401,7 @@
                        and c.del_flag = '0'
                        and bc.del_flag = '0'
                        and bc.area_id = b.area_id
                        AND YEAR( c.sign_date ) = #{queryDTO.year}
                        and party_b_id IN
                        <foreach collection="compIds" item="id" open="(" close=")" separator=",">
                           #{id}
@@ -395,6 +421,7 @@
                     and c.del_flag = '0'
                     and bc.del_flag = '0'
                     and bc.area_id = b.area_id
                     AND YEAR( c.sign_date ) = #{queryDTO.year}
                     and party_b_id IN
                     <foreach collection="compIds" item="id" open="(" close=")" separator=",">
                        #{id}
@@ -414,6 +441,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.area_id = b.area_id
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -425,7 +453,8 @@
         contract c
            JOIN business_customer b ON c.party_a_id = b.id
      WHERE
         b.area_id IS NOT NULL
      c.del_flag='0'
      AND b.area_id IS NOT NULL
      AND YEAR ( sign_date ) = #{queryDTO.year}
      GROUP BY
         b.area_id
@@ -445,6 +474,7 @@
      where
      c1.del_flag = '0'
      and c1.industry_code = c.industry_code
      AND YEAR( sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -462,6 +492,7 @@
      where
      c1.del_flag = '0'
      and c1.industry_code = c.industry_code
      AND YEAR( sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -479,6 +510,7 @@
      where
      c1.del_flag = '0'
      and c1.industry_code = c.industry_code
      AND YEAR( sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -496,6 +528,7 @@
      where
      c1.del_flag = '0'
      and c1.industry_code = c.industry_code
      AND YEAR( sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -513,6 +546,7 @@
      where
            c1.del_flag = '0'
      and c1.industry_code = c.industry_code
      AND YEAR( sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -523,7 +557,8 @@
      FROM
      contract c
      where
      c.industry_code  is not null
      c.del_flag='0'
      AND c.industry_code  is not null
      AND YEAR ( sign_date ) = #{queryDTO.year}
      GROUP BY
      c.industry_code
@@ -545,6 +580,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = b.class_id
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -564,6 +600,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = b.class_id
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -583,6 +620,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = b.class_id
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -602,6 +640,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = b.class_id
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -621,6 +660,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = b.class_id
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -632,7 +672,8 @@
      contract c
      JOIN business_customer b ON c.party_a_id = b.id
      WHERE
      b.class_id IS NOT NULL
      c.del_flag='0'
      AND b.class_id IS NOT NULL
      AND YEAR ( sign_date ) = #{queryDTO.year}
      GROUP BY
      b.class_id
@@ -655,6 +696,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.export_service_attr = b.export_service_attr
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -674,6 +716,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.export_service_attr = b.export_service_attr
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -693,6 +736,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.export_service_attr = b.export_service_attr
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -712,6 +756,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.export_service_attr = b.export_service_attr
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -731,6 +776,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.export_service_attr = b.export_service_attr
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -742,7 +788,8 @@
      contract c
      JOIN business_customer b ON c.party_a_id = b.id
      WHERE
      b.export_service_attr IS NOT NULL
      c.del_flag='0'
      AND b.export_service_attr IS NOT NULL
      AND YEAR ( sign_date ) = #{queryDTO.year}
      GROUP BY
      b.export_service_attr
@@ -762,6 +809,7 @@
      WHERE
            ct.del_flag = '0'
      and  ct.supply_attribute = c.supply_attribute
      AND YEAR ( sign_date ) = #{queryDTO.year}
      and ct.party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -779,6 +827,7 @@
      WHERE
      ct.del_flag = '0'
      and  ct.supply_attribute = c.supply_attribute
      AND YEAR ( sign_date ) = #{queryDTO.year}
      and ct.party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -796,6 +845,7 @@
      WHERE
      ct.del_flag = '0'
      and  ct.supply_attribute = c.supply_attribute
      AND YEAR ( sign_date ) = #{queryDTO.year}
      and ct.party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -813,6 +863,7 @@
      WHERE
      ct.del_flag = '0'
      and  ct.supply_attribute = c.supply_attribute
      AND YEAR ( sign_date ) = #{queryDTO.year}
      and ct.party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -830,6 +881,7 @@
      WHERE
      ct.del_flag = '0'
      and  ct.supply_attribute = c.supply_attribute
      AND YEAR ( sign_date ) = #{queryDTO.year}
      and ct.party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -885,7 +937,9 @@
            DATE_FORMAT(sign_date, '%Y-%m') AS stat_month,
            SUM(amount) AS total_amount
         FROM contract
         WHERE YEAR(sign_date) = #{queryDTO.year}
         WHERE
            del_flag='0'
            AND YEAR(sign_date) = #{queryDTO.year}
             AND party_b_id = #{compId}
         GROUP BY DATE_FORMAT(sign_date, '%Y-%m')
      ) curr ON m.stat_month = curr.stat_month
@@ -895,7 +949,8 @@
            MONTH(sign_date) AS month_num,
            SUM(amount) AS total_amount
         FROM contract
         WHERE YEAR(sign_date) = YEAR(CURDATE())
         WHERE del_flag='0'
         AND YEAR(sign_date) = YEAR(CURDATE())
           AND party_b_id = #{compId}
         GROUP BY DATE_FORMAT(sign_date, '%Y-%m'), MONTH(sign_date)
      ) prev ON m.month_num = prev.month_num + 1
@@ -904,7 +959,8 @@
            MONTH(sign_date) AS month_num,
            SUM(amount) AS total_amount
         FROM contract
         WHERE YEAR(sign_date) = YEAR(CURDATE()) - 1
         WHERE del_flag='0'
         AND YEAR(sign_date) = YEAR(CURDATE()) - 1
         AND party_b_id = #{compId}
         GROUP BY MONTH(sign_date)
      ) last_year ON m.month_num = last_year.month_num
@@ -927,6 +983,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.sales_model = b.sales_model
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -946,6 +1003,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.sales_model = b.sales_model
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -965,6 +1023,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.sales_model = b.sales_model
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -984,6 +1043,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.sales_model = b.sales_model
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -1003,6 +1063,7 @@
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.sales_model = b.sales_model
      AND YEAR( c.sign_date ) = #{queryDTO.year}
      and party_b_id IN
      <foreach collection="compIds" item="id" open="(" close=")" separator=",">
         #{id}
@@ -1014,7 +1075,8 @@
      contract c
      JOIN business_customer b ON c.party_a_id = b.id
      WHERE
      b.sales_model IS NOT NULL
      c.del_flag='0'
      AND b.sales_model IS NOT NULL
      AND YEAR ( sign_date ) = #{queryDTO.year}
      GROUP BY
      b.sales_model
@@ -1029,6 +1091,7 @@
         c.party_a,
         c.party_b_id,
         c.party_b,
         c.party_c_id,
         c.amount,
         c.contract_type,
         c.supply_attribute,
@@ -1055,6 +1118,8 @@
            c.next_schedule_name,
          c.warranty_schedule_id,
         c.comp_id,
         c.center_push_flag,
         c.last_attachment_url,
         (select sum(delivered_quantity*unit_price) from contract_subject_matter csm where csm.contract_id = c.id) outAmount
         FROM
      contract c,
@@ -1066,6 +1131,9 @@
      <if test="queryDTO.contractName !=null and queryDTO.contractName !=''">
         AND contract_name LIKE CONCAT('%', #{queryDTO.contractName}, '%')
      </if>
      <if test="queryDTO.contractNo !=null and queryDTO.contractNo !=''">
         AND contract_no LIKE CONCAT('%', #{queryDTO.contractNo}, '%')
      </if>
      <if test="queryDTO.partyA !=null and queryDTO.partyA !=''">
         AND party_a LIKE CONCAT('%', #{queryDTO.partyA}, '%')
      </if>
@@ -1075,8 +1143,8 @@
      <if test="queryDTO.queryCompId !=null and queryDTO.queryCompId !=''">
         AND c.comp_id =  #{queryDTO.queryCompId}
      </if>
      <if test="queryDTO.queryArea !=null and queryDTO.queryArea !=''">
         AND bc.class_id =  #{queryDTO.queryArea}
      <if test="queryDTO.queryProvince !=null and queryDTO.queryProvince !=''">
         AND bc.province =  #{queryDTO.queryProvince}
      </if>
      <if test="queryDTO.queryServiceAttr !=null and queryDTO.queryServiceAttr !=''">
         AND bc.export_service_attr =  #{queryDTO.queryServiceAttr}
@@ -1139,7 +1207,7 @@
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056555602756063234
      AND comp_id = 2089995177814495234
      AND c.sign_date &gt;= CURDATE()
      AND c.sign_date &lt; DATE_ADD( CURDATE(), INTERVAL 1 DAY )) smjbr,
      (
@@ -1149,7 +1217,7 @@
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056555602756063234
      AND comp_id = 2089995177814495234
      AND c.sign_date &gt;=DATE_FORMAT( CURDATE(), '%Y-%m-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )) smjby,
      (
@@ -1159,7 +1227,7 @@
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056555602756063234
      AND comp_id = 2089995177814495234
      AND c.sign_date &gt;=DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )) smjbn,
      (
@@ -1568,4 +1636,452 @@
         c.create_time
   </select>
    <select id="zbjtStatisticByContract" resultType="com.by4cloud.platformx.business.vo.ZbjtStatisticVo">
      SELECT
      (
      SELECT
         IFNULL(sum( c.amount ),0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND c.sign_date &gt;= CURDATE()
      AND c.sign_date &lt; DATE_ADD( CURDATE(), INTERVAL 1 DAY )
      ) AS br,
      (
      SELECT
         IFNULL(sum( c.amount ),0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-%m-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 MONTH ), '%Y-%m-01' )
      ) AS bm,
      (
      SELECT
         IFNULL(sum( c.amount ),0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS bn
   </select>
   <select id="zbjtStatisticByContractAmount" resultType="com.by4cloud.platformx.business.vo.ZbjtStatisticByContractAmountVo">
      SELECT
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS smj,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056556196124250113
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS sgb,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056556421857497090
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS tfgs,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056556317461270529
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS jxc,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056556535640576002
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS ymj
   </select>
   <select id="zbjtStatisticByContractAmountPro" resultType="com.by4cloud.platformx.business.vo.ZbjtStatisticByContractAmountProVo">
      SELECT
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2089995177814495234
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS mj,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2101966257365045249
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS hwc,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2089997578009128962
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS zt,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2089996921978040321
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS scd,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND comp_id = 2056556196124250113
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS gyb,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND  (comp_id = 2056556421857497090 or comp_id = 2056556317461270529 or comp_id = 2056556535640576002 )
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS qt
   </select>
   <select id="zbjtStatisticByContractAmountClass" resultType="com.by4cloud.platformx.business.vo.ZbjtStatisticByContractAmountClassVo">
      SELECT
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c, business_customer bc
      WHERE
      bc.id = c.party_a_id
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = '1'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS jz,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c, business_customer bc
      WHERE
      bc.id = c.party_a_id
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = '2'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS zm,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c, business_customer bc
      WHERE
      bc.id = c.party_a_id
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = '3'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS wb
   </select>
   <select id="zbjtStatisticByContractAmountSupply" resultType="com.by4cloud.platformx.business.vo.ZbjtStatisticByContractAmountSupplyVo">
      SELECT
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND c.supply_attribute='0'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS cp,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND c.supply_attribute='1'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS bj,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND c.supply_attribute='2'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS dx,
      (
      SELECT
      IFNULL(sum( c.amount ) ,0)
      FROM
      contract c
      WHERE
      c.del_flag = '0'
      AND c.supply_attribute='3'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS qt
   </select>
   <select id="zbjtStatisticByContractAmountYS"
         resultType="com.by4cloud.platformx.business.vo.ZbjtStatisticByContractAmountClassVo">
      SELECT
      (
      SELECT
      IFNULL(sum( c.billing_amout - paid_amount ) ,0)
      FROM
      contract c, business_customer bc
      WHERE
      bc.id = c.party_a_id
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = '1'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS jz,
      (
      SELECT
      IFNULL(sum( c.billing_amout - paid_amount ) ,0)
      FROM
      contract c, business_customer bc
      WHERE
      bc.id = c.party_a_id
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = '2'
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS zm,
      (
      SELECT
      IFNULL(sum( c.billing_amout - paid_amount ) ,0)
      FROM
      contract c, business_customer bc
      WHERE
      bc.id = c.party_a_id
      and c.del_flag = '0'
      and bc.del_flag = '0'
      and bc.class_id = '3'
      and c.billing_amout &gt;= c.paid_amount
      AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
      AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      ) AS wb
   </select>
   <select id="zbjtIndicatorTrend" resultType="com.by4cloud.platformx.business.vo.ZbjtIndicatorTrendVo">
      WITH RECURSIVE month_series AS (
      SELECT
      DATE( #{startMon} ) AS month_start UNION ALL
      SELECT
      DATE_ADD( month_start, INTERVAL 1 MONTH )
      FROM
      month_series
      WHERE
      month_start &lt; DATE( #{endMon} )
      ) SELECT
      DATE_FORMAT( ms.month_start, '%Y-%m' ) AS `yearMon`,
      COALESCE ( SUM( c.amount ), 0 ) AS `je`
      FROM
      month_series ms
      LEFT JOIN contract c ON DATE_FORMAT( c.sign_date, '%Y-%m' ) = DATE_FORMAT( ms.month_start, '%Y-%m' )
      GROUP BY
      ms.month_start
      ORDER BY
      ms.month_start;
   </select>
   <select id="zbjtPlanAchieced" resultType="com.by4cloud.platformx.business.vo.ZbjtIndicatorTrendVo">
      WITH RECURSIVE month_series AS (
         SELECT
            DATE_FORMAT( CURDATE(), '%Y-%m-01' ) AS month_start UNION ALL
         SELECT
            DATE_SUB( month_start, INTERVAL 1 MONTH )
         FROM
            month_series
         WHERE
            month_start &gt; DATE_SUB( DATE_FORMAT( CURDATE(), '%Y-%m-01' ), INTERVAL 11 MONTH )
      ) SELECT
           DATE_FORMAT( ms.month_start, '%Y-%m' ) AS `yearMon`,
           COALESCE ( SUM( c.amount ), 0 ) AS `je`
      FROM
         month_series ms
            LEFT JOIN contract c ON DATE_FORMAT( c.sign_date, '%Y-%m' ) = DATE_FORMAT( ms.month_start, '%Y-%m' )
            AND c.del_flag = '0'
            <if test="compId !=null">
               AND c.comp_id = #{compId}
            </if>
      GROUP BY
         ms.month_start
      ORDER BY
         ms.month_start ASC;
   </select>
   <select id="zbjtPlanAchiecedSmj" resultType="com.by4cloud.platformx.business.vo.ZbjtIndicatorTrendVo">
      WITH RECURSIVE month_series AS (
      SELECT
      DATE_FORMAT( CURDATE(), '%Y-%m-01' ) AS month_start UNION ALL
      SELECT
      DATE_SUB( month_start, INTERVAL 1 MONTH )
      FROM
      month_series
      WHERE
      month_start &gt; DATE_SUB( DATE_FORMAT( CURDATE(), '%Y-%m-01' ), INTERVAL 11 MONTH )
      ) SELECT
      DATE_FORMAT( ms.month_start, '%m' ) AS `yearMon`,
      COALESCE ( SUM( c.amount ), 0 ) AS `je`
      FROM
      month_series ms
      LEFT JOIN contract c ON DATE_FORMAT( c.sign_date, '%Y-%m' ) = DATE_FORMAT( ms.month_start, '%Y-%m' )
      AND c.del_flag = '0'
         AND (comp_id = 2089995177814495234 or comp_id = 2089996921978040321 or comp_id = 2089997578009128962 or comp_id = 2101966257365045249)
      GROUP BY
      ms.month_start
      ORDER BY
      ms.month_start ASC;
   </select>
    <select id="export" resultType="com.by4cloud.platformx.business.vo.ContractExportExceVO">
      SELECT
      c.id,
      c.contract_no,
      c.contract_name,
      c.party_a_id,
      c.party_a,
      c.party_b_id,
      c.party_b,
      c.party_c_id,
      c.amount,
      c.contract_type,
      c.supply_attribute,
      c.contract_status,
      c.contract_attribute,
      c.sign_date,
      c.sign_place,
      c.effective_date,
      c.delivery_cycle,
      c.expiration_date,
      c.attachment_url,
      c.remark,
      c.parent_id,
      c.approve_time,
      c.arrival_schedule_id,
      c.accept_schedule_id,
      c.billing_status,
      c.billing_amout,
      c.template_id,
      c.sales_model,
      c.paid_amount,
      c.contract_category,
      c.economic_matters,
      c.exec_frequency,
      c.next_schedule_name,
      c.warranty_schedule_id,
      c.comp_id,
      c.center_push_flag,
      c.last_attachment_url
      FROM
      contract c,
      business_customer bc
      WHERE
      c.del_flag = '0'
      AND bc.del_flag = '0'
      AND bc.id = c.party_a_id
      <if test="queryDTO.contractName !=null and queryDTO.contractName !=''">
         AND contract_name LIKE CONCAT('%', #{queryDTO.contractName}, '%')
      </if>
      <if test="queryDTO.contractNo !=null and queryDTO.contractNo !=''">
         AND contract_no LIKE CONCAT('%', #{queryDTO.contractNo}, '%')
      </if>
      <if test="queryDTO.partyA !=null and queryDTO.partyA !=''">
         AND party_a LIKE CONCAT('%', #{queryDTO.partyA}, '%')
      </if>
      <if test="queryDTO.contractStatus !=null and queryDTO.contractStatus !=''">
         AND contract_status =  #{queryDTO.contractStatus}
      </if>
      <if test="queryDTO.queryCompId !=null and queryDTO.queryCompId !=''">
         AND c.comp_id =  #{queryDTO.queryCompId}
      </if>
      <if test="queryDTO.queryProvince !=null and queryDTO.queryProvince !=''">
         AND bc.province =  #{queryDTO.queryProvince}
      </if>
      <if test="queryDTO.queryServiceAttr !=null and queryDTO.queryServiceAttr !=''">
         AND bc.export_service_attr =  #{queryDTO.queryServiceAttr}
      </if>
      <if test="queryDTO.queryType !=null and queryDTO.queryType !='' and queryDTO.queryType =='1'.toString()">
         AND c.sign_date &gt;= CURDATE()
         AND c.sign_date &lt; DATE_ADD( CURDATE(), INTERVAL 1 DAY )
      </if>
      <if test="queryDTO.queryType !=null and queryDTO.queryType !='' and queryDTO.queryType =='2'.toString()">
         AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
         AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      </if>
      <if test="queryDTO.queryType !=null and queryDTO.queryType !='' and queryDTO.queryType =='3'.toString()">
         AND c.sign_date &gt;= DATE_FORMAT( CURDATE(), '%Y-01-01' )
         AND c.sign_date &lt; DATE_FORMAT( DATE_ADD( CURDATE(), INTERVAL 1 YEAR ), '%Y-01-01' )
      </if>
      <if test="queryDTO.startTime !=null and queryDTO.endTime !=null">
         AND c.sign_date &gt;=  #{queryDTO.startTime}
         AND c.sign_date &lt;=  #{queryDTO.endTime}
      </if>
      ORDER BY
      c.create_time DESC
   </select>
</mapper>