Commit 07fb673a authored by rbhogale's avatar rbhogale

Changed by Rohan on 18-04-13 for add validation of expired stock


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92966 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 8fc8a04c
......@@ -12,7 +12,6 @@ import java.rmi.RemoteException;
import java.sql.*;
import java.text.*;
import java.util.*;
import java.util.Date;
import javax.ejb.*;
import javax.naming.InitialContext;
......@@ -124,6 +123,15 @@ public class StockTransferIC extends ValidatorEJB implements StockTransferICRemo
String casePickInvstat = "";
String invStat = "";
/*Added By Dipak On 4 June 2012 End*/
//Changed by Rohan on 18-03-13 for define variable.start
int locCount = 0;
String locInvList = "";
String[] locList = null;
String invStatLoc = "";
boolean isLocToValid = true;
//Changed by Rohan on 18-03-13 for define variable.end
int noOfChilds = 0;
int noOfParent = 0;
int count = 0;
......@@ -422,172 +430,232 @@ public class StockTransferIC extends ValidatorEJB implements StockTransferICRemo
locCodeTo = checkNull(genericUtility.getColumnValue("loc_code__to", allDom, "3" ));
lotNo = genericUtility.getColumnValue("lot_no__fr", allDom, "3" );
lpnNo = genericUtility.getColumnValue("lot_sl__fr", allDom, "3" );
sql = "SELECT SINGLE_LOT_SL, ITEM_LOT_OPT, INV_STAT FROM LOCATION WHERE LOC_CODE = ?";//Changes are done by Dipak On 4 June 2012
//Changed by Rohan on 16-04-13 For Stock Transfer ,Expired stock can not be transfer from location configured in Disparm.start
locCode = genericUtility.getColumnValue("loc_code", allDom, "2" );
sql ="SELECT COUNT(*) AS LOCCOUNT FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? " +
" AND LOT_NO = ? AND LOT_SL = ? AND EXP_DATE <= fn_sysdate()";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, locCodeTo );
pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCode );
pstmt.setString( 4, lotNo );
pstmt.setString( 5, lpnNo );
rs = pstmt.executeQuery();
if( rs.next() )
{
singleLotSl = checkNull(rs.getString("SINGLE_LOT_SL"));
itemLotOpt = checkNull(rs.getString("ITEM_LOT_OPT"));
invStat = checkNull(rs.getString("INV_STAT"));//Added By Dipak On 4 June 2012
locCount = rs.getInt("LOCCOUNT");
}
else
{
// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
//errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
//break;
errList.add( "VMLOC6" );
errFields.add( childNodeName.toLowerCase() );
// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
//Changed by Rohan on 21/07/12 to move stock to any location.start
/*Added By Dipak On 4 June 2012 Start*/
/*
if(!(invStatList.contains(invStat.trim())))
pstmt.close();
rs.close();
pstmt = null;
rs =null;
if(locCount > 0)
{
errList.add( "VTLOCCODE8" );
errFields.add( childNodeName.toLowerCase() );
locInvList = distCommon.getDisparams("999999","NOT_TRANF_INV_STAT",conn);
System.out.println("locInvList>>>>>>"+locInvList);
if((!"".equalsIgnoreCase(locInvList.trim()) || locInvList != null) && locInvList.trim().length() > 0 )
{
locList = locInvList.split(",");
sql = "SELECT INV_STAT FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, locCodeTo );
rs = pstmt.executeQuery();
if( rs.next() )
{
invStatLoc = rs.getString("INV_STAT");
}
for(int i =0; i < locList.length ; i++)
{
System.out.println("Comparing values"+invStatLoc+"locList[i]"+locList[i]);
if(invStatLoc.trim().equalsIgnoreCase(locList[i].trim()))
{
errList.add( "VTLOCNTVAL" );
errFields.add( childNodeName.toLowerCase());
isLocToValid = false;
break;
}
}
}
}
*/
/*Added By Dipak On 4 June 2012 End*/
//Changed by Rohan on 21/07/12 to move stock to any location.end
if( singleLotSl.trim().equalsIgnoreCase("Y") )
System.out.println("isLocToValid["+isLocToValid+"]");
if(isLocToValid)
{
//Change by Rohan on 19/07/12 for bug Fixing
/*
sql = "SELECT QUANTITY FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ?"
+ " AND LOC_CODE = ? AND lOT_NO = ? AND LOT_SL = ?";
*/
sql = "SELECT QUANTITY FROM STOCK WHERE SITE_CODE = ?"
+ " AND LOC_CODE = ? ORDER BY QUANTITY DESC";
//Changed by Rohan on 16-04-13 For Stock Transfer ,Expired stock can not be transfer from location configured in Disparm.end
sql = "SELECT SINGLE_LOT_SL, ITEM_LOT_OPT, INV_STAT FROM LOCATION WHERE LOC_CODE = ?";//Changes are done by Dipak On 4 June 2012
pstmt = conn.prepareStatement( sql );
//Change by Rohan on 19/07/12 for bug Fixing.start
/*
pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
pstmt.setString( 4, lotNo );
pstmt.setString( 5, lpnNo );
*/
pstmt.setString( 1, siteCode );
pstmt.setString( 2, locCodeTo );
//Change by Rohan on 19/07/12 for bug Fixing.end
rs = pstmt.executeQuery();
if( rs.next() )
pstmt.setString( 1, locCodeTo );
rs = pstmt.executeQuery();
if( rs.next() )
{
quantity = rs.getDouble("QUANTITY");
singleLotSl = checkNull(rs.getString("SINGLE_LOT_SL"));
itemLotOpt = checkNull(rs.getString("ITEM_LOT_OPT"));
invStat = checkNull(rs.getString("INV_STAT"));//Added By Dipak On 4 June 2012
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
if( quantity != 0 )
else
{
// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
//errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
//break;
errList.add( "LOCNOTEMPT" );
errList.add( "VMLOC6" );
errFields.add( childNodeName.toLowerCase() );
// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
}
}
else
{
if( itemLotOpt.trim().equals("0") ) // Validation for single item_code and single lot_no
rs.close(); rs = null;
pstmt.close(); pstmt = null;
//Changed by Rohan on 21/07/12 to move stock to any location.start
/*Added By Dipak On 4 June 2012 Start*/
/*
if(!(invStatList.contains(invStat.trim())))
{
//changed by sankara on 13/09/2012 to add quantity
//sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE (ITEM_CODE <> ? OR LOT_NO <> ?) AND SITE_CODE = ? AND LOC_CODE = ? AND QUANTITY > 0";
errList.add( "VTLOCCODE8" );
errFields.add( childNodeName.toLowerCase() );
}
*/
/*Added By Dipak On 4 June 2012 End*/
//Changed by Rohan on 21/07/12 to move stock to any location.end
if( singleLotSl.trim().equalsIgnoreCase("Y") )
{
//Change by Rohan on 19/07/12 for bug Fixing
/*
sql = "SELECT QUANTITY FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ?"
+ " AND LOC_CODE = ? AND lOT_NO = ? AND LOT_SL = ?";
*/
sql = "SELECT QUANTITY FROM STOCK WHERE SITE_CODE = ?"
+ " AND LOC_CODE = ? ORDER BY QUANTITY DESC";
pstmt = conn.prepareStatement( sql );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[start]
/* pstmt.setString( 1, itemCode );
//Change by Rohan on 19/07/12 for bug Fixing.start
/*
pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
pstmt.setString( 4, lotNo ); */
pstmt.setString( 1, itemCode );
pstmt.setString( 2, lotNo );
pstmt.setString( 3, siteCode );
pstmt.setString( 4, locCodeTo );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[End]
rs = pstmt.executeQuery();
pstmt.setString( 4, lotNo );
pstmt.setString( 5, lpnNo );
*/
pstmt.setString( 1, siteCode );
pstmt.setString( 2, locCodeTo );
//Change by Rohan on 19/07/12 for bug Fixing.end
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
quantity = rs.getDouble("QUANTITY");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
if( count > 0 )
if( quantity != 0 )
{
// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
//errString = getErrorString("loc_code__to", "INVLOCCODE", userId );
//errString = getErrorString( "loc_code__to", "INVLOCCODE", userId );
//break;
errList.add( "VTLOCCODE2" );
errList.add( "LOCNOTEMPT" );
errFields.add( childNodeName.toLowerCase() );
// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
}
}
}
else if( itemLotOpt.trim().equals("1") ) //Validation for single item_code and multiple lot_no
else
{
/*--Commented by gulzar as it is not valid for single item and single lot
sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
pstmt.setString( 4, lotNo );
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( count > 0 )
{
errString = getErrorString("loc_code__to", "VTLOCCODE3", userId );
break;
}
*/
//changed by sankara on 13/09/2012 to add quantity
//sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND QUANTITY > 0";
pstmt = conn.prepareStatement( sql );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[start]
/* pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
pstmt.setString( 4, lotNo ); */
pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[End]
rs = pstmt.executeQuery();
if( rs.next() )
if( itemLotOpt.trim().equals("0") ) // Validation for single item_code and single lot_no
{
count = rs.getInt("COUNT");
//changed by sankara on 13/09/2012 to add quantity
//sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE (ITEM_CODE <> ? OR LOT_NO <> ?) AND SITE_CODE = ? AND LOC_CODE = ? AND QUANTITY > 0";
pstmt = conn.prepareStatement( sql );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[start]
/* pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
pstmt.setString( 4, lotNo ); */
pstmt.setString( 1, itemCode );
pstmt.setString( 2, lotNo );
pstmt.setString( 3, siteCode );
pstmt.setString( 4, locCodeTo );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[End]
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
}
rs.close(); rs = null;
pstmt.close(); pstmt = null;
if( count > 0 )
{
// 26/10/11 manoharan all the errors should be returned so that warnings can be processed
//errString = getErrorString("loc_code__to", "INVLOCCODE", userId );
//break;
errList.add( "VTLOCCODE2" );
errFields.add( childNodeName.toLowerCase() );
// end 26/10/11 manoharan all the errors should be returned so that warnings can be processed
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( count > 0 )
else if( itemLotOpt.trim().equals("1") ) //Validation for single item_code and multiple lot_no
{
errList.add( "VTLOCCODE4" );
errFields.add( childNodeName.toLowerCase() );
}
}//end of itemLotOpt == "1"
}//else of singleLotSl =="Y"
/*--Commented by gulzar as it is not valid for single item and single lot
sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE = ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
pstmt.setString( 4, lotNo );
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( count > 0 )
{
errString = getErrorString("loc_code__to", "VTLOCCODE3", userId );
break;
}
*/
//changed by sankara on 13/09/2012 to add quantity
//sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND LOT_NO <> ?";
sql = "SELECT COUNT(*) AS COUNT FROM STOCK WHERE ITEM_CODE <> ? AND SITE_CODE = ? AND LOC_CODE = ? AND QUANTITY > 0";
pstmt = conn.prepareStatement( sql );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[start]
/* pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
pstmt.setString( 4, lotNo ); */
pstmt.setString( 1, itemCode );
pstmt.setString( 2, siteCode );
pstmt.setString( 3, locCodeTo );
//changed by sankara on 13/09/2012 to set the strings in a row based on sql[End]
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( count > 0 )
{
errList.add( "VTLOCCODE4" );
errFields.add( childNodeName.toLowerCase() );
}
}//end of itemLotOpt == "1"
}//else of singleLotSl =="Y"
//Changed by Rohan on 16-04-13 For Stock Transfer ,Expired stock can not be transfer from location configured in Disparm
}
}//End of case "loc_code__to"
else if( "lot_sl__to".equalsIgnoreCase( childNodeName ) )//Case added by gulzar on 21/12/11
{
......
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