Explorar o código

首页-学习成长-平均分

chenshudong hai 2 meses
pai
achega
11501146ba

+ 16 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/system/SysLearningGrowthController.java

@@ -1,8 +1,10 @@
1 1
 package com.sundot.airport.web.controller.system;
2 2
 
3
+import java.math.BigDecimal;
3 4
 import java.util.List;
4 5
 import javax.servlet.http.HttpServletResponse;
5 6
 
7
+import com.sundot.airport.common.core.domain.BaseLargeScreenQueryParamDto;
6 8
 import com.sundot.airport.system.domain.SysLargeScreenLearningGrowthDto;
7 9
 import com.sundot.airport.system.domain.SysLargeScreenLearningGrowthOrganizationalSupportDto;
8 10
 import com.sundot.airport.system.domain.SysLargeScreenLearningGrowthQueryParamDto;
@@ -156,4 +158,18 @@ public class SysLearningGrowthController extends BaseController {
156 158
         List<SysLargeScreenLearningGrowthOrganizationalSupportDto> result = sysLearningGrowthService.organizationalSupport(dto);
157 159
         return success(result);
158 160
     }
161
+
162
+    /**
163
+     * 首页-学习成长-平均分
164
+     */
165
+//    @Cacheable(
166
+//            value = "statistics_learningGrowth_average",
167
+//            keyGenerator = "statisticsKeyGenerator",
168
+//            unless = "!T(com.sundot.airport.common.cache.StatisticsCacheConditionUtil).isSuccess(#result) ||T(com.sundot.airport.common.cache.StatisticsCacheConditionUtil).isEmptyData(#result)"
169
+//    )
170
+    @GetMapping("/learningGrowthAverage")
171
+    public AjaxResult learningGrowthAverage(BaseLargeScreenQueryParamDto dto) {
172
+        BigDecimal result = sysLearningGrowthService.learningGrowthAverage(dto);
173
+        return success(result);
174
+    }
159 175
 }

+ 5 - 0
airport-system/src/main/java/com/sundot/airport/system/domain/SysLargeScreenLearningGrowthQueryParamDto.java

@@ -14,6 +14,11 @@ import lombok.Data;
14 14
 public class SysLargeScreenLearningGrowthQueryParamDto extends BaseLargeScreenQueryParamDto {
15 15
 
16 16
     /**
17
+     * 站ID
18
+     */
19
+    private Long stationId;
20
+
21
+    /**
17 22
      * 大队ID
18 23
      */
19 24
     private Long brigadeId;

+ 8 - 0
airport-system/src/main/java/com/sundot/airport/system/service/ISysLearningGrowthService.java

@@ -97,4 +97,12 @@ public interface ISysLearningGrowthService {
97 97
      * @return 工作画像-组织支撑-培训测试平均分趋势图
98 98
      */
99 99
     public List<SysLargeScreenLearningGrowthOrganizationalSupportDto> organizationalSupport(SysLargeScreenLearningGrowthQueryParamDto dto);
100
+
101
+    /**
102
+     * 首页-学习成长-平均分
103
+     *
104
+     * @param dto 上行参数
105
+     * @return 首页-学习成长-平均分
106
+     */
107
+    public BigDecimal learningGrowthAverage(BaseLargeScreenQueryParamDto dto);
100 108
 }

+ 47 - 0
airport-system/src/main/java/com/sundot/airport/system/service/impl/SysLearningGrowthServiceImpl.java

@@ -999,4 +999,51 @@ public class SysLearningGrowthServiceImpl implements ISysLearningGrowthService {
999 999
         List<SysLargeScreenLearningGrowthOrganizationalSupportDto> result = sysLearningGrowthMapper.organizationalSupport(dto);
1000 1000
         return result;
1001 1001
     }
1002
+
1003
+    /**
1004
+     * 首页-学习成长-平均分
1005
+     *
1006
+     * @param dto 上行参数
1007
+     * @return 首页-学习成长-平均分
1008
+     */
1009
+    @Override
1010
+    public BigDecimal learningGrowthAverage(BaseLargeScreenQueryParamDto dto) {
1011
+        if (ObjUtil.isNull(dto.getUserId()) && ObjUtil.isNull(dto.getDeptId())) {
1012
+            throw new ServiceException("用户ID和部门ID不能同时为空");
1013
+        }
1014
+        // 默认筛选条件
1015
+        if (ObjUtil.isNull(dto.getStartDate()) && ObjUtil.isNull(dto.getEndDate()) && ObjUtil.isNull(dto.getSpecifiedDate())) {
1016
+            dto.setEndDate(LargeScreenDateUtils.getCurrentDate());
1017
+            dto.setStartDate(LargeScreenDateUtils.getDateBeforeYears(1));
1018
+        }
1019
+        SysLargeScreenLearningGrowthQueryParamDto tempQueryParam = new SysLargeScreenLearningGrowthQueryParamDto();
1020
+        tempQueryParam.setSpecifiedDate(dto.getSpecifiedDate());
1021
+        tempQueryParam.setStartDate(dto.getStartDate());
1022
+        tempQueryParam.setEndDate(dto.getEndDate());
1023
+        if (ObjUtil.isNotNull(dto.getUserId())) {
1024
+            tempQueryParam.setUserId(dto.getUserId());
1025
+        } else {
1026
+            SysDept sysDept = sysDeptService.selectDeptById(dto.getDeptId());
1027
+            if (ObjUtil.isNull(sysDept)) {
1028
+                throw new ServiceException("部门不存在");
1029
+            }
1030
+            if (StrUtil.equals(DeptTypeEnum.STATION.getCode(), sysDept.getDeptType())) {
1031
+                tempQueryParam.setStationId(sysDept.getDeptId());
1032
+            } else if (StrUtil.equals(DeptTypeEnum.BRIGADE.getCode(), sysDept.getDeptType())) {
1033
+                tempQueryParam.setBrigadeId(sysDept.getDeptId());
1034
+            } else if (StrUtil.equals(DeptTypeEnum.MANAGER.getCode(), sysDept.getDeptType())) {
1035
+                tempQueryParam.setDepartmentId(sysDept.getDeptId());
1036
+            } else if (StrUtil.equals(DeptTypeEnum.TEAMS.getCode(), sysDept.getDeptType())) {
1037
+                tempQueryParam.setTeamId(sysDept.getDeptId());
1038
+            } else {
1039
+                return BigDecimal.ZERO;
1040
+            }
1041
+        }
1042
+        List<SysLargeScreenLearningGrowthSqlDto> target = sysLearningGrowthMapper.selectSysLearningGrowthListByCondition(tempQueryParam);
1043
+        if (CollUtil.isEmpty(target)) {
1044
+            return BigDecimal.ZERO;
1045
+        }
1046
+        BigDecimal sum = target.stream().map(SysLargeScreenLearningGrowthSqlDto::getExamScore).reduce(BigDecimal.ZERO, BigDecimal::add);
1047
+        return sum.divide(BigDecimal.valueOf(target.size()), 2, RoundingMode.HALF_UP);
1048
+    }
1002 1049
 }

+ 3 - 0
airport-system/src/main/resources/mapper/system/SysLearningGrowthMapper.xml

@@ -153,6 +153,9 @@
153 153
         <if test="brigadeId != null">
154 154
             and sd_dd.dept_id=#{brigadeId}
155 155
         </if>
156
+        <if test="stationId != null">
157
+            and sd_zj.dept_id=#{stationId}
158
+        </if>
156 159
         <if test="specifiedDate != null">
157 160
             and slg.exam_time=#{specifiedDate}
158 161
         </if>