|
@@ -19,10 +19,12 @@ import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.time.Duration;
|
|
|
import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
import java.time.ZoneOffset;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.temporal.ChronoUnit;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
@@ -191,6 +193,40 @@ public class DingDingController {
|
|
|
return new HttpRespMsg();
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping("/syncCompCardAndLeaveTime")
|
|
|
+ public HttpRespMsg syncCompCardAndLeaveTime(Integer companyId, String startDate, String endDate) {
|
|
|
+ HttpRespMsg msg = new HttpRespMsg();
|
|
|
+ DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd");
|
|
|
+ LocalDate sDate = LocalDate.parse(startDate, dtf);
|
|
|
+ LocalDate eDate = LocalDate.parse(endDate, dtf);
|
|
|
+ //计算sDate和eDate之间的间隔天数
|
|
|
+
|
|
|
+ if (ChronoUnit.DAYS.between(sDate, eDate) > 31) {
|
|
|
+ msg.setError("日期间隔不得超过31天");
|
|
|
+ return msg;
|
|
|
+ }
|
|
|
+ //时间跨度超过7天需要分批执行
|
|
|
+ if (ChronoUnit.DAYS.between(sDate, eDate) > 6) {
|
|
|
+ LocalDate fromDate = sDate;
|
|
|
+ LocalDate toDate = null;
|
|
|
+ while (fromDate.isBefore(eDate)) {
|
|
|
+ toDate = fromDate.plusDays(6);
|
|
|
+ if (toDate.isAfter(eDate)) {
|
|
|
+ toDate = eDate;
|
|
|
+ }
|
|
|
+ dingDingService.syncLeaveTime(companyId, null, dtf.format(fromDate), dtf.format(toDate));
|
|
|
+ dingDingService.syncCardTime(companyId, null, dtf.format(fromDate), dtf.format(toDate));
|
|
|
+ fromDate = toDate.plusDays(1);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ dingDingService.syncLeaveTime(companyId, null, startDate, endDate);
|
|
|
+ dingDingService.syncCardTime(companyId, null, startDate, endDate);
|
|
|
+ }
|
|
|
+
|
|
|
+ return new HttpRespMsg();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
@RequestMapping("/refreshUserCardTime")
|
|
|
public HttpRespMsg refreshUserCardTime(Integer companyId, String userId, String date) {
|
|
|
//同步请假数据
|