Prechádzať zdrojové kódy

设计师接口提交

hcst_sunzhen 5 rokov pred
rodič
commit
ab1a8a002f

+ 2 - 3
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/job/EffiVideoJob.java

@@ -1,8 +1,7 @@
 package org.jeecg.modules.ctop.job;
 
 
-
-import org.jeecg.modules.system.service.IPerformanceService;
+import org.jeecg.modules.system.service.IPerformanceService2;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
@@ -10,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 
 public class EffiVideoJob implements Job {
     @Autowired
-    private IPerformanceService performanceService;
+    private IPerformanceService2 performanceService;
 
     /**
      * 获取有效视频以及对应人的定时任务

+ 197 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/controller/PerformanceController2.java

@@ -0,0 +1,197 @@
+package org.jeecg.modules.system.controller;
+
+import cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.modules.system.service.IPerformanceService2;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 设计师季度绩效表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-10
+ */
+@Slf4j
+@Api(tags = "设计师季度绩效表")
+@RestController
+@RequestMapping("/ctop/performance2")
+public class PerformanceController2 {
+    @Autowired
+    private IPerformanceService2 performanceService;
+
+    //平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效
+    @AutoLog(value = "平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效")
+    @ApiOperation(value = "平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效", notes = "平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效")
+    @PostMapping(value = "/getPerformanceInfo")
+    public Map<String,Object> getPerformanceInfo() {
+        Map<String,Object> resultMap = new HashMap<>();
+        try {
+            resultMap = performanceService.getPerformanceInfo();
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return resultMap;
+    }
+
+    //有效率排行榜
+    @AutoLog(value = "有效率排行榜")
+    @ApiOperation(value = "有效率排行榜", notes = "有效率排行榜")
+    @PostMapping(value = "/effiRateRank")
+    public Map<String,Object> effiRateRank(@RequestParam(name = "pageSize")Integer pageSize) {
+        Map<String,Object> resultMap = new HashMap<>();
+        try {
+            resultMap = performanceService.effiRateRank(pageSize);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return resultMap;
+    }
+
+    //素材、素材跑量、封面点击数、封面曝光数、行为数
+    @AutoLog(value = "素材、素材跑量、封面点击数、封面曝光数、行为数")
+    @ApiOperation(value = "素材、素材跑量、封面点击数、封面曝光数、行为数", notes = "素材、素材跑量、封面点击数、封面曝光数、行为数")
+    @PostMapping(value = "/materialInfoList")
+    public Map<String,Object> materialInfoList() {
+        Map<String,Object> resultMap = new HashMap<>();
+        try {
+            List<DesignMaterialInfo> designMaterialInfoList= performanceService.materialInfoList();
+            resultMap.put("designMaterialInfoList",designMaterialInfoList);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return resultMap;
+    }
+
+    //点击+符号 投放账户、投放账户、跑量
+    @AutoLog(value = "点击账户增加_投放账户、投放账户、跑量")
+    @ApiOperation(value = "点击账户增加_投放账户、投放账户、跑量", notes = "点击账户增加_投放账户、投放账户、跑量")
+    @PostMapping(value = "/materialAccountInfo")
+    public Map<String,Object> materialAccountInfo(@RequestParam(name = "materialId")String materialId) {
+        Map<String,Object> resultMap = new HashMap<>();
+        try {
+            List<DesignMaterialInfo> designMaterialInfoList= performanceService.materialAccountInfo(materialId);
+            resultMap.put("designMaterialInfoList",designMaterialInfoList);
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+        }
+        return resultMap;
+    }
+
+   /*
+    @AutoLog(value = "设计师季度绩效表-分页列表查询")
+    @ApiOperation(value = "设计师季度绩效表-分页列表查询", notes = "设计师季度绩效表-分页列表查询")
+    @GetMapping(value = "/list")
+    public Result<IPage<Performance>> queryPageList(Performance performance,
+                                                    @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                    @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                    HttpServletRequest req) {
+        Result<IPage<Performance>> result = new Result<IPage<Performance>>();
+        QueryWrapper<Performance> queryWrapper = QueryGenerator.initQueryWrapper(performance, req.getParameterMap());
+        Page<Performance> page = new Page<Performance>(pageNo, pageSize);
+        IPage<Performance> pageList = performanceService.page(page, queryWrapper);
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+
+    @AutoLog(value = "设计师季度绩效表-添加")
+    @ApiOperation(value = "设计师季度绩效表-添加", notes = "设计师季度绩效表-添加")
+    @PostMapping(value = "/add")
+    public Result<Performance> add(@RequestBody Performance performance) {
+        Result<Performance> result = new Result<Performance>();
+        try {
+            performanceService.save(performance);
+            result.success("添加成功!");
+        } catch (Exception e) {
+            log.error(e.getMessage(), e);
+            result.error500("操作失败");
+        }
+        return result;
+    }
+
+
+    @AutoLog(value = "设计师季度绩效表-编辑")
+    @ApiOperation(value = "设计师季度绩效表-编辑", notes = "设计师季度绩效表-编辑")
+    @PutMapping(value = "/edit")
+    public Result<Performance> edit(@RequestBody Performance performance) {
+        Result<Performance> result = new Result<Performance>();
+        Performance performanceEntity = performanceService.getById(performance.getId());
+        if (performanceEntity == null) {
+            result.error500("未找到对应实体");
+        } else {
+            boolean ok = performanceService.updateById(performance);
+            if (ok) {
+                result.success("修改成功!");
+            }
+        }
+
+        return result;
+    }
+
+
+    @AutoLog(value = "设计师季度绩效表-通过id删除")
+    @ApiOperation(value = "设计师季度绩效表-通过id删除", notes = "设计师季度绩效表-通过id删除")
+    @DeleteMapping(value = "/delete")
+    public Result<?> delete(@RequestParam(name = "id", required = true) String id) {
+        try {
+            performanceService.removeById(id);
+        } catch (Exception e) {
+            log.error("删除失败", e.getMessage());
+            return Result.error("删除失败!");
+        }
+        return Result.ok("删除成功!");
+    }
+
+
+    @AutoLog(value = "设计师季度绩效表-批量删除")
+    @ApiOperation(value = "设计师季度绩效表-批量删除", notes = "设计师季度绩效表-批量删除")
+    @DeleteMapping(value = "/deleteBatch")
+    public Result<Performance> deleteBatch(@RequestParam(name = "ids", required = true) String ids) {
+        Result<Performance> result = new Result<Performance>();
+        if (ids == null || "".equals(ids.trim())) {
+            result.error500("参数不识别!");
+        } else {
+            this.performanceService.removeByIds(Arrays.asList(ids.split(",")));
+            result.success("删除成功!");
+        }
+        return result;
+    }
+
+
+    @AutoLog(value = "设计师季度绩效表-通过id查询")
+    @ApiOperation(value = "设计师季度绩效表-通过id查询", notes = "设计师季度绩效表-通过id查询")
+    @GetMapping(value = "/queryById")
+    public Result<Performance> queryById(@RequestParam(name = "id", required = true) String id) {
+        Result<Performance> result = new Result<Performance>();
+        Performance performance = performanceService.getById(id);
+        if (performance == null) {
+            result.error500("未找到对应实体");
+        } else {
+            result.setResult(performance);
+            result.setSuccess(true);
+        }
+        return result;
+    }
+
+    @GetMapping("/project/list")
+    public Map<String, Object> projectList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize) {
+        return performanceService.getUserOptimizerProjectList(pageNo, pageSize);
+    }
+
+    @GetMapping("/account/list")
+    public Map<String, Object> accountList(@RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                           @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize, Long projectId) {
+        return performanceService.getUserOptimizerAccountList(projectId, pageNo, pageSize);
+    }*/
+}

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

@@ -20,6 +20,6 @@ public class EffiRateComparator implements Comparator<Object> {
     public int compare(Object o1, Object o2) {
         UserDto p1 = (UserDto) o1; // 强制转换
         UserDto p2 = (UserDto) o2;
-        return (p1.getEffiRate()).compareTo(p2.getEffiRate());
+        return (p2.getEffiRate()).compareTo(p1.getEffiRate());
     }
 }

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

@@ -23,4 +23,6 @@ public interface SysRoleMapper extends BaseMapper<SysRole> {
 
     String getRoleIdByRoleCode(@Param("roleCode")String roleCode);
 
+    String getRoleCodeByUserId(@Param("userId")String userId);
+
 }

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

@@ -6,13 +6,13 @@
 	<select id="getUserByRoleCode" resultType="org.jeecg.modules.system.entity.UserDto">
 			select
 			a.id as userId,
-			b.realname,
-			c.id as roleIdd,
+			a.realname,
+			c.id as roleId,
 			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
+		left join sys_user_role b on a.id = b.user_id
+		left join sys_role c on b.role_id = c.id
         where
         c.role_code = #{roleCode}
 	</select>
@@ -25,5 +25,16 @@
 		where role_code = #{roleCode}
 	</select>
 
+	<!-- 根据userId获取角色code -->
+	<select id="getRoleCodeByUserId" resultType="java.lang.String">
+		select
+		c.role_code
+		from
+		sys_user a
+		left join sys_user_role b on a.id = b.user_id
+		left join sys_role c on b.role_id = c.id
+        where
+        a.id = #{userId}
+	</select>
 
 </mapper>

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

@@ -1,15 +0,0 @@
-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);
-}

+ 31 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/system/service/IPerformanceService2.java

@@ -0,0 +1,31 @@
+package org.jeecg.modules.system.service;
+
+import cn.com.ctop.performanceappraisal.entity.Performance;
+import cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+import java.util.List;
+import java.util.Map;
+
+/**
+ * 设计师季度绩效表
+ *
+ * @author jeecg-boot
+ * @version V1.0
+ * @date 2019-12-10
+ */
+public interface IPerformanceService2 extends IService<Performance> {
+    void efficientVideoTask(int days);
+
+    //平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效
+    public Map<String,Object> getPerformanceInfo();
+
+    //有效率排行榜
+    public Map<String,Object> effiRateRank(Integer size);
+
+    //素材、素材跑量、封面点击数、封面曝光数、行为数
+    public List<DesignMaterialInfo> materialInfoList();
+
+    //点击+符号 投放账户、投放账户、跑量
+    public List<DesignMaterialInfo> materialAccountInfo(String materialInfoId);
+}

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

@@ -5,25 +5,25 @@ 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 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.*;
 
 /**
  * 设计师季度绩效表
@@ -33,7 +33,7 @@ import java.util.List;
  * @date 2019-12-10
  */
 @Service
-public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Performance> implements IPerformanceService {
+public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Performance> implements IPerformanceService2 {
 
     @Autowired
     private PerformanceMapper performanceMapper;
@@ -195,7 +195,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);
@@ -261,7 +261,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);
@@ -327,7 +327,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);
@@ -432,20 +432,8 @@ public class PerformanceServiceImpl extends ServiceImpl<PerformanceMapper, Perfo
         //* 3.根据编导(或剪辑、拍摄)算出素材的总消耗
         //* 4.根据部门当中是否有平面设计师来判断提成绩效。有平面,按照15%计算;没有按照20%计算
 
-        //判断媒体任务是否达成,如果未达成,则没有绩效
+        //TODO 判断媒体任务是否达成,如果未达成,则没有绩效
         if(mediaMission()){
-
-
-
-
-
-
-
-
-
-
-
-
         }else{
             return;
         }
@@ -502,35 +490,219 @@ 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");
 
-    //TODO 平台的总有效数量、素材总数、素材有效率、总跑量、当前可获得绩效
-    public void getPerformanceInfo(){
-        //获取平台的总有效数量
-    }
-
+        //获取前一天的时间
+        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());
+
+        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);
 
