Browse Source

设计绩效,改造

zhaoxian 2 years ago
parent
commit
9d34bf13f4

+ 0 - 1
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -3,7 +3,6 @@ package org.jeecg.common.util;
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONArray;
 import io.swagger.models.auth.In;
-import jdk.nashorn.internal.ir.LiteralNode;
 import net.sf.saxon.type.StringConverter;
 import org.hibernate.annotations.Check;
 import org.slf4j.Logger;

+ 170 - 79
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/controller/DesignerAchievementsController.java

@@ -1,18 +1,28 @@
 package cn.com.ctop.common.module.achievements.controller;
 
 import cn.com.ctop.common.module.achievements.service.IDesignerService;
-import com.alibaba.fastjson.JSON;
+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 com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageInfo;
 import io.swagger.annotations.Api;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.*;
-
+import org.springframework.web.bind.annotation.GetMapping;
+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.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.OutputStream;
+import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 
 /**
  * 设计人员绩效
@@ -30,148 +40,229 @@ public class DesignerAchievementsController {
     private IDesignerService designerService;
 
     /**
-     * 查询设计人员基础信息
-     *
-     * @param userId
-     * @return
-     */
-    @GetMapping(value = "/getDesignBasicsInfoList")
-    public PageInfo<JSONObject> getDesignBasicsInfoList(@RequestParam(name = "userId") String userId,
-                                                        @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
-                                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-
-        return designerService.getDesignBasicsInfoList(userId,pageNum,pageSize);
-
-    }
-
-    /**
-     * 爆款视频数据
+     * 修改绩效中的用户部分信息
      *
-     * @param userId
+     * @param jsonObject
      * @param
      * @return
      */
