Commit 8de43cc0 authored by vvengurlekar's avatar vvengurlekar

StockUpdate.java - Locking for stock_movement as per suggested by SManoharan sir


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194592 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6cd2b7b6
...@@ -2620,7 +2620,7 @@ public class StockUpdate ...@@ -2620,7 +2620,7 @@ public class StockUpdate
ResultSet rs = null; ResultSet rs = null;
int count = 0; int count = 0;
String prdCode = "",errCode = "", sql = ""; String prdCode = "",errCode = "", sql = "";
String tranDateStr=""; String tranDateStr="", dbName = "";
Timestamp tranDateTm=null; Timestamp tranDateTm=null;
double qty = 0,amount = 0; double qty = 0,amount = 0;
double poRcpQty = 0,disRcpQty = 0,woIssQty = 0,disIssQty = 0,salIssQty = 0; double poRcpQty = 0,disRcpQty = 0,woIssQty = 0,disIssQty = 0,salIssQty = 0;
...@@ -2630,6 +2630,10 @@ public class StockUpdate ...@@ -2630,6 +2630,10 @@ public class StockUpdate
double totRcpQty = 0,totIssQty = 0,openQty = 0,closeQty = 0; double totRcpQty = 0,totIssQty = 0,openQty = 0,closeQty = 0;
double totRcpValue = 0,totIssValue = 0,openValue = 0,closeValue = 0; double totRcpValue = 0,totIssValue = 0,openValue = 0,closeValue = 0;
try{ try{
//Modified by Varsha V. on [18/12/2018][To take database name][Start]
dbName = (CommonConstants.DB_NAME).trim();
System.out.println("dbName in updateStockMovement--["+dbName+"]");
//Modified by Varsha V. on [18/12/2018][To take database name][End]
qty = this.qtyStduom; qty = this.qtyStduom;
amount = qty * this.rate; amount = qty * this.rate;
if(this.tranSer.equalsIgnoreCase("P-RCP")){ if(this.tranSer.equalsIgnoreCase("P-RCP")){
...@@ -2733,10 +2737,16 @@ public class StockUpdate ...@@ -2733,10 +2737,16 @@ public class StockUpdate
errString = itmDBAccessEJB.getErrorString("","VTPRD1","","",conn); errString = itmDBAccessEJB.getErrorString("","VTPRD1","","",conn);
return errString; return errString;
} }
count = 0;
//End added by chandrashekar on 27-may-2016 //End added by chandrashekar on 27-may-2016
sql = "select count(*) from stock_movement " + /*Commented and added one more where clause by Varsha V on 18-12-18
sql = "select count(*) from stock_movement " +
"where site_code = '"+this.siteCode+"' and period_code = '"+prdCode+"' " + "where site_code = '"+this.siteCode+"' and period_code = '"+prdCode+"' " +
"and item_code = '"+this.itemCode+"' and lot_no = '"+this.lotNo+"'"; "and item_code = '"+this.itemCode+"' and lot_no = '"+this.lotNo+"'";
*/
sql = "select count(*) as cnt from stock_movement " +
"where site_code = '"+this.siteCode+"' and period_code = '"+prdCode+"' " +
"and item_code = '"+this.itemCode+"' and lot_no = '"+this.lotNo+"' and inv_stat = '"+this.invStat+"' ";
System.out.println("SQL :"+sql); System.out.println("SQL :"+sql);
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -2745,6 +2755,7 @@ public class StockUpdate ...@@ -2745,6 +2755,7 @@ public class StockUpdate
} }
rs.close(); rs.close();
pstmt.close(); pstmt.close();
System.out.println("COunt in stock_movement: "+count);
if(count == 0){ if(count == 0){
//Start added by chandrashekar on 27-may-2016 //Start added by chandrashekar on 27-may-2016
...@@ -2759,6 +2770,7 @@ public class StockUpdate ...@@ -2759,6 +2770,7 @@ public class StockUpdate
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,prdCode); pstmt.setString(1,prdCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
System.out.println("SQL :"+sql);
if(rs.next()){ if(rs.next()){
openQty = rs.getDouble(1); openQty = rs.getDouble(1);
openValue = rs.getDouble(2); openValue = rs.getDouble(2);
...@@ -2822,13 +2834,70 @@ public class StockUpdate ...@@ -2822,13 +2834,70 @@ public class StockUpdate
pstmt.executeUpdate(); pstmt.executeUpdate();
}else{ }
else{
//Start added by chandrashekar on 27-may-2016 //Start added by chandrashekar on 27-may-2016
if(!"R".equalsIgnoreCase(this.tranType)) if(!"R".equalsIgnoreCase(this.tranType))
{ {
closeQty = qty * (-1); closeQty = qty * (-1);
closeValue = amount * (-1); closeValue = amount * (-1);
} }
//Added by Varsha V on 14-12-18 for locking changes suggested by SManoharan
if (("db2".equalsIgnoreCase(dbName)) || ("mysql".equalsIgnoreCase(dbName)))
{
sql = "select site_code, period_code, item_code, lot_no, inv_stat from stock_movement " +
"where site_code = ? and period_code = ? " +
"and item_code = ? and lot_no = ? and inv_stat = ? for update";
}
else if("mssql".equalsIgnoreCase(dbName))
{
sql = "select site_code, period_code, item_code, lot_no, inv_stat from stock_movement " +
"where site_code = ? and period_code = ? " +
"and item_code = ? and lot_no = ? and inv_stat = ? ";
}
else
{
sql = "select site_code, period_code, item_code, lot_no, inv_stat from stock_movement " +
"where site_code = ? and period_code = ? " +
"and item_code = ? and lot_no = ? and inv_stat = ? for update nowait";
}
String siteCode = "", periodCode = "", itemCode = "", lotNo = "", invStat = "";
System.out.println("this.siteCode: "+this.siteCode + " prdCode: "+prdCode+" this.itemCode: "+this.itemCode+
" this.lotNo: "+this.lotNo+" this.invStat: "+this.invStat);
count = 0;
System.out.println("SQL :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,this.siteCode);
pstmt.setString(2,prdCode);
pstmt.setString(3,this.itemCode);
pstmt.setString(4,this.lotNo);
pstmt.setString(5,this.invStat);
rs = pstmt.executeQuery();
if(rs.next())
{
count++;
siteCode = rs.getString("site_code");
periodCode = rs.getString("period_code");
itemCode = rs.getString("item_code");
lotNo = rs.getString("lot_no");
invStat = rs.getString("inv_stat");
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTLCKERR","","",conn);
return errString;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
//Ended by Varsha V on 14-12-18 for locking changes suggested by SManoharan
//End added by chandrashekar on 27-may-2016 //End added by chandrashekar on 27-may-2016
sql = "update stock_movement set " + sql = "update stock_movement set " +
//" open_qty = ?, " + //" open_qty = ?, " +
......
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