Browse Source

针对明夷进行考勤同步获取考试时长

seyason 1 year ago
parent
commit
d4a8ef780e

+ 13 - 0
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/ReportController.java

@@ -415,6 +415,19 @@ public class ReportController {
                     }
                 }
             }
+            //任务分组和阶段必填
+            if (company.getPackageEngineering() == 0 && company.getId() == 3917) {
+                if (stage == null) {
+                    stage = new String[projectId.length];
+                }
+                for (int i=0;i<projectId.length; i++) {
+                    if (stage[i] == null || stage[i].trim().length() == 0 || stage[i].equals("-")) {
+                        HttpRespMsg msg = new HttpRespMsg();
+                        msg.setError("请选择任务分组和阶段");
+                        return msg;
+                    }
+                }
+            }
         }
 
         //检查项目是否可填报; 修改为不校验项目,前端加载的项目已经过滤掉了完成和撤销的

+ 26 - 8
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/controller/UserFvTimeController.java

@@ -13,6 +13,7 @@ import com.management.platform.service.LeaveSheetService;
 import com.management.platform.service.UserFvTimeService;
 import com.management.platform.util.DockWithMLD;
 import com.management.platform.util.HttpRespMsg;
+import com.management.platform.util.WorkDayCalculateUtils;
 import org.springframework.http.*;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
