钉钉考勤

This commit is contained in:
张松
2025-12-03 10:26:32 +08:00
parent 1fd171da65
commit 03fad012d0

View File

@@ -68,24 +68,46 @@ public class AttendanceServiceImpl implements AttendanceService {
@Override @Override
public Map<String, Object> detail(Long shopId, String userId, String startTime, String endTime, Integer weekNum) { public Map<String, Object> detail(Long shopId, String userId, String startTime, String endTime, Integer weekNum) {
ArrayList<DingAttendanceStatsVO> listed = list(shopId, null, startTime, endTime, userId); ArrayList<DingAttendanceStatsVO> listed = list(shopId, null, startTime, endTime, userId);
ArrayList<Map<String, Object>> weekList = new ArrayList<>(); ArrayList<Map<String, Object>> weekList = new ArrayList<>();
DateTime dateTime = StrUtil.isBlank(endTime) ? DateUtil.date() : DateUtil.parse(endTime);
int start = DateUtil.dayOfMonth(StrUtil.isBlank(startTime) ? DateUtil.beginOfMonth(dateTime) : DateUtil.parse(startTime)); // 结束时间:默认今天
int end = DateUtil.dayOfMonth(dateTime); DateTime endDate = StrUtil.isBlank(endTime)
for (int i = start; i <= end; i++) { ? DateUtil.date()
DateTime date = DateUtil.offsetDay(StrUtil.isBlank(startTime) ? DateUtil.beginOfMonth(dateTime) : DateUtil.parse(startTime), i - 1); : DateUtil.parse(endTime);
String week = formatWeek(date);
weekList.add(new HashMap<>(){{ // 开始时间默认当月1号
put("week", week); DateTime startDate = StrUtil.isBlank(startTime)
put("date", date); ? DateUtil.beginOfMonth(endDate)
}}); : DateUtil.parse(startTime);
// 若开始时间 > 结束时间,交换,避免死循环
if (startDate.after(endDate)) {
DateTime temp = startDate;
startDate = endDate;
endDate = temp;
} }
// 按天递增循环(跨月完全没问题)
DateTime current = startDate;
while (!current.after(endDate)) {
String week = formatWeek(current);
Map<String, Object> map = new HashMap<>();
map.put("week", week);
map.put("date", current);
weekList.add(map);
// 下一天
current = DateUtil.offsetDay(current, 1);
}
if (listed.isEmpty()) { if (listed.isEmpty()) {
return new HashMap<String, Object>() {{ return new HashMap<String, Object>() {{
put("attendanceSummary", null); put("attendanceSummary", null);
put("weekList", weekList); put("weekList", weekList);
put("statusList", null); put("statusList", null);
@@ -93,7 +115,7 @@ public class AttendanceServiceImpl implements AttendanceService {
} }
ShopConfig config = shopConfigService.getById(shopId); ShopConfig config = shopConfigService.getById(shopId);
if (config == null || StrUtil.isBlank(config.getDingAppSecret())) { if (config == null || StrUtil.isBlank(config.getDingAppSecret())) {
return new HashMap<String, Object>() {{ return new HashMap<String, Object>() {{
put("attendanceSummary", null); put("attendanceSummary", null);
put("weekList", weekList); put("weekList", weekList);
put("statusList", null); put("statusList", null);