yangzian 3 rokov pred
rodič
commit
fff85aedc8

+ 54 - 2
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -5,6 +5,7 @@ import org.slf4j.LoggerFactory;
 import org.springframework.util.StringUtils;
 
 import java.beans.PropertyEditorSupport;
+import java.sql.SQLOutput;
 import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
@@ -1089,6 +1090,7 @@ public class DateUtils extends PropertyEditorSupport {
         return sdf.format(calendar.getTime());
     }
 
+
     public static Date addDay(Date date, int day) {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);
@@ -1924,11 +1926,61 @@ public class DateUtils extends PropertyEditorSupport {
 
 
 
+    /**
+     * 根据本阶段日期 获取上阶段 开始 和 截至 日期
+     * @param startTime 本阶段开始时间
+     * @param endTime 本阶段截至时间
+     * @return
+     * @throws ParseException
+     */
+    public static Map<String,String> getStartEndTime(String startTime,String endTime) throws ParseException {
+        Map<String,String> timeMap = new HashMap();
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date start = sdf.parse(startTime);
+        Date end = sdf.parse(endTime);
+        //相差天数
+        Long daysBetween = (end.getTime()-start.getTime())/(60*60*24*1000);
+        String lastTimeStart = getSubtractTime(start, daysBetween.intValue());
+        String lastTimeEnd = getSubtractTime(end, daysBetween.intValue());
+        timeMap.put("lastTimeStart",lastTimeStart);
+        timeMap.put("lastTimeEnd",lastTimeEnd);
+        timeMap.put("daysBetween",daysBetween.toString());
+        return timeMap;
+    }
+
+    /**
+     * 返回 日期 - 天数 的string 日期
+     * @param time 时间
+     * @param daysBetween 天数
+     * @return
+     */
+    public static String getSubtractTime(Date time,Integer daysBetween){
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Calendar rightNow  = Calendar.getInstance();
+        rightNow .setTime(time);
+        if (daysBetween.intValue() > 0){
+            rightNow .add(Calendar.DAY_OF_YEAR,-daysBetween.intValue()-1);//日期加 相差的 天数 再 -1
+        }else {
+            rightNow .add(Calendar.DAY_OF_YEAR,-1);//日期 -1
+        }
+        Date rightNowTime = rightNow .getTime();
+        String nowTime = sdf.format(rightNowTime);
+        return nowTime;
+    }
+
+
+
 
 
-    public static void main(String[] args) {
+    public static void main(String[] args) throws Exception{
         //System.out.println(DateUtils.getFirstDayByMonth());
-        System.out.println(intDateToString("20210101"));
+        //System.out.println(intDateToString("20210101"));
+
+       // SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMMdd");
+        //System.out.println(sdf1.parse("20220115"));
+
+        Double  a = 3.268890;
+        System.out.println(String.format("%.3f", a));
 
 
     }

+ 1 - 0
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/config/shiro/ShiroConfig.java

@@ -245,6 +245,7 @@ public class ShiroConfig {
         filterChainDefinitionMap.put("/stare/**", "anon");
         filterChainDefinitionMap.put("/boss/**", "anon");
         filterChainDefinitionMap.put("/external/materialCollection/*", "anon");
+        filterChainDefinitionMap.put("/kuaiShouOpreate/**", "anon");
 
         // 添加自己的过滤器并且取名为jwt
         Map<String, Filter> filterMap = new HashMap<>(1);

+ 234 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/KuaiShouMaterialStareController.java

@@ -0,0 +1,234 @@
+package org.jeecg.ctop.material.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.ctop.material.service.MaterialStareService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletResponse;
+import java.util.Set;
+
+/**
+ * 快手-运营数据盯盘
+ */
+@Slf4j
+@RestController
+@RequestMapping("/kuaiShouOpreate/kuaiShouMaterialStareController")
+public class KuaiShouMaterialStareController {
+
+
+    @Autowired
+    MaterialStareService materialStareService;
+
+
+    /**
+     *
+     * @description:数据总览-快手
+     *
+     * @param mediaType 媒体类型 1-头条 2-快手
+     * @param type 查询类型 1-汇总 2-运营个人
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @author: zianY
+     * @time: 2022/2/15
+     */
+    @GetMapping("/kuaiShousumData")
+    public Result<JSONObject> kuaiShousumData(@RequestParam(name="mediaType",defaultValue = "2") String mediaType,
+                                              @RequestParam(name="type") String type,
+                                              @RequestParam(name="startTime") String startTime,
+                                              @RequestParam(name="endTime") String endTime,
+                                              @RequestParam(name="userId") String userId) {
+        return materialStareService.kuaiShousumData(mediaType, type, startTime, endTime, userId);
+    }
+
+
+    /**
+     *
+     * @description: 快手-运营组数据
+     *
+     * @param mediaType 媒体类型 1-头条 2-快手
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     * @author: zianY
+     * @time: 2022/2/15
+     */
+    @GetMapping("/kuaiShouOperateDateTotal")
+    public Result<JSONObject> kuaiShouOperateDateTotal(@RequestParam(name="mediaType") String mediaType,
+                                              @RequestParam(name="startTime") String startTime,
+                                              @RequestParam(name="endTime") String endTime,
+                                              @RequestParam(name="userId") String userId) {
+
+        return materialStareService.kuaiShouOperateDateTotal(mediaType, startTime, endTime, userId);
+    }
+
+
+    /**
+     *
+     * @description: 运营数据详情
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     * @author: zianY
+     * @time: 2022/2/16
+     */
+    @GetMapping("/getKuaiShouOperateInfo")
+    public Result<JSONObject> getKuaiShouOperateInfo(@RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
+                                                       @RequestParam(name="pageSize",defaultValue = "5") int pageSize,
+                                              @RequestParam(name="startTime") String startTime,
+                                              @RequestParam(name="endTime") String endTime,
+                                              @RequestParam(name="userId") String userId) {
+        return materialStareService.getKuaiShouOperateInfo(pageNum, pageSize,startTime, endTime, userId);
+    }
+
+    @GetMapping("/exportKuaiShouOperateInfo")
+    public Result<JSONObject> exportKuaiShouOperateInfo(@RequestParam(name="startTime") String startTime,
+                                              @RequestParam(name="endTime") String endTime,
+                                              @RequestParam(name="userId") String userId,
+                                                        HttpServletResponse response) {
+        return materialStareService.exportKuaiShouOperateInfo(startTime, endTime, userId,response);
+    }
+
+
+    /**
+     *
+     * @description:运营数据-项目列表
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     * @author: zianY
+     * @time: 2022/2/17
+     */
+    @GetMapping("/getKuaiShouOperateProjectInfo")
+    public Result<JSONObject> getKuaiShouOperateProjectInfo(@RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
+                                                     @RequestParam(name="pageSize",defaultValue = "10") int pageSize,
+                                                     @RequestParam(name="startTime") String startTime,
+                                                     @RequestParam(name="endTime") String endTime,
+                                                     @RequestParam(name="userId") String userId) {
+
+        return materialStareService.getKuaiShouOperateProjectInfo(pageNum, pageSize,startTime, endTime, userId);
+    }
+
+
+
+    /**
+     *
+     * @description:运营数据-账户列表
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param startTime
+     * @param endTime
+     * @param projectId
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     * @author: zianY
+     * @time: 2022/2/18
+     */
+    @GetMapping("/getKuaiShouOperateAccountInfo")
+    public Result<JSONObject> getKuaiShouOperateAccountInfo(@RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
+                                                     @RequestParam(name="pageSize",defaultValue = "1000") int pageSize,
+                                                     @RequestParam(name="startTime") String startTime,
+                                                     @RequestParam(name="endTime") String endTime,
+                                                     @RequestParam(name="projectId",required = false) String projectId,
+                                                     @RequestParam(name="userId") String userId) {
+
+
+        return materialStareService.getKuaiShouOperateAccountInfo(pageNum, pageSize,startTime, endTime,projectId, userId);
+    }
+
+
+    /**
+     *
+     * @description: 查询账户余额 以及 账户状态 和 消耗
+     *
+     * @param accountId
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     * @author: zianY
+     * @time: 2022/2/21 14:39
+     */
+    @GetMapping("/getKuaiShouAccountInfo")
+    public Result<JSONObject> getKuaiShouAccountInfo(@RequestParam(name="accountId") long accountId) {
+        return materialStareService.getKuaiShouAccountInfo(accountId);
+    }
+
+
+    /**
+     *
+     * @description: 账户 折线图 查询时间为当天查询时报;查询时间为多天 查询日报
+     *
+     * @param accountId
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     * @author: zianY
+     * @time: 2022/2/21
+     */
+    @GetMapping("/getKuaiShouAccountInfoBrokenLine")
+    public Result<JSONObject> getKuaiShouAccountInfoBrokenLine(@RequestParam(name="accountId") long accountId,
+                                                     @RequestParam(name="startTime") String startTime,
+                                                     @RequestParam(name="endTime") String endTime) {
+        return materialStareService.getKuaiShouAccountInfoBrokenLine(accountId,startTime,endTime);
+    }
+
+
+
+    /**
+     *
+     * @description: 快手 账户 素材上新-有效-爆款
+     *
+     * @param accountId
+     * @param searchType searchType:查询类型  0-全部 1-上新 2-有效 3-爆款
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result<com.alibaba.fastjson.JSONObject>
+     * @author: zianY
+     * @time: 2022/2/21
+     */
+    @GetMapping("/getKuaiShouAccountMaterialNewAndEffectAndFaddish")
+    public Result<JSONObject> getKuaiShouAccountMaterialNewAndEffectAndFaddish(@RequestParam(name="accountId") long accountId,
+                                                                               @RequestParam(name="searchType") String searchType,
+                                                                               @RequestParam(name="startTime") String startTime,
+                                                                               @RequestParam(name="endTime") String endTime,
+                                                                               @RequestParam(name="pageNum",defaultValue = "1") Integer pageNum,
+                                                                               @RequestParam(name="pageSize",defaultValue = "10") Integer pageSize) {
+        return materialStareService.getKuaiShouAccountMaterialNewAndEffectAndFaddish(accountId,searchType,startTime,endTime,pageNum,pageSize);
+    }
+
+
+
+    /**
+     *
+     * @description: 查询账户饼图数据信息 分版位;年龄;性别
+     *
+     * @param accountId
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/22 10:50
+     */
+    @GetMapping("/getKuaiShouAccountPieChar")
+    public Result getKuaiShouAccountPieChar(@RequestParam(name="accountId") long accountId,
+                                            @RequestParam(name="startTime") String startTime,
+                                            @RequestParam(name="endTime") String endTime) {
+        return materialStareService.getKuaiShouAccountPieChar(accountId,startTime,endTime);
+    }
+
+
+
+
+
+}

+ 0 - 42
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/controller/MaterialStareController.java

@@ -1,42 +0,0 @@
-package org.jeecg.ctop.material.controller;
-
-import com.alibaba.fastjson.JSONObject;
-import lombok.extern.slf4j.Slf4j;
-import org.jeecg.common.api.vo.Result;
-import org.jeecg.ctop.material.service.MaterialStareService;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-
-import java.util.Set;
-
-/**
- * 盯盘接口
- */
-@Slf4j
-@RestController
-@RequestMapping("/stare")
-public class MaterialStareController {
-
-
-    @Autowired
-    MaterialStareService materialStareService;
-
-    /**
-     * 数据总览
-     */
-    @PostMapping("/sumData")
-    public Result<JSONObject> sumData(@RequestBody JSONObject params) {
-        Result<Set<JSONObject>> result = new Result<>();
-        return materialStareService.sumData(params.getInteger("mediaId"),
-                params.getInteger("userType"),
-                params.getString("userId"),
-                params.getString("startDate"),
-                params.getString("endDate"),
-                params.getInteger("type"));
-    }
-
-
-}

+ 59 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouAccountPieVo.java

@@ -0,0 +1,59 @@
+package org.jeecg.ctop.material.entity.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 盯盘- 账户维度 数据  环形图
+ * zian Y
+ * 2022/2/16
+ **/
+
+@Data
+public class KuaiShouAccountPieVo implements Serializable {
+
+
+    @ApiModelProperty(value = "版位")
+    private String adScene;
+
+    @ApiModelProperty(value = "年龄段落")
+    private String ageSegment;
+
+    @ApiModelProperty(value = "性别")
+    private String gender;
+
+    @ApiModelProperty(value = "花费")
+    private Double cost;
+
+    @ApiModelProperty(value = "激活数")
+    private Integer activation;
+
+    @ApiModelProperty(value = "激活成本")
+    private Double activationPrice;
+
+    @ApiModelProperty(value = "ROI")
+    private Double eventPayRoi;
+
+    @ApiModelProperty(value = "付费次数")
+    private Integer eventPay;
+
+    @ApiModelProperty(value = "付费成本")
+    private Double eventPayCost;
+
+    @ApiModelProperty(value = "首日付费金额")
+    private Double eventPayPurchaseAmountFirstDay;
+
+    @ApiModelProperty(value = "次留数")
+    private Integer eventNextDayStay;
+
+    @ApiModelProperty(value = "次留")
+    private String leave;
+
+
+
+
+
+}

+ 118 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateAccountVo.java

@@ -0,0 +1,118 @@
+package org.jeecg.ctop.material.entity.vo;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 盯盘-运营数据 账户维度
+ * zian Y
+ * 2022/2/16
+ **/
+
+@Data
+public class KuaiShouOperateAccountVo {
+
+
+    @ApiModelProperty(value = "账户id")
+    private long accountId;
+
+    @ApiModelProperty(value = "总花费")
+    private Double totalCost;
+
+    private String projectId;
+    private String projectName;
+
+    @ApiModelProperty(value = "运营姓名")
+    private String userName;
+
+    @ApiModelProperty(value = "激活数")
+    private Integer activation;
+
+    @ApiModelProperty(value = "激活单价")
+    private String activationPrice;
+
+    @ApiModelProperty(value = "次留")
+    private String leave;
+
+    @ApiModelProperty(value = "付费次数")
+    private Integer eventPay;
+
+    @ApiModelProperty(value = "付费成本")
+    private String eventPayCost;
+
+    @ApiModelProperty(value = "付费率")
+    private String eventPayRate;
+
+    @ApiModelProperty(value = "新增付费人数")
+    private Integer eventNewUserPay;
+
+    @ApiModelProperty(value = "新增付费成本")
+    private String eventNewUserPayCost;
+
+    @ApiModelProperty(value = "新增付费率")
+    private String eventNewUserPayRate;
+
+    @ApiModelProperty(value = "唤起应用数")
+    private Integer eventAppInvoked;
+
+    @ApiModelProperty(value = "唤起应用成本")
+    private String eventAppInvokedCost;
+
+    @ApiModelProperty(value = "注册数")
+    private Integer eventRegister;
+
+    @ApiModelProperty(value = "注册成本")
+    private String eventRegisterCost;
+
+    @ApiModelProperty(value = "关键行为数")
+    private Integer keyAction;
+
+    @ApiModelProperty(value = "关键行为成本")
+    private String keyActionCost;
+
+    @ApiModelProperty(value = "关键行为率")
+    private String keyActionRate;
+
+    @ApiModelProperty(value = "首日付费金额")
+    private String eventPayPurchaseAmountFirstDay;
+
+    @ApiModelProperty(value = "首日ROI")
+    private String eventPayFirstDayRoi;
+
+    @ApiModelProperty(value = "表单提交数")
+    private Integer formCount;
+
+    @ApiModelProperty(value = "表单提交单价")
+    private String formCountPrice;
+
+    @ApiModelProperty(value = "有效视频数量")
+    private Integer newEffectNum;
+
+    @ApiModelProperty(value = "上新视频数量")
+    private Integer newVideoNum;
+
+    @ApiModelProperty(value = "爆款视频数量")
+    private Integer newHotNum;
+
+    @ApiModelProperty(value = "封面曝光数")
+    private Integer photoShow;
+
+    @ApiModelProperty(value = "封面点击数")
+    private Integer photoClick;
+
+
+
+
+
+
+    @ApiModelProperty(value = "环比")
+    private Double yearOnYear;
+
+    @ApiModelProperty(value = "同比")
+    private Double equallyRate;
+
+
+
+
+
+}

+ 109 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateProjectVo.java

@@ -0,0 +1,109 @@
+package org.jeecg.ctop.material.entity.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 盯盘-运营数据 项目维度
+ * zian Y
+ * 2022/2/16
+ **/
+
+@Data
+public class KuaiShouOperateProjectVo {
+
+
+    @ApiModelProperty(value = "账户数量")
+    private Integer accountNum;
+
+    @ApiModelProperty(value = "总花费")
+    private Double totalCost;
+
+    private String projectId;
+    private String projectName;
+
+    @ApiModelProperty(value = "用户数量")
+    private Integer userNum;
+
+    @ApiModelProperty(value = "激活数")
+    private Integer activation;
+
+    @ApiModelProperty(value = "激活单价")
+    private String activationPrice;
+
+    @ApiModelProperty(value = "次留")
+    private String leave;
+
+    @ApiModelProperty(value = "付费次数")
+    private Integer eventPay;
+
+    @ApiModelProperty(value = "付费成本")
+    private String eventPayCost;
+
+    @ApiModelProperty(value = "付费率")
+    private String eventPayRate;
+
+    @ApiModelProperty(value = "新增付费人数")
+    private Integer eventNewUserPay;
+
+    @ApiModelProperty(value = "新增付费成本")
+    private String eventNewUserPayCost;
+
+    @ApiModelProperty(value = "新增付费率")
+    private String eventNewUserPayRate;
+
+    @ApiModelProperty(value = "唤起应用数")
+    private Integer eventAppInvoked;
+
+    @ApiModelProperty(value = "唤起应用成本")
+    private String eventAppInvokedCost;
+
+    @ApiModelProperty(value = "注册数")
+    private Integer eventRegister;
+
+    @ApiModelProperty(value = "注册成本")
+    private String eventRegisterCost;
+
+    @ApiModelProperty(value = "关键行为数")
+    private Integer keyAction;
+
+    @ApiModelProperty(value = "关键行为成本")
+    private String keyActionCost;
+
+    @ApiModelProperty(value = "关键行为率")
+    private String keyActionRate;
+
+    @ApiModelProperty(value = "首日付费金额")
+    private String eventPayPurchaseAmountFirstDay;
+
+    @ApiModelProperty(value = "首日ROI")
+    private String eventPayFirstDayRoi;
+
+    @ApiModelProperty(value = "表单提交数")
+    private Integer formCount;
+
+    @ApiModelProperty(value = "表单提交单价")
+    private String formCountPrice;
+
+    @ApiModelProperty(value = "有效视频数量")
+    private Integer newEffectNum;
+
+    @ApiModelProperty(value = "上新视频数量")
+    private Integer newVideoNum;
+
+    @ApiModelProperty(value = "爆款视频数量")
+    private Integer newHotNum;
+
+
+    @ApiModelProperty(value = "环比")
+    private Double yearOnYear;
+
+    @ApiModelProperty(value = "同比")
+    private Double equallyRate;
+
+
+
+
+
+}

+ 47 - 0
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/entity/vo/KuaiShouOperateVo.java

@@ -0,0 +1,47 @@
+package org.jeecg.ctop.material.entity.vo;
+
+import cn.afterturn.easypoi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+import java.io.Serializable;
+
+/**
+ * 盯盘-运营数据
+ * zian Y
+ * 2022/2/16
+ **/
+
+@Data
+public class KuaiShouOperateVo implements Serializable {
+
+
+
+    @Excel(name = "运营人员",width = 15)
+    private String userName;
+
+    @Excel(name = "账户数量",width = 10)
+    private Integer accountNum;
+
+    @Excel(name = "总花费",width = 20)
+    private Double totalCost;
+
+    @Excel(name = "花费环比",width = 10)
+    private Double rate;
+
+    private String userId;
+
+    @Excel(name = "有效素材数",width = 15)
+    private Integer newEffectNum;
+
+    @Excel(name = "新上计划数",width = 15)
+    private Integer newCampaignNum;
+
+    @Excel(name = "新上组数",width = 15)
+    private Integer newUnitNum;
+
+
+
+
+
+}

+ 57 - 6
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/MaterialStareMapper.java

@@ -3,6 +3,10 @@ package org.jeecg.ctop.material.mapper;
 import com.alibaba.fastjson.JSONObject;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
+import org.jeecg.ctop.material.entity.vo.KuaiShouAccountPieVo;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo;
 
 import java.util.List;
 import java.util.Map;
@@ -11,15 +15,62 @@ import java.util.Set;
 @Mapper
 public interface MaterialStareMapper {
 
-    List<Map> getCostByUserIdList(@Param("today") Long today, @Param("yesterday") Long yesterday, @Param("list") Set<String> operatorUserIds);
 
-    List<Map> getCostByUserIdListMoreDay(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
+    Set<String> getAffiliateId(@Param("leaderId")String userId);
+    Set<String> querySubordinateRecursive(@Param("leaderIds")Set<String> leaderIds);
+
+
+
+    // 快手 - 时报 查询
+    List<Map> getKuaiShouCostHourlyByUserIdList(@Param("startDate") Long today, @Param("endDate") Long yesterday, @Param("list") Set<String> operatorUserIds);
+    //快手-查询时报 消耗 前5
+    List<JSONObject> getKuaiShouCostByTop5HourList(@Param("startDate")Long start, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
+
+    //快手 -日报查询
+    List<Map> getKuaiShouCostDailyByUserIdList(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
+    //快手-查询日报 消耗 前5
+    List<JSONObject> getKuaiShouCostByTop5DailyList(@Param("startDate")Long start, @Param("endDate")Long end, @Param("list")Set<String> operatorUserIds);
+
+    //快手 时报总消耗
+    JSONObject getKuaiShouTotalCost(@Param("startDate")Long startDate,@Param("endDate")Long endDate, @Param("nowHour")int nowHour, @Param("list")Set<String> operatorUserIds);
+
+    //快手-查询账户数据信息
+    List<KuaiShouOperateVo> getKuaiShouOperateInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("list")Set<String> operatorUserIds);
+
+    //快手 -查询 项目 数据信息
+    List<KuaiShouOperateProjectVo> getKuaiShouOperateProjectInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("projectId")String projectId,@Param("list")Set<String> operatorUserIds);
+
+    //快手 -查询 账户 数据信息
+    List<KuaiShouOperateAccountVo> getKuaiShouOperateAccountInfo(@Param("startDate")Long startDate, @Param("endDate")Long endDate, @Param("projectId")String projectId,@Param("accountId")Long accountId, @Param("list")Set<String> operatorUserIds);
+
+
+
+    //快手 账户 余额
+    JSONObject getKuaiShouAccountBalance(@Param("accountId")Long accountId,@Param("statDate")Long statDate);
+    //快手 账户 消耗以及状态
+    JSONObject getKuaiShouAccountTotalCost(@Param("accountId")Long accountId,@Param("statDate")Long statDate);
+
+    //快手 账户趋势图-时报
+    List<JSONObject> getKuaiShouAccountInfoBrokenLineHour(@Param("accountId")Long accountId,@Param("statDate")Long statDate);
+    //快手 账户趋势图-日报
+    List<JSONObject> getKuaiShouAccountInfoBrokenLineDaily(@Param("accountId")Long accountId,@Param("startDate")Long startDate, @Param("endDate")Long endDate);
+
+    //快手 账户 素材上新-有效-爆款   searchType: 0-全部 1-上新 2-有效 3-爆款
+    List<JSONObject> getKuaiShouAccountMaterialNewAndEffectAndFaddish(@Param("accountId")Long accountId,@Param("searchType")String searchType,@Param("startDate")Long startDate, @Param("endDate")Long endDate);
+
+
+    //快手 账户饼图图-分版位
+    List<KuaiShouAccountPieVo> getKuaiShouAccountPieScene(@Param("accountId")Long accountId, @Param("startDate")Long startDate, @Param("endDate")Long endDate);
+    //快手 账户饼图图-分年龄
+    List<KuaiShouAccountPieVo> getKuaiShouAccountPieAge(@Param("accountId")Long accountId, @Param("startDate")Long startDate, @Param("endDate")Long endDate);
+    //快手 账户饼图图-分性别
+    List<KuaiShouAccountPieVo> getKuaiShouAccountPieGender(@Param("accountId")Long accountId, @Param("startDate")Long startDate, @Param("endDate")Long endDate);
+
+
+
+
 
-    List<JSONObject> getCostByTop5List(@Param("startDate")Long start, @Param("list")Set<String> operatorUserIds);
 
-    List<JSONObject> getCostByTop5ListMoreDay(@Param("startDate")Long start, @Param("endDate")Long end, @Param("list")Set<String> operatorUserIds);
 
-    Set<String> getAffiliateId(@Param("leaderId")String userId);
 
-    Set<String> querySubordinateRecursive(@Param("leaderIds")Set<String> leaderIds);
 }

+ 552 - 29
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/mapper/xml/MaterialStareMapper.xml

@@ -2,14 +2,16 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="org.jeecg.ctop.material.mapper.MaterialStareMapper">
 
-    <select id="getCostByUserIdList" resultType="Map">
-        SELECT t.`hour`,ROUND(SUM(charge),2) as todayCost,
-        (SELECT IFNULL(ROUND(SUM(charge),2),0)
-        from application.kuaishou_account_report_hourly_dw
-        WHERE stat_date =#{today}
-        and `hour`=t.`hour`) as yesterdayCost
-        from application.kuaishou_account_report_hourly_dw t
-        WHERE t.stat_date =#{yesterday}
+    <!-- 快手 时报  -->
+    <select id="getKuaiShouCostHourlyByUserIdList" resultType="Map">
+        SELECT
+        t.`hour`,
+        ROUND( SUM( charge ), 3 ) AS totalCost
+        FROM
+        application.kuaishou_account_report_hourly_dw t
+        where
+        stat_date &gt;= #{startDate}
+        AND stat_date &lt;= #{endDate}
         <if test='list!=null'>
             AND t.user_id IN
             <foreach collection="list" item="item" separator=","
@@ -17,13 +19,45 @@
                 #{item}
             </foreach>
         </if>
-        GROUP BY t.`hour` ORDER BY t.`hour`
+        GROUP BY t.`hour`
+        ORDER BY t.`hour`
     </select>
 
-    <select id="getCostByUserIdListMoreDay" resultType="Map">
-        SELECT DATE_FORMAT(t.stat_date,'%Y-%m-%d') as date,ROUND(SUM(charge),2) as cost
+
+
+
+    <!-- 快手-查询时报 消耗 前5 -->
+    <select id="getKuaiShouCostByTop5HourList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        user_id,
+        SUM( charge ) totalCost,
+        (SELECT realname from `jeecg-boot`.sys_user u where u.id = user_id) as userName
+        FROM
+        application.kuaishou_account_report_hourly_dw
+        WHERE
+        stat_date &gt;= #{startDate}
+        AND stat_date &lt;= #{endDate}
+        <if test='list!=null'>
+            AND user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY user_id ORDER BY SUM(charge) DESC LIMIT 5
+    </select>
+
+
+
+
+<!--快手 -日报  -->
+    <select id="getKuaiShouCostDailyByUserIdList" resultType="Map">
+        SELECT DATE_FORMAT(t.stat_date,'%Y-%m-%d') as dateTime,
+        ROUND(SUM(charge),3) as totalCost
         FROM application.kuaishou_account_report_daily_dw t
-        WHERE t.stat_date BETWEEN #{startDate} and #{endDate}
+        WHERE
+        t.stat_date &gt;= #{startDate}
+        AND t.stat_date &lt;= #{endDate}
         <if test='list!=null'>
             AND t.user_id IN
             <foreach collection="list" item="item" separator=","
@@ -31,13 +65,22 @@
                 #{item}
             </foreach>
         </if>
-        GROUP BY t.stat_date ORDER BY t.stat_date;
+        GROUP BY t.stat_date
+        ORDER BY t.stat_date;
     </select>
 
-    <select id="getCostByTop5List" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT SUM(t.charge)as cost,t.`hour` from
-        (SELECT user_id,SUM(charge) from application.kuaishou_account_report_hourly_dw
-        WHERE stat_date =#{startDate}
+
+    <!-- 快手-查询日报 消耗 前5 -->
+    <select id="getKuaiShouCostByTop5DailyList" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        user_id,
+        SUM( charge ) totalCost,
+        (SELECT realname from `jeecg-boot`.sys_user u where u.id = user_id) as userName
+        FROM
+        application.kuaishou_account_report_daily_dw
+        WHERE
+        stat_date &gt;= #{startDate}
+        AND stat_date &lt;= #{endDate}
         <if test='list!=null'>
             AND user_id IN
             <foreach collection="list" item="item" separator=","
@@ -45,17 +88,29 @@
                 #{item}
             </foreach>
         </if>
-        GROUP BY user_id ORDER BY SUM(charge) DESC LIMIT 5) tt
-        LEFT JOIN application.kuaishou_account_report_hourly_dw t
-        on tt.user_id=t.user_id
-        WHERE t.stat_date =#{startDate} GROUP BY t.`hour`,tt.user_id ORDER BY t.`hour`,SUM(t.charge) ASC
+        GROUP BY user_id ORDER BY SUM(charge) DESC LIMIT 5
     </select>
 
 
-    <select id="getCostByTop5ListMoreDay" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT SUM(t.charge)as cost,t.stat_date as statDate from
-        (SELECT user_id,SUM(charge) from application.kuaishou_account_report_daily_dw
-        WHERE stat_date BETWEEN #{startDate}  and #{endDate}
+
+    <!-- 快手 时报总消耗 及 账户数量 -->
+    <select id="getKuaiShouTotalCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        ROUND( SUM( charge ), 3 ) AS totalCost,
+        COUNT(DISTINCT account_id) accountNum
+        FROM
+        application.kuaishou_account_report_hourly_dw
+        where 1 = 1
+        <if test="startDate != null and startDate != '' ">
+            and stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and stat_date &lt;= #{endDate}
+        </if>
+        <if test="nowHour != null and nowHour != '' ">
+            AND hour &lt;= #{nowHour}
+        </if>
+
         <if test='list!=null'>
             AND user_id IN
             <foreach collection="list" item="item" separator=","
@@ -63,12 +118,480 @@
                 #{item}
             </foreach>
         </if>
-        GROUP BY user_id ORDER BY SUM(charge) DESC LIMIT 5) tt
-        LEFT JOIN application.kuaishou_account_report_daily_dw t
-        on tt.user_id=t.user_id
-        WHERE t.stat_date BETWEEN #{startDate}  and #{endDate} GROUP BY t.stat_date,tt.user_id ORDER BY t.stat_date,SUM(t.charge) ASC
+
+    </select>
+
+
+
+    <!-- 快手 快手-查询账户数据信息 -->
+    <select id="getKuaiShouOperateInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo">
+        SELECT
+        SUM( d.charge ) totalCost,
+        COUNT(DISTINCT d.account_id) accountNum,
+        d.user_id as userId,
+        (SELECT u.realname from `jeecg-boot`.sys_user u where u.id = d.user_id) as userName,
+        m.newEffectNum,
+        m.newCampaignNum,
+        m.newUnitNum
+        FROM
+        application.kuaishou_account_report_daily_dw d
+        LEFT JOIN
+        (
+        SELECT abi.account_id ,
+        COUNT(abi.new_effect_num) as newEffectNum,
+        COUNT(abi.new_campaign_num) as newCampaignNum,
+        COUNT(abi.new_unit_num) as newUnitNum
+        from application.app_kuaishou_account_base_info_d abi
+            <where>
+                <if test="startDate != null and startDate != '' ">
+                    and abi.stat_date &gt;= #{startDate}
+                </if>
+                <if test="endDate != null and endDate != '' ">
+                    and abi.stat_date &lt;= #{endDate}
+                </if>
+            </where>
+            GROUP BY abi.account_id
+        ) m
+        on d.account_id = m.account_id
+        WHERE
+        d.charge > 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_date &lt;= #{endDate}
+        </if>
+        <if test='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.user_id
+        ORDER BY SUM( d.charge ) DESC
+    </select>
+
+    <!-- 快手 -查询项目数据信息 -->
+    <select id="getKuaiShouOperateProjectInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo">
+        SELECT
+        SUM( d.charge ) AS totalCost,
+        COUNT( DISTINCT d.account_id ) AS accountNum,
+        d.project_id AS projectId,
+        d.project_name AS projectName,
+        COUNT( DISTINCT d.user_id ) AS userNum,
+        SUM( d.activation ) AS activation,
+        ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ) AS activationPrice,
+        ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ), 2 ) AS leave,
+        SUM( d.event_pay ) AS eventPay,
+        ROUND( SUM( d.charge ) / SUM( d.event_pay ), 2 ) AS eventPayCost,
+        ROUND( SUM( d.event_pay ) / ( SUM( d.activation ) + SUM( d.form_count )), 2 ) AS eventPayRate,
+        SUM( d.event_new_user_pay ) AS eventNewUserPay,
+        ROUND( SUM( d.charge ) / SUM( d.event_new_user_pay ), 2 ) AS eventNewUserPayCost,
+        ROUND( SUM( d.event_new_user_pay ) / ( SUM( d.activation ) + SUM( d.form_count )), 2 ) AS eventNewUserPayRate,
+        SUM( d.event_app_invoked ) AS eventAppInvoked,
+        ROUND( SUM( d.charge ) / SUM( d.event_app_invoked ), 2 ) AS eventAppInvokedCost,
+        SUM( d.event_register ) AS eventRegister,
+        ROUND( SUM( d.charge ) / SUM( d.event_register ), 2 ) AS eventRegisterCost,
+        SUM( d.key_action ) AS keyAction,
+        ROUND( SUM( d.charge ) / SUM( d.key_action ), 2 ) AS keyActionCost,
+        CONCAT( ROUND( SUM( d.charge )/ SUM( d.activation )* 100, 2 ), '%' ) AS keyActionRate,
+        SUM( d.event_pay_purchase_amount_first_day ) AS eventPayPurchaseAmountFirstDay,
+        SUM( d.event_pay_first_day_roi ) AS eventPayFirstDayRoi,
+        SUM( d.form_count ) AS formCount,
+        ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ) AS formCountPrice,
+        m.newEffectNum AS newEffectNum,
+        m.newVideoNum AS newVideoNum,
+        m.newHotNum AS newHotNum
+        FROM
+        application.kuaishou_account_report_daily_dw d
+        LEFT JOIN (
+            SELECT
+            abi.account_id,
+            COUNT( abi.new_effect_num ) AS newEffectNum,
+            COUNT( abi.new_video_num ) AS newVideoNum,
+            COUNT( abi.new_hot_num ) AS newHotNum
+            FROM
+            application.app_kuaishou_account_base_info_d abi
+            <where>
+                    <if test="startDate != null and startDate != '' ">
+                        and abi.stat_date &gt;= #{startDate}
+                    </if>
+                    <if test="endDate != null and endDate != '' ">
+                        and abi.stat_date &lt;= #{endDate}
+                    </if>
+                </where>
+                GROUP BY abi.account_id
+        ) m
+        on d.account_id = m.account_id
+        WHERE
+        d.charge > 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_date &lt;= #{endDate}
+        </if>
+        <if test="projectId != null and projectId != '' ">
+            and d.project_id = #{projectId}
+        </if>
+        <if test='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.project_id
+        ORDER BY SUM( d.charge ) DESC
+    </select>
+
+
+
+    <!-- 快手 -查询 账户 数据信息  -->
+    <select id="getKuaiShouOperateAccountInfo" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo">
+        SELECT
+        SUM( d.charge ) AS totalCost,
+        d.account_id as accountId,
+        d.project_id AS projectId,
+        d.project_name AS projectName,
+        COUNT( DISTINCT d.user_id ) AS userNum,
+        ( SELECT u.realname FROM `jeecg-boot`.sys_user u WHERE u.id = d.user_id ) AS userName,
+        SUM( d.activation ) AS activation,
+        ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ) AS activationPrice,
+        ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ), 2 ) AS leave,
+        SUM( d.event_pay ) AS eventPay,
+        ROUND( SUM( d.charge ) / SUM( d.event_pay ), 2 ) AS eventPayCost,
+        ROUND( SUM( d.event_pay ) / ( SUM( d.activation ) + SUM( d.form_count )), 2 ) AS eventPayRate,
+        SUM( d.event_new_user_pay ) AS eventNewUserPay,
+        ROUND( SUM( d.charge ) / SUM( d.event_new_user_pay ), 2 ) AS eventNewUserPayCost,
+        ROUND( SUM( d.event_new_user_pay ) / ( SUM( d.activation ) + SUM( d.form_count )), 2 ) AS eventNewUserPayRate,
+        SUM( d.event_app_invoked ) AS eventAppInvoked,
+        ROUND( SUM( d.charge ) / SUM( d.event_app_invoked ), 2 ) AS eventAppInvokedCost,
+        SUM( d.event_register ) AS eventRegister,
+        ROUND( SUM( d.charge ) / SUM( d.event_register ), 2 ) AS eventRegisterCost,
+        SUM( d.key_action ) AS keyAction,
+        ROUND( SUM( d.charge ) / SUM( d.key_action ), 2 ) AS keyActionCost,
+        CONCAT( ROUND( SUM( d.charge )/ SUM( d.activation )* 100, 2 ), '%' ) AS keyActionRate,
+        SUM( d.event_pay_purchase_amount_first_day ) AS eventPayPurchaseAmountFirstDay,
+        SUM( d.event_pay_first_day_roi ) AS eventPayFirstDayRoi,
+        SUM( d.form_count ) AS formCount,
+        ROUND( SUM( d.charge ) / SUM( d.form_count ), 2 ) AS formCountPrice,
+        SUM(d.`show`) as photoShow,
+        SUM(d.photo_click) as photoClick,
+        m.newEffectNum AS newEffectNum,
+        m.newVideoNum AS newVideoNum,
+        m.newHotNum AS newHotNum
+        FROM
+        application.kuaishou_account_report_daily_dw d
+        LEFT JOIN (
+            SELECT
+            abi.account_id,
+            COUNT( abi.new_effect_num ) AS newEffectNum,
+            COUNT( abi.new_video_num ) AS newVideoNum,
+            COUNT( abi.new_hot_num ) AS newHotNum
+            FROM
+            application.app_kuaishou_account_base_info_d abi
+            <where>
+                    <if test="startDate != null and startDate != '' ">
+                        and abi.stat_date &gt;= #{startDate}
+                    </if>
+                    <if test="endDate != null and endDate != '' ">
+                        and abi.stat_date &lt;= #{endDate}
+                    </if>
+                </where>
+                GROUP BY abi.account_id
+        ) m
+        on d.account_id = m.account_id
+        WHERE
+        d.charge > 0
+        <if test="startDate != null and startDate != '' ">
+            and d.stat_date &gt;= #{startDate}
+        </if>
+        <if test="endDate != null and endDate != '' ">
+            and d.stat_date &lt;= #{endDate}
+        </if>
+        <if test="projectId != null and projectId != '' ">
+            and d.project_id = #{projectId}
+        </if>
+        <if test="accountId != null and accountId != '' ">
+            and d.account_id = #{accountId}
+        </if>
+        <if test='list!=null'>
+            AND d.user_id IN
+            <foreach collection="list" item="item" separator=","
+                     open="(" close=")">
+                #{item}
+            </foreach>
+        </if>
+        GROUP BY d.account_id
+        ORDER BY SUM( d.charge ) DESC
+    </select>
+
+
+
+    <!-- 快手 账户 余额 -->
+    <select id="getKuaiShouAccountBalance" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            d.total_charged_in_yuan as totalCost,
+            d.total_balance_in_yuan as balance
+        FROM application.app_kuaishou_agent_report_d d
+        <where>
+            <if test="accountId != null and accountId != '' ">
+                and d.account_id = #{accountId}
+            </if>
+            <if test="statDate != null and statDate != '' ">
+                and d.stat_date = #{statDate}
+            </if>
+        </where>
     </select>
 
