Browse Source

代填日报不检查无考勤的情况

seyason 2 years ago
parent
commit
f9b332dde3

+ 85 - 57
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -71,6 +71,8 @@ public class ReportController {
     private ProjectMapper projectMapper;
     @Resource
     private SysFunctionMapper sysFunctionMapper;
+    @Resource
+    private UserCorpwxTimeMapper userCorpwxTimeMapper;
 
 
 
@@ -273,47 +275,47 @@ public class ReportController {
         }
 
 
-        //检查项目是否可填报
+        //检查项目是否可填报; 修改为不校验项目,前端加载的项目已经过滤掉了完成和撤销的
         List<Integer> integers = Arrays.asList(projectId);
         List<Project> projectList = projectMapper.selectList(new QueryWrapper<Project>().in("id", integers));
-        for (int i=0;i<projectId.length; i++) {
-            int pid = projectId[i];
-            Optional<Project> findP = projectList.stream().filter(p->p.getId().equals(pid)).findFirst();
-            if (findP.isPresent()) {
-                Project curP = findP.get();
-                if (!createDate[i].contains("@")) {
-                    if (curP.getStatus() == 2) {
-                        HttpRespMsg msg = new HttpRespMsg();
-                        //msg.setError("项目["+curP.getProjectName()+"]已完成。");
-                        msg.setError(MessageUtils.message("project.complete",curP.getProjectName()));
-                        return msg;
-                    }
-                    if (curP.getStatus() == 3) {
-                        HttpRespMsg msg = new HttpRespMsg();
-                        //msg.setError("项目["+curP.getProjectName()+"]已撤销。");
-                        msg.setError(MessageUtils.message("project.revoke",curP.getProjectName()));
-                        return msg;
-                    }
-                } else {
-                    //批量填报(含代填)
-                    String[] dateArr = createDate[i].split("@");
-                    for (String curDate : dateArr) {
-                        if (curP.getStatus() == 2) {
-                            HttpRespMsg msg = new HttpRespMsg();
-                            //msg.setError("项目["+curP.getProjectName()+"]已完成。");
-                            msg.setError(MessageUtils.message("project.complete",curP.getProjectName()));
-                            return msg;
-                        }
-                        if (curP.getStatus() == 3) {
-                            HttpRespMsg msg = new HttpRespMsg();
-                            //msg.setError("项目["+curP.getProjectName()+"]已撤销。");
-                            msg.setError(MessageUtils.message("project.revoke",curP.getProjectName()));
-                            return msg;
-                        }
-                    }
-                }
-            }
-        }
+//        for (int i=0;i<projectId.length; i++) {
+//            int pid = projectId[i];
+//            Optional<Project> findP = projectList.stream().filter(p->p.getId().equals(pid)).findFirst();
+//            if (findP.isPresent()) {
+//                Project curP = findP.get();
+//                if (!createDate[i].contains("@")) {
+//                    if (curP.getStatus() == 2) {
+//                        HttpRespMsg msg = new HttpRespMsg();
+//                        //msg.setError("项目["+curP.getProjectName()+"]已完成。");
+//                        msg.setError(MessageUtils.message("project.complete",curP.getProjectName()));
+//                        return msg;
+//                    }
+//                    if (curP.getStatus() == 3) {
+//                        HttpRespMsg msg = new HttpRespMsg();
+//                        //msg.setError("项目["+curP.getProjectName()+"]已撤销。");
+//                        msg.setError(MessageUtils.message("project.revoke",curP.getProjectName()));
+//                        return msg;
+//                    }
+//                } else {
+//                    //批量填报(含代填)
+//                    String[] dateArr = createDate[i].split("@");
+//                    for (String curDate : dateArr) {
+//                        if (curP.getStatus() == 2) {
+//                            HttpRespMsg msg = new HttpRespMsg();
+//                            //msg.setError("项目["+curP.getProjectName()+"]已完成。");
+//                            msg.setError(MessageUtils.message("project.complete",curP.getProjectName()));
+//                            return msg;
+//                        }
+//                        if (curP.getStatus() == 3) {
+//                            HttpRespMsg msg = new HttpRespMsg();
+//                            //msg.setError("项目["+curP.getProjectName()+"]已撤销。");
+//                            msg.setError(MessageUtils.message("project.revoke",curP.getProjectName()));
+//                            return msg;
+//                        }
+//                    }
+//                }
+//            }
+//        }
         TimeType comTimeType = timeTypeMapper.selectById(user.getCompanyId());
         List<ReportAuditorSetting> auditorSettingList = null;
         if (comTimeType.getReportAuditType() == 3) {
@@ -1015,28 +1017,54 @@ public class ReportController {
                                 return msg;
                             }
                         }
-                    } else {
-                        //按周填报时不校验已填的工时日报了
-//                        List<LocalDate> collect = oldReportList.stream().map(Report::getCreateDate).collect(Collectors.toList());
-//                        for (Report report : reportList) {
-//                            if (report.getId() == null) {
-//                                if (collect.stream().anyMatch(oldDate->oldDate.isEqual(report.getCreateDate()))) {
-//                                    sb.append(mdFormatter.format(report.getCreateDate())).append(",");
-//                                }
-//                            }
-//                        }
-
-//                        String s = sb.toString();
-//                        if (s.length() > 0) {
-//                            s = s.substring(0, s.length() -1);
-//                            HttpRespMsg msg = new HttpRespMsg();
-//                            msg.setError("已存在填写日报: " + s+", 请先删除后再填报。");
-//                            return msg;
-//                        }
                     }
                 }
             }
         }
