hcst_sunzhen 5 éve
szülő
commit
d81251368c

+ 25 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/EffiRateComparator.java

@@ -0,0 +1,25 @@
+package org.jeecg.modules.system.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Comparator;
+import java.util.Date;
+
+public class EffiRateComparator implements Comparator<Object> {
+
+
+    @Override
+    public int compare(Object o1, Object o2) {
+        UserDto p1 = (UserDto) o1; // 强制转换
+        UserDto p2 = (UserDto) o2;
+        return (p1.getEffiRate()).compareTo(p2.getEffiRate());
+    }
+}

+ 36 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/entity/UserDto.java

@@ -0,0 +1,36 @@
+package org.jeecg.modules.system.entity;
+
+import lombok.Data;
+
+import java.awt.print.Book;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Comparator;
+
+@Data
+public class UserDto implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    private String userId;
+
+    private String username;
+
+    private String roleId;
+
+    private String roleName;
+
+    private BigDecimal effiRate;
+
+    //public int compareTo(Object obj) {// Comparable接口中的方法
+    //    UserDto b = (UserDto) obj;
+    //   return this.effiRate.compareTo(b.getEffiRate()); //比较大小,用于默认排序
+    //}
+
+    //@Override
+    //public int compare(Object o1, Object o2) {
+    //    UserDto p1 = (UserDto) o1; // 强制转换
+    //    UserDto p2 = (UserDto) o2;
+    //    return (p1.getEffiRate()).compareTo(p2.getEffiRate());
+    //}
+}

+ 10 - 1
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/SysRoleMapper.java

@@ -1,8 +1,13 @@
 package org.jeecg.modules.system.mapper;
 
-import org.jeecg.modules.system.entity.SysRole;
+
+import io.lettuce.core.dynamic.annotation.Param;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.system.entity.SysRole;
+import org.jeecg.modules.system.entity.UserDto;
+
+import java.util.List;
 
 /**
  * <p>
@@ -13,5 +18,9 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @since 2018-12-19
  */
 public interface SysRoleMapper extends BaseMapper<SysRole> {
+    //根据roleCode获取相对应的用户信息
+    List<UserDto> getUserByRoleCode(@Param("roleCode")String roleCode);
+
+    String getRoleIdByRoleCode(@Param("roleCode")String roleCode);
 
 }

+ 29 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/mapper/xml/SysRoleMapper.xml

@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.system.mapper.SysRoleMapper">
+
+	<!-- 根据rolecode获取相对应角色所有的人 -->
+	<select id="getUserByRoleCode" resultType="org.jeecg.modules.system.entity.UserDto">
+			select
+			a.id as userId,
+			b.realname,
+			c.id as roleIdd,
+			c.role_name
+		from
+		sys_user a
+		left join on sys_user_role b on a.id = b.user_id
+		left join sys_role c int not null on b.role_id = c.id
+        where
+        c.role_code = #{roleCode}
+	</select>
+
+	<!-- 根据roleCode获取roleId -->
+	<select id="getRoleIdByRoleCode" resultType="java.lang.String">
+		select
+		id
+		from sys_role
+		where role_code = #{roleCode}
+	</select>
+
+
+</mapper>

+ 15 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IPerformanceService.java

@@ -0,0 +1,15 @@
+package org.jeecg.modules.system.service;
+
+import cn.com.ctop.performanceappraisal.entity.Performance;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * 设计师季度绩效表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-10
+ */
+public interface IPerformanceService extends IService<Performance> {
+    void efficientVideoTask(int days);
+}

+ 536 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/impl/PerformanceServiceImpl.java

@@ -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(){
+        //获取平台的总有效数量
+    }
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+}

+ 22 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/EffiVideoDTO.java

@@ -0,0 +1,22 @@
+package cn.com.ctop.userefficientvideomap.entity;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+
+@Data
+public class EffiVideoDTO {
+	private String signature;
+	private BigDecimal charge;
+	private String clipId;
+	private String clipName;
+	private String shotId;
+	private String shotName;
+	private String planId;
+	private String planName;
+	private String planeId;
+	private String planeName;
+
+
+}

+ 12 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/ProjectDTO.java