+
+    <!-- 快手 账户 余额 以及状态 -->
+    <select id="getKuaiShouAccountTotalCost" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        SUM(h.charge) todayCost,
+        u.account_status as accountStatus
+        from
+        application.kuaishou_account_report_hourly_dw h
+        LEFT JOIN `jeecg-boot`.`ctop_user_allocation` u
+        on u.account_id = h.account_id
+        <where>
+            <if test="accountId != null and accountId != '' ">
+                and h.account_id = #{accountId}
+            </if>
+            <if test="statDate != null and statDate != '' ">
+                and h.stat_date = #{statDate}
+            </if>
+        </where>
+    </select>
+
+
+
+    <!-- 快手 账户趋势图-时报 -->
+    <select id="getKuaiShouAccountInfoBrokenLineHour" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT t.*,y.*
+        FROM
+            (
+                SELECT
+                    h.`hour` as tHour,
+                    h.charge AS tCost,
+                    IFNULL( ROUND(( h.charge / h.activation ), 2 ), 0 ) AS tActivationPrice,
+                    IFNULL( ROUND(( h.charge / h.event_new_user_pay ), 2 ), 0 ) AS tEventNewUserPayCost,
+                    IFNULL( ROUND( ( h.event_next_day_stay / h.activation ), 2 ), 0 ) AS tLeave
+                FROM
+                    application.kuaishou_account_report_hourly_dw h
+                <where>
+                    <if test="accountId != null and accountId != '' ">
+                        and h.account_id = #{accountId}
+                    </if>
+                    <if test="statDate != null and statDate != '' ">
+                        and h.stat_date = #{statDate}
+                    </if>
+                </where>
+                ORDER BY
+                    h.hour) t
+                RIGHT JOIN
+            (
+                SELECT
+                    h.`hour` as yHour,
+                    h.charge AS yCost,
+                    IFNULL( ROUND(( h.charge / h.activation ), 2 ), 0 ) AS yActivationPrice,
+                    IFNULL( ROUND(( h.charge / h.event_new_user_pay ), 2 ), 0 ) AS yEventNewUserPayCost,
+                    IFNULL( ROUND( ( h.event_next_day_stay / h.activation ), 2 ), 0 ) AS yLeave
+                FROM
+                    application.kuaishou_account_report_hourly_dw h
+                <where>
+                    <if test="accountId != null and accountId != '' ">
+                        and h.account_id = #{accountId}
+                    </if>
+                    <if test="statDate != null and statDate != '' ">
+                        and h.stat_date = #{statDate}
+                    </if>
+                </where>
+                ORDER BY
+                    h.HOUR) y
+            on t.tHour = y.yHour
+    </select>
+
+
+
+    <!-- 快手 账户趋势图-日报 -->
+    <select id="getKuaiShouAccountInfoBrokenLineDaily" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+            SUM( d.charge ) as cost,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationPrice,
+            IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_new_user_pay ), 2 ), 0 ) AS eventNewUserPayCost,
+            IFNULL( ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ), 2 ), 0 ) AS leave
+        FROM
+            application.kuaishou_account_report_daily_dw d
+        <where>
+            <if test="accountId != null and accountId != '' ">
+                and d.account_id = #{accountId}
+            </if>
+            <if test="startDate != null and startDate != '' ">
+                and d.stat_date &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != '' ">
+                and d.stat_date &lt;= #{endDate}
+            </if>
+        </where>
+        GROUP BY
+        d.stat_date
+        ORDER BY
+        d.stat_date
+    </select>
+
+    <!-- 快手 账户 素材上新-有效-爆款   searchType: 0-全部 1-上新 2-有效 3-爆款-->
+    <select id="getKuaiShouAccountMaterialNewAndEffectAndFaddish" resultType="com.alibaba.fastjson.JSONObject">
+        SELECT
+        vd.signature,
+        SUM( vd.charge ) AS totalCost,
+        SUM( vd.activation ) AS activation,
+        ROUND(( SUM( vd.charge ) / SUM( vd.activation ) ), 2 ) AS activationPrice,
+        vd.stat_date AS statDate,
+        m.media_time AS mediaTime
+        FROM
+        application.kuaishou_material_video_report_daily_dw vd,
+        application.app_kuaishou_material_info m
+        WHERE
+        vd.signature = m.material_id
+        AND vd.account_id = #{accountId}
+        AND vd.stat_date &gt;= #{startDate}
+        AND vd.stat_date &lt;= #{endDate}
+        <if test="searchType == '1'.toString()">
+            and material_innovate = 2
+        </if>
+        <if test="searchType == '2'.toString()">
+            AND m.effect_flag = 2
+            AND m.effect_date &gt;= #{startDate}
+            AND m.effect_date &lt;= #{endDate}
+        </if>
+         <if test="searchType == '3'.toString()">
+             and m.faddish_flag = 2
+             and m.faddish_date &gt;= #{startDate}
+            AND m.faddish_date &lt;= #{endDate}
+        </if>
+        GROUP BY
+            vd.signature
+        ORDER BY
+            m.media_time DESC
+    </select>
+
+
+
+
+
+    <!-- 快手 账户饼图图-分版位 -->
+    <select id="getKuaiShouAccountPieScene" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouAccountPieVo">
+        SELECT
+        d.ad_scene AS adScene,
+        SUM( d.charge ) AS cost,
+        SUM( d.activation ) AS activation,
+        IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationPrice,
+        SUM( d.event_pay_roi ) AS eventPayRoi,
+        SUM( d.event_pay ) AS eventPay,
+        IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_pay ), 2 ), 0 ) AS eventPayCost,
+        SUM( d.event_pay_purchase_amount_first_day ) AS eventPayPurchaseAmountFirstDay,
+        SUM( d.event_next_day_stay ) AS event_next_day_stay,
+        IFNULL( ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ), 2 ), 0 ) AS leave
+        FROM
+        application.app_kuaishou_account_ad_scene_report_d d
+        <where>
+            <if test="accountId != null and accountId != '' ">
+                and d.account_id = #{accountId}
+            </if>
+            <if test="startDate != null and startDate != '' ">
+                and d.stat_date &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != '' ">
+                and d.stat_date &lt;= #{endDate}
+            </if>
+        </where>
+        GROUP BY
+            d.ad_scene
+        ORDER BY
+            d.ad_scene
+    </select>
+
+
+    <!-- 快手 账户饼图图-分年龄 -->
+    <select id="getKuaiShouAccountPieAge" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouAccountPieVo">
+        SELECT
+        d.age_segment AS ageSegment,
+        SUM( d.charge ) AS cost,
+        SUM( d.activation ) AS activation,
+        IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationPrice,
+        SUM( d.event_pay_roi ) AS eventPayRoi,
+        SUM( d.event_pay ) AS eventPay,
+        IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_pay ), 2 ), 0 ) AS eventPayCost,
+        SUM( d.event_pay_purchase_amount_first_day ) AS eventPayPurchaseAmountFirstDay,
+        SUM( d.event_next_day_stay ) AS event_next_day_stay,
+        IFNULL( ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ), 2 ), 0 ) AS leave
+        FROM
+        media_api.kuaishou_audience_age_report_daily d
+        <where>
+            <if test="accountId != null and accountId != '' ">
+                and d.advertiser_id = #{accountId}
+            </if>
+            <if test="startDate != null and startDate != '' ">
+                and d.stat_date &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != '' ">
+                and d.stat_date &lt;= #{endDate}
+            </if>
+        </where>
+        GROUP BY
+            d.age_segment
+        ORDER BY
+            d.age_segment
+    </select>
+
+
+    <!-- 快手 账户饼图图-分性别 -->
+    <select id="getKuaiShouAccountPieGender" resultType="org.jeecg.ctop.material.entity.vo.KuaiShouAccountPieVo">
+        SELECT
+        d.gender AS gender,
+        SUM( d.charge ) AS cost,
+        SUM( d.activation ) AS activation,
+        IFNULL( ROUND( SUM( d.charge ) / SUM( d.activation ), 2 ), 0 ) AS activationPrice,
+        SUM( d.event_pay_roi ) AS eventPayRoi,
+        SUM( d.event_pay ) AS eventPay,
+        IFNULL( ROUND( SUM( d.charge ) / SUM( d.event_pay ), 2 ), 0 ) AS eventPayCost,
+        SUM( d.event_pay_purchase_amount_first_day ) AS eventPayPurchaseAmountFirstDay,
+        SUM( d.event_next_day_stay ) AS event_next_day_stay,
+        IFNULL( ROUND( SUM( d.event_next_day_stay ) / SUM( d.activation ), 2 ), 0 ) AS leave
+        FROM
+        media_api.kuaishou_audience_gender_report_daily d
+        <where>
+            <if test="accountId != null and accountId != '' ">
+                and d.advertiser_id = #{accountId}
+            </if>
+            <if test="startDate != null and startDate != '' ">
+                and d.stat_date &gt;= #{startDate}
+            </if>
+            <if test="endDate != null and endDate != '' ">
+                and d.stat_date &lt;= #{endDate}
+            </if>
+        </where>
+        GROUP BY
+            d.gender
+        ORDER BY
+            d.gender
+    </select>
+
+
+
+
+
+
+
+
+
+
+
+
+
     <select id="getAffiliateId" resultType="java.lang.String">
         SELECT distinct id
         FROM sys_user

