12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- package com.gyee.generation.init;
- import com.alibaba.fastjson.JSONObject;
- import com.alibaba.fastjson.TypeReference;
- import com.gyee.generation.model.auto.*;
- import com.gyee.generation.service.auto.*;
- import com.gyee.generation.util.redis.RedisService;
- import org.slf4j.Logger;
- import org.slf4j.LoggerFactory;
- 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 : xieshengjie
- * @Date: 2021/5/18 9:35
- * @Description : 缓存
- */
- @Component
- public class CacheContext implements CommandLineRunner {
- Logger logger = LoggerFactory.getLogger(CacheContext.class);
- @Resource
- private IWindturbineService windturbineService;
- @Resource
- private ILineService lineService;
- @Resource
- private IProjectService projectService;
- @Resource
- private IWindpowerstationService windpowerstationService;
- @Resource
- private IMeterpointService meterpointService;
- @Resource
- private RedisService redisService;
- public static List<Windturbine> wtls = new ArrayList<>();
- public static List<Project> projects = new ArrayList<>();
- public static List<Line> lines = new ArrayList<>();
- public static List<Windpowerstation> wpls = new ArrayList<>();
- public static List<Meterpoint> meterpoints = new ArrayList<>();
- public static Map<String,List<Project>> wppromap = new HashMap<>();
- public static Map<String,List<Line>> prolinemap = new HashMap<>();
- public static Map<String, Map<String, Windturbinetestingpointnew>> wtpAimap = new HashMap<>();// 风电机测点AI表
- public static Map<String,Map<String, Windpowerstationpointnew>> linepointmap =new HashMap<>();
- public static Map<String,Map<String, Windpowerstationpointnew>> propointmap =new HashMap<>();
- public static Map<String,Map<String, Windpowerstationpointnew>> wppointmap =new HashMap<>();
- @Override
- public void run(String... args) throws Exception {
- logger.info("缓存开始------------------------------------------------------------");
- wtls = windturbineService.list();
- lines = lineService.list();
- lines.stream().forEach(l->{
- if (prolinemap.containsKey(l.getProjectid())){
- prolinemap.get(l.getProjectid()).add(l);
- }else {
- List<Line> lineList = new ArrayList<>();
- lineList.add(l);
- prolinemap.put(l.getProjectid(),lineList);
- }
- });
- projects = projectService.list();
- projects.stream().forEach(p->{
- if (wppromap.containsKey(p.getWindpowerstationid())){
- wppromap.get(p.getWindpowerstationid()).add(p);
- }else {
- List<Project> prolist = new ArrayList<>();
- prolist.add(p);
- wppromap.put(p.getWindpowerstationid(),prolist);
- }
- });
- wpls = windpowerstationService.list();
- meterpoints = meterpointService.list();
- String wpString = redisService.get("PRODUCT-WP");
- wppointmap = JSONObject.parseObject(wpString, new TypeReference<Map<String, Map<String, Windpowerstationpointnew>>>() {
- });
- String pjString = redisService.get("PRODUCT-PJ");
- propointmap = JSONObject.parseObject(pjString, new TypeReference<Map<String, Map<String, Windpowerstationpointnew>>>() {
- });
- String lnString = redisService.get("PRODUCT-LN");
- linepointmap = JSONObject.parseObject(lnString, new TypeReference<Map<String, Map<String, Windpowerstationpointnew>>>() {
- });
- String wtString = redisService.get("PRODUCT-WT");
- wtpAimap = JSONObject.parseObject(wtString, new TypeReference<Map<String, Map<String, Windturbinetestingpointnew>>>() {
- });
- logger.info("缓存结束------------------------------------------------------------");
- }
- }
|