Просмотр исходного кода

添加缺失的ReportAuditorSetting

seyason 2 лет назад
Родитель
Сommit
d6f9514237

+ 21 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportAuditorSettingController.java

@@ -0,0 +1,21 @@
+package com.management.platform.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-09-28
+ */
+@RestController
+@RequestMapping("/report-auditor-setting")
+public class ReportAuditorSettingController {
+
+}
+

+ 44 - 46
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/WeiXinCorpController.java

@@ -1444,7 +1444,6 @@ public class WeiXinCorpController {
                     .setColor(ColorUtil.randomColor())
                     .setJobNumber(curUserid)
                     .setCorpwxDeptid(maxDeptId);
-            System.out.println("姓名=="+user.getName());
             allCorpWxUserList.add(user);
         }
 
@@ -1474,7 +1473,6 @@ public class WeiXinCorpController {
                         //有父部门需要更新
                         curDept.setCorpwxDeptpid(parentId);
                         departmentMapper.updateById(curDept);
-
                     }
                 }
             }
@@ -1514,9 +1512,8 @@ public class WeiXinCorpController {
                 u.setDepartmentId(0);
                 u.setDepartmentCascade("0");
             }
-
         });
-
+        userService.updateBatchById(updateUserList);
         return new HttpRespMsg();
     }
 
@@ -1554,16 +1551,16 @@ public class WeiXinCorpController {
         }
         int companyId = company.getId();
         //获取公司根部门人员,也就是没有分配部门的人员
