|
|
|
@ -143,34 +143,35 @@ public class VectorParamServiceImpl extends ServiceImpl<VectorParamMapper, Vecto
|
|
|
|
|
} |
|
|
|
|
log.info("synchronization vector param id:{}", id); |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
String tableName = entity.getTableName().replace(entity.getProjectPrefix() + "_", ""); |
|
|
|
|
String syncResult = weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap); |
|
|
|
|
if (this.update(Wrappers.<VectorParamEntity>lambdaUpdate() |
|
|
|
|
.eq(VectorParamEntity::getId, id) |
|
|
|
|
.set(VectorParamEntity::getSynchronizationRemark, syncResult) |
|
|
|
|
.set(VectorParamEntity::getSynchronizationTime, new Date()))) { |
|
|
|
|
return vectorParamLogService.synchronization(VectorParamLogEntity.builder() |
|
|
|
|
.vectorParamId(id) |
|
|
|
|
.type(DataOperateType.SYNCHRONIZATION.getCode()).build()); |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
if (response == null || response.getOriginalData() == null || response.getOriginalData().isEmpty()) { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
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()); |
|
|
|
|
} |
|
|
|
|
String tableName = entity.getTableName().replace(entity.getProjectPrefix() + "_", ""); |
|
|
|
|
String syncResult = weaviateService.saveBatch(response.getOriginalData(), tableName, attrMap); |
|
|
|
|
log.info("synchronization vector param id:{}, result:{}", id, syncResult); |
|
|
|
|
if (this.update(Wrappers.<VectorParamEntity>lambdaUpdate() |
|
|
|
|
.eq(VectorParamEntity::getId, id) |
|
|
|
|
.set(VectorParamEntity::getSynchronizationRemark, syncResult) |
|
|
|
|
.set(VectorParamEntity::getSynchronizationTime, new Date()))) { |
|
|
|
|
return vectorParamLogService.synchronization(VectorParamLogEntity.builder() |
|
|
|
|
.vectorParamId(id) |
|
|
|
|
.type(DataOperateType.SYNCHRONIZATION.getCode()).build()); |
|
|
|
|
} else { |
|
|
|
|
return false; |
|
|
|
|
} |
|
|
|
|
return true; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|