|
@@ -7,31 +7,26 @@ import java.util.stream.Collectors;
|
|
|
import com.ruoyi.common.core.domain.AjaxResult;
|
|
|
import com.ruoyi.common.core.domain.entity.SysRole;
|
|
|
import com.ruoyi.common.core.domain.entity.SysUser;
|
|
|
+import com.ruoyi.common.exception.ServiceException;
|
|
|
import com.ruoyi.common.utils.DateUtils;
|
|
|
import com.ruoyi.common.utils.PageUtils;
|
|
|
import com.ruoyi.common.utils.SecurityUtils;
|
|
|
import com.ruoyi.common.utils.StringUtils;
|
|
|
-import com.ruoyi.system.domain.ClockUserInfo;
|
|
|
-import com.ruoyi.system.domain.DutySchedule;
|
|
|
-import com.ruoyi.system.domain.OrderFood;
|
|
|
-import com.ruoyi.system.mapper.ClockUserInfoMapper;
|
|
|
-import com.ruoyi.system.mapper.DutyScheduleMapper;
|
|
|
-import com.ruoyi.system.mapper.OrderFoodMapper;
|
|
|
+import com.ruoyi.system.domain.*;
|
|
|
+import com.ruoyi.system.mapper.*;
|
|
|
+import lombok.SneakyThrows;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
-import com.ruoyi.system.mapper.ClockRecordMapper;
|
|
|
-import com.ruoyi.system.domain.ClockRecord;
|
|
|
import com.ruoyi.system.service.IClockRecordService;
|
|
|
|
|
|
|
|
|
* 打卡记录Service业务层处理
|
|
|
- *
|
|
|
+ *
|
|
|
* @author ruoyi
|
|
|
* @date 2024-08-06
|
|
|
*/
|
|
|
@Service
|
|
|
-public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
-{
|
|
|
+public class ClockRecordServiceImpl implements IClockRecordService {
|
|
|
@Autowired
|
|
|
private ClockRecordMapper clockRecordMapper;
|
|
|
@Autowired
|
|
@@ -40,37 +35,37 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
private OrderFoodMapper orderFoodMapper;
|
|
|
@Autowired
|
|
|
private DutyScheduleMapper dutyScheduleMapper;
|
|
|
+ @Autowired
|
|
|
+ private ClockHolidaysMapper clockHolidaysMapper;
|
|
|
|
|
|
|
|
|
* 查询打卡记录
|
|
|
- *
|
|
|
+ *
|
|
|
* @param clockId 打卡记录主键
|
|
|
* @return 打卡记录
|
|
|
*/
|
|
|
@Override
|
|
|
- public ClockRecord selectClockRecordByClockId(Long clockId)
|
|
|
- {
|
|
|
+ public ClockRecord selectClockRecordByClockId(Long clockId) {
|
|
|
return clockRecordMapper.selectClockRecordByClockId(clockId);
|
|
|
}
|
|
|
|
|
|
|
|
|
* 查询打卡记录列表
|
|
|
- *
|
|
|
+ *
|
|
|
* @param clockRecord 打卡记录
|
|
|
* @return 打卡记录
|
|
|
*/
|
|
|
@Override
|
|
|
- public List<ClockRecord> selectClockRecordList(ClockRecord clockRecord)
|
|
|
- {
|
|
|
+ public List<ClockRecord> selectClockRecordList(ClockRecord clockRecord) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
List<SysRole> roles = user.getRoles();
|
|
|
boolean bl = true;
|
|
|
for (SysRole role : roles) {
|
|
|
- if("admin".equals(role.getRoleKey()) || "administrators".equals(role.getRoleKey())){
|
|
|
+ if ("admin".equals(role.getRoleKey()) || "administrators".equals(role.getRoleKey())) {
|
|
|
bl = false;
|
|
|
}
|
|
|
}
|
|
|
- if(bl){
|
|
|
+ if (bl) {
|
|
|
clockRecord.setUserId(user.getUserId());
|
|
|
}
|
|
|
return clockRecordMapper.selectClockRecordList(clockRecord);
|
|
@@ -78,14 +73,18 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
|
|
|
|
|
|
* 新增打卡记录
|
|
|
- *
|
|
|
+ *
|
|
|
* @param clockRecord 打卡记录
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int insertClockRecord(ClockRecord clockRecord)
|
|
|
- {
|
|
|
+ public int insertClockRecord(ClockRecord clockRecord) {
|
|
|
SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
+
|
|
|
+ ClockUserInfo clockUserInfo = clockUserInfoMapper.selectClockUserInfoByUserId(user.getUserId());
|
|
|
+ if (clockUserInfo == null) {
|
|
|
+ throw new ServiceException("当前账号无法打卡");
|
|
|
+ }
|
|
|
clockRecord.setUserId(user.getUserId());
|
|
|
clockRecord.setUserName(user.getNickName());
|
|
|
clockRecord.setPhonenumber(user.getPhonenumber());
|
|
@@ -105,38 +104,35 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
|
|
|
|
|
|
* 修改打卡记录
|
|
|
- *
|
|
|
+ *
|
|
|
* @param clockRecord 打卡记录
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int updateClockRecord(ClockRecord clockRecord)
|
|
|
- {
|
|
|
+ public int updateClockRecord(ClockRecord clockRecord) {
|
|
|
clockRecord.setUpdateTime(DateUtils.getNowDate());
|
|
|
return clockRecordMapper.updateClockRecord(clockRecord);
|
|
|
}
|
|
|
|
|
|
|
|
|
* 批量删除打卡记录
|
|
|
- *
|
|
|
+ *
|
|
|
* @param clockIds 需要删除的打卡记录主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteClockRecordByClockIds(Long[] clockIds)
|
|
|
- {
|
|
|
+ public int deleteClockRecordByClockIds(Long[] clockIds) {
|
|
|
return clockRecordMapper.deleteClockRecordByClockIds(clockIds);
|
|
|
}
|
|
|
|
|
|
|
|
|
* 删除打卡记录信息
|
|
|
- *
|
|
|
+ *
|
|
|
* @param clockId 打卡记录主键
|
|
|
* @return 结果
|
|
|
*/
|
|
|
@Override
|
|
|
- public int deleteClockRecordByClockId(Long clockId)
|
|
|
- {
|
|
|
+ public int deleteClockRecordByClockId(Long clockId) {
|
|
|
return clockRecordMapper.deleteClockRecordByClockId(clockId);
|
|
|
}
|
|
|
|
|
@@ -145,57 +141,60 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
ClockUserInfo clockUserInfo = clockUserInfoMapper.selectClockUserInfoByUserId(clockRecord.getUserId());
|
|
|
- resultMap.put("name",clockUserInfo.getUserName());
|
|
|
+ resultMap.put("name", clockUserInfo.getUserName());
|
|
|
|
|
|
ClockRecord clockRecordNew = clockRecordMapper.selectClockRecordNew(clockRecord);
|
|
|
- resultMap.put("time",clockRecordNew.getRecordDate());
|
|
|
+ resultMap.put("time", "");
|
|
|
+ if (clockRecordNew != null) {
|
|
|
+ resultMap.put("time", clockRecordNew.getRecordDate());
|
|
|
+ }
|
|
|
|
|
|
DutySchedule dutySchedule = dutyScheduleMapper.selectDutyScheduleByDutyNew();
|
|
|
- resultMap.put("workTime",dutySchedule.getStartWorkTime()+" - "+dutySchedule.getEndWorkTime());
|
|
|
+ resultMap.put("workTime", dutySchedule.getStartWorkTime() + " - " + dutySchedule.getEndWorkTime());
|
|
|
|
|
|
List<ClockRecord> clockRecords = clockRecordMapper.selectOrderFoodListRl(clockRecord);
|
|
|
|
|
|
Map<String, List<ClockRecord>> clockTime = new HashMap<>();
|
|
|
- if (clockRecords != null && clockRecords.size() > 0){
|
|
|
+ if (clockRecords != null && clockRecords.size() > 0) {
|
|
|
clockTime = clockRecords.stream().collect(Collectors.groupingBy(ClockRecord::getRecordDate));
|
|
|
}
|
|
|
|
|
|
List<String> dayList = DateUtils.getDay(DateUtils.parseDate(clockRecord.getRecordDate()));
|
|
|
|
|
|
List<Map> mapList = new ArrayList<>();
|
|
|
- if (dayList.size()> 0){
|
|
|
+ if (dayList.size() > 0) {
|
|
|
for (String day : dayList) {
|
|
|
- Map<String,Object> map = new HashMap<>(5);
|
|
|
- map.put("date",day);
|
|
|
- map.put("am","未打卡");
|
|
|
+ Map<String, Object> map = new HashMap<>(5);
|
|
|
+ map.put("date", day);
|
|
|
+ map.put("am", "未打卡");
|
|
|
|
|
|
- map.put("amex","5");
|
|
|
- map.put("pm","未打卡");
|
|
|
+ map.put("amex", "5");
|
|
|
+ map.put("pm", "未打卡");
|
|
|
|
|
|
- map.put("pmex","5");
|
|
|
- if (clockTime.size() > 0){
|
|
|
+ map.put("pmex", "5");
|
|
|
+ if (clockTime.size() > 0) {
|
|
|
List<ClockRecord> clockRecordList = clockTime.get(day);
|
|
|
- if (clockRecordList != null && clockRecordList.size() > 0){
|
|
|
+ if (clockRecordList != null && clockRecordList.size() > 0) {
|
|
|
clockRecordList = clockRecordList.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
- if("1".equals(clockRecordList.get(clockRecordList.size()-1).getType())){
|
|
|
- map.put("am",clockRecordList.get(clockRecordList.size()-1).getRecordTime());
|
|
|
+ if ("1".equals(clockRecordList.get(clockRecordList.size() - 1).getType())) {
|
|
|
+ map.put("am", clockRecordList.get(clockRecordList.size() - 1).getRecordTime());
|
|
|
|
|
|
- map.put("amex",clockRecordList.get(clockRecordList.size()-1).getIsOutwork());
|
|
|
+ map.put("amex", clockRecordList.get(clockRecordList.size() - 1).getIsOutwork());
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(clockRecordList.size()-1).getType())){
|
|
|
- map.put("pm",clockRecordList.get(clockRecordList.size()-1).getRecordTime());
|
|
|
+ if ("2".equals(clockRecordList.get(clockRecordList.size() - 1).getType())) {
|
|
|
+ map.put("pm", clockRecordList.get(clockRecordList.size() - 1).getRecordTime());
|
|
|
|
|
|
- map.put("pmex",clockRecordList.get(clockRecordList.size()-1).getIsOutwork());
|
|
|
+ map.put("pmex", clockRecordList.get(clockRecordList.size() - 1).getIsOutwork());
|
|
|
}
|
|
|
- if("1".equals(clockRecordList.get(0).getType())){
|
|
|
- map.put("am",clockRecordList.get(0).getRecordTime());
|
|
|
+ if ("1".equals(clockRecordList.get(0).getType())) {
|
|
|
+ map.put("am", clockRecordList.get(0).getRecordTime());
|
|
|
|
|
|
- map.put("amex",clockRecordList.get(0).getIsOutwork());
|
|
|
+ map.put("amex", clockRecordList.get(0).getIsOutwork());
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(0).getType())){
|
|
|
- map.put("pm",clockRecordList.get(0).getRecordTime());
|
|
|
+ if ("2".equals(clockRecordList.get(0).getType())) {
|
|
|
+ map.put("pm", clockRecordList.get(0).getRecordTime());
|
|
|
|
|
|
- map.put("pmex",clockRecordList.get(0).getIsOutwork());
|
|
|
+ map.put("pmex", clockRecordList.get(0).getIsOutwork());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -204,7 +203,18 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- resultMap.put("rlData",mapList);
|
|
|
+ resultMap.put("rlData", mapList);
|
|
|
+
|
|
|
+
|
|
|
+ ClockHolidays clockHoliday = new ClockHolidays();
|
|
|
+ clockHoliday.setYear(DateUtils.getYear());
|
|
|
+ clockHoliday.setHolidayDate(clockRecord.getRecordDate());
|
|
|
+ List<ClockHolidays> clockHolidaysList = clockHolidaysMapper.selectClockHolidaysMonthList(clockHoliday);
|
|
|
+ if (clockHolidaysList == null || clockHolidaysList.size() < 0) {
|
|
|
+ clockHolidaysList = new ArrayList<>();
|
|
|
+ }
|
|
|
+
|
|
|
+ resultMap.put("holidays", clockHolidaysList);
|
|
|
return AjaxResult.success(resultMap);
|
|
|
}
|
|
|
|
|
@@ -223,15 +233,18 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
ClockUserInfo clockUserInfo = new ClockUserInfo();
|
|
|
clockUserInfo.setDelFlag("0");
|
|
|
List<ClockUserInfo> clockUserInfoList = clockUserInfoMapper.selectClockUserInfoList(clockUserInfo);
|
|
|
+ if(clockUserInfoList!=null && clockUserInfoList.size()>0){
|
|
|
+ dkzs = clockUserInfoList.size();
|
|
|
+ }
|
|
|
|
|
|
int ydk = 0;
|
|
|
|
|
|
int wdk = 0;
|
|
|
- if(clockUserId!=null && clockUserId.size()>0){
|
|
|
+ if (clockUserId != null && clockUserId.size() > 0) {
|
|
|
ydk = clockUserId.size();
|
|
|
}
|
|
|
- if(clockUserInfoList!=null && clockUserInfoList.size()>0){
|
|
|
- wdk = clockUserInfoList.size()-clockUserId.size();
|
|
|
+ if (clockUserInfoList != null && clockUserInfoList.size() > 0) {
|
|
|
+ wdk = clockUserInfoList.size() - clockUserId.size();
|
|
|
}
|
|
|
|
|
|
|
|
@@ -244,23 +257,23 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
int dcwc = 0;
|
|
|
|
|
|
int dcDinner = 0;
|
|
|
- if(orderFoods!=null && orderFoods.size()>0){
|
|
|
+ if (orderFoods != null && orderFoods.size() > 0) {
|
|
|
dczs = orderFoods.size();
|
|
|
for (OrderFood food : orderFoods) {
|
|
|
- if("1".equals(food.getOrderFoodType())){
|
|
|
+ if ("1".equals(food.getOrderFoodType())) {
|
|
|
dcwc++;
|
|
|
}
|
|
|
- if("2".equals(food.getOrderFoodType())){
|
|
|
+ if ("2".equals(food.getOrderFoodType())) {
|
|
|
dcDinner++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- resultMap.put("dkzs",dkzs);
|
|
|
- resultMap.put("ydk",ydk);
|
|
|
- resultMap.put("wdk",wdk);
|
|
|
- resultMap.put("dczs",dczs);
|
|
|
- resultMap.put("dcwc",dcwc);
|
|
|
- resultMap.put("dcDinner",dcDinner);
|
|
|
+ resultMap.put("dkzs", dkzs);
|
|
|
+ resultMap.put("ydk", ydk);
|
|
|
+ resultMap.put("wdk", wdk);
|
|
|
+ resultMap.put("dczs", dczs);
|
|
|
+ resultMap.put("dcwc", dcwc);
|
|
|
+ resultMap.put("dcDinner", dcDinner);
|
|
|
return AjaxResult.success(resultMap);
|
|
|
}
|
|
|
|
|
@@ -269,53 +282,53 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
DutySchedule dutySchedule = dutyScheduleMapper.selectDutyScheduleByDutyNew();
|
|
|
- resultMap.put("workTime",dutySchedule.getStartWorkTime()+" - "+dutySchedule.getEndWorkTime());
|
|
|
+ resultMap.put("workTime", dutySchedule.getStartWorkTime() + " - " + dutySchedule.getEndWorkTime());
|
|
|
|
|
|
-
|
|
|
+
|
|
|
List<ClockRecord> clockRecords = clockRecordMapper.selectClockRecordList(clockRecord);
|
|
|
|
|
|
Map<String, List<ClockRecord>> clockTime = new HashMap<>();
|
|
|
- if (clockRecords != null && clockRecords.size() > 0){
|
|
|
+ if (clockRecords != null && clockRecords.size() > 0) {
|
|
|
clockTime = clockRecords.stream().collect(Collectors.groupingBy(ClockRecord::getRecordDate));
|
|
|
}
|
|
|
|
|
|
- List<Date> dayList = DateUtils.getDatesBetween(clockRecord.getStartTime(),clockRecord.getEndTime());
|
|
|
+ List<Date> dayList = DateUtils.getDatesBetween(clockRecord.getStartTime(), clockRecord.getEndTime());
|
|
|
|
|
|
List<Map> mapList = new ArrayList<>();
|
|
|
- if (dayList.size()> 0){
|
|
|
+ if (dayList.size() > 0) {
|
|
|
for (Date day : dayList) {
|
|
|
- Map<String,Object> map = new HashMap<>(5);
|
|
|
+ Map<String, Object> map = new HashMap<>(5);
|
|
|
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
- map.put("date",format.format(day));
|
|
|
- map.put("am","未打卡");
|
|
|
+ map.put("date", format.format(day));
|
|
|
+ map.put("am", "未打卡");
|
|
|
|
|
|
- map.put("amex","5");
|
|
|
- map.put("pm","未打卡");
|
|
|
+ map.put("amex", "5");
|
|
|
+ map.put("pm", "未打卡");
|
|
|
|
|
|
- map.put("pmex","5");
|
|
|
- if (clockTime.size() > 0){
|
|
|
+ map.put("pmex", "5");
|
|
|
+ if (clockTime.size() > 0) {
|
|
|
List<ClockRecord> clockRecordList = clockTime.get(format.format(day));
|
|
|
- if (clockRecordList != null && clockRecordList.size() > 0){
|
|
|
+ if (clockRecordList != null && clockRecordList.size() > 0) {
|
|
|
clockRecordList = clockRecordList.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
- if("1".equals(clockRecordList.get(clockRecordList.size()-1).getType())){
|
|
|
- map.put("am",clockRecordList.get(clockRecordList.size()-1).getRecordTime());
|
|
|
+ if ("1".equals(clockRecordList.get(clockRecordList.size() - 1).getType())) {
|
|
|
+ map.put("am", clockRecordList.get(clockRecordList.size() - 1).getRecordTime());
|
|
|
|
|
|
- map.put("amex",clockRecordList.get(clockRecordList.size()-1).getIsOutwork());
|
|
|
+ map.put("amex", clockRecordList.get(clockRecordList.size() - 1).getIsOutwork());
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(clockRecordList.size()-1).getType())){
|
|
|
- map.put("pm",clockRecordList.get(clockRecordList.size()-1).getRecordTime());
|
|
|
+ if ("2".equals(clockRecordList.get(clockRecordList.size() - 1).getType())) {
|
|
|
+ map.put("pm", clockRecordList.get(clockRecordList.size() - 1).getRecordTime());
|
|
|
|
|
|
- map.put("pmex",clockRecordList.get(clockRecordList.size()-1).getIsOutwork());
|
|
|
+ map.put("pmex", clockRecordList.get(clockRecordList.size() - 1).getIsOutwork());
|
|
|
}
|
|
|
- if("1".equals(clockRecordList.get(0).getType())){
|
|
|
- map.put("am",clockRecordList.get(0).getRecordTime());
|
|
|
+ if ("1".equals(clockRecordList.get(0).getType())) {
|
|
|
+ map.put("am", clockRecordList.get(0).getRecordTime());
|
|
|
|
|
|
- map.put("amex",clockRecordList.get(0).getIsOutwork());
|
|
|
+ map.put("amex", clockRecordList.get(0).getIsOutwork());
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(0).getType())){
|
|
|
- map.put("pm",clockRecordList.get(0).getRecordTime());
|
|
|
+ if ("2".equals(clockRecordList.get(0).getType())) {
|
|
|
+ map.put("pm", clockRecordList.get(0).getRecordTime());
|
|
|
|
|
|
- map.put("pmex",clockRecordList.get(0).getIsOutwork());
|
|
|
+ map.put("pmex", clockRecordList.get(0).getIsOutwork());
|
|
|
}
|
|
|
|
|
|
}
|
|
@@ -324,35 +337,241 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- resultMap.put("rlData",mapList);
|
|
|
+ resultMap.put("rlData", mapList);
|
|
|
return AjaxResult.success(resultMap);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public AjaxResult personage(ClockRecord clockRecord) {
|
|
|
- SysUser user = SecurityUtils.getLoginUser().getUser();
|
|
|
- clockRecord.setUserId(user.getUserId());
|
|
|
Map<String, Object> resultMap = statistics(clockRecord);
|
|
|
return AjaxResult.success(resultMap);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<Map<String,Object>> all(ClockUserInfo clockUserInfo) {
|
|
|
- List<Map<String,Object>> listMap = new ArrayList<>();
|
|
|
+ public List<Map<String, Object>> all(ClockUserInfo clockUserInfo) {
|
|
|
+ List<Map<String, Object>> listMap = new ArrayList<>();
|
|
|
startPage();
|
|
|
List<ClockUserInfo> clockUserList = clockUserInfoMapper.selectClockUserInfoList(clockUserInfo);
|
|
|
clearPage();
|
|
|
for (ClockUserInfo userInfo : clockUserList) {
|
|
|
ClockRecord clockRecord = new ClockRecord();
|
|
|
clockRecord.setUserId(userInfo.getUserId());
|
|
|
- clockRecord.setRecordDate(clockUserInfo.getRecordDate()+"-01");
|
|
|
+ clockRecord.setRecordDate(clockUserInfo.getRecordDate() + "-01");
|
|
|
Map<String, Object> resultMap = statistics(clockRecord);
|
|
|
- resultMap.put("name",userInfo.getUserName());
|
|
|
+ resultMap.put("name", userInfo.getUserName());
|
|
|
+ resultMap.put("userId", userInfo.getUserId());
|
|
|
listMap.add(resultMap);
|
|
|
}
|
|
|
return listMap;
|
|
|
}
|
|
|
|
|
|
+ @SneakyThrows
|
|
|
+ @Override
|
|
|
+ public AjaxResult abnormal(ClockRecord clockRecord) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ int wq = 0;
|
|
|
+ int cd = 0;
|
|
|
+ int zt = 0;
|
|
|
+ int wdk = 0;
|
|
|
+
|
|
|
+
|
|
|
+ ClockUserInfo clockUserInfo = new ClockUserInfo();
|
|
|
+ clockUserInfo.setDelFlag("0");
|
|
|
+ List<ClockUserInfo> clockUserInfoList = clockUserInfoMapper.selectClockUserInfoList(clockUserInfo);
|
|
|
+
|
|
|
+ List<ClockRecord> clockRecords = clockRecordMapper.selectClockRecordList(clockRecord);
|
|
|
+
|
|
|
+
|
|
|
+ Map<Long, List<ClockRecord>> clockUser = new HashMap<>();
|
|
|
+ if (clockRecords != null && clockRecords.size() > 0) {
|
|
|
+ clockUser = clockRecords.stream().collect(Collectors.groupingBy(ClockRecord::getUserId));
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ ClockHolidays clockHoliday = new ClockHolidays();
|
|
|
+ clockHoliday.setYear(DateUtils.getYear());
|
|
|
+ List<ClockHolidays> clockHolidaysList = clockHolidaysMapper.selectClockHolidaysList(clockHoliday);
|
|
|
+
|
|
|
+ List<String> jjrList = new ArrayList<>();
|
|
|
+ List<String> bbList = new ArrayList<>();
|
|
|
+ for (ClockHolidays clockHolidays : clockHolidaysList) {
|
|
|
+ if ("NO".equals(clockHolidays.getType())) {
|
|
|
+ jjrList.add(clockHolidays.getHolidayDate());
|
|
|
+ } else {
|
|
|
+ bbList.add(clockHolidays.getHolidayDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ List<Date> dayList = DateUtils.getDatesBetween(clockRecord.getStartTime(), clockRecord.getEndTime());
|
|
|
+ for (ClockUserInfo userInfo : clockUserInfoList) {
|
|
|
+ List<ClockRecord> clockRecordUser = clockUser.get(userInfo.getUserId());
|
|
|
+
|
|
|
+ Map<String, List<ClockRecord>> clockTime = new HashMap<>();
|
|
|
+ if (clockRecordUser != null && clockRecordUser.size() > 0) {
|
|
|
+ clockTime = clockRecordUser.stream().collect(Collectors.groupingBy(ClockRecord::getRecordDate));
|
|
|
+ }
|
|
|
+ if (dayList.size() > 0) {
|
|
|
+ for (Date day : dayList) {
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+ boolean bl = (DateUtils.dayForWeek(format.format(day)) == 6 || DateUtils.dayForWeek(format.format(day)) == 7);
|
|
|
+ if (jjrList.contains(format.format(day)) || (bl && !bbList.contains(format.format(day)))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<ClockRecord> clockRecordList = clockTime.get(format.format(day));
|
|
|
+ if (clockRecordList == null || clockRecordList.size() <= 0) {
|
|
|
+ wdk++;
|
|
|
+ } else {
|
|
|
+ boolean sw = false;
|
|
|
+ boolean xw = false;
|
|
|
+ boolean bcd = false;
|
|
|
+ boolean bzt = false;
|
|
|
+ boolean bwq = false;
|
|
|
+
|
|
|
+ Map<String, List<ClockRecord>> typMap = clockRecordList.stream().collect(Collectors.groupingBy(ClockRecord::getType));
|
|
|
+ if (typMap.containsKey("1")) {
|
|
|
+
|
|
|
+ List<ClockRecord> clockRecordTyp = typMap.get("1");
|
|
|
+ clockRecordTyp = clockRecordTyp.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ sw = true;
|
|
|
+ if ("3".equals(clockRecordTyp.get(clockRecordTyp.size() - 1).getIsOutwork())) {
|
|
|
+ bcd = true;
|
|
|
+ }
|
|
|
+ if ("2".equals(clockRecordTyp.get(clockRecordTyp.size() - 1).getIsOutwork())) {
|
|
|
+ bwq = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (typMap.containsKey("2")) {
|
|
|
+
|
|
|
+ List<ClockRecord> clockRecordTyp = typMap.get("2");
|
|
|
+ clockRecordTyp = clockRecordTyp.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ xw = true;
|
|
|
+ if ("4".equals(clockRecordTyp.get(0).getIsOutwork())) {
|
|
|
+ bzt = true;
|
|
|
+ }
|
|
|
+ if ("2".equals(clockRecordTyp.get(0).getIsOutwork())) {
|
|
|
+ bwq = true;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ if (!sw || !xw) {
|
|
|
+ wdk++;
|
|
|
+ }
|
|
|
+ if (bcd) {
|
|
|
+ cd++;
|
|
|
+ }
|
|
|
+ if (bzt) {
|
|
|
+ zt++;
|
|
|
+ }
|
|
|
+ if (bwq) {
|
|
|
+ wq++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ resultMap.put("cd", cd);
|
|
|
+ resultMap.put("zt", zt);
|
|
|
+ resultMap.put("wq", wq);
|
|
|
+ resultMap.put("wdk", wdk);
|
|
|
+ return AjaxResult.success(resultMap);
|
|
|
+ }
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
+ @Override
|
|
|
+ public AjaxResult details(ClockRecord clockRecord) {
|
|
|
+ List<Map<String, Object>> listMap = new ArrayList<>();
|
|
|
+
|
|
|
+ clockRecord.setRecordDate(clockRecord.getRecordDate() + "-01");
|
|
|
+ List<ClockRecord> clockRecords = clockRecordMapper.selectOrderFoodListRl(clockRecord);
|
|
|
+
|
|
|
+ Map<String, List<ClockRecord>> clockTime = new HashMap<>();
|
|
|
+ if (clockRecords != null && clockRecords.size() > 0) {
|
|
|
+ clockTime = clockRecords.stream().collect(Collectors.groupingBy(ClockRecord::getRecordDate));
|
|
|
+ }
|
|
|
+
|
|
|
+ List<String> dayList = DateUtils.getDay(DateUtils.parseDate(clockRecord.getRecordDate()));
|
|
|
+
|
|
|
+ ClockHolidays clockHoliday = new ClockHolidays();
|
|
|
+ clockHoliday.setYear(DateUtils.getYear());
|
|
|
+ List<ClockHolidays> clockHolidaysList = clockHolidaysMapper.selectClockHolidaysList(clockHoliday);
|
|
|
+
|
|
|
+ List<String> jjrList = new ArrayList<>();
|
|
|
+ List<String> bbList = new ArrayList<>();
|
|
|
+ for (ClockHolidays clockHolidays : clockHolidaysList) {
|
|
|
+ if ("NO".equals(clockHolidays.getType())) {
|
|
|
+ jjrList.add(clockHolidays.getHolidayDate());
|
|
|
+ } else {
|
|
|
+ bbList.add(clockHolidays.getHolidayDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String day : dayList) {
|
|
|
+ Map<String, Object> resultMap = new HashMap<>();
|
|
|
+ boolean bl = (DateUtils.dayForWeek(day) == 6 || DateUtils.dayForWeek(day) == 7);
|
|
|
+ if (jjrList.contains(day) || (bl && !bbList.contains(day))) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<ClockRecord> clockRecordList = clockTime.get(day);
|
|
|
+ if (clockRecordList == null || clockRecordList.size() <= 0) {
|
|
|
+ resultMap.put("time", day);
|
|
|
+ resultMap.put("details", "全天未打卡");
|
|
|
+ listMap.add(resultMap);
|
|
|
+ } else {
|
|
|
+ resultMap.put("time", day);
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ Map<String, List<ClockRecord>> typMap = clockRecordList.stream().collect(Collectors.groupingBy(ClockRecord::getType));
|
|
|
+ if (typMap.containsKey("1")) {
|
|
|
+
|
|
|
+ List<ClockRecord> clockRecordTyp = typMap.get("1");
|
|
|
+ clockRecordTyp = clockRecordTyp.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if ("3".equals(clockRecordTyp.get(clockRecordTyp.size() - 1).getIsOutwork())) {
|
|
|
+ sb.append("上午:迟到");
|
|
|
+ }
|
|
|
+ if ("2".equals(clockRecordTyp.get(clockRecordTyp.size() - 1).getIsOutwork())) {
|
|
|
+ sb.append("上午:外勤");
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ sb.append("上午:缺卡");
|
|
|
+ }
|
|
|
+
|
|
|
+ if (typMap.containsKey("2")) {
|
|
|
+
|
|
|
+ List<ClockRecord> clockRecordTyp = typMap.get("2");
|
|
|
+ clockRecordTyp = clockRecordTyp.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if ("4".equals(clockRecordTyp.get(0).getIsOutwork())) {
|
|
|
+ if(StringUtils.isNotEmpty(sb.toString())){
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append("下午:早退");
|
|
|
+ }
|
|
|
+ if ("2".equals(clockRecordTyp.get(0).getIsOutwork())) {
|
|
|
+ if(StringUtils.isNotEmpty(sb.toString())){
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append("下午:外勤");
|
|
|
+ }
|
|
|
+
|
|
|
+ }else{
|
|
|
+ if(StringUtils.isNotEmpty(sb.toString())){
|
|
|
+ sb.append(",");
|
|
|
+ }
|
|
|
+ sb.append("下午:缺卡");
|
|
|
+ }
|
|
|
+
|
|
|
+ resultMap.put("details", sb.toString());
|
|
|
+ listMap.add(resultMap);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return AjaxResult.success(listMap);
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
* 设置请求分页数据
|
|
|
*/
|
|
@@ -367,7 +586,10 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
PageUtils.clearPage();
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @SneakyThrows
|
|
|
public Map<String, Object> statistics(ClockRecord clockRecord) {
|
|
|
+ String year = DateUtils.getYear();
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
|
|
|
int cd = 0;
|
|
@@ -375,59 +597,98 @@ public class ClockRecordServiceImpl implements IClockRecordService
|
|
|
int zt = 0;
|
|
|
|
|
|
int wq = 0;
|
|
|
+
|
|
|
+ int wdk = 0;
|
|
|
|
|
|
- if(StringUtils.isEmpty(clockRecord.getRecordDate())){
|
|
|
+ if (StringUtils.isEmpty(clockRecord.getRecordDate())) {
|
|
|
clockRecord.setRecordDate(DateUtils.getDate());
|
|
|
}
|
|
|
|
|
|
- List<ClockRecord> clockRecords = clockRecordMapper.selectClockRecordList(clockRecord);
|
|
|
+ List<ClockRecord> clockRecords = clockRecordMapper.selectOrderFoodListRl(clockRecord);
|
|
|
|
|
|
Map<String, List<ClockRecord>> clockTime = new HashMap<>();
|
|
|
- if (clockRecords != null && clockRecords.size() > 0){
|
|
|
+ if (clockRecords != null && clockRecords.size() > 0) {
|
|
|
clockTime = clockRecords.stream().collect(Collectors.groupingBy(ClockRecord::getRecordDate));
|
|
|
}
|
|
|
- for (String key : clockTime.keySet()) {
|
|
|
- List<ClockRecord> clockRecordList = clockTime.get(key);
|
|
|
- clockRecordList = clockRecordList.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
- for (ClockRecord record : clockRecordList) {
|
|
|
- if("1".equals(clockRecordList.get(clockRecordList.size()-1).getType())){
|
|
|
- if("3".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
+
|
|
|
+ List<String> dayList = DateUtils.getDay(DateUtils.parseDate(clockRecord.getRecordDate()));
|
|
|
+
|
|
|
+
|
|
|
+ ClockHolidays clockHoliday = new ClockHolidays();
|
|
|
+ clockHoliday.setYear(year);
|
|
|
+ List<ClockHolidays> clockHolidaysList = clockHolidaysMapper.selectClockHolidaysList(clockHoliday);
|
|
|
+
|
|
|
+ List<String> jjrList = new ArrayList<>();
|
|
|
+ List<String> bbList = new ArrayList<>();
|
|
|
+ for (ClockHolidays clockHolidays : clockHolidaysList) {
|
|
|
+ if ("NO".equals(clockHolidays.getType())) {
|
|
|
+ jjrList.add(clockHolidays.getHolidayDate());
|
|
|
+ } else {
|
|
|
+ bbList.add(clockHolidays.getHolidayDate());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ for (String s : dayList) {
|
|
|
+ if (DateUtils.compare(s, DateUtils.getDate()) < 0) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ boolean bl = (DateUtils.dayForWeek(s) == 6 || DateUtils.dayForWeek(s) == 7);
|
|
|
+ if (bbList.contains(s) || (!bl && !jjrList.contains(s))) {
|
|
|
+
|
|
|
+ if (!clockTime.containsKey(s)) {
|
|
|
+ wdk = wdk + 2;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ List<ClockRecord> clockRecordList = clockTime.get(s);
|
|
|
+ clockRecordList = clockRecordList.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
+ boolean sw = false;
|
|
|
+ boolean xw = false;
|
|
|
+ boolean swwq = false;
|
|
|
+ boolean xwwq = false;
|
|
|
+ Map<String, List<ClockRecord>> typMap = clockRecordList.stream().collect(Collectors.groupingBy(ClockRecord::getType));
|
|
|
+ if (typMap.containsKey("1")) {
|
|
|
+
|
|
|
+ List<ClockRecord> clockRecordTyp = typMap.get("1");
|
|
|
+ clockRecordTyp = clockRecordTyp.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ sw = true;
|
|
|
+ if ("3".equals(clockRecordTyp.get(clockRecordTyp.size() - 1).getIsOutwork())) {
|
|
|
cd++;
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
- wq++;
|
|
|
+ if ("2".equals(clockRecordTyp.get(clockRecordTyp.size() - 1).getIsOutwork())) {
|
|
|
+ swwq = true;
|
|
|
}
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(clockRecordList.size()-1).getType())){
|
|
|
- if("4".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
+ if (typMap.containsKey("2")) {
|
|
|
+
|
|
|
+ List<ClockRecord> clockRecordTyp = typMap.get("2");
|
|
|
+ clockRecordTyp = clockRecordTyp.stream().sorted(Comparator.comparing(ClockRecord::getRecordTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ xw = true;
|
|
|
+ if ("4".equals(clockRecordTyp.get(0).getIsOutwork())) {
|
|
|
zt++;
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
- wq++;
|
|
|
+ if ("2".equals(clockRecordTyp.get(0).getIsOutwork())) {
|
|
|
+ xwwq = true;
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
- if("1".equals(clockRecordList.get(0).getType())){
|
|
|
- if("3".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
- cd++;
|
|
|
- }
|
|
|
- if("2".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
- wq++;
|
|
|
- }
|
|
|
+ if (!sw || !xw) {
|
|
|
+ wdk++;
|
|
|
}
|
|
|
- if("2".equals(clockRecordList.get(0).getType())){
|
|
|
- if("4".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
- zt++;
|
|
|
- }
|
|
|
- if("2".equals(clockRecordList.get(clockRecordList.size()-1).getIsOutwork())){
|
|
|
- wq++;
|
|
|
- }
|
|
|
+ if (swwq) {
|
|
|
+ wq++;
|
|
|
+ }
|
|
|
+ if (xwwq) {
|
|
|
+ wq++;
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
- resultMap.put("cd",cd);
|
|
|
- resultMap.put("zt",zt);
|
|
|
- resultMap.put("wq",wq);
|
|
|
+ resultMap.put("cd", cd);
|
|
|
+ resultMap.put("zt", zt);
|
|
|
+ resultMap.put("wq", wq);
|
|
|
+ resultMap.put("wdk", wdk);
|
|
|
return resultMap;
|
|
|
}
|
|
|
|