钉钉考勤
This commit is contained in:
@@ -68,24 +68,46 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
|
||||
@Override
|
||||
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<>();
|
||||
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);
|
||||
for (int i = start; i <= end; i++) {
|
||||
DateTime date = DateUtil.offsetDay(StrUtil.isBlank(startTime) ? DateUtil.beginOfMonth(dateTime) : DateUtil.parse(startTime), i - 1);
|
||||
String week = formatWeek(date);
|
||||
weekList.add(new HashMap<>(){{
|
||||
put("week", week);
|
||||
put("date", date);
|
||||
}});
|
||||
// 结束时间:默认今天
|
||||
DateTime endDate = StrUtil.isBlank(endTime)
|
||||
? DateUtil.date()
|
||||
: DateUtil.parse(endTime);
|
||||
|
||||
// 开始时间:默认当月1号
|
||||
DateTime startDate = StrUtil.isBlank(startTime)
|
||||
? 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()) {
|
||||
return new HashMap<String, Object>() {{
|
||||
return new HashMap<String, Object>() {{
|
||||
put("attendanceSummary", null);
|
||||
put("weekList", weekList);
|
||||
put("statusList", null);
|
||||
@@ -93,7 +115,7 @@ public class AttendanceServiceImpl implements AttendanceService {
|
||||
}
|
||||
ShopConfig config = shopConfigService.getById(shopId);
|
||||
if (config == null || StrUtil.isBlank(config.getDingAppSecret())) {
|
||||
return new HashMap<String, Object>() {{
|
||||
return new HashMap<String, Object>() {{
|
||||
put("attendanceSummary", null);
|
||||
put("weekList", weekList);
|
||||
put("statusList", null);
|
||||
|
||||
Reference in New Issue
Block a user