Commit 324cdd72 authored by kmandhre's avatar kmandhre

solve the issue of duplicate entry in INV_HOLD_REL_TRACE table


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95088 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8f4d02b2
...@@ -1039,13 +1039,13 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer ...@@ -1039,13 +1039,13 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer
{ {
PreparedStatement pstmtInsertInvHold =null; PreparedStatement pstmtInsertInvHold =null;
PreparedStatement pstmtMaxLine =null; PreparedStatement pstmtMaxLine =null;
ResultSet rsMaxLine =null; ResultSet rsMaxLine =null ,rs = null;
//Changed by Rohan on 17-07-13 for updating INV_HOLD_REL_TRACE prepared statement and result set.start //Changed by Rohan on 17-07-13 for updating INV_HOLD_REL_TRACE prepared statement and result set.start
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
String sql = ""; String sql = "";
String tranId = ""; String tranId = "";
//Changed by Rohan on 17-07-13 for updating INV_HOLD_REL_TRACE prepared statement and result set.end //Changed by Rohan on 17-07-13 for updating INV_HOLD_REL_TRACE prepared statement and result set.end
int maxLineNo=0; int maxLineNo=0,count = 0,count1 = 0;
try { try {
...@@ -1068,6 +1068,70 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer ...@@ -1068,6 +1068,70 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer
Date sysDate = new Date(); Date sysDate = new Date();
String sysDateStr = sdf.format(sysDate); String sysDateStr = sdf.format(sysDate);
sql ="select count(*) from inv_hold_det where tran_id = ? and item_code = ? and site_code = ? "
+" and loc_code = ? and lot_no = ? and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdHold);
pstmt.setString(2, itemCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, locCode);
pstmt.setString(5, lotNo);
pstmt.setString(6, lotSl);
rs =pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
if(count > 0)//aaded by kunal on 22/may/14
{
sql ="select count(*) from INV_HOLD_REL_TRACE where REF_NO = ? and ITEM_CODE = ? and SITE_CODE = ? "
+" and LOC_CODE = ? and LOT_NO = ? and LOT_SL = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIdHold);
pstmt.setString(2, itemCode);
pstmt.setString(3, siteCode);
pstmt.setString(4, locCode);
pstmt.setString(5, lotNo);
pstmt.setString(6, lotSl);
rs =pstmt.executeQuery();
if(rs.next())
{
count1 = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
System.out.println("count1="+count1);
if(count1 > 0)
{
sql = " update inv_hold_rel_trace set hold_qty = hold_qty + ? where ref_no = ? and item_code = ? "
+" and site_code = ? and loc_code = ? and lot_no = ? and lot_sl = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setDouble( 1,holdQuantity );
pstmt.setString( 2, tranIdHold);
pstmt.setString( 3, itemCode );
pstmt.setString( 4, siteCode );
pstmt.setString( 5, locCode );
pstmt.setString( 6, lotNo);
pstmt.setString( 7, lotSl );
System.out.println("record updated::"+pstmt.executeUpdate());
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
}
else
{
String sqlInsertInvHold = "INSERT INTO INV_HOLD_DET (TRAN_ID, LINE_NO, ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, HOLD_STATUS, STATUS_DATE , SCH_REL_DATE ) " + String sqlInsertInvHold = "INSERT INTO INV_HOLD_DET (TRAN_ID, LINE_NO, ITEM_CODE, SITE_CODE, LOC_CODE, LOT_NO, LOT_SL, HOLD_STATUS, STATUS_DATE , SCH_REL_DATE ) " +
" VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"; " VALUES ( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
...@@ -1122,6 +1186,7 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer ...@@ -1122,6 +1186,7 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer
pstmt.executeUpdate(); pstmt.executeUpdate();
//Changed by Rohan on 17-07-13 for updating INV_HOLD_REL_TRACE.end //Changed by Rohan on 17-07-13 for updating INV_HOLD_REL_TRACE.end
}
} }
catch (Exception e) catch (Exception e)
......
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