+ 23 - 1
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/MaterialStareService.java

@@ -3,10 +3,32 @@ package org.jeecg.ctop.material.service;
 import com.alibaba.fastjson.JSONObject;
 import org.jeecg.common.api.vo.Result;
 
+import javax.servlet.http.HttpServletResponse;
+
 /**
  * 盯盘接口
  */
 public interface MaterialStareService {
 
-    Result<JSONObject> sumData(Integer mediaId, Integer userType, String userId, String startDate, String endDate, Integer type);
+    Result kuaiShousumData(String mediaType, String type, String startTime, String endTime, String userId);
+
+    Result kuaiShouOperateDateTotal(String mediaType,String startTime, String endTime, String userId);
+
+    Result getKuaiShouOperateInfo(Integer pageNum,int pageSize,String startTime, String endTime, String userId);
+    Result exportKuaiShouOperateInfo(String startTime, String endTime, String userId, HttpServletResponse response);
+
+    Result getKuaiShouOperateProjectInfo(Integer pageNum,int pageSize,String startTime, String endTime, String userId);
+
+    Result getKuaiShouOperateAccountInfo(Integer pageNum,int pageSize,String startTime, String endTime, String projectId,String userId);
+
+    Result getKuaiShouAccountInfo(long accountId);
+
+    Result getKuaiShouAccountInfoBrokenLine(long accountId,String startTime, String endTime);
+
+    Result getKuaiShouAccountMaterialNewAndEffectAndFaddish(long accountId,String searchType,String startTime, String endTime,Integer pageNum,Integer pageSize);
+
+    Result getKuaiShouAccountPieChar(long accountId,String startTime, String endTime);
+
+
+
 }

