Fixed the Transaction lock, Now the transaction is short
This commit is contained in:
parent
8814b541ee
commit
3483a4f8c1
|
@ -71,40 +71,36 @@ public class MRPUpdate extends SvrProcess
|
||||||
|
|
||||||
public boolean deleteMRP()
|
public boolean deleteMRP()
|
||||||
{
|
{
|
||||||
|
Trx trx = Trx.get("MRP Delete", true);
|
||||||
|
|
||||||
System.out.println("begin deleteMRP()");
|
|
||||||
|
|
||||||
//String sql = "DELETE FROM PP_MRP mrp WHERE mrp.TypeMRP = 'MOP' AND EXISTS(SELECT PP_Order_ID FROM PP_Order o WHERE o.PP_Order_ID = mrp.PP_Order_ID AND o.DocStatus IN ('DR','CL')) AND mrp.AD_Client_ID = " + AD_Client_ID;
|
|
||||||
|
|
||||||
String sql = "DELETE FROM PP_MRP WHERE TypeMRP = 'MOP' AND AD_Client_ID=" + AD_Client_ID;
|
String sql = "DELETE FROM PP_MRP WHERE TypeMRP = 'MOP' AND AD_Client_ID=" + AD_Client_ID;
|
||||||
|
|
||||||
DB.executeUpdate(sql, get_TrxName());
|
DB.executeUpdate(sql, trx.getTrxName());
|
||||||
|
|
||||||
sql = "DELETE FROM PP_MRP mrp WHERE mrp.TypeMRP = 'FCT' AND mrp.AD_Client_ID = " + AD_Client_ID;
|
sql = "DELETE FROM PP_MRP mrp WHERE mrp.TypeMRP = 'FCT' AND mrp.AD_Client_ID = " + AD_Client_ID;
|
||||||
|
|
||||||
DB.executeUpdate(sql,get_TrxName());
|
DB.executeUpdate(sql,trx.getTrxName());
|
||||||
|
|
||||||
//sql = "DELETE FROM PP_MRP mrp WHERE mrp.TypeMRP = 'POR' AND EXISTS(SELECT M_Requisition_ID FROM M_Requisition r WHERE r.M_Requisition_ID = mrp.M_Requisition_ID AND (r.DocStatus='DR' AND r.DocStatus='CL')) AND mrp.AD_Client_ID = " + AD_Client_ID;
|
//sql = "DELETE FROM PP_MRP mrp WHERE mrp.TypeMRP = 'POR' AND EXISTS(SELECT M_Requisition_ID FROM M_Requisition r WHERE r.M_Requisition_ID = mrp.M_Requisition_ID AND (r.DocStatus='DR' AND r.DocStatus='CL')) AND mrp.AD_Client_ID = " + AD_Client_ID;
|
||||||
sql = "DELETE FROM PP_MRP mrp WHERE mrp.TypeMRP = 'POR' AND mrp.AD_Client_ID = " + AD_Client_ID;
|
sql = "DELETE FROM PP_MRP mrp WHERE mrp.TypeMRP = 'POR' AND mrp.AD_Client_ID = " + AD_Client_ID;
|
||||||
|
|
||||||
DB.executeUpdate(sql,get_TrxName());
|
DB.executeUpdate(sql,trx.getTrxName());
|
||||||
|
|
||||||
sql = "DELETE FROM AD_Note n WHERE AD_Table_ID = " + MPPMRP.Table_ID + " AND AD_Client_ID = " + AD_Client_ID;
|
sql = "DELETE FROM AD_Note n WHERE AD_Table_ID = " + MPPMRP.Table_ID + " AND AD_Client_ID = " + AD_Client_ID;
|
||||||
|
|
||||||
DB.executeUpdate(sql, get_TrxName());
|
DB.executeUpdate(sql, trx.getTrxName());
|
||||||
|
|
||||||
|
|
||||||
sql = "SELECT o.PP_Order_ID FROM PP_Order o WHERE o.DocStatus = 'DR' AND o.AD_Client_ID = " + AD_Client_ID;
|
sql = "SELECT o.PP_Order_ID FROM PP_Order o WHERE o.DocStatus = 'DR' AND o.AD_Client_ID = " + AD_Client_ID;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
pstmt = DB.prepareStatement (sql,get_TrxName());
|
pstmt = DB.prepareStatement (sql,trx.getTrxName());
|
||||||
//pstmt.setInt(1, p_M_Warehouse_ID);
|
//pstmt.setInt(1, p_M_Warehouse_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
MPPOrder order = new MPPOrder(getCtx(), rs.getInt(1), get_TrxName());
|
MPPOrder order = new MPPOrder(getCtx(), rs.getInt(1), trx.getTrxName());
|
||||||
order.delete(true);
|
order.delete(true);
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
|
@ -117,17 +113,17 @@ public class MRPUpdate extends SvrProcess
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
sql = "SELECT r.M_Requisition_ID FROM M_Requisition r WHERE r.DocStatus = 'DR' AND r.AD_Client_ID = " + AD_Client_ID;
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
sql = "SELECT r.M_Requisition_ID FROM M_Requisition r WHERE r.DocStatus = 'DR' AND r.AD_Client_ID = " + AD_Client_ID;
|
||||||
|
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
pstmt = DB.prepareStatement (sql,get_TrxName());
|
pstmt = DB.prepareStatement (sql,trx.getTrxName());
|
||||||
//pstmt.setInt(1, p_M_Warehouse_ID);
|
//pstmt.setInt(1, p_M_Warehouse_ID);
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
MRequisition r = new MRequisition(getCtx(), rs.getInt(1),get_TrxName());
|
MRequisition r = new MRequisition(getCtx(), rs.getInt(1),trx.getTrxName());
|
||||||
|
|
||||||
MRequisitionLine[] rlines = r. getLines();
|
MRequisitionLine[] rlines = r. getLines();
|
||||||
for ( int i= 0 ; i < rlines.length; i++ )
|
for ( int i= 0 ; i < rlines.length; i++ )
|
||||||
|
@ -140,7 +136,7 @@ public class MRPUpdate extends SvrProcess
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
|
@ -148,6 +144,9 @@ public class MRPUpdate extends SvrProcess
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trx.commit();
|
||||||
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -155,6 +154,7 @@ public class MRPUpdate extends SvrProcess
|
||||||
public boolean update()
|
public boolean update()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
// Get Forcast
|
// Get Forcast
|
||||||
String sql = "SELECT fl.M_FORECASTLINE_ID FROM M_FORECASTLINE fl WHERE fl.Qty > 0 AND fl.AD_Client_ID = " + AD_Client_ID;
|
String sql = "SELECT fl.M_FORECASTLINE_ID FROM M_FORECASTLINE fl WHERE fl.Qty > 0 AND fl.AD_Client_ID = " + AD_Client_ID;
|
||||||
PreparedStatement pstmt = null;
|
PreparedStatement pstmt = null;
|
||||||
|
@ -167,8 +167,10 @@ public class MRPUpdate extends SvrProcess
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
Trx trx = Trx.get("MRP Forecast", true);
|
||||||
MForecastLine fl = new MForecastLine(Env.getCtx(),rs.getInt(1),get_TrxName());
|
MForecastLine fl = new MForecastLine(Env.getCtx(),rs.getInt(1),get_TrxName());
|
||||||
MPPMRP.M_ForecastLine(fl,false);
|
MPPMRP.M_ForecastLine(fl,false);
|
||||||
|
trx.commit();
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
|
@ -187,9 +189,10 @@ public class MRPUpdate extends SvrProcess
|
||||||
ResultSet rs = pstmt.executeQuery ();
|
ResultSet rs = pstmt.executeQuery ();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
Trx trx = Trx.get("MRP MO", true);
|
||||||
MPPOrder o = new MPPOrder(Env.getCtx(),rs,get_TrxName());
|
MPPOrder o = new MPPOrder(Env.getCtx(),rs,get_TrxName());
|
||||||
MPPMRP.PP_Order(o);
|
MPPMRP.PP_Order(o);
|
||||||
|
trx.commit();
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
|
@ -212,8 +215,10 @@ public class MRPUpdate extends SvrProcess
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
Trx trx = Trx.get("MRP OrderLine", true);
|
||||||
MOrderLine ol = new MOrderLine(Env.getCtx(),rs.getInt(1),get_TrxName());
|
MOrderLine ol = new MOrderLine(Env.getCtx(),rs.getInt(1),get_TrxName());
|
||||||
MPPMRP.C_OrderLine(ol,false);
|
MPPMRP.C_OrderLine(ol,false);
|
||||||
|
trx.commit();
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
|
@ -237,8 +242,10 @@ public class MRPUpdate extends SvrProcess
|
||||||
ResultSet rs = pstmt.executeQuery();
|
ResultSet rs = pstmt.executeQuery();
|
||||||
while (rs.next())
|
while (rs.next())
|
||||||
{
|
{
|
||||||
|
Trx trx = Trx.get("MRP OrderLine", true);
|
||||||
MRequisitionLine rl = new MRequisitionLine(Env.getCtx(),rs.getInt(1),get_TrxName());
|
MRequisitionLine rl = new MRequisitionLine(Env.getCtx(),rs.getInt(1),get_TrxName());
|
||||||
MPPMRP.M_RequisitionLine(rl,false);
|
MPPMRP.M_RequisitionLine(rl,false);
|
||||||
|
trx.commit();
|
||||||
}
|
}
|
||||||
rs.close();
|
rs.close();
|
||||||
pstmt.close();
|
pstmt.close();
|
||||||
|
|
Loading…
Reference in New Issue