|
@@ -15,6 +15,7 @@ import org.springframework.boot.CommandLineRunner;
|
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
@@ -50,119 +51,135 @@ public class CacheContext implements CommandLineRunner {
|
|
|
@Autowired
|
|
|
private IModelpowerrdService modelpowerrdService;
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ public static Map<String, Map<String, Windturbinetestingpointai2>> wtpointMap = new HashMap<>();
|
|
|
+ public static List<Windturbine> wtls = new ArrayList<>();
|
|
|
@Override
|
|
|
public void run(String... args) throws Exception {
|
|
|
|
|
|
Logger logger= LoggerFactory.getLogger(CacheContext.class);
|
|
|
- logger.info("----------------------数据中心点开始");
|
|
|
- //缓存golden 所有点
|
|
|
- List<Datacenter> datacenterList = datacenterService.list();
|
|
|
-
|
|
|
- datacenterList.stream().forEach(i->{
|
|
|
- if (!redisService.hasKey(i.getTableid())){
|
|
|
- QueryWrapper<Datacenterpoint> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.eq("tid",i.getTableid());
|
|
|
- List<Datacenterpoint> realtimedataList = datacenterpointService.list(queryWrapper);
|
|
|
- String s = null;
|
|
|
- try {
|
|
|
- s = JSONUtil.objectToJson(realtimedataList);
|
|
|
- } catch (IOException e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- redisService.set(i.getTableid(),s);
|
|
|
+ logger.info("----------------------缓存开始");
|
|
|
+ wtls = windturbineService.list();
|
|
|
+ List<Windturbinetestingpointai2> wtplist = windturbinetestingpointai2Service.list();
|
|
|
+ for (Windturbinetestingpointai2 pointai : wtplist) {
|
|
|
+ if (wtpointMap.containsKey(pointai.getWindturbineid())){
|
|
|
+ wtpointMap.get(pointai.getWindturbineid()).put(pointai.getUniformcode(),pointai);
|
|
|
+ }else{
|
|
|
+ Map<String, Windturbinetestingpointai2> map = new HashMap<>();
|
|
|
+ map.put(pointai.getUniformcode(),pointai);
|
|
|
+ wtpointMap.put(pointai.getWindturbineid(),map);
|
|
|
}
|
|
|
- });
|
|
|
- logger.info("----------------------数据中心点结束");
|
|
|
- logger.info("----------------------设备点开始");
|
|
|
- //缓存设备点
|
|
|
- if (!redisService.hasKey("WT")){
|
|
|
- Map<String,Map<String,Windturbinetestingpointai2>> wtaimap = new HashMap<>();
|
|
|
- List<Windturbine> windturbineList = windturbineService.list();
|
|
|
- windturbineList.stream().forEach(i->{
|
|
|
- Map<String,Windturbinetestingpointai2> codeaimap = new HashMap<>();
|
|
|
- QueryWrapper<Windturbinetestingpointai2> qw = new QueryWrapper<>();
|
|
|
- qw.eq("windturbineid",i.getId());
|
|
|
- List<Windturbinetestingpointai2> windturbinetestingpointai2List = windturbinetestingpointai2Service.list(qw);
|
|
|
- windturbinetestingpointai2List.stream().forEach(x->{
|
|
|
- codeaimap.put(x.getUniformcode(),x);
|
|
|
- });
|
|
|
- wtaimap.put(i.getId(),codeaimap);
|
|
|
- });
|
|
|
- String s = JSONObject.toJSONString(wtaimap);
|
|
|
- redisService.set("WT",s);
|
|
|
- };
|
|
|
- logger.info("----------------------设备点结束");
|
|
|
- logger.info("----------------------线路点开始");
|
|
|
- //缓存线路点
|
|
|
- if (!redisService.hasKey("LN")){
|
|
|
- Map<String,Map<String, Windpowerstationtestingpoint2>> lnaimap = new HashMap<>();
|
|
|
- List<Line> lineList = lineService.list();
|
|
|
- lineList.stream().forEach(i->{
|
|
|
- Map<String,Windpowerstationtestingpoint2> codeaimap = new HashMap<>();
|
|
|
- QueryWrapper<Windpowerstationtestingpoint2> qw = new QueryWrapper<>();
|
|
|
- qw.eq("windpowerstationid",i.getId());
|
|
|
- List<Windpowerstationtestingpoint2> windpowerstationtestingpoint2List = windpowerstationtestingpoint2Service.list(qw);
|
|
|
- windpowerstationtestingpoint2List.stream().forEach(x->{
|
|
|
- codeaimap.put(x.getUniformcode(),x);
|
|
|
- });
|
|
|
- lnaimap.put(i.getId(),codeaimap);
|
|
|
- });
|
|
|
- String s = JSONObject.toJSONString(lnaimap);
|
|
|
- redisService.set("LN",s);
|
|
|
- };
|
|
|
- logger.info("----------------------线路点结束");
|
|
|
- logger.info("----------------------工程点开始");
|
|
|
- //缓存工程点
|
|
|
- if (!redisService.hasKey("PJ")){
|
|
|
- Map<String,Map<String, Windpowerstationtestingpoint2>> pjaimap = new HashMap<>();
|
|
|
- List<Project> projectList = projectService.list();
|
|
|
- projectList.stream().forEach(i->{
|
|
|
- Map<String,Windpowerstationtestingpoint2> codeaimap = new HashMap<>();
|
|
|
- QueryWrapper<Windpowerstationtestingpoint2> qw = new QueryWrapper<>();
|
|
|
- qw.eq("windpowerstationid",i.getId());
|
|
|
- List<Windpowerstationtestingpoint2> windpowerstationtestingpoint2List = windpowerstationtestingpoint2Service.list(qw);
|
|
|
- windpowerstationtestingpoint2List.stream().forEach(x->{
|
|
|
- codeaimap.put(x.getUniformcode(),x);
|
|
|
- });
|
|
|
- pjaimap.put(i.getId(),codeaimap);
|
|
|
- });
|
|
|
- String s = JSONObject.toJSONString(pjaimap);
|
|
|
- redisService.set("PJ",s);
|
|
|
- };
|
|
|
- logger.info("----------------------工程点结束");
|
|
|
- logger.info("----------------------场站点开始");
|
|
|
- //缓存场站点
|
|
|
- if (!redisService.hasKey("WP")){
|
|
|
- Map<String,Map<String, Windpowerstationtestingpoint2>> wpaimap = new HashMap<>();
|
|
|
- List<Windpowerstation> wpList = windpowerstationService.list();
|
|
|
- List<String> wpids = wpList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
- wpids.add("0");
|
|
|
- wpids.add("-1");
|
|
|
- wpids.add("-2");
|
|
|
- wpids.stream().forEach(i->{
|
|
|
- Map<String,Windpowerstationtestingpoint2> codeaimap = new HashMap<>();
|
|
|
- QueryWrapper<Windpowerstationtestingpoint2> qw = new QueryWrapper<>();
|
|
|
- qw.eq("windpowerstationid",i);
|
|
|
- List<Windpowerstationtestingpoint2> windpowerstationtestingpoint2List = windpowerstationtestingpoint2Service.list(qw);
|
|
|
- windpowerstationtestingpoint2List.stream().forEach(x->{
|
|
|
- codeaimap.put(x.getUniformcode(),x);
|
|
|
- });
|
|
|
- wpaimap.put(i,codeaimap);
|
|
|
- });
|
|
|
- String s = JSONObject.toJSONString(wpaimap);
|
|
|
-
|
|
|
- redisService.set("WP",s);
|
|
|
- };
|
|
|
- logger.info("----------------------场站点结束");
|
|
|
- logger.info("----------------------MODELPOWERRD表开始");
|
|
|
- if (!redisService.hasKey("MPRD")){
|
|
|
- List<Modelpowerrd> mordlist = modelpowerrdService.list();
|
|
|
- String s = JSONObject.toJSONString(mordlist);
|
|
|
- redisService.set("MPRD",s);
|
|
|
}
|
|
|
- logger.info("----------------------MODELPOWERRD表结束");
|
|
|
+
|
|
|
+ logger.info("----------------------缓存结束");
|
|
|
+
|
|
|
+
|
|
|
+ logger.info("----------------------数据中心点开始");
|
|
|
+ //缓存golden 所有点
|
|
|
+// List<Datacenter> datacenterList = datacenterService.list();
|
|
|
+//
|
|
|
+// datacenterList.stream().forEach(i->{
|
|
|
+// if (!redisService.hasKey(i.getTableid())){
|
|
|
+// QueryWrapper<Datacenterpoint> queryWrapper = new QueryWrapper<>();
|
|
|
+// queryWrapper.eq("tid",i.getTableid());
|
|
|
+// List<Datacenterpoint> realtimedataList = datacenterpointService.list(queryWrapper);
|
|
|
+// String s = null;
|
|
|
+// try {
|
|
|
+// s = JSONUtil.objectToJson(realtimedataList);
|
|
|
+// } catch (IOException e) {
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
+// redisService.set(i.getTableid(),s);
|
|
|
+// }
|
|
|
+// });
|
|
|
+// logger.info("----------------------数据中心点结束");
|
|
|
+// logger.info("----------------------设备点开始");
|
|
|
+// //缓存设备点
|
|
|
+// if (!redisService.hasKey("WT")){
|
|
|
+// Map<String,Map<String,Windturbinetestingpointai2>> wtaimap = new HashMap<>();
|
|
|
+// List<Windturbine> windturbineList = windturbineService.list();
|
|
|
+// windturbineList.stream().forEach(i->{
|
|
|
+// Map<String,Windturbinetestingpointai2> codeaimap = new HashMap<>();
|
|
|
+// QueryWrapper<Windturbinetestingpointai2> qw = new QueryWrapper<>();
|
|
|
+// qw.eq("windturbineid",i.getId());
|
|
|
+// List<Windturbinetestingpointai2> windturbinetestingpointai2List = windturbinetestingpointai2Service.list(qw);
|
|
|
+// windturbinetestingpointai2List.stream().forEach(x->{
|
|
|
+// codeaimap.put(x.getUniformcode(),x);
|
|
|
+// });
|
|
|
+// wtaimap.put(i.getId(),codeaimap);
|
|
|
+// });
|
|
|
+// String s = JSONObject.toJSONString(wtaimap);
|
|
|
+// redisService.set("WT",s);
|
|
|
+// };
|
|
|
+// logger.info("----------------------设备点结束");
|
|
|
+// logger.info("----------------------线路点开始");
|
|
|
+// //缓存线路点
|
|
|
+// if (!redisService.hasKey("LN")){
|
|
|
+// Map<String,Map<String, Windpowerstationtestingpoint2>> lnaimap = new HashMap<>();
|
|
|
+// List<Line> lineList = lineService.list();
|
|
|
+// lineList.stream().forEach(i->{
|
|
|
+// Map<String,Windpowerstationtestingpoint2> codeaimap = new HashMap<>();
|
|
|
+// QueryWrapper<Windpowerstationtestingpoint2> qw = new QueryWrapper<>();
|
|
|
+// qw.eq("windpowerstationid",i.getId());
|
|
|
+// List<Windpowerstationtestingpoint2> windpowerstationtestingpoint2List = windpowerstationtestingpoint2Service.list(qw);
|
|
|
+// windpowerstationtestingpoint2List.stream().forEach(x->{
|
|
|
+// codeaimap.put(x.getUniformcode(),x);
|
|
|
+// });
|
|
|
+// lnaimap.put(i.getId(),codeaimap);
|
|
|
+// });
|
|
|
+// String s = JSONObject.toJSONString(lnaimap);
|
|
|
+// redisService.set("LN",s);
|
|
|
+// };
|
|
|
+// logger.info("----------------------线路点结束");
|
|
|
+// logger.info("----------------------工程点开始");
|
|
|
+// //缓存工程点
|
|
|
+// if (!redisService.hasKey("PJ")){
|
|
|
+// Map<String,Map<String, Windpowerstationtestingpoint2>> pjaimap = new HashMap<>();
|
|
|
+// List<Project> projectList = projectService.list();
|
|
|
+// projectList.stream().forEach(i->{
|
|
|
+// Map<String,Windpowerstationtestingpoint2> codeaimap = new HashMap<>();
|
|
|
+// QueryWrapper<Windpowerstationtestingpoint2> qw = new QueryWrapper<>();
|
|
|
+// qw.eq("windpowerstationid",i.getId());
|
|
|
+// List<Windpowerstationtestingpoint2> windpowerstationtestingpoint2List = windpowerstationtestingpoint2Service.list(qw);
|
|
|
+// windpowerstationtestingpoint2List.stream().forEach(x->{
|
|
|
+// codeaimap.put(x.getUniformcode(),x);
|
|
|
+// });
|
|
|
+// pjaimap.put(i.getId(),codeaimap);
|
|
|
+// });
|
|
|
+// String s = JSONObject.toJSONString(pjaimap);
|
|
|
+// redisService.set("PJ",s);
|
|
|
+// };
|
|
|
+// logger.info("----------------------工程点结束");
|
|
|
+// logger.info("----------------------场站点开始");
|
|
|
+// //缓存场站点
|
|
|
+// if (!redisService.hasKey("WP")){
|
|
|
+// Map<String,Map<String, Windpowerstationtestingpoint2>> wpaimap = new HashMap<>();
|
|
|
+// List<Windpowerstation> wpList = windpowerstationService.list();
|
|
|
+// List<String> wpids = wpList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
+// wpids.add("0");
|
|
|
+// wpids.add("-1");
|
|
|
+// wpids.add("-2");
|
|
|
+// wpids.stream().forEach(i->{
|
|
|
+// Map<String,Windpowerstationtestingpoint2> codeaimap = new HashMap<>();
|
|
|
+// QueryWrapper<Windpowerstationtestingpoint2> qw = new QueryWrapper<>();
|
|
|
+// qw.eq("windpowerstationid",i);
|
|
|
+// List<Windpowerstationtestingpoint2> windpowerstationtestingpoint2List = windpowerstationtestingpoint2Service.list(qw);
|
|
|
+// windpowerstationtestingpoint2List.stream().forEach(x->{
|
|
|
+// codeaimap.put(x.getUniformcode(),x);
|
|
|
+// });
|
|
|
+// wpaimap.put(i,codeaimap);
|
|
|
+// });
|
|
|
+// String s = JSONObject.toJSONString(wpaimap);
|
|
|
+//
|
|
|
+// redisService.set("WP",s);
|
|
|
+// };
|
|
|
+// logger.info("----------------------场站点结束");
|
|
|
+// logger.info("----------------------MODELPOWERRD表开始");
|
|
|
+// if (!redisService.hasKey("MPRD")){
|
|
|
+// List<Modelpowerrd> mordlist = modelpowerrdService.list();
|
|
|
+// String s = JSONObject.toJSONString(mordlist);
|
|
|
+// redisService.set("MPRD",s);
|
|
|
+// }
|
|
|
+// logger.info("----------------------MODELPOWERRD表结束");
|
|
|
|
|
|
|
|
|
}
|