|
@@ -229,6 +229,7 @@
|
|
|
<if test="earnestMoney != null">earnest_money = #{earnestMoney},</if>
|
|
|
<if test="deliveryDate != null">delivery_date = #{deliveryDate},</if>
|
|
|
<if test="lotNumber != null">lot_number = #{lotNumber},</if>
|
|
|
+ <if test="completionTime != null">completion_time = #{completionTime},</if>
|
|
|
</trim>
|
|
|
where id = #{id}
|
|
|
</update>
|
|
@@ -344,4 +345,625 @@
|
|
|
order by so.id desc
|
|
|
</select>
|
|
|
|
|
|
+<!-- <select id="aa">-->
|
|
|
+<!-- SELECT-->
|
|
|
+<!-- so.sale_custom_no,-->
|
|
|
+<!-- COUNT(*) AS order_count,-->
|
|
|
+<!-- s1.weight-->
|
|
|
+<!-- FROM-->
|
|
|
+<!-- sale_order so-->
|
|
|
+<!-- LEFT JOIN (-->
|
|
|
+<!-- SELECT TRUNCATE-->
|
|
|
+<!-- ( sum( sp.product_number ), 2 ) AS weight,-->
|
|
|
+<!-- so.sale_custom_no-->
|
|
|
+<!-- FROM-->
|
|
|
+<!-- sale_products sp-->
|
|
|
+<!-- LEFT JOIN sale_order so ON sp.sale_order_no = so.sale_no-->
|
|
|
+<!-- AND so.del_flag = '0'-->
|
|
|
+<!-- AND sale_no IN (-->
|
|
|
+<!-- SELECT-->
|
|
|
+<!-- sale_no-->
|
|
|
+<!-- FROM-->
|
|
|
+<!-- sale_order-->
|
|
|
+<!-- WHERE-->
|
|
|
+<!-- sale_order_technology_no != 'retailOrder'-->
|
|
|
+<!-- AND sale_custom_no IN ( 16, 15, 14 ))-->
|
|
|
+<!-- WHERE-->
|
|
|
+<!-- sp.del_flag = '0'-->
|
|
|
+<!-- GROUP BY-->
|
|
|
+<!-- so.sale_custom_no-->
|
|
|
+<!-- ) s1 ON so.sale_custom_no = s1.sale_custom_no-->
|
|
|
+<!-- WHERE-->
|
|
|
+<!-- so.del_flag = '0'-->
|
|
|
+<!-- GROUP BY-->
|
|
|
+<!-- so.sale_custom_no-->
|
|
|
+<!-- ORDER BY-->
|
|
|
+<!-- order_count DESC-->
|
|
|
+<!-- LIMIT 10;-->
|
|
|
+<!-- </select>-->
|
|
|
+
|
|
|
+ <select id="saleOrderTop10List" parameterType="string" resultType="map">
|
|
|
+ SELECT
|
|
|
+ so.sale_custom_no as customerNo,
|
|
|
+ c.custom_name as customerName,
|
|
|
+ COUNT(*) AS orderCount,
|
|
|
+ s1.weight
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN
|
|
|
+ (
|
|
|
+ SELECT TRUNCATE( sum( sp.product_number ), 2 ) AS weight,so.sale_custom_no FROM {DBNAME}.sale_products sp LEFT JOIN {DBNAME}.sale_order so ON sp.sale_order_no = so.sale_no AND so.del_flag ='0'
|
|
|
+ AND sale_no IN (SELECT sale_no FROM {DBNAME}.sale_order WHERE sale_order_technology_no != 'retailOrder' and del_flag = '0' AND sale_custom_no IN
|
|
|
+ <foreach collection="list" item="customerNo" open="(" separator="," close=")">
|
|
|
+ #{customerNo}
|
|
|
+ </foreach>
|
|
|
+ ) WHERE
|
|
|
+ sp.del_flag = '0' GROUP BY so.sale_custom_no
|
|
|
+ ) s1 ON so.sale_custom_no = s1.sale_custom_no
|
|
|
+ left join {DBNAME}.customer c on so.sale_custom_no = c.custom_no and c.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.del_flag = '0' and so.sale_order_technology_no != 'retailOrder'
|
|
|
+ GROUP BY
|
|
|
+ so.sale_custom_no
|
|
|
+ ORDER BY
|
|
|
+ orderCount DESC
|
|
|
+ LIMIT 10
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="saleRetailOrderTop10List" parameterType="string" resultType="map">
|
|
|
+ SELECT
|
|
|
+ so.sale_custom_no as customerNo,
|
|
|
+ c.custom_name as customerName,
|
|
|
+ COUNT(*) AS orderCount,
|
|
|
+ sum(por.suttle) as weight
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON so.sale_no = pi.sale_order_no AND pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.product_outbound_record por on por.notice_number = pi.notice_number AND por.del_flag = '0'
|
|
|
+ left join {DBNAME}.customer c on so.sale_custom_no = c.custom_no and c.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.sale_order_technology_no = 'retailOrder'
|
|
|
+ AND so.del_flag = '0'
|
|
|
+ and so.`status` = '6'
|
|
|
+ AND so.sale_custom_no IN
|
|
|
+ <foreach collection="list" item="customerNo" open="(" separator="," close=")">
|
|
|
+ #{customerNo}
|
|
|
+ </foreach>
|
|
|
+ group by so.sale_custom_no
|
|
|
+ </select>
|
|
|
+<!-- <select id="saleRetailOrderTop10List" parameterType="string" resultType="map">-->
|
|
|
+<!-- SELECT-->
|
|
|
+<!-- so.sale_custom_no as customerNo,-->
|
|
|
+<!-- c.custom_name as customerName,-->
|
|
|
+<!-- COUNT(*) AS orderCount,-->
|
|
|
+<!-- por.weight-->
|
|
|
+<!-- FROM-->
|
|
|
+<!-- {DBNAME}.sale_order so left join {DBNAME}.product_invoice pi on so.sale_no = pi.sale_order_no-->
|
|
|
+<!-- left join-->
|
|
|
+<!-- (-->
|
|
|
+<!-- select sum(por.suttle) as weight,por.notice_number from {DBNAME}.product_outbound_record por-->
|
|
|
+<!-- left join {DBNAME}.product_invoice pi on por.notice_number = pi.notice_number and pi.del_flag = '0'-->
|
|
|
+<!-- where por.del_flag = '0' group by pi.customer_id-->
|
|
|
+<!-- ) as por on por.notice_number = pi.notice_number-->
|
|
|
+<!-- left join {DBNAME}.customer c on so.sale_custom_no = c.custom_no and c.del_flag = '0'-->
|
|
|
+<!-- WHERE-->
|
|
|
+<!-- pi.del_flag = '0'-->
|
|
|
+<!-- and so.sale_order_technology_no = 'retailOrder'-->
|
|
|
+<!-- AND so.del_flag = '0'-->
|
|
|
+<!-- and so.`status` = '6'-->
|
|
|
+<!-- AND so.sale_custom_no IN-->
|
|
|
+<!-- <foreach collection="list" item="customerNo" open="(" separator="," close=")">-->
|
|
|
+<!-- #{customerNo}-->
|
|
|
+<!-- </foreach>-->
|
|
|
+<!-- group by so.sale_custom_no-->
|
|
|
+<!-- </select>-->
|
|
|
+
|
|
|
+ <select id="saleOrderTop10CustomerNoList" resultType="string">
|
|
|
+ SELECT
|
|
|
+ sale_custom_no as customerNo
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order
|
|
|
+ WHERE
|
|
|
+ del_flag = '0'
|
|
|
+ GROUP BY
|
|
|
+ sale_custom_no
|
|
|
+ ORDER BY
|
|
|
+ COUNT(*) DESC
|
|
|
+ LIMIT 10
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectSaleOrderCountByCustomerNo" resultType="map">
|
|
|
+ SELECT
|
|
|
+ COUNT(*) AS orderCount,
|
|
|
+ so.sale_custom_no as customerNo,
|
|
|
+ c.custom_name as customerName
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so left join {DBNAME}.customer c on so.sale_custom_no = c.custom_no and c.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.del_flag = '0'
|
|
|
+ AND so.sale_order_technology_no != 'retailOrder' and so.sale_custom_no = #{customerNo}
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+-- group by so.sale_custom_no
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectRetailOrderCountByCustomerNo" resultType="map">
|
|
|
+ SELECT
|
|
|
+ COUNT(*) AS orderCount,
|
|
|
+ so.sale_custom_no AS customerNo,
|
|
|
+ c.custom_name as customerName
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so left join {DBNAME}.customer c on so.sale_custom_no = c.custom_no and c.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.del_flag = '0'
|
|
|
+ AND so.sale_order_technology_no != 'retailOrder'
|
|
|
+ and so.`status` = '6'
|
|
|
+ and so.sale_custom_no = #{customerNo}
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+-- group by so.sale_custom_no
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectSaleOrderProductCountByCustomerNo" resultType="map">
|
|
|
+ SELECT
|
|
|
+ p.id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ TRUNCATE(sum(sp.product_number),2) as weight,
|
|
|
+ CONCAT(m.materie_encoding,m.materie_color_number) as productColour,
|
|
|
+ so.sale_custom_no as customerNo
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN {DBNAME}.sale_products sp ON so.sale_no = sp.sale_order_no AND sp.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on sp.product_no = p.product_no and p.del_flag = '0'
|
|
|
+ left join {DBNAME}.materiel m on m.materiel_code = sp.colour_number and m.del_flag = '0'
|
|
|
+
|
|
|
+ where so.sale_order_technology_no != 'retailOrder' and so.del_flag = '0' and so.sale_custom_no = #{customerNo}
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ group by sp.product_no,sp.colour_number
|
|
|
+-- ,so.sale_custom_no
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectRetailOrderProductCountByCustomerNo" resultType="map">
|
|
|
+ SELECT
|
|
|
+ por.product_id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ TRUNCATE(sum(por.suttle),2) as weight,
|
|
|
+ por.product_colour as productColour,
|
|
|
+ so.sale_custom_no as customerNo
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON so.sale_no = pi.sale_order_no and pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.product_outbound_record por on por.notice_number = pi.notice_number and por.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on p.id = por.product_id
|
|
|
+ where so.sale_order_technology_no = 'retailOrder' and so.del_flag = '0' and so.`status` = '6' and so.sale_custom_no = #{customerNo}
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ group by por.product_id,por.product_colour
|
|
|
+-- ,so.sale_custom_no
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="selectMaxProductCountByproductType" resultType="map">
|
|
|
+ SELECT
|
|
|
+ productIno.*,
|
|
|
+ TRUNCATE(sum(weight1),2) as weight
|
|
|
+ FROM
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ so.sale_no as saleNo,
|
|
|
+ por.product_id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ TRUNCATE(sum(por.suttle),2) as weight1,
|
|
|
+ por.product_colour as productColour,
|
|
|
+ DATE( so.sale_date ) AS days,
|
|
|
+ DATE_FORMAT( so.sale_date, '%Y-%m' ) AS months,
|
|
|
+ CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) AS quarters,
|
|
|
+ YEAR ( so.sale_date ) AS years
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON so.sale_no = pi.sale_order_no AND pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.product_outbound_record por on por.notice_number = pi.notice_number and por.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on p.id = por.product_id
|
|
|
+ where so.sale_order_technology_no = 'retailOrder' and so.del_flag = '0' and so.`status` = '6' and p.product_type = #{productType}
|
|
|
+ group by por.product_id,por.product_colour,por.notice_number
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ SELECT
|
|
|
+ sp.sale_order_no as saleNo,
|
|
|
+ p.id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ sp.product_number as weight1,
|
|
|
+ CONCAT(m.materie_encoding,m.materie_color_number) as productColour,
|
|
|
+ DATE( so.sale_date ) AS days,
|
|
|
+ DATE_FORMAT( so.sale_date, '%Y-%m' ) AS months,
|
|
|
+ CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) AS quarters,
|
|
|
+ YEAR ( so.sale_date ) AS years
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so left join {DBNAME}.sale_products sp on so.sale_no = sp.sale_order_no and sp.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on sp.product_no = p.product_no and p.del_flag = '0'
|
|
|
+ left join {DBNAME}.materiel m on m.materiel_code = sp.colour_number and m.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.sale_order_technology_no != 'retailOrder'
|
|
|
+ AND so.del_flag = '0'
|
|
|
+ AND so.`status` = '6' and p.product_type = #{productType}
|
|
|
+ ) as productIno
|
|
|
+ <where>
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ days = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ months = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ quarters = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ years = #{timeParam}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+ group by productId,productColour
|
|
|
+ ORDER BY weight DESC
|
|
|
+ LIMIT 10;
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="saleOrderProductCountBySalesman" resultType="map">
|
|
|
+ SELECT
|
|
|
+ TRUNCATE( sum( sp.product_number ), 2 ) AS weight,
|
|
|
+ so.create_by_id as saleId
|
|
|
+ FROM {DBNAME}.sale_products sp LEFT JOIN {DBNAME}.sale_order so ON sp.sale_order_no = so.sale_no AND so.del_flag ='0'
|
|
|
+ WHERE sp.del_flag = '0' AND so.sale_no
|
|
|
+ IN (SELECT sale_no FROM {DBNAME}.sale_order WHERE sale_order_technology_no != 'retailOrder' and del_flag = '0' )
|
|
|
+
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+
|
|
|
+ group by so.create_by_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="retailOrderProductCountBySalesman" resultType="map">
|
|
|
+ SELECT
|
|
|
+ TRUNCATE(sum( por.suttle ),2) AS weight,
|
|
|
+ so.create_by_id as saleId
|
|
|
+ FROM
|
|
|
+ {DBNAME}.product_outbound_record por
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON por.notice_number = pi.notice_number AND pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.sale_order so on pi.sale_order_no = so.sale_no and so.del_flag = '0' and so.`status` = '6' and so.sale_order_technology_no = 'retailOrder'
|
|
|
+ WHERE
|
|
|
+ por.del_flag = '0'
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ so.create_by_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="saleOrderCountBySalesman" resultType="map">
|
|
|
+ SELECT
|
|
|
+ count( 1 ) as orderCount,
|
|
|
+ create_by_id as saleId
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order
|
|
|
+ WHERE
|
|
|
+ del_flag = '0'
|
|
|
+ AND sale_order_technology_no != 'retailOrder'
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( sale_date ),'-',QUARTER ( sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ create_by_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="retailOrderCountBySalesman" resultType="map">
|
|
|
+ SELECT
|
|
|
+ count( 1 ) as orderCount,
|
|
|
+ create_by_id as saleId
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order
|
|
|
+ WHERE
|
|
|
+ del_flag = '0'
|
|
|
+ AND `status` = '6'
|
|
|
+ AND sale_order_technology_no = 'retailOrder'
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( sale_date ),'-',QUARTER ( sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ GROUP BY
|
|
|
+ create_by_id
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="saleOrderProductWeightByProductType" resultType="map">
|
|
|
+ SELECT
|
|
|
+ TRUNCATE(sum(sp.product_number),2) as weight,
|
|
|
+ p.product_type as productType
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so left join {DBNAME}.sale_products sp on so.sale_no = sp.sale_order_no and sp.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on p.product_no = sp.product_no and p.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.sale_order_technology_no != 'retailOrder'
|
|
|
+ AND so.del_flag = '0'
|
|
|
+ AND so.`status` = '6'
|
|
|
+ group by p.product_type
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="retailOrderProductWeightByProductType" resultType="map">
|
|
|
+ SELECT
|
|
|
+ TRUNCATE(sum( por.suttle ),2) AS weight,
|
|
|
+ p.product_type as productType
|
|
|
+ FROM
|
|
|
+ {DBNAME}.product_outbound_record por
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON por.notice_number = pi.notice_number AND pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.sale_order so on pi.sale_order_no = so.sale_no and so.del_flag = '0' and so.`status` = '6' and so.sale_order_technology_no = 'retailOrder'
|
|
|
+ left join {DBNAME}.production p on p.id = por.product_id
|
|
|
+ where por.del_flag = '0'
|
|
|
+ group by p.product_type
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="saleOrderSaleVolume" resultType="map">
|
|
|
+ SELECT
|
|
|
+ IFNULL(TRUNCATE( sum( sp.product_number ), 2 ),0) AS weight
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so left join {DBNAME}.sale_products sp on so.sale_no = sp.sale_order_no and sp.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on p.product_no = sp.product_no and p.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.sale_order_technology_no != 'retailOrder'
|
|
|
+ AND so.del_flag = '0'
|
|
|
+ AND so.`status` = '6'
|
|
|
+
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="retailOrderSaleVolume" resultType="map">
|
|
|
+ SELECT
|
|
|
+ IFNULL(TRUNCATE( sum( por.suttle ), 2 ),0) AS weight
|
|
|
+ FROM
|
|
|
+ {DBNAME}.product_outbound_record por
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON por.notice_number = pi.notice_number AND pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.sale_order so on pi.sale_order_no = so.sale_no and so.del_flag = '0' and so.`status` = '6' and so.sale_order_technology_no = 'retailOrder'
|
|
|
+ left join {DBNAME}.production p on p.id = por.product_id
|
|
|
+ where por.del_flag = '0'
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="productionVolume" resultType="map">
|
|
|
+ SELECT
|
|
|
+ IFNULL(TRUNCATE( sum( suttle ), 2 ),0) AS weight
|
|
|
+ FROM
|
|
|
+ {DBNAME}.product_warehousing_record
|
|
|
+ WHERE
|
|
|
+ del_flag = '0'
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( warehousing_time ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( warehousing_time, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( warehousing_time ),'-',QUARTER ( warehousing_time )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( warehousing_time ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="saleOrderRanking" resultType="map">
|
|
|
+ select a.* from
|
|
|
+ (
|
|
|
+ SELECT
|
|
|
+ so.sale_no as saleNo,
|
|
|
+ por.product_id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ TRUNCATE(sum(por.suttle),2) as weight,
|
|
|
+ por.product_colour as productColour,
|
|
|
+ DATE( so.sale_date ) AS days,
|
|
|
+ DATE_FORMAT( so.sale_date, '%Y-%m' ) AS months,
|
|
|
+ CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) AS quarters,
|
|
|
+ YEAR ( so.sale_date ) AS years
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON so.sale_no = pi.sale_order_no AND pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.product_outbound_record por on por.notice_number = pi.notice_number and por.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on p.id = por.product_id
|
|
|
+ where so.sale_order_technology_no = 'retailOrder' and so.del_flag = '0' and so.`status` = '6'
|
|
|
+
|
|
|
+
|
|
|
+ group by so.sale_no
|
|
|
+
|
|
|
+ UNION ALL
|
|
|
+
|
|
|
+ SELECT
|
|
|
+ sp.sale_order_no as saleNo,
|
|
|
+ p.id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ sum(sp.product_number) as weight,
|
|
|
+ CONCAT(m.materie_encoding,m.materie_color_number) as productColour,
|
|
|
+ DATE( so.sale_date ) AS days,
|
|
|
+ DATE_FORMAT( so.sale_date, '%Y-%m' ) AS months,
|
|
|
+ CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) AS quarters,
|
|
|
+ YEAR ( so.sale_date ) AS years
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so left join {DBNAME}.sale_products sp on so.sale_no = sp.sale_order_no and sp.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on sp.product_no = p.product_no and p.del_flag = '0'
|
|
|
+ left join {DBNAME}.materiel m on m.materiel_code = sp.colour_number and m.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.sale_order_technology_no != 'retailOrder'
|
|
|
+ AND so.del_flag = '0'
|
|
|
+ group by so.sale_no
|
|
|
+
|
|
|
+ ) as a
|
|
|
+ <where>
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ days = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ months = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ quarters = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ years = #{timeParam}
|
|
|
+ </if>
|
|
|
+ </where>
|
|
|
+
|
|
|
+ ORDER BY weight DESC
|
|
|
+ LIMIT 10
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="retailFastSellingProduct" resultType="map">
|
|
|
+ SELECT
|
|
|
+ por.product_id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ TRUNCATE(sum(por.suttle),2) as weight,
|
|
|
+ por.product_colour as productColour,
|
|
|
+ p.product_specifications as spec
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN {DBNAME}.product_invoice pi ON so.sale_no = pi.sale_order_no AND pi.del_flag = '0'
|
|
|
+ left join {DBNAME}.product_outbound_record por on por.notice_number = pi.notice_number and por.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on p.id = por.product_id
|
|
|
+ where so.sale_order_technology_no = 'retailOrder' and so.del_flag = '0' and so.`status` = '6'
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ group by por.product_id,por.product_colour
|
|
|
+ </select>
|
|
|
+
|
|
|
+ <select id="saleFastSellingProduct" resultType="map">
|
|
|
+ SELECT
|
|
|
+ p.id as productId,
|
|
|
+ p.product_name as productName,
|
|
|
+ TRUNCATE(sum(sp.product_number),2) as weight,
|
|
|
+ CONCAT(m.materie_encoding,m.materie_color_number) as productColour,
|
|
|
+ p.product_specifications as spec
|
|
|
+ FROM
|
|
|
+ {DBNAME}.sale_order so
|
|
|
+ LEFT JOIN {DBNAME}.sale_products sp ON sp.sale_order_no = so.sale_no AND sp.del_flag = '0'
|
|
|
+ left join {DBNAME}.production p on sp.product_no = p.product_no and p.del_flag = '0'
|
|
|
+ left join {DBNAME}.materiel m on sp.colour_number = m.materiel_code and m.del_flag = '0'
|
|
|
+ WHERE
|
|
|
+ so.del_flag = '0'
|
|
|
+ AND so.sale_order_technology_no != 'retailOrder'
|
|
|
+ <if test="timeType == 'days'">
|
|
|
+ and DATE( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'months'">
|
|
|
+ and DATE_FORMAT( so.sale_date, '%Y-%m' ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'quarters'">
|
|
|
+ and CONCAT(YEAR ( so.sale_date ),'-',QUARTER ( so.sale_date )) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ <if test="timeType == 'years'">
|
|
|
+ and YEAR ( so.sale_date ) = #{timeParam}
|
|
|
+ </if>
|
|
|
+ group by sp.product_no,sp.colour_number
|
|
|
+ </select>
|
|
|
+
|
|
|
</mapper>
|