|
|
@ -108,10 +108,11 @@ public abstract class OdooAbstrackob {
|
|
|
|
LarkCompanyRelation companyRelation = context.getCompanyRelation();
|
|
|
|
LarkCompanyRelation companyRelation = context.getCompanyRelation();
|
|
|
|
LarkTableRelation tableRelation = context.getTableRelation();
|
|
|
|
LarkTableRelation tableRelation = context.getTableRelation();
|
|
|
|
LarkTableRequest larkRequest = new LarkTableRequest(companyRelation.getAppId(), companyRelation.getSecret(), tableRelation.getToAppToken(), tableRelation.getToTableId());
|
|
|
|
LarkTableRequest larkRequest = new LarkTableRequest(companyRelation.getAppId(), companyRelation.getSecret(), tableRelation.getToAppToken(), tableRelation.getToTableId());
|
|
|
|
|
|
|
|
List<Integer> retryPageList = new ArrayList<>();
|
|
|
|
//待创建关联关系
|
|
|
|
//待创建关联关系
|
|
|
|
do {
|
|
|
|
do {
|
|
|
|
List<ErpLarkRelation> waitCreateRelation = new ArrayList<>();
|
|
|
|
List<ErpLarkRelation> waitCreateRelation = new ArrayList<>();
|
|
|
|
dateList = getDate(context, pageMap, errorList,context.getWarehouseId());
|
|
|
|
dateList = getDate(context, pageMap,context.getWarehouseId(),retryPageList);
|
|
|
|
List<JSONObject> midDateList = dateList.stream().map(r -> {
|
|
|
|
List<JSONObject> midDateList = dateList.stream().map(r -> {
|
|
|
|
return (JSONObject)JSONObject.toJSON(r);
|
|
|
|
return (JSONObject)JSONObject.toJSON(r);
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
}).collect(Collectors.toList());
|
|
|
@ -126,6 +127,29 @@ public abstract class OdooAbstrackob {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
pageMap.put(PAGE_OFFSET_KEY,pageMap.get(PAGE_OFFSET_KEY) + PAGE_SIZE);
|
|
|
|
pageMap.put(PAGE_OFFSET_KEY,pageMap.get(PAGE_OFFSET_KEY) + PAGE_SIZE);
|
|
|
|
} while (dateList == null || (CollectionUtils.isNotEmpty(dateList) && dateList.size() == PAGE_SIZE));
|
|
|
|
} while (dateList == null || (CollectionUtils.isNotEmpty(dateList) && dateList.size() == PAGE_SIZE));
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(retryPageList)){
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
for (Integer page : retryPageList) {
|
|
|
|
|
|
|
|
pageMap.put(PAGE_OFFSET_KEY,page + PAGE_SIZE);
|
|
|
|
|
|
|
|
List<ErpLarkRelation> waitCreateRelation = new ArrayList<>();
|
|
|
|
|
|
|
|
dateList = getDate(context, pageMap,context.getWarehouseId(),null);
|
|
|
|
|
|
|
|
List<JSONObject> midDateList = dateList.stream().map(r -> {
|
|
|
|
|
|
|
|
return (JSONObject)JSONObject.toJSON(r);
|
|
|
|
|
|
|
|
}).collect(Collectors.toList());
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(midDateList)){
|
|
|
|
|
|
|
|
Map<String, String> relationMap = getLarkRelation(midDateList,context.getWarehouseId());
|
|
|
|
|
|
|
|
for (JSONObject jsonObject : midDateList) {
|
|
|
|
|
|
|
|
sync(jsonObject, errorList, relationMap, larkRequest,waitCreateRelation,context.getWarehouseId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(waitCreateRelation)){
|
|
|
|
|
|
|
|
erpLarkRelationMapper.batchInsert(waitCreateRelation);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}catch (Exception e){
|
|
|
|
|
|
|
|
errorList.add(String.format("%s 获取第【%s】页数据失败 %s", this.getClassName(), pageMap.get(PAGE_OFFSET_KEY), e.getMessage()));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
if (!CollectionUtils.isEmpty(errorList)) {
|
|
|
|
if (!CollectionUtils.isEmpty(errorList)) {
|
|
|
|
String errorKey = String.join(",", errorList);
|
|
|
|
String errorKey = String.join(",", errorList);
|
|
|
|
throw new RuntimeException(String.format("存在同步失败的记录 %s", errorKey));
|
|
|
|
throw new RuntimeException(String.format("存在同步失败的记录 %s", errorKey));
|
|
|
@ -244,7 +268,7 @@ public abstract class OdooAbstrackob {
|
|
|
|
return jsonArray;
|
|
|
|
return jsonArray;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public List<Object> getDate(OdooContext odooContext, Map<String, Integer> pageMap, List<String> errorList,Integer warehouseId) {
|
|
|
|
public List<Object> getDate(OdooContext odooContext, Map<String, Integer> pageMap,Integer warehouseId,List<Integer> retryPageList) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
XmlRpcClient models = odooContext.getModels();
|
|
|
|
XmlRpcClient models = odooContext.getModels();
|
|
|
|
Integer uid = getUserId();
|
|
|
|
Integer uid = getUserId();
|
|
|
@ -264,7 +288,9 @@ public abstract class OdooAbstrackob {
|
|
|
|
)));
|
|
|
|
)));
|
|
|
|
} catch (Exception e) {
|
|
|
|
} catch (Exception e) {
|
|
|
|
log.error("{} 获取数据失败", this.getClassName(), e);
|
|
|
|
log.error("{} 获取数据失败", this.getClassName(), e);
|
|
|
|
errorList.add(String.format("%s 获取第【%s】页数据失败 %s", this.getClassName(), pageMap.get(PAGE_OFFSET_KEY), e.getMessage()));
|
|
|
|
if (retryPageList != null) {
|
|
|
|
|
|
|
|
retryPageList.add(pageMap.get(PAGE_OFFSET_KEY));
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|