Sfoglia il codice sorgente

自动生成指定月份非干部月度考核

chenshudong 1 mese fa
parent
commit
e547823f1a

+ 9 - 0
airport-admin/src/main/java/com/sundot/airport/web/controller/personnel/PersonnelNonCadreMonthlyAssessmentController.java

@@ -97,4 +97,13 @@ public class PersonnelNonCadreMonthlyAssessmentController extends BaseController
97 97
     public AjaxResult remove(@PathVariable Long[] ids) {
98 98
         return toAjax(personnelNonCadreMonthlyAssessmentService.deletePersonnelNonCadreMonthlyAssessmentByIds(ids));
99 99
     }
100
+
101
+    /**
102
+     * 自动生成指定月份非干部月度考核
103
+     */
104
+    @PreAuthorize("@ss.hasPermi('personnel:assessment:add')")
105
+    @GetMapping(value = "/autoGenerate/{month}")
106
+    public AjaxResult autoGenerate(@PathVariable("month") String month) {
107
+        return success(personnelNonCadreMonthlyAssessmentService.autoGenerate(month));
108
+    }
100 109
 }

+ 8 - 0
airport-personnel/src/main/java/com/sundot/airport/personnel/service/IPersonnelNonCadreMonthlyAssessmentService.java

@@ -59,4 +59,12 @@ public interface IPersonnelNonCadreMonthlyAssessmentService extends IService<Per
59 59
      * @return 结果
60 60
      */
61 61
     public int deletePersonnelNonCadreMonthlyAssessmentById(Long id);
62
+
63
+    /**
64
+     * 自动生成指定月份非干部月度考核
65
+     *
66
+     * @param month 月份值
67
+     * @return 结果
68
+     */
69
+    public List<PersonnelNonCadreMonthlyAssessment> autoGenerate(String month);
62 70
 }

+ 73 - 0
airport-personnel/src/main/java/com/sundot/airport/personnel/service/impl/PersonnelNonCadreMonthlyAssessmentServiceImpl.java

@@ -14,6 +14,8 @@ import cn.hutool.core.util.StrUtil;
14 14
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
15 15
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
16 16
 import com.sundot.airport.common.core.domain.entity.SysUser;
17
+import com.sundot.airport.common.dto.SysPersonnelUserConditionDto;
18
+import com.sundot.airport.common.dto.SysUserLeaderConditionDto;
17 19
 import com.sundot.airport.common.enums.AssessmentTeamEnum;
18 20
 import com.sundot.airport.common.enums.BasePerformanceIndicatorApplicationMethodRuleEnum;
19 21
 import com.sundot.airport.common.enums.BasePerformanceIndicatorAssessmentResultRuleEnum;
@@ -25,6 +27,7 @@ import com.sundot.airport.common.enums.RoleTypeEnum;
25 27
 import com.sundot.airport.common.exception.ServiceException;
26 28
 import com.sundot.airport.common.utils.DateUtils;
27 29
 import com.sundot.airport.common.utils.MonthUtils;
30
+import com.sundot.airport.common.utils.SecurityUtils;
28 31
 import com.sundot.airport.personnel.domain.PersonnelMonthlyAssessmentIndicatorDetail;
29 32
 import com.sundot.airport.personnel.domain.PersonnelMonthlyAssessmentIndicatorRewardPunishmentDetail;
30 33
 import com.sundot.airport.personnel.service.IPersonnelMonthlyAssessmentIndicatorDetailService;
@@ -839,4 +842,74 @@ public class PersonnelNonCadreMonthlyAssessmentServiceImpl extends ServiceImpl<P
839 842
         // 判断当前用户分数是否分数最低(包括并列)
840 843
         return lowerOrEqualCount == 0;
841 844
     }
