Parcourir la source

添加异步多线程调度功能

shilin il y a 2 mois
Parent
commit
0ec1880a3f

+ 4 - 1
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmPlanController.java

@@ -95,17 +95,20 @@ public class ProEconAlarmPlanController {
 
             @ApiImplicitParam(name = "pageNum", value = "页号", required = true, dataType = "Integer", paramType = "query"),
             @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "pageSize", value = "每页显示多少行", required = true, dataType = "Integer", paramType = "query"),
+            @ApiImplicitParam(name = "types", value = "名称", required = false, dataType = "string", paramType = "query"),
             @ApiImplicitParam(name = "name", value = "名称", required = false, dataType = "string", paramType = "query")
            })
 
     public AjaxResult queryByPage(HttpServletRequest request,
                                   @RequestParam(value = "pageNum") Integer pageNum,
                                   @RequestParam(value = "pageSize") Integer pageSize,
+                                  @RequestParam(value = "types", required = false) String types,
                                   @RequestParam(value = "name", required = false) String name
     ) {
         Page<ProEconAlarmPlan> page = new Page(pageNum, pageSize);
 
-        IPage<ProEconAlarmPlan> pageResult = proEconAlarmPlanService.pageQueryAll(page, name);
+        IPage<ProEconAlarmPlan> pageResult = proEconAlarmPlanService.pageQueryAll(page, name,types);
 
 
         if (StringUtils.notEmp(pageResult)) {

+ 77 - 0
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmRealController.java

@@ -0,0 +1,77 @@
+package com.gyee.alarm.controller;
+
+
+import com.gyee.alarm.model.auto.ProBasicPowerstation;
+import com.gyee.alarm.model.auto.ProBasicSubStation;
+import com.gyee.alarm.model.vo.AjaxResult;
+import com.gyee.alarm.model.vo.AjaxStatus;
+import com.gyee.alarm.model.vo.AlarmTypeValue;
+import com.gyee.alarm.service.TokenService;
+import com.gyee.alarm.util.StringUtils;
+import io.swagger.annotations.ApiOperation;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.context.request.RequestContextHolder;
+import org.springframework.web.context.request.ServletRequestAttributes;
+
+import javax.annotation.Resource;
+import javax.servlet.http.HttpServletRequest;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * <p>
+ *  前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2024-10-28
+ */
+@RestController
+@RequestMapping("///electricity")
+public class ProEconAlarmRealController {
+
+    @Resource
+    private TokenService tokenService;
+
+
+    @GetMapping(value = "/czlist")
+    @ApiOperation(value = "查询场站列表", notes = "查询场站列表")
+    public AjaxResult queryWplList(String types) {
+
+        HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
+        List<ProBasicPowerstation> wpls = tokenService.getWpls(request);
+        List<ProBasicPowerstation> vos = new ArrayList<>();
+        if(!wpls.isEmpty())
+        {
+            for(ProBasicPowerstation wp:wpls)
+            {
+                if(StringUtils.notEmp(types))
+                {
+                    if(types.equals(AlarmTypeValue.WT.getCode())  && wp.getId().contains("FDC"))
+                    {
+                        vos.add(wp);
+                    }else if(types.equals(AlarmTypeValue.IN.getCode())  && wp.getId().contains("GDC"))
+                    {
+                        vos.add(wp);
+                    }else if(types.equals(AlarmTypeValue.BT.getCode()))
+                    {
+                        List<ProBasicSubStation> subwpls = tokenService.getSubwpls(request);
+                        return AjaxResult.successData(AjaxStatus.success.code, subwpls);
+                    }
+                }else
+                {
+                    vos =wpls;
+                }
+            }
+        }
+        if (StringUtils.notEmp(vos)) {
+
+            return AjaxResult.successData(AjaxStatus.success.code, vos);
+        } else {
+            return AjaxResult.successData(AjaxStatus.loginexpire.code, "error");
+        }
+    }
+
+}

+ 3 - 3
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProBasicDeviceFaultModeMapper.java

@@ -32,7 +32,7 @@ public interface ProBasicDeviceFaultModeMapper extends BaseMapper<ProBasicDevice
             "select * from pro_basic_device_fault_mode a ",
             "<where>",
             "<if test='deviceId !=null' >",
-            "and a.deviceid=#{deviceId}",
+            "and a.device_id=#{deviceId}",
             "</if>",
             "</where>",
 
@@ -43,7 +43,7 @@ public interface ProBasicDeviceFaultModeMapper extends BaseMapper<ProBasicDevice
             "select * from pro_basic_device_fault_mode a ",
             "<where>",
             "<if test='deviceId !=null' >",
-            "and a.deviceId=#{deviceId}",
+            "and a.device_id=#{deviceId}",
             "</if>",
             "<if test='structureCode !=null' >",
             "and   a.structure_code like '${structureCode}%'",
@@ -58,7 +58,7 @@ public interface ProBasicDeviceFaultModeMapper extends BaseMapper<ProBasicDevice
             "select * from pro_basic_device_fault_mode a ",
             "<where>",
             "<if test='deviceId !=null' >",
-            "and a.deviceId=#{deviceId}",
+            "and a.device_id=#{deviceId}",
             "</if>",
             "<if test='nodeCode !=null' >",
             "and a.code=#{nodeCode}",

+ 4 - 2
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmPlanMapper.java

@@ -63,12 +63,14 @@ public interface ProEconAlarmPlanMapper extends BaseMapper<ProEconAlarmPlan> {
             "<if test='name !=null  '>",
             "and a.name like #{name} ",
             "</if>",
-
+            "<if test='types !=null  '>",
+            "and a.types = #{types} ",
+            "</if>",
             "</where>",
 
             "</script>"})
     IPage<ProEconAlarmPlan> pageQueryAll(Page page,
-                                         @Param("name") String name);
+                                         @Param("name") String name, @Param("types") String types);
 
 
 }

