|
|
|
@ -39,6 +39,151 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
|
|
|
|
|
|
private static final int limit = 100;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* @Description:从金蝶ERP同步单位信息
|
|
|
|
|
*/
|
|
|
|
|
@Override
|
|
|
|
|
public int syncUnitInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception {
|
|
|
|
|
// String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) ?
|
|
|
|
|
// mesBaseSupplierInfoMapper.selectMaxErpModifyDate() : erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
|
String maxErpModifyDate = erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
|
return syncUnitInfoFromErp(startRow, maxErpModifyDate);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* @Description:从金蝶ERP同步单位信息,递归使用
|
|
|
|
|
*/
|
|
|
|
|
public int syncUnitInfoFromErp(int startRow, String maxErpModifyDate) throws Exception {
|
|
|
|
|
System.out.println("startRow=" + startRow + ",,,maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
|
K3CloudApi api = new K3CloudApi();
|
|
|
|
|
JSONObject queryJson = new JSONObject();
|
|
|
|
|
String formId = "BD_Unit";
|
|
|
|
|
String fieldKeys = "FUnitId,FNumber,FName,FCreateDate,FModifyDate";
|
|
|
|
|
String orderString = "";
|
|
|
|
|
int topRowCount = 0;
|
|
|
|
|
// int startRow = 0;
|
|
|
|
|
// int limit = 2;
|
|
|
|
|
queryJson.put("FormId", formId);
|
|
|
|
|
queryJson.put("FieldKeys", fieldKeys);
|
|
|
|
|
queryJson.put("OrderString", orderString);
|
|
|
|
|
queryJson.put("TopRowCount", topRowCount);
|
|
|
|
|
queryJson.put("StartRow", startRow);
|
|
|
|
|
queryJson.put("Limit", limit);
|
|
|
|
|
queryJson.put("SubSystemId", "");
|
|
|
|
|
|
|
|
|
|
//条件查询
|
|
|
|
|
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
|
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
|
|
|
|
|
queryJson.put("FilterString", filterString);
|
|
|
|
|
}
|
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
// if (StringUtils.isNotEmpty(beginTime) && StringUtils.isNotEmpty(endTime)) {
|
|
|
|
|
// String filterString = "FCreateDate >'" + beginTime + "' AND '" + endTime + "' >FCreateDate";
|
|
|
|
|
// queryJson.put("FilterString", filterString);
|
|
|
|
|
// }
|
|
|
|
|
// System.out.println(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
// "FieldKeys": "FNumber,FName,FBaseUnitId,FSpecification,FNETWEIGHT,FGROSSWEIGHT,FCreateDate,FModifyDate,FApproveDate",
|
|
|
|
|
// "FilterString": "FDocumentStatus='C' AND FCreateDate>'2022-01-01' and FMaterialGroup.FNUMBER IN ('28')",
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
|
|
if (StringUtils.isEmpty(result)) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
JSONArray resultArray = JSONArray.parseArray(result);
|
|
|
|
|
if (resultArray == null) {
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// List<MesBaseSupplierInfo> toInsertSupplierInfoList = new ArrayList<>();
|
|
|
|
|
// List<MesBaseSupplierInfo> toUpdateSupplierInfoList = new ArrayList<>();
|
|
|
|
|
// Date currentDate = new Date();
|
|
|
|
|
// for (int i = 0; i < resultArray.size(); i++) {
|
|
|
|
|
// try {
|
|
|
|
|
// JSONObject resultObject = (JSONObject) resultArray.get(i);
|
|
|
|
|
// MesBaseSupplierInfo mesBaseSupplierInfo = new MesBaseSupplierInfo();
|
|
|
|
|
// //供应商编号
|
|
|
|
|
// String FNumber = resultObject.getString("FNumber");
|
|
|
|
|
// //供应商名称
|
|
|
|
|
// String FName = resultObject.getString("FName");
|
|
|
|
|
// //erp主键id
|
|
|
|
|
// Long erpId = resultObject.getLong("FSupplierId");
|
|
|
|
|
// //创建时间
|
|
|
|
|
// String FCreateDate = resultObject.getString("FCreateDate");
|
|
|
|
|
// //更新时间
|
|
|
|
|
// String FModifyDate = resultObject.getString("FModifyDate");
|
|
|
|
|
// //审核日期
|
|
|
|
|
// String FAuditDate = resultObject.getString("FAuditDate");
|
|
|
|
|
//
|
|
|
|
|
// mesBaseSupplierInfo.setErpId(erpId);
|
|
|
|
|
// mesBaseSupplierInfo.setSupplierCode(FNumber);
|
|
|
|
|
// mesBaseSupplierInfo.setSupplierName(FName);
|
|
|
|
|
//
|
|
|
|
|
// //供应商状态
|
|
|
|
|
// mesBaseSupplierInfo.setSupplierStatus("1");
|
|
|
|
|
// mesBaseSupplierInfo.setUpdateTime(currentDate);
|
|
|
|
|
//
|
|
|
|
|
// if (StringUtils.isNotEmpty(FCreateDate)) {
|
|
|
|
|
// mesBaseSupplierInfo.setCreateTime(conversionERPTime(FCreateDate));
|
|
|
|
|
// }
|
|
|
|
|
// if (StringUtils.isNotEmpty(FModifyDate)) {
|
|
|
|
|
// mesBaseSupplierInfo.setErpModifyDate(conversionERPTime(FModifyDate));
|
|
|
|
|
// }
|
|
|
|
|
// if (StringUtils.isNotEmpty(FAuditDate)) {
|
|
|
|
|
// mesBaseSupplierInfo.setAuditDate(conversionERPTime(FAuditDate));
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// MesBaseSupplierInfo existedMesBaseSupplierInfo = mesBaseSupplierInfoMapper.selectMesBaseSupplierInfoByErpId(erpId);
|
|
|
|
|
//
|
|
|
|
|
// if (existedMesBaseSupplierInfo != null) {
|
|
|
|
|
// mesBaseSupplierInfo.setSupplierId(existedMesBaseSupplierInfo.getSupplierId());
|
|
|
|
|
// toUpdateSupplierInfoList.add(mesBaseSupplierInfo);
|
|
|
|
|
// } else {
|
|
|
|
|
// toInsertSupplierInfoList.add(mesBaseSupplierInfo);
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
//
|
|
|
|
|
// if (!toInsertSupplierInfoList.isEmpty()) {
|
|
|
|
|
// mesBaseSupplierInfoMapper.batchMesBaseSupplierInfo(toInsertSupplierInfoList);
|
|
|
|
|
// }
|
|
|
|
|
// if (!toUpdateSupplierInfoList.isEmpty()) {
|
|
|
|
|
// for (MesBaseSupplierInfo toUpdatedSupplierInfo : toUpdateSupplierInfoList) {
|
|
|
|
|
// mesBaseSupplierInfoMapper.updateMesBaseSupplierInfo(toUpdatedSupplierInfo);
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
System.out.println("size:" + resultArray.size());
|
|
|
|
|
System.out.println(resultArray);
|
|
|
|
|
//如果返回的数组的数量等于分页数量,则继续获取下一页数据
|
|
|
|
|
// if (resultArray.size() == limit) {
|
|
|
|
|
//// System.out.println(startRow);
|
|
|
|
|
// //通过递归同步所有供应商,测试先不用
|
|
|
|
|
// int i = syncSupplierInfoFromErp(startRow + resultArray.size(), maxErpModifyDate);
|
|
|
|
|
//// return i;
|
|
|
|
|
// return 1;
|
|
|
|
|
// } else {
|
|
|
|
|
// //为空时的总行数
|
|
|
|
|
// return startRow + resultArray.size();
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @throws Exception
|
|
|
|
|
* @Description:从金蝶ERP同步供应商信息
|
|
|
|
|