瀏覽代碼

安品利润统计改为按项目分组,添加利润率

lazhaoqian 4 年之前
父節點
當前提交
e3a313ac3f

+ 19 - 7
ruoyi-warehouse/src/main/java/com/ruoyi/anpin/ProfitExcel.java

@@ -24,8 +24,8 @@ public class ProfitExcel {
     @Excel(name = "月")
     private String abbreviated;
     //客户中文名
-    @Excel(name = "客户名称")
-    private String fCorpName;
+    @Excel(name = "项目名称")
+    private String projectName;
     //收入
     @Excel(name = "收入")
     private BigDecimal market;
@@ -35,6 +35,17 @@ public class ProfitExcel {
     //利润
     @Excel(name = "利润")
     private BigDecimal profit;
+    //利润率
+    @Excel(name = "利润率")
+    private BigDecimal profitMargin;
+
+    public BigDecimal getProfitMargin() {
+        return profitMargin;
+    }
+
+    public void setProfitMargin(BigDecimal profitMargin) {
+        this.profitMargin = profitMargin;
+    }
 
     public String getAnnual() {
         return annual;
@@ -52,12 +63,12 @@ public class ProfitExcel {
         this.abbreviated = abbreviated;
     }
 
-    public String getfCorpName() {
-        return fCorpName;
+    public String getProjectName() {
+        return projectName;
     }
 
-    public void setfCorpName(String fCorpName) {
-        this.fCorpName = fCorpName;
+    public void setProjectName(String projectName) {
+        this.projectName = projectName;
     }
 
     public BigDecimal getMarket() {
@@ -89,10 +100,11 @@ public class ProfitExcel {
         return "ProfitExcel{" +
                 "years='" + annual + '\'' +
                 ", months='" + abbreviated + '\'' +
-                ", fCorpName='" + fCorpName + '\'' +
+                ", projectName='" + projectName + '\'' +
                 ", market=" + market +
                 ", purchase=" + purchase +
                 ", profit=" + profit +
+                ", profitMargin=" + profitMargin +
                 '}';
     }
 }

+ 1 - 1
ruoyi-warehouse/src/main/java/com/ruoyi/warehouseBusiness/service/impl/TWarehouseBillsServiceImpl.java

@@ -2116,7 +2116,7 @@ public class TWarehouseBillsServiceImpl implements ITWarehouseBillsService {
         List<ProfitExcel> profitExcels = tWarehousebillsfeesMapper.salectAnpinProfit(tWarehouseBills);
         //去重
         List<ProfitExcel> collect = profitExcels.stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(ProfitExcel -> ProfitExcel.getAbbreviated()
-                + ";"+ ProfitExcel.getAnnual()+ ";"+ ProfitExcel.getfCorpName()+ ";"+ ProfitExcel.getMarket()+ ";"+ ProfitExcel.getProfit()+ ";"+ ProfitExcel.getPurchase()
+                + ";"+ ProfitExcel.getAnnual()+ ";"+ ProfitExcel.getProjectName()+ ";"+ ProfitExcel.getMarket()+ ";"+ ProfitExcel.getProfit()+ ";"+ ProfitExcel.getPurchase()
         ))), ArrayList::new));
         return collect;
     }

+ 22 - 43
ruoyi-warehouse/src/main/resources/mapper/warehouseBusiness/TWarehousebillsfeesMapper.xml

@@ -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">