|
|
@ -6,6 +6,7 @@ import com.hw.common.core.constant.MesConstants;
|
|
|
|
import com.hw.common.core.utils.DateUtils;
|
|
|
|
import com.hw.common.core.utils.DateUtils;
|
|
|
|
import com.hw.common.core.utils.StringUtils;
|
|
|
|
import com.hw.common.core.utils.StringUtils;
|
|
|
|
import com.hw.jindie.api.domain.vo.ErpSyncInfoVo;
|
|
|
|
import com.hw.jindie.api.domain.vo.ErpSyncInfoVo;
|
|
|
|
|
|
|
|
import com.hw.jindie.config.KingdeeConfig;
|
|
|
|
import com.hw.jindie.domain.*;
|
|
|
|
import com.hw.jindie.domain.*;
|
|
|
|
import com.hw.jindie.mapper.*;
|
|
|
|
import com.hw.jindie.mapper.*;
|
|
|
|
import com.hw.jindie.service.IKingdeeErpSyncService;
|
|
|
|
import com.hw.jindie.service.IKingdeeErpSyncService;
|
|
|
@ -39,9 +40,131 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
private MesPurchaseOrderMapper mesPurchaseOrderMapper;
|
|
|
|
private MesPurchaseOrderMapper mesPurchaseOrderMapper;
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private MesBaseUnitInfoMapper mesBaseUnitInfoMapper;
|
|
|
|
private MesBaseUnitInfoMapper mesBaseUnitInfoMapper;
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private KingdeeConfig kingdeeConfig;
|
|
|
|
|
|
|
|
|
|
|
|
private static final int limit = 100;
|
|
|
|
private static final int limit = 100;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
|
|
* @Description:从金蝶ERP同步部门信息
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public int syncDeptInfoFromErp(int startRow) throws Exception {
|
|
|
|
|
|
|
|
// String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) ?
|
|
|
|
|
|
|
|
// mesBaseSupplierInfoMapper.selectMaxErpModifyDate() : erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
|
|
|
|
// String maxErpModifyDate = erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
|
|
|
|
return syncDeptInfoFromErp1(startRow);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* @throws Exception
|
|
|
|
|
|
|
|
* @Description:从金蝶ERP同步单位信息,递归使用
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public int syncDeptInfoFromErp1(int startRow) throws Exception {
|
|
|
|
|
|
|
|
System.out.println("startRow=" + startRow);
|
|
|
|
|
|
|
|
K3CloudApi api = new K3CloudApi();
|
|
|
|
|
|
|
|
JSONObject queryJson = new JSONObject();
|
|
|
|
|
|
|
|
String formId = "BD_Department";
|
|
|
|
|
|
|
|
String fieldKeys = "FDeptId,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(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(result)) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
System.out.println("部门单据查询接口: " + result);
|
|
|
|
|
|
|
|
JSONArray resultArray = JSONArray.parseArray(result);
|
|
|
|
|
|
|
|
if (resultArray == null) {
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<MesBaseUnitInfo> toInsertSupplierInfoList = new ArrayList<>();
|
|
|
|
|
|
|
|
List<MesBaseUnitInfo> toUpdateSupplierInfoList = new ArrayList<>();
|
|
|
|
|
|
|
|
Date currentDate = new Date();
|
|
|
|
|
|
|
|
// for (int i = 0; i < resultArray.size(); i++) {
|
|
|
|
|
|
|
|
// try {
|
|
|
|
|
|
|
|
// JSONObject resultObject = (JSONObject) resultArray.get(i);
|
|
|
|
|
|
|
|
// MesBaseUnitInfo baseUnitInfo = new MesBaseUnitInfo();
|
|
|
|
|
|
|
|
// //主键
|
|
|
|
|
|
|
|
// Long FUnitId = resultObject.getLong("FUnitId");
|
|
|
|
|
|
|
|
// //编号
|
|
|
|
|
|
|
|
// String FNumber = resultObject.getString("FNumber");
|
|
|
|
|
|
|
|
// //描述
|
|
|
|
|
|
|
|
// String FName = resultObject.getString("FName");
|
|
|
|
|
|
|
|
// //创建时间
|
|
|
|
|
|
|
|
// String FCreateDate = resultObject.getString("FCreateDate");
|
|
|
|
|
|
|
|
// //更新时间
|
|
|
|
|
|
|
|
// String FModifyDate = resultObject.getString("FModifyDate");
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// baseUnitInfo.setUnitCode(FNumber);
|
|
|
|
|
|
|
|
// baseUnitInfo.setErpId(FUnitId);
|
|
|
|
|
|
|
|
// baseUnitInfo.setUnitName(FName);
|
|
|
|
|
|
|
|
// baseUnitInfo.setUnitStatus("1");
|
|
|
|
|
|
|
|
// baseUnitInfo.setUpdateTime(currentDate);
|
|
|
|
|
|
|
|
// if (StringUtils.isNotEmpty(FCreateDate)) {
|
|
|
|
|
|
|
|
// baseUnitInfo.setCreateTime(conversionERPTime(FCreateDate));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// if (StringUtils.isNotEmpty(FModifyDate)) {
|
|
|
|
|
|
|
|
// baseUnitInfo.setErpModifyDate(conversionERPTime(FModifyDate));
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// MesBaseUnitInfo existedUnitInfo = mesBaseUnitInfoMapper.selectMesBaseUnitInfoByErpId(FUnitId);
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (existedUnitInfo != null) {
|
|
|
|
|
|
|
|
// baseUnitInfo.setUnitId(existedUnitInfo.getUnitId());
|
|
|
|
|
|
|
|
// toUpdateSupplierInfoList.add(baseUnitInfo);
|
|
|
|
|
|
|
|
// } else {
|
|
|
|
|
|
|
|
// toInsertSupplierInfoList.add(baseUnitInfo);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// } catch (Exception e) {
|
|
|
|
|
|
|
|
// e.printStackTrace();
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// if (!toInsertSupplierInfoList.isEmpty()) {
|
|
|
|
|
|
|
|
// for (MesBaseUnitInfo mesBaseUnitInfo : toInsertSupplierInfoList) {
|
|
|
|
|
|
|
|
// mesBaseUnitInfoMapper.insertMesBaseUnitInfo(mesBaseUnitInfo);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// if (!toUpdateSupplierInfoList.isEmpty()) {
|
|
|
|
|
|
|
|
// for (MesBaseUnitInfo toUpdatedUnitInfo : toUpdateSupplierInfoList) {
|
|
|
|
|
|
|
|
// mesBaseUnitInfoMapper.updateMesBaseUnitInfo(toUpdatedUnitInfo);
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("size:" + resultArray.size());
|
|
|
|
|
|
|
|
// System.out.println(resultArray);
|
|
|
|
|
|
|
|
//如果返回的数组的数量等于分页数量,则继续获取下一页数据
|
|
|
|
|
|
|
|
if (resultArray.size() == limit) {
|
|
|
|
|
|
|
|
//通过递归同步所有供应商,测试先不用
|
|
|
|
|
|
|
|
int i = syncDeptInfoFromErp1(startRow + resultArray.size());
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
//为空时的总行数
|
|
|
|
|
|
|
|
return startRow + resultArray.size();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
* @throws Exception
|
|
|
|
* @Description:从金蝶ERP同步单位信息
|
|
|
|
* @Description:从金蝶ERP同步单位信息
|
|
|
@ -165,7 +288,6 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
* @throws Exception
|
|
|
|
* @Description:从金蝶ERP同步供应商信息
|
|
|
|
* @Description:从金蝶ERP同步供应商信息
|
|
|
@ -323,6 +445,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
public int syncMaterialInfoFromErp(int startRow, String maxErpModifyDate) throws Exception {
|
|
|
|
public int syncMaterialInfoFromErp(int startRow, String maxErpModifyDate) throws Exception {
|
|
|
|
K3CloudApi api = new K3CloudApi();
|
|
|
|
K3CloudApi api = new K3CloudApi();
|
|
|
|
String FDocumentStatus = "C";
|
|
|
|
String FDocumentStatus = "C";
|
|
|
|
|
|
|
|
String materialCodePrefix = kingdeeConfig.materialCodePrefix;
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject queryJson = new JSONObject();
|
|
|
|
JSONObject queryJson = new JSONObject();
|
|
|
|
String formId = "BD_Material";
|
|
|
|
String formId = "BD_Material";
|
|
|
@ -341,11 +464,18 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
queryJson.put("Limit", limit);
|
|
|
|
queryJson.put("Limit", limit);
|
|
|
|
queryJson.put("SubSystemId", "");
|
|
|
|
queryJson.put("SubSystemId", "");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.isEmpty(materialCodePrefix)) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//条件查询
|
|
|
|
//条件查询
|
|
|
|
|
|
|
|
StringBuilder filterStringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
filterStringBuilder.append("FNumber like '%").append(materialCodePrefix).append("%'");
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
|
|
|
|
filterStringBuilder.append(" and FModifyDate >'").append(maxErpModifyDate).append("'");
|
|
|
|
queryJson.put("FilterString", filterString);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
queryJson.put("FilterString", filterStringBuilder.toString());
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
@ -417,6 +547,9 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpId);
|
|
|
|
MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByErpId(erpId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// MesBaseMaterialInfo existedMesBaseMaterialInfo = mesBaseMaterialInfoMapper.selectMesBaseMaterialInfoByMaterialCode(materialCode);
|
|
|
|
|
|
|
|
|
|
|
|
if (existedMesBaseMaterialInfo != null) {
|
|
|
|
if (existedMesBaseMaterialInfo != null) {
|
|
|
|
mesBaseMaterialInfo.setMaterialId(existedMesBaseMaterialInfo.getMaterialId());
|
|
|
|
mesBaseMaterialInfo.setMaterialId(existedMesBaseMaterialInfo.getMaterialId());
|
|
|
|
toUpdateMaterialInfoList.add(mesBaseMaterialInfo);
|
|
|
|
toUpdateMaterialInfoList.add(mesBaseMaterialInfo);
|
|
|
@ -456,8 +589,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int syncSaleOrderFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception {
|
|
|
|
public int syncSaleOrderFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception {
|
|
|
|
String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate())?
|
|
|
|
String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) ?
|
|
|
|
mesSaleOrderMapper.selectMaxErpModifyDate():erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
mesSaleOrderMapper.selectMaxErpModifyDate() : erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
return syncSaleOrderFromErp(startRow, maxErpModifyDate);
|
|
|
|
return syncSaleOrderFromErp(startRow, maxErpModifyDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -486,6 +619,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
// String filterString = "FNumber='98010102'";
|
|
|
|
// String filterString = "FNumber='98010102'";
|
|
|
|
// String filterString = "";
|
|
|
|
// String filterString = "";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String orderString = "";
|
|
|
|
String orderString = "";
|
|
|
|
int topRowCount = 0;
|
|
|
|
int topRowCount = 0;
|
|
|
|
// int startRow = 0;
|
|
|
|
// int startRow = 0;
|
|
|
@ -501,11 +636,23 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
|
|
//条件查询
|
|
|
|
//条件查询
|
|
|
|
|
|
|
|
Long deptId = kingdeeConfig.erpDeptId;
|
|
|
|
|
|
|
|
if (deptId == null) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
StringBuilder filterStringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
filterStringBuilder.append("FSaleDeptId = ").append(deptId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filterStringBuilder.append(" and FDocumentStatus='C'");
|
|
|
|
|
|
|
|
|
|
|
|
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
|
|
|
|
filterStringBuilder.append(" and FModifyDate >'").append(maxErpModifyDate).append("'");
|
|
|
|
queryJson.put("FilterString", filterString);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
queryJson.put("FilterString", filterStringBuilder.toString());
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
@ -558,6 +705,10 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
Long stockOrgId = resultObject.getLong("FStockOrgId");
|
|
|
|
Long stockOrgId = resultObject.getLong("FStockOrgId");
|
|
|
|
//单据状态
|
|
|
|
//单据状态
|
|
|
|
String documentStatus = resultObject.getString("FDocumentStatus");
|
|
|
|
String documentStatus = resultObject.getString("FDocumentStatus");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!documentStatus.equals("C")){
|
|
|
|
|
|
|
|
System.out.println(documentStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
String tondBase = resultObject.getString("F.TOND.Base");
|
|
|
|
String tondBase = resultObject.getString("F.TOND.Base");
|
|
|
|
String FCreateDate = resultObject.getString("FCreateDate");
|
|
|
|
String FCreateDate = resultObject.getString("FCreateDate");
|
|
|
|
|
|
|
|
|
|
|
@ -638,8 +789,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int syncProjectInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception {
|
|
|
|
public int syncProjectInfoFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception {
|
|
|
|
String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate())?
|
|
|
|
String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) ?
|
|
|
|
mesProjectInfoMapper.selectMaxErpModifyDate(): erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
mesProjectInfoMapper.selectMaxErpModifyDate() : erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
return syncProjectInfoFromErp(startRow, maxErpModifyDate);
|
|
|
|
return syncProjectInfoFromErp(startRow, maxErpModifyDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -672,7 +823,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
//条件查询
|
|
|
|
//条件查询
|
|
|
|
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
|
|
|
|
String filterString = "FModifyDate >'" + maxErpModifyDate + "' and FDocumentStatus ='C'";
|
|
|
|
queryJson.put("FilterString", filterString);
|
|
|
|
queryJson.put("FilterString", filterString);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
@ -693,6 +844,11 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
String FNumber = resultObject.getString("FNumber");
|
|
|
|
String FNumber = resultObject.getString("FNumber");
|
|
|
|
String FName = resultObject.getString("FName");
|
|
|
|
String FName = resultObject.getString("FName");
|
|
|
|
String FDocumentStatus = resultObject.getString("FDocumentStatus");
|
|
|
|
String FDocumentStatus = resultObject.getString("FDocumentStatus");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(!FDocumentStatus.equals("C")){
|
|
|
|
|
|
|
|
System.out.println(FDocumentStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
String FForbidStatus = resultObject.getString("FForbidStatus");
|
|
|
|
String FForbidStatus = resultObject.getString("FForbidStatus");
|
|
|
|
String FAuditDate = resultObject.getString("FAuditDate");
|
|
|
|
String FAuditDate = resultObject.getString("FAuditDate");
|
|
|
|
String FModifyDate = resultObject.getString("FModifyDate");
|
|
|
|
String FModifyDate = resultObject.getString("FModifyDate");
|
|
|
@ -757,8 +913,8 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public int syncPurchaseOrderFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception {
|
|
|
|
public int syncPurchaseOrderFromErp(int startRow, ErpSyncInfoVo erpSyncInfoVo) throws Exception {
|
|
|
|
String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate())?
|
|
|
|
String maxErpModifyDate = StringUtils.isEmpty(erpSyncInfoVo.getMaxErpModifyDate()) ?
|
|
|
|
mesPurchaseOrderMapper.selectMaxErpModifyDate():erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
mesPurchaseOrderMapper.selectMaxErpModifyDate() : erpSyncInfoVo.getMaxErpModifyDate();
|
|
|
|
return syncPurchaseOrderFromErp(startRow, maxErpModifyDate);
|
|
|
|
return syncPurchaseOrderFromErp(startRow, maxErpModifyDate);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -767,13 +923,13 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
* @Descrption:从金蝶ERP同步采购订单
|
|
|
|
* @Descrption:从金蝶ERP同步采购订单
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public int syncPurchaseOrderFromErp(int startRow, String maxErpModifyDate) throws Exception {
|
|
|
|
public int syncPurchaseOrderFromErp(int startRow, String maxErpModifyDate) throws Exception {
|
|
|
|
maxErpModifyDate = "2022-03-23 11:30:57";
|
|
|
|
// maxErpModifyDate = "2022-03-23 11:30:57";
|
|
|
|
K3CloudApi api = new K3CloudApi();
|
|
|
|
K3CloudApi api = new K3CloudApi();
|
|
|
|
// String FDocumentStatus = "C";
|
|
|
|
// String FDocumentStatus = "C";
|
|
|
|
JSONObject queryJson = new JSONObject();
|
|
|
|
JSONObject queryJson = new JSONObject();
|
|
|
|
String formId = "PUR_PurchaseOrder";
|
|
|
|
String formId = "PUR_PurchaseOrder";
|
|
|
|
String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," +
|
|
|
|
String fieldKeys = "FID,FBillNo,FApproveDate,FDocumentStatus,FPOOrderEntry_FEntryID,FRequireDeptId,FMaterialId,FMaterialId.FNumber,FMaterialId.FName," +
|
|
|
|
"FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FAUXPROPID.FF100001,FSrcBillNo,FPurchaseOrgId,F_TOND_Base,FSupplierId";
|
|
|
|
"FQty,FDeliveryDate,FCreateDate,FModifyDate,FUnitId,FStockUnitID,FPriceUnitID,FAuxPropId,FAUXPROPID.FF100001,FSrcBillNo,FPurchaseOrgId,FPurchaseDeptId,F_TOND_Base,FSupplierId";
|
|
|
|
// String filterString = "";
|
|
|
|
// String filterString = "";
|
|
|
|
String orderString = "";
|
|
|
|
String orderString = "";
|
|
|
|
int topRowCount = 0;
|
|
|
|
int topRowCount = 0;
|
|
|
@ -787,20 +943,32 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
queryJson.put("StartRow", startRow);
|
|
|
|
queryJson.put("StartRow", startRow);
|
|
|
|
queryJson.put("Limit", limit);
|
|
|
|
queryJson.put("Limit", limit);
|
|
|
|
queryJson.put("SubSystemId", "");
|
|
|
|
queryJson.put("SubSystemId", "");
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
// System.out.println(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
|
|
//条件查询
|
|
|
|
//条件查询
|
|
|
|
System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
Long deptId = kingdeeConfig.erpDeptId;
|
|
|
|
|
|
|
|
if (deptId == null) {
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
|
|
|
|
StringBuilder filterStringBuilder = new StringBuilder();
|
|
|
|
|
|
|
|
filterStringBuilder.append("FPurchaseDeptId = ").append(deptId);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filterStringBuilder.append(" and FDocumentStatus = 'C'");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// System.out.println("maxErpModifyDate=" + maxErpModifyDate);
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
if (StringUtils.isNotEmpty(maxErpModifyDate)) {
|
|
|
|
String filterString = "FModifyDate >'" + maxErpModifyDate + "'";
|
|
|
|
filterStringBuilder.append(" FModifyDate >'").append(maxErpModifyDate).append("'");
|
|
|
|
queryJson.put("FilterString", filterString);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
System.out.println(queryJson.toString());
|
|
|
|
queryJson.put("FilterString", filterStringBuilder.toString());
|
|
|
|
|
|
|
|
// System.out.println(queryJson.toString());
|
|
|
|
|
|
|
|
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
|
String result = api.billQuery(queryJson.toString());
|
|
|
|
JSONArray resultArray = JSONArray.parseArray(result);
|
|
|
|
JSONArray resultArray = JSONArray.parseArray(result);
|
|
|
|
System.out.println(resultArray.size());
|
|
|
|
// System.out.println(resultArray.size());
|
|
|
|
System.out.println("采购订单单据查询接口: " + result);
|
|
|
|
// System.out.println("采购订单单据查询接口: " + result);
|
|
|
|
|
|
|
|
|
|
|
|
List<MesPurchaseOrder> toInsertPurchaseOrderList = new ArrayList<>();
|
|
|
|
List<MesPurchaseOrder> toInsertPurchaseOrderList = new ArrayList<>();
|
|
|
|
List<MesPurchaseOrder> toUpdatePurchaseOrderList = new ArrayList<>();
|
|
|
|
List<MesPurchaseOrder> toUpdatePurchaseOrderList = new ArrayList<>();
|
|
|
@ -817,6 +985,9 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
String approveDate = resultObject.getString("FApproveDate");
|
|
|
|
String approveDate = resultObject.getString("FApproveDate");
|
|
|
|
//单据状态
|
|
|
|
//单据状态
|
|
|
|
String documentStatus = resultObject.getString("FDocumentStatus");
|
|
|
|
String documentStatus = resultObject.getString("FDocumentStatus");
|
|
|
|
|
|
|
|
if(!documentStatus.equals("C")){
|
|
|
|
|
|
|
|
System.out.println(documentStatus);
|
|
|
|
|
|
|
|
}
|
|
|
|
//订单明细id
|
|
|
|
//订单明细id
|
|
|
|
Long fentryId = resultObject.getLong("FPOOrderEntry.FEntryID");
|
|
|
|
Long fentryId = resultObject.getLong("FPOOrderEntry.FEntryID");
|
|
|
|
//erp物料ID
|
|
|
|
//erp物料ID
|
|
|
@ -871,9 +1042,7 @@ public class KingdeeErpSyncServiceImpl implements IKingdeeErpSyncService {
|
|
|
|
mesPurchaseOrder.setTondBase(tondBase);
|
|
|
|
mesPurchaseOrder.setTondBase(tondBase);
|
|
|
|
mesPurchaseOrder.setSupplierId(supplierId);
|
|
|
|
mesPurchaseOrder.setSupplierId(supplierId);
|
|
|
|
mesPurchaseOrder.setUpdateTime(currentDate);
|
|
|
|
mesPurchaseOrder.setUpdateTime(currentDate);
|
|
|
|
|
|
|
|
mesPurchaseOrder.setOrderStatus(MesConstants.MES_PURCHASE_ORDER_STATUS_TOPURCHASE);
|
|
|
|
//todo:需要确认ERP中的采购订单信息有没有完成和代采购的状态等信息
|
|
|
|
|
|
|
|
// mesPurchaseOrder.setOrderStatus(待采购);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (approveDate != null) {
|
|
|
|
if (approveDate != null) {
|
|
|
|
mesPurchaseOrder.setApproveDate(conversionERPTime(approveDate));
|
|
|
|
mesPurchaseOrder.setApproveDate(conversionERPTime(approveDate));
|
|
|
|