|
|
|
@ -49,6 +49,7 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
|
|
|
|
|
.header("Hzinfo-Auth", hzinfoToken).execute(); |
|
|
|
|
if (response.getStatus() == HttpServletResponse.SC_OK) { |
|
|
|
|
String body = response.body(); |
|
|
|
|
log.info("vector url response url:{}, response:{}", url, body); |
|
|
|
|
try { |
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
JsonNode rootNode = mapper.readTree(body); |
|
|
|
@ -108,28 +109,33 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Boolean synchronization(Long id, String bladeToken, String hzinfoToken) { |
|
|
|
|
VectorParamEntity entity = getById(id); |
|
|
|
|
if (null == entity) { |
|
|
|
|
public Boolean synchronization(List<Long> ids, String bladeToken, String hzinfoToken) { |
|
|
|
|
if (null == ids && ids.isEmpty()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); |
|
|
|
|
if (response != null) { |
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
JsonNode rootNode = null; |
|
|
|
|
try { |
|
|
|
|
rootNode = mapper.readTree(entity.getAttributeMap()); |
|
|
|
|
} catch (JsonProcessingException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
for (Long id : ids) { |
|
|
|
|
VectorParamEntity entity = getById(id); |
|
|
|
|
if (null == entity) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
Map<String, String> attrMap = new HashMap<>(); |
|
|
|
|
Iterator<String> iterator = rootNode.fieldNames(); |
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
String key = iterator.next(); |
|
|
|
|
attrMap.put(key, rootNode.findValue(key).textValue()); |
|
|
|
|
VectorUrlResponse response = getUrlResponse(entity.getUrl(), bladeToken, hzinfoToken); |
|
|
|
|
if (response != null) { |
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
JsonNode rootNode = null; |
|
|
|
|
try { |
|
|
|
|
rootNode = mapper.readTree(entity.getAttributeMap()); |
|
|
|
|
} catch (JsonProcessingException e) { |
|
|
|
|
log.error("getUrlResponseKeyList error", e); |
|
|
|
|
} |
|
|
|
|
Map<String, String> attrMap = new HashMap<>(); |
|
|
|
|
Iterator<String> iterator = rootNode.fieldNames(); |
|
|
|
|
while (iterator.hasNext()) { |
|
|
|
|
String key = iterator.next(); |
|
|
|
|
attrMap.put(key, rootNode.findValue(key).textValue()); |
|
|
|
|
} |
|
|
|
|
weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap); |
|
|
|
|
this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); |
|
|
|
|
} |
|
|
|
|
weaviateService.saveBatch(response.getOriginalData(), entity.getTableName(), attrMap); |
|
|
|
|
this.update(Wrappers.<VectorParamEntity>lambdaUpdate().eq(VectorParamEntity::getId, id).set(VectorParamEntity::getUpdateTime, new Date())); |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|