|
@@ -0,0 +1,536 @@
|
|
|
+package org.jeecg.modules.system.service.impl;
|
|
|
+
|
|
|
+import cn.com.ctop.performanceappraisal.entity.OptimizerConfig;
|
|
|
+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.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 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.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;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 设计师季度绩效表
|
|
|
+ *
|
|
|
+ * @author jeecg-boot
|
|
|
+ * @version V1.0
|
|
|
+ * @date 2019-12-10
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Performance> implements IPerformanceService {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private PerformanceMapper performanceMapper;
|
|
|
+ @Autowired
|
|
|
+ private UserEfficientVideoMapMapper userEfficientVideoMapMapper;
|
|
|
+ @Autowired
|
|
|
+ private SysRoleMapper sysRoleMapper;
|
|
|
+ @Autowired
|
|
|
+ private IOptimizerConfigService optimizerConfigService;
|
|
|
+
|
|
|
+ //获取季度有效视频和角色对应关系的定时任务
|
|
|
+ //每天定时任务:角色对应本季度有效视频计算--需要工具类有效视频计算工具类
|
|
|
+ public void efficientVideoTask(int days){
|
|
|
+ //有效视频定义:两周内视频消耗>=5000的视频称为
|
|
|
+ //季度有效视频定义:在本季度成为有效视频的视频成为季度有效视频
|
|
|
+ //每月1号计算上个月最后一天的有效视频,然后可以跑每个季度的计算绩效的定时任务
|
|
|
+ //如果按照时间
|
|
|
+ //计算逻辑 1.查找出来所有的剪辑、编导、拍摄,循环查找出对应当天产生的有效视频---不太好,同一个视频会被查出好多次,舍去
|
|
|
+ //2.查出当天的有效视频,再和表中有效视频做对比,然后插入;采用
|
|
|
+ //如何查询出前一天的有效视频。
|
|
|
+ //方案:从两周前开始到昨天的所有上传的视频都扫描一遍,如果成为了有效视频而且没有再数据库中,则插入数据库当中
|
|
|
+
|
|
|
+ //addDay(Date date, int day) 返回之前几天的时间
|
|
|
+ //需要增加 1.获取传入参数获取年份的接口 2.传入参数获取月份的参数 3.根据月份计算出季度的时间方法
|
|
|
+ //1和2用Dateutis.formatAddDate获取calendar即可,不行用getYear也可以 3.getQuarter(Date date)获取根据月份计算时间的方法
|
|
|
+
|
|
|
+ //传入时间,获取对应的年份
|
|
|
+ try {
|
|
|
+ Date thisDate = DateUtils.addDay(new Date(), days);
|
|
|
+ String thisDateStr = DateUtils.formatDate(thisDate,"yyyy-MM-dd");
|
|
|
+ String thisYear = DateUtils.getYear( "yyyy-MM-dd", thisDateStr);
|
|
|
+ //String thisMonth = DateUtils.getMonth("yyyy-MM-dd", thisYear);
|
|
|
+ int thisQuarter = DateUtils.getQuarter(thisDate);
|
|
|
+
|
|
|
+ //以传入的时间为节点,向前获取14天(包括当天)的时间
|
|
|
+ String startDate = DateUtils.formatDate(DateUtils.addDay(thisDate, 13),"yyyy-MM-dd");
|
|
|
+ //获取时间段内所有<快手>的有效视频
|
|
|
+ List<EffiVideoDTO> EffiVideoDTOList = userEfficientVideoMapMapper.getUserVideoMap(thisDateStr, startDate);
|
|
|
+
|
|
|
+ for(EffiVideoDTO effiVideoDTO : EffiVideoDTOList){
|
|
|
+ //判断此视频是否已经在关系表中存在,如果已经存在则说明此视频已经存在,跳过即可
|
|
|
+ //有效视频的逻辑是无论是快手还是头条
|
|
|
+ int signatureCount = userEfficientVideoMapMapper.getEffiVideoCountBySignature(effiVideoDTO.getSignature());
|
|
|
+ if(signatureCount != 0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ UserEfficientVideoMap shot = new UserEfficientVideoMap();
|
|
|
+ UserEfficientVideoMap plane = new UserEfficientVideoMap();
|
|
|
+ UserEfficientVideoMap plan = new UserEfficientVideoMap();
|
|
|
+ UserEfficientVideoMap clip = new UserEfficientVideoMap();
|
|
|
+
|
|
|
+ //拍摄
|
|
|
+ shot.setUserId(effiVideoDTO.getShotId());
|
|
|
+ shot.setEfficientVideoSignature(effiVideoDTO.getSignature());
|
|
|
+ shot.setQuarter(thisQuarter);
|
|
|
+ shot.setAppType(1); //1快手 2头条
|
|
|
+ shot.setYear(Integer.parseInt(thisYear));
|
|
|
+ shot.setRoleId("7bff9afed625aeeabca6bffe3c189183");
|
|
|
+ userEfficientVideoMapMapper.insert(shot);
|
|
|
+
|
|
|
+ //平面
|
|
|
+ plane.setUserId(effiVideoDTO.getPlaneId());
|
|
|
+ plane.setEfficientVideoSignature(effiVideoDTO.getSignature());
|
|
|
+ plane.setQuarter(thisQuarter);
|
|
|
+ plane.setAppType(1); //1快手 2头条
|
|
|
+ plane.setYear(Integer.parseInt(thisYear));
|
|
|
+ plane.setRoleId("8dc30cb9810bde89bdc3fa8a85b830b0");
|
|
|
+ userEfficientVideoMapMapper.insert(plane);
|
|
|
+
|
|
|
+ //策划
|
|
|
+ plan.setUserId(effiVideoDTO.getPlanId());
|
|
|
+ plan.setEfficientVideoSignature(effiVideoDTO.getSignature());
|
|
|
+ plan.setQuarter(thisQuarter);
|
|
|
+ plan.setAppType(1); //1快手 2头条
|
|
|
+ plan.setYear(Integer.parseInt(thisYear));
|
|
|
+ plan.setRoleId("0214283aa16f943efbb149ea4bb18f18");
|
|
|
+ userEfficientVideoMapMapper.insert(plan);
|
|
|
+
|
|
|
+ //剪辑
|
|
|
+ clip.setUserId(effiVideoDTO.getClipId());
|
|
|
+ clip.setEfficientVideoSignature(effiVideoDTO.getSignature());
|
|
|
+ clip.setQuarter(thisQuarter);
|
|
|
+ clip.setAppType(1); //1快手 2头条
|
|
|
+ clip.setYear(Integer.parseInt(thisYear));
|
|
|
+ clip.setRoleId("f38d8d70cf7ec50d5357a749e4dbf8ee");
|
|
|
+ userEfficientVideoMapMapper.insert(clip);
|
|
|
+ }
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 分平台:快手、抖音
|
|
|
+ *
|
|
|
+ * 编导、剪辑、拍摄:
|
|
|
+ * 1.根据角色(编导、剪辑、拍摄)查询出相对应角色所有的人
|
|
|
+ * 2.根据查询出来的所属角色的人,从定时任务跑出来的视频人对应的表中查询出来每个人对应的季度视频总数和季度有效视频数量
|
|
|
+ * 3.循环所有人并计算出相对应的视频有效率,并排序
|
|
|
+ * 4.根据有效率和对应的绩效梯度进行绩效计算,前百分之30,给予千分之5的提点绩效;中间百分之50%,给予千分之3的提点绩效
|
|
|
+ * 即角色人的本季度绩效=本季度视频总消耗*提点*角色提成点(需要考虑到小数点问题和绩效节点上下有效率相同的问题)
|
|
|
+ *
|
|
|
+ *平面设计:
|
|
|
+ * 1.根据角色查询出相对应的平面设计所有的人
|
|
|
+ * 2.循环所有人并计算出相对应的素材总消耗
|
|
|
+ * 3.判断媒体总任务是否完成,如果完成则按照千分之5来进行提点绩效;如果未完成,则给予千分之3的提点绩效
|
|
|
+ *
|
|
|
+ * 设计师leader:
|
|
|
+ * 1.如果媒体总任务未达成,则没有绩效;如果已达成,则按照千分之5给予提点绩效
|
|
|
+ * 2.查询出所有设计部门的代码,并找出每部门的leader,和部门下所有人员
|
|
|
+ * 3.根据编导(或剪辑、拍摄)算出素材的总消耗
|
|
|
+ * 4.根据部门当中是否有平面设计师来判断提成绩效。有平面,按照15%计算;没有按照20%计算
|
|
|
+ */
|
|
|
+ //季度定时任务(在有效视频绑定人定时任务之后跑):设计师绩效计算-----包括快手和头条的计算逻辑
|
|
|
+ public void designerPerformanceTask(){
|
|
|
+ kuaishouDesigner();//快手
|
|
|
+ toutiaoDesigner();//头条
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ //快手设计师逻辑
|
|
|
+ private void kuaishouDesigner(){
|
|
|
+ Date thisDate = DateUtils.addDay(new Date(), -1);
|
|
|
+ String thisDateStr = DateUtils.formatDate(thisDate,"yyyy-MM-dd");
|
|
|
+ String thisYear = null;
|
|
|
+ try {
|
|
|
+ thisYear = DateUtils.getYear( "yyyy-MM-dd", thisDateStr);
|
|
|
+ } catch (ParseException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
+ //String thisMonth = DateUtils.getMonth("yyyy-MM-dd", thisYear);
|
|
|
+ int thisQuarter = DateUtils.getQuarter(thisDate);
|
|
|
+ String startTime = null; //季度开始时间
|
|
|
+ String endTime = null; //季度结束时间
|
|
|
+ if(thisQuarter == 1){
|
|
|
+ startTime = thisYear + "-01-01";
|
|
|
+ endTime = thisYear + "-03-31";
|
|
|
+ }else if(thisQuarter == 2){
|
|
|
+ startTime = thisYear + "-04-01";
|
|
|
+ endTime = thisYear + "-06-30";
|
|
|
+ }else if(thisQuarter == 3){
|
|
|
+ startTime = thisYear + "-07-01";
|
|
|
+ endTime = thisYear + "-09-30";
|
|
|
+ }else if(thisQuarter == 4){
|
|
|
+ startTime = thisYear + "-10-01";
|
|
|
+ endTime = thisYear + "-12-31";
|
|
|
+ }
|
|
|
+
|
|
|
+ //1.根据角色(编导、剪辑、拍摄)查询出相对应角色所有的人
|
|
|
+ List<UserDto> planList = sysRoleMapper.getUserByRoleCode("plan"); //编导
|
|
|
+ List<UserDto> shotList = sysRoleMapper.getUserByRoleCode("shot"); //拍摄
|
|
|
+ List<UserDto> clipList = sysRoleMapper.getUserByRoleCode("clip"); //剪辑
|
|
|
+ List<UserDto> planeList = sysRoleMapper.getUserByRoleCode("plane"); //平面
|
|
|
+
|
|
|
+ //2.1 编导 start
|
|
|
+ //循环编导列表计算视频有效率并排序
|
|
|
+ for(UserDto userDto:planList){
|
|
|
+ //有效视频数量
|
|
|
+ int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(thisYear),thisQuarter,userDto.getUserId());
|
|
|
+ //总视频数量
|
|
|
+ int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(startTime, endTime, userDto.getUserId());
|
|
|
+ //视频有效率
|
|
|
+ BigDecimal effiRate = new BigDecimal( String.valueOf(effiVideoCount) ).divide( new BigDecimal(String.valueOf(videoCount)) );
|
|
|
+ userDto.setEffiRate(effiRate);
|
|
|
+ }
|
|
|
+ Collections.sort(planList, new EffiRateComparator());
|
|
|
+
|
|
|
+ //获取编导人数并按照提点比例计算每个梯度的人数
|
|
|
+ int planLength = planList.size();
|
|
|
+ //获取前30%和中间50%的人数(视频有效率四舍五入)
|
|
|
+ int top30 = new BigDecimal(String.valueOf(planLength)).multiply(new BigDecimal("0.3")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+ int middle50 = new BigDecimal(String.valueOf(planLength)).multiply(new BigDecimal("0.5")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+
|
|
|
+ //循环前30%有绩效的人数并计算其绩效,并入库
|
|
|
+ for(int i=0; i<=top30 - 1; i++){
|
|
|
+ //总消耗--获取这个人所在项目的总消耗
|
|
|
+ BigDecimal totalCost = userEfficientVideoMapMapper.getProjectTotalCostByUserId(planList.get(i).getUserId(), startTime, endTime);
|
|
|
+ //总绩效=总消耗*提点比例(5‰)*提成比例(编导40%)
|
|
|
+ BigDecimal totalPerformance = totalCost.multiply(new BigDecimal("0.005")).multiply(new BigDecimal("0.4"));
|
|
|
+
|
|
|
+ Performance performance = new Performance();
|
|
|
+ performance.setAppType(1); //1快手 2抖音
|
|
|
+ performance.setRoleId(planList.get(i).getRoleId());
|
|
|
+ performance.setQuarter(thisQuarter);
|
|
|
+ performance.setYear(Integer.parseInt(thisYear));
|
|
|
+ performance.setCommissionRate(new BigDecimal("0.005"));
|
|
|
+ performance.setTotalCost(totalCost);
|
|
|
+ performance.setTotalPerformance(totalPerformance);
|
|
|
+ performance.setStartTime(startTime);
|
|
|
+ performance.setEndTime(endTime);
|
|
|
+ performance.setVideoEfficiency(planList.get(i).getEffiRate().setScale(4,BigDecimal.ROUND_HALF_UP));
|
|
|
+ performance.setUserId(planList.get(i).getUserId());
|
|
|
+ performanceMapper.insert(performance);
|
|
|
+ }
|
|
|
+
|
|
|
+ //去掉list中前30的数据
|
|
|
+ planList.subList(0,top30-1).clear();
|
|
|
+
|
|
|
+ //循环中间50%有绩效的人,计算绩效并入库
|
|
|
+ for(int i=0; i<=middle50 - 1; i++){
|
|
|
+ //总消耗--获取这个人所在项目的总消耗
|
|
|
+ BigDecimal totalCost = userEfficientVideoMapMapper.getProjectTotalCostByUserId(planList.get(i).getUserId(), startTime, endTime);
|
|
|
+ //总绩效=总消耗*提点比例(3‰)*提成比例(编导40%)
|
|
|
+ BigDecimal totalPerformance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.4"));
|
|
|
+
|
|
|
+ Performance performance = new Performance();
|
|
|
+ performance.setAppType(1); //1快手 2抖音
|
|
|
+ performance.setRoleId(planList.get(i).getRoleId());
|
|
|
+ performance.setQuarter(thisQuarter);
|
|
|
+ performance.setYear(Integer.parseInt(thisYear));
|
|
|
+ performance.setCommissionRate(new BigDecimal("0.003"));
|
|
|
+ performance.setTotalCost(totalCost);
|
|
|
+ performance.setTotalPerformance(totalPerformance);
|
|
|
+ performance.setStartTime(startTime);
|
|
|
+ performance.setEndTime(endTime);
|
|
|
+ performance.setVideoEfficiency(planList.get(i).getEffiRate().setScale(4,BigDecimal.ROUND_HALF_UP));
|
|
|
+ performance.setUserId(planList.get(i).getUserId());
|
|
|
+ performanceMapper.insert(performance);
|
|
|
+ }
|
|
|
+ /////////////////////////////////////////编导end
|
|
|
+
|
|
|
+ //2.2 拍摄 start
|
|
|
+ for(UserDto userDto:shotList){
|
|
|
+ //有效视频数量
|
|
|
+ int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(thisYear),thisQuarter,userDto.getUserId());
|
|
|
+ //总视频数量
|
|
|
+ int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(startTime, endTime, userDto.getUserId());
|
|
|
+ //视频有效率
|
|
|
+ BigDecimal effiRate = new BigDecimal( String.valueOf(effiVideoCount) ).divide( new BigDecimal(String.valueOf(videoCount)) );
|
|
|
+ userDto.setEffiRate(effiRate);
|
|
|
+ }
|
|
|
+ Collections.sort(shotList, new EffiRateComparator());
|
|
|
+
|
|
|
+ //获取编导人数并按照提点比例计算每个梯度的人数
|
|
|
+ int shotLength = shotList.size();
|
|
|
+ //获取前30%和中间50%的人数(视频有效率四舍五入)
|
|
|
+ int shotTop30 = new BigDecimal(String.valueOf(shotLength)).multiply(new BigDecimal("0.3")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+ int shotMiddle50 = new BigDecimal(String.valueOf(shotLength)).multiply(new BigDecimal("0.5")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+
|
|
|
+ //循环前30%有绩效的人数并计算其绩效,并入库
|
|
|
+ for(int i=0; i<=shotTop30 - 1; i++){
|
|
|
+ //总消耗--获取这个人所在项目的总消耗
|
|
|
+ BigDecimal totalCost = userEfficientVideoMapMapper.getProjectTotalCostByUserId(shotList.get(i).getUserId(), startTime, endTime);
|
|
|
+ //总绩效=总消耗*提点比例(5‰)*提成比例(拍摄10%)
|
|
|
+ BigDecimal totalPerformance = totalCost.multiply(new BigDecimal("0.005")).multiply(new BigDecimal("0.1"));
|
|
|
+
|
|
|
+ Performance performance = new Performance();
|
|
|
+ performance.setAppType(1); //1快手 2抖音
|
|
|
+ performance.setRoleId(shotList.get(i).getRoleId());
|
|
|
+ performance.setQuarter(thisQuarter);
|
|
|
+ performance.setYear(Integer.parseInt(thisYear));
|
|
|
+ performance.setCommissionRate(new BigDecimal("0.005"));
|
|
|
+ performance.setTotalCost(totalCost);
|
|
|
+ performance.setTotalPerformance(totalPerformance);
|
|
|
+ performance.setStartTime(startTime);
|
|
|
+ performance.setEndTime(endTime);
|
|
|
+ performance.setVideoEfficiency(shotList.get(i).getEffiRate().setScale(4,BigDecimal.ROUND_HALF_UP));
|
|
|
+ performance.setUserId(shotList.get(i).getUserId());
|
|
|
+ performanceMapper.insert(performance);
|
|
|
+ }
|
|
|
+
|
|
|
+ //去掉list中前30的数据
|
|
|
+ shotList.subList(0,shotTop30-1).clear();
|
|
|
+
|
|
|
+ //循环中间50%有绩效的人,计算绩效并入库
|
|
|
+ for(int i=0; i<=shotMiddle50 - 1; i++){
|
|
|
+ //总消耗--获取这个人所在项目的总消耗
|
|
|
+ BigDecimal totalCost = userEfficientVideoMapMapper.getProjectTotalCostByUserId(shotList.get(i).getUserId(), startTime, endTime);
|
|
|
+ //总绩效=总消耗*提点比例(3‰)*提成比例(拍摄10%)
|
|
|
+ BigDecimal totalPerformance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.1"));
|
|
|
+
|
|
|
+ Performance performance = new Performance();
|
|
|
+ performance.setAppType(1); //1快手 2抖音
|
|
|
+ performance.setRoleId(shotList.get(i).getRoleId());
|
|
|
+ performance.setQuarter(thisQuarter);
|
|
|
+ performance.setYear(Integer.parseInt(thisYear));
|
|
|
+ performance.setCommissionRate(new BigDecimal("0.003"));
|
|
|
+ performance.setTotalCost(totalCost);
|
|
|
+ performance.setTotalPerformance(totalPerformance);
|
|
|
+ performance.setStartTime(startTime);
|
|
|
+ performance.setEndTime(endTime);
|
|
|
+ performance.setVideoEfficiency(shotList.get(i).getEffiRate().setScale(4,BigDecimal.ROUND_HALF_UP));
|
|
|
+ performance.setUserId(shotList.get(i).getUserId());
|
|
|
+ performanceMapper.insert(performance);
|
|
|
+ }
|
|
|
+ ///////////////////////////////////////////////////拍摄 end
|
|
|
+
|
|
|
+ //剪辑 start
|
|
|
+ for(UserDto userDto:clipList){
|
|
|
+ //有效视频数量
|
|
|
+ int effiVideoCount = userEfficientVideoMapMapper.getEffiVideoCountByUserId(Integer.parseInt(thisYear),thisQuarter,userDto.getUserId());
|
|
|
+ //总视频数量
|
|
|
+ int videoCount = userEfficientVideoMapMapper.getQuarterMaterialCountByUserId(startTime, endTime, userDto.getUserId());
|
|
|
+ //视频有效率
|
|
|
+ BigDecimal effiRate = new BigDecimal( String.valueOf(effiVideoCount) ).divide( new BigDecimal(String.valueOf(videoCount)) );
|
|
|
+ userDto.setEffiRate(effiRate);
|
|
|
+ }
|
|
|
+ Collections.sort(clipList, new EffiRateComparator());
|
|
|
+
|
|
|
+ //获取剪辑人数并按照提点比例计算每个梯度的人数
|
|
|
+ int clipLength = clipList.size();
|
|
|
+ //获取前30%和中间50%的人数(视频有效率四舍五入)
|
|
|
+ int clipTop30 = new BigDecimal(String.valueOf(clipLength)).multiply(new BigDecimal("0.3")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+ int clipMiddle50 = new BigDecimal(String.valueOf(clipLength)).multiply(new BigDecimal("0.5")).setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
|
|
|
+
|
|
|
+ //循环前30%有绩效的人数并计算其绩效,并入库
|
|
|
+ for(int i=0; i<=clipTop30 - 1; i++){
|
|
|
+ //总消耗--获取这个人所在项目的总消耗
|
|
|
+ BigDecimal totalCost = userEfficientVideoMapMapper.getProjectTotalCostByUserId(clipList.get(i).getUserId(), startTime, endTime);
|
|
|
+ //总绩效=总消耗*提点比例(5‰)*提成比例(剪辑30%)
|
|
|
+ BigDecimal totalPerformance = totalCost.multiply(new BigDecimal("0.005")).multiply(new BigDecimal("0.3"));
|
|
|
+
|
|
|
+ Performance performance = new Performance();
|
|
|
+ performance.setAppType(1); //1快手 2抖音
|
|
|
+ performance.setRoleId(clipList.get(i).getRoleId());
|
|
|
+ performance.setQuarter(thisQuarter);
|
|
|
+ performance.setYear(Integer.parseInt(thisYear));
|
|
|
+ performance.setCommissionRate(new BigDecimal("0.005"));
|
|
|
+ performance.setTotalCost(totalCost);
|
|
|
+ performance.setTotalPerformance(totalPerformance);
|
|
|
+ performance.setStartTime(startTime);
|
|
|
+ performance.setEndTime(endTime);
|
|
|
+ performance.setVideoEfficiency(clipList.get(i).getEffiRate().setScale(4,BigDecimal.ROUND_HALF_UP));
|
|
|
+ performance.setUserId(clipList.get(i).getUserId());
|
|
|
+ performanceMapper.insert(performance);
|
|
|
+ }
|
|
|
+
|
|
|
+ //去掉list中前30的数据
|
|
|
+ clipList.subList(0,clipTop30-1).clear();
|
|
|
+
|
|
|
+ //循环中间50%有绩效的人,计算绩效并入库
|
|
|
+ for(int i=0; i<=clipMiddle50 - 1; i++){
|
|
|
+ //总消耗--获取这个人所在项目的总消耗
|
|
|
+ BigDecimal totalCost = userEfficientVideoMapMapper.getProjectTotalCostByUserId(clipList.get(i).getUserId(), startTime, endTime);
|
|
|
+ //总绩效=总消耗*提点比例(3‰)*提成比例(剪辑30%)
|
|
|
+ BigDecimal totalPerformance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.3"));
|
|
|
+
|
|
|
+ Performance performance = new Performance();
|
|
|
+ performance.setAppType(1); //1快手 2抖音
|
|
|
+ performance.setRoleId(clipList.get(i).getRoleId());
|
|
|
+ performance.setQuarter(thisQuarter);
|
|
|
+ performance.setYear(Integer.parseInt(thisYear));
|
|
|
+ performance.setCommissionRate(new BigDecimal("0.003"));
|
|
|
+ performance.setTotalCost(totalCost);
|
|
|
+ performance.setTotalPerformance(totalPerformance);
|
|
|
+ performance.setStartTime(startTime);
|
|
|
+ performance.setEndTime(endTime);
|
|
|
+ performance.setVideoEfficiency(clipList.get(i).getEffiRate().setScale(4,BigDecimal.ROUND_HALF_UP));
|
|
|
+ performance.setUserId(clipList.get(i).getUserId());
|
|
|
+ performanceMapper.insert(performance);
|
|
|
+ }
|
|
|
+ //////////////////////////////////////////////////////剪辑 end
|
|
|
+
|
|
|
+ //平面设计的总消耗 start
|
|
|
+ // *平面设计:
|
|
|
+ // * 1.根据媒体的任务
|
|
|
+ // * 1.根据角色查询出相对应的平面设计所有的人
|
|
|
+ // * 2.循环所有人并计算出相对应的素材总消耗
|
|
|
+ // * 3.判断媒体总任务是否完成,如果完成则按照千分之5来进行提点绩效;如果未完成,则给予千分之3的提点绩效
|
|
|
+ planeList = sysRoleMapper.getUserByRoleCode("plane");
|
|
|
+
|
|
|
+ //判断媒体任务是否完成
|
|
|
+ String raiseRate = null;
|
|
|
+ if(mediaMission()){
|
|
|
+ raiseRate = "0.005";
|
|
|
+ }else{
|
|
|
+ raiseRate = "0.003";
|
|
|
+ }
|
|
|
+
|
|
|
+ for(UserDto userDto:planeList){
|
|
|
+ //总消耗--获取这个人所在项目的总消耗2
|
|
|
+ BigDecimal totalCost = userEfficientVideoMapMapper.getTotalCostByPlaneId(userDto.getUserId(), startTime, endTime);
|
|
|
+ //总绩效=总消耗*提点比例*提成比例(平面5%)
|
|
|
+ BigDecimal totalPerformance = totalCost.multiply(new BigDecimal(raiseRate)).multiply(new BigDecimal("0.05"));
|
|
|
+
|
|
|
+ Performance performance = new Performance();
|
|
|
+ performance.setAppType(1); //1快手 2抖音
|
|
|
+ performance.setRoleId(userDto.getRoleId());
|
|
|
+ performance.setQuarter(thisQuarter);
|
|
|
+ performance.setYear(Integer.parseInt(thisYear));
|
|
|
+ performance.setCommissionRate(null);
|
|
|
+ performance.setTotalCost(totalCost);
|
|
|
+ performance.setTotalPerformance(totalPerformance);
|
|
|
+ performance.setStartTime(startTime);
|
|
|
+ performance.setEndTime(endTime);
|
|
|
+ performance.setVideoEfficiency(userDto.getEffiRate().setScale(4,BigDecimal.ROUND_HALF_UP));
|
|
|
+ performance.setUserId(userDto.getUserId());
|
|
|
+ performanceMapper.insert(performance);
|
|
|
+ }
|
|
|
+ ///////////////////////////////////////////////////////////////////平面end
|
|
|
+
|
|
|
+ //设计师leader start
|
|
|
+ //* 1.如果媒体总任务未达成,则没有绩效;如果已达成,则按照千分之5给予提点绩效
|
|
|
+ //* 2.查询出所有设计部门的代码,并找出每部门的leader,和部门下所有人员
|
|
|
+ //* 3.根据编导(或剪辑、拍摄)算出素材的总消耗
|
|
|
+ //* 4.根据部门当中是否有平面设计师来判断提成绩效。有平面,按照15%计算;没有按照20%计算
|
|
|
+
|
|
|
+ //判断媒体任务是否达成,如果未达成,则没有绩效
|
|
|
+ if(mediaMission()){
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ }else{
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //设计师leader end
|
|
|
+ }
|
|
|
+
|
|
|
+ //头条设计师逻辑
|
|
|
+ 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 year = DateUtils.getYear(getDate) + "";
|
|
|
+ String quarter = DateUtils.getQuarter(getDate) + "";
|
|
|
+ return performanceMapper.getOptimizerTotalCost(startDate, endDate, year, quarter);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ //TODO 平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效
|
|
|
+ public void getPerformanceInfo(){
|
|
|
+ //获取平台的总有效数量
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+}
|