瀏覽代碼

批量下载重出吃力

anderx 2 年之前
父節點
當前提交
1495e64a2b

+ 29 - 3
ruoyi-system/src/main/java/com/ruoyi/project/service/impl/ProjectStaffRecordServiceImpl.java

@@ -152,6 +152,7 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
     @Override
     public AjaxResult myDurationMonth(Long id) {
         LoginUser loginUser = SecurityUtils.getLoginUser();
+        ProjectTask projectTask = projectTaskMapper.selectByPrimaryKey(id);
         BigDecimal maxDuration= new BigDecimal(loginUser.getUser().getDept().getMaxDuration());
         String  date=DateUtils.getDate();
         Long aid=loginUser.getUserId();
@@ -159,20 +160,27 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         supplementMyMonthDays(myMonthDays);
         for (MyMonthDays myMonthDay : myMonthDays) {
             DateUtils.getWeeks(myMonthDay.getDates());
-//            0 =未到时限 1=满工时,2=未打卡,3=未满工时
-            if (compareTo(date,myMonthDay.getDates())){
+//            0 =未到时限 1=满工时,2=未打卡,3=未满工时,4=不属于打卡区间
+            if (compareTo(projectTask.getStartTime(),myMonthDay.getDates(),0)||compareTo(projectTask.getEndTime(),myMonthDay.getDates(),1)){
+                myMonthDay.setStatus(4);
+                myMonthDay.setDuration("0");
+            }else if (compareTo(date,myMonthDay.getDates())){
                 myMonthDay.setStatus(0);
             }else if (myMonthDay.getDuration().equals("0")) {
                 myMonthDay.setStatus(2);
             }else if (new BigDecimal(myMonthDay.getDuration()).compareTo(maxDuration)<0){
                 myMonthDay.setStatus(3);
-            }else if (new BigDecimal(myMonthDay.getDuration()).compareTo(maxDuration)==0){
+            }else if (new BigDecimal(myMonthDay.getDuration()).compareTo(maxDuration)>=0){
                 myMonthDay.setStatus(1);
+            }else {
+                myMonthDay.setStatus(5);
             }
         }
         return AjaxResult.success(myMonthDays);
     }
 
+
+
     @Override
     public AjaxResult recordDetails(Long id) {
         return AjaxResult.success(projectStaffRecordMapper.selectDetailsById(id));
@@ -259,6 +267,24 @@ public class ProjectStaffRecordServiceImpl implements ProjectStaffRecordService
         }
     }
 
+    /**
+     *
+     * @param startTime\endTime 项目开始时间结束时间
+     * @param dates   打卡时间
+     * @param type  0=小于开始判定,1=大于结束判定
+     * @return
+     */
+    private boolean compareTo(Date startTime, String dates,int type) {
+        long time = startTime.getTime();
+        long time2 = DateUtils.parseDate(dates).getTime();
+        if (type==0){
+            if (time>time2)return true;
+        }else {
+            if (time<time2)return true;
+        }
+        return false;
+    }
+
     private void supplementMyMonthDays(List<MyMonthDays> myMonthDays) {
         List<Map<String,Object>> monthDays = getMonthDays();
         for ( Map<String,Object> map : monthDays) {