package cn.fw.valhalla.service.report; import cn.fw.common.cache.locker.DistributedLocker; import lombok.Getter; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.redisson.api.RLock; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import java.time.LocalDate; /** * 公共池报表数据服务 * * @author : kurisu * @version : 2.0 * @className : PublicReportBizService * @description : 公共池报表数据服务 * @date : 2023-05-04 15:07 */ @Service @Slf4j @RequiredArgsConstructor public class PublicReportBizService { private final DistributedLocker distributedLocker; @Value("${spring.cache.custom.global-prefix}:PublicReport:extracting") @Getter private String keyPrefix; /** * 抽取集团公共池数据 * * @param nowDate 日期 * @param groupId 集团id */ @Transactional(rollbackFor = Exception.class) public void extracting(final LocalDate nowDate, final Long groupId) { log.info("开始抽取公共池报表数据,日期:{} 集团:{}", nowDate, groupId); final String lockKey = generateKey(groupId); RLock lock = (RLock) distributedLocker.lock(lockKey); if (lock == null || !lock.isLocked()) { return; } try { // TODO: 2023/5/4 完成方法 } finally { if (lock.isLocked()) { lock.unlock(); } } } private String generateKey(final Long groupId) { Assert.notNull(groupId, "groupId cannot be null"); return String.format("%s:%s", getKeyPrefix(), groupId); } }