Pārlūkot izejas kodu

添加优化师头条相关统计接口

syh 5 gadi atpakaļ
vecāks
revīzija
35f26060b5

+ 3 - 273
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl2.java

@@ -42,9 +42,6 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     @Autowired
     private PlaneProjectCostMapper planeProjectCostMapper;
 
-    //获取季度有效视频和角色对应关系的定时任务
-    //每天定时任务:角色对应本季度有效视频计算--需要工具类有效视频计算工具类
-    @Override
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
     //有效视频计算开始
     ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@@ -63,17 +60,8 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
      *
      * @param calcDateStr yyyy-MM-dd格式的日期
      */
+    @Override
     public void efficientVideoTask(String calcDateStr) {
-        //本周五-下一个周四 为一周的计算起止时间
-        //
-        //例如:20191220-20191226这周
-        //总视频数:这一周时间内发布的所有视频的总数;
-        //有效视频数:20191129-20191205这一周发布的所有视频,在20191206-20191219这两周内成为有效视频的数量;
-
-        //1.有效视频应分平台,不同平台的人使用自己平台的计算(极少会有相同素材在两个平台上的交叉,这种情况下人工处理)
-        //2.设置周五为一个星期的第一天,则下一周的周四为一周的最后一天
-        //3.使用当前时间计算出周五的时间,然后根据此时间找出本周计算有效视频的时间,进行计算
-        //
         Date calcDate = null;
         try {
             calcDate = DateUtils.parseDate(calcDateStr, "yyyy-MM-dd");
@@ -295,157 +283,6 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     }
 
     //头条设计师逻辑
-    private void toutiaoDesigner() {
-        //TODO 头条目前还没有开发基础部件,等待开发完
-    }
-
-    //根据userId查询出所属的所有项目
-    private List<ProjectDTO> getProjects(String userId) {
-        List<ProjectDTO> projectDTOList = userEfficientVideoMapMapper.getProjectsByUserId(userId);
-        return projectDTOList;
-    }
-
-    //根据projectId判断此项目是否存在plane平面设计师
-    private boolean planeExistsInProject(Long projectId) {
-        int planeCount = userEfficientVideoMapMapper.getPlaneCountByProjectId(projectId);
-        if (planeCount == 0) {
-            return true;
-        }
-        return false;
-    }
-
-    //根据角色id判断所在team是否存在平面设计师
-    private boolean planeExistsInTeam(String userId) {
-        int planeCount = userEfficientVideoMapMapper.getPlaneCountByUserId(userId);
-        if (planeCount == 0) {
-            return true;
-        }
-        return true;
-    }
-
-    //判断媒体季度任务是否完成(设计师不需要判断季度媒体任务)
-    private boolean mediaMission() {
-        //查询优化师系统设置数据
-        OptimizerConfig config = optimizerConfigService.getEnabledConfigByMediaType(String.valueOf(2));
-
-        //2: 查询媒体季度任务完成情况
-        OptimizerCostDetailVO totalCostVo = getOptimizerTotalCost();
-        //result.put("totalCost", totalCostVo.getTotalCost().toString());
-        if (totalCostVo.getTotalCost().compareTo(config.getMediaTask()) < 0) {
-            //当前消耗季度任务未完成
-            return false;
-        }
-        return true;
-    }
-
-    public OptimizerCostDetailVO getOptimizerTotalCost() {
-        Date date = new Date();
-        Date getDate = DateUtils.addDay(date, -1);
-        String startDate = DateUtils.getQuarterStartDate(getDate);
-        String endDate = DateUtils.getQuarterEndDate(getDate);
-        String endNowDate = DateUtils.formatDate(getDate);
-        String year = DateUtils.getYear(getDate) + "";
-        String quarter = DateUtils.getQuarter(getDate) + "";
-        return performanceMapper.getKuaishouOptimizerTotalCost(startDate, endNowDate, year, quarter);
-    }
-
-    //1
-    //季度到前一天为止个人的有效数量、素材总数、素材有效率、总跑量
-    //{"effiVideoCount有效数":70,"videoCount素材总数":200,"effiRate":40,"cost":2019;performance绩效":20000}
-    @Override
-    public Map<String, Object> getPerformanceInfo() {
-        Map<String, Object> performanceInfoMap = new HashMap<>();
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-
-        //获取前一天的时间
-        Date date = new Date();
-        Date getDate = DateUtils.addDay(date, -1);
-        String startDate = DateUtils.getQuarterStartDate(getDate);
-        String endDate = DateUtils.getQuarterEndDate(getDate);
-        String endNowDate = DateUtils.formatDate(getDate);
-
-        String roleCode = sysRoleMapper.getRoleCodeByUserId(sysUser.getId());
-
-        log.info(roleCode + ":" + sysUser.getRealname() + "getPerformanceInfo接口开始");
-
-        Map<String, String> lastDateMap = getLastDateInfo();
-        //获取本人的视频总有效数量
-        int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(lastDateMap.get("year")), Integer.parseInt(lastDateMap.get("quarter")), sysUser.getId());
-        //获取本人的视频总数
-        int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(roleCode, startDate, endNowDate, sysUser.getId());
-        //获取本人目前的视频有效率
-        BigDecimal videoEffiRate = BigDecimal.ZERO;
-        if (effiVideoCount != 0 && videoCount != 0) {
-            videoEffiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount))).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
-        }
-        //获取本人的总跑量
-        BigDecimal cost = BigDecimal.ZERO;
-
-        if (roleCode.equals("plan")) {
-            cost = userEfficientVideoMapMapper.getTotalCostByPlanId(sysUser.getId(), startDate, endDate);
-        } else if (roleCode.equals("shot")) {
-            cost = userEfficientVideoMapMapper.getTotalCostByShotId(sysUser.getId(), startDate, endDate);
-        } else if (roleCode.equals("clip")) {
-            cost = userEfficientVideoMapMapper.getTotalCostByClipId(sysUser.getId(), startDate, endDate);
-        }
-
-        performanceInfoMap.put("effiVideoCount", effiVideoCount);
-        performanceInfoMap.put("videoCount", videoCount);
-        performanceInfoMap.put("effiRate", videoEffiRate);
-        performanceInfoMap.put("cost", cost);
-
-        log.info(roleCode + ":" + sysUser.getRealname() + "getPerformanceInfo接口开始");
-        return performanceInfoMap;
-    }
-
-    //2
-    //有效率排行榜
-    //{"list":[{"name":"pipi","effiRate":50},{"name":"pipixia","effiRate":40},{"name":"pipiqiu","effiRate":30}],"performance":performance}
-    @Override
-    public Map<String, Object> effiRateRank(Integer size) {
-        Map<String, Object> resultMap = new HashMap<>();
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //LoginUser sysUser = new LoginUser();
-        //sysUser.setId("9712328fddd1443faf566ddb87693658");
-
-        //获取前一天的时间
-        Date date = new Date();
-        Date getDate = DateUtils.addDay(date, -1);
-        String startDate = DateUtils.getQuarterStartDate(getDate);
-        String endDate = DateUtils.getQuarterEndDate(getDate);
-        String endNowDate = DateUtils.formatDate(getDate);
-        Map<String, String> lastDateMap = getLastDateInfo();
-        String roleCode = sysRoleMapper.getRoleCodeByUserId(sysUser.getId());
-
-        log.info(roleCode + ":" + sysUser.getRealname() + "有效率排行榜接口开始");
-
-        List<UserDto> userRoleList = new ArrayList<>();
-        BigDecimal rate = BigDecimal.ZERO; //提成比例
-        if (roleCode.equals("plan")) {
-            userRoleList = sysRoleMapper.getUserByRoleCode("plan"); //编导
-            rate = new BigDecimal("0.4");
-        } else if (roleCode.equals("shot")) {
-            userRoleList = sysRoleMapper.getUserByRoleCode("shot"); //拍摄
-            rate = new BigDecimal("0.1");
-        } else if (roleCode.equals("clip")) {
-            userRoleList = sysRoleMapper.getUserByRoleCode("clip"); //剪辑
-            rate = new BigDecimal("0.3");
-        }
-
-        if (userRoleList != null) {
-            for (UserDto userDto : userRoleList) {
-                //有效视频数量
-                int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(lastDateMap.get("year")), Integer.parseInt(lastDateMap.get("quarter")), userDto.getUserId());
-                //总视频数量
-                int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(roleCode, startDate, endNowDate, userDto.getUserId());
-                //视频有效率
-                BigDecimal effiRate = BigDecimal.ZERO;
-                if (effiVideoCount != 0 && videoCount != 0) {
-                    effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount))).multiply(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_HALF_UP);
-                }
-                userDto.setEffiRate(effiRate);
-            }
-            Collections.sort(userRoleList, new EffiRateComparator());
     private void toutiaoDesigner(int thisYear, int thisQuarter) {
         log.info(thisYear + "年第" + thisQuarter + "季度头条设计师季度绩效计算开始");
         Map<String, String> quarterStartEndDateMap = DateUtils.quarterStartEndDate(thisYear, thisQuarter);
@@ -466,115 +303,6 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
         log.info(thisYear + "年第" + thisQuarter + "头条设计师季度绩效计算开始");
     }
 
