# BgReportLogServiceImpl.java

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

    import cloud.wconnect.commonlib.pojo.dto.PropertyDTO;
    import cloud.wconnect.commonlib.util.DateTimeUtils;
    import cloud.wconnect.frontoffice.entity.badguest.BgReportLog;
    import cloud.wconnect.frontoffice.mapper.badguest.BgReportLogMapper;
    import cloud.wconnect.frontoffice.service.badguest.IBgReportLogService;
    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.springframework.stereotype.Service;

    import java.util.List;
    import java.util.Objects;

    /**
     * <p>
     * Black List 报告处理日志表 服务实现类
     * </p>
     *
     * @author zc
     * @since 2023-05-12
     */
    @DS("logbook")
    @Service
    public class BgReportLogServiceImpl extends ServiceImpl<BgReportLogMapper, BgReportLog> implements IBgReportLogService {

        /**
         * 保存报告处理日志
         *
         * @param propertyDTO 资产对象
         * @param reportType 报告类型
         * @param userId 用户id
         * @return void
         * @author lichen
         * @date 2023/5/12
         */
        @Override
        public void save(PropertyDTO propertyDTO, int reportType, int userId) {
            BgReportLog bgReportLog = getOne(new LambdaQueryWrapper<BgReportLog>()
                    .eq(BgReportLog::getPropertyId, propertyDTO.getId())
                    .eq(BgReportLog::getReportType, reportType));
            if(Objects.nonNull(bgReportLog)){
                //更新
                bgReportLog.setProcessBy(userId);
                bgReportLog.setProcessTime(DateTimeUtils.dateTimeNowOfSecond(propertyDTO.getTimezone()));
                updateById(bgReportLog);
            }else{
                //新增
                BgReportLog insert = new BgReportLog();
                insert.setPropertyId(propertyDTO.getId());
                insert.setReportType(reportType);
                insert.setProcessBy(userId);
                insert.setProcessTime(DateTimeUtils.dateTimeNowOfSecond(propertyDTO.getTimezone()));
                save(insert);
            }
        }

        /**
         * 根据资产id查询报告处理日志
         *
         * @param propertyId 资产id
         * @return java.util.List<cloud.wconnect.frontoffice.entity.badguest.BgReportLog>
         * @author lichen
         * @date 2025/12/29
         */
        @Override
        public List<BgReportLog> listByPropertyId(int propertyId) {
            //查询报告导入log
            return list(new LambdaQueryWrapper<BgReportLog>().eq(BgReportLog::getPropertyId, propertyId));
        }
    }