创建临时表进行性能优化

	public void updatePurAndSaleOrderByARAP(Context ctx, IObjectPK pk,boolean isAudit) throws EASBizException, BOSException {
// boolean isAR = com.kingdee.eas.fi.ar.OtherBillFactory.getLocalInstance(ctx).exists(pk);
// if (isAR) {
String tempTableDefine[][] = {
{ "APentryID", "VARCHAR(44)" },
{ "TOBentryID", "VARCHAR(44)" }};
Connection connection = CommonServerUtils.getConnection(ctx);
SysTempTableHelper tem = new SysTempTableHelper(ctx, connection);
String tempTable = tem.createTempTable(ctx, tempTableDefine);
if(tempTable==null || tempTable.trim().length()==0)
{
System.out.println("临时表创建失败");
return;
}
StringBuffer sql = new StringBuffer();
sql.append(" INSERT INTO "+tempTable+" \n");
sql.append(" select \n");
sql.append(" \n");
sql.append(" APentry.FID APentryID, \n"); // 应付单分录ID
sql.append(" TOBentry.FID TOBentryID \n"); // 采购订单分录ID
sql.append(" \n");
sql.append(" from T_AP_OtherBillentry APentry \n"); // 应付单分录
sql.append(" \n");
sql.append(" inner join T_IM_PurInWarehsEntry PIWentry \n"); // 应付单源单采购入库单分录
sql.append(" on PIWentry.FID = APentry.FSourceBillEntryId \n");
sql.append(" \n");
sql.append(" inner join T_IM_TransferOrderBillEntry TOBentry \n"); // 采购入库单源单调拨订单分录
sql.append(" on TOBentry.FID = PIWentry.FSourceBillEntryId \n");
sql.append(" \n");
sql.append(" inner join T_IM_TransferOrderBill TOB \n");
sql.append(" on TOB.FID = TOBentry.FParentID \n");
sql.append(" \n");
sql.append(" inner join T_SCM_BizType BType \n");
sql.append(" on BType.FID = TOB.FBizTypeID \n");
sql.append(" \n");
sql.append(" where APentry.FParentID='"+pk+"' \n");
sql.append(" and (BType.FNumber = '370' or BType.FNumber = '310') \n");

tem.execute(sql.toString());

StringBuffer sqla = new StringBuffer();
sqla.append(" select \n");
sqla.append(" \n");
sqla.append(" temp.APentryID APentryID, \n");
sqla.append(" SOentry.FID SPOentryID, \n");
sqla.append(" 'C48A423A' entryID \n");
sqla.append(" \n");
sqla.append(" from "+tempTable+" temp \n");
sqla.append(" \n");
sqla.append(" inner join T_SD_SaleOrderEntry SOentry \n");
sqla.append(" on SOentry.FSourceBillEntryId = temp.TOBentryID \n");
sqla.append(" \n");
sqla.append(" union all \n");
sqla.append(" \n");
sqla.append(" select \n");
sqla.append(" \n");
sqla.append(" temp.APentryID APentryID, \n");
sqla.append(" POentry.FID SPOentryID, \n");
sqla.append(" '3171BFAD' entryID \n");
sqla.append(" \n");
sqla.append(" from "+tempTable+" temp \n");
sqla.append(" \n");
sqla.append(" inner join T_SM_PurOrderEntry POentry \n");
sqla.append(" on POentry.FSourceBillEntryId = temp.TOBentryID \n");

ResultSet result = DbUtil.executeQuery(ctx,sqla.toString());
try {
while (result.next())
{
String entryID = result.getString("entryID");
if("C48A423A".equals(entryID))
{
SynergyBillAssistUtils.updateSaleByAP(ctx, result.getString("SPOentryID"), result.getString("APentryID"), isAudit);
}else if("3171BFAD".equals(entryID))
{
SynergyBillAssistUtils.updatePurByAP(ctx, result.getString("SPOentryID"), result.getString("APentryID"), isAudit);
}
}
} catch (SQLException e) {
e.printStackTrace();
}

//释放临时表
if(tempTable==null || tempTable.trim().length()==0)
{
tem.releaseTempTable(tempTable);
}

/* // 2.应收单反写采购订单
updatePurByAR(ctx, tempTable,pk, isAudit);
// 3.应收单反写销售
updateSaleByAR(ctx, tempTable,pk, isAudit);

//释放临时表
if(tempTable==null || tempTable.trim().length()==0)
{
tem.releaseTempTable(tempTable);
}
// } else {
// 1.应付单反写采购
updatePurByAP(ctx, pk, isAudit);
// }
*/ }
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值