Commit a5c8a5d1 authored by caotao's avatar caotao

调整原来的controller与service实现用于支持请求时判断当前算法是否在进行计算

parent 5e2d8b85
package com.yeejoin.amos.boot.module.jxiop.biz.Enum;
public enum SmartAnalyseEnum {
FAN_QJHF("FAN_QJHF", "风机区间变量划分"),
FAN_XGX("FAN_XGX","风机相关性"),
FAN_ZXZ("FAN_ZXZ","风机中心值"),
PV_QJHF("PV_QJHF","光伏区间变量划分"),
PV_XGX("PV_XGX","光伏相关性"),
PV_ZXZ("PV_ZXZ","光伏中心值");
private String key;
private String name;
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
SmartAnalyseEnum(String key, String name) {
this.key = key;
this.name = name;
}
}
package com.yeejoin.amos.boot.module.jxiop.biz.Thread;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.SmartAnalyseEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.service.impl.CommonServiceImpl;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.HashMap;
public class MyServiceThread extends Thread {
Logger logger = LoggerFactory.getLogger(MyServiceThread.class);
private String startTime;
private String endTime;
private CommonServiceImpl commonService;
private String type;
public MyServiceThread(CommonServiceImpl commonService, String startTime, String endTime, String type) {
this.commonService = commonService;
this.startTime = startTime;
this.endTime = endTime;
this.type = type;
}
@Override
public void run() {
if (type.equals(SmartAnalyseEnum.FAN_QJHF.getKey())) {
this.commonService.getFanConditionVariablesByTime(this.startTime, this.endTime);
logger.info("--------------------------开始调用风机区间划分算法-----------------------");
} else if (type.equals(SmartAnalyseEnum.FAN_XGX.getKey())) {
this.commonService.getFanConditionVariablesByTimeAnalyse(startTime, endTime);
} else if (type.equals(SmartAnalyseEnum.FAN_ZXZ.getKey())) {
this.commonService.getFanConditionVariablesByTimeAnalyse1(startTime, endTime);
} else if (type.equals(SmartAnalyseEnum.PV_QJHF.getKey())) {
this.commonService.getPvConditionVariablesByTime(startTime, endTime);
} else if (type.equals(SmartAnalyseEnum.PV_XGX.getKey())) {
this.commonService.getPvConditionVariablesByTimeAnalyse(startTime, endTime);
} else if (type.equals(SmartAnalyseEnum.PV_ZXZ.getKey())) {
this.commonService.getPvConditionVariablesByTimeAnalyse1(startTime, endTime);
}
}
}
......@@ -29,38 +29,38 @@ public class AnalyseController extends BaseController {
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "工况测点区间划分-风机", notes = "工况测点区间划分-风机")
@GetMapping(value = "/getFanConditionVariablesByTime")
public void getFanConditionVariablesByTime(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getFanConditionVariablesByTime(startTime, endTime);
public ResponseModel<String> getFanConditionVariablesByTime(@RequestParam String startTime, @RequestParam String endTime) {
return ResponseHelper.buildResponse(commonServiceImpl.getFanConditionVariablesByTimeThread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "工况测点区间划分-光伏", notes = "工况测点区间划分-光伏")
@GetMapping(value = "/getPvConditionVariablesByTime")
public void getPvConditionVariablesByTime(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getPvConditionVariablesByTime(startTime, endTime);
public ResponseModel<String> getPvConditionVariablesByTime(@RequestParam String startTime, @RequestParam String endTime) {
return ResponseHelper.buildResponse(commonServiceImpl.getPvConditionVariablesByTimeThread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "相关性分析-风机", notes = "相关性分析-风机")
@GetMapping(value = "/getFanConditionVariablesByTimeAnalyse")
public void getFanConditionVariablesByTimeAnalyse(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getFanConditionVariablesByTimeAnalyse(startTime, endTime);
public ResponseModel<String> getFanConditionVariablesByTimeAnalyse(@RequestParam String startTime, @RequestParam String endTime) {
return ResponseHelper.buildResponse(commonServiceImpl.getFanConditionVariablesByTimeAnalyseThread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "相关性分析-风机", notes = "相关性分析-风机")
@GetMapping(value = "/getPvConditionVariablesByTimeAnalyse")
public void getPvConditionVariablesByTimeAnalyse(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getPvConditionVariablesByTimeAnalyse(startTime, endTime);
public ResponseModel<String> getPvConditionVariablesByTimeAnalyse(@RequestParam String startTime, @RequestParam String endTime) {
return ResponseHelper.buildResponse(commonServiceImpl.getPvConditionVariablesByTimeAnalyseThread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "中心值计算-风机", notes = "中心值计算-风机")
@GetMapping(value = "/getFanConditionVariablesByTimeAnalyse1")
public void getFanConditionVariablesByTimeAnalyse1(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getFanConditionVariablesByTimeAnalyse1(startTime, endTime);
public ResponseModel<String> getFanConditionVariablesByTimeAnalyse1(@RequestParam String startTime, @RequestParam String endTime) {
return ResponseHelper.buildResponse(commonServiceImpl.getFanConditionVariablesByTimeAnalyse1Thread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@ApiOperation(httpMethod = "GET", value = "中心值计算-光伏", notes = "中心值计算-光伏")
@GetMapping(value = "/getPvConditionVariablesByTimeAnalyse1")
public void getPvConditionVariablesByTimeAnalyse1(@RequestParam String startTime, @RequestParam String endTime) {
commonServiceImpl.getPvConditionVariablesByTimeAnalyse1(startTime, endTime);
public ResponseModel<String> getPvConditionVariablesByTimeAnalyse1(@RequestParam String startTime, @RequestParam String endTime) {
return ResponseHelper.buildResponse(commonServiceImpl.getPvConditionVariablesByTimeAnalyse1Thread(startTime, endTime));
}
@TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
......
......@@ -7,6 +7,8 @@ import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.yeejoin.amos.boot.module.jxiop.biz.ESDto.ESEquipments;
import com.yeejoin.amos.boot.module.jxiop.biz.Enum.SmartAnalyseEnum;
import com.yeejoin.amos.boot.module.jxiop.biz.Thread.MyServiceThread;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizFanPointProcessVariableClassificationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.dto.IdxBizPvPointProcessVariableClassificationDto;
import com.yeejoin.amos.boot.module.jxiop.biz.entity.*;
......@@ -36,6 +38,7 @@ import java.util.stream.Collectors;
@Service
public class CommonServiceImpl {
private static final HashMap<String,Object> cacheExecInfo = new HashMap<>();
//utc时间格式
public static final String FORMAT_UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
public static final String FORMAT_DEFAULT = "yyyy-MM-dd HH:mm:ss";
......@@ -50,21 +53,21 @@ public class CommonServiceImpl {
//----------------工况变量工况变量划分请求属性配置------------------------
@Value("${gkblhffan.url:74435221-796d-43c0-ae72-319792b8f89e}")
String gkqjhfurlfan;
@Value("${gkblhfpv.url:e884fccf-b7ac-4fa4-bdb7-a5b6ff7319ec}")
@Value("${gkblhfpv.url:728d13ae-f333-4e36-b55c-6a0b6bb3b150}")
String gkqjhfurlpv;
@Value("${gkblhf.key:input 1}")
String gkqjhfkey;
//----------------工况变量相关性计算请求属性配置------------------------
@Value("${gkxgxfxfan.url:b5797e0a-d456-44d3-9f21-9528e5321b74}")
String gkxgxfxurlfan;
@Value("${gkxgxfxpv.url:f5457bfe-0780-418d-9287-c4f31d3fb4c7}")
@Value("${gkxgxfxpv.url:3d583330-1b3c-4c7a-b904-9e94f3de9fc9}")
String gkxgxfxurlpv;
@Value("${gkxgxfx.key:input 1}")
String gkxgxfxkey;
//----------------工况变量中心值计算相关请求属性配置------------------------
@Value("${gkzxzjsfan.url:a6f8d689-0028-445e-b797-493b5ac65e42}")
String gkzxzjsurlfan;
@Value("${gkzxzjspv.url:5c9fc897-a9f2-4563-8d7b-8cf60c6a663f}")
@Value("${gkzxzjspv.url:0945f8f6-faa6-4bd6-87fd-c7bed37d9bdc}")
String gkzxzjsurlpv;
@Value("${gkzxzjs.key:input 1}")
String gkzxzjskey1;
......@@ -144,6 +147,18 @@ public class CommonServiceImpl {
return idxBizPvPointProcessVariableClassificationHashMap;
}
public String getFanConditionVariablesByTimeThread(String startTime, String endTime) {
String result ="开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.FAN_QJHF.getKey()))){
result="正在计算中";
}else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.FAN_QJHF.getKey());
myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.FAN_QJHF.getKey(),myServiceThread);
}
return result;
}
//遍历工况列表数据-风机
public void getFanConditionVariablesByTime(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime);
......@@ -155,6 +170,19 @@ public class CommonServiceImpl {
foreachHandlerConditionVariabFan(s, list, startTimeUTC, endTimeUTC);
}
});
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey());
}
public String getPvConditionVariablesByTimeThread(String startTime, String endTime) {
String result ="开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.PV_QJHF.getKey()))){
result="正在计算中";
}else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.PV_QJHF.getKey());
myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.PV_QJHF.getKey(),myServiceThread);
}
return result;
}
//遍历工况列表数据-光伏
......@@ -168,6 +196,7 @@ public class CommonServiceImpl {
foreachHandlerConditionVariabPv(s, list, startTimeUTC, endTimeUTC);
}
});
cacheExecInfo.remove(SmartAnalyseEnum.FAN_QJHF.getKey());
}
//遍历查询数据并调用并计算-风机
......@@ -284,6 +313,17 @@ public class CommonServiceImpl {
return idxBizPvPointProcessVariableClassificationHashMap;
}
public String getFanConditionVariablesByTimeAnalyseThread(String startTime, String endTime) {
String result ="开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.FAN_XGX.getKey()))){
result="正在计算中";
}else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.FAN_XGX.getKey());
myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.FAN_XGX.getKey(),myServiceThread);
}
return result;
}
//相关性分析-风机入口
public void getFanConditionVariablesByTimeAnalyse(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime);
......@@ -298,8 +338,20 @@ public class CommonServiceImpl {
}
});
});
cacheExecInfo.remove(SmartAnalyseEnum.FAN_XGX.getKey());
}
public String getPvConditionVariablesByTimeAnalyseThread(String startTime, String endTime) {
String result ="开始计算";
if(!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.PV_XGX.getKey()))){
result="正在计算中";
}else {
MyServiceThread myServiceThread =new MyServiceThread(this,startTime,endTime,SmartAnalyseEnum.PV_XGX.getKey());
myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.PV_XGX.getKey(),myServiceThread);
}
return result;
}
//相关性分析-光伏入口
public void getPvConditionVariablesByTimeAnalyse(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime);
......@@ -314,6 +366,7 @@ public class CommonServiceImpl {
}
});
});
cacheExecInfo.remove(SmartAnalyseEnum.PV_XGX.getKey());
}
//遍历处理数据-组装风机
......@@ -452,7 +505,18 @@ public class CommonServiceImpl {
return resultList;
}
//中心值计算-风电
public String getFanConditionVariablesByTimeAnalyse1Thread(String startTime, String endTime) {
String result = "开始计算";
if (!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.FAN_ZXZ.getKey()))) {
result = "正在计算中";
} else {
MyServiceThread myServiceThread = new MyServiceThread(this, startTime, endTime, SmartAnalyseEnum.FAN_ZXZ.getKey());
myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.FAN_ZXZ.getKey(), myServiceThread);
}
return result;
}
//中心值计算-风电
public void getFanConditionVariablesByTimeAnalyse1(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime);
String endTimeUTC =getUtcTimeString(endTime);
......@@ -466,8 +530,20 @@ public class CommonServiceImpl {
}
});
});
cacheExecInfo.remove(SmartAnalyseEnum.FAN_ZXZ.getKey());
}
public String getPvConditionVariablesByTimeAnalyse1Thread(String startTime, String endTime) {
String result = "开始计算";
if (!ObjectUtils.isEmpty(cacheExecInfo.get(SmartAnalyseEnum.PV_ZXZ.getKey()))) {
result = "正在计算中";
} else {
MyServiceThread myServiceThread = new MyServiceThread(this, startTime, endTime, SmartAnalyseEnum.PV_ZXZ.getKey());
myServiceThread.start();
cacheExecInfo.put(SmartAnalyseEnum.PV_ZXZ.getKey(), myServiceThread);
}
return result;
}
//中心值计算-光伏
public void getPvConditionVariablesByTimeAnalyse1(String startTime, String endTime) {
String startTimeUTC = getUtcTimeString(startTime);
......@@ -483,6 +559,7 @@ public class CommonServiceImpl {
});
});
cacheExecInfo.remove(SmartAnalyseEnum.PV_ZXZ.getKey());
}
//中心值参数组装-风电
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment