Browse Source

状态计算调整

xieshengjie 2 years ago
parent
commit
058803408d
22 changed files with 672 additions and 221 deletions
  1. 1 0
      common/src/main/java/com/gyee/common/contant/Contant.java
  2. 20 0
      realtime/computing-services7001/src/main/java/com/gyee/generation/controller/ProEconStateAiController.java
  3. 16 1
      realtime/computing-services7001/src/main/java/com/gyee/generation/init/CacheContext.java
  4. 16 0
      realtime/computing-services7001/src/main/java/com/gyee/generation/mapper/auto/ProEconStateAiMapper.java
  5. 30 0
      realtime/computing-services7001/src/main/java/com/gyee/generation/model/auto/ProEconStateAi.java
  6. 103 70
      realtime/computing-services7001/src/main/java/com/gyee/generation/service/StatusService.java
  7. 16 0
      realtime/computing-services7001/src/main/java/com/gyee/generation/service/auto/IProEconStateAiService.java
  8. 20 0
      realtime/computing-services7001/src/main/java/com/gyee/generation/service/auto/impl/ProEconStateAiServiceImpl.java
  9. 20 0
      realtime/computing-services7002/src/main/java/com/gyee/generation/controller/ProEconStateAiController.java
  10. 15 0
      realtime/computing-services7002/src/main/java/com/gyee/generation/init/CacheContext.java
  11. 16 0
      realtime/computing-services7002/src/main/java/com/gyee/generation/mapper/auto/ProEconStateAiMapper.java
  12. 30 0
      realtime/computing-services7002/src/main/java/com/gyee/generation/model/auto/ProEconStateAi.java
  13. 103 70
      realtime/computing-services7002/src/main/java/com/gyee/generation/service/StatusService.java
  14. 16 0
      realtime/computing-services7002/src/main/java/com/gyee/generation/service/auto/IProEconStateAiService.java
  15. 20 0
      realtime/computing-services7002/src/main/java/com/gyee/generation/service/auto/impl/ProEconStateAiServiceImpl.java
  16. 20 0
      realtime/computing-services7003/src/main/java/com/gyee/generation/controller/ProEconStateAiController.java
  17. 16 1
      realtime/computing-services7003/src/main/java/com/gyee/generation/init/CacheContext.java
  18. 16 0
      realtime/computing-services7003/src/main/java/com/gyee/generation/mapper/auto/ProEconStateAiMapper.java
  19. 30 0
      realtime/computing-services7003/src/main/java/com/gyee/generation/model/auto/ProEconStateAi.java
  20. 112 79
      realtime/computing-services7003/src/main/java/com/gyee/generation/service/StatusService.java
  21. 16 0
      realtime/computing-services7003/src/main/java/com/gyee/generation/service/auto/IProEconStateAiService.java
  22. 20 0
      realtime/computing-services7003/src/main/java/com/gyee/generation/service/auto/impl/ProEconStateAiServiceImpl.java

+ 1 - 0
common/src/main/java/com/gyee/common/contant/Contant.java

