liujie
2026-05-16 539fa09b48cfe03c573284381cfba4ba092e8007
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
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;
 
    }
}