|
@@ -8,6 +8,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
import com.fasterxml.jackson.databind.node.ArrayNode;
|
|
import com.fasterxml.jackson.databind.node.IntNode;
|
|
import com.fasterxml.jackson.databind.node.IntNode;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
import com.fasterxml.jackson.databind.node.ObjectNode;
|
|
|
|
+import io.swagger.util.Json;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
|
import java.lang.reflect.Field;
|
|
import java.lang.reflect.Field;
|
|
@@ -119,8 +120,8 @@ public class TestJson {
|
|
dto.setScada("all");
|
|
dto.setScada("all");
|
|
dto.setAutoOrManual("manual");
|
|
dto.setAutoOrManual("manual");
|
|
dto.setBeginTime("1234-12-12 00:00:12");
|
|
dto.setBeginTime("1234-12-12 00:00:12");
|
|
-// dto.setExcludingMonths(Arrays.asList("1","2","3"));
|
|
|
|
-// dto.setTurbines(Arrays.asList("456","789"));
|
|
|
|
|
|
+ dto.setExcludingMonths(Arrays.asList("1","2","3"));
|
|
|
|
+ dto.setTurbines(Arrays.asList("456","789"));
|
|
dto.setValueActivePower(Arrays.asList(1,2));
|
|
dto.setValueActivePower(Arrays.asList(1,2));
|
|
dto.setConfigAnalysis(Arrays.asList("algorithm.powerOscillationAnalyst|PowerOscillationAnalyst|executeAnalysis|minute","algorithm.pitchTSRCpAnalyst|PitchTSRCpAnalyst|executeAnalysis|second"));
|
|
dto.setConfigAnalysis(Arrays.asList("algorithm.powerOscillationAnalyst|PowerOscillationAnalyst|executeAnalysis|minute","algorithm.pitchTSRCpAnalyst|PitchTSRCpAnalyst|executeAnalysis|second"));
|
|
setValue(dto,rootNode);
|
|
setValue(dto,rootNode);
|
|
@@ -156,7 +157,13 @@ public class TestJson {
|
|
if (entry.getKey().equals(propertyName)) {
|
|
if (entry.getKey().equals(propertyName)) {
|
|
//如果当前节点没有子节点直接复制
|
|
//如果当前节点没有子节点直接复制
|
|
if(!entry.getValue().fields().hasNext() && !propertyName.equals("configAnalysis")){
|
|
if(!entry.getValue().fields().hasNext() && !propertyName.equals("configAnalysis")){
|
|
- ((ObjectNode) rootNode).put(propertyName, value.toString());
|
|
|
|
|
|
+ if(StringUtils.endsWithAny(propertyName,"turbines","excludingMonths")){
|
|
|
|
+ ArrayNode arrayNode = mapper.createArrayNode();
|
|
|
|
+ ((List<String>)value).stream().forEach(item-> arrayNode.add(item));
|
|
|
|
+ ((ObjectNode) rootNode).set(propertyName,arrayNode);
|
|
|
|
+ }else{
|
|
|
|
+ ((ObjectNode) rootNode).put(propertyName, value.toString());
|
|
|
|
+ }
|
|
}else {
|
|
}else {
|
|
try {
|
|
try {
|
|
assignmentByPropertyName(entry.getValue(), propertyName, value,scada);
|
|
assignmentByPropertyName(entry.getValue(), propertyName, value,scada);
|
|
@@ -206,6 +213,11 @@ public class TestJson {
|
|
return ;
|
|
return ;
|
|
}
|
|
}
|
|
//分析类型特殊处理
|
|
//分析类型特殊处理
|
|
|
|
+// if("turbines".equals(propertyName)){
|
|
|
|
+// dealArrayNode(subNode, newValue);
|
|
|
|
+// return;
|
|
|
|
+// }
|
|
|
|
+ //分析类型特殊处理
|
|
if("configAnalysis".equals(propertyName)){
|
|
if("configAnalysis".equals(propertyName)){
|
|
dealConfigAnalysis(subNode, newValue,scada);
|
|
dealConfigAnalysis(subNode, newValue,scada);
|
|
return;
|
|
return;
|
|
@@ -221,6 +233,19 @@ public class TestJson {
|
|
" \"scada\": \"\"\n" +
|
|
" \"scada\": \"\"\n" +
|
|
"}";
|
|
"}";
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 数组类型处理
|
|
|
|
+ * @param subNode
|
|
|
|
+ * @param newValue
|
|
|
|
+ */
|
|
|
|
+ private static void dealArrayNode(JsonNode subNode, Object newValue) throws JsonProcessingException {
|
|
|
|
+ ArrayNode arrayNode = (ArrayNode) subNode;
|
|
|
|
+ List<String> tu = (List) newValue;
|
|
|
|
+ tu.stream().forEach(item -> arrayNode.add(item));
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 分析类型处理
|
|
* 分析类型处理
|
|
* @param subNode
|
|
* @param subNode
|