Commit 98725490 authored by mnair's avatar mnair

Added actionStock method

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@182537 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cdcc5468
...@@ -40,7 +40,12 @@ public class StockTransferAct extends ActionHandlerEJB implements ...@@ -40,7 +40,12 @@ public class StockTransferAct extends ActionHandlerEJB implements
retString = actionAllItems(dom, dom1, xtraParams, actionType); retString = actionAllItems(dom, dom1, xtraParams, actionType);
} }
if (actionType.equalsIgnoreCase("Stock"))
{
retString = actionStock(dom, dom1, xtraParams);
}
} catch (Exception e) { } catch (Exception e) {
System.out System.out
.println("Exception :StockTransferAct :actionHandler(String xmlString):" .println("Exception :StockTransferAct :actionHandler(String xmlString):"
...@@ -65,7 +70,7 @@ public class StockTransferAct extends ActionHandlerEJB implements ...@@ -65,7 +70,7 @@ public class StockTransferAct extends ActionHandlerEJB implements
PreparedStatement pstmt1 = null; PreparedStatement pstmt1 = null;
ArrayList lineNo = new ArrayList(); ArrayList lineNo = new ArrayList();
HashMap<String, Double> hm = new HashMap<String, Double>(); HashMap<String, Double> hm = new HashMap<String, Double>();
String lineNoStr = "", locCode = "", locCode1 = "", lotNum = "", siteCodeReq = "", lotSerial = "", sql = ""; String lineNoStr = "", locCode = "", lotNum = "", siteCodeReq = "", lotSerial = "", sql = "";
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n"); StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String detailCnt = ""; String detailCnt = "";
String itemCode = ""; String itemCode = "";
...@@ -187,7 +192,7 @@ public class StockTransferAct extends ActionHandlerEJB implements ...@@ -187,7 +192,7 @@ public class StockTransferAct extends ActionHandlerEJB implements
System.out.println("remainingQty :" + remainingQty); System.out.println("remainingQty :" + remainingQty);
System.out.println("NO ART :" + noArt); System.out.println("NO ART :" + noArt);
if (!hm.containsKey(itemCode + "~" + siteCodeReq + "~"+ locCode1 + "~" + lotNum + "~" + lotSerial)) if (!hm.containsKey(itemCode + "~" + siteCodeReq + "~"+ locCode + "~" + lotNum + "~" + lotSerial))
{ {
hm.put(itemCode + "~" + siteCodeReq + "~" + locCode+ "~" + lotNum + "~" + lotSerial, new Double(rs1.getDouble(10))); hm.put(itemCode + "~" + siteCodeReq + "~" + locCode+ "~" + lotNum + "~" + lotSerial, new Double(rs1.getDouble(10)));
} }
...@@ -227,34 +232,16 @@ public class StockTransferAct extends ActionHandlerEJB implements ...@@ -227,34 +232,16 @@ public class StockTransferAct extends ActionHandlerEJB implements
valueXmlString.append("<lot_no__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lotNum).append("]]>").append("</lot_no__to>\r\n"); valueXmlString.append("<lot_no__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lotNum).append("]]>").append("</lot_no__to>\r\n");
valueXmlString.append("<lot_sl__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lotSerial).append("]]>").append("</lot_sl__to>\r\n"); valueXmlString.append("<lot_sl__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lotSerial).append("]]>").append("</lot_sl__to>\r\n");
valueXmlString.append("<no_art isSrvCallOnChg=\"0\">").append("<![CDATA[").append(noArt).append("]]>").append("</no_art>\r\n"); valueXmlString.append("<no_art isSrvCallOnChg=\"0\">").append("<![CDATA[").append(noArt).append("]]>").append("</no_art>\r\n");
// valueXmlString.append("<acct_code__cr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((acctCodeInv // valueXmlString.append("<acct_code__cr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((acctCodeInv== null) ?"":acctCodeInv).append("]]>").append("</acct_code__cr>\r\n");
// == null) ? // valueXmlString.append("<cctr_code__cr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((cctrCodeInv== null) ?"":cctrCodeInv).append("]]>").append("</cctr_code__cr>\r\n");
// "":acctCodeInv).append("]]>").append("</acct_code__cr>\r\n"); // valueXmlString.append("<acct_code__dr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((acctCodeDr== null) ?"":acctCodeDr).append("]]>").append("</acct_code__dr>\r\n");
// valueXmlString.append("<cctr_code__cr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((cctrCodeInv // valueXmlString.append("<cctr_code__dr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((cctrCodeDr== null) ?"":cctrCodeDr).append("]]>").append("</cctr_code__dr>\r\n");
// == null) ?
// "":cctrCodeInv).append("]]>").append("</cctr_code__cr>\r\n");
// valueXmlString.append("<acct_code__dr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((acctCodeDr
// == null) ?
// "":acctCodeDr).append("]]>").append("</acct_code__dr>\r\n");
// valueXmlString.append("<cctr_code__dr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((cctrCodeDr
// == null) ?
// "":cctrCodeDr).append("]]>").append("</cctr_code__dr>\r\n");
// valueXmlString.append("<item_descr isSrvCallOnChg=\"0\">").append("<![CDATA[").append(itemDescr).append("]]>").append("</item_descr>\r\n"); // valueXmlString.append("<item_descr isSrvCallOnChg=\"0\">").append("<![CDATA[").append(itemDescr).append("]]>").append("</item_descr>\r\n");
// valueXmlString.append("<loc_code__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCode // valueXmlString.append("<loc_code__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCode== null) ?"":locCode).append("]]>").append("</loc_code__fr>\r\n");
// == null) ? // valueXmlString.append("<location_descr__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCodeDescr== null) ?"":locCodeDescr).append("]]>").append("</location_descr__fr>\r\n");
// "":locCode).append("]]>").append("</loc_code__fr>\r\n"); // valueXmlString.append("<loc_descr__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCodeDescr== null) ?"":locCodeDescr).append("]]>").append("</loc_descr__to>\r\n");
// valueXmlString.append("<location_descr__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCodeDescr // valueXmlString.append("<lot_no__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotNoTo== null) ?"":lotNoTo).append("]]>").append("</lot_no__fr>\r\n");
// == null) ? // valueXmlString.append("<lot_sl__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotSlTo== null) ?"":lotSlTo).append("]]>").append("</lot_sl__fr>\r\n");
// "":locCodeDescr).append("]]>").append("</location_descr__fr>\r\n");
// valueXmlString.append("<loc_descr__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCodeDescr
// == null) ?
// "":locCodeDescr).append("]]>").append("</loc_descr__to>\r\n");
// valueXmlString.append("<lot_no__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotNoTo
// == null) ?
// "":lotNoTo).append("]]>").append("</lot_no__fr>\r\n");
// valueXmlString.append("<lot_sl__fr isSrvCallOnChg=\"0\">").append("<![CDATA[").append((lotSlTo
// == null) ?
// "":lotSlTo).append("]]>").append("</lot_sl__fr>\r\n");
valueXmlString.append("</Detail>\r\n"); valueXmlString.append("</Detail>\r\n");
...@@ -277,28 +264,28 @@ public class StockTransferAct extends ActionHandlerEJB implements ...@@ -277,28 +264,28 @@ public class StockTransferAct extends ActionHandlerEJB implements
}//end of try block }//end of try block
catch (SQLException sqx) catch (SQLException sqx)
{ {
System.out.println("The sqlException occured in StockTransferAct :"+ sqx); System.out.println("The sqlException occured in StockTransferAct for Default button:"+ sqx);
throw new ITMException(sqx); throw new ITMException(sqx);
} }
catch (Exception e) catch (Exception e)
{ {
System.out.println("The Exception occured in StockTransferAct :"+ e); System.out.println("The Exception occured in StockTransferAct for Default button:"+ e);
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
if( rs != null ) //For resultSet rs if( rs != null )
rs.close(); rs.close();
rs = null; rs = null;
if( rs1 != null ) //For resultSet rs1 if( rs1 != null )
rs1.close(); rs1.close();
rs1=null; rs1=null;
if( pstmt != null ) //For PreparedStatement pstmt if( pstmt != null )
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( pstmt1!=null ) //For PreparedStatement pstmt1 if( pstmt1!=null )
pstmt1.close(); pstmt1.close();
pstmt1 = null; pstmt1 = null;
if( conn != null ) if( conn != null )
...@@ -315,4 +302,234 @@ public class StockTransferAct extends ActionHandlerEJB implements ...@@ -315,4 +302,234 @@ public class StockTransferAct extends ActionHandlerEJB implements
return valueXmlString.toString(); return valueXmlString.toString();
} // End of actionAllItems method } // End of actionAllItems method
private String actionStock(Document dom, Document dom1, String xtraParams)throws RemoteException, ITMException
{
String refSerFor = "",refIdFor="",remarks="",siteCodeReq = "";
String locCode = "", lotNum = "", lotSerial = "", sql = "";
//String lotNum1="" ,lotSerial1="";
double noArt = 0,remainingQty = 0d;
//double inputQty = 0d,hmQty = 0d;
String siteCode = "", itemCode = "", quantity = "", availableYn = "";
String errCode = "", errString = "";
int countItemCode = 0;
String lineNo="";
//HashMap<String, Double> hm = new HashMap<String, Double>();
ResultSet rs = null,rs1=null;
PreparedStatement pstmt = null,pstmt1 = null;
Connection conn = null;
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
if (dom == null)
{
valueXmlString.append("</Root>\r\n");
return valueXmlString.toString();
}
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
try
{
conn = getConnection();
if(refIdFor!= null && refIdFor.trim().length()>0 )
{
refIdFor = genericUtility.getColumnValue("ref_id__for", dom1);
System.out.println("Reference id:::["+refIdFor+"]");
if (("S-REQ").trim().equalsIgnoreCase(refSerFor))
{
refSerFor = genericUtility.getColumnValue("ref_ser__for", dom1);
System.out.println("Reference series:::["+refSerFor+"]" );
}
sql = "SELECT COUNT(*) FROM STOCK A, INVSTAT B "
+"WHERE A.INV_STAT = B.INV_STAT "
+"AND A.ITEM_CODE = ? "
+"AND A.SITE_CODE = ? "
+"AND B.AVAILABLE = ? "
+"AND (CASE WHEN ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END)) IS NULL THEN 0 ELSE ((CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END) - (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END))END) > 0";
System.out.println("SQL :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,availableYn);
rs = pstmt.executeQuery();
System.out.println(":::STOCK DETAILS DYNAMIC INPUTS:::");
System.out.println("Stock itemCode ::["+itemCode+"]");
System.out.println("Stock siteCodeReq ::["+siteCode+"]" );
System.out.println("Invstat availableYn ::["+availableYn+"]");
if (rs.next())
{
countItemCode = rs.getInt(1);
System.out.println("countItemCode :["+countItemCode+"]");
}
if (countItemCode == 0)
{
errCode = "VTSTOCK1";
errString = itmDBAccess.getErrorString("",errCode,"","",conn);
System.out.println("errString :"+errString);
return errString;
}
sql = "select det.line_no,"
+ "det.item_code,"
+ "det.quantity,"
+ "det.remarks, "
+ "hdr.lot_no, "
+ "hdr.lot_sl "
+ "from ser_req_item det,ser_request hdr"
+ "where det.req_id = hdr.req_id "
+ "and hdr.req_id = ? ";
System.out.println("SQL ::" + sql);
pstmt = conn.prepareStatement( sql );
pstmt.setString(1,refIdFor);
rs = pstmt.executeQuery();
while (rs.next()) {
lineNo = rs.getString("line_no");
itemCode = rs.getString("item_code");
quantity = rs.getString("quantity");
remarks = rs.getString("remarks");
// lotNum1 = rs.getString("lot_no");
// lotSerial1 = rs.getString("lot_sl");
System.out.println(":::SER_REQ_ITEM TABLE DETAIL:::");
System.out.println("lineNo ::["+lineNo+"]");
System.out.println("itemCode ::["+itemCode+"]");
System.out.println("quantity ::["+quantity+"]");
System.out.println("remarks ::["+remarks+"]");
//System.out.println("lotNum1 ::["+lotNum1+"]");
//System.out.println("lotSerial1 ::["+lotSerial1+"]");
sql = "SELECT STOCK.ITEM_SER, "
+ "STOCK.ITEM_CODE,"
+ "STOCK.UNIT, "
+ "STOCK.LOC_CODE,"
+ "STOCK.LOT_NO,"
+ "STOCK.LOT_SL,"
+ "STOCK.QUANTITY - STOCK.ALLOC_QTY AS BAL_QUANTITY, "
+ "STOCK.SITE_CODE, "
+ "STOCK.NO_ART, "
+ "(STOCK.QUANTITY - CASE WHEN STOCK.ALLOC_QTY IS NULL THEN 0 ELSE STOCK.ALLOC_QTY END -CASE WHEN STOCK.HOLD_QTY IS NULL THEN 0 ELSE STOCK.HOLD_QTY END) ,"
+ "STOCK.EXP_DATE, " + "STOCK.RETEST_DATE, "
+ "STOCK.DIMENSION, " + "STOCK.RATE "
+ " FROM STOCK, INVSTAT"
+ " WHERE STOCK.INV_STAT = INVSTAT.INV_STAT"
+ " AND STOCK.ITEM_CODE = ? "
+ " AND STOCK.SITE_CODE = ? "
+ " AND STOCK.QUANTITY - STOCK.ALLOC_QTY > 0"
+ " AND INVSTAT.AVAILABLE = ? ";
System.out.println("sql :" + sql);
pstmt1 = conn.prepareStatement( sql );
pstmt1.setString(1,itemCode);
pstmt1.setString(2,siteCodeReq);
pstmt1.setString(3,availableYn);
rs1 = pstmt1.executeQuery();
System.out.println(":::STOCK DETAILS DYNAMIC INPUTS:::");
System.out.println("itemCode ::["+itemCode+"]");
System.out.println("siteCodeReq ::["+siteCodeReq+"]");
System.out.println("availableYn ::["+availableYn+"]");
while (rs1.next()) {
locCode = rs1.getString("loc_code");
lotNum = rs1.getString("LOT_NO");
lotSerial = rs1.getString("LOT_SL");
remainingQty = rs1.getDouble("BAL_QUANTITY");
noArt = rs1.getDouble("NO_ART");
System.out.println(":::STOCK DETAILS:::");
System.out.println("lotNum ::["+lotNum+"]");
System.out.println("lotSerial ::["+lotSerial+"]" );
System.out.println("remainingQty ::["+remainingQty+"]");
System.out.println("noArt ::["+noArt+"]");
System.out.println("locCode ::["+locCode+"]");
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<line_no isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lineNo).append("]]>").append("</line_no>\r\n");
valueXmlString.append("<item_code isSrvCallOnChg=\"0\">").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<quantity isSrvCallOnChg=\"0\">").append("<![CDATA[").append(quantity).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<loc_code__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append((locCode == null) ? "" : locCode).append("]]>").append("</loc_code__to>\r\n");
valueXmlString.append("<lot_no__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lotNum).append("]]>").append("</lot_no__to>\r\n");
valueXmlString.append("<lot_sl__to isSrvCallOnChg=\"0\">").append("<![CDATA[").append(lotSerial).append("]]>").append("</lot_sl__to>\r\n");
valueXmlString.append("<no_art isSrvCallOnChg=\"0\">").append("<![CDATA[").append(noArt).append("]]>").append("</no_art>\r\n");
valueXmlString.append("<remarks isSrvCallOnChg=\"0\">").append("<![CDATA[").append(remarks).append("]]>").append("</remarks>\r\n");
valueXmlString.append("</Detail>\r\n");
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
}//while end
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("</Root>\r\n");
}//end of ref_id_for
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in StockTransferAct for Stock button :"+sqx);
throw new ITMException(sqx);
}
catch (Exception e)
{
System.out.println("The Exception occured in StockTransferAct for Stock button:"+e);
throw new ITMException(e);
}
finally
{
try
{
if( rs != null )
rs.close();
rs = null;
if( rs1 != null )
rs1.close();
rs1=null;
if( pstmt != null )
pstmt.close();
pstmt = null;
if( pstmt1!=null )
pstmt1.close();
pstmt1 = null;
if( conn != null )
conn.close();
conn = null;
}
catch (Exception e)
{
e.printStackTrace();
}
}
System.out.println("valueXmlString return from StockTransfer[actionStock]] :"+valueXmlString.toString());
return valueXmlString.toString();
} //End of actionStock method
} }
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