微调
This commit is contained in:
@@ -41,6 +41,7 @@ import com.njcn.gather.util.StorageUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.log4j.Log4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -60,6 +61,7 @@ import java.util.stream.Stream;
|
||||
* @description
|
||||
* @date 2024/12/20 13:52
|
||||
*/
|
||||
@Log4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DetectionServiceImpl {
|
||||
@@ -2286,14 +2288,59 @@ public class DetectionServiceImpl {
|
||||
public Map<String, List<List<Double>>> devListMap(Map<String, List<List<Double>>> phaseValueList, DictDataEnum dataRule, boolean isRemoveMaxElement) {
|
||||
Map<String, List<List<Double>>> resultMap = new HashMap<>(3);
|
||||
|
||||
List<Double> aDev = BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(0), Double.class);
|
||||
List<Double> aStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(1), Double.class);
|
||||
List<Double> bDev = BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(0), Double.class);
|
||||
List<Double> bStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(1), Double.class);
|
||||
List<Double> cDev = BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(0), Double.class);
|
||||
List<Double> cStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(1), Double.class);
|
||||
List<Double> tDev = BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(0), Double.class);
|
||||
List<Double> tStandardDev = BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(1), Double.class);
|
||||
List<Double> aDev = new ArrayList<>();
|
||||
List<Double> aStandardDev = new ArrayList<>();
|
||||
|
||||
if (phaseValueList.containsKey(TYPE_A)) {
|
||||
if (phaseValueList.get(TYPE_A).size() >= 1) {
|
||||
aDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(0), Double.class));
|
||||
aStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_A).get(1), Double.class));
|
||||
} else {
|
||||
log.error("数据异常,phaseValueList.get(TYPE_A).size()=" + phaseValueList.get(TYPE_A).size());
|
||||
}
|
||||
} else {
|
||||
log.equals("数据异常,phaseValueList.containsKey(TYPE_A)=" + phaseValueList.containsKey(TYPE_A));
|
||||
}
|
||||
|
||||
List<Double> bDev = new ArrayList<>();
|
||||
List<Double> bStandardDev = new ArrayList<>();
|
||||
|
||||
if (phaseValueList.containsKey(TYPE_B)) {
|
||||
if (phaseValueList.get(TYPE_B).size() >= 1) {
|
||||
bDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(0), Double.class));
|
||||
bStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_B).get(1), Double.class));
|
||||
} else {
|
||||
log.error("数据异常,phaseValueList.get(TYPE_B).size()=" + phaseValueList.get(TYPE_B).size());
|
||||
}
|
||||
} else {
|
||||
log.equals("数据异常,phaseValueList.containsKey(TYPE_B)=" + phaseValueList.containsKey(TYPE_B));
|
||||
}
|
||||
|
||||
List<Double> cDev = new ArrayList<>();
|
||||
List<Double> cStandardDev = new ArrayList<>();
|
||||
if (phaseValueList.containsKey(TYPE_C)) {
|
||||
if (phaseValueList.get(TYPE_C).size() >= 1) {
|
||||
cDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(0), Double.class));
|
||||
cStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_C).get(1), Double.class));
|
||||
} else {
|
||||
log.error("数据异常,phaseValueList.get(TYPE_C).size()=" + phaseValueList.get(TYPE_C).size());
|
||||
}
|
||||
} else {
|
||||
log.equals("数据异常,phaseValueList.containsKey(TYPE_C)=" + phaseValueList.containsKey(TYPE_C));
|
||||
}
|
||||
|
||||
List<Double> tDev = new ArrayList<>();
|
||||
List<Double> tStandardDev = new ArrayList<>();
|
||||
if (phaseValueList.containsKey(TYPE_T)) {
|
||||
if (phaseValueList.get(TYPE_T).size() >= 1) {
|
||||
tDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(0), Double.class));
|
||||
tStandardDev.addAll(BeanUtil.copyToList(phaseValueList.get(TYPE_T).get(1), Double.class));
|
||||
} else {
|
||||
log.error("数据异常,phaseValueList.get(TYPE_T).size()=" + phaseValueList.get(TYPE_T).size());
|
||||
}
|
||||
} else {
|
||||
log.equals("数据异常,phaseValueList.containsKey(TYPE_T)=" + phaseValueList.containsKey(TYPE_T));
|
||||
}
|
||||
|
||||
if (isRemoveMaxElement) {
|
||||
List<Double> aErrorValueList = new ArrayList<>();
|
||||
@@ -2350,12 +2397,12 @@ public class DetectionServiceImpl {
|
||||
tDev.addAll(newArray);
|
||||
}
|
||||
|
||||
List<Integer> aIdxs = DetectionUtil.sort(aStandardDev, false);
|
||||
List<Integer> bIdxs = DetectionUtil.sort(bStandardDev, false);
|
||||
List<Integer> cIdxs = DetectionUtil.sort(cStandardDev, false);
|
||||
List<Integer> tIdxs = DetectionUtil.sort(tStandardDev, false);
|
||||
switch (dataRule) {
|
||||
case SECTION_VALUE:
|
||||
case SECTION_VALUE: {
|
||||
List<Integer> aIdxs = DetectionUtil.sort(aStandardDev, false);
|
||||
List<Integer> bIdxs = DetectionUtil.sort(bStandardDev, false);
|
||||
List<Integer> cIdxs = DetectionUtil.sort(cStandardDev, false);
|
||||
List<Integer> tIdxs = DetectionUtil.sort(tStandardDev, false);
|
||||
if (aStandardDev.size() > 2) {
|
||||
aStandardDev.remove(0);
|
||||
aStandardDev.remove(aStandardDev.size() - 1);
|
||||
@@ -2363,7 +2410,6 @@ public class DetectionServiceImpl {
|
||||
aDev.clear();
|
||||
aDev.addAll(newArray);
|
||||
}
|
||||
|
||||
if (bStandardDev.size() > 2) {
|
||||
bStandardDev.remove(0);
|
||||
bStandardDev.remove(bStandardDev.size() - 1);
|
||||
@@ -2371,7 +2417,6 @@ public class DetectionServiceImpl {
|
||||
bDev.clear();
|
||||
bDev.addAll(newArray);
|
||||
}
|
||||
|
||||
if (cStandardDev.size() > 2) {
|
||||
cStandardDev.remove(0);
|
||||
cStandardDev.remove(cStandardDev.size() - 1);
|
||||
@@ -2379,7 +2424,6 @@ public class DetectionServiceImpl {
|
||||
cDev.clear();
|
||||
cDev.addAll(newArray);
|
||||
}
|
||||
|
||||
if (tStandardDev.size() > 2) {
|
||||
tStandardDev.remove(0);
|
||||
tStandardDev.remove(tStandardDev.size() - 1);
|
||||
@@ -2387,8 +2431,13 @@ public class DetectionServiceImpl {
|
||||
tDev.clear();
|
||||
tDev.addAll(newArray);
|
||||
}
|
||||
break;
|
||||
case CP95_VALUE:
|
||||
}
|
||||
break;
|
||||
case CP95_VALUE: {
|
||||
List<Integer> aIdxs = DetectionUtil.sort(aStandardDev, false);
|
||||
List<Integer> bIdxs = DetectionUtil.sort(bStandardDev, false);
|
||||
List<Integer> cIdxs = DetectionUtil.sort(cStandardDev, false);
|
||||
List<Integer> tIdxs = DetectionUtil.sort(tStandardDev, false);
|
||||
if (CollUtil.isNotEmpty(aStandardDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(aStandardDev);
|
||||
aStandardDev = Collections.singletonList(aStandardDev.get(cp95Idx));
|
||||
@@ -2399,20 +2448,18 @@ public class DetectionServiceImpl {
|
||||
bStandardDev = Collections.singletonList(bStandardDev.get(cp95Idx));
|
||||
bDev = Collections.singletonList(bDev.get(bIdxs.get(cp95Idx)));
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(cStandardDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(cStandardDev);
|
||||
cStandardDev = Collections.singletonList(cStandardDev.get(cp95Idx));
|
||||
cDev = Collections.singletonList(cDev.get(cIdxs.get(cp95Idx)));
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(tStandardDev)) {
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(tStandardDev);
|
||||
tStandardDev = Collections.singletonList(tStandardDev.get(cp95Idx));
|
||||
tDev = Collections.singletonList(tDev.get(tIdxs.get(cp95Idx)));
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case AVG_VALUE:
|
||||
aDev = DetectionUtil.getAvgDoubles(aDev);
|
||||
bDev = DetectionUtil.getAvgDoubles(bDev);
|
||||
@@ -2425,54 +2472,82 @@ public class DetectionServiceImpl {
|
||||
tStandardDev = DetectionUtil.getAvgDoubles(tStandardDev);
|
||||
break;
|
||||
case Own_value:
|
||||
List<Double> newArray = DetectionUtil.getNewArray(aDev, aIdxs);
|
||||
aDev.clear();
|
||||
aDev.addAll(newArray);
|
||||
|
||||
newArray = DetectionUtil.getNewArray(bDev, bIdxs);
|
||||
bDev.clear();
|
||||
bDev.addAll(newArray);
|
||||
|
||||
newArray = DetectionUtil.getNewArray(cDev, cIdxs);
|
||||
cDev.clear();
|
||||
cDev.addAll(newArray);
|
||||
|
||||
newArray = DetectionUtil.getNewArray(tDev, tIdxs);
|
||||
tDev.clear();
|
||||
tDev.addAll(newArray);
|
||||
break;
|
||||
case AT_WILL_VALUE:
|
||||
if (CollUtil.isNotEmpty(aStandardDev)) {
|
||||
aStandardDev = aStandardDev.subList(0, 1);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(aDev)) {
|
||||
Double v = aDev.get(aIdxs.get(0));
|
||||
aDev.clear();
|
||||
aDev.add(v);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(bStandardDev)) {
|
||||
bStandardDev = bStandardDev.subList(0, 1);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(bDev)) {
|
||||
Double v = bDev.get(bIdxs.get(0));
|
||||
bDev.clear();
|
||||
bDev.add(v);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(cStandardDev)) {
|
||||
cStandardDev = cStandardDev.subList(0, 1);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(cDev)) {
|
||||
Double v = cDev.get(cIdxs.get(0));
|
||||
cDev.clear();
|
||||
cDev.add(v);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(tStandardDev)) {
|
||||
tStandardDev = tStandardDev.subList(0, 1);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(tDev)) {
|
||||
Double v = tDev.get(tIdxs.get(0));
|
||||
tDev.clear();
|
||||
tDev.add(v);
|
||||
if (isRemoveMaxElement) {
|
||||
if (CollUtil.isNotEmpty(aStandardDev) && CollUtil.isNotEmpty(aDev)) {
|
||||
aStandardDev = aStandardDev.subList(aStandardDev.size() - 1, aStandardDev.size());
|
||||
aDev = aDev.subList(aDev.size() - 1, aDev.size());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(bStandardDev) && CollUtil.isNotEmpty(bDev)) {
|
||||
bStandardDev = bStandardDev.subList(bStandardDev.size() - 1, bStandardDev.size());
|
||||
bDev = bDev.subList(bDev.size() - 1, bDev.size());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(cStandardDev) && CollUtil.isNotEmpty(cDev)) {
|
||||
cStandardDev = cStandardDev.subList(cStandardDev.size() - 1, cStandardDev.size());
|
||||
cDev = cDev.subList(cDev.size() - 1, cDev.size());
|
||||
}
|
||||
if (CollUtil.isNotEmpty(tStandardDev) && CollUtil.isNotEmpty(tDev)) {
|
||||
tStandardDev = tStandardDev.subList(tStandardDev.size() - 1, tStandardDev.size());
|
||||
tDev = tDev.subList(tDev.size() - 1, tDev.size());
|
||||
}
|
||||
} else {
|
||||
List<Double> aErrorValueList = new ArrayList<>();
|
||||
List<Double> bErrorValueList = new ArrayList<>();
|
||||
List<Double> cErrorValueList = new ArrayList<>();
|
||||
List<Double> tErrorValueList = new ArrayList<>();
|
||||
for (int i = 0; i < aStandardDev.size(); i++) {
|
||||
aErrorValueList.add(Math.abs(aStandardDev.get(i) - aDev.get(i)));
|
||||
}
|
||||
for (int i = 0; i < bStandardDev.size(); i++) {
|
||||
bErrorValueList.add(Math.abs(bStandardDev.get(i) - bDev.get(i)));
|
||||
}
|
||||
for (int i = 0; i < cStandardDev.size(); i++) {
|
||||
cErrorValueList.add(Math.abs(cStandardDev.get(i) - cDev.get(i)));
|
||||
}
|
||||
for (int i = 0; i < tStandardDev.size(); i++) {
|
||||
tErrorValueList.add(Math.abs(tStandardDev.get(i) - tDev.get(i)));
|
||||
}
|
||||
List<Integer> aErrorValueIdxs = DetectionUtil.sort(aErrorValueList, true);
|
||||
List<Integer> bErrorValueIdxs = DetectionUtil.sort(bErrorValueList, true);
|
||||
List<Integer> cErrorValueIdxs = DetectionUtil.sort(cErrorValueList, true);
|
||||
List<Integer> tErrorValueIdxs = DetectionUtil.sort(tErrorValueList, true);
|
||||
|
||||
if (CollUtil.isNotEmpty(aStandardDev) && CollUtil.isNotEmpty(aDev)) {
|
||||
Double v = aStandardDev.get(aErrorValueIdxs.get(0));
|
||||
aStandardDev.clear();
|
||||
aStandardDev.add(v);
|
||||
v = aDev.get(aErrorValueIdxs.get(0));
|
||||
aDev.clear();
|
||||
aDev.add(v);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(bStandardDev) && CollUtil.isNotEmpty(bDev)) {
|
||||
Double v = bStandardDev.get(bErrorValueIdxs.get(0));
|
||||
bStandardDev.clear();
|
||||
bStandardDev.add(v);
|
||||
v = bDev.get(bErrorValueIdxs.get(0));
|
||||
bDev.clear();
|
||||
bDev.add(v);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(cStandardDev) && CollUtil.isNotEmpty(cDev)) {
|
||||
Double v = cStandardDev.get(cErrorValueIdxs.get(0));
|
||||
cStandardDev.clear();
|
||||
cStandardDev.add(v);
|
||||
v = cDev.get(cErrorValueIdxs.get(0));
|
||||
cDev.clear();
|
||||
cDev.add(v);
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(tStandardDev) && CollUtil.isNotEmpty(tDev)) {
|
||||
Double v = tStandardDev.get(tErrorValueIdxs.get(0));
|
||||
tStandardDev.clear();
|
||||
tStandardDev.add(v);
|
||||
v = tDev.get(tErrorValueIdxs.get(0));
|
||||
tDev.clear();
|
||||
tDev.add(v);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -2647,9 +2722,10 @@ public class DetectionServiceImpl {
|
||||
}
|
||||
|
||||
if (CollUtil.isNotEmpty(value)) {
|
||||
List<Integer> idx = DetectionUtil.sort(value, false);
|
||||
|
||||
switch (dataRule) {
|
||||
case SECTION_VALUE:
|
||||
case SECTION_VALUE: {
|
||||
List<Integer> idx = DetectionUtil.sort(value, false);
|
||||
if (value.size() > 2) {
|
||||
value.remove(0);
|
||||
value.remove(value.size() - 1);
|
||||
@@ -2657,9 +2733,11 @@ public class DetectionServiceImpl {
|
||||
devPhaseHarmData.clear();
|
||||
devPhaseHarmData.addAll(newArray);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case CP95_VALUE:
|
||||
if (CollUtil.isNotEmpty(value)) {
|
||||
List<Integer> idx = DetectionUtil.sort(value, false);
|
||||
int cp95Idx = DetectionUtil.getCP95Idx(value);
|
||||
List<Double> newValue = Collections.singletonList(value.get(cp95Idx));
|
||||
value.clear();
|
||||
@@ -2678,18 +2756,30 @@ public class DetectionServiceImpl {
|
||||
devPhaseHarmData.addAll(devAvgData);
|
||||
break;
|
||||
case Own_value:
|
||||
List<Double> newArray = DetectionUtil.getNewArray(devPhaseHarmData, idx);
|
||||
devPhaseHarmData.clear();
|
||||
devPhaseHarmData.addAll(newArray);
|
||||
break;
|
||||
case AT_WILL_VALUE:
|
||||
if (CollUtil.isNotEmpty(value)) {
|
||||
Double v = value.get(0);
|
||||
if (isRemoveMaxElement) {
|
||||
if (CollUtil.isNotEmpty(value)) {
|
||||
Double v = value.get(value.size() - 1);
|
||||
value.clear();
|
||||
value.add(v);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(devPhaseHarmData)) {
|
||||
Double v = devPhaseHarmData.get(devPhaseHarmData.size() - 1);
|
||||
devPhaseHarmData.clear();
|
||||
devPhaseHarmData.add(v);
|
||||
}
|
||||
} else {
|
||||
List<Double> errorValueList = new ArrayList<>();
|
||||
for (int i = 0; i < value.size(); i++) {
|
||||
errorValueList.add(Math.abs(value.get(i) - devPhaseHarmData.get(i)));
|
||||
}
|
||||
|
||||
List<Integer> idxErrorValueList = DetectionUtil.sort(errorValueList, true);
|
||||
Double v = value.get(idxErrorValueList.get(0));
|
||||
value.clear();
|
||||
value.add(v);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(devPhaseHarmData)) {
|
||||
Double v = devPhaseHarmData.get(idx.get(0));
|
||||
v = devPhaseHarmData.get(idxErrorValueList.get(0));
|
||||
devPhaseHarmData.clear();
|
||||
devPhaseHarmData.add(v);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user