jindie:增加单位信息同步
master
xs 4 months ago
parent 470b8bb782
commit f629d164bb

@ -32,6 +32,21 @@ public class KingdeeErpSyncController {
@Autowired
private KingdeeErpService kingdeeErpService;
/**
* erpMES
*/
@PostMapping("/syncUnitInfoFromErp")
@Log(title = "ERP单位信息", businessType = BusinessType.INSERT)
// @InnerAuth
public AjaxResult syncUnitInfoFromErp(@RequestBody ErpSyncInfoVo erpSyncInfoVo) {
try {
return AjaxResult.success(kingdeeErpSyncService.syncUnitInfoFromErp(0, erpSyncInfoVo));
} catch (Exception e) {
logger.error("同步单位信息错误:" + e.getMessage());
return AjaxResult.error();
}
}
/**
* erpMES
*/

@ -4,6 +4,12 @@ import com.hw.jindie.api.domain.vo.ErpSyncInfoVo;
public interface IKingdeeErpSyncService {
/**
* @throws Exception
* @Description:ERP
*/
public int syncUnitInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception;
public int syncSupplierInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception;
public int syncMaterialInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception;
public int syncProjectInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception;

@ -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

Loading…
Cancel
Save