@@ -0,0 +1,12 @@
+package cn.com.ctop.userefficientvideomap.entity;
+
+import lombok.Data;
+
+import java.math.BigDecimal;
+
+
+@Data
+public class ProjectDTO {
+	private Long projectId;
+	private BigDecimal projectName;
+}

+ 79 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/SysRole.java

@@ -0,0 +1,79 @@
+package cn.com.ctop.userefficientvideomap.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 角色表
+ * </p>
+ *
+ * @Author scott
+ * @since 2018-12-19
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SysRole implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    private String id;
+
+    /**
+     * 角色名称
+     */
+    @Excel(name="角色名",width=15)
+    private String roleName;
+
+    /**
+     * 角色编码
+     */
+    @Excel(name="角色编码",width=15)
+    private String roleCode;
+
+    /**
+          * 描述
+     */
+    @Excel(name="描述",width=60)
+    private String description;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    private Date updateTime;
+
+
+}

+ 142 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/SysUser.java

@@ -0,0 +1,142 @@
+package cn.com.ctop.userefficientvideomap.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableField;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableLogic;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * <p>
+ * 用户表
+ * </p>
+ *
+ * @Author scott
+ * @since 2018-12-20
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class SysUser implements Serializable {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * id
+     */
+    @TableId(type = IdType.UUID)
+    private String id;
+
+    /**
+     * 登录账号
+     */
+    @Excel(name = "登录账号", width = 15)
+    private String username;
+
+    /**
+     * 真实姓名
+     */
+    @Excel(name = "真实姓名", width = 15)
+    private String realname;
+
+    /**
+     * 密码
+     */
+    private String password;
+
+    /**
+     * md5密码盐
+     */
+    private String salt;
+
+    /**
+     * 头像
+     */
+    @Excel(name = "头像", width = 15)
+    private String avatar;
+
+    /**
+     * 生日
+     */
+    @Excel(name = "生日", width = 15, format = "yyyy-MM-dd")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private Date birthday;
+
+    /**
+     * 性别(1:男 2:女)
+     */
+    @Excel(name = "性别", width = 15, dicCode = "sex")
+    @Dict(dicCode = "sex")
+    private Integer sex;
+
+    /**
+     * 电子邮件
+     */
+    @Excel(name = "电子邮件", width = 15)
+    private String email;
+
+    /**
+     * 电话
+     */
+    @Excel(name = "电话", width = 15)
+    private String phone;
+
+    /**
+     * 部门code
+     */
+    private String orgCode;
+
+    /**
+     * 状态(1:正常  2:冻结 )
+     */
+    @Excel(name = "状态", width = 15, dicCode = "user_status")
+    @Dict(dicCode = "user_status")
+    private Integer status;
+
+    /**
+     * 删除状态(0,正常,1已删除)
+     */
+    @Excel(name = "删除状态", width = 15, dicCode = "del_flag")
+    @TableLogic
+    private String delFlag;
+
+    /**
+     * 创建人
+     */
+    private String createBy;
+
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 更新人
+     */
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    private Date updateTime;
+    /**
+     * 同步工作流引擎1同步0不同步
+     */
+    private String activitiSync;
+
+
+    @TableField(exist = false)
+    private String departId;
+
+
+}

+ 24 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/job/EffiVideoJob.java

@@ -0,0 +1,24 @@
+package cn.com.ctop.userefficientvideomap.job;
+
+import cn.com.ctop.performanceappraisal.service.IPerformanceService;
+import org.quartz.Job;
+import org.quartz.JobExecutionContext;
+import org.quartz.JobExecutionException;
+import org.springframework.beans.factory.annotation.Autowired;
+
+public class EffiVideoJob implements Job {
+    @Autowired
+    private IPerformanceService performanceService;
+
+    /**
+     * 获取有效视频以及对应人的定时任务
+     *
+     * @param jobExecutionContext
+     * @throws JobExecutionException
+     */
+    @Override
+    public void execute(JobExecutionContext jobExecutionContext) {
+        performanceService.efficientVideoTask(2);
+        performanceService.efficientVideoTask(1);
+    }
+}

+ 31 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -1,10 +1,14 @@
 package cn.com.ctop.userefficientvideomap.mapper;
 
+import java.math.BigDecimal;
 import java.util.List;
 