+        if (createDate[0].contains("@") && targetUserList == null) {
+            //个人批量填报,判断是否需要考勤校验
+            if (comTimeType.getSyncCorpwxTime() == 1) {
+                String[] dateArr = createDate[0].split("@");
+                List<UserCorpwxTime> cardTimeList = userCorpwxTimeMapper.selectList(new QueryWrapper<UserCorpwxTime>().eq("corpwx_userid", user.getCorpwxUserid()).between("create_date", dateArr[0], dateArr[1]));
+                //考勤记录不能为空或时长为0
+                if (comTimeType.getNotAllowedNoAttendance() == 1) {
+                    String str = "";
+                    for (Report r : reportList) {
+                        Optional<UserCorpwxTime> first = cardTimeList.stream().filter(card -> card.getCreateDate().isEqual(r.getCreateDate())).findFirst();
+                        if (first.isPresent()) {
+                            if (first.get().getWorkHours() == 0) {
+                                str += dtf.format(r.getCreateDate()) + ",";
+                            }
+                        } else {
+                            str += dtf.format(r.getCreateDate()) + ",";
+                        }
+                    }
+                    //有无考勤的日期
+                    if (str.length() > 0) {
+                        str = str.substring(0, str.length()-1);
+                        HttpRespMsg msg = new HttpRespMsg();
+                        msg.setError(MessageUtils.message("report.lackCardTime", str));
+                        return msg;
+                    }
+                }
+                String str = "";
+                for (Report r : reportList) {
+                    Optional<UserCorpwxTime> first = cardTimeList.stream().filter(card -> card.getCreateDate().isEqual(r.getCreateDate())).findFirst();
+                    if (first.isPresent()) {
+                        double cardTime = first.get().getWorkHours();
+                        if (r.getWorkingTime() > cardTime) {
+                            str += dtf.format(r.getCreateDate()) + ",";
+                        }
+                    }
+                }
+                if (str.length() > 0) {
+                    str = str.substring(0, str.length()-1);
+                    HttpRespMsg msg = new HttpRespMsg();
+                    msg.setError(MessageUtils.message("report.lackCardTime", str));
+                    return msg;
+                }
+            }
+        }
         return reportService.editReport(reportList, createDate.length > 0 ? createDate[0] : null, targetUserList, hourCost, user.getCompanyId());
     }
 

File diff suppressed because it is too large
+ 716 - 714
fhKeeper/formulahousekeeper/management-platform/src/main/resources/i18n/messages.properties


+ 2 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/resources/i18n/messages_en_US.properties

