Browse Source

Merge branch 'test'

zhaoxian 2 năm trước cách đây
mục cha
commit
50fa0782e4

+ 275 - 31
jeecg-boot-base/jeecg-boot-base-core/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -2,6 +2,8 @@ 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;
@@ -13,6 +15,10 @@ import java.sql.Timestamp;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
+import java.time.Month;
 import java.util.*;
 
 /**
@@ -1252,9 +1258,14 @@ public class DateUtils extends PropertyEditorSupport {
      * @return
      * @throws ParseException
      */
-    public static String getYear(String format, String date) throws ParseException {
+    public static String getYear(String format, String date) {
         SimpleDateFormat df = new SimpleDateFormat(format);
-        Date parse = df.parse(date);
+        Date parse = null;
+        try {
+            parse = df.parse(date);
+        }catch (ParseException e) {
+            e.printStackTrace();
+        }
         return String.format("%tY", parse);
     }
 
@@ -1285,9 +1296,14 @@ public class DateUtils extends PropertyEditorSupport {
      * @return
      * @throws ParseException
      */
-    public static String getDay(String format, String date) throws ParseException {
+    public static String getDay(String format, String date){
         SimpleDateFormat df = new SimpleDateFormat(format);
-        Date parse = df.parse(date);
+        Date parse = null;
+        try {
+            parse = df.parse(date);
+        }catch (ParseException e) {
+            e.printStackTrace();
+        }
         return String.format("%td", parse);
     }
 
@@ -1848,6 +1864,30 @@ public class DateUtils extends PropertyEditorSupport {
         return null;
     }
 
+/**
+     * int 日期转 string
+     * 20220118 ====>>>> 2022-01-18
+     *
+     * @param date
+     * @return
+     */
+    public static String getStrDateToInt(int date) {
+
+        SimpleDateFormat sdfSource = new SimpleDateFormat("yyyyMMdd");
+        SimpleDateFormat sdfTarget = new SimpleDateFormat("yyyy-MM-dd");
+        String dateSource = String.valueOf(date);
+        String dateTarget = "";
+        try {
+            dateTarget = sdfTarget.format(sdfSource.parse(dateSource));
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+        return dateTarget;
+
+    }
+
+
+
 
     /**
      * 获取当前月份第一天
@@ -2147,19 +2187,19 @@ public class DateUtils extends PropertyEditorSupport {
 
         //System.out.println(getSubtractTime(new Date(),6));;
 
-        List<String> list = new ArrayList<String>();
-        list.add("2022-09-01");
-        list.add("2022-09-04");
+//        List<String> list = new ArrayList<String>();
+//        list.add("2022-09-01");
+//        list.add("2022-09-04");
 
 
         //System.out.println(getHoursListDifference(list));
         //System.out.println(getCurrentQuarterMonths());
-        System.out.println(isThisQuarter("2022-08-02 12:23:23"));
+//        System.out.println(isThisQuarter("2022-08-02 12:23:23"));
 
 
         //离职时间不为空
-        String frozenTime = "";
-        String createTime = "2022-11-02 12:23:23";
+//        String frozenTime = "";
+//        String createTime = "2022-11-02 12:23:23";
 
 //        //绩效 = 在职月份 * 80w 额度
 //        int cost = 80;
@@ -2199,40 +2239,108 @@ public class DateUtils extends PropertyEditorSupport {
 //        }
 //
 
-        System.out.println(getQuarterEndDay("2022-01-01"));
-        System.out.println(getMonth("yyyy-MM-dd","2022-01-01"));
+//        System.out.println(getQuarterEndDay("2022-10-05"));
+        //System.out.println(getMonth("yyyy-MM-dd","2022-01-01"));
+
+
+//        System.out.println(quarterStartEndDate(2022,4));
+
+
+//        List list = new ArrayList();
+//        Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(3);
+//        String[] quarterStr = (String[])timeMap.get("quarter");
+//        for (String month : quarterStr ){
+//            Map<String,Integer> map = new HashMap<>();
+//            map.put("startTime",getFirstDayOfMonth(Integer.valueOf(month)));
+//            map.put("endTime",getLastDayOfMonth(Integer.valueOf(month)));
+//            list.add(map);
+//        }
+//        System.out.println(list);
+
+
+        //System.out.println(getMaterialCost("2022-09-03","2022-09-01",3));
+        //System.out.println(getIntDateToStr(20220903));
+
+
+        System.out.println(subMonthMiddleDay("2022-12-01"));
+        if (subMonthMiddleDay("2022-12-01") == 20221215){
+            System.out.println("111");
+        }else {
+            System.out.println("222");
+        }
+
+
+
 
     }
 
+    /****
+     * 传入具体日期 ,返回具体日期增加15天。
+     * @param date 日期(2022-04-01)
+     * @return 2022-04-15
+     * @throws ParseException
+     */
+    public static Integer subMonthMiddleDay(String date) {
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+
+        Date dt = null;
+        try {
+            dt = sdf.parse(date);
+        }catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        Calendar rightNow = Calendar.getInstance();
+        rightNow.setTime(dt);
+        rightNow.add(Calendar.DAY_OF_MONTH, 14);
+        Date dt1 = rightNow.getTime();
+        String reStr = sdf.format(dt1);
+        return getDateInteger(reStr);
+    }
+
+
+
+
     /**
-     * 获取当前时间的季度的月份
+     * 获取季度所在的3个月份的 开始和结束时间
+     * @param quarterTime
      * @return
      */
-    public static Map<String,Object> getCurrentQuarterMonths(String dateStr){
+    public static List<Map<String,Integer>> getQuarStartAndEndTime(int quarterTime){
+        List<Map<String,Integer>> list = new ArrayList();
+        Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(quarterTime);
+        String[] quarterStr = (String[])timeMap.get("quarter");
+        for (String month : quarterStr ){
+            Map<String,Integer> map = new HashMap<>();
+            map.put("startTime",getFirstDayOfMonth(Integer.valueOf(month)));
+            map.put("endTime",getLastDayOfMonth(Integer.valueOf(month)));
+            list.add(map);
+        }
+        return list;
+    }
 
-        Date date = parseDate(dateStr,"yyyy-MM-dd HH:mm:ss");
+
+    /**
+     * 获取当前时间的季度的月份
+     * @return
+     */
+    public static Map<String,Object> getCurrentQuarterMonths(int quarterTime){
 
         Map<String,Object> map = new HashMap<>();
         String quarter[] = new String[]{};
-        Calendar calendar = Calendar.getInstance();
-        calendar.setTime(date);
-        int yearTime = calendar.get(Calendar.YEAR);
-        int monthTime = calendar.get(Calendar.MONTH)+1;
-        int quarterTime = monthTime % 3 == 0 ? monthTime / 3 : monthTime / 3 + 1;
+
         if (quarterTime == 1){
-             quarter = new String[]{"1","2","3"};
+             quarter = new String[]{"01","02","03"};
         }
         if (quarterTime == 2){
-             quarter = new String[]{"4","5","6"};
+             quarter = new String[]{"04","05","06"};
         }
         if (quarterTime == 3){
-             quarter = new String[]{"7","8","9"};
+             quarter = new String[]{"07","08","09"};
         }
         if (quarterTime == 4){
              quarter = new String[]{"10","11","12"};
         }
-        map.put("yearTime",yearTime);
-        map.put("monthTime",monthTime);
         map.put("quarterTime",quarterTime);
         map.put("quarter",quarter);
         return map;
@@ -2292,17 +2400,153 @@ public class DateUtils extends PropertyEditorSupport {
      * @return
      */
     public static String getQuarterEndDay(String time) {
-        Date date = parseDate(time, "yyyy-MM-dd");
-        Calendar cal = Calendar.getInstance();
-        cal.setTime(date);
-        cal.add(Calendar.MONTH, 3);
-        cal.add(Calendar.DATE, -1);
-        return dateToStringTime(cal.getTime());
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        Date dEnd = null;
+        try {
+            dEnd = sdf.parse(time);
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(dEnd);
+        int remainder = (calendar.get(Calendar.MONTH) + 1) % 3;
+        int month = remainder != 0 ? calendar.get(Calendar.MONTH) + (3 - remainder) : calendar.get(Calendar.MONTH);
+        calendar.set(Calendar.MONTH, month);
+        calendar.set(Calendar.DAY_OF_MONTH, calendar.getActualMaximum(Calendar.DAY_OF_MONTH));
+        calendar.setTime(calendar.getTime());
+        return sdf.format(calendar.getTime());
     }
 
 
 
+    /**
+     * 获取当前月第一天
+     * @param month
+     * @return
+     */
+    public static Integer getFirstDayOfMonth(int month) {
+        Calendar calendar = Calendar.getInstance();
+        // 设置月份
+        calendar.set(Calendar.MONTH, month - 1);
+        // 获取某月最小天数
+        int firstDay = calendar.getActualMinimum(Calendar.DAY_OF_MONTH);
+        // 设置日历中月份的最小天数
+        calendar.set(Calendar.DAY_OF_MONTH, firstDay);
+        // 格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String firstDayDate = sdf.format(calendar.getTime());
+        return getDateInteger(firstDayDate);
+    }
 
+    /**
+     * 获取当前月最后一天
+     * @param month
+     * @return
+     */
+    public static Integer getLastDayOfMonth(int month) {
+        Calendar calendar = Calendar.getInstance();
+        // 设置月份
+        calendar.set(Calendar.MONTH, month - 1);
+        // 获取某月最大天数
+        int lastDay=0;
+        //2月的平年瑞年天数
+        if(month==2) {
+            // 这个api在计算2020年2月的过程中有问题
+            lastDay = calendar.getLeastMaximum(Calendar.DAY_OF_MONTH);
+        }else {
+            lastDay = calendar.getActualMaximum(Calendar.DAY_OF_MONTH);
+        }
+        // 设置日历中月份的最大天数
+        calendar.set(Calendar.DAY_OF_MONTH, lastDay);
+        // 格式化日期
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+        String lastDayDate = sdf.format(calendar.getTime());
+        return getDateInteger(lastDayDate);
+    }
+
+
+
+
+
+
+
+    public static Double getMaterialCost(String frozenTime, String createTime,int monthTime){
+
+        //String frozenTime = "";
+        //String createTime = "2022-11-02 12:23:23";
+
+        //绩效 = 在职月份 * 80w 额度
+        Double cost = new Double("800000");
+        int i = 3;
+
+        /**
+         * 人员离职
+         */
+        if (frozenTime != null){
+
+            Date  date = DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd"));
+            // 判断时间所在的季度
+            int quarterTime = DateUtils.getQuarter(date);
+
+            //季度查询时间 超过 离职时间 则比例为0 绩效 无
+            if (quarterTime < monthTime){
+                i = 0;
+                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},",frozenTime,monthTime,new Date());
+
+            }
+
+            if (quarterTime > monthTime){
+                log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},",frozenTime,monthTime,new Date());
+
+            }
+
+            //离职时间 是否是当前季度
+            if (quarterTime == monthTime){
+                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+                //离职时间所在 月份
+                String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
+                //离职时间所在的季度 的全部 月份
+                String[]  quarter =(String[]) map.get("quarter");
+                //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
+                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
+                i = j + 1;
+                log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}",frozenTime,monthTime,i,i*cost);
+
+            }
+            //return i * cost;
+
+        }else {
+            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){
+                i = 0;
+                log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},",createTime,monthTime,new Date());
+            }
+
+            //入职时间 在当前季度
+            if (quarterTime == monthTime){
+                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+                //月份
+                //入职时间所在 月份
+                String month = DateUtils.getMonth("yyyy-MM-dd",createTime);
+                //季度
+                String[]  quarter =(String[]) map.get("quarter");
+                //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
+                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
+                i = j + 1;
+                log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}",createTime,monthTime,i,i*cost);
+                return i * cost;
+            };
+        }
+        return i * cost;
+    }
 
 
 

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

@@ -1,12 +1,19 @@
 package cn.com.ctop.common.module.achievements.controller;
 
 import cn.com.ctop.common.module.achievements.service.IDesignerService;
+import com.alibaba.fastjson.JSON;
+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.jeecg.common.api.vo.Result;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+import java.util.Map;
+
 /**
  * 设计人员绩效
  *
@@ -29,9 +36,9 @@ public class DesignerAchievementsController {
      * @return
      */
     @GetMapping(value = "/getDesignBasicsInfoList")
-    public Result getDesignBasicsInfoList(@RequestParam(name = "userId") String userId,
-                                          @RequestParam(name = "pageNum",defaultValue = "1") Integer pageNum,
-                                          @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+    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);
 
@@ -45,9 +52,11 @@ public class DesignerAchievementsController {
      * @return
      */
     @GetMapping(value = "/getHotVideoData")
-    public Result getHotVideoData(@RequestParam(name = "userId") String userId) {
+    public List<Map<String,Object>> getHotVideoData(@RequestParam(name = "userId") String userId,
+                                                    @RequestParam(name = "yearTime")String yearTime,
+                                                    @RequestParam(name = "monthTime")String monthTime) {
 
-        return designerService.getHotVideoData(userId);
+        return designerService.getHotVideoData(userId,yearTime,monthTime);
 
     }
 
@@ -59,8 +68,10 @@ public class DesignerAchievementsController {
      * @return
      */
     @GetMapping(value = "/getDesignerAchievements")
-    public Result getDesignerAchievements(@RequestParam(name = "userId") String userId) {
-        return designerService.getDesignerAchievements(userId);
+    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);
 
     }
 
@@ -72,11 +83,14 @@ public class DesignerAchievementsController {
      * @return
      */
     @GetMapping(value = "/getDesignerCommission")
-    public Result getDesignerCommission(@RequestParam(name = "userId") String userId) {
-        return designerService.getDesignerCommission(userId);
+    public JSONObject getDesignerCommission(@RequestParam(name = "userId") String userId,
+                                            @RequestParam(name = "yearTime")String yearTime,
+                                            @RequestParam(name = "monthTime")String monthTime) {
+        return designerService.getDesignerCommission(userId,yearTime,monthTime);
 
     }
 
+
     /**
      * 修改绩效中的用户部分信息
      *
@@ -91,4 +105,73 @@ public class DesignerAchievementsController {
 
     }
 
+
+    /**
+     * 基础信息+爆款
+     * @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);
+
+    }
+
+
+
+    /**
+     * 基础信息+绩效
+     * @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);
+
+    }
+
+
+    /**
+     * 基础信息+提成
+     * @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);
+
+    }
+
+
+    /**
+     * 根据角色查询人员
+     * @param roleName
+     * @return
+     */
+    @GetMapping(value = "/getUserByRoleName")
+    public Result getUserByRoleName(@RequestParam(name = "roleName") String roleName) {
+       return designerService.getUserByRoleName(roleName);
+
+    }
+
+
+
 }

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

@@ -1,6 +1,7 @@
 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;
@@ -29,34 +30,60 @@ public interface DesignerMapper{
      * @param userId
      * @param roleName  角色名称
      * @param mediaType 1-头条 2-快手
-     * @param yearTime 当前年份
-     * @param monthTime 当前月份
+     * @param startTime 当前年份
+     * @param endTime 当前月份
      * @return
      */
     JSONObject  getHotVideoData(@Param("userId")String userId,
                                      @Param("roleName") String roleName,
-                                     @Param("mediaType") String mediaType,
-                                     @Param("yearTime") String yearTime,
-                                     @Param("monthTime") String monthTime);
+                                     @Param("mediaType") Integer mediaType,
+                                @Param("startTime") Integer startTime,
+                                @Param("endTime") Integer endTime);
 
 
     /**
      *  设计人员绩效-头条
      * @param userId
-     * @param yearTime
-     * @param monthTime
+     * @param startTime
+     * @param endTime
      * @return
      */
     List<JSONObject>  getDesignerAchievementsBytedance(@Param("userId")String userId,
-                                     @Param("yearTime") String yearTime,
-                                     @Param("monthTime") String monthTime);
+                                     @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);
+/**
+     * 查询设计 本季度 快手季度消耗汇总
      * @param userId
      * @return
      */
-    List<JSONObject>  getDesignerBytedanceAndKuaishouQuaterCost(@Param("userId")String userId);
+    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);
 
     /**
      * 查询人员离职时间
@@ -70,7 +97,8 @@ public interface DesignerMapper{
      * @param userId
      * @return
      */
-    JSONObject  getUserHotMaterialQuarter(@Param("userId")String userId);
+    JSONObject  getUserHotMaterialQuarter(@Param("userId")String userId,@Param("startTime") Integer startTime,
+                                          @Param("endTime") Integer endTime);
 
     /**
      * 绩效- 用户信息修改
@@ -82,6 +110,12 @@ public interface DesignerMapper{
                                            @Param("remarks")String remarks);
 
 
+    /**
+     * 根据角色查询人员
+     * @param roleName
+     * @return
+     */
+    List<JSONObject> getUserByRoleName(@Param("roleName")String roleName);
 
 
 }

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

@@ -29,6 +29,7 @@
                     </foreach>
             </if>
         </where>
+        ORDER BY u.id
     </select>
 
 
@@ -44,11 +45,9 @@
         application.hot_material h
         LEFT JOIN `jeecg-boot`.ctop_material_ascription v ON v.material_id = h.signature
         where
-        v.clip_id != v.shot_id
-        AND v.shot_id != v.plan_id
-        AND h.media_id = #{mediaType}
-        AND DATE_FORMAT( h.hot_date, '%Y' ) = #{yearTime}
-        AND DATE_FORMAT( h.hot_date, '%m' ) = #{monthTime}
+         h.media_id = #{mediaType}
+        AND h.hot_date &gt;= #{startTime}
+        AND  h.hot_date &lt;= #{endTime}
         <if test="roleName == 'clip'.toString()">
             AND clip_id = #{userId}
         </if>
@@ -61,6 +60,10 @@
             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>
+
     </select>
 
 
@@ -80,8 +83,10 @@
             application.bytedance_material_cost_daily d
         WHERE
             clip_id = #{userId}
-          AND DATE_FORMAT( d.first_cost_day, '%Y' ) = #{yearTime}
-          AND DATE_FORMAT( d.first_cost_day, '%m' ) = #{monthTime}
+          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}
         UNION ALL
         SELECT
             QUARTER	( d.first_cost_day ) quaterTime,
@@ -95,8 +100,10 @@
             application.bytedance_material_cost_daily d
         WHERE
             shot_id = #{userId}
-          AND DATE_FORMAT( d.first_cost_day, '%Y' ) = #{yearTime}
-          AND DATE_FORMAT( d.first_cost_day, '%m' ) = #{monthTime}
+          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}
         UNION ALL
         SELECT
             QUARTER	( d.first_cost_day ) quaterTime,