+import cn.com.ctop.userefficientvideomap.entity.EffiVideoDTO;
+import cn.com.ctop.userefficientvideomap.entity.ProjectDTO;
 import org.apache.ibatis.annotations.Param;
 import cn.com.ctop.userefficientvideomap.entity.UserEfficientVideoMap;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.springframework.stereotype.Component;
 
 /**
  * 有效视频与角色对应表
@@ -12,6 +16,33 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * @date:   2019-12-16
  * @cersion: V1.0
  */
+@Component
 public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVideoMap> {
 
+    List<EffiVideoDTO> getUserVideoMap(@Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    int getEffiVideoCountBySignature(@Param("signature")String signature);
+
+    int getEffiVideoCountByUserId(@Param("year")int year, @Param("quarter")int quarter, @Param("userId")String userId);
+
+    int getQuarterMaterialCountByUserId(@Param("startTime")String startTime, @Param("endTime")String endTime, @Param("userId")String userId);
+
+    BigDecimal getTotalCostByClipId(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    BigDecimal getTotalCostByShotId(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    BigDecimal getTotalCostByPlanId(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    BigDecimal getTotalCostByPlaneId(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    BigDecimal getProjectTotalCostByUserId(@Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    List<ProjectDTO> getProjectsByUserId(@Param("userId")String userId);
+
+    int getPlaneCountByProjectId(@Param("projectId")Long projectId);
+
+    int getPlaneCountByUserId(@Param("userId")String userId);
+
+
+
 }

+ 174 - 1
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/xml/UserEfficientVideoMapMapper.xml

@@ -2,4 +2,177 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="cn.com.ctop.userefficientvideomap.mapper.UserEfficientVideoMapMapper">
 
-</mapper>
+    <!-- 获取有效视频以及视频和人的对应关系 -->
+    <select id="getUserVideoMap" resultType="cn.com.ctop.userefficientvideomap.entity.EffiVideoDTO">
+            select
+            a.signature,
+            sum(a.charge) as charge,
+            d1.id as clip_id,
+            d1.realname as clip_name,
+            d2.id as shot_id,
+            d2.realname as shot_name,
+            d3.id as plan_id,
+            d3.realname as plan_name,
+            d4.id as plane_id,
+            d4.realname as plane_name
+        from ctop_kuaishou_report_daily_creative_statistic a
+        left join ctop_material_info b on a.signature = b.code
+        left join ctop_material_ascription c on b.id = c.material_id
+        left join sys_user d1 on c.clip_id = d1.id
+        left join sys_user d2 on c.shot_id = d2.id
+        left join sys_user d3 on c.plan_id = d3.id
+        left join sys_user d4 on c.plane_id = d4.id
+        where a.signature is not null and b.id is not null
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+        group by a.signature
+        having sum(a.charge) >= 5000
+    </select>
+
+    <!-- 根据md5获取有效视频是否存在 -->
+    <select id="getEffiVideoCountBySignature" resultType="java.lang.Integer">
+            select
+            count(1)
+        from ctop_user_efficient_video_map
+        where efficient_video_signature = #{signature}
+    </select>
+
+    <!-- 根据年、季度、userId获取有效视频数量 -->
+    <select id="getEffiVideoCountByUserId" resultType="java.lang.Integer">
+        select
+        count(1)
+        from
+        ctop_user_efficient_video_map
+        where year = #{year}
+        and quarter = #{quarter}
+        and user_id = #{userId}
+    </select>
+
+    <!-- 按人获取季度总视频数量 -->
+    <select id="getQuarterMaterialCountByUserId" resultType="java.lang.Integer">
+            select
+            count(1)
+        from ctop_material_info
+        where user_id = #{userId}
+        and create_time &gt;= #{startTime}
+        and create_time &lt;= #{endTime}
+    </select>
+
+    <!-- 根据clip_id获取视频总消耗 -->
+    <select id="getTotalCostByClipId" resultType="java.math.BigDecimal">
+            select
+            sum(a.charge) as charge
+        from ctop_kuaishou_report_daily_creative_statistic a
+        left join ctop_material_info b on a.signature = b.code
+        left join ctop_material_ascription c on b.id = c.material_id
+        left join sys_user d1 on c.clip_id = d1.id
+        left join sys_user d2 on c.shot_id = d2.id
+        left join sys_user d3 on c.plan_id = d3.id
+        left join sys_user d4 on c.plane_id = d4.id
+        where a.signature is not null and b.id is not null
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+        where c.clip_id = #{userId}
+    </select>
+
+    <!-- 根据clip_id获取视频总消耗 -->
+    <select id="getTotalCostByShotId" resultType="java.math.BigDecimal">
+            select
+            sum(a.charge) as charge
+        from ctop_kuaishou_report_daily_creative_statistic a
+        left join ctop_material_info b on a.signature = b.code
+        left join ctop_material_ascription c on b.id = c.material_id
+        left join sys_user d1 on c.clip_id = d1.id
+        left join sys_user d2 on c.shot_id = d2.id
+        left join sys_user d3 on c.plan_id = d3.id
+        left join sys_user d4 on c.plane_id = d4.id
+        where a.signature is not null and b.id is not null
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+        where c.shot_id = #{userId}
+    </select>
+
+    <!-- 根据clip_id获取视频总消耗 -->
+    <select id="getTotalCostByPlanId" resultType="java.math.BigDecimal">
+            select
+            sum(a.charge) as charge
+        from ctop_kuaishou_report_daily_creative_statistic a
+        left join ctop_material_info b on a.signature = b.code
+        left join ctop_material_ascription c on b.id = c.material_id
+        left join sys_user d1 on c.clip_id = d1.id
+        left join sys_user d2 on c.shot_id = d2.id
+        left join sys_user d3 on c.plan_id = d3.id
+        left join sys_user d4 on c.plane_id = d4.id
+        where a.signature is not null and b.id is not null
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+        where c.plan_id = #{userId}
+    </select>
+
+    <!-- 根据plane_id获取视频总消耗 -->
+    <select id="getTotalCostByPlaneId" resultType="java.math.BigDecimal">
+            select
+            sum(a.charge) as charge
+        from ctop_kuaishou_report_daily_creative_statistic a
+        left join ctop_material_info b on a.signature = b.code
+        left join ctop_material_ascription c on b.id = c.material_id
+        left join sys_user d1 on c.clip_id = d1.id
+        left join sys_user d2 on c.shot_id = d2.id
+        left join sys_user d3 on c.plan_id = d3.id
+        left join sys_user d4 on c.plane_id = d4.id
+        where a.signature is not null and b.id is not null
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+        where c.plane_id = #{userId}
+    </select>
+
+    <select id="getProjectTotalCostByUserId" resultType="java.math.BigDecimal">
+        select
+        sum(dailiAccount.charge) as charge
+        from
+        ctop_kuaishou_report_daily_account dailiAccount
+        left join
+        ctop_user_allocation allocation on dailiAccount.account_id = allocation.account_id
+        left join
+        ctop_project_member projectMember on projectMember.project_id = allocation.project_id
+        where
+        projectMember.user_id = #{userId}
+        AND
+        dailiAccount.stat_date &gt;= #{startDate}
+        AND
+        dailiAccount.stat_date &lt; #{endDate}
+    </select>
+
+    <!-- 获取这个人所在的所有项目 -->
+    <select id="getProjectsByUserId" resultType="cn.com.ctop.userefficientvideomap.entity.ProjectDTO ">
+        select
+        project_id as projectId,
+        project_name as projectName
+        from
+        ctop_project_member
+        where
+        user_id = #{userId}
+    </select>
+
+
+    <!-- 根据项目id获取平面设计师的数量 -->
+    <select id="getPlaneCountByProjectId" resultType="java.lang.Integer">
+        select
+        count(1)
+        from ctop_project_member
+        where project_id = #{projectId}
+        and role_code = 'plane';
+    </select>
+
+    <!-- 根据获取的id -->
+    <select id="getPlaneCountByUserId" resultType="java.lang.Integer">
+        select
+        count(1)
+        from sys_user as u
+        left join sys_user_role ur where u.user_id = ur.user_id
+        left join sys_role r on ur.role_id = r.id
+        where u.org_code = (select org_code from sys_user u2 where id = #{userId})
+        and role_code = 'plane'
+    </select>
+
+</mapper>