From 2562e13a8db342cc1e23e17b8a26d84ce314f9eb Mon Sep 17 00:00:00 2001
From: xiaoyong931011 <15274802129@163.com>
Date: Fri, 13 Aug 2021 12:04:57 +0800
Subject: [PATCH] 20210813

---
 zq-erp/src/main/java/com/matrix/system/hive/statistics/AchieveAction.java |   82 +++++++++++++++++++++++++++++-----------
 1 files changed, 59 insertions(+), 23 deletions(-)

diff --git a/zq-erp/src/main/java/com/matrix/system/hive/statistics/AchieveAction.java b/zq-erp/src/main/java/com/matrix/system/hive/statistics/AchieveAction.java
index 98aaef4..354a30d 100644
--- a/zq-erp/src/main/java/com/matrix/system/hive/statistics/AchieveAction.java
+++ b/zq-erp/src/main/java/com/matrix/system/hive/statistics/AchieveAction.java
@@ -9,8 +9,10 @@
 import com.matrix.core.tools.WebUtil;
 import com.matrix.core.tools.excl.ExcelSheetPO;
 import com.matrix.core.tools.excl.ExcelVersion;
+import com.matrix.system.common.bean.CustomerDataDictionary;
 import com.matrix.system.common.bean.SysUsers;
-import com.matrix.system.common.constance.AppConstance;
+import com.matrix.system.common.dao.CustomerDataDictionaryDao;
+import com.matrix.system.common.tools.DataAuthUtil;
 import com.matrix.system.common.tools.ResponseHeadUtil;
 import com.matrix.system.hive.action.util.QueryUtil;
 import com.matrix.system.hive.bean.AchieveNew;
@@ -18,8 +20,6 @@
 import com.matrix.system.hive.dto.AchieveNewStatisticsDto;
 import com.matrix.system.hive.plugin.util.CollectionUtils;
 import com.matrix.system.hive.service.AchieveNewService;
-import com.matrix.system.hive.service.SysOrderItemService;
-import com.matrix.system.hive.service.SysOrderService;
 import com.matrix.system.hive.vo.AchieveNewStatisticsVo;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Controller;
@@ -50,12 +50,6 @@
     private AchieveNewService achieveNewService;
 
     @Autowired
-    private SysOrderService sysOrderService;
-
-    @Autowired
-    private SysOrderItemService sysOrderItemService;
-
-    @Autowired
     private AchieveNewDao achieveNewDao;
 
 
@@ -82,9 +76,9 @@
      */
     @RequestMapping(value = "/findSumDailyInfoNew")
     public @ResponseBody