@@ -110,8 +117,10 @@
             application.bytedance_material_cost_daily d
         WHERE
             plan_id = #{userId}
-          AND DATE_FORMAT( d.first_cost_day, '%Y' ) = #{yearTime}
-          AND DATE_FORMAT( d.first_cost_day, '%m' ) = #{monthTime}
+          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}
     </select>
 
 
@@ -129,8 +138,10 @@
             application.kuaishou_material_cost_daily d
         WHERE
             clip_id = #{userId}
-          AND DATE_FORMAT( d.first_cost_day, '%Y' ) = #{yearTime}
-          AND DATE_FORMAT( d.first_cost_day, '%m' ) = #{monthTime}
+          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}
         UNION ALL
         SELECT
             QUARTER	( d.first_cost_day ) quaterTime,
@@ -144,8 +155,10 @@
             application.kuaishou_material_cost_daily d
         WHERE
             shot_id = #{userId}
-          AND DATE_FORMAT( d.first_cost_day, '%Y' ) = #{yearTime}
-          AND DATE_FORMAT( d.first_cost_day, '%m' ) = #{monthTime}
+          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}
         UNION ALL
         SELECT
             QUARTER( d.first_cost_day ) quaterTime,
@@ -159,12 +172,14 @@
             application.kuaishou_material_cost_daily d
         WHERE
             plan_id = #{userId}
