浏览代码

填报及时率接口修改

yurk 2 年之前
父节点
当前提交
89f88c37f5

+ 21 - 1
fhKeeper/formulahousekeeper/management-platform/src/main/java/com/management/platform/service/impl/ProjectServiceImpl.java

@@ -13,6 +13,7 @@ import com.management.platform.service.*;
 import com.management.platform.util.ExcelUtil;
 import com.management.platform.util.HttpRespMsg;
 import com.management.platform.util.ListUtil;
+import com.management.platform.util.WorkDayCalculateUtils;
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
 import org.apache.poi.ss.usermodel.CellType;
@@ -34,7 +35,10 @@ import javax.servlet.http.HttpServletResponse;
 import java.io.*;
 import java.math.BigDecimal;
 import java.sql.Timestamp;
-import java.text.*;
+import java.text.DateFormat;
+import java.text.DecimalFormat;
+import java.text.NumberFormat;
+import java.text.SimpleDateFormat;
 import java.time.Duration;
 import java.time.LocalDate;
 import java.time.LocalDateTime;
@@ -3090,8 +3094,16 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         DecimalFormat dft =  new DecimalFormat("0%");
         LocalDateTime sDate = LocalDate.parse(startDate).atTime(LocalTime.now());
         LocalDateTime eDate = LocalDate.parse(endDate).atTime(LocalTime.now());
+        List<LocalDateTime> dateTimeList = getDays(sDate, eDate);
         Duration duration=Duration.between(sDate,eDate);
+        //去掉非工作日
         long days = duration.toDays();
+        for (LocalDateTime localDateTime : dateTimeList) {
+            if(WorkDayCalculateUtils.isWorkDay(localDateTime.toLocalDate())){
+                days-=1;
+            }
+        }
+        System.out.println(days);
         Integer companyId= userMapper.selectById(request.getHeader("token")).getCompanyId();
         TimeType timeType = timeTypeMapper.selectById(companyId);
         String alertTime = timeType.getAlertTime();
@@ -3265,5 +3277,13 @@ public class ProjectServiceImpl extends ServiceImpl<ProjectMapper, Project> impl
         }
         return allList;
     }
+    private  List<LocalDateTime> getDays(LocalDateTime start, LocalDateTime end) {
+        List<LocalDateTime> result = new ArrayList<LocalDateTime>();
+        while (start.isBefore(end)) {
+            result.add(start.plusDays(1));
+            start=start.plusDays(1);
+        }
+        return result;
+    }
 
 }