|
@@ -64,17 +64,62 @@ public class RawDataServiceImpl implements RawDataService {
|
|
|
for (int i = 0; i < rawDataList.size(); i++) {
|
|
|
String dataValue = rawDataList.get(i).getDataValue();
|
|
|
Boolean[] dataValueList = JSON.parseObject(dataValue, Boolean[].class);
|
|
|
- Boolean avg;
|
|
|
+ Boolean data = null;
|
|
|
if (itemGroup.getValueCondition().equals(ConstantStr.AVERAGE_VALUE)) {
|
|
|
- avg = MathUtil.getAvgBoolean(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ int countFalse = 0;
|
|
|
+ int countTrue = 0;
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (dataValueList[i]) {
|
|
|
+ countTrue += 1;
|
|
|
+ } else {
|
|
|
+ countFalse += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (countTrue != countFalse) {
|
|
|
+ if (countTrue > countFalse) {
|
|
|
+ data = true;
|
|
|
+ } else {
|
|
|
+ data = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MAX_VALUE)) {
|
|
|
- avg = MathUtil.getMaxBoolean(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (dataValueList[i]) {
|
|
|
+ data = true;
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ data = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ if (data) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MIN_VALUE)) {
|
|
|
- avg = MathUtil.getMinBoolean(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (!dataValueList[i]) {
|
|
|
+ data = false;
|
|
|
+ break;
|
|
|
+ } else {
|
|
|
+ data = true;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ if (!data) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前还未适配此种类型数据组的取值条件");
|
|
|
}
|
|
|
- booleanList.add(avg);
|
|
|
+ booleanList.add(data);
|
|
|
String valueBelongTime = rawDataList.get(i).getValueBelongTime();
|
|
|
dataTimeList.add(valueBelongTime);
|
|
|
}
|
|
@@ -206,7 +251,7 @@ public class RawDataServiceImpl implements RawDataService {
|
|
|
String dataType = rawDataList.get(0).getDataType();
|
|
|
if (dataType.toLowerCase().equals("boolean")) {
|
|
|
if (itemGroup.getValueCondition().equals(ConstantStr.AVERAGE_VALUE)) {
|
|
|
- Boolean data = null;
|
|
|
+ Boolean avg = null;
|
|
|
int countFalse = 0;
|
|
|
int countTrue = 0;
|
|
|
for (RawData rawData : rawDataList) {
|
|
@@ -221,31 +266,33 @@ public class RawDataServiceImpl implements RawDataService {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (countTrue >= countFalse) {
|
|
|
- data = true;
|
|
|
- } else {
|
|
|
- data = false;
|
|
|
+ if (countTrue != countFalse) {
|
|
|
+ if (countTrue > countFalse) {
|
|
|
+ avg = true;
|
|
|
+ } else {
|
|
|
+ avg = false;
|
|
|
+ }
|
|
|
}
|
|
|
- jsonObject.put("data", data);
|
|
|
+ jsonObject.put("data", avg);
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MAX_VALUE)) {
|
|
|
- Boolean data = null;
|
|
|
+ Boolean max = null;
|
|
|
for (RawData rawData : rawDataList) {
|
|
|
Boolean[] dataValueList = JSON.parseObject(rawData.getDataValue(), Boolean[].class);
|
|
|
if (Blank.isNotEmpty(dataValueList)) {
|
|
|
for (int i = 0; i < dataValueList.length; i++) {
|
|
|
if (dataValueList[i]) {
|
|
|
- data = true;
|
|
|
+ max = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if (Blank.isNotEmpty(data)) {
|
|
|
- if (data) {
|
|
|
+ if (Blank.isNotEmpty(max)) {
|
|
|
+ if (max) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- jsonObject.put("data", data);
|
|
|
+ jsonObject.put("data", max);
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MIN_VALUE)) {
|
|
|
Boolean data = null;
|
|
|
for (RawData rawData : rawDataList) {
|
|
@@ -378,18 +425,59 @@ public class RawDataServiceImpl implements RawDataService {
|
|
|
List<Boolean> booleanList = new ArrayList<>();
|
|
|
for (int i = 0; i < rawDataList.size(); i++) {
|
|
|
String dataValue = rawDataList.get(i).getDataValue();
|
|
|
+ Boolean data = null;
|
|
|
+ int countFalse = 0;
|
|
|
+ int countTrue = 0;
|
|
|
Boolean[] dataValueList = JSON.parseObject(dataValue, Boolean[].class);
|
|
|
- Boolean avg;
|
|
|
if (itemGroup.getValueCondition().equals(ConstantStr.AVERAGE_VALUE)) {
|
|
|
- avg = MathUtil.getAvgBoolean(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (dataValueList[j]) {
|
|
|
+ countTrue += 1;
|
|
|
+ } else {
|
|
|
+ countFalse += 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (countTrue != countFalse) {
|
|
|
+ if (countTrue > countFalse) {
|
|
|
+ data = true;
|
|
|
+ } else {
|
|
|
+ data = false;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MAX_VALUE)) {
|
|
|
- avg = MathUtil.getMaxBoolean(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (dataValueList[j]) {
|
|
|
+ data = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(data)) {
|
|
|
+ if (data) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MIN_VALUE)) {
|
|
|
- avg = MathUtil.getMinBoolean(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (!dataValueList[j]) {
|
|
|
+ data = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (Blank.isNotEmpty(data)) {
|
|
|
+ if (!data) {
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前还未适配此种类型数据组的取值条件");
|
|
|
}
|
|
|
- booleanList.add(avg);
|
|
|
+ booleanList.add(data);
|
|
|
String valueBelongTime = rawDataList.get(i).getValueBelongTime();
|
|
|
dataTimeList.add(valueBelongTime);
|
|
|
}
|
|
@@ -400,23 +488,49 @@ public class RawDataServiceImpl implements RawDataService {
|
|
|
String dataValue = rawDataList.get(i).getDataValue();
|
|
|
try {
|
|
|
BigDecimal[] dataValueList = JSON.parseObject(dataValue, BigDecimal[].class);
|
|
|
- BigDecimal avg;
|
|
|
+ BigDecimal data = null;
|
|
|
if (itemGroup.getValueCondition().equals(ConstantStr.AVERAGE_VALUE)) {
|
|
|
- avg = MathUtil.getAvg(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ BigDecimal bigDecimal = null;
|
|
|
+ int sum = 0;
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (Blank.isEmpty(bigDecimal)) {
|
|
|
+ bigDecimal = dataValueList[j];
|
|
|
+ } else {
|
|
|
+ bigDecimal.add(dataValueList[j]);
|
|
|
+ }
|
|
|
+ sum += 1;
|
|
|
+ }
|
|
|
+ data = bigDecimal.divide(new BigDecimal(sum));
|
|
|
+ }
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MAX_VALUE)) {
|
|
|
- avg = MathUtil.getMax(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (Blank.isEmpty(data)) {
|
|
|
+ data = dataValueList[j];
|
|
|
+ } else {
|
|
|
+ data.max(dataValueList[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if (itemGroup.getValueCondition().equals(ConstantStr.MIN_VALUE)) {
|
|
|
- avg = MathUtil.getMin(dataValueList);
|
|
|
+ if (Blank.isNotEmpty(dataValueList)) {
|
|
|
+ for (int j = 0; j < dataValueList.length; j++) {
|
|
|
+ if (Blank.isEmpty(data)) {
|
|
|
+ data = dataValueList[j];
|
|
|
+ } else {
|
|
|
+ data.min(dataValueList[j]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
} else {
|
|
|
throw new CustomException(ResultEnum.REQUEST_WRONGPARAMS.getRespCode(), "目前还未适配此种类型数据组的取值条件");
|
|
|
}
|
|
|
- dataList.add(avg);
|
|
|
+ dataList.add(data);
|
|
|
} catch (Exception e) {
|
|
|
String[] dataValueList = JSON.parseObject(dataValue, String[].class);
|
|
|
if (Blank.isNotEmpty(dataValueList)) {
|
|
|
dataList.add(dataValueList[0]);
|
|
|
- } else {
|
|
|
- dataList.add("");
|
|
|
}
|
|
|
}
|
|
|
String valueBelongTime = rawDataList.get(i).getValueBelongTime();
|