# ShiftWakeupCallServiceImpl.java

    package cloud.wconnect.frontoffice.service.endofshift.impl;

    import cloud.wconnect.commonlib.cons.BaseErrorCodeEnum;
    import cloud.wconnect.commonlib.cons.CommonErrorI18nConstant;
    import cloud.wconnect.commonlib.exception.BadRequestException;
    import cloud.wconnect.commonlib.exception.ForbiddenException;
    import cloud.wconnect.frontoffice.entity.endofshift.ShiftWakeupCall;
    import cloud.wconnect.frontoffice.mapper.endofshift.ShiftWakeupCallMapper;
    import cloud.wconnect.frontoffice.service.endofshift.IShiftWakeupCallService;
    import com.baomidou.dynamic.datasource.annotation.DS;
    import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
    import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
    import org.apache.commons.collections.CollectionUtils;
    import org.springframework.stereotype.Service;

    import java.text.MessageFormat;
    import java.util.Collection;
    import java.util.Collections;
    import java.util.List;
    import java.util.Objects;

    /**
     * <p>
     * 服务实现类
     * </p>
     *
     * @author lichen
     * @since 2023-03-07
     */
    @Service
    @DS("ratelog_manage")
    public class ShiftWakeupCallServiceImpl extends ServiceImpl<ShiftWakeupCallMapper, ShiftWakeupCall> implements IShiftWakeupCallService {

        /**
         * 校验Wake Up Call是否存在，且属于资产
         *
         * @param id         wakeUpCall主键id
         * @param propertyId 资产id
         * @return cloud.wconnect.frontoffice.entity.endofshiftreport.ShiftWakeupCall
         * @author lichen
         * @date 2023/5/12
         */
        @Override
        public ShiftWakeupCall checkIsExistAndAffiliation(Integer id, Integer propertyId) {
            ShiftWakeupCall wakeupCall = getById(id);
            if (Objects.isNull(wakeupCall)) {
                throw new BadRequestException(CommonErrorI18nConstant.DATA_NOT_FOUND,
                        BaseErrorCodeEnum.DATA_VALIDATION_ERROR.getCode(), "the Wake Up Call does not exist");
            }
            if (!wakeupCall.getPropertyId().equals(propertyId)) {
                throw new ForbiddenException(BaseErrorCodeEnum.DATA_FORBIDDEN.getI18nCode(),
                        BaseErrorCodeEnum.DATA_FORBIDDEN.getCode(),
                        MessageFormat.format("The Wake Up Call is not affiliation to propertyId:{0}; Wake Up Call propertyId:{1}",
                                propertyId, wakeupCall.getPropertyId()));
            }
            return wakeupCall;
        }

        /**
         * 查询wake up call信息
         *
         * @param shiftId 班次id
         * @param status  状态
         * @return java.util.List<cloud.wconnect.frontoffice.entity.endofshiftreport.ShiftWakeupCall>
         * @author lichen
         * @date 2023/12/8
         */
        @Override
        public List<ShiftWakeupCall> listShiftIdAndStatus(Integer shiftId, boolean status) {
            return list(new LambdaQueryWrapper<ShiftWakeupCall>()
                    .eq(ShiftWakeupCall::getShiftId, shiftId)
                    .eq(ShiftWakeupCall::getStatus, status)
                    .orderByAsc(ShiftWakeupCall::getAlarmTime));
        }

        /**
         * 根据排班id查询walk up call信息
         *
         * @param shiftId 排班id
         * @return java.util.List<cloud.wconnect.frontoffice.entity.endofshift.ShiftWakeupCall>
         * @author lichen
         * @date 2025/6/20
         */
        @Override
        public List<ShiftWakeupCall> listByShiftId(Integer shiftId) {
            return list(new LambdaQueryWrapper<ShiftWakeupCall>()
                    .eq(ShiftWakeupCall::getShiftId, shiftId)
                    .orderByAsc(ShiftWakeupCall::getAlarmTime));
        }

        /**
         * 根据排班id查询walk up call信息
         *
         * @param shiftIds 排班id集合
         * @return java.util.List<cloud.wconnect.frontoffice.entity.endofshift.ShiftWakeupCall>
         * @author lichen
         * @date 2025/6/24
         */
        @Override
        public List<ShiftWakeupCall> listByShiftIds(Collection<Integer> shiftIds) {
            if (CollectionUtils.isEmpty(shiftIds)) return Collections.emptyList();
            return list(new LambdaQueryWrapper<ShiftWakeupCall>()
                    .in(ShiftWakeupCall::getShiftId, shiftIds));
        }

    }