-        List<JSONObject> hasDirectLdMembs = new ArrayList<>();
+//        List<JSONObject> hasDirectLdMembs = new ArrayList<>();
         SysRole defaultRole = sysRoleMapper.selectOne(
                 new QueryWrapper<SysRole>().eq("company_id", companyId).eq("is_default", 1));
 
         int companyRootDeptId = 1;
         if (syncMembs == 1) {
-            JSONArray unAssignedUserList = getDeptUserInfo(curCorpAccessToken, companyRootDeptId);
+            JSONArray allCorpWxUserJsonArray = getDeptUserInfo(curCorpAccessToken, companyRootDeptId);
             //获取远程的带姓名的详情,通过企业通讯录的token获取
             JSONArray remoteUnAUserList = null;
-            if (unAssignedUserList.size() > 0) {
+            if (allCorpWxUserJsonArray.size() > 0) {
                 remoteUnAUserList = remoteGetDeptUserDetail(wxCorpInfo, corpContactAccessToken, companyRootDeptId);
                 //做id转化
                 List<String> corpUserIds = new ArrayList<>();
@@ -1594,15 +1591,16 @@ public class WeiXinCorpController {
             }
 
             List<User> updateUserList = new ArrayList<>();
-            for (int m=0;m<unAssignedUserList.size(); m++) {
-                JSONObject userJson = unAssignedUserList.getJSONObject(m);
+
+            for (int m=0;m<allCorpWxUserJsonArray.size(); m++) {
+                JSONObject userJson = allCorpWxUserJsonArray.getJSONObject(m);
                 String curUserid = userJson.getString("userid");
                 //跳过非激活状态的员工
                 if (userJson.getInteger("status") != 1) continue;
                 System.out.println("userid="+curUserid+", name=" + userJson.getString("name")+", department="+userJson.getJSONArray("department"));
-                if (userJson.getJSONArray("direct_leader").size() > 0) {
-                    hasDirectLdMembs.add(userJson);
-                }
+//                if (userJson.getJSONArray("direct_leader").size() > 0) {
+//                    hasDirectLdMembs.add(userJson);
+//                }
                 //不存在的人员, 进行插入
                 User user = new User();
 
@@ -1753,9 +1751,9 @@ public class WeiXinCorpController {
                     String curUserid = userJson.getString("userid");
                     if (userJson.getInteger("status") != 1) continue;
                     log.info("userid="+curUserid+", name=" + userJson.getString("name")+", mobile="+userJson.getString("mobile"));
-                    if (userJson.getJSONArray("direct_leader").size() > 0) {
-                        hasDirectLdMembs.add(userJson);
-                    }
+//                    if (userJson.getJSONArray("direct_leader").size() > 0) {
+//                        hasDirectLdMembs.add(userJson);
+//                    }
                     //不存在的人员, 进行插入
                     User user = new User();
 
@@ -1843,37 +1841,37 @@ public class WeiXinCorpController {
             departmentService.updateBatchById(needUpdateDepts);
         }
         //更新人员的直属上级
-        if (hasDirectLdMembs.size() > 0) {
-            List<String> corpwxUids = new ArrayList<>();
-            for (JSONObject userJson : hasDirectLdMembs) {
-                String curUserid = userJson.getString("userid");
-                //取第一个leaderId
-                JSONArray directLeader = userJson.getJSONArray("direct_leader");
-                String string = directLeader.getString(0);
-                corpwxUids.add(curUserid);
-                if (!corpwxUids.contains(string)) {
-                    corpwxUids.add(string);
-                }
-            }
-            List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, corpwx_userid, superior_id").in("corpwx_userid", corpwxUids));
-            List<User> updateUserList = new ArrayList<>();
-            for (JSONObject userJson : hasDirectLdMembs) {
-                String curUserid = userJson.getString("userid");
-                User user = userList.stream().filter(u -> u.getCorpwxUserid().equals(curUserid)).findFirst().get();
-                JSONArray directLeader = userJson.getJSONArray("direct_leader");
-                String leaderCorpWxuid = directLeader.getString(0);
-                //查找leader
-                User leader = userList.stream().filter(u -> u.getCorpwxUserid().equals(leaderCorpWxuid)).findFirst().get();
-                if (!leader.getId().equals(user.getSuperiorId())) {
-                    user.setSuperiorId(leader.getId());
-                    updateUserList.add(user);
-                }
-            }
-            if (updateUserList.size() > 0) {
-                //批量更新上级领导
-                userService.updateBatchById(updateUserList);
-            }
-        }
+//        if (hasDirectLdMembs.size() > 0) {
+//            List<String> corpwxUids = new ArrayList<>();
+//            for (JSONObject userJson : hasDirectLdMembs) {
+//                String curUserid = userJson.getString("userid");
+//                //取第一个leaderId
+//                JSONArray directLeader = userJson.getJSONArray("direct_leader");
+//                String string = directLeader.getString(0);
+//                corpwxUids.add(curUserid);
+//                if (!corpwxUids.contains(string)) {
+//                    corpwxUids.add(string);
+//                }
+//            }
+//            List<User> userList = userMapper.selectList(new QueryWrapper<User>().select("id, corpwx_userid, superior_id").in("corpwx_userid", corpwxUids));
+//            List<User> updateUserList = new ArrayList<>();
+//            for (JSONObject userJson : hasDirectLdMembs) {
+//                String curUserid = userJson.getString("userid");
+//                User user = userList.stream().filter(u -> u.getCorpwxUserid().equals(curUserid)).findFirst().get();
+//                JSONArray directLeader = userJson.getJSONArray("direct_leader");
+//                String leaderCorpWxuid = directLeader.getString(0);
+//                //查找leader
+//                User leader = userList.stream().filter(u -> u.getCorpwxUserid().equals(leaderCorpWxuid)).findFirst().get();
+//                if (!leader.getId().equals(user.getSuperiorId())) {
+//                    user.setSuperiorId(leader.getId());
+//                    updateUserList.add(user);
+//                }
+//            }
+//            if (updateUserList.size() > 0) {
+//                //批量更新上级领导
+//                userService.updateBatchById(updateUserList);
+//            }
+//        }
 
         //更新人员的deptcascade
         updateUserDeptCascade(companyId);

+ 62 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/entity/ReportAuditorSetting.java

@@ -0,0 +1,62 @@
+package com.management.platform.entity;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableField;
+import java.io.Serializable;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-09-29
+ */
+@Data
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+public class ReportAuditorSetting extends Model<ReportAuditorSetting> {
+
+    private static final long serialVersionUID=1L;
+
+    /**
+     * 主键: 日报id
+     */
+    @TableId("report_id")
+    private Integer reportId;
+
+    /**
+     * 第一审核人
+     */
+    @TableField("auditor_first")
+    private String auditorFirst;
+
+    /**
+     * 第二审核人
+     */
+    @TableField("auditor_sec")
+    private String auditorSec;
+
+    /**
+     * 第三审核人
+     */
+    @TableField("auditor_third")
+    private String auditorThird;
+
+    /**
+     * 抄送人
+     */
+    @TableField("cc_userid")
+    private String ccUserid;
+
+
+    @Override
+    protected Serializable pkVal() {
+        return this.reportId;
+    }
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/mapper/ReportAuditorSettingMapper.java

@@ -0,0 +1,16 @@
+package com.management.platform.mapper;
+
+import com.management.platform.entity.ReportAuditorSetting;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-09-28
+ */
+public interface ReportAuditorSettingMapper extends BaseMapper<ReportAuditorSetting> {
+
+}

+ 16 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/ReportAuditorSettingService.java

@@ -0,0 +1,16 @@
+package com.management.platform.service;
+
+import com.management.platform.entity.ReportAuditorSetting;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-09-28
+ */
+public interface ReportAuditorSettingService extends IService<ReportAuditorSetting> {
+
+}

+ 20 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportAuditorSettingServiceImpl.java

@@ -0,0 +1,20 @@
+package com.management.platform.service.impl;
+
+import com.management.platform.entity.ReportAuditorSetting;
+import com.management.platform.mapper.ReportAuditorSettingMapper;
+import com.management.platform.service.ReportAuditorSettingService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author Seyason
+ * @since 2022-09-28
+ */
+@Service
+public class ReportAuditorSettingServiceImpl extends ServiceImpl<ReportAuditorSettingMapper, ReportAuditorSetting> implements ReportAuditorSettingService {
+
+}

+ 53 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ReportServiceImpl.java

@@ -617,7 +617,8 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                         }
                     }
                 } else if (reportAuditType == 3) {
-
+                    //获取日报对应已经设置好的审核人和抄送人
+                    r.setAuditorSetting(reportAuditorSettingMapper.selectById(r.getId()));
                 }
 
             });
@@ -1350,7 +1351,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 //员工自由选择的审批人
                 String auditorId = user.getId();
                 List<ReportAuditorSetting> auditorSettingList = reportAuditorSettingMapper.selectList(new QueryWrapper<ReportAuditorSetting>().in("report_id", ids));
-
+                List<Report> updateReportList = new ArrayList<>();
                 for (Integer rid : ids) {
                     Report r = new Report();
                     r.setId(rid);
@@ -1364,6 +1365,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             r.setProjectAuditTime(LocalDateTime.now());
                             r.setState(1);
                         }
+                        updateReportList.add(r);
                     } else if (auditorId.equals(auditorItem.getAuditorSec())) {
                         if (auditorItem.getAuditorThird() != null) {
                             //进入到第三审批人
@@ -1373,13 +1375,18 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                             r.setProjectAuditTime(LocalDateTime.now());
                             r.setState(1);
                         }
+                        updateReportList.add(r);
                     } else if (auditorId.equals(auditorItem.getAuditorThird())) {
                         //目前最多三层,第三个审批人审批后结束
                         r.setProjectAuditState(1);
                         r.setProjectAuditTime(LocalDateTime.now());
                         r.setState(1);
+                        updateReportList.add(r);
                     }
                 }