+ 497 - 103
jeecg-boot-material-view/src/main/java/org/jeecg/ctop/material/service/impl/MaterialStareServiceImpl.java

@@ -1,18 +1,36 @@
 package org.jeecg.ctop.material.service.impl;
 
 
+import cn.afterturn.easypoi.excel.ExcelExportUtil;
+import cn.afterturn.easypoi.excel.entity.ExportParams;
+import cn.hutool.core.date.DateUtil;
 import com.alibaba.fastjson.JSONObject;
+import com.github.pagehelper.PageHelper;
+import com.github.pagehelper.PageInfo;
+import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.poi.ss.usermodel.Workbook;
 import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.util.DateUtils;
+import org.jeecg.ctop.material.constants.Check;
 import org.jeecg.ctop.material.constants.CtopAdConstant;
+import org.jeecg.ctop.material.entity.vo.KuaiShouAccountPieVo;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateAccountVo;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateProjectVo;
+import org.jeecg.ctop.material.entity.vo.KuaiShouOperateVo;
 import org.jeecg.ctop.material.mapper.MaterialStareMapper;
 import org.jeecg.ctop.material.service.MaterialStareService;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import javax.servlet.http.HttpServletResponse;
+import java.net.URLEncoder;
+import java.text.DecimalFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
+import java.util.stream.Collectors;
 
 /**
  * 盯盘接口
@@ -25,132 +43,506 @@ public class MaterialStareServiceImpl implements MaterialStareService {
     MaterialStareMapper materialStareMapper;
 
 
+
+
     /**
-     * 数据总览
+     *
+     * @description:数据总览-快手
+     *
+     * @param mediaType 媒体类型 1-头条 2-快手
+     * @param type 查询类型 1-汇总 2-运营个人
+     * @param userId
+     * @param startTime
+     * @param startTime
+     * @author: zianY
+     * @time: 2022/2/15
      */
     @Override