@@ -29,10 +30,7 @@ import java.time.LocalDate;
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.time.format.DateTimeFormatter;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
-import java.util.Optional;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -62,7 +60,7 @@ public class UserFvTimeController {
     @Resource
     private RestTemplate restTemplate;
 
-    private DecimalFormat df = new DecimalFormat("#.0");
+    private DecimalFormat df = new DecimalFormat("#0.0");
 
     @RequestMapping("/get")
     public HttpRespMsg get(){
@@ -377,21 +375,41 @@ public class UserFvTimeController {
             return httpRespMsg;
         }
         User user = userMapper.selectById(request.getHeader("token"));
+        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         List<UserFvTime> timeList = userFvTimeService.list(new QueryWrapper<UserFvTime>().between("work_date", startDate, endDate).eq("company_id", user.getCompanyId()).eq("user_id", user.getId()));
         double sum = timeList.stream().mapToDouble(UserFvTime::getWorkHours).sum();
-        httpRespMsg.setData(df.format(sum));
+        int workDayCount = WorkDayCalculateUtils.getWorkDaysCountInRange(startDate, endDate, timeType.getIncludeWeekends());
+        HashMap map = new HashMap();
+        map.put("workHours", df.format(sum));
+        map.put("workDayCount", workDayCount);
+        if (workDayCount == 0) {
+            map.put("avgWorkDayHours", 0);
+        } else {
+            map.put("avgWorkDayHours", df.format(sum / workDayCount));
+        }
+        httpRespMsg.setData(map);
         return httpRespMsg;
     }
 
     @RequestMapping("/getMinYiWorkHour")
     public HttpRespMsg getMinYiWorkHour(HttpServletRequest request, String startDate,String endDate){
         HttpRespMsg httpRespMsg=new HttpRespMsg();
-        DecimalFormat df = new DecimalFormat("#.0");
+        DecimalFormat df = new DecimalFormat("#0.0");
         User user = userMapper.selectById(request.getHeader("token"));
+        TimeType timeType = timeTypeMapper.selectById(user.getCompanyId());
         List<UserFvTime> userFvTimeList = userFvTimeService.list(new QueryWrapper<UserFvTime>().between("work_date", startDate, endDate).eq("company_id", user.getCompanyId()).eq("user_id", user.getId()));
         double sum=0;
         sum = userFvTimeList.stream().mapToDouble(UserFvTime::getWorkHours).sum();
-        httpRespMsg.setData(df.format(sum));
+        int workDayCount = WorkDayCalculateUtils.getWorkDaysCountInRange(startDate, endDate, timeType.getIncludeWeekends());
+        HashMap map = new HashMap();
+        map.put("workHours", df.format(sum));
+        map.put("workDayCount", workDayCount);
+        if (workDayCount == 0) {
+            map.put("avgWorkDayHours", 0);
+        } else {
+            map.put("avgWorkDayHours", df.format(sum / workDayCount));
+        }
+        httpRespMsg.setData(map);
         return httpRespMsg;
     }
 

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

@@ -350,21 +350,21 @@
                         @change="changeMonth()" @blur="iptBlur(reportTimeType.type)" :clearable="false" :placeholder="$t('defaultText.selectWorkDate')" :disabled="isDisable"></el-date-picker>
                         <div v-if="falsss" style="display: inline-block;margin-left:10px">{{jsDay}} {{$t('time.day')}}, {{jsTime}} {{$t('time.hour')}}</div>
                         <div v-if="isBatch!=0" style="display: inline-block;margin-left:10px">{{jsDay}} {{$t('time.day')}}</div>
-                        <span v-if="reportTimeType.type == 3" style="margin-left:10px;">{{isBatch==0? $t('other.total'):$t('weekDay.daily')}}{{$t('time.duration')}}:</span>
-                        <el-input-number :disabled="(!canEdit || user.timeType.lockWorktime) && !isWeekend" v-if="reportTimeType.type == 3" style="margin-left:5px;" @change="changeAllTime"
+                        <span v-if="reportTimeType.type == 3 && user.company.companyName != mingyiName" style="margin-left:10px;">{{isBatch==0? $t('other.total'):$t('weekDay.daily')}}{{$t('time.duration')}}:</span>
+                        <el-input-number :disabled="(!canEdit || user.timeType.lockWorktime) && !isWeekend" v-if="reportTimeType.type == 3&& user.company.companyName != mingyiName" style="margin-left:5px;" @change="changeAllTime"
                             v-model="reportTimeType.allday" :precision="1" :step="0.5" :max="12" :min="0.5"></el-input-number>
-                        <span v-if="reportTimeType.type == 3">{{$t('time.hour')}}</span>
-                        <span v-if="isBatch">, {{$t('other.fillInTheTotal')}} {{jsTime.toFixed(1)}} {{$t('time.hour')}}</span>
+                        <span v-if="reportTimeType.type == 3 && user.company.companyName != mingyiName">{{$t('time.hour')}}</span>
+                        <span v-if="isBatch && user.company.companyName != mingyiName">, {{$t('other.fillInTheTotal')}} {{jsTime.toFixed(1)}} {{$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="!isBatch && (user.timeType.syncDingding==1 || user.timeType.syncCorpwxTime==1)&&!workForm.time" >{{$t('other.noAttendanceRecord')}}</span>
-                        <span v-if="isBatch && user.company.companyName==='明夷'">{{',考勤时长'}}:{{this.workTimeForMinYi}}{{$t('time.hour')}}</span>
+                        <span v-if="isBatch && user.company.companyName === mingyiName">{{',考勤时长'}}:{{this.workTimeForMinYi}}{{$t('time.hour')}}</span>
                         <el-button type="default" style="margin-left:5px;" size="small" :loading="syncTimeLoading" 
                         v-if="!isBatch && user.timeType.syncCorpwxTime==1" icon="el-icon-refresh" 
                                 @click="refreshWXCardTime(workForm.createDate)"></el-button>
                         <el-button type="default" style="margin-left:5px;" size="small" :loading="syncTimeLoading" 
-                        v-if="isBatch && user.company.companyName==='明夷'" icon="el-icon-refresh" 
+                        v-if="isBatch && user.company.companyName === mingyiName" icon="el-icon-refresh" 
                                 @click="refreshAttendance(workForm.createDate)"></el-button>
                         <!-- AI智能填报 -->
                         <el-button type="primary" @click="getAIReport()" v-if="!hasWrittenReport" style="margin-left:5px;" >智能填报</el-button>
@@ -472,10 +472,10 @@
                                 <el-option v-for="item in timeBasecostList" :label="item.name" :value="item.id" :key="item.id"></el-option>
                             </el-select>
                         </el-form-item>
-                        <el-form-item :label="$t('lable.taskGrouping')" v-if="user.company.packageProject == 1" :prop="'domains[' + index + '].stage'"
-                                         :rules="{ required: true, message: '请选择任务分组和阶段', trigger: ['change','blur'] }" >
+                        <el-form-item :label="$t('lable.taskGrouping')" v-if="user.company.packageProject == 1"
+                                          >
                             <!-- 任务分组 -->
-                            <el-select v-model="domain.groupId" :placeholder="$t('defaultText.pleaseSelectaTaskGroup')" style="width:200px;" clearable="true" 
+                            <span style="color:red;">*</span><el-select v-model="domain.groupId" :placeholder="$t('defaultText.pleaseSelectaTaskGroup')" style="width:200px;" clearable="true" 
                             :disabled="workForm.domains.length==0?true:(workForm.domains[index].state>=2?false:true)" @change="getGroupStages(domain, index)">
                                 <el-option v-for="item in domain.taskGroups" :key="item.id" :label="item.name" :value="item.id"></el-option>
                             </el-select>
@@ -1830,6 +1830,8 @@
         },
         data() {
             return {
+                mingyiName : '南京火石演示科技公司',
+                // mingyiName : '明夷',
                 modItemDataId: null,
                 modImportTime: null,
                 modImportUserId: null,
@@ -2454,7 +2456,6 @@
             },
              refreshAttendance(workdate) {
                  if (!workdate) return;
-                 if(this.workTimeForMinYi>0) return;
                 this.syncTimeLoading = true;
                 this.http.post('/user-fv-time/syncAttendanceForMingYi',{
                     startDate: workdate[0],
@@ -2462,7 +2463,9 @@
                 },res => {
                     this.syncTimeLoading = false;
                     if(res.code == 'ok'){
-                        this.workTimeForMinYi= res.data;
+                        this.workTimeForMinYi = parseFloat(res.data.workHours);
+                        this.reportTimeType.allday = parseFloat(res.data.avgWorkDayHours);
+                        this.totalReportHours = this.workTimeForMinYi;
                     }else {
                         this.$message({
                             message: res.msg,
@@ -2992,7 +2995,9 @@
                 },
                 res => {
                     if (res.code == "ok") {
-                        this.workTimeForMinYi = res.data
+                        this.workTimeForMinYi = parseFloat(res.data.workHours);
+                        this.reportTimeType.allday = parseFloat(res.data.avgWorkDayHours);
+                        this.totalReportHours = this.workTimeForMinYi;
                     } else {
                         this.$message({
                             message: res.msg,
@@ -3008,8 +3013,6 @@
                     });
                     }
                 );
-                var sl = this.workForm.domains
-                this.chuji(i)
             },
             chuji(i) {
                 if(i == 0) {