package com.gyee.backconfig.config; import com.gyee.backconfig.model.auto.*; import com.gyee.backconfig.service.auto.*; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.CommandLineRunner; import org.springframework.stereotype.Component; import javax.annotation.Resource; import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; /** * @ClassName : CacheContext * @Author : wang * @Date: 2022/9/26 9:35 * @Description : 缓存 */ @Component public class CacheContext implements CommandLineRunner { @Autowired private IRegionService regionService;//区域 @Resource private ICompanysService companysService;//公司 @Resource private IProjectService projectService;//期次 @Resource private ILineService lineService;//线路 @Resource private IWindpowerstationService windpowerstationService;//场站 @Autowired private IWindturbineService windturbineService;//风机 public static Map regionmap = new HashMap<>(); public static List regions = new ArrayList<>(); public static Map linemap = new HashMap<>(); public static List lines = new ArrayList<>(); public static Map windturbinemap = new HashMap<>(); public static List windturbines = new ArrayList<>(); public static Map promap = new HashMap<>(); public static List prols = new ArrayList<>(); public static Map wpmap = new HashMap<>(); public static List wpls = new ArrayList<>(); public static Map cpmap = new HashMap<>(); public static List cpls = new ArrayList<>(); @Override public void run(String... args) throws Exception { cpls = companysService.list(); cpls.stream().forEach(Companys -> { cpmap.put(Companys.getId(),Companys); }); wpls = windpowerstationService.list(); wpls.stream().forEach(windpowerstation -> { wpmap.put(windpowerstation.getId(),windpowerstation); }); prols = projectService.list(); prols.stream().forEach(Project -> { promap.put(Project.getWindpowerstationid(),Project); }); //区域 regions = regionService.list(); regions.stream().forEach(region -> { regionmap.put(region.getId(), region); }); //线路 lines = lineService.list(); lines.stream().forEach(line -> { linemap.put(line.getId(), line); }); //风机 windturbines = windturbineService.list(); windturbines.stream().forEach(windturbine -> { windturbinemap.put(windturbine.getId(), windturbine); }); } }