-            //总消耗--获取这个人素材总消耗
-            //总绩效=总消耗*提点比例(5‰)*提成比例(剪辑30%)
-            BigDecimal performance = BigDecimal.ZERO; //绩效
-            BigDecimal totalCost = BigDecimal.ZERO;  //总消耗
-            if (roleCode.equals("plan")) {
-                totalCost = userEfficientVideoMapMapper.getTotalCostByPlanId(sysUser.getId(), startDate, endNowDate);
-                if (index <= userTopSize) {
-                    performance = totalCost.multiply(new BigDecimal("0.005")).multiply(new BigDecimal("0.4"));
-                } else if (index > userTopSize && index <= (userTopSize + userMiddleSize)) {
-                    performance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.4"));
-                } else {
-                    performance = BigDecimal.ZERO;
-                }
-            } else if (roleCode.equals("shot")) {
-                totalCost = userEfficientVideoMapMapper.getTotalCostByShotId(sysUser.getId(), startDate, endNowDate);
-                if (index <= userTopSize) {
-                    performance = totalCost.multiply(new BigDecimal("0.005")).multiply(new BigDecimal("0.1"));
-                } else if (index > userTopSize && index <= (userTopSize + userMiddleSize)) {
-                    performance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.1"));
-                } else {
-                    performance = BigDecimal.ZERO;
-                }
-            } else {
-                totalCost = userEfficientVideoMapMapper.getTotalCostByClipId(sysUser.getId(), startDate, endNowDate);
-                if (index <= userTopSize) {
-                    performance = totalCost.multiply(new BigDecimal("0.005")).multiply(new BigDecimal("0.3"));
-                } else if (index > userTopSize && index <= (userTopSize + userMiddleSize)) {
-                    performance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.3"));
-                } else {
-                    performance = BigDecimal.ZERO;
-                }
-            }
-
-            //去掉list中前30的数据
-            if (size != null) {
-                userRoleList.subList(size, userRoleList.size()).clear();
-            }
-
-            resultMap.put("userRoleList", userRoleList);
-            resultMap.put("performance", performance);
-        } else {
-            resultMap.put("userRoleList", null);
-            resultMap.put("performance", 0);
-        }
-
-        log.info(roleCode + ":" + sysUser.getRealname() + "有效率排行榜接口结束");
-        return resultMap;
-    }
-
-    //3
-    //素材、素材跑量、封面点击数、封面曝光数、行为数
-    //{"videoUrl":"http://dadfadfadf.mp4","videoCost":34.56,"pageClickCount":1200,"pageExposureCount":3939,"behaviorCount":5000}
-    @Override
-    public List<DesignMaterialInfo> materialInfoList() {
-        LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
-        //LoginUser sysUser = new LoginUser();
-        //sysUser.setId("9712328fddd1443faf566ddb87693658");
-        String roleCode = sysRoleMapper.getRoleCodeByUserId(sysUser.getId());
-
-        log.info(roleCode + ":" + sysUser.getRealname() + "materialInfoList接口开始");
-
-        Date date = new Date();
-        Date getDate = DateUtils.addDay(date, -1);
-        String startDate = DateUtils.getQuarterStartDate(getDate);
-        String endDate = DateUtils.getQuarterEndDate(getDate);
-        String endNowDate = DateUtils.formatDate(getDate);
-
-        List<DesignMaterialInfo> materialInfoList = userEfficientVideoMapMapper.designMaterialInfoList(roleCode, sysUser.getId(), startDate, endNowDate);
-
-        log.info(roleCode + ":" + sysUser.getRealname() + "materialInfoList接口结束");
-        return materialInfoList;
-    }
-
-    //4
-    //点击+符号 投放账户、投放账户、跑量
-    //{"videoAccount":"aabbcc","servingAccount":"ttyyhh","cost":34234.43}
-    @Override
-    public List<DesignMaterialInfo> materialAccountInfo(String materialInfoId) {
-        log.info("materialAccountInfo接口开始");
-        Date date = new Date();
-        Date getDate = DateUtils.addDay(date, -1);
-        String startDate = DateUtils.getQuarterStartDate(getDate);
-        String endDate = DateUtils.getQuarterEndDate(getDate);
-        String endNowDate = DateUtils.formatDate(getDate);
-
-        List<DesignMaterialInfo> materialInfoList = userEfficientVideoMapMapper.getMaterialAccountInfoByMaterialId(materialInfoId, startDate, endNowDate);
-        log.info("materialAccountInfo接口结束");
-        return materialInfoList;
-    }
-
-    //获取前一天的年、季度信息
-    private Map<String, String> getLastDateInfo() {
-        Map<String, String> timeMap = new HashMap<String, String>();
-        Date date = new Date();
-        Date getDate = DateUtils.addDay(date, -1);
-        String startDate = DateUtils.getQuarterStartDate(getDate);
-        String endDate = DateUtils.getQuarterEndDate(getDate);
-        String year = DateUtils.getYear(getDate) + "";
-        String quarter = DateUtils.getQuarter(getDate) + "";
-
-        timeMap.put("startDate", startDate);
-        timeMap.put("endDate", endDate);
-        timeMap.put("year", year);
-        timeMap.put("quarter", quarter);
-        return timeMap;
-    }
-
-    //编导季度绩效计算
-    private void planPerformance(int thisYear, int thisQuarter, String startTime, String endTime) {
     ////////////////////////////////////////////////////////////////////////////////////////////
     //快手
     ////////////////////////////////////////////////////////////////////////////////////////////
@@ -1392,6 +1120,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     //3
     //素材、素材跑量、封面点击数、封面曝光数、行为数
     //{"videoUrl":"http://dadfadfadf.mp4","videoCost":34.56,"pageClickCount":1200,"pageExposureCount":3939,"behaviorCount":5000}
+    @Override
     public List<DesignMaterialInfo> materialInfoList() {
         LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
         //LoginUser sysUser = new LoginUser();
@@ -1415,6 +1144,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
     //4
     //点击+符号 投放账户、投放账户、跑量
     //{"videoAccount":"aabbcc","servingAccount":"ttyyhh","cost":34234.43}
+    @Override
     public List<DesignMaterialInfo> materialAccountInfo(String materialInfoId) {
         log.info("materialAccountInfo接口开始");
         Date date = new Date();