+        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());
+
+        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();
+
+            int index = 0;
+            for(int i=0; i<= userRoleLength; i++){
+                index = index+1;
+                if(userRoleList.get(i).getUserId() .equals( sysUser.getId() )){
+                    System.out.println("当前登陆人userId:" + sysUser.getId() + "排名:" + index);
+                    break;
+                }
+            }
 
+            //总消耗--获取这个人素材总消耗
+            //总绩效=总消耗*提点比例(5‰)*提成比例(剪辑30%)
+            BigDecimal performance = BigDecimal.ZERO; //绩效
+            BigDecimal totalCost = BigDecimal.ZERO;  //总消耗
+            if(roleCode == "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 == "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()-1).clear();
+            }
 
+            resultMap.put("userRoleList",userRoleList);
+            resultMap.put("performance",performance);
+        }else{
+            resultMap.put("userRoleList",null);
+            resultMap.put("performance",0);
+        }
 
+        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());
 
+        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);
 
+        return materialInfoList;
+    }
 
+    //4
+    //点击+符号 投放账户、投放账户、跑量
+    //{"videoAccount":"aabbcc","servingAccount":"ttyyhh","cost":34234.43}
+    public List<DesignMaterialInfo> materialAccountInfo(String materialInfoId){
+        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);
+        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;
+    }
 
 
 }

