Commit 7b612837 authored by msingh's avatar msingh

D15CKAT001, Changes for MS SQL Server.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98667 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0113a849
......@@ -31,7 +31,7 @@ import javax.ejb.Stateless; // added for ejb3
public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLocal , InvHoldRelConfRemote //SessionBean
{
/* public void ejbCreate() throws RemoteException,CreateException{
/* public void ejbCreate() throws RemoteException,CreateException{
}
public void ejbRemove(){
......@@ -48,7 +48,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
}*/
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
String retString = "",errCode = "",confirmed = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
......@@ -71,7 +71,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
}
}
catch(Exception exception)
{
System.out.println("Exception in [InvHoldConfEJB] getCurrdateAppFormat " + exception.getMessage());
......@@ -79,16 +79,16 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
return retString;
}
public String confirm(String tranId,String xtraParams, String forcedFlag ,Connection conn,boolean isConn) throws RemoteException,ITMException
{
// Connection conn = null;
PreparedStatement pstmt = null;
public String confirm(String tranId,String xtraParams, String forcedFlag ,Connection conn,boolean isConn) throws RemoteException,ITMException
{
// Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
// ConnDriver connDriver = null;
ResultSet rs = null;
String sql = "";
// ConnDriver connDriver = null;
String loginEmpCode = null;
ibase.utility.E12GenericUtility genericUtility= null;
ibase.utility.E12GenericUtility genericUtility= null;
Document dom = null;
int count=0;
......@@ -97,7 +97,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
int upd = 0;
int lineNo= 0;
//changed by Dharmesh on 12-08-2011 [WM1ESUN004].start
String itemCode = null;
String siteCode = null;
String locCode = null;
......@@ -122,7 +122,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
double relQty = 0.0;
int lineNoHold = 0;
String sqlUpdate = null;
String sqlHoldDet = null;
String sqlSelStck = null;
......@@ -130,31 +130,31 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
String sqlInsert = null;
String sqlDetail = null;
String lockCode = null;
PreparedStatement pUpdate = null;
PreparedStatement pHoldDet = null;
PreparedStatement pSelStock = null;
PreparedStatement pSelTrace = null;
PreparedStatement pInsert = null;
PreparedStatement pDetail = null;
ResultSet rsHoldDet = null;
ResultSet rsSelStck = null;
ResultSet rsSelTrace = null;
ResultSet rsDetail = null;
String holdStatus = ""; // 14/04/14 manoharan
//changed by Dharmesh on 12-08-2011 [WM1ESUN004].end
try
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = new ibase.utility.E12GenericUtility();
// connDriver = new ConnDriver();
// conn = connDriver.getConnectDB("DriverITM");
// conn.setAutoCommit(false);
// connDriver = new ConnDriver();
// conn = connDriver.getConnectDB("DriverITM");
// conn.setAutoCommit(false);
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
//Changed by sumit on 02/10/12 getting loginempCode in case of null start.
......@@ -165,34 +165,34 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
//Changed by sumit on 02/10/12 getting loginempCode in case of null end.
//check if there is record in detal
int countDet = 0;
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " select count( 1 ) cnt from inv_hold_rel_det where tran_id = '" + tranId.trim() + "' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
*/
sql = "select count( 1 ) cnt from inv_hold_rel_det where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
if( rs.next() )
{
countDet = rs.getInt( "cnt" );
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( countDet == 0 )
{
errString = itmDBAccessEJB.getErrorString("","VTNODET","","",conn);
}
if( errString == null || errString.length() == 0 )
{
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
......@@ -200,7 +200,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
sql = " select count( 1 ) cnt from inv_hold_rel where tran_id = '" + tranId.trim() + "' AND CONFIRMED = 'Y' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
*/
*/
sql = "select count( 1 ) cnt from inv_hold_rel where tran_id = ? AND CONFIRMED = 'Y'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
......@@ -210,17 +210,17 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
{
countDet = rs.getInt( "cnt" );
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( countDet > 0 )
{
errString = itmDBAccessEJB.getErrorString("","VTCONFMD","","",conn);
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to commit unconfirmed transaction.start
else
{
......@@ -229,28 +229,28 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
sqlSelStck = "SELECT ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, QTY_PER_ART, HOLD_QTY FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? " ;
pSelStock = conn.prepareStatement(sqlSelStck);
sqlSelTrace = "SELECT SUM( case when HOLD_QTY is null then 0 else HOLD_QTY end ) AS HOLD_QTY_TRACE, SUM( case when REL_QTY is null then 0 else REL_QTY end ) AS REL_QTY_TRACE FROM INV_HOLD_REL_TRACE WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO = ? AND LOT_SL = ? " ;
pSelTrace = conn.prepareStatement(sqlSelTrace);
//sqlInsert = " INSERT INTO INV_HOLD_REL_TRACE ( TRAN_ID, ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, REF_NO, REL_QTY, LOCK_CODE ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ? ) " ; // comment added by sagar on 23/07/15
sqlInsert = " INSERT INTO INV_HOLD_REL_TRACE ( TRAN_ID, ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, REF_NO, REL_QTY, LOCK_CODE, REF_LINE ) VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) " ; // REF_LINE added by sagar on 23/07/15
pInsert = conn.prepareStatement(sqlInsert);
// 14/04/14 manoharan hold_status added it should not be R
sqlHoldDet = "SELECT ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, LINE_NO_SL, HOLD_STATUS FROM INV_HOLD_DET WHERE TRAN_ID = ? AND LINE_NO = ?" ;
pHoldDet = conn.prepareStatement(sqlHoldDet);
/*sqlDetail = " SELECT HOLDDET.TRAN_ID__HOLD, HOLDDET.LINE_NO__HOLD, IHOLD.LOCK_CODE "+
" FROM INV_HOLD_REL_DET HOLDDET, INV_HOLD IHOLD "+
" WHERE HOLDDET.TRAN_ID__HOLD = IHOLD.TRAN_ID AND HOLDDET.TRAN_ID = ? ";*/ // comment added by sagar on 27/07/15
sqlDetail = " SELECT HOLDDET.TRAN_ID__HOLD, HOLDDET.LINE_NO__HOLD, IHOLD.LOCK_CODE, HOLDDET.LINE_NO "+
" FROM INV_HOLD_REL_DET HOLDDET, INV_HOLD IHOLD "+
" WHERE HOLDDET.TRAN_ID__HOLD = IHOLD.TRAN_ID AND HOLDDET.TRAN_ID = ? "; // LINE_NO added by sagar on 27/07/15
" FROM INV_HOLD_REL_DET HOLDDET, INV_HOLD IHOLD "+
" WHERE HOLDDET.TRAN_ID__HOLD = IHOLD.TRAN_ID AND HOLDDET.TRAN_ID = ? "; // LINE_NO added by sagar on 27/07/15
pDetail = conn.prepareStatement( sqlDetail );
pDetail.setString( 1,tranId );
rsDetail = pDetail.executeQuery();
pDetail.clearParameters();
while( rsDetail.next() )
{
tranIdHold = rsDetail.getString("TRAN_ID__HOLD");
......@@ -263,10 +263,10 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
System.out.println(">>>>Release Line No:"+ lineNo);
pHoldDet.setString( 1,tranIdHold );
pHoldDet.setInt( 2,lineNoHold );
rsHoldDet = pHoldDet.executeQuery();
pHoldDet.clearParameters();
while( rsHoldDet.next() )
{
itemCode = checkNull(rsHoldDet.getString("ITEM_CODE"));
......@@ -275,7 +275,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
lotNo = checkNull(rsHoldDet.getString("LOT_NO"));
lotSl = checkNull(rsHoldDet.getString("LOT_SL"));
lineNoSl = checkNull(rsHoldDet.getString("LINE_NO_SL"));
// 14/04/14 manoharan if hold_status = "R" the give error
// 14/04/14 manoharan if hold_status = "R" the give error
holdStatus = checkNull(rsHoldDet.getString("HOLD_STATUS"));
if ("R".equals(holdStatus))
{
......@@ -293,45 +293,45 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
pSelStock.setString( 3, locCode );
pSelStock.setString( 4, lotNo );
pSelStock.setString( 5, lotSl );
rsSelStck = pSelStock.executeQuery();
pSelStock.clearParameters();
if( rsSelStck.next() )
{
qtyPerArt = rsSelStck.getDouble("QTY_PER_ART");
holdQtyStock = rsSelStck.getDouble("HOLD_QTY");
}
if( rsSelStck != null )
{
rsSelStck.close();
rsSelStck = null;
}
pSelTrace.setString( 1, itemCode );
pSelTrace.setString( 2, siteCode );
pSelTrace.setString( 3, locCode );
pSelTrace.setString( 4, lotNo );
pSelTrace.setString( 5, lotSl );
rsSelTrace = pSelTrace.executeQuery();
pSelTrace.clearParameters();
if( rsSelTrace.next() )
{
holdQtyTrace = rsSelTrace.getDouble("HOLD_QTY_TRACE");
relQtyTrace = rsSelTrace.getDouble("REL_QTY_TRACE");
}
if(rsSelTrace != null)
{
rsSelTrace.close();
rsSelTrace = null;
}
balQtyHold = holdQtyTrace - ( Math.abs(relQtyTrace) + qtyPerArt );
if( balQtyHold == 0 )
{
pUpdate.setDouble( 1, balQtyHold);
......@@ -366,16 +366,31 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
pInsert.setDouble( 8, (-qtyPerArt) );
pInsert.setString( 9, lockCode );
pInsert.setInt( 10, lineNo );
pInsert.executeUpdate();
pInsert.clearParameters();
}//end of Line_sl present
else //i.e. line_sl is not found
{
HashMap pkKeyValMap = new HashMap();
StringBuffer sb = new StringBuffer("SELECT ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY, HOLD_QTY, QTY_PER_ART FROM STOCK WHERE ");//change on 09/jun/14 compare with inv_hold_rel_trace table
sb.append(" ( ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL ) in (select ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL from inv_hold_rel_trace where ref_no ='"+tranIdHold+"') and STOCK.QUANTITY > 0 and STOCK.HOLD_QTY > 0 and ") ;//ADDED BY KUNAL ON 27/MAY/14 add extra condition for data filter
// Changed by Manish on 30/09/15 for Ms Sql Server.
StringBuffer sb ;
String DB = CommonConstants.DB_NAME;
if("mssql".equalsIgnoreCase(DB))
{
sb = new StringBuffer("SELECT S.ITEM_CODE, S.SITE_CODE, S.LOC_CODE, S.LOT_NO, S.LOT_SL, S.QUANTITY, S.HOLD_QTY, S.QTY_PER_ART FROM STOCK S ");//change on 09/jun/14 compare with inv_hold_rel_trace table
sb.append(" inner join (select ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL from inv_hold_rel_trace where ref_no ='"+tranIdHold+"') A on (S.ITEM_CODE = A.ITEM_CODE AND S.SITE_CODE = A.SITE_CODE AND S.LOC_CODE = A.LOC_CODE AND S.LOT_NO = A.LOT_NO AND S.LOT_SL = A.LOT_SL ) ") ;
sb.append(" where S.QUANTITY > 0 and S.HOLD_QTY > 0 and ") ;
}
else
{
sb = new StringBuffer("SELECT ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY, HOLD_QTY, QTY_PER_ART FROM STOCK WHERE ");//change on 09/jun/14 compare with inv_hold_rel_trace table
sb.append(" ( ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL ) in (select ITEM_CODE,SITE_CODE,LOC_CODE,LOT_NO,LOT_SL from inv_hold_rel_trace where ref_no ='"+tranIdHold+"') and STOCK.QUANTITY > 0 and STOCK.HOLD_QTY > 0 and ") ;//ADDED BY KUNAL ON 27/MAY/14 add extra condition for data filter
}
// Changed by Manish on 30/09/15 for Ms Sql Server.
ArrayList pkList = new ArrayList();
if ( itemCode != null && itemCode.length() > 0 )
......@@ -409,6 +424,12 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
for ( int i = 0; i < pkList.size(); i++ )
{
key = pkList.get(i).toString();
if("mssql".equalsIgnoreCase(DB))
{
sb.append("S."); // S added by manish for mssql
}
sb.append(key).append(" = ? and ");
}
String stockQuery = sb.toString();
......@@ -435,19 +456,19 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
pSelTrace.setString( 5, lotSl );
rsSelTrace = pSelTrace.executeQuery();
pSelTrace.clearParameters();
if(rsSelTrace.next())
{
holdQtyTrace = rsSelTrace.getDouble("HOLD_QTY_TRACE");
relQtyTrace = rsSelTrace.getDouble("REL_QTY_TRACE");
}
if( rsSelTrace != null)
{
rsSelTrace.close();
rsSelTrace = null;
}
*/
*/
rsStock = pstmtStock.executeQuery();
pstmtStock.clearParameters();
......@@ -465,7 +486,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
System.out.println("Quantity =[" + stockQty + "]");
System.out.println("holdQtyStock =[" + holdQtyStock + "]");
//Selecting sum(hold_qty) and sum(rel_qty) from trace table
pSelTrace.setString( 1, itemCode );
pSelTrace.setString( 2, siteCode );
......@@ -474,7 +495,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
pSelTrace.setString( 5, lotSl );
rsSelTrace = pSelTrace.executeQuery();
pSelTrace.clearParameters();
if(rsSelTrace.next())
{
holdQtyTrace = rsSelTrace.getDouble("HOLD_QTY_TRACE");
......@@ -490,7 +511,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
balQtyHold = holdQtyTrace - ( Math.abs(relQtyTrace) + holdQtyStock ) ;
System.out.println("balQtyHold =[" + balQtyHold + "]");
if( balQtyHold == 0 )
{
//holdQtyStock = holdQtyStock - relQtyTrace ;
......@@ -536,7 +557,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
rsStock = null;
}
}//end of else
pHoldDet.clearParameters();
}//end of outer while()
if(rsHoldDet != null)
......@@ -560,12 +581,12 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
{
break;
}*/
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to commit unconfirmed transaction.end
}
//
if( errString == null || errString.length() == 0 )
{
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
......@@ -574,7 +595,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.executeUpdate();
*/
*/
sql = "update inv_hold_rel set confirmed = 'Y', emp_code__aprv = ? , CONF_DATE = ? where tran_id = ?" ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,loginEmpCode);
......@@ -585,7 +606,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
pstmt.close();
pstmt = null;
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.start
/*
sql = " update inv_hold_det hd set "
......@@ -595,36 +616,54 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
+" in ( select rd.tran_id__hold, rd.line_no__hold "
+" from inv_hold_rel_det rd "
+" where tran_id = '" + tranId + "' ) ";
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.executeUpdate();
*/
sql = " update inv_hold_det hd set "
+" hd.hold_status = 'R', "
+" hd.STATUS_DATE = ? "
+" where (hd.tran_id, hd.line_no ) "
+" in ( select rd.tran_id__hold, rd.line_no__hold "
+" from inv_hold_rel_det rd "
+" where tran_id = ? )";
*/
//Changed by Manish on 16/09/2015 for Ms Sql Server.
String DB = CommonConstants.DB_NAME;
if("mssql".equalsIgnoreCase(DB))
{
sql = " update inv_hold_det set "
+" hold_status = 'R', "
+" STATUS_DATE = ? "
+" from inv_hold_det hd "
+" inner join ( select rd.tran_id__hold, rd.line_no__hold "
+" from inv_hold_rel_det rd "
+"where tran_id = ? ) A on (hd.tran_id = A.TRAN_ID__HOLD and hd.line_no = A.line_no__hold)";
}
else
{
sql = " update inv_hold_det hd set "
+" hd.hold_status = 'R', "
+" hd.STATUS_DATE = ? "
+" where (hd.tran_id, hd.line_no ) "
+" in ( select rd.tran_id__hold, rd.line_no__hold "
+" from inv_hold_rel_det rd "
+" where tran_id = ? )";
}
//Changed by Manish on 16/09/2015 for Ms Sql Server.
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp( 1 , new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString(2,tranId);
pstmt.executeUpdate();
//changed by Dharmesh on 11-08-2011 [WM1ESUN004] to bind variable dynamically instead of statically.end
pstmt.close();
pstmt = null;
}
if( errString != null && errString.length() > 0 )
if( errString != null && errString.length() > 0 )
{
System.out.println("Returning Result "+errString);
conn.rollback();
return errString;
}
System.out.println("Returning Result "+errString);
conn.rollback();
return errString;
}
else
{ // added by shamim
if(isConn)
......@@ -634,30 +673,30 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
errString = itmDBAccessEJB.getErrorString("","VTCNFSUCC","");
System.out.println("Returnng String From InvHoldRelConfEJB : .." + errString);
}
System.out.println("errString : "+errString);
}catch(ITMException ie)
System.out.println("errString : "+errString);
}catch(ITMException ie)
{
System.out.println("ITMException : "+ie);
try{
System.out.println("ITMException : "+ie);
try{
conn.rollback();
}catch(Exception t){}
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldRelConfEJB :"+errString);
return errString;
}catch(Exception e){
System.out.println("Returnng String From InvHoldRelConfEJB :"+e);
try{
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldRelConfEJB :"+errString);
return errString;
}catch(Exception e){
System.out.println("Returnng String From InvHoldRelConfEJB :"+e);
try{
conn.rollback();
}catch(Exception t){}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldRelConfEJB :"+errString);
return errString;
}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From InvHoldRelConfEJB :"+errString);
return errString;
}
finally
{
try{
try{
if( pstmt != null )
{
pstmt.close();
......@@ -689,24 +728,24 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
pDetail.close();
pDetail = null;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to close preparedStatements and to make null.end
if(conn != null && isConn ==true)
{
conn.close();
conn = null;
}
}catch(Exception e){System.out.println("Exception : "+e);e.printStackTrace();}
}
System.out.println("InvHoldRelConfEJB :"+errString);
return errString;
}catch(Exception e){System.out.println("Exception : "+e);e.printStackTrace();}
}
System.out.println("InvHoldRelConfEJB :"+errString);
return errString;
}
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to auto genrate Transacion Id for inv_hold_rel_trace.start
// METHOD ARGS CHANGED BY RITESH ON 13/MAR/14
public String generateTranId(String windowName,String siteCode,Connection conn)throws ITMException
//changed by Dharmesh on 12-08-2011 [WM1ESUN004] to auto genrate Transacion Id for inv_hold_rel_trace.start
// METHOD ARGS CHANGED BY RITESH ON 13/MAR/14
public String generateTranId(String windowName,String siteCode,Connection conn)throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
......@@ -716,13 +755,13 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
String keyString = "";
String keyCol = "";
String xmlValues = "";
java.sql.Date effDate = null;
// ADDED BY RITESH ON 13/MAR/14 START
java.sql.Timestamp currDate = null;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
java.sql.Timestamp currDate = null;
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
try
{
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
......@@ -730,7 +769,7 @@ public class InvHoldRelConf extends ActionHandlerEJB implements InvHoldRelConfLo
currDate = new java.sql.Timestamp(System.currentTimeMillis());
String currDateStr = sdfAppl.format(currDate);
// ADDED BY RITESH ON 13/MAR/14 END
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
......
......@@ -37,12 +37,12 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
ConnDriver connDriver = null;
try
{
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("Driver");
conn.setAutoCommit(false);
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("Driver");
conn.setAutoCommit(false);
retString = confirm( tranID, xtraParams, forcedFlag,conn);
}
catch(Exception exception)
{
......@@ -66,14 +66,14 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
try
{
if (conn==null)
{
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("Driver");
conn.setAutoCommit(false);
isLocal=true;
}
{
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("Driver");
conn.setAutoCommit(false);
isLocal=true;
}
itmDBAccessEJB = new ITMDBAccessEJB();
sql = "select confirmed,site_code from sord_alloc where tran_id = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
......@@ -95,11 +95,11 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
else
{
sql = "SELECT SALE_ORDER, LINE_NO__SORD, SUM(QUANTITY) FROM SORD_ALLOC_DET WHERE TRAN_ID = ? " +
" GROUP BY SALE_ORDER, LINE_NO__SORD ORDER BY SALE_ORDER, LINE_NO__SORD";
" GROUP BY SALE_ORDER, LINE_NO__SORD ORDER BY SALE_ORDER, LINE_NO__SORD";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while( rs.next())
{
if ("db2".equalsIgnoreCase(CommonConstants.DB_NAME ) || "mysql".equalsIgnoreCase(CommonConstants.DB_NAME ))
......@@ -114,17 +114,17 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
{
sqlSorditem = " select * from sorditem where sale_order = ? and line_no = ? for update nowait ";
}
psmtSord = conn.prepareStatement(sqlSorditem);
psmtSord.setString(1, rs.getString("SALE_ORDER"));
psmtSord.setString(2, rs.getString("LINE_NO__SORD"));
psmtSord.executeQuery();
if(psmtSord!=null)
psmtSord.close();
psmtSord.close();
psmtSord= null;
}
pstmt.close();pstmt = null;
rs.close();rs = null;
if(errString != null && errString.trim().length() > 0)
......@@ -133,7 +133,7 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
}
else
{
errString = this.sorderDeAllocate(tranId,xtraParams,conn);
}
......@@ -181,7 +181,7 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
rs1.close();
rs1 = null;
}
}
catch(Exception e)
{
......@@ -237,21 +237,21 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
java.sql.Timestamp tranDate = java.sql.Timestamp.valueOf(genericUtility.getValidDateString( currDateStr , applDateFormat, dbDateFormat ) + " 00:00:00.0") ;
getDataSql = "select d.tran_id ,d.line_no ,d.sale_order ,d.line_no__sord ,d.item_code , "
+" d.loc_code ,d.lot_no ,d.lot_sl ,d.quantity ,d.dealloc_qty,h.site_code__ship , "
+" d.exp_lev,d.pending_qty "
+" from sord_alloc_det d , sord_alloc h "
+" where h.tran_id = d.tran_id and d.tran_id = ? "
+" order by line_no asc ";
+" d.loc_code ,d.lot_no ,d.lot_sl ,d.quantity ,d.dealloc_qty,h.site_code__ship , "
+" d.exp_lev,d.pending_qty "
+" from sord_alloc_det d , sord_alloc h "
+" where h.tran_id = d.tran_id and d.tran_id = ? "
+" order by line_no asc ";
pSordAllocDet = conn.prepareStatement(getDataSql);
pSordAllocDet.setString(1,tranId);
rs = pSordAllocDet.executeQuery();
System.out.println("tranId------["+ tranId);
int updCount = 0;
while(rs.next())
{
tranIDD = rs.getString(1);
lineNo = rs.getString(2);
saleOrder = rs.getString(3);
......@@ -272,62 +272,99 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
System.out.println("pendingQuantity["+pendingQuantity+"]");
System.out.print("qtyToBeDeAllocated = " + qtyToBeDeAllocated);
strDeAllocate = new HashMap();
strDeAllocate.put("tran_date",tranDate);
strDeAllocate.put("ref_ser","D-ALOC");
strDeAllocate.put("site_code",siteCodeShip);
strDeAllocate.put("item_code",itemCode);
strDeAllocate.put("loc_code",locCode);
strDeAllocate.put("lot_no",lotNo);
strDeAllocate.put("lot_sl",lotSl);
strDeAllocate.put("alloc_qty",new Double(-1 * qtyToBeDeAllocated));
System.out.print("DeallocQty = [" + (-1 * qtyToBeDeAllocated)+"]");
strDeAllocate.put("chg_user",new ibase.utility.E12GenericUtility().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strDeAllocate.put("chg_term",new ibase.utility.E12GenericUtility().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strDeAllocate.put("chg_win","W_SORD_DEALLOC");
if (qtyToBeDeAllocated > 0 && saleOrder.trim().length()>0)
strDeAllocate = new HashMap();
strDeAllocate.put("tran_date",tranDate);
strDeAllocate.put("ref_ser","D-ALOC");
strDeAllocate.put("site_code",siteCodeShip);
strDeAllocate.put("item_code",itemCode);
strDeAllocate.put("loc_code",locCode);
strDeAllocate.put("lot_no",lotNo);
strDeAllocate.put("lot_sl",lotSl);
strDeAllocate.put("alloc_qty",new Double(-1 * qtyToBeDeAllocated));
System.out.print("DeallocQty = [" + (-1 * qtyToBeDeAllocated)+"]");
strDeAllocate.put("chg_user",new ibase.utility.E12GenericUtility().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strDeAllocate.put("chg_term",new ibase.utility.E12GenericUtility().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strDeAllocate.put("chg_win","W_SORD_DEALLOC");
if (qtyToBeDeAllocated > 0 && saleOrder.trim().length()>0)
{
strDeAllocate.put("ref_id",saleOrder);
strDeAllocate.put("ref_line",lineNo);
errString = invAllocTrace.updateInvallocTrace(strDeAllocate,conn);
if (errString != null && errString.trim().length() > 0)
{
strDeAllocate.put("ref_id",saleOrder);
strDeAllocate.put("ref_line",lineNo);
errString = invAllocTrace.updateInvallocTrace(strDeAllocate,conn);
System.out.println("errString :::"+ errString );
return errString;
}
System.out.println("expLev["+expLev+"]"+"saleOrder["+saleOrder+"]");
updateSorditem ="UPDATE SORDITEM SET QTY_ALLOC = QTY_ALLOC - " + new Double(qtyToBeDeAllocated).toString()
+" WHERE SALE_ORDER = '" + saleOrder + "' "
+" AND LINE_NO = '" + lineNoSord + "' "
+" AND EXP_LEV = '" + expLev + "' ";
if (errString != null && errString.trim().length() > 0)
{
System.out.println("errString :::"+ errString );
return errString;
}
System.out.println("expLev["+expLev+"]"+"saleOrder["+saleOrder+"]");
updateSorditem ="UPDATE SORDITEM SET QTY_ALLOC = QTY_ALLOC - " + new Double(qtyToBeDeAllocated).toString()
+" WHERE SALE_ORDER = '" + saleOrder + "' "
+" AND LINE_NO = '" + lineNoSord + "' "
+" AND EXP_LEV = '" + expLev + "' ";
System.out.println("updateSql------->"+updateSorditem);
st = conn.prepareStatement(updateSorditem);
st.executeUpdate(updateSorditem);
System.out.println("updateSql------->"+updateSorditem);
st = conn.prepareStatement(updateSorditem);
// Changed by Manish on 28/09/15 [start]
// The method executeUpdate() cannot take arguments on a PreparedStatement
//st.executeUpdate(updateSorditem);
st.executeUpdate();
// Changed by Manish on 28/09/15 [End]
System.out.println("UPDATE SUCCESS FOR SORDITEM....>>>>>>>>");
st.close();
st = null;
updateSql = " UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - " + new Double(qtyToBeDeAllocated).toString()
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNoSord + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
System.out.println("updateSql:::>>>>"+ updateSql);
st = conn.prepareStatement(updateSql);
// Changed by Manish on 28/09/15 [start]
// The method executeUpdate() cannot take arguments on a PreparedStatement
//updCount=st.executeUpdate(updateSql);
updCount=st.executeUpdate();
// Changed by Manish on 28/09/15 [End]
if ( updCount > 0 )
{
System.out.println("UPDATE SUCCESS FOR SORDITEM....>>>>>>>>");
st.close();
st = null;
updateSql = " UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC - " + new Double(qtyToBeDeAllocated).toString()
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNoSord + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
System.out.println("updateSql:::>>>>"+ updateSql);
st = conn.prepareStatement(updateSql);
updCount=st.executeUpdate(updateSql);
if ( updCount > 0 )
}
st.close();
st = null;
System.out.println("UPDATE SUCCESS FOR SORDALLOC....");
SqlQtyAlloc = "SELECT QTY_ALLOC FROM SORDALLOC "
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNoSord + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
System.out.println("SqlQtyAlloc:::>>>>"+ SqlQtyAlloc);
st = conn.prepareStatement(SqlQtyAlloc);
// Changed by Manish on 28/09/15
// The method executeUpdate() cannot take arguments on a PreparedStatement
//rsQtyAlloc = st.executeQuery(SqlQtyAlloc);
rsQtyAlloc = st.executeQuery();
// Changed by Manish on 28/09/15
if (rsQtyAlloc.next())
{
System.out.println("Updated Allocated Qty :::"+rsQtyAlloc.getDouble(1));
if(rsQtyAlloc.getDouble(1)<=0)
{
System.out.println("UPDATE SUCCESS FOR SORDITEM....>>>>>>>>");
}
st.close();
st = null;
System.out.println("UPDATE SUCCESS FOR SORDALLOC....");
SqlQtyAlloc = "SELECT QTY_ALLOC FROM SORDALLOC "
DelQtyAlloc = "DELETE FROM SORDALLOC"
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNoSord + "' "
+ " AND EXP_LEV = '" + expLev + "' "
......@@ -335,36 +372,28 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
System.out.println("SqlQtyAlloc:::>>>>"+ SqlQtyAlloc);
st = conn.prepareStatement(SqlQtyAlloc);
rsQtyAlloc = st.executeQuery(SqlQtyAlloc);
if (rsQtyAlloc.next())
{
System.out.println("Updated Allocated Qty :::"+rsQtyAlloc.getDouble(1));
if(rsQtyAlloc.getDouble(1)<=0)
{
DelQtyAlloc = "DELETE FROM SORDALLOC"
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNoSord + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
System.out.println("DelQtyAlloc:::"+DelQtyAlloc);
st1 = conn.prepareStatement(DelQtyAlloc);
st1.executeUpdate(DelQtyAlloc);
System.out.println("Delete completed ");
st1.close();
st1 = null;
}
System.out.println("DelQtyAlloc:::"+DelQtyAlloc);
st1 = conn.prepareStatement(DelQtyAlloc);
// Changed by Manish on 28/09/15
// The method executeUpdate() cannot take arguments on a PreparedStatement
//st1.executeUpdate(DelQtyAlloc);
st1.executeUpdate();
// Changed by Manish on 28/09/15
System.out.println("Delete completed ");
st1.close();
st1 = null;
}
rsQtyAlloc.close();
rsQtyAlloc = null;
st.close();
st = null;
}
/*//For saleOrder is null and you have cust_code
rsQtyAlloc.close();
rsQtyAlloc = null;
st.close();
st = null;
}
/*//For saleOrder is null and you have cust_code
else if(qtyToBeDeAllocated > 0 && tranId.trim().length()>0)
{
strDeAllocate.put("ref_id",tranId);
......@@ -387,7 +416,7 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
st.close();
st = null;
}*/
}//end of while
rs.close(); rs = null;
pSordAllocDet.clearParameters();
......@@ -405,7 +434,7 @@ public class StockDeAllocConf extends ActionHandlerEJB implements StockDeAllocCo
pstmt.setString(3,tranId);
updCount = pstmt.executeUpdate();
pstmt.close(); pstmt = null;
if( updCount > 0 )
{
errString = itmDBAccessEJB.getErrorString("","CONFSUCCES","");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment