ソースを参照

增加B2B订阅查询接口

hejq 7 年 前
コミット
713ce40178

+ 103 - 0
src/main/java/com/uas/platform/b2b/publicapi/controller/TurnoverController.java

@@ -0,0 +1,103 @@
+package com.uas.platform.b2b.publicapi.controller;
+
+import com.uas.platform.b2b.publicapi.model.Turnover;
+import com.uas.platform.b2b.publicapi.service.TurnoverService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.util.List;
+
+/**
+ * ERP查询平台贸易数据
+ *
+ * Created by hejq on 2018-05-31.
+ */
+@RequestMapping("/public/turnover")
+@RestController
+public class TurnoverController {
+
+    @Autowired
+    private TurnoverService turnoverService;
+
+    /**
+     * 获取年度代采订单交易额
+     *
+     * @return
+     */
+    @RequestMapping(value = "/substitute", method = RequestMethod.GET)
+    public List<Turnover> findSubstitute() {
+        return turnoverService.findSubstitute();
+    }
+
+    /**
+     * 获取年度代采订单交易额
+     *
+     * @return
+     */
+    @RequestMapping(value = "/substitute/RMB", method = RequestMethod.GET)
+    public List<Turnover> findRMBSubstitute() {
+        return turnoverService.findSubstituteByRMB();
+    }
+
+    /**
+     * B2B年度交易总额折合RMB
+     *
+     * @return
+     */
+    @RequestMapping(value = "/orderAmount/RMB", method = RequestMethod.GET)
+    public List<Turnover> findRMBOrderAmount() {
+        return turnoverService.findRMBOrderAmount();
+    }
+
+    /**
+     * B2B商务本年度交易总金额
+     *
+     * @return
+     */
+    @RequestMapping(value = "/orderAmount", method = RequestMethod.GET)
+    public List<Turnover> findOrderAmount() {
+        return turnoverService.findOrderAmount();
+    }
+
+    /**
+     *上月订单交易额汇总
+     *
+     * @return
+     */
+    @RequestMapping(value = "/orderAmount/lastMonth", method = RequestMethod.GET)
+    public List<Turnover> findLastMonthOrderAmount() {
+        return turnoverService.findLastMonthOrderAmount();
+    }
+
+    /**
+     * 上月订单数
+     *
+     * @return
+     */
+    @RequestMapping(value = "/orderCount/lastMonth", method = RequestMethod.GET)
+    public List<Turnover> findLastMonthOrderCount() {
+        return turnoverService.findLastMonthOrderCount();
+    }
+
+    /**
+     *订单交易额汇总
+     *
+     * @return
+     */
+    @RequestMapping(value = "/orderAmount/thisMonth", method = RequestMethod.GET)
+    public List<Turnover> findThisMonthOrderAmount() {
+        return turnoverService.findThisMonthOrderAmount();
+    }
+
+    /**
+     * 上月订单数
+     *
+     * @return
+     */
+    @RequestMapping(value = "/orderCount/thisMonth", method = RequestMethod.GET)
+    public List<Turnover> findThisMonthOrderCount() {
+        return turnoverService.findThisMonthOrderCount();
+    }
+}

+ 72 - 0
src/main/java/com/uas/platform/b2b/publicapi/model/Turnover.java

@@ -0,0 +1,72 @@
+package com.uas.platform.b2b.publicapi.model;
+
+import java.math.BigDecimal;
+
+/**
+ * B2B平台交易额
+ *
+ * Created by hejq on 2018-05-31.
+ */
+public class Turnover {
+
+    private String x;
+
+    private String y;
+
+    private String z;
+
+    private BigDecimal sum;
+
+    private String xField;
+
+    private String yField;
+
+    public String getX() {
+        return x;
+    }
+
+    public void setX(String x) {
+        this.x = x;
+    }
+
+    public String getY() {
+        return y;
+    }
+
+    public void setY(String y) {
+        this.y = y;
+    }
+
+    public String getZ() {
+        return z;
+    }
+
+    public void setZ(String z) {
+        this.z = z;
+    }
+
+    public BigDecimal getSum() {
+        return sum;
+    }
+
+    public void setSum(BigDecimal sum) {
+        this.sum = sum;
+    }
+
+    public String getxField() {
+        return xField;
+    }
+
+    public void setxField(String xField) {
+        this.xField = xField;
+    }
+
+    public String getyField() {
+        return yField;
+    }
+
+    public void setyField(String yField) {
+        this.yField = yField;
+    }
+
+}

