|
@@ -1,4 +1,3 @@
|
|
|
-/*
|
|
|
package org.jeecg.modules.system.service.impl;
|
|
|
|
|
|
import cn.com.ctop.performanceappraisal.entity.OptimizerConfig;
|
|
@@ -6,37 +5,37 @@ import cn.com.ctop.performanceappraisal.entity.Performance;
|
|
|
import cn.com.ctop.performanceappraisal.mapper.PerformanceMapper;
|
|
|
import cn.com.ctop.performanceappraisal.service.IOptimizerConfigService;
|
|
|
import cn.com.ctop.performanceappraisal.vo.OptimizerCostDetailVO;
|
|
|
+import cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo;
|
|
|
import cn.com.ctop.userefficientvideomap.entity.EffiVideoDTO;
|
|
|
import cn.com.ctop.userefficientvideomap.entity.ProjectDTO;
|
|
|
import cn.com.ctop.userefficientvideomap.entity.UserEfficientVideoMap;
|
|
|
import cn.com.ctop.userefficientvideomap.mapper.UserEfficientVideoMapMapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import org.apache.commons.io.filefilter.FalseFileFilter;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.shiro.SecurityUtils;
|
|
|
+import org.jeecg.common.system.vo.LoginUser;
|
|
|
import org.jeecg.common.util.DateUtils;
|
|
|
import org.jeecg.modules.system.entity.EffiRateComparator;
|
|
|
import org.jeecg.modules.system.entity.UserDto;
|
|
|
import org.jeecg.modules.system.mapper.SysRoleMapper;
|
|
|
-import org.jeecg.modules.system.service.IPerformanceService;
|
|
|
+import org.jeecg.modules.system.service.IPerformanceService2;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.text.ParseException;
|
|
|
-import java.util.Collections;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
|
|
|
-*/
|
|
|
/**
|
|
|
* 设计师季度绩效表
|
|
|
*
|
|
|
* @author jeecg-boot
|
|
|
* @version V1.0
|
|
|
* @date 2019-12-10
|
|
|
- *//*
|
|
|
-
|
|
|
+ */
|
|
|
+@Slf4j
|
|
|
@Service
|
|
|
-public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Performance> implements IPerformanceService {
|
|
|
+public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Performance> implements IPerformanceService2 {
|
|
|
|
|
|
@Autowired
|
|
|
private PerformanceMapper performanceMapper;
|
|
@@ -130,8 +129,7 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- */
|
|
|
-/**
|
|
|
+ /**
|
|
|
* 分平台:快手、抖音
|
|
|
*
|
|
|
* 编导、剪辑、拍摄:
|
|
@@ -151,8 +149,7 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
* 2.查询出所有设计部门的代码,并找出每部门的leader,和部门下所有人员
|
|
|
* 3.根据编导(或剪辑、拍摄)算出素材的总消耗
|
|
|
* 4.根据部门当中是否有平面设计师来判断提成绩效。有平面,按照15%计算;没有按照20%计算
|
|
|
- *//*
|
|
|
-
|
|
|
+ */
|
|
|
//季度定时任务(在有效视频绑定人定时任务之后跑):设计师绩效计算-----包括快手和头条的计算逻辑
|
|
|
public void designerPerformanceTask(){
|
|
|
kuaishouDesigner();//快手
|
|
@@ -200,7 +197,7 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
//有效视频数量
|
|
|
int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(thisYear),thisQuarter,userDto.getUserId());
|
|
|
//总视频数量
|
|
|
- int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(startTime, endTime, userDto.getUserId());
|
|
|
+ int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId("plan",startTime, endTime, userDto.getUserId());
|
|
|
//视频有效率
|
|
|
BigDecimal effiRate = new BigDecimal( String.valueOf(effiVideoCount) ).divide( new BigDecimal(String.valueOf(videoCount)) );
|
|
|
userDto.setEffiRate(effiRate);
|
|
@@ -266,7 +263,7 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
//有效视频数量
|
|
|
int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(thisYear),thisQuarter,userDto.getUserId());
|
|
|
//总视频数量
|
|
|
- int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(startTime, endTime, userDto.getUserId());
|
|
|
+ int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId("shot",startTime, endTime, userDto.getUserId());
|
|
|
//视频有效率
|
|
|
BigDecimal effiRate = new BigDecimal( String.valueOf(effiVideoCount) ).divide( new BigDecimal(String.valueOf(videoCount)) );
|
|
|
userDto.setEffiRate(effiRate);
|
|
@@ -332,7 +329,7 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
//有效视频数量
|
|
|
int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(thisYear),thisQuarter,userDto.getUserId());
|
|
|
//总视频数量
|
|
|
- int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(startTime, endTime, userDto.getUserId());
|
|
|
+ int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId("clip",startTime, endTime, userDto.getUserId());
|
|
|
//视频有效率
|
|
|
BigDecimal effiRate = new BigDecimal( String.valueOf(effiVideoCount) ).divide( new BigDecimal(String.valueOf(videoCount)) );
|
|
|
userDto.setEffiRate(effiRate);
|
|
@@ -431,7 +428,7 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
}
|
|
|
///////////////////////////////////////////////////////////////////平面end
|
|
|
|
|
|
- //设计师leader start
|
|
|
+ //TODO 设计师leader start
|
|
|
//* 1.如果媒体总任务未达成,则没有绩效;如果已达成,则按照千分之5给予提点绩效
|
|
|
//* 2.查询出所有设计部门的代码,并找出每部门的leader,和部门下所有人员
|
|
|
//* 3.根据编导(或剪辑、拍摄)算出素材的总消耗
|
|
@@ -439,18 +436,6 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
|
|
|
//判断媒体任务是否达成,如果未达成,则没有绩效
|
|
|
if(mediaMission()){
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}else{
|
|
|
return;
|
|
|
}
|
|
@@ -507,36 +492,230 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
|
|
|
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.getOptimizerTotalCost(startDate, endDate, year, quarter);
|
|
|
+ return performanceMapper.getOptimizerTotalCost(startDate, endNowDate, year, quarter);
|
|
|
}
|
|
|
|
|
|
+ //1
|
|
|
+ //季度到前一天为止个人的有效数量、素材总数、素材有效率、总跑量
|
|
|
+ //{"effiVideoCount有效数":70,"videoCount素材总数":200,"effiRate":40,"cost":2019;performance绩效":20000}
|
|
|
+ public Map<String,Object> getPerformanceInfo(){
|
|
|
+ Map<String,Object> performanceInfoMap = 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);
|
|
|
|
|
|
- //TODO 平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效
|
|
|
- public void getPerformanceInfo(){
|
|
|
- //获取平台的总有效数量
|
|
|
- }
|
|
|
+ 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}
|
|
|
+ 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());
|
|
|
+
|
|
|
+ //获取剪辑人数并按照提点比例计算每个梯度的人数
|
|
|
+ int userRoleLength = userRoleList.size();
|
|
|
+ //获取前30%和中间50%的人数(视频有效率四舍五入)
|
|
|
+ int userTopSize = new BigDecimal(String.valueOf(userRoleLength)).multiply(new BigDecimal("0.3")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+ int userMiddleSize = new BigDecimal(String.valueOf(userRoleLength)).multiply(new BigDecimal("0.5")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+ log.info(roleCode + "的总人数为:" + userRoleLength + ";前30%人数为:"+ userTopSize + ";中间50%的人数为:" + userMiddleSize);
|
|
|
+
|
|
|
+ int index = 0;
|
|
|
+ for(int i=0; i<= userRoleLength; i++){
|
|
|
+ index = index+1;
|
|
|
+ if(userRoleList.get(i).getUserId() .equals( sysUser.getId() )){
|
|
|
+ log.info("当前登陆人userId:" + sysUser.getId() + ";姓名:" +sysUser.getRealname() + ";排名:" + index);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ //总消耗--获取这个人素材总消耗
|
|
|
+ //总绩效=总消耗*提点比例(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}
|
|
|
+ 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}
|
|
|
+ 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;
|
|
|
+ }
|
|
|
|
|
|
|
|
|
}
|
|
|
-*/
|