PublicReportBizService.java
1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
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);
}
}