| | |
| | | |
| | | |
| | | import com.gs.dingtalk.config.ResultMessage; |
| | | import com.gs.dingtalk.service.QwCheckinDayDataService; |
| | | import com.gs.dingtalk.service.QwHardwareCheckinDataService; |
| | | import com.gs.dingtalk.service.SendDingtalkService; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.springframework.web.bind.annotation.CrossOrigin; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | import org.springframework.web.bind.annotation.*; |
| | | |
| | | import java.time.LocalDate; |
| | | import java.time.ZoneId; |
| | | import java.time.format.DateTimeFormatter; |
| | | |
| | | @RestController |
| | | @RequestMapping("Numerical") |
| | |
| | | |
| | | |
| | | private final SendDingtalkService sendDingtalkService; |
| | | |
| | | private final QwCheckinDayDataService qwCheckinDayDataService; |
| | | |
| | | private final QwHardwareCheckinDataService qwHardwareCheckinDataService; |
| | | |
| | | @PostMapping("/chatSendMessage") |
| | | public ResultMessage chatSendMessage() { |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 同步企业微信打卡日报数据 |
| | | * @param startDate 开始日期,格式:yyyy-MM-dd |
| | | * @param endDate 结束日期,格式:yyyy-MM-dd |
| | | * @return 同步结果 |
| | | */ |
| | | @PostMapping("/syncCheckinDayData") |
| | | public ResultMessage syncCheckinDayData(@RequestParam String startDate, @RequestParam String endDate) { |
| | | try { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDate start = LocalDate.parse(startDate, formatter); |
| | | LocalDate end = LocalDate.parse(endDate, formatter); |
| | | |
| | | // 转换为Unix时间戳(当天0点) |
| | | ZoneId zoneId = ZoneId.of("Asia/Shanghai"); |
| | | long startTime = start.atStartOfDay(zoneId).toEpochSecond(); |
| | | long endTime = end.atStartOfDay(zoneId).toEpochSecond(); |
| | | |
| | | int totalInsert = 0; |
| | | // 日报接口starttime和endtime需相同,逐天同步 |
| | | for (long date = startTime; date <= endTime; date += 86400) { |
| | | int insertCount = qwCheckinDayDataService.syncDayData(date); |
| | | totalInsert += insertCount; |
| | | } |
| | | |
| | | return ResultMessage.ok(); |
| | | } catch (Exception e) { |
| | | return ResultMessage.error(e); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 同步企业微信设备打卡数据 |
| | | * @param startDate 开始日期,格式:yyyy-MM-dd |
| | | * @param endDate 结束日期,格式:yyyy-MM-dd |
| | | * @return 同步结果 |
| | | */ |
| | | @PostMapping("/syncHardwareCheckinData") |
| | | public ResultMessage syncHardwareCheckinData(@RequestParam String startDate, @RequestParam String endDate) { |
| | | try { |
| | | DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd"); |
| | | LocalDate start = LocalDate.parse(startDate, formatter); |
| | | LocalDate end = LocalDate.parse(endDate, formatter); |
| | | |
| | | // 转换为Unix时间戳 |
| | | ZoneId zoneId = ZoneId.of("Asia/Shanghai"); |
| | | long startTime = start.atStartOfDay(zoneId).toEpochSecond(); |
| | | // 结束时间为当天23:59:59 |
| | | long endTime = end.plusDays(1).atStartOfDay(zoneId).toEpochSecond() - 1; |
| | | |
| | | int insertCount = qwHardwareCheckinDataService.syncHardwareData(startTime, endTime); |
| | | |
| | | return ResultMessage.ok(); |
| | | } catch (Exception e) { |
| | | return ResultMessage.error(e); |
| | | } |
| | | } |
| | | |
| | | } |