-          AND DATE_FORMAT( d.first_cost_day, '%Y' ) = #{yearTime}
-          AND DATE_FORMAT( d.first_cost_day, '%m' ) = #{monthTime}
+          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}
     </select>
 
-    <!-- 查询设计 本季度 头条和快手季度消耗汇总-->
-    <select id="getDesignerBytedanceAndKuaishouQuaterCost" resultType="com.alibaba.fastjson.JSONObject">
+    <!-- 查询设计 本季度 头条季度消耗汇总-->
+    <select id="getDesignerBytedanceQuaterCost" resultType="com.alibaba.fastjson.JSONObject">
         SELECT
             QUARTER( d.first_cost_day ) quaterTime,
             YEAR ( d.first_cost_day ) yearTime,
@@ -176,11 +191,14 @@
             (
             d.clip_id = #{userId} OR d.shot_id = #{userId} OR d.plan_id = #{userId}
             )
-          AND
-            QUARTER ( d.first_cost_day ) = QUARTER (NOW())
-          AND YEAR ( d.first_cost_day ) = YEAR (NOW())
-        UNION ALL
-        SELECT
+          AND stat_date &gt;= #{startTime}
+          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,
@@ -192,9 +210,33 @@
             (
             d.clip_id = #{userId} OR d.shot_id = #{userId} OR d.plan_id = #{userId}
             )
