QuYueTing преди 1 седмица
родител
ревизия
38a681c630

+ 3 - 2
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -1084,6 +1084,7 @@ public class ReportController {
                                         .setPicStr(picStr!=null?picStr[i]:null)
                                         .setCreateDate(localStartDate)
                                         .setCreatorId(subsUser.getId())
+                                        .setFillUserid(token)
                                         .setDeptId(subsUser.getDepartmentId())
                                         .setProjectAuditorId(projectAuditorId[i]);
                                 report.setProjectAuditState(0);
@@ -1587,8 +1588,8 @@ public class ReportController {
                     }
                 }
 
-                //HardCode:对于正北两家公司,校验填报工时不得少于考勤时长
-                if (company.getId() == 8138 || company.getId() == 7703) {
+                //HardCode:对于正北两家公司,校验填报工时不得少于考勤时长。(代填的不校验)
+                if ((company.getId() == 8138 || company.getId() == 7703) && (report.getFillUserid() == null || creatorId.equals(report.getFillUserid()))) {
                     if (company.getId() == 8138) {
                         //苏州正北, 用钉钉
                         List<UserDingdingTime> userDingdingTimes = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().eq("user_id", creatorId).eq("work_date", cDate));

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

@@ -73,6 +73,9 @@ public class UserDingdingTime extends Model<UserDingdingTime> {
     private Integer isOffiBusiness;
 
 
+    @TableField(exist = false)
+    private String name;
+    
     @Override
     protected Serializable pkVal() {
         return this.id;

+ 13 - 3
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/DingDingServiceImpl.java

@@ -2278,7 +2278,10 @@ public class DingDingServiceImpl implements DingDingService {
         List<String> ddIds = userList.stream().map(User::getDingdingUserid).collect(Collectors.toList());
         req.setUserIds(ddIds);
         req.setCheckDateFrom(startDate+ " 02:00:00");
-        req.setCheckDateTo(endDate+ " 23:59:59");
+        //考虑到可能加班到凌晨,需要设置第二天凌晨6点为下班时间
+        endDate = LocalDate.parse(endDate, DateTimeFormatter.ofPattern("yyyy-MM-dd")).plusDays(1).toString();
+        req.setCheckDateTo(endDate+ " 06:00:00");
+        System.out.println("请求考勤attendance/listRecord:startTime="+req.getCheckDateFrom()+", endTime="+req.getCheckDateTo());
         req.setIsI18n(false);
         OapiAttendanceListRecordResponse rsp = null;
         try {
@@ -2340,13 +2343,20 @@ public class DingDingServiceImpl implements DingDingService {
                         }
                         if (offDutyLatest != null) {
                             LocalDateTime oLt = LocalDateTime.ofEpochSecond(offDutyLatest.getUserCheckTime()/1000, 0, ZoneOffset.ofHours(8));
-                            timeItem.setEndTime(hmFormat.format(oLt));
+                            String preFix = "";
+                            if (onDutyEarleast != null) {
+                                //下班打卡时间在第二天的情况下,设置为次日
+                                if (oLt.toLocalDate().isAfter(check)) {
+                                    preFix = "次日";
+                                }
+                            }
+                            timeItem.setEndTime(preFix+hmFormat.format(oLt));
                             check=oLt.toLocalDate();
                         }
                         timeItem.setCompanyId(dingding.getCompanyId());
                         if (onDutyEarleast != null && offDutyLatest != null) {
                             //下班打卡时间在第二天的情况下设置为前一天的23:59
-                            if(offDutyLatest.getUserCheckTime() <onDutyEarleast.getUserCheckTime()){
+                            if(offDutyLatest.getUserCheckTime() < onDutyEarleast.getUserCheckTime()){
                                 LocalDateTime localDateTime = check.atTime(LocalTime.MAX);
                                 long timeInSeconds = localDateTime.toEpochSecond(ZoneOffset.UTC);
                                 onDutyEarleast.setUserCheckTime(timeInSeconds*1000);

+ 4 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectMainServiceImpl.java

@@ -47,7 +47,10 @@ public class ProjectMainServiceImpl extends ServiceImpl<ProjectMainMapper, Proje
         Integer companyId = userMapper.selectById(request.getHeader("token")).getCompanyId();
         projectMain.setCompanyId(companyId);
         ProjectCategory projectCategory = projectCategoryMapper.selectById(projectMain.getCategoryId());
-        projectMain.setCategoryName(projectCategory.getName());
+        if (projectCategory != null) {
+            projectMain.setCategoryName(projectCategory.getName());
+        }
+
         if(projectMain.getId()!=null){
             ProjectMain oldProject = projectMainMapper.selectById(projectMain.getId());
             Integer count = projectMainMapper.selectCount(new QueryWrapper<ProjectMain>().eq("company_id", projectMain.getCompanyId())

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

@@ -248,6 +248,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
     private CompanyDingdingMapper companyDingdingMapper;
     @Resource
     private SysRoleFunctionService sysRoleFunctionService;
+    private DingDingService dingDingService;
 
 
     //获取报告列表
@@ -2165,6 +2166,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 String name = (String)a.get("name");
                 String uid = (String)a.get("userId");
                 String corpwxUserid = (String)a.get("corpwxUserid");
+                String fillUserName = (String)a.get("fillUserName");
                 System.out.println("createDate=="+createDate + " name=="+name+" uid=="+uid+" corpwxUserid=="+corpwxUserid);
                 if (lastName == null || !(lastName.get("name").equals(name) && lastName.get("dateStr").equals(createDate))) {
                     lastName = new HashMap<String, Object>();
@@ -2172,6 +2174,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     lastName.put("name", name);
                     lastName.put("userId", uid);
                     lastName.put("corpwxUserid", corpwxUserid);
+                    lastName.put("fillUserName", fillUserName);
                     nameList.add(lastName);
                     userDailyReportList = new ArrayList<>();
                     lastName.put("data", userDailyReportList);
@@ -6460,6 +6463,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
             if(companyId == 7536){
                 titles.add("工单号");
                 titles.add("行号");
+                titles.add("协助部门");
             }
             titles.add(MessageUtils.message("entry.projectStage"));
             if(companyId==936){
@@ -6804,6 +6808,17 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 if(companyId == 7536){
                     item.add((String) map.get("extraField4"));
                     item.add((String) map.get("extraField5"));
+                    //日报部门与提交人不是同一部门,则为协助部门
+                    String creatorId = (String) map.get("creatorId");
+                    Optional<User> curUser = userList.stream().filter(u->u.getId().equals(creatorId)).findFirst();
+                    if (curUser.isPresent()) {
+                        Integer userDeptId = curUser.get().getDepartmentId();
+                        if(userDeptId != null && !userDeptId.equals(dept.getDepartmentId())){
+                            item.add("协助部门");
+                        } else {
+                            item.add("");
+                        }
+                    }
                 }
                 item.add(map.get("stageName")==null?"":(String) map.get("stageName"));
                 if(companyId==936){
@@ -11053,6 +11068,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         User operator = userMapper.selectById(request.getHeader("token"));
         Integer companyId = operator.getCompanyId();
         WxCorpInfo wxCorpInfo = wxCorpInfoMapper.selectOne(new LambdaQueryWrapper<WxCorpInfo>().eq(WxCorpInfo::getCompanyId, companyId));
+        CompanyDingding dingding = companyDingdingService.getOne(new QueryWrapper<CompanyDingding>().eq("company_id", companyId));
         List<Information> informationList = new ArrayList<>();
         LocalDate firstDay = LocalDate.parse(ymonth + "-01");
         LocalDate lastDay = firstDay.with(TemporalAdjusters.lastDayOfMonth());
@@ -11063,6 +11079,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 String curUserid = String.valueOf(e.get("userId"));
                 String date = String.valueOf(e.get("createDate"));
                 String userName = String.valueOf(e.get("name"));
+                String ddUserid = String.valueOf(e.get("dingdingUserId"));
                 information.setUserId(curUserid);
                 information.setTime(LocalDateTime.now());
                 information.setContent(date);
@@ -11101,6 +11118,10 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 if(wxCorpInfo!=null&&e.get("corpwxUserId")!=null){
                     wxCorpInfoService.sendWXCorpMsg(wxCorpInfo,String.valueOf(e.get("corpwxUserId")), reason, null, WxCorpInfoServiceImpl.TEXT_CARD_MSG_REPORT_ABNOEMAL);
                 }
+
+                if (dingding != null) {
+                    companyDingdingService.sendRejectReportMsg(companyId,date, "全部项目",  reason,operator.getName(), ddUserid);
+                }
             });
         }
         if(informationList.size()>0){
@@ -12109,6 +12130,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         List<User> manageUserList = new ArrayList<>();
         List<UserCorpwxTime> userCorpwxTimeList = new ArrayList<>();
         List<UserFvTime> userFvTimeList = new ArrayList<>();
+        List<UserDingdingTime> userDingdingTimeList = new ArrayList<>();
         if (timeType.getSyncCorpwxTime() == 1) {
             //获取考勤表记录
             if (canViewAll) {
@@ -12236,6 +12258,62 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     manageUserList.add(user);
                 }
             }
+        } else if (timeType.getSyncDingding() == 1) {
+            //获取user_dingding_time表的考勤记录
+            if (canViewAll) {
+                if (!StringUtils.isEmpty(userId)) {
+                    User findUser = userMapper.selectById(userId);
+                    if (findUser != null) {
+                        userDingdingTimeList = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().eq("company_id", companyId).eq("user_id", userId).between("work_date", firstDay, lastDay));
+                        manageUserList.add(findUser);
+                    }
+                } else  if (deptId != null) {
+                    //按部门过滤
+                    List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+                    List<Integer> allSubDeptIds = departmentService.getDeptIncludeSubDeptIds(deptId, allDeptList);
+                    manageUserList = userMapper.selectList(new QueryWrapper<User>().in("department_id", allSubDeptIds));
+                    if (manageUserList.size() > 0) {
+                        List<String> collect = manageUserList.stream().map(User::getId).collect(Collectors.toList());
+                        userDingdingTimeList = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().eq("company_id", companyId).in("user_id", collect).between("work_date", firstDay, lastDay));
+                    }
+                } else {
+                    userDingdingTimeList = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().eq("company_id", companyId).between("work_date", firstDay, lastDay));
+                    manageUserList = userMapper.selectList(new QueryWrapper<User>().eq("company_id", companyId));
+                }
+            } else {
+                //是否是部门负责人
+                List<Integer> allDeptIds = getAllVisibleDeptIdList(user, departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId)));
+                if (allDeptIds.size() > 0) {
+                    if (!StringUtils.isEmpty(userId)) {
+                        User findUser = userMapper.selectById(userId);
+                        if (findUser != null) {
+                            manageUserList.add(findUser);
+                        }
+                    } else if (deptId != null) {
+                        //按部门过滤
+                        if (allDeptIds.contains(deptId)) {
+                            List<Department> allDeptList = departmentMapper.selectList(new QueryWrapper<Department>().eq("company_id", companyId));
+                            List<Integer> allSubDeptIds = departmentService.getDeptIncludeSubDeptIds(deptId, allDeptList);
+                            manageUserList = userMapper.selectList(new QueryWrapper<User>().in("department_id", allSubDeptIds));
+                        }
+                    } else {
+                        //取部门的人员
+                        manageUserList = userMapper.selectList(new QueryWrapper<User>().in("department_id", allDeptIds));
+                    }
+                    //如果自己不在manageUserList中,加进去
+                    if (!manageUserList.stream().anyMatch(u -> u.getId().equals(user.getId()))) {
+                        manageUserList.add(user);
+                    }
+                    List<String> userIdList = manageUserList.stream().map(User::getId).collect(Collectors.toList());
+                    if (userIdList.size() > 0) {
+                        userDingdingTimeList = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().eq("company_id", companyId).in("user_id", userIdList).between("work_date", firstDay, lastDay));
+                    }
+                } else {
+                    //个人看自己的
+                    userDingdingTimeList = userDingdingTimeMapper.selectList(new QueryWrapper<UserDingdingTime>().eq("company_id", companyId).eq("user_id", user.getId()).between("work_date", firstDay, lastDay));
+                    manageUserList.add(user);
+                }
+            }
         }
         //去掉不提醒的人员
         for (int i=0;i<manageUserList.size();i++) {
@@ -12250,6 +12328,9 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                 } else if (timeType.getSyncFanwei() == 1) {
                     //从userFvTimeList中去掉
                     userFvTimeList.removeIf(userFvTime -> userFvTime.getUserId() != null && userFvTime.getUserId().equals(item.getId()));
+                } else if (timeType.getSyncDingding() == 1) {
+                    //从userFvTimeList中去掉
+                    userDingdingTimeList.removeIf(userDdTime -> userDdTime.getUserId() != null && userDdTime.getUserId().equals(item.getId()));
                 }
             }
         }
@@ -12260,7 +12341,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         int LEAVE_PROJECT_ID = 80333;
         if (canViewAll && StringUtils.isEmpty(userId) && deptId == null) {
             //查看全公司的
-            QueryWrapper<Report> reportQueryWrapper = new QueryWrapper<Report>().select("creator_id,create_date, sum(working_time) as working_time").eq("company_id", companyId).between("create_date", firstDay, lastDay).groupBy("creator_id,create_date");
+            QueryWrapper<Report> reportQueryWrapper = new QueryWrapper<Report>().select("fill_userid,creator_id,create_date, sum(working_time) as working_time").eq("company_id", companyId).ne("state", 2).between("create_date", firstDay, lastDay).groupBy("creator_id,create_date");
             if (companyId == HONGHUCompanyId) {
                 reportQueryWrapper.ne("project_id", LEAVE_PROJECT_ID);//泓浒,排除掉请假项目,请假是自动生成的,不计考勤工时
             }
@@ -12268,7 +12349,7 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
         } else if (manageUserList.size() > 0) {
             List<String> userIdList = manageUserList.stream().map(User::getId).collect(Collectors.toList());
             if (userIdList.size() > 0) {
-                QueryWrapper<Report> reportQueryWrapper = new QueryWrapper<Report>().select("creator_id,create_date, sum(working_time) as working_time").between("create_date", firstDay, lastDay).groupBy("creator_id,create_date");
+                QueryWrapper<Report> reportQueryWrapper = new QueryWrapper<Report>().select("fill_userid,creator_id,create_date, sum(working_time) as working_time").ne("state", 2).between("create_date", firstDay, lastDay).groupBy("creator_id,create_date");
                 if (userIdList.size() == 1) {
                     reportQueryWrapper.eq("creator_id", userIdList.get(0));
                     //按单个人匹配
@@ -12364,9 +12445,43 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                     }
                 }
             }
+        } else if (timeType.getSyncDingding() == 1) {
+            for (UserDingdingTime ddTime : userDingdingTimeList) {
+                boolean isMatch = true;
+                double reportTime = 0;
+                Optional<User> first = manageUserList.stream().filter(u -> u.getId().equals(ddTime.getUserId())).findFirst();
+                if (first.isPresent()) {
+                    User targetUser = first.get();
+                    for (Report report : reportList) {
+                        if (report.getCreatorId().equals(ddTime.getUserId()) && ddTime.getWorkDate().isEqual(report.getCreateDate())) {
+                            reportTime = report.getWorkingTime();
+                            //不一致
+                            if (Math.abs(ddTime.getWorkHours() - report.getWorkingTime()) > 0.01) {
+                                isMatch = false;
+                                ddTime.setName(targetUser.getName());
+                            }
+                            break;
+                        }
+                    }
+                    if (!isMatch) {
+                        Map<String, Object> map = new HashMap<>();
+                        map.put("userId", ddTime.getUserId());
+                        map.put("dingdingUserId", targetUser.getDingdingUserid());
+                        map.put("name", ddTime.getName());
+                        map.put("createDate", dateTimeFormatter.format(ddTime.getWorkDate()));
+                        map.put("workHours", ddTime.getWorkHours());
+                        map.put("reportTime", reportTime);
+                        resultList.add(map);
+                    }
+                }
+            }
         }
         //反向,检测有填报日报但是没有考勤的数据
         for (Report report : reportList) {
+            //代填的不校验
+            if (report.getFillUserid() != null && !report.getFillUserid().equals(report.getCreatorId())) {
+                continue;
+            }
             boolean hasCardTime = false;
             Optional<User> first = manageUserList.stream().filter(u -> u.getId().equals(report.getCreatorId())).findFirst();
             if (!first.isPresent()) {
@@ -12396,12 +12511,23 @@ public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> impleme
                         break;
                     }
                 }
+            } else if (timeType.getSyncDingding() == 1) {
+                for (UserDingdingTime ddTime : userDingdingTimeList) {
+                    //人员/日期匹配
+                    if (targetUser.getId().equals(ddTime.getUserId()) && ddTime.getWorkDate().isEqual(report.getCreateDate())) {
+                        if (ddTime.getWorkHours() > 0) {
+                            hasCardTime = true;
+                        }
+                        break;
+                    }
+                }
             }
 
             if (!hasCardTime) {
                 Map<String, Object> map = new HashMap<>();
                 map.put("userId", targetUser.getId());
                 map.put("corpwxUserId", targetUser.getCorpwxUserid());
+                map.put("dingdingUserId", targetUser.getDingdingUserid());
                 map.put("name", targetUser.getName());
                 map.put("createDate", dateTimeFormatter.format(report.getCreateDate()));
                 map.put("workHours", 0);

+ 2 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/mapper/ReportMapper.xml

@@ -651,7 +651,7 @@
     <!--新版获取待审核的列表,一次性获取全部 -->
     <select id="getAuditReportList" resultType="java.util.Map">
         SELECT a.id, user.id as userId,user.corpwx_userid as corpwxUserid, user.name, DATE_FORMAT(a.create_date, '%Y-%m-%d') as date, a.project_id as projectId, b.project_code AS projectCode, b.project_name AS project, a.working_time AS time, a.content, a.state, a.time_type as timeType,
-        a.cost, a.report_time_type as reportTimeType, a.start_time as startTime,
+        a.cost, a.report_time_type as reportTimeType, a.start_time as startTime, uf.name as fillUserName,
         a.end_time as endTime, b.incharger_id as inchargerId,dept.department_name as departmentName,
         a.creator_id as creatorId, d.name as subProjectName,d.code as subProjectCode,a.task_id as taskId, task.name as taskName, a.is_overtime as isOvertime,a.progress as progress,
         a.department_audit_state as departmentAuditState, a.stage, a.pic_str as picStr, multi_worktime as multiWorktime
@@ -661,6 +661,7 @@
         ,a.group_audit_state as groupAuditState,a.batch_id as batchId,a.extra_field1 as extraField1,a.extra_field2 as extraField2,a.extra_field3 as extraField3, a.batch_id as batchId,a.sap_service_id as sapServiceId, multi_degr_id as multiDegrId, a.extra_field4 as extraField4,a.extra_field5 as extraField5
         FROM report AS a
         left join user on user.id = a.creator_id
+        left join user uf on uf.id = a.fill_userid
         JOIN project AS b ON a.project_id=b.id
         left join sub_project as d on d.id = a.sub_project_id
         left join task on task.id = a.task_id

+ 4 - 2
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -1778,7 +1778,7 @@
           <el-alert style="position:absolute;bottom:0;z-index:10;" v-if="isFlag" :title="$t('message.loading')+'...'" type="success" center :closable="false" show-icon></el-alert>
           <el-alert style="position:absolute;bottom:0;z-index:10;" v-if="isMore" :title="$t('message.noMoreData')" type="success" center show-icon></el-alert>
         </el-tab-pane>
-        <el-tab-pane :label="$t('cardtimenotfull')" name="fourth" v-if="(user.timeType.syncCorpwxTime==1 || user.timeType.syncFanwei == 1) && user.companyId!=5978">
+        <el-tab-pane :label="$t('cardtimenotfull')" name="fourth" v-if="(user.timeType.syncCorpwxTime==1 || user.timeType.syncFanwei == 1 || user.timeType.syncDingding == 1) && user.companyId!=5978">
           <div class="selectworktime_export" style="margin-top:10px">
             <div class="selectworktime_export_l">
               <el-date-picker
@@ -9312,7 +9312,9 @@
                             this.$message({
                                 message: res.msg,
                                 type: 'success'
-                            })
+                            });
+                            this.notFullData = [];
+                            this.notFullOriginList = [];
                         }else{
                             this.$message({
                                 message: res.msg,

+ 12 - 0
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/dailyReportReview.vue

@@ -251,6 +251,18 @@
                       <span v-for="(item, index) in scope.row.data" style="margin-right:10px;" ><template v-if="index==0 || (index>0 && (scope.row.data[index-1].content != item.content))"><b>{{item.project}}</b>{{ ':'+item.content }}</template></span>
                   </template>
               </el-table-column>
+              <el-table-column label="代填人" v-if="user.companyId == 8138 || user.companyId == 7703" width="120">
+                  <template slot-scope="scope">
+                      <div>
+                          <span v-if="user.userNameNeedTranslate == '1'">
+                              <TranslationOpenDataText type='userName' :openid='scope.row.fillUserName'></TranslationOpenDataText>
+                          </span>
+                          <span v-else>
+                              {{scope.row.fillUserName}}
+                          </span>
+                      </div>
+                  </template>
+              </el-table-column>
               <el-table-column prop="state" :label="$t('state.states')" sortable width="200">
                   <template slot-scope="scope">
                       <span v-if="scope.row.state == 0" style="color:#DAA520;">