-    public Result<JSONObject> sumData(Integer mediaId, Integer userType, String userId, String startDate, String endDate, Integer type) {
-        Result result = new Result();
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-        Long start = Long.parseLong(startDate.replace("-", ""));
-        Long end = Long.parseLong(endDate.replace("-", ""));
-
-        if (mediaId == CtopAdConstant.PLATFORM_TYPE_BYTEDANCE_INT) {
-            //头条
-            //功能待完善
-        } else if (mediaId == CtopAdConstant.PLATFORM_TYPE_KUAISHOU_INT) {
-            //快手
-            if (userType == 1) {  //运营经理界面
-                //查询当前人员所有下级
-                Set<String> operatorUserIds = getAffiliateId(userId);
-                if (type == 1) {  //汇总查看
-                    if (start.equals(end)) {  //查看当日
-                        Long beforeDay = dayBefore(start);
-                        //查询账户时报表当日数据
-                        List<Map> list = materialStareMapper.getCostByUserIdList(start, beforeDay, operatorUserIds);
-                        result.setResult(list);
-                        result.setSuccess(true);
-                        return result;
-                    } else { //查看多日
-                        //查询账户日报表当日数据
-                        List<Map> list = materialStareMapper.getCostByUserIdListMoreDay(start, end, operatorUserIds);
-                        result.setResult(list);
-                        result.setSuccess(true);
-                        return result;
-                    }
+    public Result kuaiShousumData(String mediaType, String type, String startTime, String endTime, String userId) {
+        long stratDate = DateUtils.getDateInteger(startTime);
+        long endDate = DateUtils.getDateInteger(endTime);
+        //查询当前人员所有下级
+        Set<String> operatorUserIds = getAffiliateId(userId);
+        //头条
+        if (StringUtils.equals(mediaType,"1")){
+            return Result.successMsg("暂无头条数据。",null);
+        }
+        //快手
+        if (StringUtils.equals(mediaType,"2")){
+            //汇总
+            if (StringUtils.equals(type,"1")){
+                //查询一天数据时 查询时报
+                if (stratDate == endDate){
+                    Map resultMap = new HashMap<>();
+                    //时报
+                    List<Map> todayList = materialStareMapper.getKuaiShouCostHourlyByUserIdList(stratDate, endDate, operatorUserIds);
+                    long time = DateUtils.getDateInteger(DateUtils.addDayParse(Long.toString(endDate), -1));
+                    List<Map> yesterdayList = materialStareMapper.getKuaiShouCostHourlyByUserIdList(time,time , operatorUserIds);
+                    resultMap.put("todayList",todayList);
+                    resultMap.put("yesterdayList",yesterdayList);
+                    return Result.successMsg("查询-时报-汇总。",resultMap);
+                }
+                //多天 数据
+                // 日报
+                List<Map> dailyList = materialStareMapper.getKuaiShouCostDailyByUserIdList(stratDate, endDate, operatorUserIds);
+                return Result.successMsg("查询-日报-汇总成功。",dailyList);
 
-                } else if (type == 2) {  //运营个人查看
-                    if (start.equals(end)) { //查看当日
-                        //查询个人top5当日时报
-                        List<JSONObject> resultList = new ArrayList<>();
-                        List<JSONObject> list = materialStareMapper.getCostByTop5List(start, operatorUserIds);
-                        int size = 0;
-                        int firstHour = list.get(0).getInteger("hour");
-                        //判断每个小时取出几条
-                        for (JSONObject jsonObject : list) {
-                            //判断每个小时取出几条
-                            Integer hour = jsonObject.getInteger("hour");
-                            if (hour == firstHour) {
-                                size++;
-                            }
-                        }
-                        for (int i = 0; i < list.size() / size; i++) {
-                            //没top条数据切割出来封装
-                            List<JSONObject> objects = list.subList(i * size, (i + 1) * size);
-                            JSONObject resultObj = new JSONObject();
-                            int j = 1;
-                            for (JSONObject object : objects) {
-                                resultObj.put("hours", object.getInteger("hour"));
-                                resultObj.put("top" + j, object.getBigDecimal("cost"));
-                                j++;
-                            }
-                            resultList.add(resultObj);
-                        }
-                        result.setResult(resultList);
-                        result.setSuccess(true);
-                        return result;
-                    } else {   //查看多日
-                        List<JSONObject> resultList = new ArrayList<>();
-                        //查询个人top5当日日报
-                        List<JSONObject> list = materialStareMapper.getCostByTop5ListMoreDay(start, end, operatorUserIds);
-                        int size = 0;
-                        int firstDate = list.get(0).getInteger("statDate");
-                        //判断每个小时取出几条
-                        for (JSONObject jsonObject : list) {
-                            //判断每个小时取出几条
-                            Integer hour = jsonObject.getInteger("statDate");
-                            if (hour == firstDate) {
-                                size++;
-                            }
-                        }
-                        for (int i = 0; i < list.size() / size; i++) {
-                            //没top条数据切割出来封装
-                            List<JSONObject> objects = list.subList(i * size, (i + 1) * size);
-                            JSONObject resultObj = new JSONObject();
-                            int j = 1;
-                            for (JSONObject object : objects) {
-                                resultObj.put("date", object.getInteger("statDate"));
-                                resultObj.put("top" + j, object.getBigDecimal("cost"));
-                                j++;
-                            }
-                            resultList.add(resultObj);
-                        }
-                        result.setResult(resultList);
-                        result.setSuccess(true);
-                        return result;
+            //运营个人
+            }else if (StringUtils.equals(type,"2")){
+                if (stratDate == endDate){
+                    //时报 消耗前5
+                    List<JSONObject> userList = materialStareMapper.getKuaiShouCostByTop5HourList(stratDate, endDate, operatorUserIds);
+                    List<Map> resultList = new ArrayList<>();
+                    for (JSONObject jsonObject : userList) {
+                        Map map = new HashMap();
+                        Set<String> userSet = new HashSet<String>(){{
+                            add(jsonObject.getString("user_id"));
+                        }};
+                        List<Map> usertopList = materialStareMapper.getKuaiShouCostHourlyByUserIdList(stratDate, endDate, userSet);
+                        map.put(jsonObject.getString("userName"),usertopList);
+                        resultList.add(map);
                     }
+                    return Result.successMsg("查询-时报-运营个人消耗top5成功。",resultList);
+                }
+
+                //时报 消耗前5
+                List<JSONObject> userList = materialStareMapper.getKuaiShouCostByTop5DailyList(stratDate,endDate, operatorUserIds);
+                List<Map> resultList = new ArrayList<>();
+                for (JSONObject jsonObject : userList) {
+                    Map map = new HashMap();
+                    Set<String> userSet = new HashSet<String>(){{
+                        add(jsonObject.getString("user_id"));
+                    }};
+                    List<Map> usertopList = materialStareMapper.getKuaiShouCostDailyByUserIdList(stratDate, endDate, userSet);
+                    map.put(jsonObject.getString("userName"),usertopList);
+                    resultList.add(map);
                 }
-            } else if (userType == 2) {
-                //运营个人界面
+                return Result.successMsg("查询-日报-运营个人消耗top5成功。",resultList);
             }
         }
+
+
+
+
+
         return null;
     }
 
 
     /**
-     * 获取指定日期前一日 LONG类型
+     *
+     * @description: 快手-运营组数据
+     *
+     * @param mediaType 媒体类型 1-头条 2-快手
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/15
+     */
+    @Override
+    public Result kuaiShouOperateDateTotal(String mediaType, String startTime, String endTime, String userId) {
+        Map resultMap = new HashMap();
+        try {
+            //查询当前人员所有下级
+            Set<String> operatorUserIds = getAffiliateId(userId);
+            SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
+            // ==>> 20220202
+            String now = sdf.format(new Date());
+            long nowDate = Long.valueOf(now);
+            int nowHour = DateUtils.getNowHour();
+            //昨天时间
+            long time = DateUtils.getDateInteger(DateUtils.addDayParse(now, -1));
+
+            //当天总消耗
+            JSONObject jsonObjectNow = materialStareMapper.getKuaiShouTotalCost(nowDate,nowDate,nowHour,operatorUserIds);
+            resultMap.put("todayCost",jsonObjectNow.getString("totalCost"));
+            //昨天总消耗
+            JSONObject jsonObjectYesterday = materialStareMapper.getKuaiShouTotalCost(time,time,nowHour,operatorUserIds);
+            //今日同比 = (今天总消耗 - 昨天总消耗 ) / 昨天总消耗
+            Double d = (Double.valueOf(jsonObjectNow.getString("totalCost")) - Double.valueOf(jsonObjectYesterday.getString("totalCost"))) / Double.valueOf(jsonObjectYesterday.getString("totalCost"));
+            resultMap.put("compare",d);
+
+            //时间段内 总消耗 及 账户数量
+            JSONObject totalCost = materialStareMapper.getKuaiShouTotalCost(Long.valueOf(DateUtils.getDateInteger(startTime)),
+                    Long.valueOf(DateUtils.getDateInteger(endTime)),
+                    0,
+                    operatorUserIds);
+            // 人均账户数量 = 时间段内 账户总数量 / 人数
+            Double userAverageAccount = Double.valueOf(totalCost.getString("accountNum")) / operatorUserIds.size();
+            // 人均消耗 = 时间段内 总消耗 / 人数
+            Double userAveragecost = Double.valueOf(totalCost.getString("totalCost")) / operatorUserIds.size();
+            resultMap.put("userAverageAccount",userAverageAccount);
+            resultMap.put("userAveragecost",userAveragecost);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return Result.successMsg("查询成功",resultMap);
+    }
+
+    /**
+     *
+     * @description: 运营数据详情
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/16
+     */
+    @Override
+    public Result getKuaiShouOperateInfo(Integer pageNum, int pageSize, String startTime, String endTime, String userId) {
+       try {
+        //查询当前人员所有下级
+        Set<String> operatorUserIds = getAffiliateId(userId);
+        //2022-02-15 ==>> 20220215
+        long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+        long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+        //上阶段时间
+        Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
+        long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
+        long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
+
+        PageHelper.startPage(pageNum,pageSize);
+        //查询运营数据
+        List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
+        for (KuaiShouOperateVo operate : listOperate) {
+            Set<String> userSet = new HashSet<String>(){{
+                add(operate.getUserId());
+            }};
+            List<KuaiShouOperateVo> userOperate = materialStareMapper.getKuaiShouOperateInfo(lastTimeStart,lastTimeEnd,userSet);
+            Double rate = new Double(0);
+            if (!Check.isNull(userOperate)){
+                //环比 =
+                rate = (operate.getTotalCost() - userOperate.get(0).getTotalCost()) / userOperate.get(0).getTotalCost() * 100;
+                rate = Double.valueOf(String.format("%.3f", rate));
+            }
+            operate.setRate(rate);
+        }
+        PageInfo<KuaiShouOperateVo> pageInfo = new PageInfo<>(listOperate);
+        return Result.successMsg("运营数据查询成功。",pageInfo);
+       }catch (Exception e){
+           e.printStackTrace();
+       }
+        return Result.errorMsg("哎呀,查询失败了。");
+    }
+
+    @Override
+    public Result exportKuaiShouOperateInfo(String startTime, String endTime, String userId, HttpServletResponse response) {
+       try {
+        //查询当前人员所有下级
+        Set<String> operatorUserIds = getAffiliateId(userId);
+        //2022-02-15 ==>> 20220215
+        long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+        long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+        //上阶段时间
+        Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
+        long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
+        long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
+
+        //查询运营数据
+        List<KuaiShouOperateVo> listOperate = materialStareMapper.getKuaiShouOperateInfo(startDate,entDate,operatorUserIds);
+        for (KuaiShouOperateVo operate : listOperate) {
+            Set<String> userSet = new HashSet<String>(){{
+                add(operate.getUserId());
+            }};
+            List<KuaiShouOperateVo> userOperate = materialStareMapper.getKuaiShouOperateInfo(lastTimeStart,lastTimeEnd,userSet);
+            Double rate = new Double(0);
+            if (!Check.isNull(userOperate)){
+                //环比 = (当前 - 上阶段 ) / 上阶段
+                rate = (operate.getTotalCost() - userOperate.get(0).getTotalCost() ) / userOperate.get(0).getTotalCost() * 100;
+                rate = Double.valueOf(String.format("%.3f", rate));
+            }
+            operate.setRate(rate);
+        }
+       Workbook workbook = ExcelExportUtil.exportExcel(new ExportParams("运营数据详情", "运营数据"), KuaiShouOperateVo.class, listOperate);
+       response.setCharacterEncoding("UTF-8");
+       response.setHeader("content-Type", "application/vnd.ms-excel");
+       response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("运营数据详情.xlsx", "UTF-8"));
+       workbook.write(response.getOutputStream());
+       return null;
+       }catch (Exception e){
+           e.printStackTrace();
+       }
+        return Result.errorMsg("哎呀,查询失败了。");
+    }
+
+
+    /**
+     *
+     * @description: 运营数据-项目列表
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/17
+     */
+    @Override
+    public Result getKuaiShouOperateProjectInfo(Integer pageNum, int pageSize, String startTime, String endTime, String userId) {
+        try {
+            //查询当前人员所有下级
+            Set<String> operatorUserIds = getAffiliateId(userId);
+            //2022-02-15 ==>> 20220215
+            long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+            long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+
+            //计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
+            Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
+            long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
+            long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
+            Integer daysBetween = Integer.valueOf(lastTime.get("daysBetween"));
+
+            //计算同比 时间值 只支持7天
+            long startEqually = new Long("0");
+            long endEqually = new Long("0");
+            if (daysBetween <= 7) {
+                startEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(startTime)), -7));
+                endEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(endTime)), -7));
+            }
+
+            PageHelper.startPage(pageNum,pageSize);
+            //查询运营数据-项目维度
+            List<KuaiShouOperateProjectVo> listOperate = materialStareMapper.getKuaiShouOperateProjectInfo(startDate,entDate,null,operatorUserIds);
+            for (KuaiShouOperateProjectVo projectInfo : listOperate) {
+                String projectId = projectInfo.getProjectId();
+                List<KuaiShouOperateProjectVo> projectYearOnYearInfo = materialStareMapper.getKuaiShouOperateProjectInfo(lastTimeStart,lastTimeEnd,projectId,operatorUserIds);
+                //环比 = (当前 - 上阶段 ) / 上阶段
+                Double yearOnYear = new Double(0);
+                if (!Check.isNull(projectYearOnYearInfo)){
+                    yearOnYear = (projectInfo.getTotalCost() - projectYearOnYearInfo.get(0).getTotalCost()) / projectYearOnYearInfo.get(0).getTotalCost() * 100;
+                    yearOnYear = Double.valueOf(String.format("%.2f", yearOnYear));
+                }
+                projectInfo.setYearOnYear(yearOnYear);
+
+                //同比 日期超过 7 天 则不显示
+                Double equallyRate = new Double(0);
+                if (daysBetween <= 7){
+                    List<KuaiShouOperateProjectVo> projectEquallyInfo = materialStareMapper.getKuaiShouOperateProjectInfo(startEqually,endEqually,projectId,operatorUserIds);
+                    if (!Check.isNull(projectEquallyInfo)){
+                        equallyRate = (projectInfo.getTotalCost() - projectEquallyInfo.get(0).getTotalCost()) / projectEquallyInfo.get(0).getTotalCost() * 100;
+                        equallyRate = Double.valueOf(String.format("%.2f", equallyRate));
+                    }
+                }
+                projectInfo.setEquallyRate(equallyRate);
+
+            }
+
+            PageInfo<KuaiShouOperateProjectVo> pageInfo = new PageInfo<>(listOperate);
+            return Result.successMsg("运营项目列表数据查询成功。",pageInfo);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return Result.errorMsg("哎呀,查询失败了。");
+    }
+
+
+
+    /**
+     *
+     * @description: 运营数据-账户列表
+     *
+     * @param pageNum
+     * @param pageSize
+     * @param startTime
+     * @param endTime
+     * @param userId
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/18
      */
