Commit 0662050f authored by wansari's avatar wansari

W15GSUN002 added component for Pallet requisition


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98829 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 4557bb04
/*
* Author:Wasim Ansari
* Date: 10-OCT-15
* Request ID: W15GSUN002
* Description: Pallet requisition (Against Order)
*/
package ibase.webitm.ejb.wms;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import javax.ejb.Stateless;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.utility.wms.CommonWmsUtil;
@Stateless
public class PalletRequisitionActEJB extends ActionHandlerEJB implements PalletRequisitionActLocal,PalletRequisitionActRemote
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
CommonWmsUtil commonWmsUtility = CommonWmsUtil.getInstance();
public String distActionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("--------------ActionHandler method of Distribution Pallet Requisition ------------- : ["+tranId+"]");
String retString = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
Boolean isError = false;
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
retString = distPalletRequisition(tranId,xtraParams,forcedFlag,conn);
//String sql = "select item_code,line_no,quantity,unit,lot_no,lot_sl,mfg_date,exp_date,pallet_no from distord_issdet where dist_order = ?";
//retString = distPalletRequisition(tranId,xtraParams,forcedFlag,sql,conn);
}
catch(Exception e)
{
isError = true;
System.out.println("Exception :SendReport :actionHandler():" + e.getMessage() + ":");
retString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
}
finally
{
System.out.println("is Error in main="+isError);
try
{
if(isError)
{
conn.rollback();
retString = itmDBAccessEJB.getErrorString("","VTTNSVD","","",conn);
}
if(conn != null){conn.close();conn = null;}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("Final return="+retString);
return retString;
}
public String sorderActionHandler(String tranId, String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
System.out.println("--------------ActionHandler method of Sorder Pallet Requisition ------------- : ["+tranId+"]");
String retString = "";
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
Boolean isError = false;
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
retString = sorderPalletRequisition(tranId,xtraParams,forcedFlag,conn);
//String sql = "select item_code,line_no,quantity,unit__std,lot_no,lot_sl,mfg_date,exp_date FROM sordalloc where sale_order = ?";
//retString = distPalletRequisition(tranId,xtraParams,forcedFlag,sql,conn);
}
catch(Exception e)
{
isError = true;
System.out.println("Exception :SendReport :actionHandler():" + e.getMessage() + ":");
retString = GenericUtility.getInstance().createErrorString(e);
e.printStackTrace();
}
finally
{
System.out.println("is Error in main="+isError);
try
{
if(isError)
{
retString = itmDBAccessEJB.getErrorString("","VTTNSVD","","",conn);
}
if(conn != null){conn.close();conn = null;}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("Final return="+retString);
return retString;
}
public String distPalletRequisition(String tranId,String xtraParams,String forcedFlag,Connection conn) throws RemoteException,ITMException
{
System.out.println("==================In distPalletRequisition=======================");
String sql = "", interfaceSql = "";
ResultSet rs = null;
PreparedStatement pstmt = null, interfacePstmt = null;
int caseCount = 0,flag = 0;
Boolean isError = false;
HashMap hm = new HashMap();
String loginEmpCode = "",userId = "",loginSite = "",errString = "",objName = "";
String itemCode = "",lineNo = "",descr = "",unit = "",itemType = "",familyGrp = "",refSer = "",lotNo = "",refId = "",lotSl = "",
palletNo = "",palletStatus = "",lockStat = "",qcType = "",stroPref = "",palletRej = "",palletRejDesc = "",confirmed = "",siteCode = "";
String transactionId = "";
Timestamp today = new Timestamp(System.currentTimeMillis());
Timestamp expDate = null;
Timestamp mfgDate = null;
double quantity = 0, noArtQuot = 0,noArtRem = 0,notArt = 0,shipperSize = 0,totalQuantity = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("XTRA PARAMS ["+xtraParams+"]");
loginEmpCode = checkNullAndTrim(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"));
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = checkNullAndTrim((genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode")));
ArrayList interfaceArrList = new ArrayList();
try
{
System.out.println("Inside try block distribution.....");
sql = "SELECT CONFIRMED FROM DISTORDER WHERE DIST_ORDER = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = checkNullAndTrim(rs.getString("CONFIRMED"));
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if("Y".equalsIgnoreCase(confirmed))
{
sql = "SELECT * FROM INTERFACE2 WHERE REF_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("Transaction is already present in interface2 table");
errString = itmDBAccessEJB.getErrorString("","ALRDYSUBMT","","",conn);
return errString;
}
else
{
sql = "SELECT ITEM_CODE,LINE_NO,QUANTITY,UNIT,LOT_NO,LOT_SL,MFG_DATE,EXP_DATE,LOC_CODE,SITE_CODE__MFG FROM DISTORDER_ALLOC WHERE DIST_ORDER = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
itemCode = checkNullAndTrim(rs.getString("ITEM_CODE"));
lineNo = checkNullAndTrim(rs.getString("LINE_NO"));
lineNo = " " + lineNo;
lineNo = lineNo.substring(lineNo.length()-3);
quantity = rs.getDouble("QUANTITY");
unit = checkNullAndTrim(rs.getString("UNIT"));
lotNo = checkNullAndTrim(rs.getString("LOT_NO"));
lotSl = checkNullAndTrim(rs.getString("LOT_SL"));
//mfgDate = rs.getTimestamp("MFG_DATE");
//expDate = rs.getTimestamp("EXP_DATE");
palletNo = checkNullAndTrim(rs.getString("LOC_CODE"));
siteCode = checkNullAndTrim(rs.getString("SITE_CODE__MFG"));
/*hm = getPalletizedAttributes(itemCode,siteCode,conn);
familyGrp = (String) hm.get("LOC_ZONE__PREF");
qcType = (String) hm.get("PROC_MTH");
stroPref = (String) hm.get("ANALYSIS_CLASS");*/
//transactionId = generateTranTd("w_interface2",today.toString(),loginSite,conn);
HashMap interfaceHmap = new HashMap();
hm = commonWmsUtility.getItemVoumeMap(itemCode,lotNo,conn);
shipperSize = (Double) hm.get("PACK_SIZE");
noArtQuot= quantity / shipperSize ;
noArtRem = quantity % shipperSize ;
if(noArtRem > 0)
{
noArtRem = 1;
}
notArt = noArtQuot + noArtRem;
totalQuantity = notArt * shipperSize;
System.out.println("Quantity["+quantity+"]ShipperSize["+shipperSize+"]noArtQuot["+noArtQuot+"]"
+ "noArtRem["+noArtRem+"]notArt["+notArt+"]TotalQuantity["+totalQuantity+"]");
interfaceHmap.put("TRAN_ID", "");
interfaceHmap.put("ITEM_CODE", itemCode);
interfaceHmap.put("DESCR", "");
interfaceHmap.put("UNIT", unit);
interfaceHmap.put("ITEM_TYPE", itemType);
interfaceHmap.put("FAMILY_GRP", familyGrp);
interfaceHmap.put("IN_OUT", "O");
interfaceHmap.put("REF_SER", refSer);
interfaceHmap.put("REF_ID", tranId);
interfaceHmap.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today)));
interfaceHmap.put("LOT_NO", lotNo);
interfaceHmap.put("LOT_SL", lotSl);
interfaceHmap.put("QUANTITY", String.valueOf(noArtQuot));
interfaceHmap.put("QTY_PER_ART", String.valueOf(shipperSize));
interfaceHmap.put("TOTAL_QTY", String.valueOf(totalQuantity));
System.out.println("exp_date="+expDate);
System.out.println("Mfg_date="+mfgDate);
interfaceHmap.put("EXP_DATE", checkNullAndTrim(String.valueOf(expDate)));
interfaceHmap.put("MFG_DATE", checkNullAndTrim(String.valueOf(mfgDate)));
interfaceHmap.put("PALLET_NO", palletNo);
interfaceHmap.put("MSG_STAT", "");
interfaceHmap.put("PALLET_STATUS", palletStatus);
interfaceHmap.put("LOCK_STAT", lockStat);
interfaceHmap.put("ERR_COD", "");
interfaceHmap.put("ERR_DESC", "");
interfaceHmap.put("QC_TYPE", qcType);
interfaceHmap.put("TRANS_DT_ACK", "");
interfaceHmap.put("STRO_PREF", stroPref);
interfaceHmap.put("LINE_NO", lineNo);
interfaceArrList.add(interfaceHmap);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(flag == 0)
{
errString = itmDBAccessEJB.getErrorString("","RECNOTSORA","","",conn);
return errString;
}
else
{
commonWmsUtility.updateAwmsInterface(interfaceArrList,loginSite,conn);
}
}
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTTSORNTCF","","",conn);
return errString;
}
}
catch(Exception e)
{
isError = true;
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError="+isError);
if(isError)
{
conn.rollback();
}
else
{
conn.commit();
errString = itmDBAccessEJB.getErrorString("","VTCONPARM","","",conn);
}
if(pstmt != null){pstmt.close();pstmt=null;}
if(interfacePstmt != null){interfacePstmt.close();interfacePstmt=null;}
if(rs != null){rs.close();rs=null;}
}
catch(Exception e1)
{
throw new ITMException(e1);
}
}
return errString;
}
public String sorderPalletRequisition(String tranId,String xtraParams,String forcedFlag,Connection conn) throws RemoteException,ITMException
{
System.out.println("==================In sorderPalletRequisition=======================");
String sql = "", interfaceSql = "";
ResultSet rs = null;
PreparedStatement pstmt = null, interfacePstmt = null;
int caseCount = 0,flag = 0;
Boolean isError = false;
String loginEmpCode = "",userId = "",loginSite = "",errString = "",objName = "";
String itemCode = "",lineNo = "",descr = "",unit = "",itemType = "",familyGrp = "",refSer = "",lotNo = "",refId = "",lotSl = "",
palletNo = "",palletStatus = "",lockStat = "",qcType = "",stroPref = "",palletRej = "",palletRejDesc = "",confirmed = "",siteCode = "";
String transactionId = "";
double quantity = 0, noArtQuot = 0,noArtRem = 0,notArt = 0,shipperSize = 0,totalQuantity = 0;
Timestamp today = new Timestamp(System.currentTimeMillis());
Timestamp expDate = null;
Timestamp mfgDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
System.out.println("XTRA PARAMS ["+xtraParams+"]");
loginEmpCode = checkNullAndTrim(genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode"));
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = checkNullAndTrim((genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode")));
ArrayList interfaceArrList = new ArrayList();
try
{
System.out.println("Inside try block sale order.....");
System.out.println("Today="+today);
sql = "SELECT CONFIRMED FROM SORDER WHERE SALE_ORDER = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
confirmed = checkNullAndTrim(rs.getString("CONFIRMED"));
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if("Y".equalsIgnoreCase(confirmed))
{
sql = "SELECT * FROM INTERFACE2 WHERE REF_ID = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("Transaction is already present in interface2 table");
errString = itmDBAccessEJB.getErrorString("","ALRDYSUBMT","","",conn);
return errString;
}
else
{
sql = "SELECT ITEM_CODE,LINE_NO,QUANTITY,UNIT__STD,LOT_NO,LOT_SL,MFG_DATE,EXP_DATE,LOC_CODE,SITE_CODE FROM SORDALLOC WHERE SALE_ORDER = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
while(rs.next())
{
flag = 1;
itemCode = checkNullAndTrim(rs.getString("ITEM_CODE"));
lineNo = checkNullAndTrim(rs.getString("LINE_NO"));
lineNo = " " + lineNo;
lineNo = lineNo.substring(lineNo.length()-3);
quantity = rs.getDouble("QUANTITY");
unit = checkNullAndTrim(rs.getString("UNIT__STD"));
lotNo = checkNullAndTrim(rs.getString("LOT_NO"));
lotSl = checkNullAndTrim(rs.getString("LOT_SL"));
//mfgDate = rs.getTimestamp("MFG_DATE");
//expDate = rs.getTimestamp("EXP_DATE");
palletNo = checkNullAndTrim(rs.getString("LOC_CODE"));
siteCode = checkNullAndTrim(rs.getString("SITE_CODE"));
/*hm = getPalletizedAttributes(itemCode,siteCode,conn);
familyGrp = (String) hm.get("LOC_ZONE__PREF");
qcType = (String) hm.get("PROC_MTH");
stroPref = (String) hm.get("ANALYSIS_CLASS");*/
//transactionId = generateTranTd("w_interface2",today.toString(),loginSite,conn);
HashMap hm = new HashMap();
hm = commonWmsUtility.getItemVoumeMap(itemCode,lotNo,conn);
shipperSize = (Double) hm.get("PACK_SIZE");
noArtQuot= quantity / shipperSize ;
noArtRem = quantity % shipperSize ;
if(noArtRem > 0)
{
noArtRem = 1;
}
notArt = noArtQuot + noArtRem;
totalQuantity = notArt * shipperSize;
System.out.println("Quantity["+quantity+"]ShipperSize["+shipperSize+"]noArtQuot["+noArtQuot+"]"
+ "noArtRem["+noArtRem+"]notArt["+notArt+"]TotalQuantity["+totalQuantity+"]");
HashMap interfaceHmap = new HashMap();
interfaceHmap.put("TRAN_ID", "");
interfaceHmap.put("ITEM_CODE", itemCode);
interfaceHmap.put("DESCR", "");
interfaceHmap.put("UNIT", unit);
interfaceHmap.put("ITEM_TYPE", itemType);
interfaceHmap.put("FAMILY_GRP", familyGrp);
interfaceHmap.put("IN_OUT", "O");
interfaceHmap.put("REF_SER", "S-ORD");
interfaceHmap.put("REF_ID", tranId);
interfaceHmap.put("TRAN_DATE", checkNullAndTrim(String.valueOf(today)));
interfaceHmap.put("LOT_NO", lotNo);
interfaceHmap.put("LOT_SL", lotSl);
interfaceHmap.put("QUANTITY", String.valueOf(noArtQuot));
interfaceHmap.put("QTY_PER_ART", String.valueOf(shipperSize));
interfaceHmap.put("TOTAL_QTY", String.valueOf(totalQuantity));
System.out.println("exp_date="+expDate);
System.out.println("Mfg_date="+mfgDate);
interfaceHmap.put("EXP_DATE", checkNullAndTrim(String.valueOf(expDate)));
interfaceHmap.put("MFG_DATE", checkNullAndTrim(String.valueOf(mfgDate)));
interfaceHmap.put("PALLET_NO", palletNo);
interfaceHmap.put("MSG_STAT", "");
interfaceHmap.put("PALLET_STATUS", palletStatus);
interfaceHmap.put("LOCK_STAT", lockStat);
interfaceHmap.put("ERR_COD", "");
interfaceHmap.put("ERR_DESC", "");
interfaceHmap.put("QC_TYPE", qcType);
interfaceHmap.put("TRANS_DT_ACK", "");
interfaceHmap.put("STRO_PREF", stroPref);
interfaceHmap.put("LINE_NO", lineNo);
interfaceArrList.add(interfaceHmap);
}
rs.close();rs = null;
pstmt.close();pstmt = null;
if(flag == 0)
{
errString = itmDBAccessEJB.getErrorString("","RECNOTSORA","","",conn);
return errString;
}
else
{
commonWmsUtility.updateAwmsInterface(interfaceArrList,loginSite,conn);
}
}
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTTSORNTCF","","",conn);
return errString;
}
}
catch(Exception e)
{
isError = true;
throw new ITMException(e);
}
finally
{
try
{
System.out.println("isError="+isError);
System.out.println("Flag="+flag);
if(isError)
{
conn.rollback();
}
else
{
conn.commit();
errString = itmDBAccessEJB.getErrorString("","VTCONPARM","","",conn);
}
if(pstmt != null){pstmt.close();pstmt=null;}
if(interfacePstmt != null){interfacePstmt.close();interfacePstmt=null;}
if(rs != null){rs.close();rs=null;}
}
catch(Exception e1)
{
throw new ITMException(e1);
}
}
System.out.println("errString="+errString);
return errString;
}
private static String checkNullAndTrim(String input)
{
if (input==null)
{
input="";
}
return input.trim();
}
}
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