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);
|
}
|
|
}
|