-          and
-            QUARTER ( d.first_cost_day ) = QUARTER (NOW())
-          AND YEAR ( d.first_cost_day ) = YEAR (NOW())
+          AND stat_date &gt;= #{startTime}
+          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
+        ORDER BY t.sort
     </select>
 
 
@@ -208,7 +250,8 @@
             u.frozen_time frozenTime,
             IFNULL(u.open_screen_num,0) openHotVideoNum,
             IFNULL(u.pay_salary,0) paySalary,
-            u.remarks
+            u.remarks,
+            u.status
         FROM
             `jeecg-boot`.sys_user u
         WHERE u.id = #{userId}
@@ -228,10 +271,10 @@
                 (v.plan_id = #{userId}
                     OR v.clip_id = #{userId}
                     or v.shot_id =#{userId}
+                    or v.leader_id = #{userId}
                     )
-                and
-                QUARTER ( h.hot_date ) = QUARTER (NOW())
-                AND YEAR ( h.hot_date ) = YEAR (NOW())
+          AND  h.hot_date &gt;= #{startTime}
+          AND  h.hot_date &lt;= #{endTime}
 
     </select>
 
@@ -256,5 +299,42 @@
 
 
 
+    <!-- 根据角色查询人员 -->
+    <select id="getUserByRoleName" 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`
+        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>
+             <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>
+
+
+
+
+
 
 </mapper>

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

@@ -1,8 +1,12 @@
 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;
+
 /**
  * 设计人员绩效
  *
@@ -13,14 +17,22 @@ import org.jeecg.common.api.vo.Result;
 public interface IDesignerService{
 
 
-    Result getDesignBasicsInfoList(String userId,int pageNum,int pageSize);
+    PageInfo<JSONObject> getDesignBasicsInfoList(String userId, int pageNum, int pageSize);
 
-    Result getHotVideoData(String userId);
+    List<Map<String,Object>> getHotVideoData(String userId,String yearTime,String monthTime);
 
-    Result getDesignerAchievements(String userId);
+    Map<String,Object> getDesignerAchievements(String userId,String yearTime,String monthTime);
 
-    Result getDesignerCommission(String userId);
+    JSONObject getDesignerCommission(String userId,String yearTime,String monthTime);
 
     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 getUserByRoleName(String roleName);
+
 }

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

@@ -3,6 +3,8 @@ 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;
@@ -16,6 +18,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.function.ToDoubleFunction;
@@ -42,7 +45,7 @@ public class DesignerServiceImpl implements IDesignerService {
     private ToDoubleFunction<JSONObject> getJSONObject;
 
     @Override
-    public Result getDesignBasicsInfoList(String userId,int pageNum,int pageSize) {
+    public PageInfo<JSONObject> getDesignBasicsInfoList(String userId,int pageNum,int pageSize) {
         String departName = null;
         Set<String> userIdList = new HashSet<>();
         //查询用户角色
@@ -59,7 +62,8 @@ public class DesignerServiceImpl implements IDesignerService {
         PageHelper.startPage(pageNum,pageSize);
         List<JSONObject> list = designerMapper.getDesignerUserInfo(departName,userIdList);
         PageInfo<JSONObject> pageInfo = new PageInfo<>(list);
-        return Result.successMsg("设计基础信息查询成功",pageInfo);
+
+        return pageInfo;
     }
 
 
@@ -72,7 +76,7 @@ public class DesignerServiceImpl implements IDesignerService {
      * @author: zianY
      */
     @Override
-    public Result getHotVideoData(String userId) {
+    public List<Map<String,Object>> getHotVideoData(String userId,String yearTime,String monthTime) {
         String roleName = null;
         //查询用户角色
         String roleCode = roleService.getRoleCodeByUserId(userId);
@@ -83,62 +87,66 @@ public class DesignerServiceImpl implements IDesignerService {
         }else if (roleCode.contains("plan")){
             roleName = "plan";
         }else {
-            return Result.successMsg("请核实人员["+userId+"]角色信息。",userId);
+            roleName = "all";
         }
+
+
         //取当前时间的季度的月份
-        Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(DateUtils.dateToStringTime(new Date()));
-        String[] quarterStr = (String[])timeMap.get("quarter");
+        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 (String month : quarterStr ){
+        for (Map<String,Integer> month : timeMap ){
             //头条
-            JSONObject bytedanceJson = designerMapper.getHotVideoData(userId,roleName,"1",timeMap.get("yearTime")+"",month);
+            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",timeMap.get("yearTime")+"",month);
+            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 Result.successMsg("设计基础信息查询成功",resultList);
+        return resultList;
     }
 
 
    @Override
-    public Result getDesignerAchievements(String userId) {
-        //取当前时间的季度的月份
-        Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(DateUtils.dateToStringTime(new Date()));
-        String[] quarterStr = (String[])timeMap.get("quarter");
+    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 (String month : quarterStr ){
+        for (Map<String,Integer> month : timeMap ){
             Map<String,Object> bytedanceMap = new HashMap<>();
             Map<String,Object> kuaishouMap = new HashMap<>();
             //头条
-            List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId,timeMap.get("yearTime")+"",month);
+            List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId,month.get("startTime"),month.get("endTime"));
             bytedanceMap.put("monthTime",month );
-            bytedanceMap.put("yearTime",timeMap.get("yearTime")+"" );
+            bytedanceMap.put("yearTime",yearTime);
             bytedanceMap.put("byteDance",bytedanceJson);
             byteDanceList.add(bytedanceMap);
             //快手
-            List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsBytedance(userId,timeMap.get("yearTime")+"",month);
+            List<JSONObject> kuaishouJson = designerMapper.getDesignerAchievementsKuaishou(userId,month.get("startTime"),month.get("endTime"));
             kuaishouMap.put("monthTime",month );
-            bytedanceMap.put("yearTime",timeMap.get("yearTime")+"" );
+            bytedanceMap.put("yearTime",yearTime);
             kuaishouMap.put("kuaiShou",kuaishouJson);
             kuaishouList.add(kuaishouMap);
         }
        resultMap.put("byteDanceData",byteDanceList);
        resultMap.put("kuaiShouData",kuaishouList);
-        return Result.successMsg("设计绩效信息查询成功",resultMap);
+        return resultMap;
     }
 
 
@@ -151,9 +159,9 @@ public class DesignerServiceImpl implements IDesignerService {
      * createTime 员工入职时间
      * @return
      */
-    public Double getMaterialCost(String frozenTime, String createTime){
+    public Double getMaterialCost(String frozenTime, String createTime,int yearTime,int monthTime){
 
-        //String frozenTime = "";
+//String frozenTime = "";
         //String createTime = "2022-11-02 12:23:23";
 
         //绩效 = 在职月份 * 80w 额度
@@ -163,36 +171,79 @@ public class DesignerServiceImpl implements IDesignerService {
         /**
          * 人员离职
          */
-        if (!Check.isNull(frozenTime)){
-            //离职时间 是否在当前季度
-            if (DateUtils.isThisQuarter(frozenTime)){
-                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(frozenTime);
-                //月份
-                String monthTime = map.get("monthTime")+"" ;
-                //季度
+        if (frozenTime != null){
+            String yearF = DateUtils.getYear("yyyy-MM-dd", frozenTime);
+            if (!yearF.equals(String.valueOf(yearTime))){
+                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。",frozenTime,monthTime);
+                return 0 * cost;
+            }
+
+
+            Date  date = DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd"));
+            // 判断时间所在的季度
+            int quarterTime = DateUtils.getQuarter(date);
+
+            //季度查询时间 超过 离职时间 则比例为0 绩效 无
+            if (quarterTime < monthTime){
+                i = 0;
+                log.info("离职-----离职时间是:{},查询季度{} 绩效按照0计算。当前时间是:{},",frozenTime,monthTime,new Date());
+
+            }
+
+            if (quarterTime > monthTime){
+                log.info("离职-----离职时间是:{},查询季度{},绩效按照240计算。当前时间是:{},",frozenTime,monthTime,new Date());
+
+            }
+
+            //离职时间 是否是当前季度
+            if (quarterTime == monthTime){
+                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+                //离职时间所在 月份
+                String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
+                //离职时间所在的季度 的全部 月份
                 String[]  quarter =(String[]) map.get("quarter");
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
-                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(monthTime));
+                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
                 i = j + 1;
-                log.info("离职-----离职时间是:{}在本季度范围内!系数为{}个月的绩效数据--->{}",frozenTime,i,i*cost);
-                return i * cost;
-            };
-            log.info("离职-----离职时间是:{}不在本季度范围内!绩效按照240计算。当前时间是:{},",frozenTime,new Date());
+                log.info("离职-----离职时间是:{}在查询季度{}范围内!系数为{}个月的绩效数据--->{}",frozenTime,monthTime,i,i*cost);
+
+            }
+            //return i * cost;
+
         }else {
-            //入职时间 是否在当前季度
-            if (DateUtils.isThisQuarter(createTime)){
-                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(createTime);
+            String yearC = DateUtils.getYear("yyyy-MM-dd", createTime);
+            if (!yearC.equals(String.valueOf(yearTime))){
+                log.info("在职-----入职时间是:{},查询季度{} 绩效按照240计算。",createTime,monthTime);
+                return i * cost;
+            }
+            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){
+                i = 0;
+                log.info("在职-----入职时间是:{},查询季度{},绩效按照0计算。当前时间是:{},",createTime,monthTime,new Date());
+            }
+
+            //入职时间 在当前季度
+            if (quarterTime == monthTime){
+                Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
                 //月份
-                String monthTime = map.get("monthTime")+"" ;
+                //入职时间所在 月份
+                String month = DateUtils.getMonth("yyyy-MM-dd",createTime);
                 //季度
                 String[]  quarter =(String[]) map.get("quarter");
                 //判断当前离职所在的月份 与当前季度中的月份集合 并获取下标  下标+1 则是 在职月份i
-                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(monthTime));
-                i = 3 - j;
-                log.info("在职-----入职时间是:{}在本季度范围内!系数为{}个月的绩效数据--->{}",createTime,i,i*cost);
+                int j = Collections.indexOfSubList(Arrays.asList(quarter),Arrays.asList(month));
+                i = j + 1;
+                log.info("在职-----入职时间是:{}在查询季度{}内!系数为{}个月的绩效数据--->{}",createTime,monthTime,i,i*cost);
                 return i * cost;
             };
-            log.info("在职-----入职时间是:{}不在本季度范围内!绩效按照240计算。当前时间是:{},",createTime,new Date());
         }
         return i * cost;
     }
@@ -203,26 +254,47 @@ public class DesignerServiceImpl implements IDesignerService {
      * frozenTime 离职时间
      * @return
      */
-    public Double userHappyProbability(String frozenTime){
+    public Double userHappyProbability(String frozenTime,int monthTime){
 
         //离职发放比例
         Double userHappyProbability = new Double("1");
         if (!Check.isNull(frozenTime)){
-            //离职时间所在季度的最后一天
-            String endDay = DateUtils.getQuarterEndDay(frozenTime);
-            //离职月份
+            //根据时间获取季度
+            //离职时间所在的季度 是否和 查询季度相同 相同则判断 不同 则比例为1
+
+            //当前季度的 月份
+            Map<String,Object> map = DateUtils.getCurrentQuarterMonths(monthTime);
+            //季度
+            String[]  quarter =(String[]) map.get("quarter");
             String month = DateUtils.getMonth("yyyy-MM-dd",frozenTime);
-            // 离职时间 > = 最后一天 发放比例为1
-            if (DateUtils.str2Date(frozenTime,new SimpleDateFormat("yyyy-MM-dd")).getTime() >=
-                    DateUtils.str2Date(endDay,new SimpleDateFormat("yyyy-MM-dd")).getTime()){
-                userHappyProbability = new Double("1");
+            if (Arrays.binarySearch(quarter,month) < 0){
+                return userHappyProbability;
             }
+
+
+            //离职  获取 天
+            String day = DateUtils.getDay("yyyy-MM-dd",frozenTime);
+
             //15日之前离职 不发
+            if (Integer.valueOf(day) < 15){
+                userHappyProbability = new Double("0");
+            }
+
             // 15号之后离职,发50%
-            if (Integer.valueOf(month) >= 15){
+            if (Integer.valueOf(day) >= 15){
                 userHappyProbability = new Double("0.5");
             }
 
+            //离职时间所在季度的最后一天
+            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()){
+                userHappyProbability = new Double("1");
+            }
+
+
         }
 
         return userHappyProbability;
@@ -235,24 +307,57 @@ public class DesignerServiceImpl implements IDesignerService {
 
 
    @Override
-    public Result getDesignerCommission(String userId) {
-        //取当前时间的季度的月份
-        Map<String,Object> timeMap = DateUtils.getCurrentQuarterMonths(DateUtils.dateToStringTime(new Date()));
-        String[] quarterStr = (String[])timeMap.get("quarter");
+    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);
 
+       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"));
+           Map<String,Object> leaderCostMap = new HashMap<>();
+           leaderCostMap.put("bytedanceCost",leaderCost.get(0).getString("cost"));
+           leaderCostMap.put("kuaishouCost",leaderCost.get(1).getString("cost"));
+           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);
 
        //季度 分媒体 素材消耗
-       List<JSONObject> quarterCost = designerMapper.getDesignerBytedanceAndKuaishouQuaterCost(userId);
-       userFrozen.put("quarterCostList",quarterCost);
+       userFrozen.put("quarterCostList",quarterCostList);
 
        //季度素材 总消耗
-       Double tatolCost = quarterCost.stream().mapToDouble(json -> json.getDouble("cost")).reduce(Double::sum).orElse(new Double("0"));
+       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);
 
        //离职时间
        String frozenTime = userFrozen.getString("frozenTime");
@@ -260,89 +365,135 @@ public class DesignerServiceImpl implements IDesignerService {
        String createTime = userFrozen.getString("createTime");
 
        //判断素材消耗是否达标
-       Double i = getMaterialCost(frozenTime,createTime);
+       Double i = getMaterialCost(frozenTime,createTime,Integer.valueOf(yearTime),Integer.valueOf(monthTime));
        String materialCostQualifiedFlag = tatolCost >= i ? "是" : "否";
        userFrozen.put("materialCostQualifiedFlag",materialCostQualifiedFlag);
 
-       //爆款素材数量
-       JSONObject hotVideoNum = designerMapper.getUserHotMaterialQuarter(userId);
+       //爆款素材数量 分月查询
+       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);
 
-       /**
-        * 爆款达标 提成发放系数
-        * 在季度中
-        * 爆款 >= 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);
 
 
        //提成 分月份
        List<JSONObject> commissionList = new ArrayList<>();
-       for (String month : quarterStr ) {
+       for (Map<String,Integer> month : timeMap ) {
            JSONObject commissionJson = new JSONObject();
            //头条提成
-           List<JSONObject> bytedanceJson = designerMapper.getDesignerAchievementsBytedance(userId, timeMap.get("yearTime") + "", month);
+           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.getDesignerAchievementsBytedance(userId, timeMap.get("yearTime") + "", month);
+           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);
-           commissionJson.put("yearTime", timeMap.get("yearTime") + "");
-           commissionJson.put("commission", bytedanceCommission+kuaishouCommission);
+           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);
+
+               //设计组长 看月份  如果6月离职的,则只计算4、5月份的,与日期无关
+               if (roleCode.equalsIgnoreCase("designTeamLeader")){
+                   if (frozenT > month.get("endTime")){
+                       userHappyProbability = new Double(1);
+                   }else {
+                       userHappyProbability = new Double(0);
+                   }
+                   //如果当月15日之前离职,当月不发;
+                   // 15号之后离职,发50%;
+                   // 若月底最后一天离职,则发放100
+               }else {
+                   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("ticheng", (bytedanceCommission+kuaishouCommission) * userHappyProbability);
+           commissionJson.put("commission", (bytedanceCommission+kuaishouCommission) * userHappyProbability);
+           commissionJson.put("commissionOld", bytedanceCommission+kuaishouCommission);
            commissionList.add(commissionJson);
+
        }
        userFrozen.put("commissionList",commissionList);
 
 
        //季度提成汇总
-       Double totalCommission = commissionList.stream().mapToDouble(json -> json.getDouble("commission")).reduce(Double::sum).orElse(new Double("0"));
+       BigDecimal totalCommissionBd = commissionList.stream().map(json -> json.getBigDecimal("commission")).reduce(BigDecimal.ZERO,BigDecimal::add);
+       Double totalCommission = totalCommissionBd.doubleValue();
 
-       //如果是负责人 (设计组长) 负责人提成千三的20%
+       //负责人提成 如果是负责人 (设计组长) 管理消耗 千三的20%
        Double designerLeaderCommission = new Double("0");
-       String roleCode = roleService.getRoleCodeByUserId(userId);
+
        if (roleCode.equalsIgnoreCase("designTeamLeader")){
-           designerLeaderCommission = totalCommission * 0.003 * 0.2;
+           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);
 
 
-       //离职发放比例
-       Double userHappyProbability = userHappyProbability(frozenTime);
+       /**
+        * 爆款达标 提成发放系数
+        * 在季度中
+        * 爆款 >= 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 * userHappyProbability;
+       //提成发放金额 = 总提成 * 爆款达标发放系数
+       Double userHappyGetMoney = totalCommission * coefficient;
        userFrozen.put("userHappyGetMoney",userHappyGetMoney);
 
-       return Result.successMsg("查询成功",userFrozen);
+       return userFrozen;
 
 
    }
@@ -365,6 +516,59 @@ public class DesignerServiceImpl implements IDesignerService {
 
 
 
+    @Override
+    public Result getDesignerBasicsAndHotVideoInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
+        //基础信息 + 爆款信息
+        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
+        for (JSONObject jsonObject : baseics.getList()) {
+            List<Map<String,Object>> hotVideo = getHotVideoData(jsonObject.getString("userId"),yearTime,monthTime);
+            jsonObject.put("hotVideoInfo",hotVideo);
+        }
+        return Result.successMsg("基础+爆款查询成功。",baseics);
+
+
+    }
+
+
+    @Override
+    public Result getDesignerBasicsAndAch(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
+        //基础信息 + 绩效
+        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
+        for (JSONObject jsonObject : baseics.getList()) {
+            //绩效
+            Map<String,Object> achievementsMap = getDesignerAchievements(jsonObject.getString("userId"),yearTime,monthTime);
+            jsonObject.put("achievementsMap",achievementsMap);
+        }
+        return Result.successMsg("基础+绩效查询成功。",baseics);
+    }
+
+
+    @Override
+    public Result getDesignerBasicsAndAchAndComInfo(String userId,String yearTime,String monthTime,int pageNum,int pageSize){
+        //基础信息 +提成
+        PageInfo<JSONObject> baseics = getDesignBasicsInfoList(userId,pageNum,pageSize);
+        for (JSONObject jsonObject : baseics.getList()) {
+            //提成
+            JSONObject userFrozen = getDesignerCommission(jsonObject.getString("userId"),yearTime,monthTime);
+            jsonObject.put("userFrozen",userFrozen);
+        }
+        return Result.successMsg("基础+提成查询成功。",baseics);
+    }
+
+
+
+
+
+
+
+    @Override
+    public Result getUserByRoleName(String roleName){
+        List<JSONObject> list = designerMapper.getUserByRoleName(roleName);
+        return Result.successMsg("查询成功。",list);
+    }
+
+
+
 
 
 

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

@@ -428,7 +428,7 @@ public class KuaishouOperationReportServiceImpl extends ServiceImpl<KuaishouOper
             String quitTime = user.getString("quitTime");
             if (!Check.isNull(quitTime)) {
                 Integer startMonth = Integer.valueOf(DateUtils.getMonth("yyyy-MM-dd", dateMap.get("startDate")));
-                Integer endMonth = Integer.valueOf(DateUtils.getMonth("yyyy-MM-dd HH:mm:ss", quitTime));
+                Integer endMonth = Integer.valueOf(DateUtils.getMonth("yyyy-MM-dd", quitTime));
                 user.put("monthCount", endMonth - startMonth + 1);
             }
         }
@@ -1003,7 +1003,7 @@ public class KuaishouOperationReportServiceImpl extends ServiceImpl<KuaishouOper
             String quitTime = user.getString("quitTime");
             if (!Check.isNull(quitTime)) {
                 Integer startMonth = Integer.valueOf(DateUtils.getMonth("yyyy-MM-dd", dateMap.get("startDate")));
-                Integer endMonth = Integer.valueOf(DateUtils.getMonth("yyyy-MM-dd HH:mm:ss", quitTime));
+                Integer endMonth = Integer.valueOf(DateUtils.getMonth("yyyy-MM-dd", quitTime));
                 user.put("monthCount", endMonth - startMonth + 1);
             }
         }

+ 7 - 7
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-dev.yml

@@ -122,14 +122,14 @@ spring:
       datasource:
         master:
 #---------------------线上库
-#          url: jdbc:mysql://139.186.27.96:3390/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=GMT%2B8
-#          username: readonly
-#          password: hcst@2021
+          url: jdbc:mysql://139.186.27.96:3390/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=GMT%2B8
+          username: data
+          password: hcst@2021
 #---------------------测试库
-          url: jdbc:mysql://139.186.165.84:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true
-          username: hcst
-          password: hcst@2020
-          driver-class-name: com.mysql.jdbc.Driver
+#          url: jdbc:mysql://139.186.165.84:3306/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&allowMultiQueries=true
+#          username: hcst
+#          password: hcst@2020
+#          driver-class-name: com.mysql.jdbc.Driver
   #redis 配置
   redis:
     database: 0

+ 7 - 0
jeecg-cloud-module/jeecg-cloud-system-start/src/main/resources/application-test.yml

@@ -120,6 +120,13 @@ spring:
           username: hcst
           password: hcst@2020
           driver-class-name: com.mysql.jdbc.Driver
+
+          #---------------------线上库
+#          url: jdbc:mysql://139.186.27.96:3390/jeecg-boot?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=GMT%2B8
+#          username: data
+#          password: hcst@2021
+
+
   #redis 配置
   redis:
     database: 0