zhang
2025-05-20 1313906bb1eb983d3beece810035e7fc28d6a92f
zy-acs-manager/src/main/java/com/zy/acs/manager/manager/service/impl/CodeServiceImpl.java
@@ -12,15 +12,18 @@
import com.zy.acs.manager.manager.service.CodeGapService;
import com.zy.acs.manager.manager.service.CodeService;
import com.zy.acs.manager.manager.service.RouteService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostConstruct;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Slf4j
@Service("codeService")
public class CodeServiceImpl extends ServiceImpl<CodeMapper, Code> implements CodeService {
@@ -38,6 +41,7 @@
            CODE_ID_CACHE.put(code.getId(), code);
            CODE_DATA_CACHE.put(code.getData(), code);
        }
        log.info("The code cache was initialized...");
    }
    @Override
@@ -50,6 +54,9 @@
        Code code = CODE_ID_CACHE.get(id);
        if (code == null) {
            code = this.getById(id);
            if (code != null) {
                CODE_ID_CACHE.put(id, code);
            }
        }
        return code;
    }
@@ -59,6 +66,9 @@
        Code code = CODE_DATA_CACHE.get(data);
        if (code == null) {
            code = this.selectByData(data);
            if (null != code) {
                CODE_DATA_CACHE.put(data, code);
            }
        }
        return code;
    }
@@ -198,4 +208,14 @@
        return this.baseMapper.selectDistinctCountFromY();
    }
    @Override
    public List<Code> getAllLocCode() {
        List<Long> ids = this.baseMapper.selectAllLocCode();
        List<Code> codeList = new ArrayList<>();
        for (Long id : ids) {
            codeList.add(this.getById(id));
        }
        return codeList;
    }
}