Browse Source

首页统计接口

dudm 3 years ago
parent
commit
64e606c08b

+ 37 - 145
sc-service/src/main/java/com/huyi/service/common/report/controller/ReportCompanyController.java

@@ -1,10 +1,7 @@
 package com.huyi.service.common.report.controller;
 
-import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.huyi.service.common.report.service.ReportCompanyService;
 import com.huyi.service.common.report.service.ReportCreditService;
-import com.keao.tianhu.starter.mybatis.plus.entity.QueryRequest;
-import com.tianhu.common.core.utils.AmtUtil;
 import com.tianhu.common.core.utils.CommonUtil;
 import com.tianhu.common.core.utils.DateUtils;
 import com.tianhu.common.core.web.controller.BaseController;
@@ -48,24 +45,9 @@ public class ReportCompanyController extends BaseController {
     private static String DATE_WEEK = "00";
 
     /**
-     * 时间维度类型 01
+     * 时间维度类型 01
      */
-    private static String DATE_MONTH = "01";
-
-    /**
-     * 时间维度类型 02季度
-     */
-    private static String DATE_QUARTER = "02";
-
-    /**
-     * 时间维度类型 03半年
-     */
-    private static String DATE_HALF = "03";
-
-    /**
-     * 时间维度类型 04年
-     */
-    private static String DATE_YEAR = "04";
+    private static String DATE_YEAR = "01";
 
     /**
      * 类型 00注册数量
@@ -313,19 +295,16 @@ public class ReportCompanyController extends BaseController {
     }
 
     /**
-     * 用户数据统计 -- 柱状图
-     * @param type      数据类型
+     * 平台用户统计 -- 柱状图
      * @param dateType  时间维度类型
-     * @param dates     时间范围
      * @return
      */
     @GetMapping("/getCompanyReport")
-    public AjaxResult getCompanyReport(String type,String dateType,List dates)
+    public AjaxResult getCompanyReport(String dateType)
     {
         //获取当前企业的编号
         LoginUser userInfo = tokenService.getLoginUser();
         SysUser use = userInfo.getSysUser();
-        Map<String,String> map = new HashMap<>();
         //获取企业
         String companyId = use.getCompanyId();
         //获取企业类型
@@ -334,142 +313,54 @@ public class ReportCompanyController extends BaseController {
         if(!COMPANYTYPE_TERRACE.equals(companyType)){
             return AjaxResult.success();
         }
+        //默认当年
+        String  year = DateUtils.getDate().substring(0,4);
         //月份集合
-        List<String> dateList = getMonth();
+        List<String> dateList = new ArrayList<>();
         if(DATE_WEEK.equals(dateType)){
             //周
-
-        }else if(DATE_MONTH.equals(dateType)){
-            //月
-
-        }else if(DATE_QUARTER.equals(dateType)){
-            //季度
-
-        }else if(DATE_HALF.equals(dateType)){
-            //半年
-
+            dateList = findDaysStr(DateUtils.getPastDate(7),DateUtils.dateTimeNow("yyyy-MM-dd"));
         }else if(DATE_YEAR.equals(dateType)){
             //年
-
+            dateList = getMonth();
         }
         //数据集合
         List<Map> dataList = new ArrayList<>();
-        //数量集合
+        //供应商数量
         List<String> data = new ArrayList<>();
+        //核心企业数量
+        List<String> coreData = new ArrayList<>();
         for (String date : dateList) {
-            //数量
-            String num = "0";
-            if(TYPE_REGISTER.equals(type)){
-                //平台注册
-                num =  reportCompanyService.getRegisterNum(map);
-            }else if(TYPE_COMPANY.equals(type)){
-                //入驻企业
-                num =  reportCompanyService.getCompanyNum(map);
-            }else if(TYPE_COMPANY_SUPPLIER.equals(type)){
-                map.put("type","02");
-                //入住供应商
-                num =  reportCompanyService.getCompanyNum(map);
-            }else if(TYPE_FINANCE_SUPPLIER.equals(type)){
-                //融资供应商
-                num =  reportCompanyService.getFinanceSupplier(map);
-            }else if(TYPE_COMPANY_CORE.equals(type)){
-                map.put("type","01");
-                //入住核心企业
-                num =  reportCompanyService.getCompanyNum(map);
-            }else if(TYPE_FINANCE_CORE.equals(type)){
-                //签立业务核心企业
-                num =  reportCompanyService.getFinanceCore(map);
-            }
-            data.add(num);
-        }
-        //开立额度数据对象
-        Map dataMap = new HashMap();
-        dataMap.put("name","数量");
-        dataMap.put("data",data);
-        dataList.add(dataMap);
-        Map result = new HashMap();
-        result.put("dataList",dataList);
-        result.put("dateList",dateList);
-        return AjaxResult.success(result);
-    }
-
-    /**
-     * 业务数据统计 -- 柱状图
-     * @param type          数据类型
-     * @param dateType      时间维度类型
-     * @param dates         时间范围
-     * @param companyId     资方
-     * @param productId     融资产品
-     * @return
-     */
-    @GetMapping("/getFinanceReport")
-    public AjaxResult getFinanceReport(String type,String dateType,List dates,String companyId,String productId)
-    {
-        //获取当前企业的编号
-        LoginUser userInfo = tokenService.getLoginUser();
-        SysUser use = userInfo.getSysUser();
-        Map<String,String> map = new HashMap<>();
-        //资方
-        map.put("managementCompanyId",companyId);
-        //融资产品
-        map.put("productId",productId);
-        //获取企业类型
-        String companyType = use.getCompanyType();
-        //平台
-        if(!COMPANYTYPE_TERRACE.equals(companyType)){
-            return AjaxResult.success();
-        }
-        //月份集合
-        List<String> dateList = getMonth();
-        if(DATE_WEEK.equals(dateType)){
-            //周
-
-        }else if(DATE_MONTH.equals(dateType)){
-            //月
-
-        }else if(DATE_QUARTER.equals(dateType)){
-            //季度
-
-        }else if(DATE_HALF.equals(dateType)){
-            //半年
-
-        }else if(DATE_YEAR.equals(dateType)){
-            //年
+            if(DATE_YEAR.equals(dateType)){
 
-        }
-        //数据集合
-        List<Map> dataList = new ArrayList<>();
-        //数量集合
-        List<String> data = new ArrayList<>();
-        for (String date : dateList) {
-            //数量
-            String num = "0";
-            if(TYPE_CREDIT_AMOUNT.equals(type)){
-                //授信额度
-                num =  reportCreditService.getCreditLineAll(map);
-            }else if(TYPE_PRODUCT_NUM.equals(type)){
-                //融资产品数量
-                num =  reportCompanyService.getFinanceProductNum(map);
-            }else if(TYPE_LOAN_NUM.equals(type)){
-                //融资开立数量
-                num =  reportCompanyService.getFinanceRecordNum(map);
-            }else if(TYPE_LOAN_AMOUNT.equals(type)){
-                //融资开立金额
-                num =  reportCreditService.financeRecordMonth(map);
-            }else if(TYPE_FINANCE_NUM.equals(type)){
-                //融信融资次数
-                num =  reportCompanyService.getFinanceNum(map);
-            }else if(TYPE_FINANCE_AMOUNT.equals(type)){
-                //融信融资金额
-                num =  reportCreditService.getFinancedBalance(map);
+                date = date.replaceAll("月","");
+                //年
+                date = year.concat("-").concat(CommonUtil.compare(date, "10") < 0 ? "0".concat(date) : date).concat("-31");
             }
+            Map map = new HashMap<>();
+            //入住供应商
+            map.put("type","02");
+            map.put("date",date);
+            String num = reportCompanyService.getCompanyNum(map);
+            Map coreMap = new HashMap<>();
+            //入住供应商
+            coreMap.put("type","01");
+            coreMap.put("date",date);
+            //入住核心企业
+            String coreNum = reportCompanyService.getCompanyNum(coreMap);
             data.add(num);
+            coreData.add(coreNum);
         }
-        //开立额度数据对象
+        //供应商数据对象
         Map dataMap = new HashMap();
-        dataMap.put("name","数量");
+        dataMap.put("name","供应商");
         dataMap.put("data",data);
         dataList.add(dataMap);
+        //核心企业数据对象
+        Map coreMap = new HashMap();
+        coreMap.put("name","核心企业");
+        coreMap.put("data",coreData);
+        dataList.add(coreMap);
         Map result = new HashMap();
         result.put("dataList",dataList);
         result.put("dateList",dateList);
@@ -484,7 +375,8 @@ public class ReportCompanyController extends BaseController {
         List<String> dateList = new ArrayList<>();
         //循环添加所有月份
         for(int i = 1; i < 13; i++){
-            dateList.add(i + "月");
+            String date = i + "月";
+            dateList.add(date);
         }
         return dateList;
     }

+ 83 - 24
sc-service/src/main/java/com/huyi/service/common/report/controller/ReportCreditController.java

@@ -55,6 +55,16 @@ public class ReportCreditController extends BaseController {
     private static String COMPANYTYPE_MANAGEMENT = "03";
 
     /**
+     * 时间维度类型 00周
+     */
+    private static String DATE_WEEK = "00";
+
+    /**
+     * 时间维度类型 01年
+     */
+    private static String DATE_YEAR = "01";
+
+    /**
      * 查询企业持有融信额度
      * @return
      */
@@ -115,18 +125,20 @@ public class ReportCreditController extends BaseController {
         if(CommonUtil.isEmpty(zfpType)){
             zfpType = "1";
         }
-        map.put("zfpType", zfpType);
         //获取企业类型
         String type = use.getCompanyType();
         if(COMPANYTYPE_CORE.equals(type)){
             //核心企业
             map.put("coreCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_SUPPLIER.equals(type)){
             //供应商
             map.put("supplierCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_MANAGEMENT.equals(type)){
             //资金方
             map.put("managementCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }
         String allAmount =  reportCreditService.getAvailableBalance(map);
         Map m = new HashMap();
@@ -151,18 +163,20 @@ public class ReportCreditController extends BaseController {
         if(CommonUtil.isEmpty(zfpType)){
             zfpType = "1";
         }
-        map.put("zfpType", zfpType);
         //获取企业类型
         String type = use.getCompanyType();
         if(COMPANYTYPE_CORE.equals(type)){
             //核心企业
             map.put("coreCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_SUPPLIER.equals(type)){
             //供应商
             map.put("supplierCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_MANAGEMENT.equals(type)){
             //资金方
             map.put("managementCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }
         String allAmount =  reportCreditService.getEffectBalance(map);
         Map m = new HashMap();
@@ -187,18 +201,20 @@ public class ReportCreditController extends BaseController {
         if(CommonUtil.isEmpty(zfpType)){
             zfpType = "1";
         }
-        map.put("zfpType", zfpType);
         //获取企业类型
         String type = use.getCompanyType();
         if(COMPANYTYPE_CORE.equals(type)){
             //核心企业
             map.put("coreCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_SUPPLIER.equals(type)){
             //供应商
             map.put("supplierCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_MANAGEMENT.equals(type)){
             //资金方
             map.put("managementCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }
         String allAmount =  reportCreditService.getLoanBalance(map);
         Map m = new HashMap();
@@ -223,18 +239,20 @@ public class ReportCreditController extends BaseController {
         if(CommonUtil.isEmpty(zfpType)){
             zfpType = "1";
         }
-        map.put("zfpType", zfpType);
         //获取企业类型
         String type = use.getCompanyType();
         if(COMPANYTYPE_CORE.equals(type)){
             //核心企业
             map.put("coreCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_SUPPLIER.equals(type)){
             //供应商
             map.put("supplierCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }else if(COMPANYTYPE_MANAGEMENT.equals(type)){
             //资金方
             map.put("managementCompanyId", companyId);
+            map.put("zfpType", zfpType);
         }
         String allAmount =  reportCreditService.getReturnBalance(map);
         Map m = new HashMap();
@@ -344,16 +362,18 @@ public class ReportCreditController extends BaseController {
         Map addMap = new HashMap();
         addMap.put("name","已用额度");
         addMap.put("data",data);
+        addMap.put("stack","total");
         dataList.add(addMap);
         //开立额度数据对象
         Map subMap = new HashMap();
         subMap.put("name","可用额度");
         subMap.put("data",subData);
+        subMap.put("stack","total");
         dataList.add(subMap);
         Map result = new HashMap();
         result.put("dataList",dataList);
         result.put("dateList",dateList);
-        return AjaxResult.success(list);
+        return AjaxResult.success(result);
     }
 
     /**
@@ -392,7 +412,7 @@ public class ReportCreditController extends BaseController {
      * @return
      */
     @GetMapping("/getExpiredBalance")
-    public AjaxResult getExpiredBalance()
+    public AjaxResult getExpiredBalance(String zfpType)
     {
         //获取当前企业的编号
         LoginUser userInfo = tokenService.getLoginUser();
@@ -408,24 +428,25 @@ public class ReportCreditController extends BaseController {
         String endDate = DateUtils.getFetureDate(30);
         map.put("startDate",startDate);
         map.put("endDate",endDate);
-        //融信额度
-        String allAmount = "0";
-        if(COMPANYTYPE_TERRACE.equals(type)){
-            //平台
-            allAmount =  reportCreditService.getCreditLineAll(map);
-        }else if(COMPANYTYPE_CORE.equals(type)){
+        //默认反向
+        if(CommonUtil.isEmpty(zfpType)){
+            zfpType = "1";
+        }
+        if(COMPANYTYPE_CORE.equals(type)){
             //核心企业
+            map.put("zfpType",zfpType);
             map.put("coreCompanyId", companyId);
-            allAmount =  reportCreditService.getCreditLineAll(map);
         }else if(COMPANYTYPE_SUPPLIER.equals(type)){
             //供应商
+            map.put("zfpType",zfpType);
             map.put("supplierCompanyId", companyId);
-            allAmount =  reportCreditService.getSupplierCreditLineAll(map);
         }else if(COMPANYTYPE_MANAGEMENT.equals(type)){
             //资金方
+            map.put("zfpType",zfpType);
             map.put("managementCompanyId", companyId);
-            allAmount =  reportCreditService.getCreditLineAll(map);
         }
+        //融信额度
+        String allAmount =  reportCreditService.getExpiredBalance(map);
         Map m = new HashMap();
         m.put("allAmount",allAmount);
         return AjaxResult.success(m);
@@ -476,7 +497,7 @@ public class ReportCreditController extends BaseController {
      * @return
      */
     @GetMapping("/getCreditLineList")
-    public AjaxResult getCreditLineList(QueryRequest request)
+    public AjaxResult getCreditLineList(String zfpType, QueryRequest request)
     {
         //获取当前企业的编号
         LoginUser userInfo = tokenService.getLoginUser();
@@ -486,8 +507,13 @@ public class ReportCreditController extends BaseController {
         String companyId = use.getCompanyId();
         //获取企业类型
         String type = use.getCompanyType();
+        //默认反向
+        if(CommonUtil.isEmpty(zfpType)){
+            zfpType = "1";
+        }
         if(COMPANYTYPE_CORE.equals(type)){
             //核心企业
+            map.put("zfpType", zfpType);
             map.put("coreCompanyId", companyId);
         }
         IPage<Map> list =  reportCreditService.getCreditLineList(map,request);
@@ -514,7 +540,7 @@ public class ReportCreditController extends BaseController {
      * @return
      */
     @GetMapping("/getCreditLineNumList")
-    public AjaxResult getCreditLineNumList(QueryRequest request)
+    public AjaxResult getCreditLineNumList(String zfpType, QueryRequest request)
     {
         //获取当前企业的编号
         LoginUser userInfo = tokenService.getLoginUser();
@@ -524,8 +550,13 @@ public class ReportCreditController extends BaseController {
         String companyId = use.getCompanyId();
         //获取企业类型
         String type = use.getCompanyType();
+        //默认反向
+        if(CommonUtil.isEmpty(zfpType)){
+            zfpType = "1";
+        }
         if(COMPANYTYPE_CORE.equals(type)){
             //核心企业
+            map.put("zfpType", zfpType);
             map.put("coreCompanyId", companyId);
         }
         IPage<Map> list =  reportCreditService.getCreditLineNumList(map,request);
@@ -537,7 +568,7 @@ public class ReportCreditController extends BaseController {
      * @return
      */
     @GetMapping("/financeRecordMonth")
-    public AjaxResult financeRecordMonth(){
+    public AjaxResult financeRecordMonth(String zfpType, String dateType){
         //获取当前企业的编号
         LoginUser userInfo = tokenService.getLoginUser();
         SysUser use = userInfo.getSysUser();
@@ -545,22 +576,41 @@ public class ReportCreditController extends BaseController {
         String companyId = use.getCompanyId();
         //获取企业类型
         String type = use.getCompanyType();
+        //默认反向
+        if(CommonUtil.isEmpty(zfpType)){
+            zfpType = "1";
+        }
         //默认当年
         String  year = DateUtils.getDate().substring(0,4);
         //月份集合
-        List<String> dateList = getMonth();
+        List<String> dateList = new ArrayList<>();
+        if(DATE_WEEK.equals(dateType)){
+            //周
+            dateList = findDaysStr(DateUtils.getPastDate(7),DateUtils.dateTimeNow("yyyy-MM-dd"));
+        }else if(DATE_YEAR.equals(dateType)){
+            //年
+            dateList = getMonth();
+        }
         //数据集合
         List<Map> dataList = new ArrayList<>();
         //开立额度
         List<String> data = new ArrayList<>();
         for (String date : dateList) {
-            date = year.concat("-").concat(date).replace("月","");
             Map map = new HashMap();
             if(COMPANYTYPE_CORE.equals(type)){
                 //核心企业
+                map.put("zfpType", zfpType);
                 map.put("coreCompanyId", companyId);
             }
-            map.put("month",date);
+            if(DATE_YEAR.equals(dateType)){
+                date = date.replaceAll("月","");
+                date = year.concat("-").concat(CommonUtil.compare(date, "10") < 0 ? "0".concat(date) : date);
+                //年
+                map.put("month",date);
+            }else{
+                //周
+                map.put("date",date);
+            }
             //报销所含项目
             String amt = reportCreditService.financeRecordMonth(map);
             data.add(amt);
@@ -573,13 +623,21 @@ public class ReportCreditController extends BaseController {
         //还款额度
         List<String> returnData = new ArrayList<>();
         for (String date : dateList) {
-            date = year.concat("-").concat(date).replace("月","");
             Map map = new HashMap();
             if(COMPANYTYPE_CORE.equals(type)){
                 //核心企业
+                map.put("zfpType", zfpType);
                 map.put("coreCompanyId", companyId);
             }
-            map.put("month",date);
+            if(DATE_YEAR.equals(dateType)){
+                date = date.replaceAll("月","");
+                date = year.concat("-").concat(CommonUtil.compare(date, "10") < 0 ? "0".concat(date) : date);
+                //年
+                map.put("returnMonth",date);
+            }else{
+                //周
+                map.put("returnDate",date);
+            }
             map.put("applyStatus","01");
             //报销所含项目
             String amt = reportCreditService.financeRecordMonth(map);
@@ -665,7 +723,8 @@ public class ReportCreditController extends BaseController {
         List<String> dateList = new ArrayList<>();
         //循环添加所有月份
         for(int i = 1; i < 13; i++){
-            dateList.add(i + "月");
+            String date = i + "月";
+            dateList.add(date);
         }
         return dateList;
     }

+ 3 - 0
sc-service/src/main/resources/mapper/common/ReportCompanyMapper.xml

@@ -26,6 +26,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="type != null  and type != ''">
             AND scy_type = #{type}
         </if>
+        <if test="date != null  and date != ''">
+            AND DATE_FORMAT(create_time, '%Y-%m-%d') &lt;= #{date}
+        </if>
     </select>
 
     <!--已融资供应商数量-->

+ 15 - 3
sc-service/src/main/resources/mapper/common/ReportCreditMapper.xml

@@ -231,6 +231,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="managementCompanyId != null  and managementCompanyId != ''">
             AND zfp_management_id = #{managementCompanyId}
         </if>
+        <if test="startDate != null  and startDate != ''">
+            AND zfi_expire_date BETWEEN #{startDate} AND #{endDate}
+        </if>
+        <if test="zfpType != null  and zfpType != ''">
+            AND zfp_type = #{zfpType}
+        </if>
 
     </select>
 
@@ -256,8 +262,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="paramMap.coreCompanyId != null  and paramMap.coreCompanyId != ''">
             AND zfi_core_id = #{paramMap.coreCompanyId}
         </if>
-        <if test="zfpType != null  and zfpType != ''">
-            AND zfp_type = #{zfpType}
+        <if test="paramMap.zfpType != null  and paramMap.zfpType != ''">
+            AND zfp_type = #{paramMap.zfpType}
         </if>
         GROUP BY zfp_management_id
     </select>
@@ -285,6 +291,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <if test="paramMap.coreCompanyId != null  and paramMap.coreCompanyId != ''">
             AND zfi_core_id = #{paramMap.coreCompanyId}
         </if>
+        <if test="paramMap.zfpType != null  and paramMap.zfpType != ''">
+            AND zfp_type = #{paramMap.zfpType}
+        </if>
         GROUP BY zfp_management_id
     </select>
 
@@ -312,7 +321,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             AND zfr_apply_status = #{applyStatus}
         </if>
         <if test="month != null  and month != ''">
-            AND DATE_FORMAT(zfi_sign_date, '%Y-%c') = #{month}
+            AND DATE_FORMAT(zfi_sign_date, '%Y-%m') = #{month}
+        </if>
+        <if test="returnMonth != null  and returnMonth != ''">
+            AND DATE_FORMAT(zfr_pay_date, '%Y-%m') = #{returnMonth}
         </if>
         <if test="returnDate != null  and returnDate != ''">
             AND DATE_FORMAT(zfr_pay_date, '%Y-%m-%d') = #{returnDate}