| | |
| | | package com.xiaopeng.maintenance.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.xiaopeng.api.feignClient.maintenance.XpCheckLocationClient; |
| | | import com.xiaopeng.api.feignClient.vehicleConvoy.XpFleetClient; |
| | | import com.xiaopeng.api.model.maintenance.XpCheckLocation; |
| | | import com.xiaopeng.api.model.maintenance.XpClockIn; |
| | | import com.xiaopeng.api.model.maintenance.XpSchedulingDetail; |
| | | import com.xiaopeng.api.model.maintenance.XpShift; |
| | | import com.xiaopeng.api.model.vehicleConvoy.XpFleet; |
| | | import com.xiaopeng.maintenance.dto.ShiftAttendanceDTO; |
| | | import com.xiaopeng.maintenance.mapper.XpCheckLocationMapper; |
| | | import com.xiaopeng.maintenance.mapper.XpClockInMapper; |
| | | import com.xiaopeng.maintenance.mapper.XpSchedulingDetailMapper; |
| | | import com.xiaopeng.maintenance.mapper.XpShiftMapper; |
| | | import com.xiaopeng.maintenance.service.IXpSchedulingDetailService; |
| | | import com.xiaopeng.maintenance.vo.ShiftAttendanceVO; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.util.Objects; |
| | | |
| | | /** |
| | | * <p> |
| | |
| | | @Service |
| | | public class XpSchedulingDetailServiceImpl extends ServiceImpl<XpSchedulingDetailMapper, XpSchedulingDetail> implements IXpSchedulingDetailService { |
| | | |
| | | @Autowired |
| | | private XpFleetClient xpFleetClient; |
| | | @Autowired |
| | | private XpCheckLocationMapper xpCheckLocationMapper; |
| | | @Autowired |
| | | private XpShiftMapper xpShiftMapper; |
| | | @Autowired |
| | | private XpClockInMapper xpClockInMapper; |
| | | |
| | | @Override |
| | | public ShiftAttendanceVO shiftAttendance(ShiftAttendanceDTO dto) { |
| | | // 查询用户所属车队 |
| | | XpFleet xpFleet = xpFleetClient.getFleetByOperationsUserId(dto.getOperationsUserId()).getData(); |
| | | if (Objects.isNull(xpFleet)) { |
| | | return null; |
| | | } |
| | | // 查询打卡地 |
| | | XpCheckLocation xpCheckLocation = xpCheckLocationMapper.selectById(xpFleet.getLocationId()); |
| | | if (Objects.isNull(xpCheckLocation)) { |
| | | return null; |
| | | } |
| | | // 查询排班明细 |
| | | XpSchedulingDetail schedulingDetail = this.getOne(Wrappers.lambdaQuery(XpSchedulingDetail.class) |
| | | .likeRight(XpSchedulingDetail::getPlanTime, dto.getSchedulingDate()) |
| | | .eq(XpSchedulingDetail::getFleetId, xpFleet.getId()) |
| | | .last("LIMIT 1")); |
| | | if (Objects.isNull(schedulingDetail)) { |
| | | return null; |
| | | } |
| | | // 查询班次 |
| | | XpShift xpShift = xpShiftMapper.selectById(schedulingDetail.getShiftId()); |
| | | if (Objects.isNull(xpShift)) { |
| | | return null; |
| | | } |
| | | |
| | | ShiftAttendanceVO shiftAttendanceVO = new ShiftAttendanceVO(); |
| | | shiftAttendanceVO.setXpShift(xpShift); |
| | | shiftAttendanceVO.setXpCheckLocation(xpCheckLocation); |
| | | // 查询当前用户打卡信息 |
| | | XpClockIn xpClockIn = xpClockInMapper.selectOne(Wrappers.lambdaQuery(XpClockIn.class) |
| | | .eq(XpClockIn::getAppUserId, dto.getOperationsUserId()) |
| | | .likeRight(XpClockIn::getClockInTime, dto.getSchedulingDate()) |
| | | .last("LIMIT 1")); |
| | | if(Objects.isNull(xpClockIn)){ |
| | | shiftAttendanceVO.setClockIn(false); |
| | | shiftAttendanceVO.setClockOut(false); |
| | | }else { |
| | | shiftAttendanceVO.setClockIn(true); |
| | | shiftAttendanceVO.setClockOut(xpClockIn.getClockOutTime() != null); |
| | | } |
| | | return shiftAttendanceVO; |
| | | } |
| | | } |