Sfoglia il codice sorgente

平面、设计师leader绩效逻辑修改、绩效项目维度接口增加

hcst_sunzhen 5 anni fa
parent
commit
a32c46479e

+ 4 - 0
jeecg-boot-base-common/src/main/java/org/jeecg/common/util/DateUtils.java

@@ -753,6 +753,10 @@ public class DateUtils extends PropertyEditorSupport {
         return sdf.format(calendar.getTime());
     }
 
+    public static void main(String[] args) throws ParseException {
+        System.out.println(DateUtils.addDay( "2020-01-03",  7));
+    }
+
     public static Date addDay(Date date, int day) {
         Calendar calendar = Calendar.getInstance();
         calendar.setTime(date);

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

@@ -122,7 +122,7 @@ public class PerformanceController2 {
 
     @AutoLog(value = "根据year、quarter计算季度设计师绩效")
     @ApiOperation(value = "根据year、quarter计算季度设计师绩效", notes = "根据year、quarter计算季度设计师绩效")
-    @PostMapping(value = "/designerPerformance")
+    @GetMapping(value = "/designerPerformance")
     public Result<Map<String, Object>> designerPerformanceTask(@RequestParam(name = "year", required = true) int year,
                                                                @RequestParam(name = "quarter", required = true) int quarter) {
         Result<Map<String, Object>> result = new Result<Map<String, Object>>();

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

@@ -1,5 +1,6 @@
 package org.jeecg.modules.system.entity;
 
+import cn.com.ctop.userefficientvideomap.entity.UserDto2;
 import com.baomidou.mybatisplus.annotation.IdType;
 import com.baomidou.mybatisplus.annotation.TableId;
 import com.fasterxml.jackson.annotation.JsonFormat;
@@ -18,8 +19,8 @@ public class EffiRateComparator implements Comparator<Object> {
 
     @Override
     public int compare(Object o1, Object o2) {
-        UserDto p1 = (UserDto) o1; // 强制转换
-        UserDto p2 = (UserDto) o2;
+        UserDto2 p1 = (UserDto2) o1; // 强制转换
+        UserDto2 p2 = (UserDto2) o2;
         return (p2.getEffiRate()).compareTo(p1.getEffiRate());
     }
 }

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

@@ -24,6 +24,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.ParseException;
 import java.util.*;
 
@@ -680,7 +681,10 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //总视频数量
             int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 2, userDto.getUserId(), "plan");
             //视频有效率
-            BigDecimal effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)));
+            BigDecimal effiRate=BigDecimal.ZERO;
+            if (videoCount != 0){
+                effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)),4,BigDecimal.ROUND_HALF_UP);
+            }
             userDto.setEffiRate(effiRate);
         }
         Collections.sort(planList, new EffiRateComparator());
@@ -728,7 +732,10 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //总消耗--获取这个人所在项目的总消耗
             BigDecimal totalCost = userEfficientVideoMapMapper.getTotalCostByPlanId(planList.get(i).getUserId(), startTime, endTime);
             //总绩效=总消耗*提点比例(3‰)*提成比例(编导40%)
-            BigDecimal totalPerformance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.4"));
+            BigDecimal totalPerformance = BigDecimal.ZERO;
+            if(totalCost != null){
+                totalPerformance = totalCost.multiply(new BigDecimal("0.003")).multiply(new BigDecimal("0.4"));
+            }
 
             Performance performance = new Performance();
             performance.setAppType(2); //1头条 2快手
@@ -761,7 +768,10 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //总视频数量
             int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 2, userDto.getUserId(), "shot");
             //视频有效率
-            BigDecimal effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)));
+            BigDecimal effiRate=BigDecimal.ZERO;
+            if (videoCount != 0){
+                effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)),4,BigDecimal.ROUND_HALF_UP);
+            }
             userDto.setEffiRate(effiRate);
         }
         Collections.sort(shotList, new EffiRateComparator());
@@ -842,7 +852,10 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //总视频数量
             int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 2, userDto.getUserId(), "clip");
             //视频有效率
-            BigDecimal effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)));
+            BigDecimal effiRate=BigDecimal.ZERO;
+            if (videoCount != 0){
+                effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)),4,BigDecimal.ROUND_HALF_UP);
+            }
             userDto.setEffiRate(effiRate);
         }
         Collections.sort(clipList, new EffiRateComparator());
@@ -967,7 +980,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
                 continue;
             }
 
-            BigDecimal averageQuarterCost = quarterCost.divide(new BigDecimal(String.valueOf(size)));
+            BigDecimal averageQuarterCost = quarterCost.divide(new BigDecimal(String.valueOf(size)),4,BigDecimal.ROUND_HALF_UP);
 
             //循环项目下所有平面设计
             for (UserDto2 plane : planeList) {
@@ -1073,7 +1086,10 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //总视频数量
             int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 1, userDto.getUserId(), "plan");
             //视频有效率
-            BigDecimal effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)));
+            BigDecimal effiRate=BigDecimal.ZERO;
+            if (videoCount != 0){
+                effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)),4,BigDecimal.ROUND_HALF_UP);
+            }
             userDto.setEffiRate(effiRate);
         }
         Collections.sort(planList, new EffiRateComparator());
@@ -1151,7 +1167,10 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //总视频数量
             int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 1, userDto.getUserId(), "shot");
             //视频有效率
-            BigDecimal effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)));
+            BigDecimal effiRate=BigDecimal.ZERO;
+            if (videoCount != 0){
+                effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)),4,BigDecimal.ROUND_HALF_UP);
+            }
             userDto.setEffiRate(effiRate);
         }
         Collections.sort(shotList, new EffiRateComparator());
@@ -1229,7 +1248,10 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
             //总视频数量
             int videoCount = userEfficientVideoMapMapper.getQuarterVideoCountByRoleCodeAndUserId(thisYear, thisQuarter, 2, userDto.getUserId(), "clip");
             //视频有效率
-            BigDecimal effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)));
+            BigDecimal effiRate=BigDecimal.ZERO;
+            if (videoCount != 0){
+                effiRate = new BigDecimal(String.valueOf(effiVideoCount)).divide(new BigDecimal(String.valueOf(videoCount)),4,BigDecimal.ROUND_HALF_UP);
+            }
             userDto.setEffiRate(effiRate);
         }
         Collections.sort(clipList, new EffiRateComparator());
@@ -1352,7 +1374,7 @@ public class PerformanceServiceImpl2 extends ServiceImpl<PerformanceMapper, Perf
                 continue;
             }
 
-            BigDecimal averageQuarterCost = quarterCost.divide(new BigDecimal(String.valueOf(size)));
+            BigDecimal averageQuarterCost = quarterCost.divide(new BigDecimal(String.valueOf(size)),4,BigDecimal.ROUND_HALF_UP);
 
             //循环项目下所有平面设计
             for (UserDto2 plane : planeList) {