Bladeren bron

运营绩效 导出

zhaoxian 2 jaren geleden
bovenliggende
commit
8cf1ab060a

+ 125 - 0
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/controller/KuaishouOperationReportController.java

@@ -4,6 +4,8 @@ import cn.com.ctop.common.module.entity.AccountCompensation;
 import cn.com.ctop.common.module.service.IAccountCompensationService;
 import cn.com.ctop.common.module.service.ISysUserService;
 import cn.com.ctop.common.module.utils.Check;
+import cn.com.ctop.common.module.utils.ExportExcelUtils;
+import cn.com.ctop.common.module.utils.HttpUtils;
 import cn.com.ctop.kuaishou.modules.report.entity.KuaishouOperationReport;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouOperationReportService;
 import com.alibaba.fastjson.JSONObject;
@@ -12,6 +14,7 @@ import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.entity.SysUser;
 import org.jeecg.modules.system.service.ISysRoleService;
@@ -24,6 +27,8 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 import org.springframework.web.bind.annotation.RestController;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
 import java.math.BigDecimal;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -254,4 +259,124 @@ public class KuaishouOperationReportController {
         return Result.error("修改失败");
     }
 
+    /**
+     * 导出应季月度消耗
+     */
+    @GetMapping("/queryMonthlyDataExcel")
+    public void queryMonthlyDataExcel(HttpServletResponse response, String mediaId, Integer time, String role, String userId) {
+        try {
+            Result<Object> result = null;
+            if (mediaId.equals("1")) {
+                result = kuaishouOperationReportService.queryToutiaoMonthlyData(time, role, userId, 1, 99999);
+            } else {
+                result = kuaishouOperationReportService.queryKuaishouMonthlyData(time, role, userId, 1, 99999);
+            }
+            List<List<Object>> excelList = new ArrayList<>();
+            PageInfo pageInfo = (PageInfo) result.getResult();
+            if (!Check.isNull(pageInfo)) {
+                List<JSONObject> list = pageInfo.getList();
+                if (!list.isEmpty()) {
+                    list.forEach(data -> {
+                        List<Object> temp = new ArrayList<>();
+                        temp.add(data.getString("userName"));
+                        temp.add(data.getString("roleName"));
+                        temp.add(data.getString("upTime"));
+                        temp.add(data.getString("1totalCharge"));
+                        temp.add(data.getString("2totalCharge"));
+                        temp.add(data.getString("3totalCharge"));
+                        temp.add(data.getString("1KFCharge"));
+                        temp.add(data.getString("2KFCharge"));
+                        temp.add(data.getString("3KFCharge"));
+                        temp.add(data.getString("1FWCharge"));
+                        temp.add(data.getString("2FWCharge"));
+                        temp.add(data.getString("3FWCharge"));
+                        temp.add(data.getString("quitTime"));
+                        excelList.add(temp);
+                    });
+                }
+                List<Integer> monthInt = kuaishouOperationReportService.getMonthInt(time);
+                OutputStream os = response.getOutputStream();
+                ExportExcelUtils eeu = new ExportExcelUtils();
+                XSSFWorkbook workbook = new XSSFWorkbook();
+                String[] titles = {"运营", "岗位", "晋升时间",
+                        monthInt.get(0) + "月总消耗", monthInt.get(1) + "月总消耗", monthInt.get(2) + "月总消耗",
+                        monthInt.get(0) + "月框返消耗", monthInt.get(1) + "月框返消耗", monthInt.get(2) + "月框返消耗",
+                        monthInt.get(0) + "月服务消耗", monthInt.get(1) + "月服务消耗", monthInt.get(2) + "月服务消耗", "离职时间"};
+                eeu.exportExcelForAttendance(workbook, 0, "运营数据", titles, excelList);
+                HttpUtils.setResponseHeader(response, "clockIn.xlsx");
+                workbook.write(os);
+                os.flush();
+                os.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+    /**
+     * 查询季度消耗 导出
+     * 条件:日期,岗位,人员
+     */
+    @ApiOperation(value = "运营绩效-分页列表查询", notes = "运营绩效-分页列表查询")
+    @GetMapping(value = "/queryQuarterlyDataExcel")
+    public void queryQuarterlyDataExcel(HttpServletResponse response, String mediaId, Integer time, String role, String userId) {
+        try {
+            Result<Object> result = null;
+            if ("1".equals(mediaId)) {
+                result = kuaishouOperationReportService.queryToutiaoQuarterlyCharge(time, role, userId, 1, 99999);
+            } else {
+                result = kuaishouOperationReportService.queryKuaishouQuarterlyCharge(time, role, userId, 1, 99999);
+            }
+
+            List<List<Object>> excelList = new ArrayList<>();
+            List<JSONObject> list = (List<JSONObject>) result.getResult();
+            if (!Check.isNull(list)) {
+                if (!list.isEmpty()) {
+                    list.forEach(data -> {
+                        List<Object> temp = new ArrayList<>();
+                        temp.add(data.getString("userName"));
+                        temp.add(data.getString("roleName"));
+                        temp.add(data.getString("upTime"));
+                        temp.add(data.getString("quitTime"));
+                        temp.add(data.getString("totalCharge"));
+                        temp.add(data.getString("KFCharge"));
+                        temp.add(data.getString("FWCharge"));
+                        temp.add(data.getString("KFChargeIsOk"));
+                        temp.add(data.getString("manageCharge"));
+                        temp.add(data.getString("assistantCharge"));
+                        temp.add(data.getString("FWChargeCommission"));
+                        temp.add(data.getString("KFChargeCommission"));
+                        temp.add(data.getString("manageChargeCommission"));
+                        temp.add(data.getString("operateCompensation"));
+                        temp.add(data.getString("manageCompensation"));
+                        temp.add(data.getString("FWChargeIsOk"));
+                        temp.add(data.getString("compMoney"));
+                        temp.add(data.getString("paySalary"));
+                        temp.add(data.getString("putMoney"));
+                        temp.add(data.getString("paySalaryRatio"));
+                        temp.add(data.getString("finalPutMoney"));
+                        excelList.add(temp);
+                    });
+                }
+                List<Integer> monthInt = kuaishouOperationReportService.getMonthInt(time);
+                OutputStream os = response.getOutputStream();
+                ExportExcelUtils eeu = new ExportExcelUtils();
+                XSSFWorkbook workbook = new XSSFWorkbook();
+                String[] titles = {"运营", "岗位", "晋升时间", "离职时间",
+                        "Q" + time + "总消耗", "Q" + time + "框返消耗", "Q" + time + "服务消耗", "框返消耗是否满足30W",
+                        "管理消耗", "助理消耗", "服务消耗提成", "框返消耗提成",
+                        "管理消耗提成", "运营赔付扣罚比例", "经理/总监赔付扣罚比例", "是否达标",
+                        "扣减金额", "是否符合发放", "发放金额", "发放系数", "最终发放金额"
+                };
+                eeu.exportExcelForAttendance(workbook, 0, "运营绩效", titles, excelList);
+                HttpUtils.setResponseHeader(response, "clockIn.xlsx");
+                workbook.write(os);
+                os.flush();
+                os.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
 }

+ 3 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/IKuaishouOperationReportService.java

@@ -4,6 +4,8 @@ import cn.com.ctop.kuaishou.modules.report.entity.KuaishouOperationReport;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.common.api.vo.Result;
 
+import java.util.List;
+
 /**
  * 运营绩效
  *
@@ -24,5 +26,5 @@ public interface IKuaishouOperationReportService extends IService<KuaishouOperat
 
     Result<Object> queryKuaishouQuarterlyCharge(Integer time, String role, String userId, Integer pageNo, Integer pageSize) throws Exception;
 
-
+    List<Integer> getMonthInt(Integer time);
 }

+ 22 - 1
jeecg-boot-module-system/src/main/java/cn/com/ctop/kuaishou/modules/report/service/impl/KuaishouOperationReportServiceImpl.java

@@ -24,6 +24,8 @@ import java.math.BigDecimal;
 import java.text.ParseException;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.Comparator;
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
@@ -133,6 +135,15 @@ public class KuaishouOperationReportServiceImpl extends ServiceImpl<KuaishouOper
         if (!Check.isNull(onJobUserIds)) {
             dataList.addAll(getTtOnJobUserData(onJobUserIds, time, quarterMap));
         }
+        //后端代码排序
+        if (!Check.isNull(dataList)) {
+            Collections.sort(dataList, new Comparator<JSONObject>() {
+                @Override
+                public int compare(JSONObject o1, JSONObject o2) {
+                    return o2.getDouble("totalCharge").compareTo(o1.getDouble("totalCharge"));
+                }
+            });
+        }
         return Result.ok(dataList);
     }
 
@@ -707,6 +718,15 @@ public class KuaishouOperationReportServiceImpl extends ServiceImpl<KuaishouOper
         if (!Check.isNull(onJobUserIds)) {
             dataList.addAll(getOnJobUserData(onJobUserIds, time, quarterMap));
         }
+        //后端代码排序
+        if (!Check.isNull(dataList)) {
+            Collections.sort(dataList, new Comparator<JSONObject>() {
+                @Override
+                public int compare(JSONObject o1, JSONObject o2) {
+                    return o2.getDouble("totalCharge").compareTo(o1.getDouble("totalCharge"));
+                }
+            });
+        }
         return Result.ok(dataList);
     }
 
@@ -1232,7 +1252,8 @@ public class KuaishouOperationReportServiceImpl extends ServiceImpl<KuaishouOper
     /**
      * 获取每季度月份1~12
      */
-    private static List<Integer> getMonthInt(Integer time) {
+    @Override
+    public List<Integer> getMonthInt(Integer time) {
         List<Integer> list = new ArrayList<>();
         if (1 == time) {
             for (int i = 1; i <= 3; i++) {