فهرست منبع

首页本月毛利润

guq 7 سال پیش
والد
کامیت
12a6a4a2bb

+ 10 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/controller/HomePageController.java

@@ -104,4 +104,14 @@ public class HomePageController {
         return homePageService.keyData();
     }
 
+    /**
+     * @Description 本月毛利润
+     * @return: com.usoftchina.saas.base.Result
+     * @Author: guq
+     * @Date: 2018/12/10
+     */
+    @GetMapping("/monthProfit")
+    public Result monthProfit() {
+        return homePageService.monthProfit();
+    }
 }

+ 2 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/mapper/HomePageMapper.java

@@ -19,4 +19,6 @@ public interface HomePageMapper {
     String getSaleFutureData(Long componyId);
 
     String getKeyData(Long companyId);
+
+    String monthProfit(Long companyId);
 }

+ 2 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/HomePageService.java

@@ -51,4 +51,6 @@ public interface HomePageService {
     Result saleFutureData();
 
     Result keyData();
+
+    Result monthProfit();
 }

+ 7 - 0
applications/commons/commons-server/src/main/java/com/usoftchina/saas/commons/service/impl/HomePageServiceImpl.java

@@ -86,6 +86,13 @@ public class HomePageServiceImpl implements HomePageService{
         return Result.success(data);
     }
 
+    @Override
+    public Result monthProfit() {
+        Long companyId = BaseContextHolder.getCompanyId();
+        Object data = parseJson(homePageMapper.monthProfit(companyId));
+        return Result.success(data);
+    }
+
     private Object parseJson(String text) {
         Object json = null;
         if (null != text) {

+ 32 - 0
applications/commons/commons-server/src/main/resources/mapper/HomePageMapper.xml

@@ -116,4 +116,36 @@
             )d1
             );
     </select>
+
+    <select id="monthProfit" parameterType="long" resultType="string">
+        select concat('[',five_profit,',',other_profit,']') from (
+      (
+        #前5数据
+        select group_concat('{"x":"',custname,'","y":',profit,',"z":"',shortname,'"}') five_profit   from (
+        select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
+        pi_custcode,max(pi_custname) custname,max(ifnull(cu_shortname,'')) shortname  from prodinout left join prodiodetail on pi_id=pd_piid left join customer on cu_id=pi_custid
+        where
+        pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId}
+        GROUP BY pi_custcode,prodinout.companyid order by profit desc  limit 0,4) t
+        )five_profit_,
+	  (
+	    #其它的数据
+		select concat('{"z":"其它","x":"其它","y":',all_profit - five_profit,'}') other_profit from (
+        #总共
+        (
+        select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) all_profit
+        from prodinout left join prodiodetail on pi_id=pd_piid
+        where
+        pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId} )a1_,
+        #前5总和
+        (
+        select sum(profit) five_profit from (select sum((ifnull(pd_netprice,0)- ifnull(pd_price,0))*(ifnull(pd_outqty,0) - ifnull(pd_inqty,0))) profit,
+        pi_custcode,max(pi_custname) custname,prodinout.companyid from prodinout left join prodiodetail on pi_id=pd_piid left join customer on cu_id=pi_custid
+         where
+        pi_class in('出货单', '销售退货单') and pi_statuscode='AUDITED' and DATE_FORMAT(pi_date,'%Y%m')=DATE_FORMAT(CURDATE(),'%Y%m') and prodinout.companyid=#{componyId}
+        GROUP BY pi_custcode,prodinout.companyid order by profit desc  limit 0,4) b)a2_
+       )
+       ) other_profit_
+      )
+    </select>
 </mapper>