Commit f84c59bc authored by rtiwari's avatar rtiwari

ejb added for ref: M14ESUN002


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96206 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e59872c7
/**
DEVELOPED BY : RITESH ON 10/SEP/2014
PURPOSE : STOCK TRANSEFR FROM WIP LOCATION THROUGH WIZARD (REG : M14ESUN002)
*/
package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless;
@Stateless
public class WoTrfWizIC extends ValidatorEJB implements WoTrfWizICLocal, WoTrfWizICRemote
{
GenericUtility genericUtility = GenericUtility.getInstance();
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = null;
Document dom = null;
Document dom1 = null;
Document dom2 = null;
try
{
System.out.println("Val xmlString :: " + xmlString );
System.out.println("Val xmlString1 :: " + xmlString1 );
System.out.println("Val xmlString2 :: " + xmlString2 );
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
dom2 = parseString(xmlString2);
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
throw new ITMException( e );
}
return (errString);
}
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr=0;
int count = 0;
String childNodeName = null;
String errString = "";
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null ;
String sql = "" ;
String userId = "";
int currentFormNo=0;
int childNodeListLength;
ConnDriver connDriver = new ConnDriver();
String columnValue ="";
String campNo = "";
String locCodeTo = "";
// added by cpatil end 06-sept-12
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getApplDateFormat());
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1:
{
// dts=java.sql.Timestamp.valueOf(sdf.format(new java.util.Date()).toString() + " 00:00:00.0");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
if( childNodeName.equalsIgnoreCase( "campaign_no" ))
{
System.out.println("campaign_no ");
if(childNode.getFirstChild() == null)
{
errString = getErrorString("campaign_no","VTCAMPNO2",userId);
break;
}
else
{
campNo = genericUtility.getColumnValue("campaign_no", dom);
sql = "SELECT COUNT(*) FROM WORKORDER WHERE CAMPGN_NO = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, campNo);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(count == 0)
{
errString = getErrorString("campaign_no","VTCAMPNO1",userId);
break;
}
}
}
}
}
break;
case 2 :
{
System.out.println("case2 wfvalData()::");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
System.out.println("case2 wfvalData()::inside for ::"+ctr);
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if ( childNode != null && childNode.getFirstChild() != null )
{
columnValue = childNode.getFirstChild().getNodeValue();
}
System.out.println(" columnName [" + childNodeName + "] columnValue [" + columnValue + "]");
if( childNodeName.equalsIgnoreCase( "item_ser" ))
{
String itemSer = genericUtility.getColumnValue("item_ser", dom);
System.out.println("childNodeName.equalsIgnoreCase( item_ser )::"+itemSer);
if(childNode.getFirstChild() == null)
{
errString = getErrorString("item_ser","VMITMSER1",userId);
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM ITEMSER WHERE ITEM_SER = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,columnValue);
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if( count == 0 )
{
errString = getErrorString("item_ser","VMITMSER2",userId);
break;
}
}
}
if( childNodeName.equalsIgnoreCase( "ref_ser__for" ))
{
String refSerFor = genericUtility.getColumnValue("ref_ser__for", dom);
System.out.println("childNodeName.equalsIgnoreCase( item_ser )::"+refSerFor);
if(childNode.getFirstChild() == null)
{
errString = getErrorString("ref_ser__for","VMREFSER1",userId);
break;
}
else
{
sql = "SELECT COUNT(*) AS COUNT FROM refser WHERE ref_ser = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refSerFor);
rs = pstmt.executeQuery();
if( rs.next() )
{
count = rs.getInt("COUNT");
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if( count == 0 )
{
errString = getErrorString("item_ser","VMREFSER2",userId);
break;
}
}
}
}
}
break;
case 3:
{
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
System.out.println("Enter into detail3 validation");
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("childNodeName ::"+childNodeName);
if( childNodeName.equalsIgnoreCase( "loc_code__to" ))
{
System.out.println("loc_code__to["+childNode.getNodeValue()+"]");
if(childNode.getFirstChild() == null)
{
errString = getErrorString("loc_code__to","VTLOCTO1",userId);
break;
}
else
{
// locCodeTo = genericUtility.getColumnValue("loc_code__to", dom1);
locCodeTo = genericUtility.getColumnValue("loc_code__to", dom);
// locCodeTo= ((genericUtility.getColumnValueFromNode("loc_code__to",dom.getElementsByTagName("Detail3").item(ctr))).trim());
sql = "SELECT COUNT(*) FROM location WHERE LOC_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
count = rs.getInt(1);
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if(count == 0)
{
errString = getErrorString("loc_code__to","VTLOCTO2",userId);
break;
}
}
}
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
errString=e.getMessage();
throw new ITMException( e );
}
finally
{
try
{
if(conn!=null)
{
if(rs != null )rs.close();
rs = null;
if(pstmt != null )pstmt.close();
pstmt =null;
conn.close();
conn = null;
}
conn = null;
}catch(Exception d)
{
d.printStackTrace();
throw new ITMException( d );
}
}
return errString;
}
public String itemChanged() throws RemoteException, ITMException
{
return "";
}
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("itemChanged() called @@@@@@@@@@@@");
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString != null && xmlString.trim().length()!=0)
{
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length()!=0)
{
dom1 = genericUtility.parseString(xmlString1);
}
if (xmlString2 != null && xmlString2.trim().length()!=0)
{
dom2 = genericUtility.parseString(xmlString2);
}
System.out.println("xmlString---"+xmlString);
System.out.println("xmlString1---"+xmlString1);
System.out.println("xmlString2---"+xmlString2);
valueXmlString = itemChanged( dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams );
}
catch(Exception e)
{
System.out.println("Exception : [TrainingEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
throw new ITMException( e );
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
System.out.println("itemChanged() called @@@@@@@@@@@@ 2");
StringBuffer valueXmlString = new StringBuffer();
Connection conn = null;
PreparedStatement pstmt = null,pstmt1=null;;
ResultSet rs = null,rs1 = null ;
String sSQL = "";
String sql = "";
int currentFormNo = 0 ;
int lineNo = 0 ;
String siteCode = "";
String loginCode = "";
String chgTerm = "";
String siteDescr = "";
int cnt = 0;
String currAppdate= "";
String empCode ="", loginSiteCode = "";
Timestamp currDateNew = null;
java.util.Date currDate = null;
String currDateStr = null;
ConnDriver connDriver = new ConnDriver();
GenericUtility genericUtility = GenericUtility.getInstance();
java.util.Date utilDate = new java.util.Date();
String remarks="",reasCode="",explev="",campaignNo = "";
double issQty=0.0,integralQty=0.0,potencyadj=0.0;
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver=null;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
Timestamp date1 = Timestamp.valueOf(sdf.format(utilDate).toString() + " 00:00:00.0");
String applDateFormat = genericUtility.getApplDateFormat();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
switch(currentFormNo)
{
case 2 :
{
siteCode=checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ));
System.out.println("siteCode---"+siteCode);
//siteCode =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
currDate = new java.util.Date();
sdf = new SimpleDateFormat(applDateFormat);
currDateStr = sdf.format(currDate);
loginCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ));
System.out.println("********* login code ["+loginCode+"]");
sql = "SELECT EMP_CODE FROM USERS WHERE CODE = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, loginCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
empCode = rs.getString("EMP_CODE");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<Detail2 domID='1' selected=\"N\">\r\n");
// valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\" />\r\n");
chgTerm = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "chgTerm" ));
siteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ));
currDateNew = new java.sql.Timestamp(System.currentTimeMillis()) ;
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDateNew).toString();
currAppdate = genericUtility.getValidDateString(currAppdate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, siteCode );
rs = pstmt.executeQuery();
if( rs.next() )
{
siteDescr = rs.getString("DESCR");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
valueXmlString.append("<tran_date protect = '1'><![CDATA[" ).append( currDateStr ).append( "]]></tran_date>\r\n" );
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA["+"PL001"+"]]>").append("</site_code>");
valueXmlString.append("<site_descr><![CDATA[" ).append( checkNull( siteDescr )).append( "]]></site_descr>\r\n" );
valueXmlString.append("<item_ser><![CDATA[" ).append( "NT" ).append( "]]></item_ser>\r\n" );
valueXmlString.append("<ref_ser__for><![CDATA[" ).append( "XFRX" ).append( "]]></ref_ser__for>\r\n" );
// valueXmlString.append("<emp_codpstmt != nulle__aprv protect = '1'><![CDATA["+ empCode +"]]></emp_code__aprv>");
}
valueXmlString.append("</Detail2>");
}
break;
case 3 :
{
loginCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" ));
loginSiteCode = checkNull(genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ));
System.out.println("loginCode --->["+loginCode+"]");
// campaignNo = genericUtility.getColumnValue("campaign_no", dom);
// System.out.println(" campaignNo in Detail --->["+campaignNo+"]");
campaignNo = genericUtility.getColumnValue("campaign_no", dom1);
System.out.println(" campaignNo in Detail1 --->["+campaignNo+"]");
DecimalFormat df = new DecimalFormat("0.000");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("siteCode set in case 3---"+genericUtility.getColumnValueFromNode("site_code", dom2.getElementsByTagName("Detail2").item(0)));
System.out.println("emp_code__user set in case 3---"+genericUtility.getColumnValueFromNode("emp_code__user", dom2.getElementsByTagName("Detail2").item(0)));
System.out.println(genericUtility.getColumnValue("loc_code", dom1));
sql = " select item_code,lot_no,lot_sl,loc_code,sum(quantity) as quantity "
+" from inv_alloc_det where (case when alloc_qty is null then 0 else alloc_qty end - case when dealloc_qty is null then 0 else dealloc_qty end) > 0 and tran_id IN (SELECT TRAN_ID FROM INV_ALLOCATE WHERE WORK_ORDER IN (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? AND STATUS = 'R')) "
+" GROUP BY item_code, lot_no, lot_sl, loc_code ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,campaignNo);
System.out.println("** SQL **[" + sql + "]");
rs = pstmt.executeQuery();
while (rs.next())
{
lineNo++;
issQty = rs.getDouble("quantity");
sSQL = " select site_code,remarks,reas_code,potency_adj,line_no,exp_lev " +
" from inv_alloc_det where tran_id in ( SELECT TRAN_ID FROM INV_ALLOCATE WHERE WORK_ORDER IN (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? )) and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? ";
pstmt1 = conn.prepareStatement(sSQL);
pstmt1.setString(1, campaignNo);
pstmt1.setString(2, rs.getString("item_code"));
pstmt1.setString(3, rs.getString("lot_no"));
pstmt1.setString(4, rs.getString("lot_sl"));
pstmt1.setString(5, rs.getString("loc_code"));
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
siteCode = rs1.getString("site_code");
remarks = rs1.getString("remarks");
reasCode = rs1.getString("reas_code");
potencyadj = rs1.getDouble("potency_adj");
// lineno = rs1.getInt("line_no");
explev = rs1.getString("exp_lev");
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
sql = "select INTEGRAL_QTY from item where item_code = ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, rs.getString("item_code"));
rs1 = pstmt1.executeQuery();
if ( rs1.next() )
{
integralQty = rs1.getDouble(1);
}
if(rs1 != null)
rs1.close();
rs1 = null;
if(pstmt1 != null)
pstmt1.close();
pstmt1 = null;
valueXmlString.append("<Detail3 domID='" + lineNo+ "' selected=\"N\">\r\n");
// valueXmlString.append("<Detail3 domID='" + lineNo+ "' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n");
// valueXmlString.append("<tran_id/>");
valueXmlString.append("<site_code><![CDATA[").append(checkNullAndTrim(siteCode)).append("]]></site_code>\r\n");
valueXmlString.append("<item_code><![CDATA[").append(checkNullAndTrim(rs.getString("item_code"))).append("]]></item_code>\r\n");
valueXmlString.append("<loc_code><![CDATA[").append(checkNullAndTrim( rs.getString("loc_code"))).append("]]></loc_code>\r\n");
valueXmlString.append("<lot_no><![CDATA[").append(checkNullAndTrim(rs.getString("lot_no"))).append("]]></lot_no>\r\n");
valueXmlString.append("<lot_sl><![CDATA[").append(checkNullAndTrim(rs.getString("lot_sl"))).append("]]></lot_sl>\r\n");
valueXmlString.append("<allocated_qty><![CDATA[").append(0.0).append("]]></allocated_qty>\r\n");
if(integralQty > 0)
{
if(issQty > integralQty ){
if(issQty % integralQty != 0 && integralQty != 0)
{
valueXmlString.append("<quantity>").append("<![CDATA[" + df.format((integralQty - (issQty % integralQty) + issQty)) +"]]>").append("</quantity>");
}
else
{
valueXmlString.append("<quantity>").append("<![CDATA[" + df.format(issQty) +"]]>").append("</quantity>");
}
}else{
valueXmlString.append("<quantity>").append("<![CDATA[" + df.format(integralQty) +"]]>").append("</quantity>");
}
}
else if(integralQty == 0)
{
valueXmlString.append("<quantity>").append("<![CDATA[" + df.format(issQty) +"]]>").append("</quantity>");
}
valueXmlString.append("<actual_qty><![CDATA[").append(df.format(issQty)).append("]]></actual_qty>\r\n");
valueXmlString.append("<exp_lev><![CDATA[").append(explev).append("]]></exp_lev>\r\n");
valueXmlString.append("<potency_adj><![CDATA[").append(potencyadj).append("]]></potency_adj>\r\n");
valueXmlString.append("</Detail3>\r\n");
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
System.out.println("Detail 3 String ["+valueXmlString.toString()+"]");
System.out.println("\n$$$$$$$$$\n");
}
}
break;
}
valueXmlString.append("</Root>");
System.out.println("=================["+valueXmlString+"]");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
try {
conn.rollback();
} catch (SQLException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(rs != null)
{
rs.close();
rs = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
}
catch(Exception d)
{
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private String checkNullAndTrim( String inputVal )
{
if ( inputVal == null )
{
inputVal = "";
}
else
{
inputVal = inputVal.trim();
}
return inputVal;
}
private String checkNull( String inputVal )
{
if ( inputVal == null )
{
inputVal = "";
}
return inputVal;
}
private double quanitityPerPallet(String itemCode,String lotNo, double pallet ,Connection conn)
{
int findNosOfPallet=0;
int nosOfPalletPerVolume=0;
int nosOfPalletPerWeight=0;
int perPalletArticle=0;
String sql="";
PreparedStatement pstmt = null;
ResultSet rs =null;
double shipperSize =0.0;
double grossWeight =0.0;
double netWeight =0.0;
double length=0.0;
double width=0.0;
double height=0.0;
Double nosOfPallet=0.0;
double quantity = 0.0;
DistCommon distComm = new DistCommon();
sql= "SELECT SHIPPER_SIZE, GROSS_WEIGHT, NET_WEIGHT, LENGTH, WIDTH ,HEIGHT FROM ITEM_LOT_PACKSIZE WHERE ITEM_CODE = ? " +
" AND ? BETWEEN LOT_NO__FROM AND LOT_NO__TO ";
try {
pstmt =conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,lotNo);
rs=pstmt.executeQuery();
if(rs.next())
{
shipperSize=rs.getDouble(1);
grossWeight =rs.getDouble(2);
netWeight=rs.getDouble(3);
length=rs.getDouble(4);
width=rs.getDouble(5);
height=rs.getDouble(6);
}
rs.close();
pstmt.close();
rs=null;
pstmt =null;
double perPallateVolume = Double.parseDouble(distComm.getDisparams("999999","PER_PALLET__VOLUME",conn));
System.out.println("shipperSize ["+shipperSize+"] grossWeight ["+grossWeight+"] netWeight ["+netWeight+"] length ["+length+"] width ["+width+"] height ["+height+"]");
//nosOfPallet=(quantity*length*width*height/shipperSize)/(Double.parseDouble(distComm.getDisparams("999999","PER_PALLET__VOLUME",conn)));
double newValue = Math.floor((pallet * perPallateVolume)/(length*width*height));
System.out.println(" before Math.floor -->["+newValue+"]");
quantity = newValue * shipperSize;
System.out.println("<!@#>QUANTITY " +quantity);
/*//nosOfPalletPerVolume=(new Double((Math.round(nosOfPallet)))).intValue();
System.out.println("<!@#>nosOfPalletPerVolume" +nosOfPalletPerVolume);*/
//System.out.println("<!@#>findNosOfPallet" +findNosOfPallet);
} catch (SQLException e) {
e.printStackTrace();
}
return quantity;
}
public long countDaysBetween(java.sql.Date startdate, java.util.Date enddate)
{
//reset all hours mins and secs to zero on start date
Calendar startCal = GregorianCalendar.getInstance();
startCal.setTime(startdate);
startCal.set(Calendar.HOUR_OF_DAY, 0);
startCal.set(Calendar.MINUTE, 0);
startCal.set(Calendar.SECOND, 0);
long startTime = startCal.getTimeInMillis();
//reset all hours mins and secs to zero on end date
Calendar endCal = GregorianCalendar.getInstance();
endCal.setTime(enddate);
endCal.set(Calendar.HOUR_OF_DAY, 0);
endCal.set(Calendar.MINUTE, 0);
endCal.set(Calendar.SECOND, 0);
long endTime = endCal.getTimeInMillis();
return (endTime - startTime)/(1000 * 60 * 60 * 24) ;
}
private String generateTranId( String windowName, Connection conn )throws
ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
String paySiteCode = "";
String effectiveDate = "";
java.sql.Date effDate = null;
try
{
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
//System.out.println("selSql :"+selSql);
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE",
CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e){}
}
return tranId;
}//generateTranTd()
}
/**
DEVELOPED BY : RITESH ON 10/SEP/2014
PURPOSE : STOCK TRANSEFR FROM WIP LOCATION THROUGH WIZARD (REG : M14ESUN002)
*/
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local;
@Local
public interface WoTrfWizICLocal extends ValidatorLocal
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/**
DEVELOPED BY : RITESH ON 10/SEP/2014
PURPOSE : STOCK TRANSEFR FROM WIP LOCATION THROUGH WIZARD (REG : M14ESUN002)
*/
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WoTrfWizICRemote extends ValidatorRemote
{
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String wfValData(Document dom, Document dom1, Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
}
/**
DEVELOPED BY : RITESH ON 10/SEP/2014
PURPOSE : STOCK TRANSEFR FROM WIP LOCATION THROUGH WIZARD (REG : M14ESUN002)
*/
package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.adv.StockTransferConf;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import java.rmi.RemoteException;
import java.sql.*;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.utility.CommonConstants;
@javax.ejb.Stateless
public class WoTrfWizPos extends ValidatorEJB implements WoTrfWizPosLocal, WoTrfWizPosRemote
{
public String postSave()throws RemoteException,ITMException
{
return "";
}
public String postSave(String domString, String tranId,String editFlag, String xtraParams, Connection conn1 ) throws RemoteException,ITMException
{
System.out.println("post save called )( 05092014");
String errString = "";
String sSQL="",itemCode = "", locCode = "",locCodeTo="";
String siteCode = "";
String lotNo = "";
String lotSl = "";
String itemSer="",tranDate="",refSerFor="",siteCodeDom="",quantityStr="";
String campaignNo="";
double quantity = 0d;
String acctCodeInv1="" ,cctrCodeInv1="";
NodeList parentNodeList = null;
Node parentNode = null;
int parentNodeListLength = 0;
int ctr = 0;
int lineNo = 0;
boolean insertFlag = false;
Document dom = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
java.util.Date utilDate = new java.util.Date();
String sql = "";
String loginCode= "",empCode="",genratedTranId="";
Connection conn = null;
ConnDriver connDriver = null;
ArrayList list = new ArrayList();
HashMap stockMap = new HashMap();
java.sql.Timestamp expDate = null;
java.sql.Timestamp mfgDate = null;
java.sql.Timestamp restestDate = null;
String packCode = "";
String siteCodeMfg = "";
String packInstr = "";
String suppCodeMfg = "";
String unitAlt = "";
String batchNo = "";
String unit = "";
String grade = "";
String remarks1 = "";
String dimension = "";
String acctCodeDr = "";
String ediOption = "";
String dataStr = "";
String chgTerm = "";
double totWoQty= 0.0;
double grossRate = 0d;
double convQtyStduom = 0d;
double batchSize = 0d;
double stkGrossRate = 0d;
double stkRate = 0d;
double actualRate = 0d;
double stkQuantity = 0,holdQuantity = 0;
double holdQty = 0;
double potencyPerc=0,grossWeight=0,tareWeight=0,netWeight=0;
try
{
System.out.println("domString::{"+domString+"}");
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
conn.setAutoCommit(false);
GenericUtility genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
Timestamp date1 = Timestamp.valueOf(sdf.format(utilDate).toString() + " 00:00:00.0");
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
Timestamp currDate = java.sql.Timestamp.valueOf(sdf1.format(new java.util.Date()).toString() + " 00:00:00.0");
dom = genericUtility.parseString(domString);
siteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" );
parentNodeList = dom.getElementsByTagName("Detail3");
parentNodeListLength = parentNodeList.getLength();
// added on 25/MAR/14 BY RITESH START
loginCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginCode" );
System.out.println("********* login code ["+loginCode+"]");
sql = "SELECT EMP_CODE FROM USERS WHERE CODE = ?";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, loginCode);
rs = pstmt.executeQuery();
if( rs.next() )
{
empCode = rs.getString("EMP_CODE");
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
campaignNo= ((genericUtility.getColumnValueFromNode("campaign_no",dom.getElementsByTagName("Detail1").item(ctr))).trim());
siteCodeDom= ((genericUtility.getColumnValueFromNode("site_code",dom.getElementsByTagName("Detail2").item(ctr))).trim());
itemSer= ((genericUtility.getColumnValueFromNode("item_ser",dom.getElementsByTagName("Detail2").item(ctr))).trim());
tranDate= ((genericUtility.getColumnValueFromNode("tran_date",dom.getElementsByTagName("Detail2").item(ctr))).trim());
refSerFor= ((genericUtility.getColumnValueFromNode("ref_ser__for",dom.getElementsByTagName("Detail2").item(ctr))).trim());
System.out.println("empCode::::["+empCode+"]"+"siteCodeDom["+siteCodeDom+"] itemSer["+itemSer+"] tranDate["+tranDate+"] refSerFor["+refSerFor+"] locCodeTo["+locCodeTo+"]");
genratedTranId = generateTranId( "w_stock_transfer",siteCode, conn );
sql = "INSERT INTO STOCK_TRANSFER(SITE_CODE,ITEM_SER,REF_SER__FOR,TRAN_DATE,EMP_CODE__APRV,TRAN_ID,CONFIRMED) VALUES(?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, siteCodeDom);
pstmt.setString(2, itemSer);
pstmt.setString(3, refSerFor);
pstmt.setString(4, tranDate);
pstmt.setString(5, " ");
pstmt.setString(6, genratedTranId);
pstmt.setString(7, "N");
pstmt.executeUpdate();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
for(ctr = 0; ctr < parentNodeListLength ; ctr++ )
{
lineNo ++;
System.out.println(" parentNodeListLength - ctr ::"+ctr);
// locCodeTo= ((genericUtility.getColumnValueFromNode("loc_code__to",dom.getElementsByTagName("Detail3").item(ctr))).trim());
// System.out.println("locCodeTo :: "+locCodeTo);
// locCodeTo = genericUtility.getColumnValue("loc_code__to", dom);
// System.out.println("locCodeTo from dom ::"+locCodeTo);
parentNode = parentNodeList.item(ctr);
itemCode = genericUtility.getColumnValueFromNode("item_code", parentNode);
locCode = genericUtility.getColumnValueFromNode("loc_code", parentNode);
lotNo = genericUtility.getColumnValueFromNode("lot_no", parentNode);
lotSl = genericUtility.getColumnValueFromNode("lot_sl", parentNode);
locCodeTo = genericUtility.getColumnValueFromNode("loc_code__to", parentNode);
siteCode = genericUtility.getColumnValueFromNode("site_code", parentNode);
quantityStr = genericUtility.getColumnValueFromNode("quantity", parentNode);
list.add(locCodeTo+":"+itemCode+":"+lotNo+":"+lotSl+":"+locCode+":"+siteCode+":"+quantityStr);
if(quantityStr != null && quantityStr.trim().length() > 0)
{
quantity = Double.parseDouble(quantityStr);
}
System.out.println("ITEM CODE["+itemCode+"] SITE CODE["+siteCode+"] LOC CODE["+locCode+"] LOT_NO["+lotNo+"] LOT SL["+lotSl+"]"+"locCodeTo["+locCodeTo+"]");
sql = "select acct_code__inv, cctr_code__inv from stock where item_code = ? and site_code = ? and loc_code = ? and lot_no = ? and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
rs = pstmt.executeQuery();
if(rs.next())
{
acctCodeInv1 = rs.getString("acct_code__inv")==null?"1440":rs.getString("acct_code__inv");
cctrCodeInv1 = rs.getString("cctr_code__inv")==null?"H651":rs.getString("cctr_code__inv");
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt=null;
sql = " INSERT INTO STOCK_TRANSFER_DET(ITEM_CODE,LINE_NO,QUANTITY,REMARKS,LOC_CODE__FR,LOC_CODE__TO,LOT_NO__FR,LOT_SL__FR,LOT_NO__TO,LOT_SL__TO,ACCT_CODE__DR,ACCT_CODE__CR,CCTR_CODE__CR,CCTR_CODE__DR,TRAN_ID) "+
" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt = conn.prepareStatement( sql );
pstmt.setString(1, itemCode);
pstmt.setInt(2, lineNo);
pstmt.setDouble(3, quantity);
pstmt.setString(4, "Generated from stock transfer wip location wizard ");
pstmt.setString(5, locCode);
pstmt.setString(6, locCodeTo);
pstmt.setString(7, lotNo);
pstmt.setString(8, lotSl);
pstmt.setString(9, lotNo);
pstmt.setString(10, lotSl);
pstmt.setString(11, acctCodeInv1);
pstmt.setString(12, acctCodeInv1);
pstmt.setString(13, cctrCodeInv1);
pstmt.setString(14, cctrCodeInv1);
pstmt.setString(15, genratedTranId);
if(pstmt.executeUpdate() > 0) insertFlag = true;
else insertFlag = false;
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
System.out.println(" detailData final tree ::"+list.size()+"::"+list);
if(insertFlag)
{
conn.commit();System.out.println(" connection committed @@@@@@");
StockTransferConf stconf = new StockTransferConf();
errString = stconf.confirm(genratedTranId,xtraParams,"");
System.out.println("retString from StockTransferConf :: @:: "+errString);//CONFSUCC
if(errString.indexOf("CONFSUCC") > -1)
{
int count = 0,updInv = 0;
for(int i = 0;i <= list.size()-1;i++)
{
ArrayList errList = new ArrayList();
String detDate = (String)list.get(i);System.out.println("String detDate = "+ detDate );
String detDataArr[] = detDate.split(":");System.out.println("String detDataArr[] = "+ detDataArr );
locCodeTo = detDataArr[0];
itemCode = detDataArr[1];
lotNo = detDataArr[2];
lotSl = detDataArr[3];
locCode = detDataArr[4];
siteCode = detDataArr[5];
quantityStr = detDataArr[6];
if(quantityStr != null && quantityStr.trim().length() > 0)
{
quantity = Double.parseDouble(quantityStr);
}
stockMap.put("item_code", itemCode);
stockMap.put("site_code", siteCode);
stockMap.put("loc_code", locCode);
stockMap.put("lot_no", lotNo);
stockMap.put("lot_sl", lotSl);
// double quantity = 0.0;
// if(allocQty != null)
// {
// quantity = Double.parseDouble(allocQty);
// }
stockMap.put("quantity", ""+quantity);
String invStatLocCodeTo = "";
sql = "SELECT INV_STAT FROM LOCATION WHERE LOC_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
rs = pstmt.executeQuery();
if(rs.next())
{
invStatLocCodeTo = checkNull(rs.getString("INV_STAT"));
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
// //if(invStatLocCodeTo.trim().equalsIgnoreCase(locCodeTo.trim()) && invStatLocCodeTo.trim().equalsIgnoreCase(partialGrlLoc.trim()))
// {
// stockMap.put("no_art", allocQty);
// }
// else
// {
stockMap.put("no_art", "0");
// }
stockMap.put("tran_ser", "XFRX");
stockMap.put("acct_code__cr",acctCodeInv1);
stockMap.put("cctr_code__cr",cctrCodeInv1);
stockMap.put("acct_code_inv",acctCodeInv1);
stockMap.put("cctr_code_inv",cctrCodeInv1);
sql = "select acct_code__inv, cctr_code__inv, "
+ "exp_date, pack_code, mfg_date, site_code__mfg, "
+ "pack_instr, supp_code__mfg, retest_date, "
+ "gross_rate, rate, conv__qty_stduom, unit__alt, batch_no, batch_size, "
+ "unit, grade, remarks, dimension, quantity ,hold_qty,actual_rate ,partial_used "
+ ",potency_perc, inv_stat, gross_weight, tare_weight, net_weight, lot_sl__org "
+ "from stock "
+ "where item_code = ? "
+ "and site_code = ? "
+ "and loc_code = ? "
+ "and lot_no = ? "
+ "and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
rs = pstmt.executeQuery();
if ( rs.next() )
{
expDate = rs.getTimestamp("exp_date");
packCode = rs.getString("pack_code");
mfgDate = rs.getTimestamp("mfg_date");
siteCodeMfg = rs.getString("site_code__mfg");
packInstr = rs.getString("pack_instr");
suppCodeMfg = rs.getString("supp_code__mfg");
restestDate = rs.getTimestamp("retest_date");
stkGrossRate = rs.getDouble("gross_rate");
stkRate = rs.getDouble("rate");
System.out.println("stkGrossRate"+stkGrossRate+"stkRate"+stkRate);
convQtyStduom = rs.getDouble("conv__qty_stduom");
unitAlt = rs.getString("unit__alt");
batchNo = rs.getString("batch_no");
batchSize = rs.getDouble("batch_size");
unit = rs.getString("unit");
grade = rs.getString("grade");
remarks1 = rs.getString("remarks");
dimension = rs.getString("dimension");
stkQuantity = rs.getDouble("quantity");
holdQuantity = rs.getDouble("hold_qty");
actualRate = rs.getDouble("actual_rate");
//partialUsed = checkNull(rs.getString("partial_used"));
potencyPerc = rs.getDouble("potency_perc");
grossWeight = rs.getDouble("gross_weight");
tareWeight = rs.getDouble("tare_weight");
netWeight = rs.getDouble("net_weight");
//lotSlOrg = rs.getString("lot_sl__org");
stockMap.put("rate",Double.toString(stkRate));
stockMap.put("gross_rate",Double.toString(stkGrossRate));
System.out.println("stkGrossRate:::"+Double.toString(stkRate)+"stkRate::::"+Double.toString(stkGrossRate));
stockMap.put("tran_id", genratedTranId );
stockMap.put("tran_date",currDate );
stockMap.put("qty_stduom", ""+quantity);
stockMap.put("unit",unit);
stockMap.put("grade",grade);
stockMap.put("remarks",remarks1);
stockMap.put("dimension",dimension);
stockMap.put("tran_type", "I");
stockMap.put("exp_date", expDate);
stockMap.put("pack_code", packCode);
stockMap.put("mfg_date", mfgDate);
stockMap.put("site_code__mfg", siteCodeMfg);
stockMap.put("pack_instr", packInstr);
stockMap.put("supp_code__mfg", suppCodeMfg);
stockMap.put("retest_date", restestDate);
stockMap.put("conv__qty_stduom", ""+convQtyStduom);
stockMap.put("unit__alt", unitAlt);
stockMap.put("batch_no", batchNo);
stockMap.put("batch_size", ""+batchSize);
stockMap.put("actual_rate", actualRate);
}
if(rs != null)
rs.close();
rs = null;
if(pstmt != null)
pstmt.close();
pstmt = null;
boolean isError = false;
String retString = "";
WoTransferPrc mfgStkTrf = new WoTransferPrc();
errList = mfgStkTrf.allocTransfer(siteCode,itemCode,locCode ,
lotNo,lotSl,locCodeTo ,lotNo,lotSl,
quantity,stockMap, xtraParams , conn );
System.out.println("FROM ALLOC TRANSFER=="+errList.toString());
retString = errList.get(0).toString() ;
System.out.println("FROM ALLOCTRANSFER 0 : "+retString);
if ( retString != null && retString.trim().length() > 0 )
{
isError = true;
}
stockMap.clear();
if(isError == false)
{
conn.commit();
///////////////////////////////////////////////////////////////////
sql = " UPDATE WORKORDER_ISSDET SET LOC_CODE = ? "+
" WHERE TRAN_ID IN "+
" (SELECT TRAN_ID FROM WORKORDER_ISS " +
" WHERE "+
" WORK_ORDER "+
" IN "+
" (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? AND WORK_ORDER IN "+
" (SELECT WORK_ORDER FROM INV_ALLOCATE WHERE TRAN_ID IN "+
" (SELECT TRAN_ID FROM INV_ALLOC_DET )))) "+
" AND ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ? AND LOC_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,campaignNo);
pstmt.setString(3,itemCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
pstmt.setString(6,locCode);
count = count+pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt=null;
sql = " update inv_alloc_det set loc_code = ? where tran_id in ( SELECT TRAN_ID FROM INV_ALLOCATE WHERE WORK_ORDER IN (SELECT WORK_ORDER FROM WORKORDER WHERE CAMPGN_NO = ? )) and item_code = ? and lot_no = ? and lot_sl = ? and loc_code = ? and site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,locCodeTo);
pstmt.setString(2,campaignNo);
pstmt.setString(3,itemCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
pstmt.setString(6,locCode);
pstmt.setString(7,siteCode);
updInv = updInv+pstmt.executeUpdate();
if(pstmt != null)
pstmt.close();
pstmt = null;
} // if - mfg ctk trf
}// end of for
System.out.println( " location updated in workorder iss @ effected lines::"+count);
System.out.println( " location updated in inventory detail @ effected lines::"+count);
}
}else
{
conn.rollback();System.out.println(" connection rollback @@@@@@");
}
}
catch(Exception e)
{
try
{
conn.rollback();System.out.println(" EXCEPTION CATCHED - connection rollback @@@@@@ ");
System.out.println("Exception "+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
catch (Exception e1)
{
e1.printStackTrace();
}
}
finally
{
try
{
if( rs != null )
{
rs.close();
rs = null;
}
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
}
return errString;
}
private String generateTranId( String windowName,String siteCode, Connection conn )throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
java.sql.Timestamp currDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis());
String currDateStr = sdfAppl.format(currDate);
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + currDateStr + "</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e){}
}
System.out.println("@@@@@@@@@@@@@@@@@@@@@@tranId[[[[[[[[[[["+tranId+"]]]]]]]]]]]]]]]");
return tranId;
}//end of generateTranTd()
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
/**
DEVELOPED BY : RITESH ON 10/SEP/2014
PURPOSE : STOCK TRANSEFR FROM WIP LOCATION THROUGH WIZARD (REG : M14ESUN002)
*/
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
@javax.ejb.Local
public interface WoTrfWizPosLocal extends ValidatorLocal
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
\ No newline at end of file
/**
DEVELOPED BY : RITESH ON 10/SEP/2014
PURPOSE : STOCK TRANSEFR FROM WIP LOCATION THROUGH WIZARD (REG : M14ESUN002)
*/
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
@javax.ejb.Remote
public interface WoTrfWizPosRemote extends ValidatorRemote
{
public String postSave()throws RemoteException,ITMException;
public String postSave( String domString,String tranId, String editFlag, String xtraParams, Connection conn ) throws RemoteException,ITMException;
}
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