Commit 1206d362 authored by dsawant's avatar dsawant

updated for hold qty validation


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96286 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cac71ebf
......@@ -23,7 +23,9 @@ import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.StringTokenizer;
import javax.ejb.Stateless;
......@@ -119,7 +121,7 @@ public class DistIssWiz extends ValidatorEJB implements DistIssWizLocal, DistIss
String sql = "",locCode ="",invstat="",aval="",avalyn="";
double qtyConf=0,qtyShip=0,totQty=0,detquantity=0,stkquantity=0,quantity=0,totquantity=0,dodetquantity=0,allQty=0;
String squantity="",distOrder = "",itemCode="",confirmed="",tranId="",siteCode="",lotSl="",addUser="",tranCode="",siteCodeDlv="";
String squantity="",distOrder = "",itemCode="",confirmed="",tranId="",siteCode="",lotSl="",addUser="",tranCode="",siteCodeDlv="",lotno="";
try {
System.out.println("editFlag>>>>wf"+editFlag);
......@@ -459,6 +461,20 @@ public class DistIssWiz extends ValidatorEJB implements DistIssWizLocal, DistIss
siteCode = genericUtility.getColumnValue("site_code",dom2);
itemCode = genericUtility.getColumnValue("item_code",dom2);
lotSl = genericUtility.getColumnValue("lot_sl",dom2);
locCode = genericUtility.getColumnValue("loc_code",dom2);
lotno = genericUtility.getColumnValue("lot_no",dom2);
tranId = genericUtility.getColumnValue("tran_id",dom2);
HashMap<String,String>invHoldMap=new HashMap<String,String>();
invHoldMap.put("item_code", itemCode);
invHoldMap.put("site_code", siteCode);
invHoldMap.put("loc_code", locCode);
invHoldMap.put("lot_no", lotno);
invHoldMap.put("lot_sl", lotSl);
avalyn=getColumnDescr(conn, "available_yn", "distord_iss", "tran_id", tranId);
avalyn=avalyn==null ? "N" : avalyn.trim();
System.out.println("squantity"+squantity+"workOrder<><><>"+distOrder+">>D"+siteCode+"FDFf"+lotSl);
if (squantity == null || squantity.trim().length() == 0)
{
......@@ -469,6 +485,20 @@ public class DistIssWiz extends ValidatorEJB implements DistIssWizLocal, DistIss
quantity = Double.parseDouble(squantity);
}
System.out.println("quantity>>>>>>{{{"+quantity);
cnt=getInvHoldCount(invHoldMap, conn);
if("N".equalsIgnoreCase(avalyn)){
if(cnt == 0){
//Error
errCode = "DIDOLKCINC";//Despatch can not be created as qunaity is on hold.
errString = getErrorString("quantity",errCode,userId);
break;
}
}
/*sql = "select quantity from stock where site_code = ? AND LOT_SL = ? AND QUANTITY > 0";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
......@@ -599,19 +629,6 @@ public class DistIssWiz extends ValidatorEJB implements DistIssWizLocal, DistIss
pstmt = null;
rs = null;
/* sql = "select AVAILABLE_YN from distord_iss where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
avalyn = rs.getString("AVAILABLE_YN")==null?"":rs.getString("AVAILABLE_YN").trim();
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;*/
if(aval.equalsIgnoreCase("N"))
{
......@@ -703,7 +720,7 @@ public class DistIssWiz extends ValidatorEJB implements DistIssWizLocal, DistIss
String rate = "";
double amount = 0;
int cnt = 0;
String addUser="";
String addUser="",avalyn="";
String tranCode = "",tranName="",transMode="";
StringBuffer detail2xml = new StringBuffer();
String tranDate = null;
......@@ -2135,7 +2152,28 @@ public class DistIssWiz extends ValidatorEJB implements DistIssWizLocal, DistIss
valueXmlString.append("<item_code protect=\"0\">").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
setNodeValue( dom, "item_code", getAbsString(""+itemCode));
sql = "select AVAILABLE_YN from distord_iss where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranid);
rs = pstmt.executeQuery();
if(rs.next())
{
avalyn = rs.getString("AVAILABLE_YN")==null?"":rs.getString("AVAILABLE_YN").trim();
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if("Y".equalsIgnoreCase(avalyn))
{
setQty = squantity - (allQty + holdQty);
}
else
{
setQty = squantity - allQty;
}
valueXmlString.append("<quantity protect=\"0\">").append("<![CDATA[" + setQty + "]]>").append("</quantity>");
setNodeValue( dom, "quantity", getAbsString(""+setQty));
......@@ -2292,6 +2330,110 @@ public class DistIssWiz extends ValidatorEJB implements DistIssWizLocal, DistIss
return valueXmlString.toString();
}
private int getInvHoldCount(Map<String,String> invHoldMap,Connection conn)
{
System.out.println("----in getInvHoldQuantity method------");
ResultSet rs=null;
PreparedStatement pstmt=null;
String sql="",holdQty="",countS="",qcLockValue="";
int count=0;
try{
qcLockValue=getColumnDescr(conn, "var_value", "disparm", "var_name", "QUARNTINE_LOCKCODE");
qcLockValue = qcLockValue == null ? "": qcLockValue.trim();
System.out.println("qcLockValue------->>["+qcLockValue+"]");
sql="select count(*) from inv_hold h,inv_hold_det d where h.tran_id = d.tran_id "
+"and d.item_code = ? and d.site_code = ? "
+"and d.loc_code = ? and d.lot_no= ? AND h.CONFIRMED= ? "
+"and d.lot_sl= ? and h.lock_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invHoldMap.get("item_code"));
pstmt.setString(2, invHoldMap.get("site_code"));
pstmt.setString(3, invHoldMap.get("loc_code"));
pstmt.setString(4, invHoldMap.get("lot_no"));
pstmt.setString(5, "Y");
pstmt.setString(6, invHoldMap.get("lot_sl"));
pstmt.setString(7, qcLockValue);
rs=pstmt.executeQuery();
if(rs.next()){
count=rs.getInt(1);
}
if(rs!=null){
rs.close();
rs=null;
}
if(pstmt!=null){
pstmt.close();
pstmt=null;
}
/*sql="select hold_qty FROM stock where "
+ "item_code = ? and site_code = ? and loc_code = ? and lot_no = ? and lot_sl= ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1, invHoldMap.get("item_code"));
pstmt.setString(2, invHoldMap.get("site_code"));
pstmt.setString(3, invHoldMap.get("loc_code"));
pstmt.setString(4, invHoldMap.get("lot_no"));
pstmt.setString(5, invHoldMap.get("lot_sl"));
rs=pstmt.executeQuery();
if(rs.next()){
holdQty=rs.getString("hold_qty");
}
if(rs!=null){
rs.close();
rs=null;
}
if(pstmt!=null){
pstmt.close();
pstmt=null;
}*/
}
catch(Exception e){
e.printStackTrace();
}
holdQty=holdQty==null ? "0" : holdQty.trim();
countS=Integer.toString(count);
System.out.println("count---->>["+count+"]");
return count;
}
private String getColumnDescr(Connection conn, String columnName ,String tableName, String columnName2, String value)
{
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "";
String findValue = "";
try
{
sql = "SELECT " + columnName + " from " + tableName + " where " + columnName2 +"= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,value);
rs = pstmt.executeQuery();
if(rs.next())
{
findValue = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
catch(Exception e)
{
System.out.println("Exception in getColumnDescr ");
e.printStackTrace();
}
System.out.println("returning String from getColumnDescr " + findValue);
return findValue;
}
private static String getAbsString( String str )
{
......
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