+ 68 - 0
src/main/java/com/uas/platform/b2b/publicapi/service/TurnoverService.java

@@ -0,0 +1,68 @@
+package com.uas.platform.b2b.publicapi.service;
+
+import com.uas.platform.b2b.publicapi.model.Turnover;
+
+import java.util.List;
+
+/**
+ * ERP查询平台贸易数据接口
+ *
+ * Created by hejq on 2018-05-31.
+ */
+public interface TurnoverService {
+
+    /**
+     * 查询年度代采订单交易额
+     *
+     * @return
+     */
+    List<Turnover> findSubstitute();
+
+    /**
+     * B2B年度代采订单统计RMB
+     *
+     * @return
+     */
+    List<Turnover> findSubstituteByRMB();
+
+    /**
+     * B2B年度交易额折合RMB
+     * @return
+     */
+    List<Turnover> findRMBOrderAmount();
+
+    /**
+     *B2B商务本年度交易总金额
+     *
+     * @return
+     */
+    List<Turnover> findOrderAmount();
+
+    /**
+     * 上月订单交易额汇总
+     *
+     * @return
+     */
+    List<Turnover> findLastMonthOrderAmount();
+
+    /**
+     * 上月订单数
+     *
+     * @return
+     */
+    List<Turnover> findLastMonthOrderCount();
+
+    /**
+     * 本月订单交易额汇总
+     *
+     * @return
+     */
+    List<Turnover> findThisMonthOrderAmount();
+
+    /**
+     * 本月订单数
+     *
+     * @return
+     */
+    List<Turnover> findThisMonthOrderCount();
+}

+ 154 - 0
src/main/java/com/uas/platform/b2b/publicapi/service/impl/TurnoverServiceImpl.java