-    public Long dayBefore(Long date) {
+    @Override
+    public Result getKuaiShouOperateAccountInfo(Integer pageNum, int pageSize, String startTime, String endTime,String projectId, String userId) {
+        try {
+            //查询当前人员所有下级
+            Set<String> operatorUserIds = getAffiliateId(userId);
+            //2022-02-15 ==>> 20220215
+            long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+            long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+
+            //计算环比 时间值 上阶段时间 以及 两个日期之间的 间隔天数
+            Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
+            long lastTimeStart = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeStart")));
+            long lastTimeEnd = Long.valueOf(DateUtils.getDateInteger(lastTime.get("lastTimeEnd")));
+            Integer daysBetween = Integer.valueOf(lastTime.get("daysBetween"));
+
+            //计算同比 时间值 只支持7天
+            long startEqually = new Long("0");
+            long endEqually = new Long("0");
+            if (daysBetween <= 7) {
+                startEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(startTime)), -7));
+                endEqually = DateUtils.getDateInteger(DateUtils.addDayParse(String.valueOf(DateUtils.getDateInteger(endTime)), -7));
+            }
+
+            PageHelper.startPage(pageNum,pageSize);
+            //查询运营数据-账户 维度
+            List<KuaiShouOperateAccountVo> listOperate = materialStareMapper.getKuaiShouOperateAccountInfo(startDate,entDate,projectId,null,operatorUserIds);
+            for (KuaiShouOperateAccountVo accountInfo : listOperate) {
+                long accountId = accountInfo.getAccountId();
+                List<KuaiShouOperateAccountVo> accountYearOnYearInfo = materialStareMapper.getKuaiShouOperateAccountInfo(lastTimeStart,lastTimeEnd,projectId,accountId,operatorUserIds);
+                //环比 = (当前 - 上阶段 ) / 上阶段
+                Double yearOnYear = new Double(0);
+                if (!Check.isNull(accountYearOnYearInfo)){
+                    yearOnYear = (accountInfo.getTotalCost() - accountYearOnYearInfo.get(0).getTotalCost()) / accountYearOnYearInfo.get(0).getTotalCost() * 100;
+                    yearOnYear = Double.valueOf(String.format("%.2f", yearOnYear));
+                }
+                accountInfo.setYearOnYear(yearOnYear);
+
+                //同比 日期超过 7 天 则不显示
+                Double equallyRate = new Double(0);
+                if (daysBetween <= 7){
+                    List<KuaiShouOperateAccountVo> accountEquallyInfo = materialStareMapper.getKuaiShouOperateAccountInfo(startEqually,endEqually,projectId,accountId,operatorUserIds);
+                    if (!Check.isNull(accountEquallyInfo)){
+                        equallyRate = (accountInfo.getTotalCost() - accountEquallyInfo.get(0).getTotalCost()) / accountEquallyInfo.get(0).getTotalCost() * 100;
+                        equallyRate = Double.valueOf(String.format("%.2f", equallyRate));
+                    }
+                }
+                accountInfo.setEquallyRate(equallyRate);
+            }
+
+            PageInfo<KuaiShouOperateAccountVo> pageInfo = new PageInfo<>(listOperate);
+            return Result.successMsg("运营账户列表数据查询成功。",pageInfo);
+        }catch (Exception e){
+            e.printStackTrace();
+        }
+        return Result.errorMsg("哎呀,查询失败了。");
+    }
+
+
+    /**
+     *
+     * @description: 查询账户余额 以及 账户状态 和 消耗
+     *
+     * @param accountId
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/21
+     */
+    @Override
+    public Result getKuaiShouAccountInfo(long accountId) {
+        Map resultMap = new HashMap();
         SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMdd");
-        Long beforeDay = null;
+        // ==>> 20220202
+        String now = sdf.format(new Date());
+        long nowDate = Long.valueOf(now);
+
+        //账户余额
+        JSONObject balance = materialStareMapper.getKuaiShouAccountBalance(accountId, nowDate);
+        //账户今日消耗 以及状态
+        JSONObject totalCost = materialStareMapper.getKuaiShouAccountTotalCost(accountId, nowDate);
+
+        resultMap.put("balance",Check.isNull(balance) ? "0" : balance);
+        resultMap.put("totalCost",Check.isNull(totalCost) ? "0" : totalCost.getString("todayCost"));
+        //0-开 1-关
+        resultMap.put("state", Check.isNull(totalCost) ? "1" : totalCost.getString("accountStatus"));
+        return Result.successMsg("账户查询成功",resultMap);
+    }
+
+
+    /**
+     *
+     * @description: 账户 折线图 查询时间为当天查询时报;查询时间为多天 查询日报
+     *
+     * @param accountId
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/21
+     */
+    @Override
+    public Result getKuaiShouAccountInfoBrokenLine(long accountId, String startTime, String endTime) {
+
+        List<JSONObject> resultList = new ArrayList<>();
         try {
-            Date parse = sdf.parse(date.toString());
-            Calendar c = Calendar.getInstance();
-            c.setTime(parse);
-            int day1 = c.get(Calendar.DATE);
-            c.set(Calendar.DATE, day1 - 1);
-            beforeDay = Long.parseLong(sdf.format(c.getTime()));
-        } catch (ParseException e) {
+            //2022-02-15 ==>> 20220215
+            long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+            long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+
+            //两个日期之间的 间隔天数
+            Map<String,String> lastTime = DateUtils.getStartEndTime(startTime,endTime);
+            Integer daysBetween = Integer.valueOf(lastTime.get("daysBetween"));
+
+            if (daysBetween == 0){
+                resultList = materialStareMapper.getKuaiShouAccountInfoBrokenLineHour(accountId,startDate);
+                return Result.successMsg("账户时报报折线图查询成功",resultList);
+            }
+            resultList = materialStareMapper.getKuaiShouAccountInfoBrokenLineDaily(accountId,startDate,entDate);
+            return Result.successMsg("账户日报折线图查询成功",resultList);
+
+        }catch (Exception e){
             e.printStackTrace();
         }
-        return beforeDay;
+        return Result.errorMsg("账户折线图查询异常");
     }
 
