OrigplacecodeMappingService.java 1.62 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.entity.OrigplacecodeMapping;
import com.erry.iclear.dateInterface.repository.OrigplacecodeMappingRepository;
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 OrigplacecodeMappingService {

    @Autowired
    private OrigplacecodeMappingRepository origplacecodeMappingRepository;

    public List<OrigplacecodeMapping> findAllOrigplacecodeMapping(){
        List<OrigplacecodeMapping> result = new ArrayList<>();
        try{
            result=origplacecodeMappingRepository.findAllOrigplacecodeMappingList();
        }catch (Exception e){
            log.error("findAllOrigplacecodeMapping() error:"+e.getMessage());
        }
        return result;
    }



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









}