845
+
846
+    /**
847
+     * 自动生成指定月份非干部月度考核
848
+     *
849
+     * @param month 月份值
850
+     * @return 结果
851
+     */
852
+    @Transactional(rollbackFor = Exception.class)
853
+    @Override
854
+    public List<PersonnelNonCadreMonthlyAssessment> autoGenerate(String month) {
855
+        List<PersonnelNonCadreMonthlyAssessment> result = new ArrayList<>();
856
+        SysPersonnelUserConditionDto sysPersonnelUserConditionDtoQuery = new SysPersonnelUserConditionDto();
857
+        sysPersonnelUserConditionDtoQuery.setMonth(month);
858
+        List<SysUser> sysUserList = sysUserService.selectPersonnelUserList(sysPersonnelUserConditionDtoQuery);
859
+        PersonnelNonCadreMonthlyAssessment personnelNonCadreMonthlyAssessmentQuery = new PersonnelNonCadreMonthlyAssessment();
860
+        personnelNonCadreMonthlyAssessmentQuery.setAssessmentMonth(month);
861
+        List<PersonnelNonCadreMonthlyAssessment> existList = personnelNonCadreMonthlyAssessmentMapper.selectPersonnelNonCadreMonthlyAssessmentList(personnelNonCadreMonthlyAssessmentQuery);
862
+        List<Long> existUserIdList = existList.stream().map(PersonnelNonCadreMonthlyAssessment::getUserId).collect(Collectors.toList());
863
+        sysUserList = sysUserList.stream().filter(sysUser -> !existUserIdList.contains(sysUser.getUserId())).collect(Collectors.toList());
864
+        sysUserList.forEach(sysUser -> {
865
+            PersonnelNonCadreMonthlyAssessment personnelNonCadreMonthlyAssessmentNew = new PersonnelNonCadreMonthlyAssessment();
866
+            personnelNonCadreMonthlyAssessmentNew.setCreateBy(SecurityUtils.getLoginUser().getUsername());
867
+            personnelNonCadreMonthlyAssessmentNew.setCreateTime(DateUtils.getNowDate());
868
+            personnelNonCadreMonthlyAssessmentNew.setAssessmentMonth(month);
869
+            personnelNonCadreMonthlyAssessmentNew.setUserId(sysUser.getUserId());
870
+            personnelNonCadreMonthlyAssessmentNew.setUserName(sysUser.getUserName());
871
+            if (CollUtil.isNotEmpty(sysUser.getRoles())) {
872
+                personnelNonCadreMonthlyAssessmentNew.setRoleId(sysUser.getRoles().get(0).getRoleId());
873
+                personnelNonCadreMonthlyAssessmentNew.setRoleName(sysUser.getRoles().get(0).getRoleName());
874
+                personnelNonCadreMonthlyAssessmentNew.setRoleKey(sysUser.getRoles().get(0).getRoleKey());
875
+            }
876
+            personnelNonCadreMonthlyAssessmentNew.setEmploymentType(sysUser.getEmploymentType());
877
+            personnelNonCadreMonthlyAssessmentNew.setAssessmentTeam(sysUser.getAssessmentTeam());
878
+            personnelNonCadreMonthlyAssessmentNew.setPost(sysUser.getPost());
879
+            SysUserLeaderConditionDto teamLeaderDto = new SysUserLeaderConditionDto();
880
+            teamLeaderDto.setUserId(sysUser.getUserId());
881
+            teamLeaderDto.setRoleKeyList(Collections.singletonList(RoleTypeEnum.banzuzhang.getCode()));
882
+            List<SysUser> teamLeaderList = sysUserService.selectUserLeaderListByCondition(teamLeaderDto);
883
+            if (CollUtil.isNotEmpty(teamLeaderList)) {
884
+                personnelNonCadreMonthlyAssessmentNew.setDeputyTeamLeaderId(teamLeaderList.get(0).getUserId());
885
+                personnelNonCadreMonthlyAssessmentNew.setDeputyTeamLeaderName(teamLeaderList.get(0).getUserName());
886
+            }
887
+            SysUserLeaderConditionDto supervisorDto = new SysUserLeaderConditionDto();
888
+            supervisorDto.setUserId(sysUser.getUserId());
889
+            supervisorDto.setRoleKeyList(Collections.singletonList(RoleTypeEnum.kezhang.getCode()));
890
+            List<SysUser> supervisorList = sysUserService.selectUserLeaderListByCondition(supervisorDto);
891
+            if (CollUtil.isNotEmpty(supervisorList)) {
892
+                personnelNonCadreMonthlyAssessmentNew.setDeputySupervisorId(supervisorList.get(0).getUserId());
893
+                personnelNonCadreMonthlyAssessmentNew.setDeputySupervisorName(supervisorList.get(0).getUserName());
894
+            }
895
+            SysUserLeaderConditionDto managerDto = new SysUserLeaderConditionDto();
896
+            managerDto.setUserId(sysUser.getUserId());
897
+            managerDto.setRoleKeyList(Collections.singletonList(RoleTypeEnum.jingli.getCode()));
898
+            List<SysUser> managerList = sysUserService.selectUserLeaderListByCondition(managerDto);
899
+            if (CollUtil.isNotEmpty(managerList)) {
900
+                if (managerList.size() > 1) {
901
+                    managerList = managerList.stream().filter(item -> StrUtil.equals(item.getWorkArea(), sysUser.getWorkArea())).collect(Collectors.toList());
902
+                }
903
+                if (CollUtil.isNotEmpty(managerList)) {
904
+                    personnelNonCadreMonthlyAssessmentNew.setDeputyManagerId(managerList.get(0).getUserId());
905
+                    personnelNonCadreMonthlyAssessmentNew.setDeputyManagerName(managerList.get(0).getUserName());
906
+                }
907
+            }
908
+            personnelNonCadreMonthlyAssessmentNew.setPersonnelMonthlyAssessmentIndicatorDetailList(new ArrayList<>());
909
+            doImprove(personnelNonCadreMonthlyAssessmentNew);
910
+            personnelNonCadreMonthlyAssessmentMapper.insertPersonnelNonCadreMonthlyAssessment(personnelNonCadreMonthlyAssessmentNew);
911
+            result.add(personnelNonCadreMonthlyAssessmentNew);
912
+        });
913
+        return result;
914
+    }
842 915
 }