Browse Source

添加风场编号查询线路信息接口

shilin 3 years ago
parent
commit
018e0fbcb7

+ 118 - 6
src/main/java/com/gyee/frame/common/quartz/QuartzSchedulerUtil.java

@@ -1,20 +1,20 @@
 package com.gyee.frame.common.quartz;
 
+import com.gyee.frame.common.spring.SpringUtils;
+import com.gyee.frame.model.auto.SysQuartzJob;
+import com.gyee.frame.model.auto.SysQuartzJobExample;
+import com.gyee.frame.service.SysQuartzJobService;
+import com.gyee.frame.util.StringUtils;
 import org.quartz.*;
 import org.quartz.impl.JobDetailImpl;
 import org.quartz.impl.matchers.GroupMatcher;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.context.annotation.Configuration;
-import com.gyee.frame.model.auto.SysQuartzJob;
-import com.gyee.frame.model.auto.SysQuartzJobExample;
-import com.gyee.frame.service.SysQuartzJobService;
-import com.gyee.frame.util.StringUtils;
 
+import javax.annotation.PostConstruct;
 import java.util.List;
 import java.util.Set;
 
-import javax.annotation.PostConstruct;
-
 /**
  * @CLASSNAME QuartzConfig
  * @Description  Quartz配置类
@@ -295,4 +295,116 @@ public class QuartzSchedulerUtil {
         	 }
         }
     }
+
+    /**
+     * @purpose 根据socket 对一些job任务进行管制
+     */
+    @Configuration
+    public static class SocketTaskUtil {
+        private QuartzSchedulerUtil quartzSchedulerUtil = SpringUtils.getBean(QuartzSchedulerUtil.class);
+        private SysQuartzJobService sysQuartzJobService = SpringUtils.getBean(SysQuartzJobService.class);
+
+        String template="*";
+
+        public void pauseJob(SysQuartzJob sysQuartzJob){
+            quartzSchedulerUtil.pauseJob(sysQuartzJob);
+        }
+        public void startJob(SysQuartzJob sysQuartzJob){
+
+            try {
+                quartzSchedulerUtil.run(sysQuartzJob);
+            } catch (SchedulerException e) {
+                e.printStackTrace();
+            }
+        }
+        public void deleteJob(SysQuartzJob sysQuartzJob){
+            quartzSchedulerUtil.deleteJob(sysQuartzJob);
+        }
+        /**
+         *
+         *@description: 该方法通过计算jobid来找到job,通过job的对象来进一步控制job任务,用来重启某一具体的任务
+         *
+         *@param:[jobid] job的编码
+         *
+         *@return:void
+         *
+         *@createTime:2020/1/9
+         *
+         */
+        public void restartJob(String jobid){
+
+            List<SysQuartzJob> quartzJobs=sysQuartzJobService.selectByExample(new SysQuartzJobExample());
+            SysQuartzJob sysQuartzJob1 = null;
+            //找到具体的任务
+            for(SysQuartzJob sysQuartzJob:quartzJobs){
+                if(sysQuartzJob.getId().equalsIgnoreCase(jobid)){
+                    sysQuartzJob1=sysQuartzJob;
+                    break;
+                }
+            }
+            this.deleteJob(sysQuartzJob1);//符合标准步骤删除-创建-启动流程
+            try {
+               // //System.out.println(sysQuartzJob1.getJobName());
+
+                sysQuartzJob1.setStatus(0);//开启任务
+
+                quartzSchedulerUtil.createSchedule(sysQuartzJob1);
+
+                //startJob(sysQuartzJob1);
+            } catch (SchedulerException e) {
+                e.printStackTrace();
+            }
+            //this.startJob(sysQuartzJob1);
+        }
+
+
+        public void restartJob(String jobid,String params){
+
+            List<SysQuartzJob> quartzJobs=sysQuartzJobService.selectByExample(new SysQuartzJobExample());
+            SysQuartzJob sysQuartzJob1 = null;
+            //找到具体的任务
+            for(SysQuartzJob sysQuartzJob:quartzJobs){
+                if(sysQuartzJob.getId().equalsIgnoreCase(jobid)){
+                    sysQuartzJob1=sysQuartzJob;
+                    break;
+                }
+            }
+            this.deleteJob(sysQuartzJob1);//符合标准步骤删除-创建-启动流程
+            try {
+                // //System.out.println(sysQuartzJob1.getJobName());
+
+                sysQuartzJob1.setStatus(0);//开启任务
+
+                if(StringUtils.notEmp(params))
+                {
+                    String temp=sysQuartzJob1.getInvokeTarget().replace(template,params);
+                    sysQuartzJob1.setInvokeTarget(temp);
+                }
+
+                quartzSchedulerUtil.createSchedule(sysQuartzJob1);
+
+                //startJob(sysQuartzJob1);
+            } catch (SchedulerException e) {
+                e.printStackTrace();
+            }
+            //this.startJob(sysQuartzJob1);
+        }
+        public void deleteJob(String jobid){
+
+            List<SysQuartzJob> quartzJobs=sysQuartzJobService.selectByExample(new SysQuartzJobExample());
+            SysQuartzJob sysQuartzJob1 = null;
+            //找到具体的任务
+            for(SysQuartzJob sysQuartzJob:quartzJobs){
+                if(sysQuartzJob.getId().equalsIgnoreCase(jobid)){
+                    sysQuartzJob1=sysQuartzJob;
+                    break;
+                }
+            }
+            if(sysQuartzJob1!=null)
+            {
+                this.deleteJob(sysQuartzJob1);
+            }
+
+        }
+    }
 }

