Quellcode durchsuchen

1. 修复工作报告模块未填人员数量不正确的问题
2. 开发员工自定义审批流程功能

seyason vor 2 Jahren
Ursprung
Commit
9a94fd1dde

+ 59 - 10
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -175,7 +175,8 @@ public class ReportController {
                                   String[] projectAuditorId,
                                   Double[] overtimeHours, //加班时长
                                   String[] customText,
-                                  Integer[] basecostId //成本基线项的id
+                                  Integer[] basecostId, //成本基线项的id
+                                  String[] auditorSettingArray
                                     ) {
         List<Report> reportList = new ArrayList<>();
         String token = request.getHeader("Token");
@@ -269,7 +270,6 @@ public class ReportController {
                     }
                 }
             }
-
         }
 
 
@@ -314,12 +314,46 @@ public class ReportController {
                 }
             }
         }
-
-        //自动填充项目审核人
-        for (int i=0;i<projectAuditorId.length; i++) {
-            if (projectAuditorId[i] == null) {
-                final int index = i;
-                projectAuditorId[i] = projectList.stream().filter(p->p.getId().equals(projectId[index])).findFirst().get().getInchargerId();
+        TimeType comTimeType = timeTypeMapper.selectById(user.getCompanyId());
+        List<ReportAuditorSetting> auditorSettingList = null;
+        if (comTimeType.getReportAuditType() == 3) {
+            //员工自由选择审批人
+            if (auditorSettingArray == null) {
+                HttpRespMsg msg = new HttpRespMsg();
+                msg.setError("请设置审批人");
+                return msg;
+            } else {
+                for (int i=0;i<auditorSettingArray.length; i++) {
+                    String str = auditorSettingArray[i];
+                    ReportAuditorSetting reportAuditorSetting = JSONObject.parseObject(str, ReportAuditorSetting.class);
+                    auditorSettingList.add(reportAuditorSetting);
+                    //检查审核人层级是否设置满
+                    if (comTimeType.getAuditLevel() == 1 && reportAuditorSetting.getAuditorFirst() == null) {
+                        HttpRespMsg msg = new HttpRespMsg();
+                        msg.setError("请设置审核人");
+                        return msg;
+                    } else if (comTimeType.getAuditLevel() == 2 && (reportAuditorSetting.getAuditorFirst() == null || reportAuditorSetting.getAuditorSec() == null)) {
+                        HttpRespMsg msg = new HttpRespMsg();
+                        msg.setError("请设置审核人");
+                        return msg;
+                    }else if (comTimeType.getAuditLevel() == 3 && (reportAuditorSetting.getAuditorFirst() == null || reportAuditorSetting.getAuditorSec() == null
+                                                                    || reportAuditorSetting.getAuditorThird() == null)) {
+                        HttpRespMsg msg = new HttpRespMsg();
+                        msg.setError("请设置审核人");
+                        return msg;
+                    }
+                    //设置审核人为第一审核人
+                    projectAuditorId = new String[auditorSettingArray.length];
+                    projectAuditorId[i] = reportAuditorSetting.getAuditorFirst();
+                }
+            }
+        } else {
+            //自动填充项目审核人
+            for (int i=0;i<projectAuditorId.length; i++) {
+                if (projectAuditorId[i] == null) {
+                    final int index = i;
+                    projectAuditorId[i] = projectList.stream().filter(p->p.getId().equals(projectId[index])).findFirst().get().getInchargerId();
+                }
             }
         }
 
@@ -337,7 +371,7 @@ public class ReportController {
         LocalDate now = LocalDate.now();
         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         BigDecimal hourCost = null;
-        TimeType comTimeType = timeTypeMapper.selectById(user.getCompanyId());
+
         //自己填写的情况,计算个人自己的时薪
         if (targetUidList == null) {
             if (user.getCostApplyDate() != null) {
@@ -519,7 +553,10 @@ public class ReportController {
                             report.setTaskFinish(taskFinish[i]);
                             report.setCustomText(customText[i]);
                             report.setBasecostId(basecostId[i]);
-
+                            //如果是员工自由选择审批流程的方式,需要处理一下
+                            if (comTimeType.getReportAuditType() == 3) {
+                                report.setAuditorSetting(auditorSettingList.get(i));
+                            }
                             if (auditWorkflowList.size() == 0) {
                                 //没有自定义审核流,默认的直接是项目负责人审核
                                 report.setIsDeptAudit(0);
@@ -577,6 +614,10 @@ public class ReportController {
                                 report.setTaskFinish(taskFinish[i]);
                                 report.setCustomText(customText[i]);
                                 report.setBasecostId(basecostId[i]);
+                                //如果是员工自由选择审批流程的方式,需要处理一下
+                                if (comTimeType.getReportAuditType() == 3) {
+                                    report.setAuditorSetting(auditorSettingList.get(i));
+                                }
                                 if (auditWorkflowList.size() == 0) {
                                     //没有自定义审核流,默认的直接是项目负责人审核
                                     report.setIsDeptAudit(0);
@@ -636,6 +677,10 @@ public class ReportController {
                         report.setTaskFinish(taskFinish[i]);
                         report.setCustomText(customText[i]);
                         report.setBasecostId(basecostId[i]);
+                        //如果是员工自由选择审批流程的方式,需要处理一下
+                        if (comTimeType.getReportAuditType() == 3) {
+                            report.setAuditorSetting(auditorSettingList.get(i));
+                        }
                         if (auditWorkflowList.size() == 0) {
                             //没有自定义审核流,默认的直接是项目负责人审核
                             report.setIsDeptAudit(0);
@@ -700,6 +745,10 @@ public class ReportController {
                             report.setTaskFinish(taskFinish[i]);
                             report.setCustomText(customText[i]);
                             report.setBasecostId(basecostId[i]);
+                            //如果是员工自由选择审批流程的方式,需要处理一下
+                            if (comTimeType.getReportAuditType() == 3) {
+                                report.setAuditorSetting(auditorSettingList.get(i));
+                            }
                             if (auditWorkflowList.size() == 0) {
                                 //没有自定义审核流,直接代填的,就算审核通过
                                 report.setIsDeptAudit(0);

+ 11 - 56
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -823,6 +823,7 @@ public class WeiXinCorpController {
                         managerRole = sysRoleService.generateDefaultRoles(company.getId());
                     }
                     data.setCompanyId(company.getId());
+                    data.setSaasSyncContact(enableNewVersion?1:0);
                     wxCorpInfoMapper.insert(data);
                     //默认普通员工的角色
                     SysRole defaultUserRole = sysRoleService.getOne(new QueryWrapper<SysRole>().eq("company_id", company.getId()).eq("is_default", 1));
@@ -859,60 +860,8 @@ public class WeiXinCorpController {
 
                     int companyId = company.getId();
                     //获取公司根部门人员,也就是没有分配部门的人员
-                    int companyRootDeptId = 1;
                     if (enableNewVersion) {
-//                    获取部门
-                        JSONObject deptObj = getDepartments(curCorpAccessToken);
-                        JSONArray deptObjJSONArray = deptObj.getJSONArray("department");
-                        Integer sysDeptId = null;
-                        List<Department> sysDeptList = new ArrayList<>();
-                        for (int i=0;i<deptObjJSONArray.size(); i++) {
-                            int deptId = deptObjJSONArray.getJSONObject(i).getIntValue("id");
-                            if (deptId != companyRootDeptId) {
-                                int parentId = deptObjJSONArray.getJSONObject(i).getIntValue("parentid");
-                                Department department = new Department();
-                                department.setCorpwxDeptid(deptId);
-                                department.setCorpwxDeptpid(parentId);
-                                department.setDepartmentName(deptObjJSONArray.getJSONObject(i).getString("name"));
-                                department.setCompanyId(companyId);
-                                departmentMapper.insert(department);
-                                sysDeptList.add(department);
-                                sysDeptId = department.getDepartmentId();
-                            }
-                            deptObjJSONArray.getJSONObject(i).put("sys_dept_id", sysDeptId);
-                            Integer departmentId = sysDeptId;
-                            JSONArray userList = getDeptUserSimple(curCorpAccessToken, deptId);
-                            for (int m=0;m<userList.size(); m++) {
-                                JSONObject userJson = userList.getJSONObject(m);
-                                String curUserid = userJson.getString("userid");
-                                log.info("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
-                                //不存在的人员, 进行插入
-                                User user = new User();
-
-                                user.setId(SnowFlake.nextId()+"")
-                                        .setRoleId(defaultUserRole.getId())//默认普通员工
-                                        .setRoleName(defaultUserRole.getRolename())
-                                        .setCompanyId(companyId)
-                                        .setDepartmentId(departmentId == companyRootDeptId?null:departmentId)
-                                        .setName(userJson.getString("name"))
-                                        .setCorpwxUserid(curUserid)
-                                        .setColor(ColorUtil.randomColor())
-                                        .setJobNumber(userId);//工号就是企业微信的用户ID
-
-                                //检查用户是否已经存在
-                                if (userMapper.selectCount(new QueryWrapper<User>().eq("corpwx_userid", curUserid)) == 0) {
-                                    userMapper.insert(user);
-                                } else {
-                                    //更新信息
-                                    User oldUser = userMapper.selectList(new QueryWrapper<User>().eq("corpwx_userid", curUserid).eq("company_id", companyId).orderByDesc("create_time")).get(0);
-                                    oldUser.setName(userJson.getString("name"));
-                                    oldUser.setDepartmentId(departmentId);
-                                    userMapper.updateById(oldUser);
-                                }
-                            }
-                        }
-//                    再来更新部门的层级关系
-                        updateDeptHierachyByCorpWx(companyId);
+                        getCorpMembsFromPlatform(companyId);
                     }
                 } else {
                     //企业已经存在
@@ -1548,11 +1497,17 @@ public class WeiXinCorpController {
         List<User> updateUserList = allCorpWxUserList.stream().filter(newItem->existingUsers.stream().anyMatch(existingItem->newItem.getCorpwxUserid().equals(existingItem.getCorpwxUserid())
                                             && (!newItem.getName().equals(existingItem.getName()) || (newItem.getCorpwxDeptid() != null && !newItem.getCorpwxDeptid().equals(existingItem.getCorpwxDeptid()))))).collect(Collectors.toList());
         List<Integer> corpWxDeptIds = updateUserList.stream().map(User::getCorpwxDeptid).collect(Collectors.toList());
-
-        List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId).in("corpwx_deptid", corpWxDeptIds));
+        List<Department> departmentList = null;
+        if (corpWxDeptIds.size() > 0) {
+            //
+            departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId).in("corpwx_deptid", corpWxDeptIds));
+        }
+        final  List<Department> fDeptList = departmentList;
         updateUserList.forEach(u->{
             if (u.getCorpwxDeptid() != 1) {
-                u.setDepartmentId(departmentList.stream().filter(d->d.getCorpwxDeptid().equals(u.getCorpwxDeptid())).findFirst().get().getDepartmentId());
+                if (fDeptList != null) {
+                    u.setDepartmentId(fDeptList.stream().filter(d->d.getCorpwxDeptid().equals(u.getCorpwxDeptid())).findFirst().get().getDepartmentId());
+                }
                 //设置层级部门
                 u.setDepartmentCascade(convertDepartmentIdToCascade(u.getDepartmentId(), allDeptList));
             } else {

+ 3 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/Report.java

@@ -352,6 +352,9 @@ public class Report extends Model<Report> {
     private Integer reportAutoApprove;
 
 
+    @TableField(exist = false)
+    private ReportAuditorSetting auditorSetting;
+
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 56 - 4
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -143,6 +143,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     @Resource
     private TaskService taskService;
     @Resource
+    private ReportAuditorSettingService reportAuditorSettingService;
+    @Resource
+    private ReportAuditorSettingMapper reportAuditorSettingMapper;
+    @Resource
     private UserRecentTaskMapper userRecentTaskMapper;
     @Resource
     private PpMembsMapper ppMembsMapper;
@@ -592,7 +596,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             r.setProjectAuditorName(auItem.get().getAuditorName());
                         }
                     }
-                } else {
+                } else if (reportAuditType == 1 || reportAuditType == 2) {
                     if (r.getGroupId() != null && r.getGroupId() != 0) {
                         //直接获取分组的负责人作为审核人
                         Optional<TaskGroup> tgoup = taskGroups.stream().filter(tg->tg.getId().equals(r.getGroupId())).findFirst();
@@ -612,6 +616,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             }
                         }
                     }
+                } else if (reportAuditType == 3) {
+
                 }
 
             });
@@ -796,6 +802,14 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         //异步下载图片
         loadPicFromCorpWXServer(companyId, reportList);
         saveFillReportLog(reportList);
+        //处理审批流程
+        if (timeType.getReportAuditType() == 3) {
+            reportList.forEach(r->r.getAuditorSetting().setReportId(r.getId()));
+            List<ReportAuditorSetting> collect = reportList.stream().map(Report::getAuditorSetting).collect(Collectors.toList());
+            if (collect.size() > 0) {
+                reportAuditorSettingService.saveOrUpdateBatch(collect);
+            }
+        }
         return httpRespMsg;
     }
 
@@ -1332,6 +1346,40 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 }
                 //批量更新
                 updateBatchById(reportList);
+            } else if (timeType.getReportAuditType() == 3) {
+                //员工自由选择的审批人
+                String auditorId = user.getId();
+                List<ReportAuditorSetting> auditorSettingList = reportAuditorSettingMapper.selectList(new QueryWrapper<ReportAuditorSetting>().in("report_id", ids));
+
+                for (Integer rid : ids) {
+                    Report r = new Report();
+                    r.setId(rid);
+                    ReportAuditorSetting auditorItem = auditorSettingList.stream().filter(a -> a.getReportId().equals(rid)).findFirst().get();
+                    if (auditorId.equals(auditorItem.getAuditorFirst())) {
+                        if (auditorItem.getAuditorSec() != null) {
+                            //进入到第二审批人
+                            r.setProjectAuditorId(auditorItem.getAuditorSec());
+                        } else {
+                            r.setProjectAuditState(1);
+                            r.setProjectAuditTime(LocalDateTime.now());
+                            r.setState(1);
+                        }
+                    } else if (auditorId.equals(auditorItem.getAuditorSec())) {
+                        if (auditorItem.getAuditorThird() != null) {
+                            //进入到第三审批人
+                            r.setProjectAuditorId(auditorItem.getAuditorThird());
+                        } else {
+                            r.setProjectAuditState(1);
+                            r.setProjectAuditTime(LocalDateTime.now());
+                            r.setState(1);
+                        }
+                    } else if (auditorId.equals(auditorItem.getAuditorThird())) {
+                        //目前最多三层,第三个审批人审批后结束
+                        r.setProjectAuditState(1);
+                        r.setProjectAuditTime(LocalDateTime.now());
+                        r.setState(1);
+                    }
+                }
             } else {
                 //之前的流程逻辑,综合了一层项目审核,或者一层任务分组审核。 可叠加部门审批流
                 List<AuditWorkflowTimeSetting> settings = auditWorkflowTimeSettingMapper.selectList(
@@ -1720,9 +1768,12 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 upR.setGroupAuditState(0);
                 System.out.println("groupId=="+r.getGroupId());
                 if (r.getGroupId() != 0) {
-                    String inchargerId = taskGroupMapper.selectById(r.getGroupId()).getInchargerId();
-                    upR.setProjectAuditorId(inchargerId);
-                    upR.setProjectAuditorName(userMapper.selectById(inchargerId).getName());
+                    TaskGroup oldGroup = taskGroupMapper.selectById(r.getGroupId());
+                    if (oldGroup != null) {
+                        String inchargerId = taskGroupMapper.selectById(r.getGroupId()).getInchargerId();
+                        upR.setProjectAuditorId(inchargerId);
+                        upR.setProjectAuditorName(userMapper.selectById(inchargerId).getName());
+                    }
                 }
                 newList.add(upR);
             }
@@ -3903,6 +3954,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         List<Department> departmentList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
         //获取企业微信同步数据
         List<Map> userCorpwxTimeMapList = userCorpwxTimeMapper.selectByAsk(companyId,startDate,endDate);
+        //请假人员名单
 
         DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
         SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");