feat: 查询数据报表时候自动把油色谱的数据进行三比值计算

dev
huangfeng 2 weeks ago
parent 2150040509
commit 3140b55c93

@ -215,8 +215,12 @@ public class NSensorController extends BasicController {
@ApiOperation("三比值")
public Response<SanbizhiModel> sanbizhi(@RequestBody Map<String, Object> map) throws Exception {
SanbizhiModel item = new SanbizhiModel();
item.build(map);
return Response.success(item);
boolean r = item.build(map);
if (r) {
return Response.success(item);
} else {
throw new BusinessException(item.getStatus());
}
}
}

@ -1,6 +1,5 @@
package com.xydl.cac.model;
import com.xydl.cac.exception.BusinessException;
import lombok.Data;
import java.util.Iterator;
@ -8,38 +7,39 @@ import java.util.Map;
@Data
public class SanbizhiModel {
Double c2h2;
Double c2h4;
Double ch4;
Double h2;
Double c2h6;
Double c2h2_c2h4_value;
Float c2h2;
Float c2h4;
Float ch4;
Float h2;
Float c2h6;
Float c2h2_c2h4_value;
String c2h2_c2h4_code;
Double ch4_h2_value;
Float ch4_h2_value;
String ch4_h2_code;
Double c2h4_c2h6_value;
Float c2h4_c2h6_value;
String c2h4_c2h6_code;
String status;
public void build(Map<String, Object> map) throws BusinessException {
public boolean build(Map<String, Object> map) {
Iterator<String> it = map.keySet().iterator();
while (it.hasNext()) {
String key = it.next();
String name = key.toLowerCase();
if (name.contains("c2h2")) {
c2h2 = (Double) map.get(key);
c2h2 = Float.parseFloat(map.get(key).toString());
} else if (name.contains("c2h4")) {
c2h4 = (Double) map.get(key);
c2h4 = Float.parseFloat(map.get(key).toString());
} else if (name.contains("ch4")) {
ch4 = (Double) map.get(key);
ch4 = Float.parseFloat(map.get(key).toString());
} else if (name.contains("h2")) {
h2 = (Double) map.get(key);
h2 = Float.parseFloat(map.get(key).toString());
} else if (name.contains("c2h6")) {
c2h6 = (Double) map.get(key);
c2h6 = Float.parseFloat(map.get(key).toString());
}
}
if (c2h2 == null || c2h4 == null || ch4 == null || h2 == null || c2h6 == null) {
throw new BusinessException("数据不符合");
status = "必要数据缺失";
return false;
}
c2h2_c2h4_value = c2h2 / c2h4;
ch4_h2_value = ch4 / h2;
@ -109,5 +109,6 @@ public class SanbizhiModel {
status = "电弧放电兼过热";
}
}
return true;
}
}

@ -211,6 +211,15 @@ public class NSensorServiceImpl implements NSensorService {
// 获取数据
SensorDetail<Map<String, Object>> result = this.getData(sensor, points, model);
if (sensor.getTypeName().contains("油色谱")) {
if (result.getContent() != null) {
for (Map<String, Object> map : result.getContent()) {
SanbizhiModel sanbizhi = new SanbizhiModel();
sanbizhi.build(map);
map.put("sanbizhi", sanbizhi);
}
}
}
return result;
}

Loading…
Cancel
Save