package com.estate.expert.admin.service.impl;
|
|
import com.estate.expert.admin.domain.user.UserRepository;
|
import com.estate.expert.admin.domain.common.response.StaffStatBo;
|
import com.estate.expert.admin.service.StaffService;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.stereotype.Service;
|
|
import javax.annotation.Resource;
|
import java.util.ArrayList;
|
import java.util.Date;
|
import java.util.List;
|
|
/**
|
* 员工服务实现
|
* @Author daisyli
|
* @Date 2023/9/10
|
**/
|
@Slf4j
|
@Service
|
public class StaffServiceImpl implements StaffService {
|
//
|
// @Resource
|
// private SignRecordRepository signRecordRepository;
|
|
final String format = "yyyy-MM-dd HH:mm:ss";
|
|
@Resource
|
private UserRepository userRepository;
|
|
public StaffStatBo stat(String day) {
|
// 总人数、今日检查人数、今日内勤人数
|
int total = userRepository.countByDeletedIsFalse();
|
String startStr = day + " 00:00:00";
|
String endStr = day + " 23:59:59";
|
|
Date startTime = new Date();// = StringCommonUtils.parseLocalDateTime(startStr, format);
|
Date endTime = new Date();// = StringCommonUtils.parseLocalDateTime(endStr, format);
|
|
StaffStatBo staffStatBo = new StaffStatBo();
|
staffStatBo.setTotal(total);
|
|
// staffStatBo.setTodayCheckAll(signRecordRepository.countBySignTimeBetweenAndSignType(startTime, endTime, null));
|
// staffStatBo.setTodayCheckIn(signRecordRepository.countBySignTimeBetweenAndSignType(startTime, endTime, SignType.IN));
|
|
return staffStatBo;
|
}
|
|
public List<StaffStatBo> statList(String startDate, String endDate) {
|
|
List<StaffStatBo> results = new ArrayList<>();
|
|
int total = userRepository.countByDeletedIsFalse();
|
String startStr = startDate + " 00:00:00";
|
String endStr = endDate + " 23:59:59";
|
|
// LocalDateTime startTime = StringCommonUtils.parseLocalDateTime(startStr, format);
|
// LocalDateTime endTime = StringCommonUtils.parseLocalDateTime(endStr, format);
|
//
|
// List<StaffStatBo> checkList = attendanceRecordDao.countCheckIn(startTime, endTime, null);
|
// List<StaffStatBo> inList = attendanceRecordDao.countCheckIn(startTime, endTime, SignType.IN.name());
|
//
|
// log.info("checkList: {}, inList: {}", JSONObject.toJSONString(checkList), JSONObject.toJSONString(inList));
|
// // <Day, StaffStatBo>
|
// Map<String, StaffStatBo> inMap = new HashMap<>();
|
// if (CollectionUtils.isNotEmpty(inList)) {
|
// for (StaffStatBo staffStatBo : inList) {
|
// inMap.put(staffStatBo.getDay(), staffStatBo);
|
// }
|
// }
|
//
|
//
|
// for (StaffStatBo staffStatBo : checkList) {
|
// String day = staffStatBo.getDay();
|
// StaffStatBo result = new StaffStatBo();
|
// if (inMap.containsKey(day)) {
|
// result.setTodayCheckIn(inMap.get(day).getTotal());
|
// }
|
//
|
// result.setTotal(total);
|
// result.setTodayCheckAll(staffStatBo.getTotal());
|
//
|
// results.add(result);
|
//
|
// }
|
|
return results;
|
|
}
|
}
|