+ 24 - 0
src/main/java/com/gyee/frame/common/quartz/task/HealthMatrixTask.java

@@ -0,0 +1,24 @@
+package com.gyee.frame.common.quartz.task;
+
+
+import com.gyee.frame.common.websocket.WebsocketMessageService;
+import com.gyee.frame.service.health.HealthMainService;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
+import java.util.Map;
+
+@Component("healthMatrixTask")
+public class HealthMatrixTask {
+    @Resource
+    private HealthMainService healthMainService;
+    @Resource
+    private WebsocketMessageService websocketMessageService;
+
+    public void healthMatrixTask(String destination) throws Exception {
+
+        Map<String, Object> map=healthMainService.findHealthMatrix();
+
+        websocketMessageService.SendAlertToAll(destination,map);
+    }
+}

+ 0 - 125
src/main/java/com/gyee/frame/common/quartz/task/SocketTaskUtil.java

@@ -1,125 +0,0 @@
-package com.gyee.frame.common.quartz.task;
-
-import com.gyee.frame.common.quartz.QuartzSchedulerUtil;
-
-import com.gyee.frame.common.spring.SpringUtils;
-import com.gyee.frame.model.auto.SysQuartzJob;
-import com.gyee.frame.model.auto.SysQuartzJobExample;
-import com.gyee.frame.service.SysQuartzJobService;
-import com.gyee.frame.util.StringUtils;
-import org.quartz.SchedulerException;
-import org.springframework.context.annotation.Configuration;
-
-import java.util.List;
-
-/**
- * @purpose 根据socket 对一些job任务进行管制
- */
-@Configuration
-public class SocketTaskUtil {
-    private QuartzSchedulerUtil quartzSchedulerUtil = SpringUtils.getBean(QuartzSchedulerUtil.class);
-    private SysQuartzJobService sysQuartzJobService = SpringUtils.getBean(SysQuartzJobService.class);
-
-    String template="*";
-
-    public void pauseJob(SysQuartzJob sysQuartzJob){
-        quartzSchedulerUtil.pauseJob(sysQuartzJob);
-    }
-    public void startJob(SysQuartzJob sysQuartzJob){
-
-        try {
-            quartzSchedulerUtil.run(sysQuartzJob);
-        } catch (SchedulerException e) {
-            e.printStackTrace();
-        }
-    }
-    public void deleteJob(SysQuartzJob sysQuartzJob){
-        quartzSchedulerUtil.deleteJob(sysQuartzJob);
-    }
-    /**
-     *
-     *@description: 该方法通过计算jobid来找到job,通过job的对象来进一步控制job任务,用来重启某一具体的任务
-     *
-     *@param:[jobid] job的编码
-     *
-     *@return:void
-     *
-     *@createTime:2020/1/9
-     *
-     */
-    public void restartJob(String jobid){
-
-        List<SysQuartzJob> quartzJobs=sysQuartzJobService.selectByExample(new SysQuartzJobExample());
-        SysQuartzJob sysQuartzJob1 = null;
-        //找到具体的任务
-        for(SysQuartzJob sysQuartzJob:quartzJobs){
-            if(sysQuartzJob.getId().equalsIgnoreCase(jobid)){
-                sysQuartzJob1=sysQuartzJob;
-                break;
-            }
-        }
-        this.deleteJob(sysQuartzJob1);//符合标准步骤删除-创建-启动流程
-        try {
-           // //System.out.println(sysQuartzJob1.getJobName());
-
-            sysQuartzJob1.setStatus(0);//开启任务
-
-            quartzSchedulerUtil.createSchedule(sysQuartzJob1);
-
-            //startJob(sysQuartzJob1);
-        } catch (SchedulerException e) {
-            e.printStackTrace();
-        }
-        //this.startJob(sysQuartzJob1);
-    }
-
-
-    public void restartJob(String jobid,String params){
-
-        List<SysQuartzJob> quartzJobs=sysQuartzJobService.selectByExample(new SysQuartzJobExample());
-        SysQuartzJob sysQuartzJob1 = null;
-        //找到具体的任务
-        for(SysQuartzJob sysQuartzJob:quartzJobs){
-            if(sysQuartzJob.getId().equalsIgnoreCase(jobid)){
-                sysQuartzJob1=sysQuartzJob;
-                break;
-            }
-        }
-        this.deleteJob(sysQuartzJob1);//符合标准步骤删除-创建-启动流程
-        try {
-            // //System.out.println(sysQuartzJob1.getJobName());
-
-            sysQuartzJob1.setStatus(0);//开启任务
-
-            if(StringUtils.notEmp(params))
-            {
-                String temp=sysQuartzJob1.getInvokeTarget().replace(template,params);
-                sysQuartzJob1.setInvokeTarget(temp);
-            }
-
-            quartzSchedulerUtil.createSchedule(sysQuartzJob1);
-
-            //startJob(sysQuartzJob1);
-        } catch (SchedulerException e) {
-            e.printStackTrace();
-        }
-        //this.startJob(sysQuartzJob1);
-    }
-    public void deleteJob(String jobid){
-
-        List<SysQuartzJob> quartzJobs=sysQuartzJobService.selectByExample(new SysQuartzJobExample());
-        SysQuartzJob sysQuartzJob1 = null;
-        //找到具体的任务
-        for(SysQuartzJob sysQuartzJob:quartzJobs){
-            if(sysQuartzJob.getId().equalsIgnoreCase(jobid)){
-                sysQuartzJob1=sysQuartzJob;
-                break;
-            }
-        }
-        if(sysQuartzJob1!=null)
-        {
-            this.deleteJob(sysQuartzJob1);
-        }
-
-    }
-}