@@ -321,6 +321,8 @@ report.hourAll=You participated in {0} projects last week with a total of {1} ho
 report.dailyReject=The {1} project in the daily report you filled in by {0} was rejected by [{2}]. Reason: {3}
 report.reportApp=Daily report approved
 report.hourReportNoFilled=Your work hour report for {0} has not been completed.
+report.lackCardTime=Lack attendance record: {0}
+report.timeReachLimitError=Report working time cannot be larger than attendance time: {0}
 #\u6A21\u677F\u76F8\u5173
 Template.subProject=subproject
 Template.AlreadyExists=The template name already exists.

+ 0 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/resources/i18n/messages_zh_CN.properties

@@ -1 +0,0 @@
-user.notExists=用户不存在

+ 17 - 12
fhKeeper/formulahousekeeper/timesheet/src/views/workReport/daily.vue

@@ -352,8 +352,9 @@
                     <span v-if="reportTimeType.type == 3">{{$t('time.hour')}}</span>
 
                     <span v-if="workForm.time">{{$t('other.attendancePunch')}}: {{workForm.time.startTime}}-{{workForm.time.endTime}}, {{workForm.time.workHours}}{{$t('time.hour')}}</span>
-                    <span v-if="(user.timeType.syncDingding==1 || user.timeType.syncCorpwxTime==1)&&!workForm.time" >{{$t('other.noAttendanceRecord')}}</span>
-                    <el-button type="default" style="margin-left:5px;" size="mini" :loading="syncTimeLoading" v-if="user.timeType.syncCorpwxTime==1 && (workForm.createDate == today || (!workForm.time))" icon="el-icon-refresh" @click="refreshWXCardTime(workForm.createDate)"></el-button>
+                    <!--批量填报和批量代填不显示考勤记录-->
+                    <span v-if="!isBatch && (user.timeType.syncDingding==1 || user.timeType.syncCorpwxTime==1)&&!workForm.time" >{{$t('other.noAttendanceRecord')}}</span>
+                    <el-button type="default" style="margin-left:5px;" size="mini" :loading="syncTimeLoading" v-if="!isBatch && user.timeType.syncCorpwxTime==1 && (workForm.createDate == today || (!workForm.time))" icon="el-icon-refresh" @click="refreshWXCardTime(workForm.createDate)"></el-button>
                 </el-form-item>
                 <!-- 000000 -->
                 <div v-for="(domain, index) in workForm.domains" :key="domain.id" :style="index>0?'margin-top:10px;':''">
@@ -1952,6 +1953,7 @@
                 // console.log('test',this.depData,this.data[0].membCount,this.reportList.length);
             },
             refreshWXCardTime(workdate) {
+                if (workdate) return;
                 this.syncTimeLoading = true;
                 this.http.post('/user-corpwx-time/getPunchRecordBySelf',{
                     date: workdate,
@@ -5707,24 +5709,27 @@
                         for (var t=0;t<this.workForm.domains.length; t++) {
                             totalTime += parseFloat(this.workForm.domains[t].workingTime);
                         }
-                        
-                        if(this.user.timeType.notAllowedNoAttendance == 1){
-                            if (this.workForm.time){
-                                if (this.workForm.time.workHours == 0){
+                        //批量填报不校验考勤时长,交给后台校验
+                        if (!isBatch) {
+                            if(this.user.timeType.notAllowedNoAttendance == 1){
+                                if (this.workForm.time){
+                                    if (this.workForm.time.workHours == 0){
+                                        this.$message({
+                                            message: this.$t('wu-kao-qin-ji-lu-bu-ke-tian-bao'),
+                                            type: 'error'
+                                        })
+                                        return
+                                    }
+                                }else{
                                     this.$message({
                                         message: this.$t('wu-kao-qin-ji-lu-bu-ke-tian-bao'),
                                         type: 'error'
                                     })
                                     return
                                 }
-                            }else{
-                                this.$message({
-                                    message: this.$t('wu-kao-qin-ji-lu-bu-ke-tian-bao'),
-                                    type: 'error'
-                                })
-                                return
                             }
                         }
+                        
 
                         if (this.reportTimeType.type == 1 && this.workForm.time) {
                             if (this.workForm.time.workHours && totalTime > parseFloat(this.workForm.time.workHours)) {