+
     /**
-     * 查询当前人员所有下级 返回自己和下属id
+     *
+     * @description: 快手 账户 素材上新-有效-爆款
+     *
+     * @param accountId
+     * @param searchType searchType:查询类型  0-全部 1-上新 2-有效 3-爆款
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/21
      */
+    @Override
+    public Result getKuaiShouAccountMaterialNewAndEffectAndFaddish(long accountId, String searchType, String startTime, String endTime,Integer pageNum,Integer pageSize) {
+        //2022-02-15 ==>> 20220215
+        long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+        long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+        PageHelper.startPage(pageNum,pageSize);
+        List<JSONObject> resultList = materialStareMapper.getKuaiShouAccountMaterialNewAndEffectAndFaddish(accountId,searchType,startDate,entDate);
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(resultList);
+        return Result.successMsg("查询账户素材信息成功。",pageInfo);
+    }
+
+    /**
+     *
+     * @description: 查询账户饼图数据信息
+     *
+     * @param accountId
+     * @param startTime
+     * @param endTime
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     * @time: 2022/2/22
+     */
+    @Override
+    public Result getKuaiShouAccountPieChar(long accountId, String startTime, String endTime) {
+
+        Map resultMap = new HashMap();
+        //2022-02-15 ==>> 20220215
+        long startDate = Long.valueOf(DateUtils.getDateInteger(startTime));
+        long entDate = Long.valueOf(DateUtils.getDateInteger(endTime));
+        //版位
+        List<KuaiShouAccountPieVo> sceneList = materialStareMapper.getKuaiShouAccountPieScene(accountId,startDate,entDate);
+        //年龄
+        List<KuaiShouAccountPieVo> ageList = materialStareMapper.getKuaiShouAccountPieAge(accountId,startDate,entDate);
+        //性别
+        List<KuaiShouAccountPieVo> genderList = materialStareMapper.getKuaiShouAccountPieGender(accountId,startDate,entDate);
+        resultMap.put("scene",sceneList);
+        resultMap.put("age",ageList);
+        resultMap.put("gender",genderList);
+        return Result.successMsg("查询饼图数据成功。",resultMap);
+    }
 
+
+//===========================================查询下级员工========================
+
+    /**
+     * 查询当前人员所有下级 返回自己和下属id
+     */
     public Set<String> getAffiliateId(String userId) {
         Set<String> result;
         //查询当前用户是否存在下级
@@ -175,4 +567,6 @@ public class MaterialStareServiceImpl implements MaterialStareService {
         querySubordinate(temp, result);
         return result;
     }
+//===========================================查询下级员工========================
+
 }