DomesticDestinationMappingService.java 1.7 KB
package com.erry.iclear.dateInterface.service;

import com.erry.iclear.dateInterface.common.Constant;
import com.erry.iclear.dateInterface.entity.AppInfo;
import com.erry.iclear.dateInterface.entity.DomesticDestinationMapping;
import com.erry.iclear.dateInterface.repository.DomesticDestinationMappingRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * @author Administrator
 */
@Service
@Slf4j
public class DomesticDestinationMappingService {

    @Autowired
    private DomesticDestinationMappingRepository domesticDestinationMappingRepository;

    public List<DomesticDestinationMapping> findAllDomesticDestinationMapping(){
        List<DomesticDestinationMapping> result = new ArrayList<>();
        try{
            result=domesticDestinationMappingRepository.findAllDomesticDestinationMapping();
        }catch (Exception e){
            log.error("findAllDomesticDestinationMapping() error:" + e.getMessage());
        }
        return result;
    }


    /**
     * 初始化DomesticDestinationMapping
     */
    public void initDomesticDestinationMapping() {
        try {
            Constant.domesticDestinationMappingCache.clear();
            List<DomesticDestinationMapping> domList = this.findAllDomesticDestinationMapping();
            for (DomesticDestinationMapping dom : domList) {
                Constant.domesticDestinationMappingCache.put(dom.getDistrictCode(), dom);
            }
        } catch (Exception e) {
            log.error("initDomesticDestinationMapping() error" + e.getMessage());
        }
    }







}