+ 6 - 2
alarm-web/src/main/java/com/gyee/alarm/service/DeviceService.java

@@ -65,7 +65,11 @@ public class DeviceService {
         String modelId = "";
         ProBasicEquipment windturbine = windturbineCache.getWindturbine(windturbineId);
         if (windturbine != null)
+        {
             modelId = windturbine.getModelId();
+        }
+
+
 
         if (StringUtils.isNotBlank(structCode)) {
             List<ProBasicDeviceMetrics> metricsList = proBasicDeviceMetricsService.getDeviceMetricsByStructureCode(deviceId, structCode);
@@ -364,7 +368,7 @@ public class DeviceService {
     public int saveOrUpdateDeviceMetric(ProBasicDeviceMetrics metrics, List<ProBasicDeviceModelMetrics> deviceModelMetrics) {
 
         int result = 0;
-        if ( StringUtils.notEmp(metrics.getId())) {
+        if ( StringUtils.empty(metrics.getId())) {
             //如果id为空,则通过雪花算法 生成一个id
             metrics.setId(String.valueOf(SnowflakeGenerator.generateId()));
             result = proBasicDeviceMetricsMapper.insert(metrics);
@@ -378,7 +382,7 @@ public class DeviceService {
         }
         if (deviceModelMetrics != null && deviceModelMetrics.size() > 0) {
             for (ProBasicDeviceModelMetrics deviceModelMetrics1 : deviceModelMetrics) {
-                if (StringUtils.notEmp(deviceModelMetrics1.getId())) {
+                if (StringUtils.empty(deviceModelMetrics1.getId())) {
                     //如果id为空,则通过雪花算法 生成一个id
                     deviceModelMetrics1.setId(String.valueOf(SnowflakeGenerator.generateId()));
                     result = roBasicDeviceModelMetricsMapper.insert(deviceModelMetrics1);

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmPlanService.java

@@ -33,6 +33,6 @@ public interface IProEconAlarmPlanService extends IService<ProEconAlarmPlan> {
 
    public boolean deleteAlertrule( List<String> idls);
 
-   public IPage<ProEconAlarmPlan> pageQueryAll(Page page, String name);
+   public IPage<ProEconAlarmPlan> pageQueryAll(Page page, String name,String types);
 
 }

+ 9 - 3
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmPlanServiceImpl.java

@@ -151,7 +151,7 @@ public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMap
     }
 
 
-    public IPage<ProEconAlarmPlan> pageQueryAll(Page page, String name) {
+    public IPage<ProEconAlarmPlan> pageQueryAll(Page page, String name,String types) {
 
 
         if(StringUtils.notEmp(name))
@@ -162,8 +162,14 @@ public class ProEconAlarmPlanServiceImpl extends ServiceImpl<ProEconAlarmPlanMap
             name=null;
         }
 
-
-        IPage<ProEconAlarmPlan> alertruleIPage = proEconAlarmPlanMapper.pageQueryAll(page, name);
+        if(StringUtils.notEmp(name))
+        {
+            types=types;
+        }else
+        {
+            types=null;
+        }
+        IPage<ProEconAlarmPlan> alertruleIPage = proEconAlarmPlanMapper.pageQueryAll(page, name,types);
 
 
         return alertruleIPage;