-    AjaxResult findSumDailyInfoNew(AchieveNew achieveNew, PaginationVO pageVo) {
+    AjaxResult findSumDailyInfoNew(@RequestBody  AchieveNew achieveNew) {
         SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
-        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){
+         if (!DataAuthUtil.hasAllShopAuth()) {
             achieveNew.setShopId(sysUsers.getShopId());
         }
         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, achieveNewService.findSumDailyInfoNew(achieveNew, null),
@@ -98,11 +92,16 @@
      */
     @RequestMapping(value = "/findDailyInfoNew")
     public @ResponseBody
-    AjaxResult findDailyInfoNew(AchieveNew achieveNew, PaginationVO pageVo) {
+    AjaxResult findDailyInfoNew(@RequestBody  AchieveNew achieveNew) {
         SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
-        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){
+        achieveNew.setCompanyId(sysUsers.getCompanyId());
+         if (!DataAuthUtil.hasAllShopAuth()) {
             achieveNew.setShopId(sysUsers.getShopId());
         }
+        PaginationVO pageVo = new PaginationVO();
+
+        pageVo.setOffset(achieveNew.getOffset());
+        pageVo.setLimit(achieveNew.getLimit());
         pageVo.setSort("datatime");
         pageVo.setOrder("desc");
         AjaxResult result = new AjaxResult(AjaxResult.STATUS_SUCCESS, achieveNewService.findDayFlow(achieveNew, pageVo),
@@ -122,7 +121,7 @@
                 , "服务提成", "人头", "项目个数", "服务时间", "订单类型"};
         orderSheet.setHeaders(header);
         SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
-        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){
+         if (!DataAuthUtil.hasAllShopAuth()) {
             queryDto.setShopId(sysUsers.getShopId());
         }
         queryDto.setCompanyId(sysUsers.getCompanyId());
@@ -159,18 +158,47 @@
         com.matrix.core.tools.excl.ExcelUtil.createWorkbookAtOutStream(ExcelVersion.V2007, res, os, true);
     }
 
+    @Autowired
+    CustomerDataDictionaryDao dataDictionaryDao;
+
     @RequestMapping(value = "/exportDailyInfoNew")
     public void exportDailyInfoNew(ModelMap model, HttpServletRequest request, HttpServletResponse response, AchieveNew achieveNew) throws IOException {
-        //这里是从数据库里查数据并组装成我们想要的数据结构的过程
+        SysUsers sysUsers = WebUtil.getSessionAttribute(MatrixConstance.LOGIN_KEY);
+
+        List<CustomerDataDictionary> achieveTyps = dataDictionaryDao.selectByParentCode("YJLX", sysUsers.getCompanyId());
+
         List<ExcelSheetPO> res = new ArrayList<>();
         ExcelSheetPO orderSheet = new ExcelSheetPO();
-        String title = "每日单据明细";
+        String title = "员工业绩报表";
         orderSheet.setSheetName(title);
         orderSheet.setTitle(title);
-        String[] header = {"年", "月", "日", "订单编号", "订单类型", "会员姓名", "项目名称", "订单金额", "订单业绩", "收款方式", "业绩类型", "员工", "本金消耗", "赠消", "提成", "人头", "项目个数", "项目时间", "顾问", "门店"};
+        List<String> headerList =new ArrayList();
+        headerList.add("订单时间");
+        headerList.add("订单编号");
+        headerList.add("订单类型");
+        headerList.add("会员姓名");
+        headerList.add("产品");
+        headerList.add("业绩规则");
+        headerList.add("产品分类");
+        headerList.add("订单金额");
+        headerList.add("现金");
+        headerList.add("划扣");
+        headerList.add("员工");
+        achieveTyps.forEach(item->{headerList.add(item.getValue());});
+        headerList.add("本金消耗");
+        headerList.add("赠消");
+        headerList.add("提成");
+        headerList.add("人头");
+        headerList.add("项目个数");
+        headerList.add("项目时间");
+        headerList.add("顾问");
+        headerList.add("门店");
+
+        String[] header =  headerList.toArray(new String[headerList.size()]);
+
+
         orderSheet.setHeaders(header);
-        SysUsers sysUsers = (SysUsers) WebUtil.getSession().getAttribute(MatrixConstance.LOGIN_KEY);
-        if(!AppConstance.ZONGDIAN.equals(sysUsers.getShopName())){
+         if (!DataAuthUtil.hasAllShopAuth()) {
             achieveNew.setShopId(sysUsers.getShopId());
         }
 
@@ -180,17 +208,25 @@
         if (dataList.size() > 0) {
             for (AchieveNew item : dataList) {
                 List<Object> temp = new ArrayList<>();
-                temp.add(item.getYear());
-                temp.add(item.getMonth());
-                temp.add(item.getDay());
+                temp.add(DateUtil.dateFormatStr(item.getDatatime(), DateUtil.DATE_FORMAT_MM));
                 temp.add(item.getOrderNo());
                 temp.add(item.getOrderType());
                 temp.add(item.getVipName());
                 temp.add(item.getProName());
+                temp.add(item.getAchieveRuleName());
+                temp.add(item.getCateName());
                 temp.add(item.getZkTotal());
                 temp.add(item.getGoodsCash());
-                temp.add(item.getPayMethod());
+                temp.add(item.getCardCash());
                 temp.add(item.getMeiliao());
+                //动态导出列----
+                achieveTyps.forEach(item2->{
+                    if(item2.getValue().equals(item.getAchieveType())){
+                        temp.add(item.getGoodsCash());
+                    }else{
+                        temp.add("");
+                    }
+                 });
                 temp.add(item.getHisConsume());
                 temp.add(item.getFreeConsume());
                 temp.add(item.getProjPercentage());

--
Gitblit v1.9.1