-    @GetMapping(value = "/getHotVideoData")
-    public List<Map<String,Object>> getHotVideoData(@RequestParam(name = "userId") String userId,
-                                                    @RequestParam(name = "yearTime")String yearTime,
-                                                    @RequestParam(name = "monthTime")String monthTime) {
+    @PostMapping(value = "/updateUserHappyProbability")
+    public Result updateUserHappyProbability(@RequestBody JSONObject jsonObject) {
 
-        return designerService.getHotVideoData(userId,yearTime,monthTime);
+        return designerService.updateUserHappyProbability(jsonObject);
 
     }
 
+
     /**
-     * 设计绩效
+     * 基础信息+爆款 --
      *
      * @param userId
-     * @param
+     * @param pageNum
+     * @param pageSize
      * @return
      */
-    @GetMapping(value = "/getDesignerAchievements")
-    public Map<String,Object> getDesignerAchievements(@RequestParam(name = "userId") String userId,
-                                                      @RequestParam(name = "yearTime")String yearTime,
-                                                      @RequestParam(name = "monthTime")String monthTime) {
-        return designerService.getDesignerAchievements(userId,yearTime,monthTime);
+    @GetMapping(value = "/getDesignerBasicsAndHotVideoInfo")
+    public Result getDesignerCommission(@RequestParam(name = "userId") String userId,
+                                        @RequestParam(name = "yearTime") String yearTime,
+                                        @RequestParam(name = "monthTime") String monthTime,
+                                        @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
+                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        return designerService.getDesignerBasicsAndHotVideoInfo(userId, yearTime, monthTime, pageNum, pageSize);
 
     }
 
+
     /**
-     * 设计提成
+     * 基础信息+绩效 --
      *
      * @param userId
-     * @param
+     * @param pageNum
+     * @param pageSize
      * @return
      */
-    @GetMapping(value = "/getDesignerCommission")
-    public JSONObject getDesignerCommission(@RequestParam(name = "userId") String userId,
-                                            @RequestParam(name = "yearTime")String yearTime,
-                                            @RequestParam(name = "monthTime")String monthTime) {
-        return designerService.getDesignerCommission(userId,yearTime,monthTime);
+    @GetMapping(value = "/getDesignerBasicsAndAch")
+    public Result getDesignerBasicsAndAch(@RequestParam(name = "userId") String userId,
+                                          @RequestParam(name = "yearTime") String yearTime,
+                                          @RequestParam(name = "monthTime") String monthTime,
+                                          @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
+                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        return designerService.getDesignerBasicsAndAch(userId, yearTime, monthTime, pageNum, pageSize);
 
     }
 
 
     /**
-     * 修改绩效中的用户部分信息
+     * 基础信息+提成
      *
-     * @param jsonObject
-     * @param
+     * @param userId
+     * @param pageNum
+     * @param pageSize
      * @return
      */
-    @PostMapping(value = "/updateUserHappyProbability")
-    public Result updateUserHappyProbability(@RequestBody JSONObject jsonObject) {
-
-        return designerService.updateUserHappyProbability(jsonObject);
+    @GetMapping(value = "/getDesignerBasicsAndAchAndComInfo")
+    public Result getDesignerBasicsAndAchAndComInfo(@RequestParam(name = "userId") String userId,
+                                                    @RequestParam(name = "yearTime") String yearTime,
+                                                    @RequestParam(name = "monthTime") String monthTime,
+                                                    @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        return designerService.getDesignerBasicsAndAchAndComInfo(userId, yearTime, monthTime, pageNum, pageSize);
 
     }
 
 
     /**
-     * 基础信息+爆款
+     * 基础信息+爆款 --
+     *
      * @param userId
-     * @param pageNum
-     * @param pageSize
      * @return
      */
-    @GetMapping(value = "/getDesignerBasicsAndHotVideoInfo")
-    public Result getDesignerCommission(@RequestParam(name = "userId") String userId,
-                                        @RequestParam(name = "yearTime") String yearTime,
-                                        @RequestParam(name = "monthTime") String monthTime,
-                                        @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
-                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-       return designerService.getDesignerBasicsAndHotVideoInfo(userId,yearTime,monthTime,pageNum,pageSize);
-
+    @GetMapping(value = "/getDesignerBasicsAndHotVideoInfoExcel")
+    public void getDesignerBasicsAndHotVideoInfoExcel(HttpServletResponse response,
+                                                      @RequestParam(name = "userId") String userId,
+                                                      @RequestParam(name = "yearTime") String yearTime,
+                                                      @RequestParam(name = "monthTime") String monthTime) {
+        try {
+            Result<PageInfo<JSONObject>> result = designerService.getDesignerBasicsAndHotVideoInfo(userId, yearTime, monthTime, 1, 99999);
+            PageInfo<JSONObject> pageInfo = result.getResult();
+            List<List<Object>> excelList = new ArrayList<>();
+            Integer month = 0;
+            if (!Check.isNull(pageInfo)) {
+                List<JSONObject> list = pageInfo.getList();
+                if (!list.isEmpty()) {
+                    month = list.get(0).getJSONObject("bytedance").getInteger("monthTime1");
+                    list.forEach(data -> {
+                        List<Object> temp = new ArrayList<>();
+                        temp.add(data.getString("userName"));
+                        temp.add(data.getString("roleName"));
+                        temp.add("1".equals(data.getString("status")) ? "正常" : "冻结");
+                        temp.add(data.getString("departName"));
+                        JSONObject bytedance = data.getJSONObject("bytedance");
+                        JSONObject kuaishou = data.getJSONObject("kuaishou");
+                        temp.add(kuaishou.getString("hotNum1"));
+                        temp.add(kuaishou.getString("hotNum2"));
+                        temp.add(kuaishou.getString("hotNum3"));
+                        temp.add(bytedance.getString("hotNum1"));
+                        temp.add(bytedance.getString("hotNum2"));
+                        temp.add(bytedance.getString("hotNum3"));
+                        excelList.add(temp);
+                    });
+                }
+                List<Integer> monthInt = null;
+                OutputStream os = response.getOutputStream();
+                ExportExcelUtils eeu = new ExportExcelUtils();
+                XSSFWorkbook workbook = new XSSFWorkbook();
+                String[] titles = {"姓名", "岗位", "状态", "组别",
+                        "快手" + month + "月爆款", "快手" + (month + 1) + "月爆款", "快手" + (month + 2) + "月爆款",
+                        "头条" + month + "月爆款", "头条" + (month + 1) + "月爆款", "头条" + (month + 2) + "月爆款"};
+                eeu.exportExcelForAttendance(workbook, 0, "设计爆款数据", titles, excelList);
+                HttpUtils.setResponseHeader(response, "clockIn.xlsx");
+                workbook.write(os);
+                os.flush();
+                os.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
 
-
     /**
-     * 基础信息+绩效
+     * 基础信息+绩效 --
+     *
      * @param userId
-     * @param pageNum
-     * @param pageSize
      * @return
      */
-    @GetMapping(value = "/getDesignerBasicsAndAch")
-    public Result getDesignerBasicsAndAch(@RequestParam(name = "userId") String userId,
-                                                    @RequestParam(name = "yearTime") String yearTime,
-                                                    @RequestParam(name = "monthTime") String monthTime,
-                                        @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
-                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-       return designerService.getDesignerBasicsAndAch(userId,yearTime,monthTime,pageNum,pageSize);
-
+    @GetMapping(value = "/getDesignerBasicsAndAchExcel")
+    public void getDesignerBasicsAndAchExcel(HttpServletResponse response,
+                                             @RequestParam(name = "userId") String userId,
+                                             @RequestParam(name = "yearTime") String yearTime,
+                                             @RequestParam(name = "monthTime") String monthTime) {
+        try {
+            Result<PageInfo<JSONObject>> result = designerService.getDesignerBasicsAndAch(userId, yearTime, monthTime, 1, 99999);
+            PageInfo<JSONObject> pageInfo = result.getResult();
+            List<List<Object>> excelList = new ArrayList<>();
+            Integer month = 0;
+            if (!Check.isNull(pageInfo)) {
+                List<JSONObject> list = pageInfo.getList();
+                if (!list.isEmpty()) {
+                    month = list.get(0).getJSONArray("byteDanceData").getJSONObject(0).getInteger("monthTime");
+                    list.forEach(data -> {
+                        List<Object> temp = new ArrayList<>();
+                        temp.add(data.getString("userName"));
+                        temp.add(data.getString("roleName"));
+                        temp.add("1".equals(data.getString("status")) ? "正常" : "冻结");
+                        temp.add(data.getString("departName"));
+                        JSONArray bytedance = data.getJSONArray("byteDanceData");
+                        JSONArray kuaishou = data.getJSONArray("kuaiShouData");
+                        for (int i = 0; i < kuaishou.size(); i++) {//clip剪辑id>plan 编导id>shot 拍摄id
+                            JSONObject obj = kuaishou.getJSONObject(i);
+                            temp.add(obj.getDouble("cost"));
+                            temp.add(obj.getDouble("commission"));
+                        }
+                        for (int i = 0; i < bytedance.size(); i++) {//clip剪辑id>plan 编导id>shot 拍摄id
+                            JSONObject obj = bytedance.getJSONObject(i);
+                            temp.add(obj.getDouble("cost"));
+                            temp.add(obj.getDouble("commission"));
+                        }
+                        excelList.add(temp);
+                    });
+                }
+                List<Integer> monthInt = null;
+                OutputStream os = response.getOutputStream();
+                ExportExcelUtils eeu = new ExportExcelUtils();
+                XSSFWorkbook workbook = new XSSFWorkbook();
+                String[] titles = {"姓名", "岗位", "状态", "组别",
+                        month + "月快手剪辑消耗", month + "月快手剪辑提成", month + "月快手编导消耗", month + "月快手编导提成", month + "月快手拍摄消耗", month + "月快手拍摄提成",
+                        (month + 1) + "月快手剪辑消耗", (month + 1) + "月快手剪辑提成", (month + 1) + "月快手编导消耗", (month + 1) + "月快手编导提成", (month + 1) + "月快手拍摄消耗", (month + 1) + "月快手拍摄提成",
+                        (month + 2) + "月快手剪辑消耗", (month + 2) + "月快手剪辑提成", (month + 2) + "月快手编导消耗", (month + 2) + "月快手编导提成", (month + 2) + "月快手拍摄消耗", (month + 2) + "月快手拍摄提成",
+                        month + "月头条剪辑消耗", month + "月头条剪辑提成", month + "月头条编导消耗", month + "月头条编导提成", month + "月头条拍摄消耗", month + "月头条拍摄提成",
+                        (month + 1) + "月头条剪辑消耗", (month + 1) + "月头条剪辑提成", (month + 1) + "月头条编导消耗", (month + 1) + "月头条编导提成", (month + 1) + "月头条拍摄消耗", (month + 1) + "月头条拍摄提成",
+                        (month + 2) + "月头条剪辑消耗", (month + 2) + "月头条剪辑提成", (month + 2) + "月头条编导消耗", (month + 2) + "月头条编导提成", (month + 2) + "月头条拍摄消耗", (month + 2) + "月头条拍摄提成",
+                };
+                eeu.exportExcelForAttendance(workbook, 0, "设计基础数据", titles, excelList);
+                HttpUtils.setResponseHeader(response, "clockIn.xlsx");
+                workbook.write(os);
+                os.flush();
+                os.close();
+            }
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 
 
     /**
      * 基础信息+提成
+     *
      * @param userId
      * @param pageNum
      * @param pageSize
      * @return
      */
-    @GetMapping(value = "/getDesignerBasicsAndAchAndComInfo")
-    public Result getDesignerBasicsAndAchAndComInfo(@RequestParam(name = "userId") String userId,
-                                                    @RequestParam(name = "yearTime") String yearTime,
-                                                    @RequestParam(name = "monthTime") String monthTime,
-                                        @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
-                                        @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
-       return designerService.getDesignerBasicsAndAchAndComInfo(userId,yearTime,monthTime,pageNum,pageSize);
+    @GetMapping(value = "/getDesignerBasicsAndAchAndComInfoExcel")
+    public Result getDesignerBasicsAndAchAndComInfoExcel(HttpServletResponse response,
+                                                         @RequestParam(name = "userId") String userId,
+                                                         @RequestParam(name = "yearTime") String yearTime,
+                                                         @RequestParam(name = "monthTime") String monthTime,
+                                                         @RequestParam(name = "pageNum", defaultValue = "1") Integer pageNum,
+                                                         @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        return designerService.getDesignerBasicsAndAchAndComInfo(userId, yearTime, monthTime, pageNum, pageSize);
 
     }
 
 
     /**
      * 根据角色查询人员
+     *
      * @param roleName
      * @return
      */
     @GetMapping(value = "/getUserByRoleName")
     public Result getUserByRoleName(@RequestParam(name = "roleName") String roleName) {
-       return designerService.getUserByRoleName(roleName);
+        return designerService.getUserByRoleName(roleName);
 
     }
 
 
-
 }

+ 41 - 33
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/mapper/DesignerMapper.java

@@ -1,10 +1,10 @@
 package cn.com.ctop.common.module.achievements.mapper;
 
 import com.alibaba.fastjson.JSONObject;
-import io.swagger.models.auth.In;
 import org.apache.ibatis.annotations.Param;
 
 import java.util.List;
+import java.util.Map;
 import java.util.Set;
 
 /**
@@ -14,108 +14,116 @@ import java.util.Set;
  * @date: 2022-09-28
  * @cersion: V1.0
  */
-public interface DesignerMapper{
+public interface DesignerMapper {
 
     /**
      * 查询设计人员基础信息
+     *
      * @param userIdList 用户id
      * @param departName 部门名称
      * @return
      */
-    List<JSONObject> getDesignerUserInfo(@Param("departName")String departName,@Param("userIdList") Set<String> userIdList);
+    List<JSONObject> getDesignerUserInfo(@Param("roleCodes") List<String> roleCodes, @Param("userIdList") Set<String> userIdList, @Param("startTime") Integer startTime, @Param("endTime") Integer endTime);
 
 
     /**
      * 获取爆款视频数量
+     *
      * @param userId
      * @param roleName  角色名称
      * @param mediaType 1-头条 2-快手
      * @param startTime 当前年份
-     * @param endTime 当前月份
+     * @param endTime   当前月份
      * @return
      */
-    JSONObject  getHotVideoData(@Param("userId")String userId,
-                                     @Param("roleName") String roleName,
-                                     @Param("mediaType") Integer mediaType,
-                                @Param("startTime") Integer startTime,
-                                @Param("endTime") Integer endTime);
+    JSONObject getHotVideoData(@Param("userId") String userId,  @Param("roleName") String roleName,@Param("mediaType") Integer mediaType, @Param("month1") Map<String, Integer> month1, @Param("month2") Map<String, Integer> month2, @Param("month3") Map<String, Integer> month3);
 
 
     /**
-     *  设计人员绩效-头条
+     * 设计人员绩效-头条
+     *
      * @param userId
      * @param startTime
      * @param endTime
      * @return
      */
-    List<JSONObject>  getDesignerAchievementsBytedance(@Param("userId")String userId,
-                                     @Param("startTime") Integer startTime,
-                                     @Param("endTime") Integer endTime);
-
-
-     List<JSONObject>  getDesignerAchievementsKuaishou(@Param("userId")String userId,
-                                     @Param("startTime") Integer startTime,
-                                     @Param("endTime") Integer endTime);
+    List<JSONObject> getDesignerAchievementsBytedance(@Param("userId") String userId,
+                                                      @Param("startTime") Integer startTime,
+                                                      @Param("endTime") Integer endTime);
 
 
+    List<JSONObject> getDesignerAchievementsKuaishou(@Param("userId") String userId,
+                                                     @Param("startTime") Integer startTime,
+                                                     @Param("endTime") Integer endTime);
 
 
     /**
      * 查询设计 本季度 头条  季度消耗汇总
+     *
      * @param userId
      * @return
      */
-    List<JSONObject>  getDesignerBytedanceQuaterCost(@Param("userId")String userId,@Param("startTime") Integer startTime,
-                                                                @Param("endTime") Integer endTime);
-/**
+    List<JSONObject> getDesignerBytedanceQuaterCost(@Param("userId") String userId, @Param("startTime") Integer startTime,
+                                                    @Param("endTime") Integer endTime);
+
+    /**
      * 查询设计 本季度 快手季度消耗汇总
+     *
      * @param userId
      * @return
      */
-    List<JSONObject>  getDesignerKuaishouQuaterCost(@Param("userId")String userId,@Param("startTime") Integer startTime,
-                                                                @Param("endTime") Integer endTime);
+    List<JSONObject> getDesignerKuaishouQuaterCost(@Param("userId") String userId, @Param("startTime") Integer startTime,
+                                                   @Param("endTime") Integer endTime);
 
     /**
      * 管理消耗
+     *
      * @param userId
      * @param startTime
      * @param endTime
      * @return
      */
-    List<JSONObject>  getDesignerManagerLeaderCost(@Param("userId")String userId,@Param("startTime") Integer startTime,
-                                             @Param("endTime") Integer endTime);
+    List<JSONObject> getDesignerManagerLeaderCost(@Param("userId") String userId, @Param("startTime") Integer startTime,
+                                                  @Param("endTime") Integer endTime);
 
     /**
      * 查询人员离职时间
+     *
      * @param userId
      * @return
      */
-    JSONObject  getUserFrozenInfo(@Param("userId")String userId);
+    JSONObject getUserFrozenInfo(@Param("userId") String userId);
 
     /**
      * 查询人员 当前季度爆款素材数量
+     *
      * @param userId
      * @return
      */
-    JSONObject  getUserHotMaterialQuarter(@Param("userId")String userId,@Param("startTime") Integer startTime,
-                                          @Param("endTime") Integer endTime);
+    JSONObject getUserHotMaterialQuarter(@Param("userId") String userId, @Param("startTime") Integer startTime,
+                                         @Param("endTime") Integer endTime);
 
     /**
      * 绩效- 用户信息修改
+     *
      * @return
      */
-    void  updateUserHappyProbability(@Param("userId")String userId,
-                                           @Param("openScreenNum")String openScreenNum,
-                                           @Param("paySalary")String paySalary,
-                                           @Param("remarks")String remarks);
+    void updateUserHappyProbability(@Param("userId") String userId,
+                                    @Param("openScreenNum") String openScreenNum,
+                                    @Param("paySalary") String paySalary,
+                                    @Param("remarks") String remarks);
 
 
     /**
      * 根据角色查询人员
+     *
      * @param roleName
      * @return
      */
-    List<JSONObject> getUserByRoleName(@Param("roleName")String roleName);
+    List<JSONObject> getUserByRoleName(@Param("roleName") String roleName);
+
 
+    List<JSONObject> getQuarterDesignerAchievementsByTedance(@Param("userId") String userId, @Param("month1") Map<String, Integer> month1, @Param("month2") Map<String, Integer> month2, @Param("month3") Map<String, Integer> month3);
 
+    List<JSONObject> getQuarterDesignerAchievementsByKuaishou(@Param("userId") String userId, @Param("month1") Map<String, Integer> month1, @Param("month2") Map<String, Integer> month2, @Param("month3") Map<String, Integer> month3);
 }

+ 480 - 205
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/mapper/xml/DesignerMapper.xml

@@ -6,275 +6,326 @@
     <!-- 查询设计人员基础信息 -->
     <select id="getDesignerUserInfo" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
-            u.id AS userId,
-            u.realname AS userName,
-            u.sex AS userSex,
-            u.frozen_time AS frozenTime,
-            d.depart_name AS departName,
-            r.role_name AS roleName,
-            u.`status`
+        u.id AS userId,
+        u.realname AS userName,
+        u.sex AS userSex,
+        IFNULL(u.frozen_time,'-') AS frozenTime,
+        d.depart_name AS departName,
+        r.role_name AS roleName,
+        u.`status`
         FROM
-            `jeecg-boot`.sys_user u
-                LEFT JOIN `jeecg-boot`.sys_depart d ON u.org_code = d.org_code
-                LEFT JOIN `jeecg-boot`.sys_user_role ur ON ur.user_id = u.id
-                LEFT JOIN `jeecg-boot`.sys_role r ON r.id = ur.role_id
-        <where>
-            <if test="departName != null and departName != ''">
-                and d.depart_name LIKE concat('%',#{departName},'%')
-            </if>
-            <if test="userIdList != null and userIdList.size() > 0">
-                and u.id in
-                    <foreach collection="userIdList" item="userId" separator="," open="(" close=")">
-                        #{userId}
-                    </foreach>
-            </if>
-        </where>
-        ORDER BY u.id
+        `jeecg-boot`.sys_user u
+        LEFT JOIN `jeecg-boot`.sys_depart d ON u.org_code = d.org_code
+        LEFT JOIN `jeecg-boot`.sys_user_role ur ON ur.user_id = u.id
+        LEFT JOIN `jeecg-boot`.sys_role r ON r.id = ur.role_id
+        where u.STATUS = 1 AND u.del_flag = 0
+        <if test="roleCodes != null and roleCodes.size() > 0">
+            and
+            <foreach collection="roleCodes" item="roleCode" separator=" OR " open="(" close=")">
+                r.role_name LIKE concat(#{roleCode},'%')
+            </foreach>
+        </if>
+        <if test="userIdList != null and userIdList.size() > 0">
+            and u.id in
+            <foreach collection="userIdList" item="userId" separator="," open="(" close=")">
+                #{userId}
+            </foreach>
+        </if>
+        UNION
+        SELECT
+        u.id AS userId,
+        u.realname AS userName,
+        u.sex AS userSex,
+        u.frozen_time AS frozenTime,
+        d.depart_name AS departName,
+        r.role_name AS roleName,
+        u.`status`
+        FROM
+        `jeecg-boot`.sys_user u
+        LEFT JOIN `jeecg-boot`.sys_depart d ON u.org_code = d.org_code
+        LEFT JOIN `jeecg-boot`.sys_user_role ur ON ur.user_id = u.id
+        LEFT JOIN `jeecg-boot`.sys_role r ON r.id = ur.role_id
+        where (u.STATUS != 1 OR u.del_flag != 0)
+        <if test="roleCodes != null and roleCodes.size() > 0">
+            and
+            <foreach collection="roleCodes" item="roleCode" separator=" OR " open="(" close=")">
+                r.role_name LIKE concat(#{roleCode},'%')
+            </foreach>
+        </if>
+        <if test="userIdList != null and userIdList.size() > 0">
+            and u.id in
+            <foreach collection="userIdList" item="userId" separator="," open="(" close=")">
+                #{userId}
+            </foreach>
+        </if>
+        AND (DATE_FORMAT(u.update_time,'%Y%m%d') BETWEEN #{startTime} AND #{endTime} OR
+        DATE_FORMAT(u.frozen_time,'%Y%m%d') BETWEEN #{startTime} AND #{endTime})
+        ORDER BY userId
     </select>
 
 
-
     <!-- 查询设计人员基础信息 -->
     <select id="getHotVideoData" resultType="com.alibaba.fastjson.JSONObject">
+        select * FROM (
         SELECT
-        QUARTER	( h.hot_date ) quaterTime,
-        DATE_FORMAT( h.hot_date, '%Y' ) yearTime,
-        DATE_FORMAT( h.hot_date, '%m' ) monthTime,
-        IFNULL( COUNT( h.signature ), 0 ) AS hotNum
+        DATE_FORMAT( #{month1.startTime}, '%m' ) as 'monthTime1',
+        IFNULL( COUNT( h.signature ), 0 ) AS 'hotNum1'
         FROM
         application.hot_material h
         LEFT JOIN `jeecg-boot`.ctop_material_ascription v ON v.material_id = h.signature
-        where
-         h.media_id = #{mediaType}
-        AND h.hot_date &gt;= #{startTime}
-        AND  h.hot_date &lt;= #{endTime}
+        WHERE
+        h.media_id = #{mediaType}
+        AND h.hot_date &gt;= #{month1.startTime}
+        AND h.hot_date &lt;= #{month1.endTime}
+        <if test="roleName == 'clip'.toString()">
+            AND clip_id = #{userId}
+        </if>
+        <if test="roleName == 'shot'.toString()">
+            AND shot_id = #{userId}
+        </if>
+        <if test="roleName == 'plan'.toString()">
+            AND plan_id = #{userId}
+        </if>
+        <if test="roleName == 'all'.toString()">
+            AND (plan_id = #{userId} or clip_id = #{userId} or shot_id = #{userId} or leader_id = #{userId})
+        </if>
+        ) t1
+        LEFT JOIN (
+        SELECT
+        DATE_FORMAT( #{month2.startTime}, '%m' ) as 'monthTime2',
+        IFNULL( COUNT( h.signature ), 0 ) AS 'hotNum2'
+        FROM
+        application.hot_material h
+        LEFT JOIN `jeecg-boot`.ctop_material_ascription v ON v.material_id = h.signature
+        WHERE
+        h.media_id = #{mediaType}
+        AND h.hot_date &gt;= #{month2.startTime}
+        AND h.hot_date &lt;= #{month2.endTime}
         <if test="roleName == 'clip'.toString()">
             AND clip_id = #{userId}
         </if>
-
         <if test="roleName == 'shot'.toString()">
             AND shot_id = #{userId}
         </if>
-
         <if test="roleName == 'plan'.toString()">
             AND plan_id = #{userId}
         </if>
-
         <if test="roleName == 'all'.toString()">
             AND (plan_id = #{userId} or clip_id = #{userId} or shot_id = #{userId} or leader_id = #{userId})
         </if>
+        )t2 ON 1=1
+        LEFT JOIN (
+        SELECT
+        DATE_FORMAT( #{month3.startTime}, '%m' ) as 'monthTime3',
+        IFNULL( COUNT( h.signature ), 0 ) AS 'hotNum3'
+        FROM
+        application.hot_material h
+        LEFT JOIN `jeecg-boot`.ctop_material_ascription v ON v.material_id = h.signature
+        WHERE
+        h.media_id = #{mediaType}
+        AND h.hot_date &gt;= #{month3.startTime}
+        AND h.hot_date &lt;= #{month3.endTime}
+        <if test="roleName == 'clip'.toString()">
+            AND clip_id = #{userId}
+        </if>
+        <if test="roleName == 'shot'.toString()">
+            AND shot_id = #{userId}
+        </if>
+        <if test="roleName == 'plan'.toString()">
+            AND plan_id = #{userId}
+        </if>
+        <if test="roleName == 'all'.toString()">
+            AND (plan_id = #{userId} or clip_id = #{userId} or shot_id = #{userId} or leader_id = #{userId})
+        </if>
+        )t3 ON 1=1
 
     </select>
 
 
-
-
     <!-- 查询设计人员 头条绩效-->
     <select id="getDesignerAchievementsBytedance" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            QUARTER	( d.first_cost_day ) quaterTime,
-            DATE_FORMAT( d.first_cost_day, '%Y' ) yearTime,
-            DATE_FORMAT( d.first_cost_day, '%m' ) monthTime,
-            IFNULL( sum( d.cost ), 0 ) AS cost,
-            '0.3' AS coefficient,
-            IFNULL( round(( sum( d.cost ) * 0.002 * 0.3 ), 3 ), 0 ) AS commission,
-            'clip' AS type
-        FROM
-            application.bytedance_material_cost_daily d
-        WHERE
-            clip_id = #{userId}
+        SELECT QUARTER(d.first_cost_day)                           quaterTime,
+               DATE_FORMAT(d.first_cost_day, '%Y')                 yearTime,
+               DATE_FORMAT(d.first_cost_day, '%m')                 monthTime,
+               IFNULL(sum(d.cost), 0)                           AS cost,
+               '0.3'                                            AS coefficient,
+               IFNULL(round((sum(d.cost) * 0.002 * 0.3), 3), 0) AS commission,
+               'clip'                                           AS type
+        FROM application.bytedance_material_cost_daily d
+        WHERE clip_id = #{userId}
           AND d.stat_date &gt;= #{startTime}
           AND d.stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
         UNION ALL
-        SELECT
-            QUARTER	( d.first_cost_day ) quaterTime,
-            DATE_FORMAT( d.first_cost_day, '%Y' ) yearTime,
-            DATE_FORMAT( d.first_cost_day, '%m' ) monthTime,
-            IFNULL( sum( d.cost ), 0 ) AS cost,
-            '0.1' AS coefficient,
-            IFNULL( round(( sum( d.cost ) * 0.002 * 0.1 ), 3 ), 0 ) AS commission,
-            'shot' AS type
-        FROM
-            application.bytedance_material_cost_daily d
-        WHERE
-            shot_id = #{userId}
+        SELECT QUARTER(d.first_cost_day)                           quaterTime,
+               DATE_FORMAT(d.first_cost_day, '%Y')                 yearTime,
+               DATE_FORMAT(d.first_cost_day, '%m')                 monthTime,
+               IFNULL(sum(d.cost), 0)                           AS cost,
+               '0.1'                                            AS coefficient,
+               IFNULL(round((sum(d.cost) * 0.002 * 0.1), 3), 0) AS commission,
+               'shot'                                           AS type
+        FROM application.bytedance_material_cost_daily d
+        WHERE shot_id = #{userId}
           AND d.stat_date &gt;= #{startTime}
           AND d.stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
         UNION ALL
-        SELECT
-            QUARTER	( d.first_cost_day ) quaterTime,
-            DATE_FORMAT( d.first_cost_day, '%Y' ) yearTime,
-            DATE_FORMAT( d.first_cost_day, '%m' ) monthTime,
-            IFNULL( sum( d.cost ), 0 ) AS cost,
-            '0.4' AS coefficient,
-            IFNULL( round(( sum( d.cost ) * 0.002 * 0.4 ), 3 ), 0 ) AS commission,
-            'plan' AS type
-        FROM
-            application.bytedance_material_cost_daily d
-        WHERE
-            plan_id = #{userId}
+        SELECT QUARTER(d.first_cost_day)                           quaterTime,
+               DATE_FORMAT(d.first_cost_day, '%Y')                 yearTime,
+               DATE_FORMAT(d.first_cost_day, '%m')                 monthTime,
+               IFNULL(sum(d.cost), 0)                           AS cost,
+               '0.4'                                            AS coefficient,
+               IFNULL(round((sum(d.cost) * 0.002 * 0.4), 3), 0) AS commission,
+               'plan'                                           AS type
+        FROM application.bytedance_material_cost_daily d
+        WHERE plan_id = #{userId}
           AND d.stat_date &gt;= #{startTime}
           AND d.stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
     </select>
 
 
     <!-- 查询设计人员 快手绩效-->
     <select id="getDesignerAchievementsKuaishou" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            QUARTER	( d.first_cost_day ) quaterTime,
-            DATE_FORMAT( d.first_cost_day, '%Y' ) yearTime,
-            DATE_FORMAT( d.first_cost_day, '%m' ) monthTime,
-            IFNULL( sum( d.charge ), 0 ) AS cost,
-            '0.3' AS coefficient,
-            IFNULL( round(( sum( d.charge ) * 0.003 * 0.3 ), 3 ), 0 ) AS commission,
-            'clip' AS type
-        FROM
-            application.kuaishou_material_cost_daily d
-        WHERE
-            clip_id = #{userId}
+        SELECT QUARTER(d.first_cost_day)                             quaterTime,
+               DATE_FORMAT(d.first_cost_day, '%Y')                   yearTime,
+               DATE_FORMAT(d.first_cost_day, '%m')                   monthTime,
+               IFNULL(sum(d.charge), 0)                           AS cost,
+               '0.3'                                              AS coefficient,
+               IFNULL(round((sum(d.charge) * 0.003 * 0.3), 3), 0) AS commission,
+               'clip'                                             AS type
+        FROM application.kuaishou_material_cost_daily d
+        WHERE clip_id = #{userId}
           AND d.stat_date &gt;= #{startTime}
           AND d.stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
         UNION ALL
-        SELECT
-            QUARTER	( d.first_cost_day ) quaterTime,
-            DATE_FORMAT( d.first_cost_day, '%Y' ) yearTime,
-            DATE_FORMAT( d.first_cost_day, '%m' ) monthTime,
-            IFNULL( sum( d.charge ), 0 ) AS cost,
-            '0.1' AS coefficient,
-            IFNULL( round(( sum( d.charge ) * 0.003 * 0.1 ), 3 ), 0 ) AS commission,
-            'shot' AS type
-        FROM
-            application.kuaishou_material_cost_daily d
-        WHERE
-            shot_id = #{userId}
+        SELECT QUARTER(d.first_cost_day)                             quaterTime,
+               DATE_FORMAT(d.first_cost_day, '%Y')                   yearTime,
+               DATE_FORMAT(d.first_cost_day, '%m')                   monthTime,
+               IFNULL(sum(d.charge), 0)                           AS cost,
+               '0.1'                                              AS coefficient,
+               IFNULL(round((sum(d.charge) * 0.003 * 0.1), 3), 0) AS commission,
+               'shot'                                             AS type
+        FROM application.kuaishou_material_cost_daily d
+        WHERE shot_id = #{userId}
           AND d.stat_date &gt;= #{startTime}
           AND d.stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
         UNION ALL
-        SELECT
-            QUARTER( d.first_cost_day ) quaterTime,
-            DATE_FORMAT( d.first_cost_day, '%Y' ) yearTime,
-            DATE_FORMAT( d.first_cost_day, '%m' ) monthTime,
-            IFNULL( sum( d.charge ), 0 ) AS cost,
-            '0.4' AS coefficient,
-            IFNULL( round(( sum( d.charge ) * 0.003 * 0.4 ), 3 ), 0 ) AS commission,
-            'plan' AS type
-        FROM
-            application.kuaishou_material_cost_daily d
-        WHERE
-            plan_id = #{userId}
+        SELECT QUARTER(d.first_cost_day)                             quaterTime,
+               DATE_FORMAT(d.first_cost_day, '%Y')                   yearTime,
+               DATE_FORMAT(d.first_cost_day, '%m')                   monthTime,
+               IFNULL(sum(d.charge), 0)                           AS cost,
+               '0.4'                                              AS coefficient,
+               IFNULL(round((sum(d.charge) * 0.003 * 0.4), 3), 0) AS commission,
+               'plan'                                             AS type
+        FROM application.kuaishou_material_cost_daily d
+        WHERE plan_id = #{userId}
           AND d.stat_date &gt;= #{startTime}
           AND d.stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
     </select>
 
     <!-- 查询设计 本季度 头条季度消耗汇总-->
     <select id="getDesignerBytedanceQuaterCost" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            QUARTER( d.first_cost_day ) quaterTime,
-            YEAR ( d.first_cost_day ) yearTime,
-            IFNULL( sum( d.cost ), 0 ) AS cost,
-            'byteDance' AS type
+        SELECT QUARTER(#{startTime}) AS 'quaterTime',
+            YEAR (
+               #{startTime}) AS 'yearTime',
+            IFNULL(SUM( d.cost ), 0 ) AS 'cost',
+            'byteDance' AS 'type'
         FROM
             application.bytedance_material_cost_daily d
         WHERE
             (
-            d.clip_id = #{userId} OR d.shot_id = #{userId} OR d.plan_id = #{userId}
+            d.clip_id = #{userId}
+           OR d.shot_id = #{userId}
+           OR d.plan_id = #{userId}
             )
           AND stat_date &gt;= #{startTime}
-          AND  stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND stat_date &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
     </select>
-<!-- 查询设计 本季度 快手季度消耗汇总-->
+    <!-- 查询设计 本季度 快手季度消耗汇总-->
     <select id="getDesignerKuaishouQuaterCost" resultType="com.alibaba.fastjson.JSONObject">
-               SELECT
-            QUARTER( d.first_cost_day ) quaterTime,
-            YEAR ( d.first_cost_day ) yearTime,
-            IFNULL( sum( d.charge ), 0 ) AS cost,
-            'kuaiShou' AS type
+        SELECT QUARTER(#{startTime}) AS 'quaterTime',
+            YEAR (
+               #{startTime}) AS 'yearTime',
+            IFNULL( SUM( d.charge ), 0 ) AS 'cost',
+            'kuaiShou' AS 'type'
         FROM
             application.kuaishou_material_cost_daily d
-
         WHERE
             (
-            d.clip_id = #{userId} OR d.shot_id = #{userId} OR d.plan_id = #{userId}
+            d.clip_id = #{userId}
+           OR d.shot_id = #{userId}
+           OR d.plan_id = #{userId}
             )
           AND stat_date &gt;= #{startTime}
-          AND  stat_date &lt;= #{endTime}
-          AND  d.first_cost_day &gt;= #{startTime}
-          AND  d.first_cost_day &lt;= #{endTime}
+          AND stat_date &lt;= #{endTime}
+          AND d.first_cost_day &gt;= #{startTime}
+          AND d.first_cost_day &lt;= #{endTime}
     </select>
 
-   <!-- 管理消耗-->
+    <!-- 管理消耗-->
     <select id="getDesignerManagerLeaderCost" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT * FROM
-            (
-                SELECT IFNULL(SUM(cost),0) cost,leader_id,'bytedance' as type ,1 as sort FROM
-                    application.bytedance_material_cost_daily
-                WHERE leader_id = #{userId}
-                  AND  stat_date &gt;= #{startTime}
-                  AND stat_date &lt;= #{endTime}
-                  AND first_cost_day &gt;= #{startTime}
-                  AND first_cost_day &lt;= #{endTime}
-                UNION
-                SELECT IFNULL(SUM(charge),0) cost,leader_id,'kuaishou' as type,2 as sort FROM
-                    application.kuaishou_material_cost_daily
-                WHERE leader_id = #{userId}
-                  AND  stat_date &gt;= #{startTime}
-                  AND stat_date &lt;= #{endTime}
-                  AND first_cost_day &gt;= #{startTime}
-                  AND first_cost_day &lt;= #{endTime}
-            )  t
+        SELECT *
+        FROM (
+                 SELECT IFNULL(SUM(cost), 0) cost, leader_id, 'bytedance' as type, 1 as sort
+                 FROM application.bytedance_material_cost_daily
+                 WHERE leader_id = #{userId}
+                   AND stat_date &gt;= #{startTime}
+                   AND stat_date &lt;= #{endTime}
+                   AND first_cost_day &gt;= #{startTime}
+                   AND first_cost_day &lt;= #{endTime}
+                 UNION
+                 SELECT IFNULL(SUM(charge), 0) cost, leader_id, 'kuaishou' as type, 2 as sort
+                 FROM application.kuaishou_material_cost_daily
+                 WHERE leader_id = #{userId}
+                   AND stat_date &gt;= #{startTime}
+                   AND stat_date &lt;= #{endTime}
+                   AND first_cost_day &gt;= #{startTime}
+                   AND first_cost_day &lt;= #{endTime}
+             ) t
         ORDER BY t.sort
     </select>
 
 
     <!-- 查询人员离职时间-->
     <select id="getUserFrozenInfo" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            u.id userId,
-            u.username userName,
-            u.realname realName,
-            u.create_time createTime,
-            u.frozen_time frozenTime,
-            IFNULL(u.open_screen_num,0) openHotVideoNum,
-            IFNULL(u.pay_salary,0) paySalary,
-            u.remarks,
-            u.status
-        FROM
-            `jeecg-boot`.sys_user u
-        WHERE u.id = #{userId}
-            limit 1
+        SELECT u.id                         userId,
+               u.username                   userName,
+               u.realname                   realName,
+               u.create_time                createTime,
+               u.frozen_time                frozenTime,
+               IFNULL(u.open_screen_num, 0) openHotVideoNum,
+               IFNULL(u.pay_salary, 0)      paySalary,
+               u.remarks,
+               u.status
+        FROM `jeecg-boot`.sys_user u
+        WHERE u.id = #{userId} limit 1
     </select>
 
 
     <!-- 查询人员 当前季度爆款素材数量 -->
     <select id="getUserHotMaterialQuarter" resultType="com.alibaba.fastjson.JSONObject">
-        SELECT
-            COUNT(h.signature) hotVideoNum
-        FROM
-            application.hot_material h
-                LEFT JOIN `jeecg-boot`.ctop_material_ascription v ON v.material_id = h.signature
-        WHERE
-
-                (v.plan_id = #{userId}
-                    OR v.clip_id = #{userId}
-                    or v.shot_id =#{userId}
-                    or v.leader_id = #{userId}
-                    )
-          AND  h.hot_date &gt;= #{startTime}
-          AND  h.hot_date &lt;= #{endTime}
+        SELECT COUNT(h.signature) hotVideoNum
+        FROM application.hot_material h
+                 LEFT JOIN `jeecg-boot`.ctop_material_ascription v ON v.material_id = h.signature
+        WHERE (v.plan_id = #{userId}
+            OR v.clip_id = #{userId}
+            or v.shot_id = #{userId}
+            or v.leader_id = #{userId}
+            )
+          AND h.hot_date &gt;= #{startTime}
+          AND h.hot_date &lt;= #{endTime}
 
     </select>
 
@@ -297,8 +348,6 @@
     </update>
 
 
-
-
     <!-- 根据角色查询人员 -->
     <select id="getUserByRoleName" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
@@ -315,26 +364,252 @@
         LEFT JOIN `jeecg-boot`.sys_user_role ur ON ur.user_id = u.id
         LEFT JOIN `jeecg-boot`.sys_role r ON r.id = ur.role_id
         <where>
-             <choose>
-                    <when test="roleName != null and roleName != ''">
-                        and r.role_name LIKE concat('%',#{roleName},'%') or r.role_code LIKE concat('%',#{roleName},'%')
-                    </when>
-                    <otherwise>
-                        and (r.role_name LIKE '%平面组长%'
-                        or r.role_name LIKE '%设计组长%'
-                        or r.role_name LIKE '%制片%'
-                        or r.role_name LIKE '%平面%'
-                        or r.role_name LIKE '%策划%'
-                        or r.role_name LIKE '%拍摄%'
-                        or r.role_name LIKE '%剪辑%' )
-                    </otherwise>
-             </choose>
+            <choose>
+                <when test="roleName != null and roleName != ''">
+                    and r.role_name LIKE concat('%',#{roleName},'%') or r.role_code LIKE concat('%',#{roleName},'%')
+                </when>
+                <otherwise>
+                    and (r.role_name LIKE '%平面组长%'
+                    or r.role_name LIKE '%设计组长%'
+                    or r.role_name LIKE '%制片%'
+                    or r.role_name LIKE '%平面%'
+                    or r.role_name LIKE '%策划%'
+                    or r.role_name LIKE '%拍摄%'
+                    or r.role_name LIKE '%剪辑%' )
+                </otherwise>
+            </choose>
         </where>
     </select>
 
 
+    <select id="getQuarterDesignerAchievementsByTedance" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        FROM (
+                 SELECT DATE_FORMAT(#{month1.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.3'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.3), 3), 0) AS commission,
+                        'clip'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE clip_id = #{userId}
+                   AND d.stat_date &gt;= #{month1.startTime}
+                   AND d.stat_date &lt;= #{month1.endTime}
+                   AND d.first_cost_day &gt;= #{month1.startTime}
+                   AND d.first_cost_day &lt;= #{month1.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month1.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.1'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.1), 3), 0) AS commission,
+                        'shot'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE shot_id = #{userId}
+                   AND d.stat_date &gt;= #{month1.startTime}
+                   AND d.stat_date &lt;= #{month1.endTime}
+                   AND d.first_cost_day &gt;= #{month1.startTime}
+                   AND d.first_cost_day &lt;= #{month1.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month1.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.4'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.4), 3), 0) AS commission,
+                        'plan'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE plan_id = #{userId}
+                   AND d.stat_date &gt;= #{month1.startTime}
+                   AND d.stat_date &lt;= #{month1.endTime}
+                   AND d.first_cost_day &gt;= #{month1.startTime}
+                   AND d.first_cost_day &lt;= #{month1.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month2.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.3'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.3), 3), 0) AS commission,
+                        'clip'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE clip_id = #{userId}
+                   AND d.stat_date &gt;= #{month2.startTime}
+                   AND d.stat_date &lt;= #{month2.endTime}
+                   AND d.first_cost_day &gt;= #{month2.startTime}
+                   AND d.first_cost_day &lt;= #{month2.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month2.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.1'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.1), 3), 0) AS commission,
+                        'shot'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE shot_id = #{userId}
+                   AND d.stat_date &gt;= #{month2.startTime}
+                   AND d.stat_date &lt;= #{month2.endTime}
+                   AND d.first_cost_day &gt;= #{month2.startTime}
+                   AND d.first_cost_day &lt;= #{month2.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month2.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.4'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.4), 3), 0) AS commission,
+                        'plan'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE plan_id = #{userId}
+                   AND d.stat_date &gt;= #{month2.startTime}
+                   AND d.stat_date &lt;= #{month2.endTime}
+                   AND d.first_cost_day &gt;= #{month2.startTime}
+                   AND d.first_cost_day &lt;= #{month2.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month3.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.3'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.3), 3), 0) AS commission,
+                        'clip'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE clip_id = #{userId}
+                   AND d.stat_date &gt;= #{month3.startTime}
+                   AND d.stat_date &lt;= #{month3.endTime}
+                   AND d.first_cost_day &gt;= #{month3.startTime}
+                   AND d.first_cost_day &lt;= #{month3.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month3.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.1'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.1), 3), 0) AS commission,
+                        'shot'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE shot_id = #{userId}
+                   AND d.stat_date &gt;= #{month3.startTime}
+                   AND d.stat_date &lt;= #{month3.endTime}
+                   AND d.first_cost_day &gt;= #{month3.startTime}
+                   AND d.first_cost_day &lt;= #{month3.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month3.startTime}, '%m')              monthTime,
+                        IFNULL(sum(d.cost), 0)                           AS cost,
+                        '0.4'                                            AS coefficient,
+                        IFNULL(round((sum(d.cost) * 0.002 * 0.4), 3), 0) AS commission,
+                        'plan'                                           AS type
+                 FROM application.bytedance_material_cost_daily d
+                 WHERE plan_id = #{userId}
+                   AND d.stat_date &gt;= #{month3.startTime}
+                   AND d.stat_date &lt;= #{month3.endTime}
+                   AND d.first_cost_day &gt;= #{month3.startTime}
+                   AND d.first_cost_day &lt;= #{month3.endTime}
+             ) t
+        order by monthTime, type
+    </select>
 
 
-
+    <!-- 查询设计人员 季度快手绩效-->
+    <select id="getQuarterDesignerAchievementsByKuaishou" resultType="com.alibaba.fastjson.JSONObject">
+        select *
+        FROM (
+                 SELECT DATE_FORMAT(#{month1.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.3'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.3), 3), 0) AS commission,
+                        'clip'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE clip_id = #{userId}
+                   AND d.stat_date &gt;= #{month1.startTime}
+                   AND d.stat_date &lt;= #{month1.endTime}
+                   AND d.first_cost_day &gt;= #{month1.startTime}
+                   AND d.first_cost_day &lt;= #{month1.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month1.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.1'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.1), 3), 0) AS commission,
+                        'shot'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE shot_id = #{userId}
+                   AND d.stat_date &gt;= #{month1.startTime}
+                   AND d.stat_date &lt;= #{month1.endTime}
+                   AND d.first_cost_day &gt;= #{month1.startTime}
+                   AND d.first_cost_day &lt;= #{month1.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month1.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.4'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.4), 3), 0) AS commission,
+                        'plan'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE plan_id = #{userId}
+                   AND d.stat_date &gt;= #{month1.startTime}
+                   AND d.stat_date &lt;= #{month1.endTime}
+                   AND d.first_cost_day &gt;= #{month1.startTime}
+                   AND d.first_cost_day &lt;= #{month1.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month2.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.3'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.3), 3), 0) AS commission,
+                        'clip'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE clip_id = #{userId}
+                   AND d.stat_date &gt;= #{month2.startTime}
+                   AND d.stat_date &lt;= #{month2.endTime}
+                   AND d.first_cost_day &gt;= #{month2.startTime}
+                   AND d.first_cost_day &lt;= #{month2.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month2.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.1'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.1), 3), 0) AS commission,
+                        'shot'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE shot_id = #{userId}
+                   AND d.stat_date &gt;= #{month2.startTime}
+                   AND d.stat_date &lt;= #{month2.endTime}
+                   AND d.first_cost_day &gt;= #{month2.startTime}
+                   AND d.first_cost_day &lt;= #{month2.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month2.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.4'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.4), 3), 0) AS commission,
+                        'plan'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE plan_id = #{userId}
+                   AND d.stat_date &gt;= #{month2.startTime}
+                   AND d.stat_date &lt;= #{month2.endTime}
+                   AND d.first_cost_day &gt;= #{month2.startTime}
+                   AND d.first_cost_day &lt;= #{month2.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month3.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.3'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.3), 3), 0) AS commission,
+                        'clip'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE clip_id = #{userId}
+                   AND d.stat_date &gt;= #{month3.startTime}
+                   AND d.stat_date &lt;= #{month3.endTime}
+                   AND d.first_cost_day &gt;= #{month3.startTime}
+                   AND d.first_cost_day &lt;= #{month3.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month3.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.1'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.1), 3), 0) AS commission,
+                        'shot'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE shot_id = #{userId}
+                   AND d.stat_date &gt;= #{month3.startTime}
+                   AND d.stat_date &lt;= #{month3.endTime}
+                   AND d.first_cost_day &gt;= #{month3.startTime}
+                   AND d.first_cost_day &lt;= #{month3.endTime}
+                 UNION
+                 SELECT DATE_FORMAT(#{month3.startTime}, '%m')                monthTime,
+                        IFNULL(sum(d.charge), 0)                           AS cost,
+                        '0.4'                                              AS coefficient,
+                        IFNULL(round((sum(d.charge) * 0.003 * 0.4), 3), 0) AS commission,
+                        'plan'                                             AS type
+                 FROM application.kuaishou_material_cost_daily d
+                 WHERE plan_id = #{userId}
+                   AND d.stat_date &gt;= #{month3.startTime}
+                   AND d.stat_date &lt;= #{month3.endTime}
+                   AND d.first_cost_day &gt;= #{month3.startTime}
+                   AND d.first_cost_day &lt;= #{month3.endTime}
+             ) t
+        order by monthTime, type
+    </select>
 
 </mapper>

+ 4 - 17
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/service/IDesignerService.java

@@ -1,12 +1,8 @@
 package cn.com.ctop.common.module.achievements.service;
 
 import com.alibaba.fastjson.JSONObject;
-import com.github.pagehelper.PageInfo;
 import org.jeecg.common.api.vo.Result;
 
-import java.util.List;
-import java.util.Map;
-
 /**
  * 设计人员绩效
  *
@@ -14,24 +10,15 @@ import java.util.Map;
  * @date: 2022-09-28
  * @cersion: V1.0
  */
-public interface IDesignerService{
-
-
-    PageInfo<JSONObject> getDesignBasicsInfoList(String userId, int pageNum, int pageSize);
-
-    List<Map<String,Object>> getHotVideoData(String userId,String yearTime,String monthTime);
-
-    Map<String,Object> getDesignerAchievements(String userId,String yearTime,String monthTime);
-
-    JSONObject getDesignerCommission(String userId,String yearTime,String monthTime);
+public interface IDesignerService {
 
     Result updateUserHappyProbability(JSONObject jsonObject);
 
-    Result getDesignerBasicsAndHotVideoInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize);
-    Result getDesignerBasicsAndAch(String userId,String yearTime,String monthTime,int pageNum,int pageSize);
-    Result getDesignerBasicsAndAchAndComInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize);
+    Result getDesignerBasicsAndHotVideoInfo(String userId, String yearTime, String monthTime, int pageNum, int pageSize);
 
+    Result getDesignerBasicsAndAch(String userId, String yearTime, String monthTime, int pageNum, int pageSize);
 
+    Result getDesignerBasicsAndAchAndComInfo(String userId, String yearTime, String monthTime, int pageNum, int pageSize);
 
     Result getUserByRoleName(String roleName);
 

+ 334 - 379
jeecg-boot-module-system/src/main/java/cn/com/ctop/common/module/achievements/service/impl/DesignerServiceImpl.java

@@ -3,12 +3,10 @@ package cn.com.ctop.common.module.achievements.service.impl;
 import cn.com.ctop.common.module.achievements.mapper.DesignerMapper;
 import cn.com.ctop.common.module.achievements.service.IDesignerService;
 import cn.com.ctop.common.module.utils.Check;
-import com.alibaba.fastjson.JSON;
-import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.github.pagehelper.PageHelper;
 import com.github.pagehelper.PageInfo;
-import com.itextpdf.text.pdf.parser.clipper.ClipperOffset;
+import com.google.common.collect.Lists;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.util.DateUtils;
@@ -20,7 +18,15 @@ import org.springframework.stereotype.Service;
 import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
 import java.util.function.ToDoubleFunction;
 
 /**
@@ -44,112 +50,6 @@ public class DesignerServiceImpl implements IDesignerService {
     private IMaterialReportOverViewService materialReportOverViewService;
     private ToDoubleFunction<JSONObject> getJSONObject;
 
-    @Override
-    public PageInfo<JSONObject> getDesignBasicsInfoList(String userId,int pageNum,int pageSize) {
-        String departName = null;
-        Set<String> userIdList = new HashSet<>();
-        //查询用户角色
-        String roleCode = roleService.getRoleCodeByUserId(userId);
-        if (roleCode.contains("admin")){
-            //查询设计部门所有人
-            departName = "设计";
-        }else if (roleCode.contains("Leader")){
-            //查询所有包含自己的下级
-            userIdList = materialReportOverViewService.recursiveQuerySubordinate(userId);
-        }else {
-            userIdList.add(userId);
-        }
-        PageHelper.startPage(pageNum,pageSize);
-        List<JSONObject> list = designerMapper.getDesignerUserInfo(departName,userIdList);
-        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
-
-        return pageInfo;
-    }
-
-
-    /**
-     *
-     * @description:爆款视频数据
-     *
-     * @param userId
-     * @return: org.jeecg.common.api.vo.Result
-     * @author: zianY
-     */
-    @Override
-    public List<Map<String,Object>> getHotVideoData(String userId,String yearTime,String monthTime) {
-        String roleName = null;
-        //查询用户角色
-        String roleCode = roleService.getRoleCodeByUserId(userId);
-        if (roleCode.contains("clip")){
-            roleName = "clip";
-        }else if (roleCode.contains("shot")){
-            roleName = "shot";
-        }else if (roleCode.contains("plan")){
-            roleName = "plan";
-        }else {
-            roleName = "all";
-        }
-
-
-        //取当前时间的季度的月份
-        List<Map<String,Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
-
-
-        List<Map<String,Object>> resultList = new ArrayList<>();
-        List<Map<String,Object>> byteDanceList = new ArrayList<>();
-        Map<String,Object> bytedanceMap = new HashMap<>();
-        List<Map<String,Object>> kuaishouList = new ArrayList<>();
-        Map<String,Object> kuaishouMap = new HashMap<>();
-        for (Map<String,Integer> month : timeMap ){
-            //头条
-            JSONObject bytedanceJson = designerMapper.getHotVideoData(userId,roleName,1,month.get("startTime"),month.get("endTime"));
-            bytedanceJson.put("monthTime",month);
-            byteDanceList.add(bytedanceJson);
-            bytedanceMap.put("byteDance",byteDanceList);
-            //快手
-            JSONObject kuaishouJson = designerMapper.getHotVideoData(userId,roleName,2,month.get("startTime"),month.get("endTime"));
-            kuaishouJson.put("monthTime",month);
-            kuaishouList.add(kuaishouJson);
-            kuaishouMap.put("kuaishou",kuaishouList);
-        }
-        resultList.add(bytedanceMap);
-        resultList.add(kuaishouMap);
-        return resultList;
-    }
-
-
-   @Override
-    public Map<String,Object> getDesignerAchievements(String userId,String yearTime,String monthTime) {
-
-       //取当前时间的季度的月份
-       List<Map<String,Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
-
-       Map<String,Object> resultMap = new HashMap<>();
-       List<Map<String,Object>> byteDanceList = new ArrayList<>();
-       List<Map<String,Object>> kuaishouList = new ArrayList<>();
-
-        for (Map<String,Integer> month : timeMap ){
-            Map<String,Object> bytedanceMap = new HashMap<>();
-            Map<String,Object> kuaishouMap = new HashMap<>();
-            //头条
-            List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId,month.get("startTime"),month.get("endTime"));
-            bytedanceMap.put("monthTime",month );
-            bytedanceMap.put("yearTime",yearTime);
-            bytedanceMap.put("byteDance",bytedanceJson);
-            byteDanceList.add(bytedanceMap);
-            //快手
-            List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsKuaishou(userId,month.get("startTime"),month.get("endTime"));
-            kuaishouMap.put("monthTime",month );
-            bytedanceMap.put("yearTime",yearTime);
-            kuaishouMap.put("kuaiShou",kuaishouJson);
-            kuaishouList.add(kuaishouMap);
-        }
-       resultMap.put("byteDanceData",byteDanceList);
-       resultMap.put("kuaiShouData",kuaishouList);
-        return resultMap;
-    }
-
-
     /**
      * 判断 人员 季度消耗 是否达标
      * 一季度3个月 平均每个月80w消耗
@@ -157,9 +57,10 @@ public class DesignerServiceImpl implements IDesignerService {
      * 此外需要考虑人员的入离职日期,如果5月入职,则只计算5、6月是否达标即可,则为每个月80w的消耗目标;
      * frozenTime 离职时间
      * createTime 员工入职时间
+     *
      * @return
      */
-    public Double getMaterialCost(String frozenTime, String createTime,int yearTime,int monthTime){
+    public Double getMaterialCost(String frozenTime, String createTime, int yearTime, int monthTime) {
 
 //String frozenTime = "";
         //String createTime = "2022-11-02 12:23:23";
@@ -171,79 +72,80 @@ public class DesignerServiceImpl implements IDesignerService {
         /**
          * 人员离职
          */
-        if (frozenTime != null){
+        if (frozenTime != null) {
             String yearF = DateUtils.getYear("yyyy-MM-dd", frozenTime);
-            if (!yearF.equals(String.valueOf(yearTime))){
-                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。",frozenTime,monthTime);
+            if (!yearF.equals(String.valueOf(yearTime))) {
+                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。", frozenTime, monthTime);
                 return 0 * cost;
             }
 
 
-            Date  date = DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd"));
+            Date date = DateUtils.str2Date(frozenTime, new SimpleDateFormat("yyyy-MM-dd"));
             // 判断时间所在的季度
             int quarterTime = DateUtils.getQuarter(date);
 
             //季度查询时间 超过 离职时间 则比例为0 绩效 无
-            if (quarterTime < monthTime){
+            if (quarterTime < monthTime) {
                 i = 0;
-                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},",frozenTime,monthTime,new Date());
+                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},", frozenTime, monthTime, new Date());
 
             }
 
-            if (quarterTime > monthTime){
-                log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},",frozenTime,monthTime,new Date());
+            if (quarterTime > monthTime) {
+                log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},", frozenTime, monthTime, new Date());
 
             }
 
             //离职时间 是否是当前季度
-            if (quarterTime == monthTime){
-                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+            if (quarterTime == monthTime) {
+                Map<String, Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
                 //离职时间所在 月份
-                String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
+                String month = DateUtils.getMonth("yyyy-MM-dd", frozenTime);
                 //离职时间所在的季度 的全部 月份
-                String[]  quarter =(String[]) map.get("quarter");
+                String[] quarter = (String[]) map.get("quarter");
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
-                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
+                int j = Collections.indexOfSubList(Arrays.asList(quarter), Arrays.asList(month));
                 i = j + 1;
-                log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}",frozenTime,monthTime,i,i*cost);
+                log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}", frozenTime, monthTime, i, i * cost);
 
             }
             //return i * cost;
 
-        }else {
+        } else {
             String yearC = DateUtils.getYear("yyyy-MM-dd", createTime);
-            if (!yearC.equals(String.valueOf(yearTime))){
-                log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。",createTime,monthTime);
+            if (!yearC.equals(String.valueOf(yearTime))) {
+                log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。", createTime, monthTime);
                 return i * cost;
             }
-            Date  date = DateUtils.str2Date(createTime,new SimpleDateFormat("yyyy-MM-dd"));
+            Date date = DateUtils.str2Date(createTime, new SimpleDateFormat("yyyy-MM-dd"));
             // 判断时间所在的季度
             int quarterTime = DateUtils.getQuarter(date);
             //查询入职前的 比例
             //季度查询时间 超过 入职时间  绩效0
-            if (quarterTime < monthTime){
-                log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。当前时间是:{},",createTime,monthTime,new Date());
+            if (quarterTime < monthTime) {
+                log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。当前时间是:{},", createTime, monthTime, new Date());
             }
             //查询入职后的 比例
-            if (quarterTime > monthTime){
+            if (quarterTime > monthTime) {
                 i = 0;
-                log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},",createTime,monthTime,new Date());
+                log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},", createTime, monthTime, new Date());
             }
 
             //入职时间 在当前季度
-            if (quarterTime == monthTime){
-                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+            if (quarterTime == monthTime) {
+                Map<String, Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
                 //月份
                 //入职时间所在 月份
-                String month = DateUtils.getMonth("yyyy-MM-dd",createTime);
+                String month = DateUtils.getMonth("yyyy-MM-dd", createTime);
                 //季度
-                String[]  quarter =(String[]) map.get("quarter");
+                String[] quarter = (String[]) map.get("quarter");
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
-                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
+                int j = Collections.indexOfSubList(Arrays.asList(quarter), Arrays.asList(month));
                 i = j + 1;
-                log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}",createTime,monthTime,i,i*cost);
+                log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}", createTime, monthTime, i, i * cost);
                 return i * cost;
-            };
+            }
+            ;
         }
         return i * cost;
     }
@@ -252,36 +154,37 @@ public class DesignerServiceImpl implements IDesignerService {
     /**
      * 离职发放比例
      * frozenTime 离职时间
+     *
      * @return
      */
-    public Double userHappyProbability(String frozenTime,int monthTime){
+    public Double userHappyProbability(String frozenTime, int monthTime) {
 
         //离职发放比例
         Double userHappyProbability = new Double("1");
-        if (!Check.isNull(frozenTime)){
+        if (!Check.isNull(frozenTime)) {
             //根据时间获取季度
             //离职时间所在的季度 是否和 查询季度相同 相同则判断 不同 则比例为1
 
             //当前季度的 月份
-            Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+            Map<String, Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
             //季度
-            String[]  quarter =(String[]) map.get("quarter");
-            String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
-            if (Arrays.binarySearch(quarter,month) < 0){
+            String[] quarter = (String[]) map.get("quarter");
+            String month = DateUtils.getMonth("yyyy-MM-dd", frozenTime);
+            if (Arrays.binarySearch(quarter, month) < 0) {
                 return userHappyProbability;
             }
 
 
             //离职  获取 天
-            String day = DateUtils.getDay("yyyy-MM-dd",frozenTime);
+            String day = DateUtils.getDay("yyyy-MM-dd", frozenTime);
 
             //15日之前离职 不发
-            if (Integer.valueOf(day) < 15){
+            if (Integer.valueOf(day) < 15) {
                 userHappyProbability = new Double("0");
             }
 
             // 15号之后离职,发50%
-            if (Integer.valueOf(day) >= 15){
+            if (Integer.valueOf(day) >= 15) {
                 userHappyProbability = new Double("0.5");
             }
 
@@ -289,8 +192,8 @@ public class DesignerServiceImpl implements IDesignerService {
             String endDay = DateUtils.getQuarterEndDay(frozenTime);
             //最后一天离职 发放比例为1
             // 离职时间 > = 最后一天
-            if (DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd")).getTime() >=
-                    DateUtils.str2Date(endDay,new SimpleDateFormat("yyyy-MM-dd")).getTime()){
+            if (DateUtils.str2Date(frozenTime, new SimpleDateFormat("yyyy-MM-dd")).getTime() >=
+                    DateUtils.str2Date(endDay, new SimpleDateFormat("yyyy-MM-dd")).getTime()) {
                 userHappyProbability = new Double("1");
             }
 
@@ -300,292 +203,344 @@ public class DesignerServiceImpl implements IDesignerService {
         return userHappyProbability;
     }
 
+    /**
+     * @param userId
+     * @description:爆款视频数据
+     * @return: org.jeecg.common.api.vo.Result
+     * @author: zianY
+     */
+    public void getHotVideoData(JSONObject jsonObject, String yearTime, List<Map<String, Integer>> timeMap) {
+        String userId = jsonObject.getString("userId");
+        String roleName = null;
+        //查询用户角色
+        String roleCode = roleService.getRoleCodeByUserId(userId);
+        if (roleCode.contains("clip")) {
+            roleName = "clip";
+        } else if (roleCode.contains("shot")) {
+            roleName = "shot";
+        } else if (roleCode.contains("plan")) {
+            roleName = "plan";
+        } else {
+            roleName = "all";
+        }
+        Map<String, Integer> month1 = timeMap.get(0);
+        Map<String, Integer> month2 = timeMap.get(1);
+        Map<String, Integer> month3 = timeMap.get(2);
+        JSONObject bytedanceJson = designerMapper.getHotVideoData(userId, roleName, 1, month1, month2, month3);
+        JSONObject kuaishouJson = designerMapper.getHotVideoData(userId, roleName, 2, month1, month2, month3);
+        jsonObject.put("bytedance", bytedanceJson);
+        jsonObject.put("kuaishou", kuaishouJson);
+    }
 
 
+    public void getDesignerAchievements(JSONObject jsonObject, String yearTime, List<Map<String, Integer>> timeMap) {
+        String userId = jsonObject.getString("userId");
+        Map<String, Object> resultMap = new HashMap<>();
+        Map<String, Integer> month1 = timeMap.get(0);
+        Map<String, Integer> month2 = timeMap.get(1);
+        Map<String, Integer> month3 = timeMap.get(2);
+        List<JSONObject> bytedanceJson = designerMapper.getQuarterDesignerAchievementsByTedance(userId, month1, month2, month3);
+        List<JSONObject> kuaishouJson = designerMapper.getQuarterDesignerAchievementsByKuaishou(userId, month1, month2, month3);
+        jsonObject.put("byteDanceData", bytedanceJson);
+        jsonObject.put("kuaiShouData", kuaishouJson);
 
+    }
 
+    public JSONObject getDesignerCommission(String userId, String yearTime, String monthTime, List<Map<String, Integer>> timeMap) {
 
+        String roleCode = roleService.getRoleCodeByUserId(userId);
 
-   @Override
-    public JSONObject getDesignerCommission(String userId,String yearTime,String monthTime) {
-
-       String roleCode = roleService.getRoleCodeByUserId(userId);
-
-       //取当前时间的季度的月份
-       List<Map<String,Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
-       //人员离职信息
-       JSONObject userFrozen = designerMapper.getUserFrozenInfo(userId);
-
-       //离职时间
-       String frozenTime = userFrozen.getString("frozenTime");
-       //入职时间
-       String createTime = userFrozen.getString("createTime");
-
-
-
-       List<Map<String,Object>> quarterCostList = new ArrayList<>();
-       List<Map<String,Object>> leaderCostList = new ArrayList<>();
-       List<JSONObject> listBytedanceCost = new ArrayList<>();
-       List<JSONObject> listKuaishouCost  = new ArrayList<>();
-       for (Map<String,Integer> month : timeMap ) {
-           //季度 分媒体 素材消耗 分月查询
-           List<JSONObject> bytedanceQuarterCost = designerMapper.getDesignerBytedanceQuaterCost(userId,month.get("startTime"),month.get("endTime"));
-           List<JSONObject> kuaishouQuarterCost = designerMapper.getDesignerKuaishouQuaterCost(userId,month.get("startTime"),month.get("endTime"));
-           listBytedanceCost.addAll(bytedanceQuarterCost);
-           listKuaishouCost.addAll(kuaishouQuarterCost);
-
-
-           //管理消耗 分月查询
-           List<JSONObject> leaderCost = designerMapper.getDesignerManagerLeaderCost(userId,month.get("startTime"),month.get("endTime"));
-
-           //离职 提成系数
-           //Double a = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
-           Double userHappyProbability = new Double(1);
-           if (!Check.isNull(frozenTime)){
-               //离职时间
-               int frozenT = DateUtils.getDateInteger(frozenTime);
-
-               //设计组长 看月份  如果6月离职的,则只计算4、5月份的,与日期无关
-               if (roleCode.equalsIgnoreCase("designTeamLeader")){
-                   if (frozenT > month.get("endTime")){
-                       userHappyProbability = new Double(1);
-                   }else {
-                       userHappyProbability = new Double(0);
-                   }
-               }
-           }
-
-           Map<String,Object> leaderCostMap = new HashMap<>();
-           leaderCostMap.put("xishu", userHappyProbability);
-           leaderCostMap.put("bytedanceCost",new Double(leaderCost.get(0).getString("cost")) * userHappyProbability);
-           leaderCostMap.put("kuaishouCost",new Double(leaderCost.get(1).getString("cost")) * userHappyProbability);
-           leaderCostList.add(leaderCostMap);
-
-       }
-       Double bytedanceCost = listBytedanceCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
-       Double kuaishouCost = listKuaishouCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
-       Map<String,Object> bytedanceMap = new HashMap<>();
-       Map<String,Object> kuaishouMap = new HashMap<>();
-       bytedanceMap.put("type","byteDance");
-       bytedanceMap.put("cost",bytedanceCost);
-       kuaishouMap.put("type","kuaiShou");
-       kuaishouMap.put("cost",kuaishouCost);
-       quarterCostList.add(bytedanceMap);
-       quarterCostList.add(kuaishouMap);
-
-       //季度 分媒体 素材消耗
-       userFrozen.put("quarterCostList",quarterCostList);
-
-       //季度素材 总消耗
-       Double tatolCost = quarterCostList.stream().mapToDouble(json -> new Double(json.get("cost")+"")).reduce(Double::sum).orElse(new Double("0"));
-       userFrozen.put("tatolQuarterCost",tatolCost);
-
-       //季度 管理消耗汇总
-       Double bytedanceLeaderCost = leaderCostList.stream().mapToDouble(json -> new Double(json.get("bytedanceCost")+"")).reduce(Double::sum).orElse(new Double("0"));
-       Double kuaishouLeaderCost = leaderCostList.stream().mapToDouble(json -> new Double(json.get("kuaishouCost")+"")).reduce(Double::sum).orElse(new Double("0"));
-       userFrozen.put("leaderCost",bytedanceLeaderCost + kuaishouLeaderCost);
-
-
-       //判断素材消耗是否达标
-       Double i = getMaterialCost(frozenTime,createTime,Integer.valueOf(yearTime),Integer.valueOf(monthTime));
-       String materialCostQualifiedFlag = tatolCost >= i ? "是" : "否";
-       userFrozen.put("materialCostQualifiedFlag",materialCostQualifiedFlag);
-
-       //爆款素材数量 分月查询
-       JSONObject hotVideoNum = designerMapper.getUserHotMaterialQuarter(userId,timeMap.get(0).get("startTime"),timeMap.get(2).get("endTime"));
-       int hotVideoN = Check.isNull(hotVideoNum) ? 0 : hotVideoNum.getInteger("hotVideoNum");
-       userFrozen.put("hotVideoNum",hotVideoN);
-
-
-       //爆款总量 开屏爆款数量 + 爆款数量
-       int hotVideoTotalNum = userFrozen.getInteger("openHotVideoNum") + hotVideoN;
-       userFrozen.put("hotVideoTotalNum",hotVideoTotalNum);
-
-
-
-       //提成 分月份
-       List<JSONObject> commissionList = new ArrayList<>();
-       for (Map<String,Integer> month : timeMap ) {
-           JSONObject commissionJson = new JSONObject();
-           //头条消耗 提成
-           List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId, month.get("startTime"),month.get("endTime"));
-           Double bytedanceCommission = bytedanceJson.stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
-
-           //快手消耗 提成
-           List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsKuaishou(userId, month.get("startTime"),month.get("endTime"));
-           Double kuaishouCommission = kuaishouJson.stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
-
-           commissionJson.put("monthTime", month.get("startTime"));
-           commissionJson.put("yearTime", yearTime);
-
-
-           //离职 提成系数
-           //Double a = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
-           Double userHappyProbability = new Double(1);
-           if (!Check.isNull(frozenTime)){
-
-               //离职时间
-               int frozenT = DateUtils.getDateInteger(frozenTime);
-
-               // 日期转换 20221021 ===>>> 2022-10-21
-               String day = DateUtils.getStrDateToInt(month.get("startTime"));
-               //获取月份的 中间的日期 20221015
-               int middleDay = DateUtils.subMonthMiddleDay(day);
-
-               //个人看日期
-               // 如果当月15日之前离职,当月不发;
-               // 15号之后离职,发50%;
-               // 若月底最后一天离职,则发放100
-               if (!roleCode.equalsIgnoreCase("designTeamLeader")){
-                   if (frozenT < middleDay){
-                       userHappyProbability = new Double(0);
-                   }
-                   if (frozenT > middleDay && frozenT < month.get("endTime")){
-                       userHappyProbability = new Double(0.5);
-                   }
-                   if (frozenT == month.get("endTime")){
-                       userHappyProbability = new Double(1);
-                   }
-               }
-           }
-
-           commissionJson.put("xishu", userHappyProbability);
-           commissionJson.put("commission", (bytedanceCommission + kuaishouCommission) * userHappyProbability);
-           commissionList.add(commissionJson);
-
-       }
-       userFrozen.put("commissionList",commissionList);
-
-
-       //季度提成汇总
-       BigDecimal totalCommissionBd = commissionList.stream().map(json -> json.getBigDecimal("commission")).reduce(BigDecimal.ZERO,BigDecimal::add);
-       Double totalCommission = totalCommissionBd.doubleValue();
-
-       //负责人提成 如果是负责人 (设计组长) 管理消耗 千三的20%
-       Double designerLeaderCommission = new Double("0");
-
-       if (roleCode.equalsIgnoreCase("designTeamLeader")){
-           Double designerLeaderCommissionBytedance = bytedanceLeaderCost * 0.002 * 0.2;
-           Double designerLeaderCommissionKuaishou = kuaishouLeaderCost * 0.003 * 0.2;
-           designerLeaderCommission = designerLeaderCommissionBytedance + designerLeaderCommissionKuaishou;
-       }
-       userFrozen.put("designerLeaderCommission",designerLeaderCommission);
+        //人员离职信息
+        JSONObject userFrozen = designerMapper.getUserFrozenInfo(userId);
+
+        //离职时间
+        String frozenTime = userFrozen.getString("frozenTime");
+        //入职时间
+        String createTime = userFrozen.getString("createTime");
+
+
+        List<Map<String, Object>> quarterCostList = new ArrayList<>();
+        List<Map<String, Object>> leaderCostList = new ArrayList<>();
+        List<JSONObject> listBytedanceCost = new ArrayList<>();
+        List<JSONObject> listKuaishouCost = new ArrayList<>();
+        for (Map<String, Integer> month : timeMap) {
+            //季度 分媒体 素材消耗 分月查询
+            List<JSONObject> bytedanceQuarterCost = designerMapper.getDesignerBytedanceQuaterCost(userId, month.get("startTime"), month.get("endTime"));
+            List<JSONObject> kuaishouQuarterCost = designerMapper.getDesignerKuaishouQuaterCost(userId, month.get("startTime"), month.get("endTime"));
+            listBytedanceCost.addAll(bytedanceQuarterCost);
+            listKuaishouCost.addAll(kuaishouQuarterCost);
+
+
+            //管理消耗 分月查询
+            List<JSONObject> leaderCost = designerMapper.getDesignerManagerLeaderCost(userId, month.get("startTime"), month.get("endTime"));
+
+            //离职 提成系数
+            //Double a = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
+            Double userHappyProbability = new Double(1);
+            if (!Check.isNull(frozenTime)) {
+                //离职时间
+                int frozenT = DateUtils.getDateInteger(frozenTime);
+
+                //设计组长 看月份  如果6月离职的,则只计算4、5月份的,与日期无关
+                if (roleCode.equalsIgnoreCase("designTeamLeader")) {
+                    if (frozenT > month.get("endTime")) {
+                        userHappyProbability = new Double(1);
+                    } else {
+                        userHappyProbability = new Double(0);
+                    }
+                }
+            }
 
-       //提成汇总 = 季度汇总 + 负责人提成
-       totalCommission+=designerLeaderCommission;
-       userFrozen.put("totalCommission",totalCommission);
+            Map<String, Object> leaderCostMap = new HashMap<>();
+            leaderCostMap.put("xishu", userHappyProbability);
+            leaderCostMap.put("bytedanceCost", new Double(leaderCost.get(0).getString("cost")) * userHappyProbability);
+            leaderCostMap.put("kuaishouCost", new Double(leaderCost.get(1).getString("cost")) * userHappyProbability);
+            leaderCostList.add(leaderCostMap);
 
-       //离职发放比例
-       Double userHappyProbability = userHappyProbability(frozenTime,Integer.valueOf(monthTime));
-       userFrozen.put("userHappyProbability",userHappyProbability);
+        }
+        Double bytedanceCost = listBytedanceCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
+        Double kuaishouCost = listKuaishouCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
+        Map<String, Object> bytedanceMap = new HashMap<>();
+        Map<String, Object> kuaishouMap = new HashMap<>();
+        bytedanceMap.put("type", "byteDance");
+        bytedanceMap.put("cost", bytedanceCost);
+        kuaishouMap.put("type", "kuaiShou");
+        kuaishouMap.put("cost", kuaishouCost);
+        quarterCostList.add(bytedanceMap);
+        quarterCostList.add(kuaishouMap);
+
+        //季度 分媒体 素材消耗
+        userFrozen.put("quarterCostList", quarterCostList);
+
+        //季度素材 总消耗
+        Double tatolCost = quarterCostList.stream().mapToDouble(json -> new Double(json.get("cost") + "")).reduce(Double::sum).orElse(new Double("0"));
+        userFrozen.put("tatolQuarterCost", tatolCost);
+
+        //季度 管理消耗汇总
+        Double bytedanceLeaderCost = leaderCostList.stream().mapToDouble(json -> new Double(json.get("bytedanceCost") + "")).reduce(Double::sum).orElse(new Double("0"));
+        Double kuaishouLeaderCost = leaderCostList.stream().mapToDouble(json -> new Double(json.get("kuaishouCost") + "")).reduce(Double::sum).orElse(new Double("0"));
+        userFrozen.put("leaderCost", bytedanceLeaderCost + kuaishouLeaderCost);
+
+
+        //判断素材消耗是否达标
+        Double flag = getMaterialCost(frozenTime, createTime, Integer.valueOf(yearTime), Integer.valueOf(monthTime));
+        String materialCostQualifiedFlag = tatolCost >= flag ? "是" : "否";
+        userFrozen.put("materialCostQualifiedFlag", materialCostQualifiedFlag);
+
+        //爆款素材数量 分月查询
+        JSONObject hotVideoNum = designerMapper.getUserHotMaterialQuarter(userId, timeMap.get(0).get("startTime"), timeMap.get(2).get("endTime"));
+        int hotVideoN = Check.isNull(hotVideoNum) ? 0 : hotVideoNum.getInteger("hotVideoNum");
+        userFrozen.put("hotVideoNum", hotVideoN);
+
+
+        //爆款总量 开屏爆款数量 + 爆款数量
+        int hotVideoTotalNum = userFrozen.getInteger("openHotVideoNum") + hotVideoN;
+        userFrozen.put("hotVideoTotalNum", hotVideoTotalNum);
+
+
+        Map<String, Integer> month1 = timeMap.get(0);
+        Map<String, Integer> month2 = timeMap.get(1);
+        Map<String, Integer> month3 = timeMap.get(2);
+        List<JSONObject> bytedanceJson = designerMapper.getQuarterDesignerAchievementsByTedance(userId, month1, month2, month3);
+        List<JSONObject> kuaishouJson = designerMapper.getQuarterDesignerAchievementsByKuaishou(userId, month1, month2, month3);
+        List<List<JSONObject>> bytedance = Lists.partition(bytedanceJson, 3);
+        List<List<JSONObject>> kuaishou = Lists.partition(kuaishouJson, 3);
+        //提成 分月份
+        List<JSONObject> commissionList = new ArrayList<>();
+        for (int i = 0; i < bytedance.size(); i++) {
+            JSONObject commissionJson = new JSONObject();
+            Double bytedanceCommission = bytedance.get(i).stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
+            Double kuaishouCommission = kuaishou.get(i).stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
+            Double userHappyProbability = new Double(1);
+            if (!Check.isNull(frozenTime)) {
+                //离职时间
+                int frozenT = DateUtils.getDateInteger(frozenTime);
+                int startTime = 0;
+                int endTime = 0;
+                if (i == 0) {
+                    startTime = month1.get("startTime");
+                    endTime = month1.get("endTime");
+                } else if (i == 1) {
+                    startTime = month2.get("startTime");
+                    endTime = month2.get("endTime");
+                } else {
+                    startTime = month3.get("startTime");
+                    endTime = month3.get("endTime");
+                }
+                // 日期转换 20221021 ===>>> 2022-10-21
+                String day = DateUtils.getStrDateToInt(startTime);
+                //获取月份的 中间的日期 20221015
+                int middleDay = DateUtils.subMonthMiddleDay(day);
+
+                //个人看日期
+                // 如果当月15日之前离职,当月不发;
+                // 15号之后离职,发50%;
+                // 若月底最后一天离职,则发放100
+                if (!roleCode.equalsIgnoreCase("designTeamLeader")) {
+                    if (frozenT < middleDay) {
+                        userHappyProbability = new Double(0);
+                    }
+                    if (frozenT > middleDay && frozenT < endTime) {
+                        userHappyProbability = new Double(0.5);
+                    }
+                    if (frozenT == endTime) {
+                        userHappyProbability = new Double(1);
+                    }
+                }
+            }
+            commissionJson.put("monthTime", bytedance.get(i).get(0).getBigInteger("monthTime"));
+            commissionJson.put("xishu", userHappyProbability);
+            commissionJson.put("commission", (bytedanceCommission + kuaishouCommission) * userHappyProbability);
+            commissionList.add(commissionJson);
+        }
+        bytedanceJson.get(0);
+        userFrozen.put("commissionList", commissionList);
 
 
-       /**
-        * 爆款达标 提成发放系数
-        * 在季度中
-        * 爆款 >= 10个 消耗>=240w 绩效 100%
-        * 爆款 < 10 消耗 >= 240w 绩效50%
-        * 爆款<=0 绩效 >= 240w 不发
-        * 爆款>=10 绩效<=240w 不发
-        * 其中的绩效240 根据入职或离职时间按月计算 使用字段materialCostQualifiedFlag
-        *
-        */
-       Double coefficient = new Double("0");
-       if (materialCostQualifiedFlag.equals("是")){
-           if (hotVideoTotalNum >= 10){
-               coefficient = new Double("1");
-           }
-           if (hotVideoTotalNum > 0 && hotVideoTotalNum < 10){
-               coefficient = new Double("0.5");
-           }
-       }
-       userFrozen.put("coefficient",coefficient);
+        //季度提成汇总
+        BigDecimal totalCommissionBd = commissionList.stream().map(json -> json.getBigDecimal("commission")).reduce(BigDecimal.ZERO, BigDecimal::add);
+        Double totalCommission = totalCommissionBd.doubleValue();
 
-       //提成发放金额 = 总提成 * 爆款达标发放系数
-       Double userHappyGetMoney = totalCommission * coefficient;
-       userFrozen.put("userHappyGetMoney",userHappyGetMoney);
-
-       return userFrozen;
+        //负责人提成 如果是负责人 (设计组长) 管理消耗 千三的20%
+        Double designerLeaderCommission = new Double("0");
 
+        if (roleCode.equalsIgnoreCase("designTeamLeader")) {
+            Double designerLeaderCommissionBytedance = bytedanceLeaderCost * 0.002 * 0.2;
+            Double designerLeaderCommissionKuaishou = kuaishouLeaderCost * 0.003 * 0.2;
+            designerLeaderCommission = designerLeaderCommissionBytedance + designerLeaderCommissionKuaishou;
+        }
+        userFrozen.put("designerLeaderCommission", designerLeaderCommission);
 
-   }
+        //提成汇总 = 季度汇总 + 负责人提成
+        totalCommission += designerLeaderCommission;
+        userFrozen.put("totalCommission", totalCommission);
 
+        //离职发放比例
+        Double userHappyProbability = userHappyProbability(frozenTime, Integer.valueOf(monthTime));
+        userFrozen.put("userHappyProbability", userHappyProbability);
 
+        /**
+         * 爆款达标 提成发放系数
+         * 在季度中
+         * 爆款 >= 10个 消耗>=240w 绩效 100%
+         * 爆款 < 10 消耗 >= 240w 绩效50%
+         * 爆款<=0 绩效 >= 240w 不发
+         * 爆款>=10 绩效<=240w 不发
+         * 其中的绩效240 根据入职或离职时间按月计算 使用字段materialCostQualifiedFlag
+         *
+         */
+        Double coefficient = new Double("0");
+        if (materialCostQualifiedFlag.equals("是")) {
+            if (hotVideoTotalNum >= 10) {
+                coefficient = new Double("1");
+            }
+            if (hotVideoTotalNum > 0 && hotVideoTotalNum < 10) {
+                coefficient = new Double("0.5");
+            }
+        }
+        userFrozen.put("coefficient", coefficient);
 
+        //提成发放金额 = 总提成 * 爆款达标发放系数
+        Double userHappyGetMoney = totalCommission * coefficient;
+        userFrozen.put("userHappyGetMoney", userHappyGetMoney);
 
+        return userFrozen;
+    }
 
 
-   @Override
+    @Override
     public Result updateUserHappyProbability(JSONObject jsonObject) {
         designerMapper.updateUserHappyProbability(jsonObject.getString("userId"),
                 jsonObject.getString("openScreenNum"),
                 jsonObject.getString("paySalary"),
                 jsonObject.getString("remarks"));
-       return Result.successMsg("修改成功",null);
+        return Result.successMsg("修改成功", null);
 
 
-   }
-
+    }
 
 
     @Override
-    public Result getDesignerBasicsAndHotVideoInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
+    public Result getDesignerBasicsAndHotVideoInfo(String userId, String yearTime, String monthTime, int pageNum, int pageSize) {
+        //取当前时间的季度的月份
+        List<Map<String, Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
         //基础信息 + 爆款信息
-        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
+        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId, pageNum, pageSize, timeMap);
         for (JSONObject jsonObject : baseics.getList()) {
-            List<Map<String,Object>> hotVideo = getHotVideoData(jsonObject.getString("userId"),yearTime,monthTime);
-            jsonObject.put("hotVideoInfo",hotVideo);
+            getHotVideoData(jsonObject, yearTime, timeMap);
         }
-        return Result.successMsg("基础+爆款查询成功。",baseics);
+        return Result.successMsg("基础+爆款查询成功。", baseics);
 
 
     }
 
 
     @Override
-    public Result getDesignerBasicsAndAch(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
+    public Result getDesignerBasicsAndAch(String userId, String yearTime, String monthTime, int pageNum, int pageSize) {
+        //取当前时间的季度的月份
+        List<Map<String, Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
         //基础信息 + 绩效
-        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
+        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId, pageNum, pageSize, timeMap);
         for (JSONObject jsonObject : baseics.getList()) {
             //绩效
-            Map<String,Object> achievementsMap = getDesignerAchievements(jsonObject.getString("userId"),yearTime,monthTime);
-            jsonObject.put("achievementsMap",achievementsMap);
+            getDesignerAchievements(jsonObject, yearTime, timeMap);
         }
-        return Result.successMsg("基础+绩效查询成功。",baseics);
+        return Result.successMsg("基础+绩效查询成功。", baseics);
     }
 
 
     @Override
-    public Result getDesignerBasicsAndAchAndComInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
+    public Result getDesignerBasicsAndAchAndComInfo(String userId, String yearTime, String monthTime, int pageNum, int pageSize) {
+        //取当前时间的季度的月份
+        List<Map<String, Integer>> timeMap = DateUtils.getQuarStartAndEndTime(Integer.valueOf(monthTime));
         //基础信息 +提成
-        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
+        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId, pageNum, pageSize, timeMap);
         for (JSONObject jsonObject : baseics.getList()) {
             //提成
-            JSONObject userFrozen = getDesignerCommission(jsonObject.getString("userId"),yearTime,monthTime);
-            jsonObject.put("userFrozen",userFrozen);
+            JSONObject userFrozen = getDesignerCommission(jsonObject.getString("userId"), yearTime, monthTime, timeMap);
+            jsonObject.put("userFrozen", userFrozen);
         }
-        return Result.successMsg("基础+提成查询成功。",baseics);
+        return Result.successMsg("基础+提成查询成功。", baseics);
     }
 
+    /**
+     * 获取人员信息
+     */
+    private PageInfo<JSONObject> getDesignBasicsInfoList(String userId, int pageNum, int pageSize, List<Map<String, Integer>> timeMap) {
+        List<String> roleCodes = new ArrayList<>();
+        Set<String> userIdList = new HashSet<>();
+        //查询用户角色
+        String roleCode = roleService.getRoleCodeByUserId(userId);
+        if (roleCode.contains("admin")) {
+            //查询设计部门所有人
+            roleCodes.add("设计");
+            roleCodes.add("平面");
+            roleCodes.add("制片");
+            roleCodes.add("策划");
+            roleCodes.add("拍摄");
+            roleCodes.add("剪辑");
+
+        } else if (roleCode.contains("Leader")) {
+            //查询所有包含自己的下级
+            userIdList = materialReportOverViewService.recursiveQuerySubordinate(userId);
+        } else {
+            userIdList.add(userId);
+        }
+        Integer startTime = timeMap.get(0).get("startTime");
+        Integer endTime = timeMap.get(2).get("endTime");
 
-
-
-
+        PageHelper.startPage(pageNum, pageSize);
+        List<JSONObject> list = designerMapper.getDesignerUserInfo(roleCodes, userIdList, startTime, endTime);
+        PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
+        return pageInfo;
+    }
 
 
     @Override
-    public Result getUserByRoleName(String roleName){
+    public Result getUserByRoleName(String roleName) {
         List<JSONObject> list = designerMapper.getUserByRoleName(roleName);
-        return Result.successMsg("查询成功。",list);
+        return Result.successMsg("查询成功。", list);
     }
 
 
-
-
-
-
-
-
-
-
 }