+                if (updateReportList.size() > 0) {
+                    updateBatchById(updateReportList);
+                }
             } else {
                 //之前的流程逻辑,综合了一层项目审核,或者一层任务分组审核。 可叠加部门审批流
                 List<AuditWorkflowTimeSetting> settings = auditWorkflowTimeSettingMapper.selectList(
@@ -1553,6 +1560,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     }
                 }
             }
+            if (timeType.getReportAuditType() == 3) {
+                //审核通过的话,给抄送人发送审核通过提醒
+
+            }
             //对导入审核,添加记录
             int channel = oldState == -1?0:1; //0-导入审核, 项目报告审核
             ReportAuditLog log = new ReportAuditLog();
@@ -2157,6 +2168,46 @@ 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));
+                List<Report> updateReportList = new ArrayList<>();
+                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);
+                        }
+                        updateReportList.add(r);
+                    } 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);
+                        }
+                        updateReportList.add(r);
+                    } else if (auditorId.equals(auditorItem.getAuditorThird())) {
+                        //目前最多三层,第三个审批人审批后结束
+                        r.setProjectAuditState(1);
+                        r.setProjectAuditTime(LocalDateTime.now());
+                        r.setState(1);
+                        updateReportList.add(r);
+                    }
+                }
+                if (updateReportList.size() > 0) {
+                    updateBatchById(updateReportList);
+                }
             } else {
                 List<AuditWorkflowTimeSetting> settings = auditWorkflowTimeSettingMapper.selectList(
                         new QueryWrapper<AuditWorkflowTimeSetting>().eq("company_id", company.getId())

+ 19 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportAuditorSettingMapper.xml

@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="com.management.platform.mapper.ReportAuditorSettingMapper">
+
+    <!-- 通用查询映射结果 -->
+    <resultMap id="BaseResultMap" type="com.management.platform.entity.ReportAuditorSetting">
+        <id column="report_id" property="reportId" />
+        <result column="auditor_first" property="auditorFirst" />
+        <result column="auditor_sec" property="auditorSec" />
+        <result column="auditor_third" property="auditorThird" />
+        <result column="cc_userid" property="ccUserid" />
+    </resultMap>
+
+    <!-- 通用查询结果列 -->
+    <sql id="Base_Column_List">
+        report_id, auditor_first, auditor_sec, auditor_third, cc_userid
+    </sql>
+
+</mapper>