|
@@ -1168,25 +1168,20 @@
|
|
|
<select id="salectAnpinProfit" parameterType="TWarehousebills"
|
|
|
resultType="com.ruoyi.anpin.ProfitExcel">
|
|
|
SELECT
|
|
|
+ DISTINCT
|
|
|
temp.years AS annual,
|
|
|
temp.months AS abbreviated,
|
|
|
- temp.fCorpName AS fCorpName,
|
|
|
+ tp.f_name AS projectName,
|
|
|
temp.market AS market,
|
|
|
temp.purchase AS purchase,
|
|
|
- temp.profit AS profit
|
|
|
+ temp.profit AS profit,
|
|
|
+ ROUND(ifnull((temp.profit/temp.market)* 100,0),2) AS profitMargin
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
xs.years AS years,
|
|
|
xs.months AS months,
|
|
|
- xs.f_corpid AS fCorpid,
|
|
|
- CASE
|
|
|
-
|
|
|
- WHEN tc.f_name IS NOT NULL THEN
|
|
|
- tc.f_name
|
|
|
- WHEN ts.f_name IS NOT NULL THEN
|
|
|
- ts.f_name
|
|
|
- END AS fCorpName,
|
|
|
+ xs.fGoodid AS fGoodid,
|
|
|
IFNULL( xs.pay, 0 ) AS market,
|
|
|
IFNULL( sq.collect, 0 ) AS purchase,
|
|
|
CASE WHEN xs.pay IS NOT NULL AND sq.collect IS NOT NULL THEN xs.pay-sq.collect
|
|
@@ -1196,20 +1191,19 @@
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
- tf.f_corpid,
|
|
|
+ tw.f_goodsid AS fGoodid,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
|
|
|
IFNULL( SUM( tf.f_amount ), 0 ) AS pay
|
|
|
FROM
|
|
|
t_warehousebillsfees tf
|
|
|
LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
|
|
|
- LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
|
|
|
WHERE
|
|
|
tf.f_billtype = 'XS'
|
|
|
AND tf.del_flag = '0'
|
|
|
AND tw.del_flag = '0'
|
|
|
<if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
|
|
|
- <if test="fGoodsid != null and fGoodsid != ''">and tf.f_corpid = #{fGoodsid}</if>
|
|
|
+ <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
|
|
|
<if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
|
|
|
<if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
|
|
|
<if test="monthList != null and monthList[0] != null and monthList[0]!= ''">
|
|
@@ -1221,28 +1215,26 @@
|
|
|
GROUP BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ),
|
|
|
- tf.f_corpid
|
|
|
+ tw.f_goodsid
|
|
|
ORDER BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' )
|
|
|
) xs
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
- tp.f_corpid,
|
|
|
+ tw.f_goodsid AS fGoodid,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
|
|
|
IFNULL( SUM( tf.f_amount ), 0 ) AS collect
|
|
|
FROM
|
|
|
t_warehousebillsfees tf
|
|
|
LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
|
|
|
- LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
|
|
|
- LEFT JOIN t_project tp ON tp.f_id = tw.f_goodsid
|
|
|
WHERE
|
|
|
tf.f_billtype = 'SQ'
|
|
|
AND tf.del_flag = '0'
|
|
|
AND tw.del_flag = '0'
|
|
|
<if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
|
|
|
- <if test="fGoodsid != null and fGoodsid != ''">and tp.f_corpid = #{fGoodsid}</if>
|
|
|
+ <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
|
|
|
<if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
|
|
|
<if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
|
|
|
<if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
|
|
@@ -1254,27 +1246,18 @@
|
|
|
GROUP BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ),
|
|
|
- tp.f_corpid
|
|
|
+ tw.f_goodsid
|
|
|
ORDER BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' )
|
|
|
- ) sq ON sq.f_corpid = xs.f_corpid
|
|
|
+ ) sq ON sq.fGoodid = xs.fGoodid
|
|
|
AND sq.years = xs.years
|
|
|
AND sq.months = xs.months
|
|
|
- LEFT JOIN t_corps tc ON xs.f_corpid = tc.f_id
|
|
|
- LEFT JOIN t_corps ts ON sq.f_corpid = ts.f_id
|
|
|
UNION ALL
|
|
|
SELECT
|
|
|
sq.years AS years,
|
|
|
sq.months AS months,
|
|
|
- sq.f_corpid AS fCorpid,
|
|
|
- CASE
|
|
|
-
|
|
|
- WHEN tc.f_name IS NOT NULL THEN
|
|
|
- tc.f_name
|
|
|
- WHEN ts.f_name IS NOT NULL THEN
|
|
|
- ts.f_name
|
|
|
- END AS fCorpName,
|
|
|
+ sq.fGoodid AS fGoodid,
|
|
|
IFNULL( xs.pay, 0 ) AS market,
|
|
|
IFNULL( sq.collect, 0 ) AS purchase,
|
|
|
CASE WHEN xs.pay IS NOT NULL AND sq.collect IS NOT NULL THEN xs.pay-sq.collect
|
|
@@ -1284,21 +1267,19 @@
|
|
|
FROM
|
|
|
(
|
|
|
SELECT
|
|
|
- tp.f_corpid,
|
|
|
+ tw.f_goodsid AS fGoodid,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
|
|
|
IFNULL( SUM( tf.f_amount ), 0 ) AS collect
|
|
|
FROM
|
|
|
t_warehousebillsfees tf
|
|
|
LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
|
|
|
- LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
|
|
|
- LEFT JOIN t_project tp ON tp.f_id = tw.f_goodsid
|
|
|
WHERE
|
|
|
tf.f_billtype = 'SQ'
|
|
|
AND tf.del_flag = '0'
|
|
|
AND tw.del_flag = '0'
|
|
|
<if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
|
|
|
- <if test="fGoodsid != null and fGoodsid != ''">and tp.f_corpid = #{fGoodsid}</if>
|
|
|
+ <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
|
|
|
<if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
|
|
|
<if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
|
|
|
<if test='monthList != null and monthList[0] != null and monthList[0]!= ""'>
|
|
@@ -1310,27 +1291,26 @@
|
|
|
GROUP BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ),
|
|
|
- tp.f_corpid
|
|
|
+ tw.f_goodsid
|
|
|
ORDER BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' )
|
|
|
) sq
|
|
|
LEFT JOIN (
|
|
|
SELECT
|
|
|
- tf.f_corpid,
|
|
|
+ tw.f_goodsid AS fGoodid,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ) AS years,
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ) AS months,
|
|
|
IFNULL( SUM( tf.f_amount ), 0 ) AS pay
|
|
|
FROM
|
|
|
t_warehousebillsfees tf
|
|
|
LEFT JOIN t_warehousebills tw ON tf.f_pid = tw.f_id
|
|
|
- LEFT JOIN t_fees te ON tf.f_feeid = te.f_id
|
|
|
WHERE
|
|
|
tf.f_billtype = 'XS'
|
|
|
AND tf.del_flag = '0'
|
|
|
AND tw.del_flag = '0'
|
|
|
<if test="fBillstatus != null and fBillstatus != ''">and tf.f_billstatus = #{fBillstatus}</if>
|
|
|
- <if test="fGoodsid != null and fGoodsid != ''">and tf.f_corpid = #{fGoodsid}</if>
|
|
|
+ <if test="fGoodsid != null and fGoodsid != ''">and tw.f_goodsid = #{fGoodsid}</if>
|
|
|
<if test="fFeeType != null">and te.f_feetype = #{fFeeType}</if>
|
|
|
<if test="annual != null and annual != ''">and DATE_FORMAT(tf.f_bsdate,'%Y') = #{annual}</if>
|
|
|
<if test='monthList != null and monthList[0] != null and monthList[0]!= "" '>
|
|
@@ -1342,17 +1322,16 @@
|
|
|
GROUP BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' ),
|
|
|
- tf.f_corpid
|
|
|
+ tw.f_goodsid
|
|
|
ORDER BY
|
|
|
DATE_FORMAT( tf.f_bsdate, '%Y' ),
|
|
|
DATE_FORMAT( tf.f_bsdate, '%m' )
|
|
|
- ) xs ON sq.f_corpid = xs.f_corpid
|
|
|
+ ) xs ON sq.fGoodid = xs.fGoodid
|
|
|
AND sq.years = xs.years
|
|
|
AND sq.months = xs.months
|
|
|
- LEFT JOIN t_corps tc ON xs.f_corpid = tc.f_id
|
|
|
- LEFT JOIN t_corps ts ON sq.f_corpid = ts.f_id
|
|
|
) AS temp
|
|
|
- ORDER BY temp.years,temp.months,CONVERT(temp.fCorpName USING GBK)
|
|
|
+ LEFT JOIN t_project tp ON tp.f_id = temp.fGoodid
|
|
|
+ ORDER BY temp.years,temp.months,CONVERT(tp.f_name USING GBK)
|
|
|
</select>
|
|
|
<!--查询入库日期所在年月是否结账-->
|
|
|
<select id="selectTMonthEndingClosingList" parameterType="object" resultType="com.ruoyi.anpin.TMonthEndingClosingExcel">
|