+ 32 - 0
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/entity/DesignMaterialInfo.java

@@ -0,0 +1,32 @@
+package cn.com.ctop.userefficientvideomap.entity;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+@Data
+public class DesignMaterialInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	private String id;
+
+	private String videoUrl;
+
+	private Integer pageExposureCount;
+
+	private Integer pageClickCount;
+
+	private Integer materialExposureCount;
+
+	private Integer behaviorCount;
+
+	private BigDecimal totalCost;
+
+	private String accountId;
+
+	private String accountName;
+
+	private String platform;
+
+}

+ 9 - 5
performance-appraisal/src/main/java/cn/com/ctop/userefficientvideomap/mapper/UserEfficientVideoMapMapper.java

@@ -1,15 +1,16 @@
 package cn.com.ctop.userefficientvideomap.mapper;
 
-import java.math.BigDecimal;
-import java.util.List;
-
+import cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo;
 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.apache.ibatis.annotations.Param;
 import org.springframework.stereotype.Component;
 
+import java.math.BigDecimal;
+import java.util.List;
+
 /**
  * 有效视频与角色对应表
  * @author: jeecg-boot
@@ -25,7 +26,7 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     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);
+    int getQuarterMaterialCountByUserId(@Param("roleCode")String roleCode, @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);
 
@@ -43,6 +44,9 @@ public interface UserEfficientVideoMapMapper extends BaseMapper<UserEfficientVid
 
     int getPlaneCountByUserId(@Param("userId")String userId);
 
+    List<DesignMaterialInfo> designMaterialInfoList(@Param("roleCode")String roleCode, @Param("userId")String userId, @Param("startDate")String startDate, @Param("endDate")String endDate);
+
+    List<DesignMaterialInfo> getMaterialAccountInfoByMaterialId(@Param("materialId")String materialId, @Param("startDate")String startDate, @Param("endDate")String endDate);
 
 
 }

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

@@ -52,10 +52,23 @@
     <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}
+        from ctop_material_info a
+        left join ctop_material_ascription b on a.id = b.material_id
+        where date_format(a.create_time,'%Y-%m-%d') &gt;= #{startTime}
+        and date_format(a.create_time,'%Y-%m-%d') &lt;= #{endTime}
+        and
+        <choose>
+            <when test=" roleCode == 'plan' ">
+                b.plan_id = #{userId}
+            </when>
+            <when test=" roleCode == 'clip' ">
+                b.clip_id = #{userId}
+            </when>
+            <otherwise>
+                b.shot_id = #{userId}
+            </otherwise>
+        </choose>
+
     </select>
 
     <!-- 根据clip_id获取视频总消耗 -->
@@ -72,7 +85,7 @@
         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}
+        and c.clip_id = #{userId}
     </select>
 
     <!-- 根据clip_id获取视频总消耗 -->
@@ -89,7 +102,7 @@
         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}
+        and c.shot_id = #{userId}
     </select>
 
     <!-- 根据clip_id获取视频总消耗 -->
@@ -106,7 +119,7 @@
         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}
+        and c.plan_id = #{userId}
     </select>
 
     <!-- 根据plane_id获取视频总消耗 -->
@@ -144,7 +157,7 @@
     </select>
 
     <!-- 获取这个人所在的所有项目 -->
-    <select id="getProjectsByUserId" resultType="cn.com.ctop.userefficientvideomap.entity.ProjectDTO ">
+    <select id="getProjectsByUserId" resultType="cn.com.ctop.userefficientvideomap.entity.ProjectDTO">
         select
         project_id as projectId,
         project_name as projectName
@@ -175,4 +188,52 @@
         and role_code = 'plane'
     </select>
 
+    <select id="designMaterialInfoList" resultType="cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo">    <!-- 素材、素材跑量、封面点击数、封面曝光数、行为数 -->
+        select
+        b.id as id,
+        b.url as videoUrl, <!-- 素材url -->
+        sum(a.photo_show) as pageExposureCount, <!-- 封面曝光数 -->
+        sum(a.photo_click) as pageClickCount, <!-- 封面点击数 -->
+        sum(a.aclick) as materialExposureCount, <!-- 素材曝光数 -->
+        sum(a.bclick) as behaviorCount,<!-- 行为数 -->
+        sum(a.charge) as totalCost <!-- 素材跑量 -->
+        from
+        ctop_material_info b
+        left join ctop_material_ascription c on b.id = c.material_id
+        left join ctop_kuaishou_report_daily_creative_statistic a on b.code = a.signature
+        where
+        <choose>
+            <when test=" roleCode == 'plan' ">
+                c.plan_id = #{userId}
+            </when>
+            <when test=" roleCode == 'clip' ">
+                c.clip_id = #{userId}
+            </when>
+            <otherwise>
+                c.shot_id = #{userId}
+            </otherwise>
+        </choose>
+         and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
+         and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+        group by b.id
+    </select>
+
+    <!-- 根据material_info的id查询出素材账户、投放账户、跑量 -->
+    <select id="getMaterialAccountInfoByMaterialId" resultType="cn.com.ctop.userefficientvideomap.entity.DesignMaterialInfo">
+        select
+        a.account_id as accountId,
+        a.account_name as accountName,
+        '快手' as platform,
+        sum(charge) as totalCost
+        from
+        ctop_material_info b
+        left join ctop_material_ascription c on b.id = c.material_id
+        left join ctop_kuaishou_report_daily_creative_statistic a on b.code = a.signature
+        where
+        b.id = #{materialId}
+        and DATE_FORMAT(b.create_time,'%Y-%m-%d') &gt;= #{startDate}
+         and DATE_FORMAT(b.create_time,'%Y-%m-%d') &lt;= #{endDate}
+    </select>
+
+
 </mapper>