fix:使用枚举方法

This commit is contained in:
nieziyan 2024-03-15 10:17:56 +08:00
parent 73f1dea4e0
commit 4601af9974
2 changed files with 14 additions and 20 deletions

View File

@ -1,10 +1,14 @@
package org.jeecg.modules.base.enums; package org.jeecg.modules.base.enums;
import cn.hutool.core.util.StrUtil;
import lombok.Getter;
/** /**
* @author nieziyan * @author nieziyan
* 数据源类型 * 数据源类型
*/ */
@Getter
public enum DSType { public enum DSType {
/* ARMD自动处理库 */ /* ARMD自动处理库 */
ARMDARR("1"), ARMDARR("1"),
@ -15,13 +19,17 @@ public enum DSType {
/* IDC人工交互库 */ /* IDC人工交互库 */
IDCRRR("4"); IDCRRR("4");
DSType(java.lang.String type) { DSType(String type) {
this.type = type; this.type = type;
} }
private String type; private final String type;
public String getType() { public static String typeOf(String type){
return type; for (DSType dsType : DSType.values()) {
if (StrUtil.equals(type, dsType.getType()))
return dsType.name();
}
return null;
} }
} }

View File

@ -28,6 +28,7 @@ import org.jeecg.modules.base.entity.postgre.AlarmAnalysisLog;
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg; import org.jeecg.modules.base.entity.postgre.AlarmAnalysisNuclideAvg;
import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule; import org.jeecg.modules.base.entity.postgre.AlarmAnalysisRule;
import org.jeecg.modules.base.enums.Condition; import org.jeecg.modules.base.enums.Condition;
import org.jeecg.modules.base.enums.DSType;
import org.jeecg.modules.feignclient.SystemClient; import org.jeecg.modules.feignclient.SystemClient;
import org.jeecg.modules.service.AnalysisResultService; import org.jeecg.modules.service.AnalysisResultService;
import org.jeecg.modules.service.IAlarmAnalysisLogService; import org.jeecg.modules.service.IAlarmAnalysisLogService;
@ -247,28 +248,13 @@ public class AnalysisConsumer implements StreamListener<String, ObjectRecord<Str
NuclideInfo nuclideInfo = new NuclideInfo(); NuclideInfo nuclideInfo = new NuclideInfo();
nuclideInfo.setNuclide(nuclideName); nuclideInfo.setNuclide(nuclideName);
nuclideInfo.setThreshold(avg.toString()); nuclideInfo.setThreshold(avg.toString());
nuclideInfo.setDatasource(type(dataSourceType)); nuclideInfo.setDatasource(DSType.typeOf(dataSourceType));
nuclideInfo.setValue(conc.toString()); nuclideInfo.setValue(conc.toString());
nuclideInfos.add(nuclideInfo); nuclideInfos.add(nuclideInfo);
} }
return nuclideInfos; return nuclideInfos;
} }
private String type(String dataSourceType){
switch (dataSourceType){
case CommonConstant.ARMDARR:
return "ARMDARR";
case CommonConstant.ARMDRRR:
return "ARMDRRR";
case CommonConstant.IDCARR:
return "IDCARR";
case CommonConstant.IDCRRR:
return "IDCRRR";
default:
return null;
}
}
private void init() { private void init() {
// start:生成临时Token到线程中 // start:生成临时Token到线程中
UserTokenContext.setToken(getTempToken()); UserTokenContext.setToken(getTempToken());