fix: 添加判断条件处理svalue,rvalue异常问题
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
package com.centricsoftware.enhancement.controller.c8;
|
||||
|
||||
import com.centricsoftware.enhancement.modules.c8.dto.ExpResultEntity;
|
||||
import com.fasterxml.jackson.core.type.TypeReference;
|
||||
import cn.hutool.core.convert.Convert;
|
||||
@ -321,7 +322,8 @@ public class C8TestController {
|
||||
public ResEntity searchByUrl(@RequestParam Map<String, ?> map) {
|
||||
String url = (String) map.get("url");
|
||||
JSONObject jsonObject = nodeInfoByUrl(url);
|
||||
return WebResponse.success(ResCode.SUCCESS, jsonObject);
|
||||
String nodeStr = JsonUtil.toJSONString(jsonObject);
|
||||
return WebResponse.success(ResCode.SUCCESS, JsonUtil.parseObject(nodeStr, Object.class));
|
||||
}
|
||||
|
||||
public JSONObject nodeInfoByUrl(String url) {
|
||||
@ -537,37 +539,66 @@ public class C8TestController {
|
||||
String modifiedTimeStart = (String) map.get("modifiedTimeStart");
|
||||
String modifiedTimeEnd = (String) map.get("modifiedTimeEnd");
|
||||
|
||||
// 如果是10位时间戳,补为13位时间戳
|
||||
if (modifiedTimeStart != null && modifiedTimeStart.length() == 10) {
|
||||
modifiedTimeStart = modifiedTimeStart + "000";
|
||||
}
|
||||
if (modifiedTimeEnd != null && modifiedTimeEnd.length() == 10) {
|
||||
modifiedTimeEnd = modifiedTimeEnd + "000";
|
||||
}
|
||||
|
||||
|
||||
int page = Convert.toInt(map.get("page"), 1);
|
||||
int pageSize = Convert.toInt(map.get("pageSize"), 10);
|
||||
|
||||
String sequence = Convert.toStr(map.get("sequence"), "DESC");
|
||||
String nodeName = (String) map.get("nodeName");
|
||||
String parent = (String) map.get("parent");
|
||||
String URL = (String) map.get("URL");
|
||||
|
||||
String sValue = (String) map.get("sValue");
|
||||
String rValue = (String) map.get("rValue");
|
||||
String value = (String) map.get("value");
|
||||
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
try {
|
||||
Map<String, Object> sValueMap = mapper.readValue(sValue, new TypeReference<Map<String, Object>>() {});
|
||||
|
||||
for (Map.Entry<String, Object> entry : sValueMap.entrySet()) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Attribute Id=\"%s\" Op=\"EQ\" SValue=\"%s\"/>",
|
||||
entry.getKey(),
|
||||
entry.getValue()
|
||||
));
|
||||
if (sValue != null) {
|
||||
Map<String, Object> sValueMap = mapper.readValue(sValue, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
for (Map.Entry<String, Object> entry : sValueMap.entrySet()) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Attribute Id=\"%s\" Op=\"EQ\" SValue=\"%s\"/>",
|
||||
entry.getKey(),
|
||||
entry.getValue()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> rValueMap = mapper.readValue(rValue, new TypeReference<Map<String, Object>>() {});
|
||||
for (Map.Entry<String, Object> entry : rValueMap.entrySet()) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Attribute Id=\"%s\" Op=\"EQ\" RValue=\"%s\"/>",
|
||||
entry.getKey(),
|
||||
entry.getValue()
|
||||
));
|
||||
if (rValue != null) {
|
||||
Map<String, Object> rValueMap = mapper.readValue(rValue, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
for (Map.Entry<String, Object> entry : rValueMap.entrySet()) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Attribute Id=\"%s\" Op=\"EQ\" RValue=\"%s\"/>",
|
||||
entry.getKey(),
|
||||
entry.getValue()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
if (value != null) {
|
||||
Map<String, Object> valueMap = mapper.readValue(value, new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
for (Map.Entry<String, Object> entry : valueMap.entrySet()) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Attribute Id=\"%s\" Op=\"EQ\" Value=\"%s\"/>",
|
||||
entry.getKey(),
|
||||
entry.getValue()
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
log.error("Error parsing JSON: {}", e.getMessage());
|
||||
}
|
||||
@ -579,13 +610,13 @@ public class C8TestController {
|
||||
|
||||
if (!StrUtil.isBlank(modifiedTimeStart)) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Attribute Id=\"ModifiedAt\" Op=\"GE\" SValue=\"%s\"/>",
|
||||
"<Node Parameter=\"PublishedTime\" Op=\"GE\" Value=\"%s\"/>",
|
||||
modifiedTimeStart
|
||||
));
|
||||
}
|
||||
if (!StrUtil.isBlank(modifiedTimeEnd)) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Attribute Id=\"ModifiedAt\" Op=\"LE\" SValue=\"%s\"/>",
|
||||
"<Node Parameter=\"PublishedTime\" Op=\"LE\" Value=\"%s\"/>",
|
||||
modifiedTimeEnd
|
||||
));
|
||||
}
|
||||
@ -604,7 +635,13 @@ public class C8TestController {
|
||||
));
|
||||
}
|
||||
|
||||
System.out.println("xmlBuilder: " + xmlBuilder.toString());
|
||||
if (!StrUtil.isBlank(URL)) {
|
||||
xmlBuilder.append(String.format(
|
||||
"<Node Parameter=\"URL\" Op=\"EQ\" Value=\"%s\"/>",
|
||||
URL
|
||||
));
|
||||
}
|
||||
log.info("xmlBuilder: {}", xmlBuilder);
|
||||
|
||||
DepPath depPath = DepPath.builderXml()
|
||||
.xml(xmlBuilder.toString())
|
||||
|
Reference in New Issue
Block a user