+ 2 - 2
src/main/java/com/gyee/frame/common/websocket/ClientInboundChannelInterceptor.java

@@ -1,6 +1,6 @@
 package com.gyee.frame.common.websocket;
 
-import com.gyee.frame.common.quartz.task.SocketTaskUtil;
+import com.gyee.frame.common.quartz.QuartzSchedulerUtil;
 import com.gyee.frame.util.StringUtils;
 import org.springframework.messaging.Message;
 import org.springframework.messaging.MessageChannel;
@@ -19,7 +19,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
  * websocket建立链接的时候获取headeri里认证的参数拦截器。
  */
 @Component
-public class ClientInboundChannelInterceptor extends SocketTaskUtil implements ChannelInterceptor {
+public class ClientInboundChannelInterceptor extends QuartzSchedulerUtil.SocketTaskUtil implements ChannelInterceptor {
 
 
 

+ 4 - 2
src/main/java/com/gyee/frame/common/websocket/WebSocketCache.java

@@ -1,6 +1,6 @@
 package com.gyee.frame.common.websocket;
 
-import com.gyee.frame.common.quartz.task.SocketTaskUtil;
+import com.gyee.frame.common.quartz.QuartzSchedulerUtil;
 import org.springframework.context.event.EventListener;
 import org.springframework.messaging.simp.stomp.StompHeaderAccessor;
 import org.springframework.stereotype.Component;
@@ -9,7 +9,7 @@ import org.springframework.web.socket.messaging.SessionDisconnectEvent;
 import java.util.concurrent.CopyOnWriteArraySet;
 
 @Component
-public class WebSocketCache  extends SocketTaskUtil {
+public class WebSocketCache  extends QuartzSchedulerUtil.SocketTaskUtil {
 
 //    public static ConcurrentHashMap<String, CopyOnWriteArraySet<String>> websocketcacheMap = new ConcurrentHashMap();
 //
@@ -72,6 +72,7 @@ public class WebSocketCache  extends SocketTaskUtil {
 
                     if(set.size()==0)
                     {
+                        WebSocketConfig.websocketcacheMap.remove(topic);
                         this.deleteJob(topic);
                     }
                 }
@@ -98,6 +99,7 @@ public class WebSocketCache  extends SocketTaskUtil {
 
                     if(set.size()==0)
                     {
+                        WebSocketConfig.websocketparamcacheMap.remove(topic);
                         this.deleteJob(topic);
                     }
                 }

+ 46 - 1
src/main/java/com/gyee/frame/controller/powercompare/PowerCompareController.java

@@ -152,6 +152,7 @@ public class PowerCompareController {
             return	AjaxResult.successData(AjaxStatus.emptyresultset.code,vos);
         }
     }
+
     /**
      * 线路下拉接口
      * @return
@@ -159,7 +160,7 @@ public class PowerCompareController {
     @GetMapping("/lineAjax")
     @ResponseBody
     @CrossOrigin
-    @ApiOperation(value = "通过项目编号查询项目数据列表", notes = "通过项目编号查询项目数据列表")
+    @ApiOperation(value = "通过项目编号查询线路数据列表", notes = "通过项目编号查询线路数据列表")
     @ApiImplicitParams({
             @ApiImplicitParam(name = "pjIds", value = "项目编号", required = true, dataType = "string", paramType = "query")})
 
@@ -192,6 +193,50 @@ public class PowerCompareController {
      * 线路下拉接口
      * @return
      */
+    @GetMapping("/lineWpIdAjax")
+    @ResponseBody
+    @CrossOrigin
+    @ApiOperation(value = "通过风场编号查询线路数据列表", notes = "通过项目编号查询线路数据列表")
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "wpId", value = "风场编号", required = true, dataType = "string", paramType = "query")})
+
+    public AjaxResult lineWpIdAjax(String wpId) {
+        List<StopTypeTreeVo> vos = new ArrayList<StopTypeTreeVo>();
+        if (StringUtils.notEmp(wpId)) {
+
+            if(InitialRunner.wpmap.containsKey(wpId))
+            {
+                List<String>  ids=new ArrayList<>();
+                for (Project project : InitialRunner.pjsmap.get(wpId)) {
+                    ids.add(project.getId());
+                }
+
+                for (String id : ids) {
+                    for (Line line : InitialRunner.lnsmap.get(id)) {
+
+                        StopTypeTreeVo vo = new StopTypeTreeVo();
+                        vo.setId(line.getId());
+                        vo.setName(line.getName());
+                        vo.setpId("0");
+                        vos.add(vo);
+                    }
+                }
+            }
+
+
+        }
+        if(vos !=null && !vos.isEmpty())
+        {
+            return	AjaxResult.successData(AjaxStatus.success.code,vos);
+        }else
+        {
+            return	AjaxResult.successData(AjaxStatus.emptyresultset.code,vos);
+        }
+    }
+    /**
+     * 线路下拉接口
+     * @return
+     */
     @GetMapping("/lineAllAjax")
     @ResponseBody
     @CrossOrigin

+ 1 - 2
src/main/java/com/gyee/frame/service/websocket/BraceletService.java

@@ -9,7 +9,6 @@ import com.gyee.frame.model.custom.PointData;
 import com.gyee.frame.service.WindTurbineTestingPointAiService;
 import com.gyee.frame.util.IRealTimeDataBaseUtil;
 import com.gyee.frame.util.golden.EdosUtil;
-import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
@@ -19,7 +18,7 @@ import java.util.concurrent.CopyOnWriteArraySet;
 @Service
 public class BraceletService  {
 
-    @Autowired
+    @Resource
     private WebsocketMessageService websocketMessageService;
     @Resource
     private WindTurbineTestingPointAiService windTurbineTestingPointAiService;