<?xml version="1.0" encoding="UTF-8"?>
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
<mapper namespace="com.by4cloud.platformx.business.mapper.ContractSubjectMatterMapper">
|
|
<resultMap id="contractSubjectMatterMap" type="com.by4cloud.platformx.business.entity.ContractSubjectMatter">
|
<id property="id" column="id"/>
|
<result property="compId" column="comp_id"/>
|
<result property="acceptTime" column="accept_time"/>
|
<result property="actualDeliveryDate" column="actual_delivery_date"/>
|
<result property="attachmentUrl" column="attachment_url"/>
|
<result property="brand" column="brand"/>
|
<result property="category" column="category"/>
|
<result property="contractId" column="contract_id"/>
|
<result property="contractName" column="contract_name"/>
|
<result property="deliveryPlace" column="delivery_place"/>
|
<result property="deliveryStatus" column="delivery_status"/>
|
<result property="description" column="description"/>
|
<result property="isAccepted" column="is_accepted"/>
|
<result property="materialCode" column="material_code"/>
|
<result property="materialInternalName" column="material_internal_name"/>
|
<result property="materialName" column="material_name"/>
|
<result property="plannedDeliveryDate" column="planned_delivery_date"/>
|
<result property="quantity" column="quantity"/>
|
<result property="sortOrder" column="sort_order"/>
|
<result property="specification" column="specification"/>
|
<result property="taxAmount" column="tax_amount"/>
|
<result property="taxRate" column="tax_rate"/>
|
<result property="totalAmount" column="total_amount"/>
|
<result property="totalAmountExcludingTax" column="total_amount_excluding_tax"/>
|
<result property="unit" column="unit"/>
|
<result property="unitPrice" column="unit_price"/>
|
<result property="warrantyPeriod" column="warranty_period"/>
|
<result property="createBy" column="create_by"/>
|
<result property="createTime" column="create_time"/>
|
<result property="updateBy" column="update_by"/>
|
<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 >= #{monstart}
|
and c1.sign_date <= #{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 >= #{monstart}
|
and payment_time <= #{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 >= #{monstart}
|
and c1.sign_date <= #{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 >= #{monstart}
|
and c1.sign_date <= #{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 >= #{monstart}
|
and c1.sign_date <= #{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 >= #{monstart}
|
and c1.sign_date <= #{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 >= #{monstart}
|
and c1.sign_date <= #{monend}
|
WHERE
|
d.dict_key = 'zb-cpmc'
|
and d.comp_id = 2089995177814495234
|
GROUP BY
|
d.dict_name,
|
d.dict_key;
|
</select>
|
|
</mapper>
|