#
Junjie
1 天以前 c4b6b51afdd3374735ed5f358457987eaa6e476f
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
package com.zy.core.config;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.service.LocMastService;
import com.zy.common.utils.RedisUtil;
import com.zy.core.enums.RedisKeyType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import javax.annotation.PostConstruct;
import java.util.HashMap;
import java.util.List;
 
@Component
public class PointInitializer {
 
    @Autowired
    private RedisUtil redisUtil;
    @Autowired
    private LocMastService locMastService;
 
    @PostConstruct
    public void init() {
        HashMap<String, String> pointMap = new HashMap<>();
        HashMap<String, String> locMap = new HashMap<>();
 
        List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<>());
        for (LocMast locMast : locMasts) {
            String locNo = locMast.getLocNo();
            String qrCodeValue = locMast.getQrCodeValue();
            pointMap.put(locNo, qrCodeValue);
            locMap.put(qrCodeValue, locNo);
        }
 
        redisUtil.set(RedisKeyType.POINT_MAP.key, pointMap);
        redisUtil.set(RedisKeyType.LOC_MAP.key, locMap);
    }
 
}