fix: 添加判断条件处理svalue,rvalue异常问题

This commit is contained in:
wht
2025-05-20 11:25:37 +08:00
parent 62682dcb5b
commit 8e44840c88

View File

@ -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,21 +539,33 @@ 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>>() {});
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\"/>",
@ -559,8 +573,11 @@ public class C8TestController {
entry.getValue()
));
}
}
Map<String, Object> rValueMap = mapper.readValue(rValue, new TypeReference<Map<String, Object>>() {});
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\"/>",
@ -568,6 +585,20 @@ public class C8TestController {
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())