@@ -0,0 +1,154 @@
+package com.uas.platform.b2b.publicapi.service.impl;
+
+import com.uas.platform.b2b.dao.CommonDao;
+import com.uas.platform.b2b.publicapi.model.Turnover;
+import com.uas.platform.b2b.publicapi.service.TurnoverService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+/**
+ * ERP查询平台贸易数据接口
+ *
+ * Created by hejq on 2018-05-31.
+ */
+@Service
+public class TurnoverServiceImpl implements TurnoverService {
+
+    @Autowired
+    private CommonDao commonDao;
+
+    /**
+     * 查询年度代采订单交易额
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findSubstitute() {
+        String sql = "select date_format(deo_entrydate,'%Y%m') x,deo_currency y,round(sum(dei_totalprice)/10000 ,2) z from purc$deputyorderitems\n" +
+                " left join purc$deputyorders on dei_deoid=deo_id where date_format(deo_entrydate,'%Y')=date_format(last_day(now()), '%Y') \n" +
+                " and deo_downloadstatus = '已下载' and deo_entrystatus='已提交' group by date_format(deo_entrydate,'%Y%m'),\n" +
+                " deo_currency order by date_format(deo_entrydate,'%Y%m'),deo_currency";
+        return commonDao.query(sql, Turnover.class);
+    }
+
+    /**
+     * B2B年度代采订单统计RMB
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findSubstituteByRMB() {
+        String sql = " select round(sum(dei_totalprice*case when  deo_currency='USD' then 6.5 when deo_currency='HKD' then 0.888 \n" +
+                " when deo_currency='RMB' then 1 end)/10000 ,2) SUM \n" +
+                " from purc$deputyorderitems left join purc$deputyorders on dei_deoid=deo_id \n" +
+                " where date_format(deo_entrydate,'%Y')=date_format(last_day(now()), '%Y')  and deo_downloadstatus = '已下载'\n" +
+                " and deo_entrystatus='已提交'";
+        return commonDao.query(sql, Turnover.class);
+    }
+
+    /**
+     * B2B年度交易额折合RMB
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findRMBOrderAmount() {
+        String sql = "select round(sum(YFIELD*(case when  a.xfield='USD' then 6.5 when a.xfield='HKD' then 0.888 when a.xfield='RMB' then 1 end )),2) SUM from \n" +
+                "(select pu_currency xField, round(sum(pd_amount)/10000 ,2) yField \n" +
+                "from purc$orderitems left join purc$orders on pd_puid=pu_id where \n" +
+                "date_format(pu_date,'%Y')=date_format(last_day(now()), '%Y')    group by pu_currency\n" +
+                "UNION\n" +
+                "select deo_currency xField, round(sum(dei_totalprice)/10000 ,2) yField \n" +
+                "from purc$deputyorderitems left join purc$deputyorders on dei_deoid=deo_id where \n" +
+                "date_format(deo_entrydate,'%Y')=date_format(last_day(now()), '%Y')  and deo_downloadstatus = '已下载'  and deo_entrystatus='已提交' \n" +
+                "group by deo_currency) a";
+        return commonDao.query(sql, Turnover.class);
+    }
+
+    /**
+     * B2B商务本年度交易总金额
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findOrderAmount() {
+        String sql = "select a.xField,ROUND(SUM(a.yField)) yField from(\n" +
+                "select pu_currency xField, round(sum(pd_amount)/10000 ,2) yField \n" +
+                "from purc$orderitems left join purc$orders on pd_puid=pu_id where \n" +
+                "date_format(pu_date,'%Y')=date_format(last_day(now()), '%Y')  group by pu_currency\n" +
+                "UNION\n" +
+                "select deo_currency xField, round(sum(dei_totalprice)/10000 ,2) yField \n" +
+                "from purc$deputyorderitems left join purc$deputyorders on dei_deoid=deo_id where \n" +
+                "date_format(deo_entrydate,'%Y')=date_format(last_day(now()), '%Y')  and deo_entrystatus='已提交' and deo_downloadstatus = '已下载' \n" +
+                "group by deo_currency) a  GROUP BY xField";
+        return commonDao.query(sql, Turnover.class);
+    }
+
+    /**
+     * 上月订单交易额汇总
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findLastMonthOrderAmount() {
+        String sql = "select a.xField,sum(a.yField) yField from\n" +
+                "(select pu_currency xField, round(sum(pd_amount)/10000 ,2) yField from purc$orderitems\n" +
+                "left join purc$orders on pd_puid=pu_id\n" +
+                "where date_format(pu_date,'%y-%m')=date_format(DATE_ADD(now(), INTERVAL -1 MONTH), '%y-%m')\n" +
+                "and pu_currency is not null group by pu_currency\n" +
+                "union\n" +
+                "select deo_currency xField, round(sum(dei_totalprice)/10000 ,2) yField from purc$deputyorderitems\n" +
+                "left join purc$deputyorders on dei_deoid=deo_id\n" +
+                "where date_format(deo_entrydate,'%y-%m') = date_format(DATE_ADD(now(), INTERVAL -1 MONTH), '%y-%m')\n" +
+                "and deo_downloadstatus = '已下载'  and deo_entrystatus='已提交' group by deo_currency) a\n" +
+                "group by xField";
+        return commonDao.query(sql, Turnover.class);
+    }
+
+    /**
+     * 上月订单数
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findLastMonthOrderCount() {
+        String sql = "select count(pu_code) sum from purc$orders\n" +
+                "where date_format(pu_date,'%y-%m')=date_format(DATE_ADD(now(), INTERVAL -1 MONTH), '%y-%m')";
+        return commonDao.query(sql, Turnover.class);
+    }
+
+    /**
+     * 本月订单交易额汇总
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findThisMonthOrderAmount() {
+        String sql = "select a.xField,sum(a.yField) yField from\n" +
+                "(select pu_currency xField, round(sum(pd_amount)/10000 ,2) yField from purc$orderitems\n" +
+                "left join purc$orders on pd_puid=pu_id\n" +
+                "where date_format(pu_date,'%y-%m')=date_format(now(), '%y-%m')\n" +
+                "and pu_currency is not null group by pu_currency\n" +
+                "union\n" +
+                "select deo_currency xField, round(sum(dei_totalprice)/10000 ,2) yField from purc$deputyorderitems\n" +
+                "left join purc$deputyorders on dei_deoid=deo_id\n" +
+                "where date_format(deo_entrydate,'%y-%m') = date_format(now(), '%y-%m')\n" +
+                "and deo_downloadstatus = '已下载'  and deo_entrystatus='已提交' group by deo_currency) a\n" +
+                "group by xField";
+        return commonDao.query(sql, Turnover.class);
+    }
+
+    /**
+     * 本月订单数
+     *
+     * @return
+     */
+    @Override
+    public List<Turnover> findThisMonthOrderCount() {
+        String sql = "select count(pu_code) sum from purc$orders\n" +
+                "where date_format(pu_date,'%y-%m')=date_format(now(), '%y-%m')";
+        return commonDao.query(sql, Turnover.class);
+    }
+}