@@ -69,6 +69,7 @@ public class Contant {
     //判断状态
     public static final String MX000 = "MX000"; //待机
     public static final String MX002 = "MX002";//运行
+    public static final String MX003 = "MX003";//降出力运行
     public static final String MX008 = "MX008";//维护
     public static final String MX006 = "MX006";//故障
 

+ 20 - 0
realtime/computing-services7001/src/main/java/com/gyee/generation/controller/ProEconStateAiController.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@RestController
+@RequestMapping("//pro-econ-state-ai")
+public class ProEconStateAiController {
+
+}

+ 16 - 1
realtime/computing-services7001/src/main/java/com/gyee/generation/init/CacheContext.java

@@ -44,6 +44,8 @@ public class CacheContext implements CommandLineRunner {
     @Resource
     private IWindturbinepowerService windturbinepowerService;
     @Resource
+    private IProEconStateAiService proEconStateAiService;
+    @Resource
     private RedisService redisService;
     @Value("${runWindpowerstation}")
     private String runWindpowerstation;
@@ -67,6 +69,7 @@ public class CacheContext implements CommandLineRunner {
     public static Map<String,Equipmentmodel> modelMap = new HashMap<>();
     public static Map<String,Map<Double,Double>> zzsglMap = new HashMap<>();
     public static Map<String,Double> modelpower = new HashMap<>();
+    public static Map<String,Map<Integer,Integer>> aistateMap = new HashMap<>();
     @Override
     public void run(String... args) throws Exception {
         logger.info("缓存开始------------------------------------------------------------");
@@ -145,7 +148,7 @@ public class CacheContext implements CommandLineRunner {
         });
 
         String sszzt = redisService.get("SSZZT");
-         statusMap = JSONObject.parseObject(sszzt, new TypeReference<Map<String,List<Windturbinestatusdi>>>() {
+        statusMap = JSONObject.parseObject(sszzt, new TypeReference<Map<String,List<Windturbinestatusdi>>>() {
         });
 
 
@@ -166,6 +169,18 @@ public class CacheContext implements CommandLineRunner {
 
         });
 
+        List<ProEconStateAi> proEconStateAis = proEconStateAiService.list();
+        proEconStateAis.stream().forEach(ai->{
+            if (aistateMap.containsKey(ai.getModelid())){
+                aistateMap.get(ai.getModelid()).put(ai.getOriginalState(),ai.getMappingState());
+            }else {
+                Map<Integer,Integer> stateMap = new HashMap<>();
+                stateMap.put(ai.getOriginalState(),ai.getMappingState());
+                aistateMap.put(ai.getModelid(),stateMap);
+            }
+        });
+
+
 //        String wpString = redisService.get("PRODUCT-WP");
 //        wppointmap = JSONObject.parseObject(wpString, new TypeReference<Map<String, Map<String, Windpowerstationpointnew>>>() {
 //        });

+ 16 - 0
realtime/computing-services7001/src/main/java/com/gyee/generation/mapper/auto/ProEconStateAiMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.mapper.auto;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+public interface ProEconStateAiMapper extends BaseMapper<ProEconStateAi> {
+
+}

+ 30 - 0
realtime/computing-services7001/src/main/java/com/gyee/generation/model/auto/ProEconStateAi.java

@@ -0,0 +1,30 @@
+package com.gyee.generation.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconStateAi extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String modelid;
+
+    private Integer originalState;
+
+    private Integer mappingState;
+
+
+}

+ 103 - 70
realtime/computing-services7001/src/main/java/com/gyee/generation/service/StatusService.java

@@ -39,6 +39,7 @@ public class StatusService {
     public static Map<String,List<Project>> wppromap;
     public static Map<String,List<Line>> prolinemap;
     public static Map<String,List<Windturbine>> linewtmap;
+    public static Map<String,Map<Integer,Integer>> aistateMap;
     @Resource
     private IEdosUtil edosUtil;
     //    @Resource
@@ -70,6 +71,7 @@ public class StatusService {
         wppromap = CacheContext.wppromap;
         prolinemap = CacheContext.prolinemap;
         linewtmap = CacheContext.linewtmap;
+        aistateMap = CacheContext.aistateMap;
     }
 
     /**
@@ -141,88 +143,119 @@ public class StatusService {
                         List<PointData> collect = interruptionRealData.stream().filter(i -> (currentDate.getTime() - i.getPointTime()) / 1000 > Integer.parseInt(second)).collect(Collectors.toList());
                         if (collect.size()!=interruptionRealData.size()){
                             Double ztmx = edosUtil.getRealData(ztmxPoint).getPointValueInDouble();
-                            if (ztmx == 7 || ztmx == 9 || ztmx == 10 || ztmx == 11 || ztmx == 4 || ztmx == 5 ){     //手打状态
-                                mxstatus = ztmx;
-                            }
-                            if (clauStatusAi.contains(wt.getProjectid())){
-                                //多状态根据一个点来判断
+//                            if (ztmx == 7 || ztmx == 9 || ztmx == 10 || ztmx == 11 || ztmx == 4 || ztmx == 5 ){     //手打状态
+//                                mxstatus = ztmx;
+//                            }
+                            String aiordi = modelMap.get(wt.getModelid()).getDescription();
+                            if (aiordi.equals("AI")){
+                                Map<Integer, Integer> stateMap = aistateMap.get(wt.getModelid());
                                 Optional<Windturbinestatusdi> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.AI422)).findFirst();
                                 if (first.isPresent()){
                                     Windturbinestatusdi windturbinestatusdi = first.get();
-                                    if (wt.getModelid().equals("EN141/2.65") || wt.getModelid().equals("EN141/3.2")){
-                                        //远景
-                                        int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
-                                        switch (pointValueInDouble){
-                                            case 1:
-                                            case 4:
-                                                mxstatus = 1.0;
-                                                break;
-                                            case 2:
-                                                mxstatus = 6.0;
-                                                break;
-                                            case 3:
-                                                mxstatus = 11.0;
-                                                break;
-                                            case 5:
-                                            case 6:
-                                                mxstatus = 2.0;
-                                                break;
-                                            case 7:
-                                                mxstatus = 4.0;
-                                                break;
-                                            case 8:
-                                                mxstatus = 12.0;
-                                                break;
-                                            case 9:
-                                                mxstatus = 0.0;
-                                                break;
-                                            case 10:
-                                                mxstatus = 10.0;
-                                                break;
-                                            case 11:
-                                            case 12:
-                                                mxstatus = 8.0;
-                                                break;
-                                        }
-                                    }else {
-                                        //联合动力
-                                        double pointValueInDouble = edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
-                                        switch ((int) pointValueInDouble){
-                                            case 0:
-                                                mxstatus = 12.0;
-                                                break;
-                                            case 1:
-                                                mxstatus = 6.0;
-                                                break;
-                                            case 2:
-                                                mxstatus = 8.0;
-                                                break;
-                                            case 3:
-                                                mxstatus = 0.0;
-                                                break;
-                                            case 4:
-                                            case 5:
-                                                mxstatus = 2.0;
-                                                break;
-                                            case 6:
-                                                mxstatus = 1.0;
-                                                break;
-                                            default:
-                                                mxstatus = 2.0;
-                                        }
-                                    }
+                                    int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+                                    mxstatus = (double)stateMap.get(pointValueInDouble);
                                 }
                             }
-                            if (clauStatusDi.contains(wt.getProjectid())){
+
+
+//                            if (clauStatusAi.contains(wt.getProjectid())){
+//                                //多状态根据一个点来判断
+//                                Optional<Windturbinestatusdi> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.AI422)).findFirst();
+//                                if (first.isPresent()){
+//                                    Windturbinestatusdi windturbinestatusdi = first.get();
+//                                    if (wt.getModelid().equals("EN141/2.65") || wt.getModelid().equals("EN141/3.2")){
+//                                        //远景
+//                                        int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+//                                        switch (pointValueInDouble){
+//                                            case 1:
+//                                            case 4:
+//                                                mxstatus = 1.0;
+//                                                break;
+//                                            case 2:
+//                                                mxstatus = 6.0;
+//                                                break;
+//                                            case 3:
+//                                                mxstatus = 11.0;
+//                                                break;
+//                                            case 5:
+//                                            case 6:
+//                                                mxstatus = 2.0;
+//                                                break;
+//                                            case 7:
+//                                                mxstatus = 4.0;
+//                                                break;
+//                                            case 8:
+//                                                mxstatus = 12.0;
+//                                                break;
+//                                            case 9:
+//                                                mxstatus = 0.0;
+//                                                break;
+//                                            case 10:
+//                                                mxstatus = 10.0;
+//                                                break;
+//                                            case 11:
+//                                            case 12:
+//                                                mxstatus = 8.0;
+//                                                break;
+//                                        }
+//                                    }else {
+//                                        //联合动力
+//                                        double pointValueInDouble = edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+//                                        switch ((int) pointValueInDouble){
+//                                            case 0:
+//                                                mxstatus = 12.0;
+//                                                break;
+//                                            case 1:
+//                                                mxstatus = 6.0;
+//                                                break;
+//                                            case 2:
+//                                                mxstatus = 8.0;
+//                                                break;
+//                                            case 3:
+//                                                mxstatus = 0.0;
+//                                                break;
+//                                            case 4:
+//                                            case 5:
+//                                                mxstatus = 2.0;
+//                                                break;
+//                                            case 6:
+//                                                mxstatus = 1.0;
+//                                                break;
+//                                            default:
+//                                                mxstatus = 2.0;
+//                                        }
+//                                    }
+//                                }
+//                            }
+//                            if (clauStatusDi.contains(wt.getProjectid())){
+//                                //每个状态一个状态点
+//                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX004) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
+//                                for(Windturbinestatusdi w : windturbinestatusdis){
+//                                    PointData realData = edosUtil.getRealData(w.getId());
+//                                    if (realData.getPointValueInDouble()==1){
+//                                        mxstatus = Double.parseDouble(w.getTypeid());
+//                                        break;
+//                                    }
+//                                }
+//                            }
+                            else {
                                 //每个状态一个状态点
-                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX004) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
+                                Map<String,String> stateMap = new HashMap<>();
+                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX003) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
                                 for(Windturbinestatusdi w : windturbinestatusdis){
                                     PointData realData = edosUtil.getRealData(w.getId());
                                     if (realData.getPointValueInDouble()==1){
+                                        stateMap.put(w.getUniformcode(),w.getTypeid());
                                         mxstatus = Double.parseDouble(w.getTypeid());
-                                        break;
+//                                        break;
                                     }
                                 }
+                                if (stateMap.containsKey("MX006") && stateMap.containsKey("MX008")){
+                                    mxstatus = Double.parseDouble(stateMap.get("MX008"));
+                                }
+                                if (stateMap.containsKey("MX002") && stateMap.containsKey("MX003")){
+                                    mxstatus = Double.parseDouble(stateMap.get("MX003"));
+                                }
                             }
                             if (mxstatus == 2){
                                 boolean isJcl = isJcl(wt, stringWindturbinetestingpointnewMap);

+ 16 - 0
realtime/computing-services7001/src/main/java/com/gyee/generation/service/auto/IProEconStateAiService.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.service.auto;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+public interface IProEconStateAiService extends IService<ProEconStateAi> {
+
+}

+ 20 - 0
realtime/computing-services7001/src/main/java/com/gyee/generation/service/auto/impl/ProEconStateAiServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.service.auto.impl;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.gyee.generation.mapper.auto.ProEconStateAiMapper;
+import com.gyee.generation.service.auto.IProEconStateAiService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@Service
+public class ProEconStateAiServiceImpl extends ServiceImpl<ProEconStateAiMapper, ProEconStateAi> implements IProEconStateAiService {
+
+}

+ 20 - 0
realtime/computing-services7002/src/main/java/com/gyee/generation/controller/ProEconStateAiController.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@RestController
+@RequestMapping("//pro-econ-state-ai")
+public class ProEconStateAiController {
+
+}

+ 15 - 0
realtime/computing-services7002/src/main/java/com/gyee/generation/init/CacheContext.java

@@ -44,6 +44,8 @@ public class CacheContext implements CommandLineRunner {
     @Resource
     private IWindturbinepowerService windturbinepowerService;
     @Resource
+    private IProEconStateAiService proEconStateAiService;
+    @Resource
     private RedisService redisService;
     @Value("${runWindpowerstation}")
     private String runWindpowerstation;
@@ -67,6 +69,7 @@ public class CacheContext implements CommandLineRunner {
     public static Map<String,Equipmentmodel> modelMap = new HashMap<>();
     public static Map<String,Map<Double,Double>> zzsglMap = new HashMap<>();
     public static Map<String,Double> modelpower = new HashMap<>();
+    public static Map<String,Map<Integer,Integer>> aistateMap = new HashMap<>();
     @Override
     public void run(String... args) throws Exception {
         logger.info("缓存开始------------------------------------------------------------");
@@ -166,6 +169,18 @@ public class CacheContext implements CommandLineRunner {
 
         });
 
+        List<ProEconStateAi> proEconStateAis = proEconStateAiService.list();
+        proEconStateAis.stream().forEach(ai->{
+            if (aistateMap.containsKey(ai.getModelid())){
+                aistateMap.get(ai.getModelid()).put(ai.getOriginalState(),ai.getMappingState());
+            }else {
+                Map<Integer,Integer> stateMap = new HashMap<>();
+                stateMap.put(ai.getOriginalState(),ai.getMappingState());
+                aistateMap.put(ai.getModelid(),stateMap);
+            }
+        });
+
+
 //        String wpString = redisService.get("PRODUCT-WP");
 //        wppointmap = JSONObject.parseObject(wpString, new TypeReference<Map<String, Map<String, Windpowerstationpointnew>>>() {
 //        });

+ 16 - 0
realtime/computing-services7002/src/main/java/com/gyee/generation/mapper/auto/ProEconStateAiMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.mapper.auto;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+public interface ProEconStateAiMapper extends BaseMapper<ProEconStateAi> {
+
+}

+ 30 - 0
realtime/computing-services7002/src/main/java/com/gyee/generation/model/auto/ProEconStateAi.java

@@ -0,0 +1,30 @@
+package com.gyee.generation.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconStateAi extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String modelid;
+
+    private Integer originalState;
+
+    private Integer mappingState;
+
+
+}

+ 103 - 70
realtime/computing-services7002/src/main/java/com/gyee/generation/service/StatusService.java

@@ -39,6 +39,7 @@ public class StatusService {
     public static Map<String,List<Project>> wppromap;
     public static Map<String,List<Line>> prolinemap;
     public static Map<String,List<Windturbine>> linewtmap;
+    public static Map<String,Map<Integer,Integer>> aistateMap;
     @Resource
     private IEdosUtil edosUtil;
     //    @Resource
@@ -70,6 +71,7 @@ public class StatusService {
         wppromap = CacheContext.wppromap;
         prolinemap = CacheContext.prolinemap;
         linewtmap = CacheContext.linewtmap;
+        aistateMap = CacheContext.aistateMap;
     }
 
     /**
@@ -141,88 +143,119 @@ public class StatusService {
                         List<PointData> collect = interruptionRealData.stream().filter(i -> (currentDate.getTime() - i.getPointTime()) / 1000 > Integer.parseInt(second)).collect(Collectors.toList());
                         if (collect.size()!=interruptionRealData.size()){
                             Double ztmx = edosUtil.getRealData(ztmxPoint).getPointValueInDouble();
-                            if (ztmx == 7 || ztmx == 9 || ztmx == 10 || ztmx == 11 || ztmx == 4 || ztmx == 5 ){     //手打状态
-                                mxstatus = ztmx;
-                            }
-                            if (clauStatusAi.contains(wt.getProjectid())){
-                                //多状态根据一个点来判断
+//                            if (ztmx == 7 || ztmx == 9 || ztmx == 10 || ztmx == 11 || ztmx == 4 || ztmx == 5 ){     //手打状态
+//                                mxstatus = ztmx;
+//                            }
+                            String aiordi = modelMap.get(wt.getModelid()).getDescription();
+                            if (aiordi.equals("AI")){
+                                Map<Integer, Integer> stateMap = aistateMap.get(wt.getModelid());
                                 Optional<Windturbinestatusdi> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.AI422)).findFirst();
                                 if (first.isPresent()){
                                     Windturbinestatusdi windturbinestatusdi = first.get();
-                                    if (wt.getModelid().equals("EN141/2.65") || wt.getModelid().equals("EN141/3.2")){
-                                        //远景
-                                        int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
-                                        switch (pointValueInDouble){
-                                            case 1:
-                                            case 4:
-                                                mxstatus = 1.0;
-                                                break;
-                                            case 2:
-                                                mxstatus = 6.0;
-                                                break;
-                                            case 3:
-                                                mxstatus = 11.0;
-                                                break;
-                                            case 5:
-                                            case 6:
-                                                mxstatus = 2.0;
-                                                break;
-                                            case 7:
-                                                mxstatus = 4.0;
-                                                break;
-                                            case 8:
-                                                mxstatus = 12.0;
-                                                break;
-                                            case 9:
-                                                mxstatus = 0.0;
-                                                break;
-                                            case 10:
-                                                mxstatus = 10.0;
-                                                break;
-                                            case 11:
-                                            case 12:
-                                                mxstatus = 8.0;
-                                                break;
-                                        }
-                                    }else {
-                                        //联合动力
-                                        double pointValueInDouble = edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
-                                        switch ((int) pointValueInDouble){
-                                            case 0:
-                                                mxstatus = 12.0;
-                                                break;
-                                            case 1:
-                                                mxstatus = 6.0;
-                                                break;
-                                            case 2:
-                                                mxstatus = 8.0;
-                                                break;
-                                            case 3:
-                                                mxstatus = 0.0;
-                                                break;
-                                            case 4:
-                                            case 5:
-                                                mxstatus = 2.0;
-                                                break;
-                                            case 6:
-                                                mxstatus = 1.0;
-                                                break;
-                                            default:
-                                                mxstatus = 2.0;
-                                        }
-                                    }
+                                    int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+                                    mxstatus = (double)stateMap.get(pointValueInDouble);
                                 }
                             }
-                            if (clauStatusDi.contains(wt.getProjectid())){
+
+
+//                            if (clauStatusAi.contains(wt.getProjectid())){
+//                                //多状态根据一个点来判断
+//                                Optional<Windturbinestatusdi> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.AI422)).findFirst();
+//                                if (first.isPresent()){
+//                                    Windturbinestatusdi windturbinestatusdi = first.get();
+//                                    if (wt.getModelid().equals("EN141/2.65") || wt.getModelid().equals("EN141/3.2")){
+//                                        //远景
+//                                        int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+//                                        switch (pointValueInDouble){
+//                                            case 1:
+//                                            case 4:
+//                                                mxstatus = 1.0;
+//                                                break;
+//                                            case 2:
+//                                                mxstatus = 6.0;
+//                                                break;
+//                                            case 3:
+//                                                mxstatus = 11.0;
+//                                                break;
+//                                            case 5:
+//                                            case 6:
+//                                                mxstatus = 2.0;
+//                                                break;
+//                                            case 7:
+//                                                mxstatus = 4.0;
+//                                                break;
+//                                            case 8:
+//                                                mxstatus = 12.0;
+//                                                break;
+//                                            case 9:
+//                                                mxstatus = 0.0;
+//                                                break;
+//                                            case 10:
+//                                                mxstatus = 10.0;
+//                                                break;
+//                                            case 11:
+//                                            case 12:
+//                                                mxstatus = 8.0;
+//                                                break;
+//                                        }
+//                                    }else {
+//                                        //联合动力
+//                                        double pointValueInDouble = edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+//                                        switch ((int) pointValueInDouble){
+//                                            case 0:
+//                                                mxstatus = 12.0;
+//                                                break;
+//                                            case 1:
+//                                                mxstatus = 6.0;
+//                                                break;
+//                                            case 2:
+//                                                mxstatus = 8.0;
+//                                                break;
+//                                            case 3:
+//                                                mxstatus = 0.0;
+//                                                break;
+//                                            case 4:
+//                                            case 5:
+//                                                mxstatus = 2.0;
+//                                                break;
+//                                            case 6:
+//                                                mxstatus = 1.0;
+//                                                break;
+//                                            default:
+//                                                mxstatus = 2.0;
+//                                        }
+//                                    }
+//                                }
+//                            }
+//                            if (clauStatusDi.contains(wt.getProjectid())){
+//                                //每个状态一个状态点
+//                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX004) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
+//                                for(Windturbinestatusdi w : windturbinestatusdis){
+//                                    PointData realData = edosUtil.getRealData(w.getId());
+//                                    if (realData.getPointValueInDouble()==1){
+//                                        mxstatus = Double.parseDouble(w.getTypeid());
+//                                        break;
+//                                    }
+//                                }
+//                            }
+                            else {
                                 //每个状态一个状态点
-                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX004) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
+                                Map<String,String> stateMap = new HashMap<>();
+                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX003) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
                                 for(Windturbinestatusdi w : windturbinestatusdis){
                                     PointData realData = edosUtil.getRealData(w.getId());
                                     if (realData.getPointValueInDouble()==1){
+                                        stateMap.put(w.getUniformcode(),w.getTypeid());
                                         mxstatus = Double.parseDouble(w.getTypeid());
-                                        break;
+//                                        break;
                                     }
                                 }
+                                if (stateMap.containsKey("MX006") && stateMap.containsKey("MX008")){
+                                    mxstatus = Double.parseDouble(stateMap.get("MX008"));
+                                }
+                                if (stateMap.containsKey("MX002") && stateMap.containsKey("MX003")){
+                                    mxstatus = Double.parseDouble(stateMap.get("MX003"));
+                                }
                             }
                             if (mxstatus == 2){
                                 boolean isJcl = isJcl(wt, stringWindturbinetestingpointnewMap);

+ 16 - 0
realtime/computing-services7002/src/main/java/com/gyee/generation/service/auto/IProEconStateAiService.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.service.auto;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+public interface IProEconStateAiService extends IService<ProEconStateAi> {
+
+}

+ 20 - 0
realtime/computing-services7002/src/main/java/com/gyee/generation/service/auto/impl/ProEconStateAiServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.service.auto.impl;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.gyee.generation.mapper.auto.ProEconStateAiMapper;
+import com.gyee.generation.service.auto.IProEconStateAiService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@Service
+public class ProEconStateAiServiceImpl extends ServiceImpl<ProEconStateAiMapper, ProEconStateAi> implements IProEconStateAiService {
+
+}

+ 20 - 0
realtime/computing-services7003/src/main/java/com/gyee/generation/controller/ProEconStateAiController.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@RestController
+@RequestMapping("//pro-econ-state-ai")
+public class ProEconStateAiController {
+
+}

+ 16 - 1
realtime/computing-services7003/src/main/java/com/gyee/generation/init/CacheContext.java

@@ -44,6 +44,8 @@ public class CacheContext implements CommandLineRunner {
     @Resource
     private IWindturbinepowerService windturbinepowerService;
     @Resource
+    private IProEconStateAiService proEconStateAiService;
+    @Resource
     private RedisService redisService;
     @Value("${runWindpowerstation}")
     private String runWindpowerstation;
@@ -67,6 +69,7 @@ public class CacheContext implements CommandLineRunner {
     public static Map<String,Equipmentmodel> modelMap = new HashMap<>();
     public static Map<String,Map<Double,Double>> zzsglMap = new HashMap<>();
     public static Map<String,Double> modelpower = new HashMap<>();
+    public static Map<String,Map<Integer,Integer>> aistateMap = new HashMap<>();
     @Override
     public void run(String... args) throws Exception {
         logger.info("缓存开始------------------------------------------------------------");
@@ -145,7 +148,7 @@ public class CacheContext implements CommandLineRunner {
         });
 
         String sszzt = redisService.get("SSZZT");
-         statusMap = JSONObject.parseObject(sszzt, new TypeReference<Map<String,List<Windturbinestatusdi>>>() {
+        statusMap = JSONObject.parseObject(sszzt, new TypeReference<Map<String,List<Windturbinestatusdi>>>() {
         });
 
 
@@ -166,6 +169,18 @@ public class CacheContext implements CommandLineRunner {
 
         });
 
+        List<ProEconStateAi> proEconStateAis = proEconStateAiService.list();
+        proEconStateAis.stream().forEach(ai->{
+            if (aistateMap.containsKey(ai.getModelid())){
+                aistateMap.get(ai.getModelid()).put(ai.getOriginalState(),ai.getMappingState());
+            }else {
+                Map<Integer,Integer> stateMap = new HashMap<>();
+                stateMap.put(ai.getOriginalState(),ai.getMappingState());
+                aistateMap.put(ai.getModelid(),stateMap);
+            }
+        });
+
+
 //        String wpString = redisService.get("PRODUCT-WP");
 //        wppointmap = JSONObject.parseObject(wpString, new TypeReference<Map<String, Map<String, Windpowerstationpointnew>>>() {
 //        });

+ 16 - 0
realtime/computing-services7003/src/main/java/com/gyee/generation/mapper/auto/ProEconStateAiMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.mapper.auto;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ *  Mapper 接口
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+public interface ProEconStateAiMapper extends BaseMapper<ProEconStateAi> {
+
+}

+ 30 - 0
realtime/computing-services7003/src/main/java/com/gyee/generation/model/auto/ProEconStateAi.java

@@ -0,0 +1,30 @@
+package com.gyee.generation.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconStateAi extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    private String id;
+
+    private String modelid;
+
+    private Integer originalState;
+
+    private Integer mappingState;
+
+
+}

+ 112 - 79
realtime/computing-services7003/src/main/java/com/gyee/generation/service/StatusService.java

@@ -39,9 +39,10 @@ public class StatusService {
     public static Map<String,List<Project>> wppromap;
     public static Map<String,List<Line>> prolinemap;
     public static Map<String,List<Windturbine>> linewtmap;
+    public static Map<String,Map<Integer,Integer>> aistateMap;
     @Resource
     private IEdosUtil edosUtil;
-//    @Resource
+    //    @Resource
 //    private IEdosUtil edosUtilTd;
     @Value("${clauStatus.ai}")
     private String clauStatusAi;
@@ -70,6 +71,7 @@ public class StatusService {
         wppromap = CacheContext.wppromap;
         prolinemap = CacheContext.prolinemap;
         linewtmap = CacheContext.linewtmap;
+        aistateMap = CacheContext.aistateMap;
     }
 
     /**
@@ -94,15 +96,15 @@ public class StatusService {
             }
             boolean b = realData.stream().allMatch(pointData -> pointData.getPointValueInDouble() == 3.0);
 
-                try {
-                    if (b){
-                        edosUtil.sendSinglePoint(createWpPoint(new AtomicInteger(1),windpowerstationpointnew));
-                    }else{
-                        edosUtil.sendSinglePoint(createWpPoint(new AtomicInteger(0),windpowerstationpointnew));
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
+            try {
+                if (b){
+                    edosUtil.sendSinglePoint(createWpPoint(new AtomicInteger(1),windpowerstationpointnew));
+                }else{
+                    edosUtil.sendSinglePoint(createWpPoint(new AtomicInteger(0),windpowerstationpointnew));
                 }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
 
 
         });
@@ -141,88 +143,119 @@ public class StatusService {
                         List<PointData> collect = interruptionRealData.stream().filter(i -> (currentDate.getTime() - i.getPointTime()) / 1000 > Integer.parseInt(second)).collect(Collectors.toList());
                         if (collect.size()!=interruptionRealData.size()){
                             Double ztmx = edosUtil.getRealData(ztmxPoint).getPointValueInDouble();
-                            if (ztmx == 7 || ztmx == 9 || ztmx == 10 || ztmx == 11 || ztmx == 4 || ztmx == 5 ){     //手打状态
-                                mxstatus = ztmx;
-                            }
-                            if (clauStatusAi.contains(wt.getProjectid())){
-                                //多状态根据一个点来判断
+//                            if (ztmx == 7 || ztmx == 9 || ztmx == 10 || ztmx == 11 || ztmx == 4 || ztmx == 5 ){     //手打状态
+//                                mxstatus = ztmx;
+//                            }
+                            String aiordi = modelMap.get(wt.getModelid()).getDescription();
+                            if (aiordi.equals("AI")){
+                                Map<Integer, Integer> stateMap = aistateMap.get(wt.getModelid());
                                 Optional<Windturbinestatusdi> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.AI422)).findFirst();
                                 if (first.isPresent()){
                                     Windturbinestatusdi windturbinestatusdi = first.get();
-                                    if (wt.getModelid().equals("EN141/2.65") || wt.getModelid().equals("EN141/3.2")){
-                                        //远景
-                                        int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
-                                        switch (pointValueInDouble){
-                                            case 1:
-                                            case 4:
-                                                mxstatus = 1.0;
-                                                break;
-                                            case 2:
-                                                mxstatus = 6.0;
-                                                break;
-                                            case 3:
-                                                mxstatus = 11.0;
-                                                break;
-                                            case 5:
-                                            case 6:
-                                                mxstatus = 2.0;
-                                                break;
-                                            case 7:
-                                                mxstatus = 4.0;
-                                                break;
-                                            case 8:
-                                                mxstatus = 12.0;
-                                                break;
-                                            case 9:
-                                                mxstatus = 0.0;
-                                                break;
-                                            case 10:
-                                                mxstatus = 10.0;
-                                                break;
-                                            case 11:
-                                            case 12:
-                                                mxstatus = 8.0;
-                                                break;
-                                        }
-                                    }else {
-                                        //联合动力
-                                        double pointValueInDouble = edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
-                                        switch ((int) pointValueInDouble){
-                                            case 0:
-                                                mxstatus = 12.0;
-                                                break;
-                                            case 1:
-                                                mxstatus = 6.0;
-                                                break;
-                                            case 2:
-                                                mxstatus = 8.0;
-                                                break;
-                                            case 3:
-                                                mxstatus = 0.0;
-                                                break;
-                                            case 4:
-                                            case 5:
-                                                mxstatus = 2.0;
-                                                break;
-                                            case 6:
-                                                mxstatus = 1.0;
-                                                break;
-                                            default:
-                                                mxstatus = 2.0;
-                                        }
-                                    }
+                                    int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+                                    mxstatus = (double)stateMap.get(pointValueInDouble);
                                 }
                             }
-                            if (clauStatusDi.contains(wt.getProjectid())){
+
+
+//                            if (clauStatusAi.contains(wt.getProjectid())){
+//                                //多状态根据一个点来判断
+//                                Optional<Windturbinestatusdi> first = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.AI422)).findFirst();
+//                                if (first.isPresent()){
+//                                    Windturbinestatusdi windturbinestatusdi = first.get();
+//                                    if (wt.getModelid().equals("EN141/2.65") || wt.getModelid().equals("EN141/3.2")){
+//                                        //远景
+//                                        int pointValueInDouble = (int) edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+//                                        switch (pointValueInDouble){
+//                                            case 1:
+//                                            case 4:
+//                                                mxstatus = 1.0;
+//                                                break;
+//                                            case 2:
+//                                                mxstatus = 6.0;
+//                                                break;
+//                                            case 3:
+//                                                mxstatus = 11.0;
+//                                                break;
+//                                            case 5:
+//                                            case 6:
+//                                                mxstatus = 2.0;
+//                                                break;
+//                                            case 7:
+//                                                mxstatus = 4.0;
+//                                                break;
+//                                            case 8:
+//                                                mxstatus = 12.0;
+//                                                break;
+//                                            case 9:
+//                                                mxstatus = 0.0;
+//                                                break;
+//                                            case 10:
+//                                                mxstatus = 10.0;
+//                                                break;
+//                                            case 11:
+//                                            case 12:
+//                                                mxstatus = 8.0;
+//                                                break;
+//                                        }
+//                                    }else {
+//                                        //联合动力
+//                                        double pointValueInDouble = edosUtil.getRealData(windturbinestatusdi.getId()).getPointValueInDouble();
+//                                        switch ((int) pointValueInDouble){
+//                                            case 0:
+//                                                mxstatus = 12.0;
+//                                                break;
+//                                            case 1:
+//                                                mxstatus = 6.0;
+//                                                break;
+//                                            case 2:
+//                                                mxstatus = 8.0;
+//                                                break;
+//                                            case 3:
+//                                                mxstatus = 0.0;
+//                                                break;
+//                                            case 4:
+//                                            case 5:
+//                                                mxstatus = 2.0;
+//                                                break;
+//                                            case 6:
+//                                                mxstatus = 1.0;
+//                                                break;
+//                                            default:
+//                                                mxstatus = 2.0;
+//                                        }
+//                                    }
+//                                }
+//                            }
+//                            if (clauStatusDi.contains(wt.getProjectid())){
+//                                //每个状态一个状态点
+//                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX004) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
+//                                for(Windturbinestatusdi w : windturbinestatusdis){
+//                                    PointData realData = edosUtil.getRealData(w.getId());
+//                                    if (realData.getPointValueInDouble()==1){
+//                                        mxstatus = Double.parseDouble(w.getTypeid());
+//                                        break;
+//                                    }
+//                                }
+//                            }
+                            else {
                                 //每个状态一个状态点
-                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX004) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
+                                Map<String,String> stateMap = new HashMap<>();
+                                List<Windturbinestatusdi> windturbinestatusdis = statusMap.get(wt.getId()).stream().filter(w -> w.getUniformcode().equals(Contant.MX000) || w.getUniformcode().equals(Contant.MX002) || w.getUniformcode().equals(Contant.MX003) || w.getUniformcode().equals(Contant.MX006) || w.getUniformcode().equals(Contant.MX008)).collect(Collectors.toList());
                                 for(Windturbinestatusdi w : windturbinestatusdis){
                                     PointData realData = edosUtil.getRealData(w.getId());
                                     if (realData.getPointValueInDouble()==1){
+                                        stateMap.put(w.getUniformcode(),w.getTypeid());
                                         mxstatus = Double.parseDouble(w.getTypeid());
-                                        break;
+//                                        break;
                                     }
                                 }
+                                if (stateMap.containsKey("MX006") && stateMap.containsKey("MX008")){
+                                    mxstatus = Double.parseDouble(stateMap.get("MX008"));
+                                }
+                                if (stateMap.containsKey("MX002") && stateMap.containsKey("MX003")){
+                                    mxstatus = Double.parseDouble(stateMap.get("MX003"));
+                                }
                             }
                             if (mxstatus == 2){
                                 boolean isJcl = isJcl(wt, stringWindturbinetestingpointnewMap);

+ 16 - 0
realtime/computing-services7003/src/main/java/com/gyee/generation/service/auto/IProEconStateAiService.java

@@ -0,0 +1,16 @@
+package com.gyee.generation.service.auto;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ *  服务类
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+public interface IProEconStateAiService extends IService<ProEconStateAi> {
+
+}

+ 20 - 0
realtime/computing-services7003/src/main/java/com/gyee/generation/service/auto/impl/ProEconStateAiServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.generation.service.auto.impl;
+
+import com.gyee.generation.model.auto.ProEconStateAi;
+import com.gyee.generation.mapper.auto.ProEconStateAiMapper;
+import com.gyee.generation.service.auto.IProEconStateAiService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ *  服务实现类
+ * </p>
+ *
+ * @author 谢生杰
+ * @since 2023-03-02
+ */
+@Service
+public class ProEconStateAiServiceImpl extends ServiceImpl<ProEconStateAiMapper, ProEconStateAi> implements IProEconStateAiService {
+
+}