Commit 64e53f4e authored by manohar's avatar manohar

This commit was generated by cvs2svn to compensate for changes in r9, which

included commits to RCS files with non-trunk default branches.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91074 ce508802-f39f-4f6c-b175-0d175dae99d5
parent edf223eb
package ibase.webitm.ejb.mfg;
import java.util.ArrayList;
//import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
//import java.sql.Timestamp;
import java.text.SimpleDateFormat;
class ADPElement
{
private String itemCode;
private String siteCode;
private String routeCode;
private String suppSour;
private String bomCode;
private String itemSchedule;
private String itemStru;
private String siteCodeSupp;
private String siteCodeCust;
private String siteCodePlan;
private String orderOpt;
private String batchQtyType;
private String masterSch;
private String unit;
private String itemDescr;
private String aprCode;
private String packCode;
private String empCodePur;
private String suppCodePref;
private String acctCodePh;
private String cctrCodePh;
private String acctCodeWp;
private String cctrCodeWp;
private String itemSer;
private String mfgType;
private double minQty = 0;
private double reoQty = 0;
private double demand = 0;
private double supply = 0;
private double planDemand = 0;
private double planSupply = 0;
private double minOrderQty = 0;
private double integralQty = 0;
private double maxQty = 0;
private double minimumQty = 0;
private double reorderQty = 0;
private double yieldPerc = 100;
private double minPlanPerc = 0;
private double batchQty = 0;
private double purcRate = 0;
private int days = 0;
private int purLeadTime = 0;
private int qcLeadTime = 0;
private int mfgLeadTime = 0;
private int maxStkDay = 0;
private int minStkDay = 0;
private ArrayList timeMRPArr;
transient GenericUtility genericUtility = null;
public ADPElement()
{
//System.out.println("New ADPElement Created");
this.timeMRPArr = new ArrayList();
}
public void setItemCode(String itemCode)
{
//itemCode = itemCode.trim() + " ";
//itemCode = itemCode.substring(0,9);
this.itemCode = itemCode;
}
public String getItemCode()
{
return this.itemCode;
}
public void setSiteCode(String siteCode)
{
//siteCode = siteCode.trim() + " ";
//siteCode = siteCode.substring(0,4);
this.siteCode = siteCode;
}
public String getSiteCode()
{
return this.siteCode;
}
public void setUnit(String uom)
{
this.unit = uom;
}
public String getUnit()
{
return this.unit;
}
public void setItemDescr(String descr)
{
this.itemDescr = descr;
}
public String getItemDescr()
{
return this.itemDescr;
}
public void setItemSer(String code)
{
this.itemSer = code;
}
public String getItemSer()
{
return this.itemSer;
}
public void setAprCode(String code)
{
this.aprCode = code;
}
public String getAprCode()
{
return this.aprCode;
}
public void setPackCode(String code)
{
this.packCode = code;
}
public String getPackCode()
{
return this.packCode;
}
public void setEmpCodePur(String code)
{
this.empCodePur = code;
}
public String getEmpCodePur()
{
return this.empCodePur;
}
public void setSuppCodePref(String code)
{
this.suppCodePref = code;
}
public String getSuppCodePref()
{
return this.suppCodePref;
}
public void setAcctCodePh(String code)
{
this.acctCodePh = code;
}
public String getAcctCodePh()
{
return this.acctCodePh;
}
public void setCctrCodePh(String code)
{
this.cctrCodePh = code;
}
public String getCctrCodePh()
{
return this.cctrCodePh;
}
public void setAcctCodeWp(String code)
{
this.acctCodeWp = code;
}
public String getAcctCodeWp()
{
return this.acctCodeWp;
}
public void setCctrCodeWp(String code)
{
this.cctrCodeWp = code;
}
public String getCctrCodeWp()
{
return this.cctrCodeWp;
}
public void setMfgType(String code)
{
this.mfgType = code;
}
public String getMfgType()
{
return this.mfgType;
}
public void setPurcRate(double rate)
{
this.purcRate = rate;
}
public double getPurcRate()
{
return this.purcRate;
}
public void setDemand(java.sql.Timestamp dueDate, double demand)
{
this.demand += demand;
updateTimeMrp(dueDate, demand, 0);
}
public double getDemand()
{
return this.demand;
}
public void setSupply(java.sql.Timestamp dueDate, double supply)
{
this.supply += supply;
updateTimeMrp(dueDate, 0, supply);
}
public double getSupply()
{
return this.supply;
}
public void setPlanSupply(java.sql.Timestamp dueDate, double supply)
{
this.planSupply += supply;
updateTimeMrp(dueDate, 0, supply);
}
public double getPlanSupply()
{
return this.planSupply;
}
//added by dharmendra on 28th-dec
public void setSuppSour(String suppSour)
{
this.suppSour = suppSour;
}
public String getSuppSour()
{
return this.suppSour;
}
public void setBomCode(String bomCode)
{
this.bomCode = bomCode;
}
public String getBomCode()
{
return this.bomCode;
}
public void setRouteCode(String routeCode)
{
this.routeCode = routeCode;
}
public String getRouteCode()
{
return this.routeCode;
}
public void setMinQty(double minQty)
{
this.minQty = minQty;
}
public double getMinQty()
{
return this.minQty;
}
public void setMinStkDay(int minStkDay)
{
this.minStkDay = minStkDay;
}
public int getMinStkDay()
{
return this.minStkDay;
}
public void setReoQty(double reoQty)
{
this.reoQty = reoQty;
}
public double getReoQty()
{
return this.reoQty;
}
public void setPurLeadTime(int purLeadTime)
{
this.purLeadTime = purLeadTime;
}
public int getPurLeadTime()
{
return this.purLeadTime;
}
public void setQcLeadTime(int qcLeadTime)
{
this.qcLeadTime = qcLeadTime;
}
public int getQcLeadTime()
{
return this.qcLeadTime;
}
public void setIntegralQty(double integralQty)
{
this.integralQty = integralQty;
}
public double getIntegralQty()
{
return this.integralQty;
}
public void setItemStru(String itemStru)
{
this.itemStru = itemStru;
}
public String getItemStru()
{
return this.itemStru;
}
public void setSiteCodeSupp(String siteCodeSupp)
{
this.siteCodeSupp = siteCodeSupp;
}
public String getSiteCodeSupp()
{
return this.siteCodeSupp;
}
public void setSiteCodePlan(String siteCodePlan)
{
this.siteCodePlan = siteCodePlan;
}
public String getSiteCodePlan()
{
return this.siteCodePlan;
}
public void setSiteCodeCust(String siteCode)
{
this.siteCodeCust = siteCode;
}
public String getSiteCodeCust()
{
return this.siteCodeCust;
}
public void setBatchQtyType(String batchQtyType)
{
this.batchQtyType = batchQtyType;
}
public String getBatchQtyType()
{
return this.batchQtyType;
}
public void setMinOrderQty(double minOrderQty)
{
this.minOrderQty = minOrderQty;
}
public double getMinOrderQty()
{
return this.minOrderQty;
}
public void setMaxStkDay(int maxStkDay)
{
this.maxStkDay = maxStkDay;
}
public int getMaxStkDay()
{
return this.maxStkDay;
}
public void setMaxQty(double maxQty)
{
this.maxQty = maxQty;
}
public double getMaxQty()
{
return this.maxQty;
}
public void setOrderOpt(String orderOpt)
{
this.orderOpt = orderOpt;
}
public String getOrderOpt()
{
return this.orderOpt;
}
public void setYieldPerc(double yieldPerc)
{
this.yieldPerc = yieldPerc;
}
public double getYieldPerc()
{
return this.yieldPerc;
}
public void setMasterSch(String masterSch)
{
this.masterSch = masterSch;
}
public String getMasterSch()
{
return this.masterSch;
}
public void setMfgLeadTime(int mfgLeadTime)
{
this.mfgLeadTime = mfgLeadTime;
}
public int getMfgLeadTime()
{
return this.mfgLeadTime;
}
public void setMinPlanPerc(double minPlanPerc)
{
this.minPlanPerc = minPlanPerc;
}
public double getMinPlanPerc()
{
return this.minPlanPerc;
}
public void setBatchQty(double qty)
{
this.batchQty = qty;
}
public double getBatchQty()
{
return this.batchQty;
}
public String toString()
{
return siteCode+":"+itemCode;
}
public ArrayList getTimeMrpList()
{
return this.timeMRPArr;
}
public void setIndependentDemand(java.sql.Timestamp dueDate, double demand)
{
//this.independentDemand += demand;
updateIndependentDemand(dueDate, demand);
}
/*public double getIndependentDemand()
{
return this.independentDemand;
}*/
private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply)
{
String errString = "";
TimeMRP timeMRP = null;
genericUtility = GenericUtility.getInstance();
int timeEle = -1, ctr;
SimpleDateFormat sdt=new SimpleDateFormat("yyyy-MM-dd");
dueDate = java.sql.Timestamp.valueOf(sdt.format(dueDate) + " 00:00:00.000");
try
{
if (timeMRPArr.size() > 0)
{
for (ctr = 0; ctr < timeMRPArr.size(); ctr++)
{
timeMRP = (TimeMRP)timeMRPArr.get(ctr);
if (timeMRP.getDueDate() != null)
{
if (timeMRP.getDueDate().equals(dueDate))
{
timeEle = ctr;
break;
}
}
}
}
if (timeEle == -1)
{
timeMRP = new TimeMRP();
timeMRP.setDueDate(dueDate);
timeMRP.setDemand(demand);
timeMRP.setSupply(supply);
this.timeMRPArr.add(timeMRP);
}
else
{
timeMRP = (TimeMRP)this.timeMRPArr.get(timeEle);
timeMRP.setDemand(demand);
timeMRP.setSupply(supply);
this.timeMRPArr.set(timeEle,timeMRP);
}
updateRunningDemandSupply(dueDate);
}
catch(Exception e)
{
System.out.println("Exception :adpeLEMENT : updateTimeMrp(Date, supply, demand):...." + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
errString = e.getMessage();
}
}
private void updateRunningDemandSupply(java.sql.Timestamp dueDate)
{
int index = 0;
double runningDemand = 0;
double runningSupply = 0;
double runningPlanSupply = 0;
double planSupply = 0;
String errString = null;
TimeMRP timeMRP = null;
try
{
for (int ctr = 0; ctr < timeMRPArr.size(); ctr++)
{
timeMRP = (TimeMRP)timeMRPArr.get(ctr);
if (timeMRP.getDueDate().equals(dueDate))
{
index = ctr;
break;
}
runningDemand = runningDemand + timeMRP.getDemand();
runningSupply = runningSupply + timeMRP.getSupply();
// 10-04-2006 manoharan
runningPlanSupply = runningPlanSupply + timeMRP.getPlanSupply();
// end 10-04-2006 manoharan
}
for (int ctr = index; ctr < timeMRPArr.size(); ctr++)
{
timeMRP = (TimeMRP)timeMRPArr.get(ctr);
runningDemand = runningDemand + timeMRP.getDemand();
//runningSupply = runningSupply + timeMRP.getSupply();
runningSupply = runningSupply + timeMRP.getSupply();
timeMRP.setRunningDemand(runningDemand);
timeMRP.setRunningSupply(runningSupply);
// 10-04-2006 manoharan
planSupply = timeMRP.getPlanSupply();
runningPlanSupply = runningPlanSupply + planSupply;
timeMRP.setRunningPlanSupply(runningPlanSupply);
// end 10-04-2006 manoharan
timeMRPArr.set(ctr, timeMRP);
}
}
catch(Exception e)
{
System.out.println("Exception :RunMRPPrcEJB : updateRunningDemandSupply(Timestamp Date):...." + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
errString = e.getMessage();
}
}
private void updateIndependentDemand(java.sql.Timestamp dueDate, double demand)
{
String errString = "";
TimeMRP timeMRP = null;
genericUtility = GenericUtility.getInstance();
int timeEle = -1, ctr;
SimpleDateFormat sdt=new SimpleDateFormat("yyyy-MM-dd");
dueDate = java.sql.Timestamp.valueOf(sdt.format(dueDate) + " 00:00:00.000");
try
{
if (timeMRPArr.size() > 0)
{
for (ctr = 0; ctr < timeMRPArr.size(); ctr++)
{
timeMRP = (TimeMRP)timeMRPArr.get(ctr);
if (timeMRP.getDueDate() != null)
{
if (timeMRP.getDueDate().equals(dueDate))
{
timeEle = ctr;
break;
}
}
}
}
if (timeEle == -1)
{
timeMRP = new TimeMRP();
timeMRP.setDueDate(dueDate);
timeMRP.setIndependentDemand(demand);
this.timeMRPArr.add(timeMRP);
}
else
{
timeMRP = (TimeMRP)this.timeMRPArr.get(timeEle);
timeMRP.setIndependentDemand(demand);
this.timeMRPArr.set(timeEle,timeMRP);
}
}
catch(Exception e)
{
System.out.println("Exception :adpeLEMENT : updateTimeMrp(Date, supply, demand):...." + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
e.printStackTrace();
errString = e.getMessage();
}
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.SessionBean;
import javax.ejb.CreateException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class BatchsizeAprvIC extends ValidatorEJB implements BatchsizeAprvICLocal, BatchsizeAprvICRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
String userId = null;
String loginSite = null;
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("BatchsizeAprvICEJB is in Process..........");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : BatchsizeAprvICEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr = 0;
String columnValue = null;
String childNodeName = null;
String errCode = null;
int cnt = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
ResultSet rs1 = null;
String sql1 = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
genericUtility = GenericUtility.getInstance();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
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 ( childNodeName.equalsIgnoreCase( "valid_upto" ) )
{
String effFromStr = null;
String validUptoStr = null;
errCode = null;
validUptoStr = genericUtility.getColumnValue( "valid_upto", dom1 );
if( validUptoStr == null || validUptoStr.trim().length() == 0 )
{
errCode = "VMVUTOBLK";
errString = getErrorString( "valid_upto", errCode, userId );
}
effFromStr = genericUtility.getColumnValue( "eff_from", dom1 );
if( effFromStr == null || effFromStr.trim().length() == 0 )
{
errCode = "VMEFRMBLK";
errString = getErrorString( "eff_from", errCode, userId );
}
if ( errCode == null )
{
Timestamp effFrom = null;
Timestamp validUpto = null;
validUpto = Timestamp.valueOf(genericUtility.getValidDateString(validUptoStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
effFrom = Timestamp.valueOf(genericUtility.getValidDateString(effFromStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
if( validUpto.compareTo ( effFrom ) < 0 )
{
errCode = "EFFFROM";
}
if( errCode != null )
{
errString = getErrorString( "eff_from", errCode, userId );
}
}
if( errCode == null )
{
errCode = isValidPeriod( dom1, conn );
if( errCode != null )
{
errString = getErrorString( "valid_upto", errCode, userId );
}
}
}
if ( childNodeName.equalsIgnoreCase( "site_code" ) )
{
String siteCode = null;
siteCode = genericUtility.getColumnValue( "site_code", dom1 );
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = " SELECT COUNT(*) FROM site WHERE site_code ='" + siteCode.trim() + "'";
System.out.println( " SQL FOR site_code ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
if( cnt == 0 )
{
errCode = "VMINVSITE";
errString = getErrorString( "site_code", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
if ( childNodeName.equalsIgnoreCase( "site_code__mfg" ) )
{
String siteCodeMfh = null;
siteCodeMfh = genericUtility.getColumnValue( "site_code__mfg", dom1 );
if( siteCodeMfh != null && siteCodeMfh.trim().length() > 0 )
{
sql = " SELECT COUNT(*) FROM site WHERE site_code ='" + siteCodeMfh.trim() + "'";
System.out.println( " SQL FOR site_code__mfg ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
if( cnt == 0 )
{
errCode = "VMSTMFGINV";
errString = getErrorString( "site_code__mfg", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
if ( childNodeName.equalsIgnoreCase( "item_code" ) )
{
String itemCode = null;
itemCode = genericUtility.getColumnValue( "item_code", dom1 );
if( itemCode == null || itemCode.trim().length() == 0 )
{
errCode = "VMITEMBLK";
errString = getErrorString( "item_code", errCode, userId );
}
if( itemCode != null && itemCode.trim().length() > 0 )
{
sql = " SELECT COUNT(*) FROM item WHERE item_code ='" + itemCode.trim() + "'";
System.out.println( " SQL FOR item_code ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
errCode = "VMINVITEM";
errString = getErrorString( "item_code", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}
if ( childNodeName.equalsIgnoreCase ( "site_code" ) )
{
String siteCode = null;
siteCode = genericUtility.getColumnValue( "site_code", dom1 );
if( siteCode == null || siteCode.trim().length() == 0 )
{
errCode = "VMSITEBLK";
errString = getErrorString( "siteCode", errCode, userId );
}
}
if ( childNodeName.equalsIgnoreCase ( "site_code__mfg" ) )
{
String siteCodeMfg = null;
siteCodeMfg = genericUtility.getColumnValue( "site_code__mfg", dom1 );
if( siteCodeMfg == null || siteCodeMfg.trim().length() == 0 )
{
errCode = "VMSTMFGBLK";
errString = getErrorString( "siteCodeMfg", errCode, userId );
}
}
if ( childNodeName.equalsIgnoreCase ( "batch_size" ) )
{
String batchSize = null;
batchSize = genericUtility.getColumnValue( "batch_size", dom1 );
if( batchSize == null || batchSize.trim().length() == 0 )
{
errCode = "VMBATCHBLK";
errString = getErrorString( "batch_size", errCode, userId );
}
}
if ( childNodeName.equalsIgnoreCase ( "eff_from" ) )
{
String effFrom = null;
effFrom = genericUtility.getColumnValue( "eff_from", dom1 );
if( effFrom == null || effFrom.trim().length() == 0 )
{
errCode = "VMEFRMBLK";
errString = getErrorString( "eff_from", errCode, userId );
}
}
} //END OF FOR LOOP OF CASE1
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
errString = e.getMessage();
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < ExprProcessIcEJB > CONNECTION IS CLOSED");
}
System.out.println("ErrString ::" + errString);
return errString;
}//END OF VALIDATION
public String itemChanged( String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams ) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = null;
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
System.out.println("xmlString1" + xmlString1);
if (xmlString2.trim().length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [BatchsizeAprvICEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement vPStmt = null;
ResultSet vRs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
String loginSite = null;
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("[BatchsizeAprvICEJB] [itemChanged] :currentFormNo ....." +currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
valueXmlString.append("<Detail1>");
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals( "itm_default" ))
{
String vSql = null;
String siteDescr = null;
vSql = "select descr from site where site_code = '" + loginSite + "'";
vPStmt = conn.prepareStatement( vSql );
vRs = vPStmt.executeQuery();
if( vRs.next() )
{
siteDescr = vRs.getString( "descr" );
}
vRs.close();
vRs = null;
vPStmt.close();
vPStmt = null;
valueXmlString.append("<site_code>").append("<![CDATA[" + ( loginSite != null ? loginSite.trim() : "" )+ "]]>").append("</site_code>");
valueXmlString.append("<site_code_descr>").append("<![CDATA[" + ( siteDescr != null ? siteDescr.trim() : "" )+ "]]>").append("</site_code_descr>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + getCurrdateAppFormat() + "]]>").append("</tran_date>");
valueXmlString.append("<eff_from>").append("<![CDATA[" + getCurrdateAppFormat() + "]]>").append("</eff_from>");
}
if (currentColumn.trim().equals( "site_code" ))
{
String vSql = null;
String siteDescr = null;
vSql = "select descr from site where site_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
vPStmt = conn.prepareStatement( vSql );
vRs = vPStmt.executeQuery();
if( vRs.next() )
{
siteDescr = vRs.getString( "descr" );
}
vRs.close();
vRs = null;
vPStmt.close();
vPStmt = null;
valueXmlString.append("<site_code_descr>").append("<![CDATA[" + ( siteDescr != null ? siteDescr.trim() : "" )+ "]]>").append("</site_code_descr>");
}
if (currentColumn.trim().equals( "site_code__mfg" ))
{
String vSql = null;
String siteDescr = null;
vSql = "select descr from site where site_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
vPStmt = conn.prepareStatement( vSql );
vRs = vPStmt.executeQuery();
if( vRs.next() )
{
siteDescr = vRs.getString( "descr" );
}
vRs.close();
vRs = null;
vPStmt.close();
vPStmt = null;
valueXmlString.append("<site_mfg_descr>").append("<![CDATA[" + ( siteDescr != null ? siteDescr.trim() : "" )+ "]]>").append("</site_mfg_descr>");
}
if (currentColumn.trim().equals( "item_code" ))
{
String vSql = null;
String itemDescr = null;
vSql = "select descr from item where item_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
vPStmt = conn.prepareStatement( vSql );
vRs = vPStmt.executeQuery();
if( vRs.next() )
{
itemDescr = vRs.getString( "descr" );
}
vRs.close();
vRs = null;
vPStmt.close();
vPStmt = null;
valueXmlString.append("<item_code_descr>").append("<![CDATA[" + ( itemDescr != null ? itemDescr.trim() : "" )+ "]]>").append("</item_code_descr>");
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
}//END OF SWITCH
}//END OF TRY
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if ( vRs != null )
{
vRs.close();
vRs = null;
}
if ( vPStmt != null )
{
vPStmt.close();
vPStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}//END OF ITEMCHANGE
private String getCurrdateAppFormat()
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
private String isValidPeriod( Document dom1, Connection conn ) throws Exception
{
String itemCode = null ,
siteCodeMfg = null ,
tranId = null ,
effFrom = null ,
validUpto = null;
Timestamp effFromDate = null ,
validUptoDate = null;
int cnt = 0;
String errCode = null;
String errString = null;
String sql = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
itemCode = genericUtility.getColumnValue( "item_code", dom1 );
tranId = genericUtility.getColumnValue( "tran_id", dom1 );
siteCodeMfg = genericUtility.getColumnValue( "site_code__mfg", dom1 );
effFrom = genericUtility.getColumnValue( "eff_from" , dom1 );
validUpto = genericUtility.getColumnValue( "valid_upto" , dom1 );
effFromDate = Timestamp.valueOf(genericUtility.getValidDateString(effFrom,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())+ " 00:00:00.0");
validUptoDate = Timestamp.valueOf(genericUtility.getValidDateString(validUpto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat())+ " 00:00:00.0");
sql = " select count(*) from batchsize_aprv "
+" where site_code__mfg = '"+ siteCodeMfg +"' "
+" and item_code = '" + itemCode + "' "
+" and ( ? BETWEEN eff_from and valid_upto "
+" OR ? BETWEEN eff_from and valid_upto )";
if( tranId != null && tranId.trim().length() > 0 )
{
sql = sql + " and tran_id <> '" + tranId + "' ";
}
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, effFromDate );
pstmt.setTimestamp( 2, validUptoDate );
rs = pstmt.executeQuery();
cnt = 0;
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
if( cnt > 0 )
{
errCode = "VMINVEFUP";
errString = getErrorString( "valid_upto", errCode, userId );
}
rs.close();
rs = null;
return errCode;
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface BatchsizeAprvICLocal extends ValidatorLocal//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface BatchsizeAprvICRemote extends ValidatorRemote//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class DefaultLotIssued extends ActionHandlerEJB implements DefaultLotIssuedLocal,DefaultLotIssuedRemote // SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException {}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}*/
public String actionHandler() throws RemoteException,ITMException{return "";}
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException
{
String retString = "";
Document dom = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
dom = genericUtility.parseString(xmlString);
}
}
catch(Exception e)
{
System.out.println("Exception :DefaultLotIssuedEJB :actionHandler(String xmlString):" + e.getMessage() + ":");
throw new ITMException(e);
}
return retString;
}
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException
{
Connection conn=null;
GenericUtility genericUtility = GenericUtility.getInstance();
Document dom = null;
Document dom1 = null;
String retString = null;
try
{
System.out.println("XML String1:::"+xmlString1);
System.out.println("XML String:::"+xmlString);
System.out.println("Default function executing in progress...................");
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String:::"+xmlString);
dom = GenericUtility.getInstance().parseString(xmlString);
System.out.println("dom :"+dom);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
System.out.println("XML String1:::"+xmlString1);
dom1 = GenericUtility.getInstance().parseString(xmlString1);
System.out.println("dom1 :"+dom1);
}
System.out.println("actionType:::["+actionType+"]");
if (actionType.equalsIgnoreCase("Default"))
{
try
{
if(conn==null)
{
System.out.println("Getting Connection From Database......");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
System.out.println("Connection Established......");
DatabaseMetaData dbmd = conn.getMetaData();
System.out.println("DriverName["+dbmd.getDriverName() );
System.out.println("DriverURI["+dbmd.getURL() );
System.out.println("DriverUSER["+dbmd.getUserName() );
//System.out.println("ApplDateFormat["+genericUtility. ());
System.out.println("DBDateFormat["+genericUtility.getDBDateFormat() );
connDriver = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
retString = actionDefault(dom, dom1, objContext, xtraParams);
}
}
catch(Exception e)
{
System.out.println("Exception :Dispatch :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from DefaultLotIssuedEJB : actionHandler"+retString);
return retString;
}
private String actionDefault(Document dom, Document dom1, String objContext, String xtraParams) throws RemoteException, ITMException
{
System.out.println("Calling the Default function.........");
GenericUtility genericUtility = GenericUtility.getInstance();
Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null;
StringBuffer valueXmlString = null;
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String worder =null;
String operation = null;
int operation1 = 0;
String sql1 = null;
String sql2 = null;
int currentFormNo = 0;
String workorder = "";
int operation2 = 0;
double quantity = 0;
String lotNo ="",lotSl ="";
try
{
String detCnt = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"detCnt");
System.out.println("detCnt ...... :"+detCnt);
if(conn==null)
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver=null;
}
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[] :currentFormNo ....." +currentFormNo);
if (dom != null)
{
worder = genericUtility.getColumnValue("work_order",dom);
String worder1 =genericUtility.getColumnValue("work_order",dom1);
System.out.println("worder1 is :"+worder1);
operation = genericUtility.getColumnValue("operation",dom1); //changes by rajendra
}
if(operation == null || operation.trim().length()==0)operation="0";
operation1 = Integer.parseInt(operation);
System.out.println("operation1 is :"+operation1);
System.out.println("work order & operations are"+worder+" , "+operation);
sql1 = "SELECT b.LOT_NO,b.LOT_SL,b.QUANTITY from workorder_iss a,workorder_issdet b "
+" where a.tran_id =b.tran_id and a.work_order = '"+worder+"' ";
System.out.println("sql1 is :"+sql1);
pstmt = conn.prepareStatement(sql1);
rs = pstmt.executeQuery();
while (rs.next())
{
lotNo = rs.getString(1) == null ? "" :rs.getString(1);
lotSl = rs.getString(2) == null ? "" :rs.getString(2);
quantity =rs.getDouble(3);
System.out.println("lotNo is :"+lotNo);
System.out.println("lotSl is :"+lotSl);
System.out.println("quantity is :"+quantity);
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<work_order>").append("<![CDATA[").append(worder.trim()).append("]]>").append("</work_order>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append("<![CDATA[").append(lotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<iss_qty>").append("<![CDATA[").append(quantity).append("]]>").append("</iss_qty>\r\n");
valueXmlString.append("<no_art>").append("<![CDATA[").append("1").append("]]>").append("</no_art>\r\n");
valueXmlString.append("</Detail>\r\n");
}
pstmt.close();
valueXmlString.append("</Root>");
pstmt = null;
}//tryBase1 greyd
catch(SQLException sqx)
{
System.out.println("The Exception caught from DefaultLotIssuedEJB :"+sqx);
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The Exception caught from DefaultLotIssuedEJB :"+e);
throw new ITMException(e);
}
finally
{
try
{
conn.close();
conn = null;
}catch(Exception e){}
}
System.out.println("valueXmlString.toString() :"+valueXmlString.toString());
return valueXmlString.toString();
}
}//end of Ejb
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface DefaultLotIssuedLocal extends ActionHandlerLocal//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface DefaultLotIssuedRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
//import java.sql.Timestamp;
public class DistDemand
{
public String siteCode = "";
public String itemCode = "";
public String unit = "";
public String siteCodeSrc = "";
public String status = "T";
public String chgUser = "";
public String chgTerm = "";
public double qtyRequired = 0;
public java.sql.Timestamp tranDate = null;
public java.sql.Timestamp planDueDate = null;
public java.sql.Timestamp dueDateOrd = null;
public java.sql.Timestamp dueDate = null;
public java.sql.Timestamp chgDate = new java.sql.Timestamp(System.currentTimeMillis());
public DistDemand()
{
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
//import java.rmi.RemoteException;
//import java.util.*;
//import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
//import javax.xml.parsers.*;
//import javax.ejb.*;
//import javax.naming.InitialContext;
//import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
//import ibase.webitm.utility.TransIDGenerator;
//import ibase.ejb.*;
//import ibase.system.config.*;
import java.text.SimpleDateFormat;
//import ibase.utility.CommonConstants;
//import java.sql.*;
//import java.lang.*;
//import ibase.webitm.ejb.mfg.*;
import java.text.NumberFormat;
import java.text.DecimalFormat;
import ibase.system.config.*;
import ibase.webitm.ejb.sys.UtilMethods; // 10/12/07 manoharan
public class ExplodeBom
{
//*************** change all decalaration properly
// ************** null / empty string checking not proper
String errString = "",matchPotency ="";
String siteCode = "",adjPotency ="";
String itemCode = "",usageType="";
String itemCodeBomDet = "",allocateType ="";
String lineType = "",locUsageType="";
String bomCode = "",considerLotNoIssue ="";
String bomCodeInner = "",item_type ="";
String bomCodeItem = "",item_ser ="";
String unit = "",unit_ref ="";
String reqType = "";
String itemRef = "";
String suppSour = "";
String suppSourInner = "";
String suppSourItem = "";
String lineTypeInner = "";
String sDueDate = "";
String isDueDate = "";
String sQuantity = "";
String critItem= "";
String exp_lev = "";
String xml_exp_lev ="";
String itemActive = null;
String siteItemActive = null;
int pevoper = 0;
SimpleDateFormat simpleDateFormat = null;
double perQty = 0,minPotencyPerc =0,netWeight =0;
double refQty = 0;
double minQty = 0;
double quantity = 0;
double quantityUpdate = 0;
double batchQty = 0;
double roundTo = 0;
char round;
//int mfgLeadTime = 0; comment by rajendra 14/04/07
//int qcLeadTime = 0;
///int leadTime = 0;
double dpurLeadTime =0;
double dmfgLeadTime =0;
double dqcLeadTime =0;
double dleadTime =0;
double mfgLeadTime =0;
double qcLeadTime =0;
double leadTime =0;
int count = 0;
int operation = 0;
int ctr = 0;
java.sql.Timestamp dueDate = null;
java.sql.Timestamp idueDate = null;
java.sql.Date tmpDate = null;
Document dom;
UtilMethods utilMethods = null;
transient GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
// public String explodeBom(String xmlString, Connection conn)//Commented by Jiten as per Kandarp Sir 13/11/06 - Connenction to be opened and to be closed here
public String explodeBom(String xmlString)//Added by Jiten 13/11/06 -
{
utilMethods = new UtilMethods(); // 10/12/07 manoharan
genericUtility = GenericUtility.getInstance();
StringBuffer valueXmlString = new StringBuffer("<Root>");
PreparedStatement pstmt = null;
PreparedStatement pstmtInner = null;
PreparedStatement pstmtLead = null;
ResultSet rs = null;
ResultSet rsInner = null;
ResultSet rsLead = null;
Connection conn = null;//Added by Jiten 13/11/06 -
ConnDriver connDriver = new ConnDriver();//Added by Jiten 13/11/06 -
int iLeadTime = 0;
int iiLeadTime = 0;
String sqlLead = null;
try
{
conn = connDriver.getConnectDB("DriverITM");//Added by Jiten 13/11/06 -
dom = genericUtility.parseString(xmlString);
siteCode = genericUtility.getColumnValue("site_code",dom);
itemCode = genericUtility.getColumnValue("item_code",dom);
lineType = genericUtility.getColumnValue("line_type",dom);
sQuantity = genericUtility.getColumnValue("quantity",dom);
quantity = Double.parseDouble(sQuantity);
bomCode = genericUtility.getColumnValue("bom_code",dom);
sDueDate = genericUtility.getColumnValue("due_date",dom);
exp_lev = genericUtility.getColumnValue("exp_lev",dom);
//mfgLeadTime = Integer.parseInt( genericUtility.getColumnValue("mfg_lead_time",dom) ); //comment by rajendra
//qcLeadTime = Integer.parseInt( genericUtility.getColumnValue("qc_lead_time",dom) ); //comment by rajendra
mfgLeadTime = Double.parseDouble( genericUtility.getColumnValue("mfg_lead_time",dom) );
qcLeadTime = Double.parseDouble( genericUtility.getColumnValue("qc_lead_time",dom) );
dueDate = java.sql.Timestamp.valueOf(sDueDate + " 00:00:00");
leadTime = mfgLeadTime + qcLeadTime;
iLeadTime = (int)leadTime;
//System.out.println("Due Date Before.........."+dueDate) ;
//dueDate = utilMethods.RelativeDate(dueDate, iLeadTime * -1); // 10/12/07 manoharan
//System.out.println("Due Date After..........."+dueDate) ;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getDBDateFormat());
sDueDate = simpleDateFormat.format(dueDate);
String sql = null;
String sqlInner = null;
/* 11-08-2007 manoharan siteitem no mandatory to be taken out
sql = "SELECT A.ITEM_CODE , A.ITEM_REF, C.UNIT, C.BATCH_QTY, A.QTY_PER, "
+ "A.REQ_TYPE, A.MIN_QTY,A.OPERATION,A.CRIT_ITEM,"
+ "A.ROUND,A.ROUND_TO, "
+ " A.MATCH_POTENCY,A.MIN_POTENCY_PERC,A.ADJ_POTENCY,A.USAGE_TYPE,A.ALLOCATE_TYPE ,"
+" LOC_USAGE_TYPE,CONSIDER_LOT_NO__ISSUE "
+ "FROM BOMDET A , SITEITEM B, BOM C "
+ "WHERE A.ITEM_CODE = B.ITEM_CODE "
+ "AND A.BOM_CODE = C.BOM_CODE "
+ "AND A.BOM_CODE = ? "
+ "AND B.SITE_CODE = ? "
+ "AND CASE WHEN B.ACTIVE IS NULL THEN 'Y' ELSE B.ACTIVE END = 'Y' "
+ "ORDER BY A.OPERATION, A.ITEM_REF, A.ITEM_CODE ";
*/
sql = " SELECT BOMDET.ITEM_CODE , BOMDET.ITEM_REF , ITEM.UNIT , BOM.BATCH_QTY , BOMDET.QTY_PER , "
+ " BOMDET.REQ_TYPE , BOMDET.MIN_QTY , BOMDET.OPERATION , BOMDET.CRIT_ITEM , BOMDET.ROUND , "
+ " BOMDET.ROUND_TO , BOMDET.MATCH_POTENCY , BOMDET.MIN_POTENCY_PERC , BOMDET.ADJ_POTENCY , "
+ " BOMDET.USAGE_TYPE , BOMDET.ALLOCATE_TYPE , BOMDET.LOC_USAGE_TYPE , BOMDET.CONSIDER_LOT_NO__ISSUE ,"
+ " ITEM.ACTIVE "
+ " FROM BOMDET LEFT OUTER JOIN ITEM ON BOMDET.ITEM_CODE = ITEM.ITEM_CODE , BOM "
+ " WHERE BOMDET.BOM_CODE = BOM.BOM_CODE "
+ " AND BOM.BOM_CODE = ? "
+ " ORDER BY BOMDET.OPERATION, BOMDET.ITEM_REF, BOMDET.ITEM_CODE ";
// end 11-08-2007 manoharan
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomCode);
//pstmt.setString(2,siteCode);
rs = pstmt.executeQuery();
//System.out.println("Exploding " + siteCode + " " + itemCode + " " + bomCode +" for " + sQuantity );
while (rs.next())
{
itemCodeBomDet = rs.getString(1);
itemRef = rs.getString(2);
unit = rs.getString(3);
batchQty = rs.getDouble(4);
perQty = rs.getDouble(5);
reqType = rs.getString(6);
minQty = rs.getDouble(7);
operation = rs.getInt(8);
critItem = rs.getString(9);
round = rs.getString(10).charAt(0);
roundTo = rs.getDouble(11);
//added field by rajendra on 14/06/07
matchPotency = rs.getString(12);
minPotencyPerc = rs.getDouble(13);
adjPotency =( rs.getString(14) ==null ? "" :rs.getString(14) );
usageType = rs.getString(15);
allocateType = rs.getString(16);
locUsageType = rs.getString(17);
considerLotNoIssue = rs.getString(18);
// 11-08-2007 manoharan
itemActive = rs.getString("ACTIVE");
if (itemActive == null)
{
itemActive = "Y";
}
sqlInner = "SELECT SUPP_SOUR, BOM_CODE ,UNIT,NET_WEIGHT,item_type,item_ser " //added unit,NET_WEIGHT by rajendra
+ "FROM ITEM "
+ "WHERE ITEM_CODE = ?";
pstmtInner = conn.prepareStatement(sqlInner);
pstmtInner.setString(1,itemCodeBomDet);
rsInner = pstmtInner.executeQuery();
if (rsInner.next())
{
suppSourItem = rsInner.getString(1);
bomCodeItem = rsInner.getString(2);
unit = rsInner.getString(3);
netWeight = rsInner.getDouble(4);
item_type =rsInner.getString(5);
item_ser =rsInner.getString(6);
//System.out.println("unit.........."+unit) ;
//System.out.println("netWeight.........."+netWeight) ;
}
rsInner.close();
rsInner = null;//Added by JIten 13/11/06 -
pstmtInner.close();
pstmtInner = null;//Added by JIten 13/11/06 -
sqlInner = "SELECT SUPP_SOUR, BOM_CODE, ACTIVE "
+ "FROM SITEITEM "
+ "WHERE SITE_CODE = ? "
+ "AND ITEM_CODE = ? ";
pstmtInner = conn.prepareStatement(sqlInner);
pstmtInner.setString(1,siteCode);
pstmtInner.setString(2,itemCodeBomDet);
rsInner = pstmtInner.executeQuery();
//rsInner = pstmtInner.executeQuery();//Commented by Jiten as this is repeated - 13/11/06
if (rsInner.next())
{
suppSourInner = rsInner.getString(1);
bomCodeInner = rsInner.getString(2);
siteItemActive = rsInner.getString("ACTIVE");
if( (suppSourInner == null) || (suppSourInner.trim().length() == 0) )
{
suppSourInner = suppSourItem;
}
if( (bomCodeInner == null) || (bomCodeInner.trim().length() == 0) )
{
bomCodeInner = bomCodeItem;
}
}
suppSourInner= suppSourInner.trim();
rsInner.close();
rsInner = null;//Added by Jiten 13/11/06 -
pstmtInner.close();
pstmtInner = null;//Added by Jiten 13/11/06 -
if (siteItemActive == null)
{
siteItemActive = "Y";
}
if ("N".equalsIgnoreCase(itemActive) || "N".equalsIgnoreCase(siteItemActive) )
{
continue;
}
// end 11-08-2007 manoharan
//siteItemActive = null;
//added by rajendra 6/04/07
if(pevoper != operation){
ctr =1;
pevoper = operation;
//System.out.println("pevoper........." +pevoper);
}
if(exp_lev == null){
xml_exp_lev = operation +"."+ctr+".";
//System.out.println("xml_exp_lev...when exp_lev is null......" +xml_exp_lev);
}else{
xml_exp_lev = xml_exp_lev +"."+ctr+".";
//System.out.println("xml_exp_lev........." +xml_exp_lev);
}
ctr++;
//end by rajendra
//System.out.println("Item Code : " + itemCodeBomDet + "Item Ref : " + itemRef + " Line Type " + lineType);
if (lineType.equals("B"))
{
if (reqType.equals("S"))
{
quantityUpdate = (quantity / batchQty) * perQty;
}
else if (reqType.equals("P"))
{
quantityUpdate = (perQty / batchQty) * quantity;
}
else if (reqType.equals("F"))
{
quantityUpdate = perQty;
}
//System.out.println("Qty :" + quantity + " Batch Qty :" + batchQty + " Item Ref : " + itemRef + " Qty Per " + perQty + " Req Type " + reqType + " Qty Update :" + quantityUpdate);
quantityUpdate = itmDBAccessEJB.getRndamt(quantityUpdate, round, roundTo);
if (quantityUpdate < minQty)
{
quantityUpdate = minQty;
}
}
else
{
quantityUpdate = quantity;
}
// check for bom or item if bom explode further
/* 11-08-2007 manoharan commented and taken up as was required to check the active flag
sqlInner = "SELECT SUPP_SOUR, BOM_CODE ,UNIT,NET_WEIGHT,item_type,item_ser " //added unit,NET_WEIGHT by rajendra
+ "FROM ITEM "
+ "WHERE ITEM_CODE = ?";
pstmtInner = conn.prepareStatement(sqlInner);
pstmtInner.setString(1,itemCodeBomDet);
rsInner = pstmtInner.executeQuery();
if (rsInner.next())
{
suppSourItem = rsInner.getString(1);
bomCodeItem = rsInner.getString(2);
unit = rsInner.getString(3);
netWeight = rsInner.getDouble(4);
item_type =rsInner.getString(5);
item_ser =rsInner.getString(6);
System.out.println("unit.........."+unit) ;
System.out.println("netWeight.........."+netWeight) ;
}
rsInner.close();
rsInner = null;//Added by JIten 13/11/06 -
pstmtInner.close();
pstmtInner = null;//Added by JIten 13/11/06 -
sqlInner = "SELECT SUPP_SOUR, BOM_CODE "
+ "FROM SITEITEM "
+ "WHERE SITE_CODE = ? "
+ "AND ITEM_CODE = ? ";
pstmtInner = conn.prepareStatement(sqlInner);
pstmtInner.setString(1,siteCode);
pstmtInner.setString(2,itemCodeBomDet);
rsInner = pstmtInner.executeQuery();
//rsInner = pstmtInner.executeQuery();//Commented by Jiten as this is repeated - 13/11/06
if (rsInner.next())
{
suppSourInner = rsInner.getString(1);
bomCodeInner = rsInner.getString(2);
if( (suppSourInner == null) || (suppSourInner.trim().length() == 0) )
{
suppSourInner = suppSourItem;
}
if( (bomCodeInner == null) || (bomCodeInner.trim().length() == 0) )
{
bomCodeInner = bomCodeItem;
}
}
rsInner.close();
rsInner = null;//Added by Jiten 13/11/06 -
pstmtInner.close();
pstmtInner = null;//Added by Jiten 13/11/06 -
*/
sqlInner = "SELECT COUNT(1) FROM ITEM WHERE ITEM_CODE = ? ";
pstmtInner = conn.prepareStatement(sqlInner);
pstmtInner.setString(1,itemCodeBomDet);
rsInner = pstmtInner.executeQuery();
if (rsInner.next())
{
count = rsInner.getInt(1);
rsInner.close();
rsInner = null;//Added by Jiten 13/11/06 -
if (count == 0)
{
pstmtInner.close();
pstmtInner = null;//Added by JIten 13/11/06 -
sqlInner = "SELECT COUNT(1) FROM BOM WHERE BOM_CODE = ? ";
pstmtInner = conn.prepareStatement(sqlInner);
pstmtInner.setString(1,itemCodeBomDet);
rsInner = pstmtInner.executeQuery();
if (rsInner.next())
{
count = rsInner.getInt(1);
if(count != 0)
{
lineTypeInner = "B";
}
else
{
errString = itmDBAccessEJB.getErrorString("","VTITEM1","","",conn);
return errString;
}
}
rsInner.close();
rsInner = null;//Added by Jiten 13/11/06 -
pstmtInner.close();
pstmtInner = null;//Added by Jiten 13/11/06 -
}
else if (count > 0)
{
pstmtInner.close();
pstmtInner = null;//Added by Jiten 13/11/06 -
sqlInner = "SELECT ITEM_STRU FROM ITEM WHERE ITEM_CODE = ?";
pstmtInner = conn.prepareStatement(sqlInner);
pstmtInner.setString(1,itemCode);
rsInner = pstmtInner.executeQuery();
if (rsInner.next())
{
lineTypeInner = rsInner.getString(1);
if (!lineTypeInner.equals("F"))
{
lineTypeInner = "I";
}
}
rsInner.close();
rsInner = null;//Added by Jiten 13/11/06 -
pstmtInner.close();
pstmtInner = null;//Added by Jiten 13/11/06 -
}
}
else//Added by Jiten 13/11/06 -
{
rsInner.close();
rsInner = null;
pstmtInner.close();
pstmtInner = null;
}
//System.out.println("Qty :" + quantity + " Batch Qty :" + batchQty + " Item Ref : " + itemRef + " Qty Per " + perQty + " Req Type " + reqType + " Qty Update :" + quantityUpdate);
//System.out.println(" Item " + itemCodeBomDet+ " Qty Per " + decFormat(perQty) + " Req Type " + reqType + " Qty Update :" + decFormat(quantityUpdate) );
valueXmlString.append("<Detail>");
valueXmlString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>");
valueXmlString.append("<bom_code>").append("<![CDATA[").append(bomCode).append("]]>").append("</bom_code>");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCodeBomDet).append("]]>").append("</item_code>");
valueXmlString.append("<item_Ref>").append("<![CDATA[").append(itemRef).append("]]>").append("</item_Ref>");
valueXmlString.append("<quantity_Ref>").append("<![CDATA[").append(sQuantity).append("]]>").append("</quantity_Ref>"); //add by rajendra
valueXmlString.append("<quantity>").append("<![CDATA[").append(quantityUpdate).append("]]>").append("</quantity>"); //add by rajendra
// 24/12/07 manoharan for supp_sour = 'P'
//if ( lineTypeInner.equals("B") )
//{
// valueXmlString.append("<due_date>").append("<![CDATA[").append(sDueDate).append("]]>").append("</due_date>"); //add by rajendra
//}
//else
//{
sqlLead = "SELECT PUR_LEAD_TIME, QC_LEAD_TIME, MFG_LEAD_TIME "
+ "FROM SITEITEM "
+ "WHERE SITE_CODE = ? "
+ "AND ITEM_CODE = ? ";
pstmtLead = conn.prepareStatement(sqlLead);
pstmtLead.setString(1,siteCode);
pstmtLead.setString(2,itemCodeBomDet);
rsLead = pstmtLead.executeQuery();
if (rsLead.next())
{
dpurLeadTime = rsLead.getDouble(1);
dqcLeadTime = rsLead.getDouble(2);
dmfgLeadTime = rsLead.getDouble(3);
pstmtLead.close();
rsLead.close();
}
else
{
sqlLead = "SELECT PUR_LEAD_TIME, QC_LEAD_TIME, MFG_LEAD "
+ "FROM ITEM "
+ "WHERE ITEM_CODE = ? ";
pstmtLead = conn.prepareStatement(sqlLead);
pstmtLead.setString(1,itemCodeBomDet);
rsLead = pstmtLead.executeQuery();
if (rsLead.next())
{
dpurLeadTime = rsLead.getDouble(1);
dqcLeadTime = rsLead.getDouble(2);
dmfgLeadTime = rsLead.getDouble(3);
pstmtLead.close();
rsLead.close();
}
}
if ( "P".equals(suppSourInner) )
{
dleadTime = dpurLeadTime + dqcLeadTime;
}
else
{
dleadTime = dmfgLeadTime + dqcLeadTime;
}
/*if ( lineTypeInner.equals("B") )
{
dleadTime = dmfgLeadTime + dqcLeadTime;
}
else
{
dleadTime = dpurLeadTime + dqcLeadTime;
}*/
iiLeadTime = (int)dleadTime;
//System.out.println("Due Date Before Inner.........."+dueDate) ;
//idueDate = java.sql.Timestamp.valueOf(sDueDate + " 00:00:00");
idueDate = utilMethods.RelativeDate(dueDate, iiLeadTime * -1); // 10/12/07 manoharan
//System.out.println("Item.........."+itemCodeBomDet + " pur ..."+ dpurLeadTime + " qc " + dqcLeadTime + " mfg " +dmfgLeadTime + " lead " +dleadTime ) ;
//System.out.println("suppSourInner..................."+suppSourInner);
//System.out.println("Due Date After Inner..........."+idueDate) ;
simpleDateFormat = new SimpleDateFormat(genericUtility.getDBDateFormat());
isDueDate = simpleDateFormat.format(idueDate);
valueXmlString.append("<due_date>").append("<![CDATA[").append(isDueDate).append("]]>").append("</due_date>"); //add by rajendra
//}
// end 24/12/07 manoharan
valueXmlString.append("<exp_lev>").append("<![CDATA[").append(xml_exp_lev).append("]]>").append("</exp_lev>"); //add by rajendra
valueXmlString.append("<operation>").append("<![CDATA[").append(operation).append("]]>").append("</operation>"); //add by rajendra
valueXmlString.append("<crit_Item>").append("<![CDATA[").append(critItem).append("]]>").append("</crit_Item>"); //add by rajendra
valueXmlString.append("<line_type>").append("<![CDATA[").append(lineTypeInner).append("]]>").append("</line_type>");
valueXmlString.append("</Detail>");
if ( lineTypeInner.equals("B") )
{
simpleDateFormat = new SimpleDateFormat(genericUtility.getDBDateFormat());
sDueDate = simpleDateFormat.format(dueDate);
StringBuffer tempXMLString = new StringBuffer("<Root>");
tempXMLString.append("<Detail>");
tempXMLString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>");
tempXMLString.append("<item_code>").append("<![CDATA[").append(itemCodeBomDet).append("]]>").append("</item_code>");
tempXMLString.append("<quantity>").append("<![CDATA[").append(quantityUpdate).append("]]>").append("</quantity>");
tempXMLString.append("<bom_code>").append("<![CDATA[").append(bomCodeInner).append("]]>").append("</bom_code>"); //add by rajendra
tempXMLString.append("<quantity_Ref>").append("<![CDATA[").append(sQuantity).append("]]>").append("</quantity_Ref>"); //add by rajendra
tempXMLString.append("<item_Ref>").append("<![CDATA[").append(itemRef).append("]]>").append("</item_Ref>"); //add by rajendra
tempXMLString.append("<line_type>").append("<![CDATA[").append(lineTypeInner).append("]]>").append("</line_type>");
tempXMLString.append("<due_date>").append("<![CDATA[").append(isDueDate).append("]]>").append("</due_date>");
tempXMLString.append("<operation>").append("<![CDATA[").append(operation).append("]]>").append("</operation>"); //add by rajendra
tempXMLString.append("<exp_lev>").append("<![CDATA[").append(xml_exp_lev).append("]]>").append("</exp_lev>"); //add by rajendra
tempXMLString.append("<crit_Item>").append("<![CDATA[").append(critItem).append("]]>").append("</crit_Item>"); //add by rajendra
tempXMLString.append("<mfg_lead_time>").append("<![CDATA[").append(dmfgLeadTime).append("]]>").append("</mfg_lead_time>");
tempXMLString.append("<qc_lead_time>").append("<![CDATA[").append(dqcLeadTime).append("]]>").append("</qc_lead_time>");
tempXMLString.append("</Detail>");
tempXMLString.append("</Root>");
//errString = explodeBom(tempXMLString.toString(), conn);//Commented by Jiten 13/11/06 -
errString = explodeBom(tempXMLString.toString()); // Added by Jiten 13/11/06 -
if ( errString != null && errString.trim().length() > 0 )
{
System.out.println("Error While Exploding Bom Further:..."+errString);
//return errString;
errString = errString.replaceAll("<Root>","");
errString = errString.replaceAll("</Root>","");
valueXmlString.append(errString);
errString = "";
}
}
}//loop end
valueXmlString.append("</Root>");
//rs.close(); //Below three lines commented by Jiten 31/10/06
//pstmtInner.close();
//pstmt.close();
}
catch(SQLException se)
{
System.out.println("SQLException : ExplodeBom :explodeBom()" +se.getMessage());
se.printStackTrace();
errString = se.getMessage();
}
catch(Exception e)
{
System.out.println("Exception :ExplodeBom :explodeBom():" + e.getMessage() + ":");
this.errString = genericUtility.createErrorString(e);
e.printStackTrace();
errString = e.getMessage();
}
finally
{
try{
if(rs != null){//Added by Jiten 13/11/06 -
rs.close();
rs = null;
}
if(conn != null){//Added by Jiten 13/11/06 -
conn.close();
conn = null;
}
if (pstmt != null) { pstmt = null; }
if (pstmtInner != null) { pstmtInner = null; }
if (pstmtInner != null) { pstmtInner = null; }
if (rs != null) { rs = null; }
if (rsInner != null) { rsInner = null; }
}catch(Exception e){}
/*if( (errString != null) && (errString.length() > 0) )
return errString;
else
return valueXmlString.toString();*/
}
return valueXmlString.toString();
}
private String decFormat(double num)
{
NumberFormat nf = new DecimalFormat("##############0.000");
nf.setMaximumFractionDigits(3);
//nf.setMaximumIntegerDigits(10);
return nf.format(num);
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.text.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class ForecastTechIC extends ValidatorEJB implements ForecastTechICLocal,ForecastTechICRemote// SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("EpaymentICEJB is in Process..........");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}
public String wfValData() throws RemoteException,ITMException
{
return "";
}*/
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
System.out.println("xmlString:::"+xmlString);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : EpaymentICEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr = 0;
String startDate = null,endDate = null;
String columnValue = null;
String childNodeName = null;
String errCode = null;
String userId = null,loginSite = null;
String prdtCode = null;
int cnt = 0;
int currentFormNo = 0;
int childNodeListLength;
Connection conn = null;
PreparedStatement pstmt=null;
ResultSet rs = null;
String sql = null;
String orderDateStr = null;
String tranDateStr = null;
int resultCount = 0;
String templateFile = null;
String exprNo = null;
ConnDriver connDriver = new ConnDriver();
try
{
System.out.println( "wfValData called" );
conn = connDriver.getConnectDB("DriverITM");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
genericUtility = GenericUtility.getInstance();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
System.out.println("VALIDATION FOR DETAIL [ 1 ]..........");
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 ( childNodeName.equalsIgnoreCase( "site_code" ) )
{
String siteCode = null;
siteCode = genericUtility.getColumnValue( "site_code", dom, "1" );
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = " SELECT COUNT(*) FROM site WHERE site_code ='" + siteCode.trim() + "'";
System.out.println( " SQL FOR custCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Site invalid or not found <==== ");
errCode = "VMINVSITE";
errString = getErrorString( "SITE_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
errCode = "VMSITEBLK";
errString = getErrorString( "SITE_CODE", errCode, userId );
}
}
if ( childNodeName.equalsIgnoreCase( "valid_upto" ) )
{
java.util.Date effFrom = null;
java.util.Date validUpto = null;
String effFromStr = null;
String validUptoStr = null;
SimpleDateFormat sdf = null;
sdf = new SimpleDateFormat( genericUtility.getApplDateFormat() );
validUptoStr = getColumnValue( "valid_upto", dom );
effFromStr = getColumnValue( "eff_from", dom );
if( effFromStr == null || effFromStr.trim().length() == 0 )
{
errCode = "VMEFFDTBLK";
errString = getErrorString("eff_from",errCode,userId);
break;
}
if( validUptoStr == null || validUptoStr.trim().length() == 0 )
{
errCode = "VMVLDUPBLK";
errString = getErrorString("valid_upto",errCode,userId);
break;
}
if( effFromStr != null && validUptoStr != null )
{
effFrom = sdf.parse( effFromStr );
validUpto = sdf.parse( validUptoStr );
if( validUpto.before( effFrom ))
{
errCode = "VMVALUPTGT";
errString = getErrorString("valid_upto",errCode,userId);
break;
}
}
}
if ( childNodeName.equalsIgnoreCase( "eff_from" ) )
{
java.util.Date effFrom = null;
java.util.Date tranDt = null;
String effFromStr = null;
SimpleDateFormat sdf = null;
sdf = new SimpleDateFormat( genericUtility.getApplDateFormat() );
effFromStr = getColumnValue( "eff_from", dom );
tranDateStr = getColumnValue( "tran_date", dom );
if( effFromStr == null || effFromStr.trim().length() == 0 )
{
errCode = "VMEFFDTBLK";
errString = getErrorString( "eff_from", errCode, userId);
break;
}
if( effFromStr != null && tranDateStr != null )
{
effFrom = sdf.parse( effFromStr );
tranDt = sdf.parse( tranDateStr );
if( effFrom.before( tranDt ) )
{
errCode = "VMEFFDTLS";
errString = getErrorString( "eff_from", errCode, userId );
break;
}
}
}
}
//END OF CASE1
break;
case 2 :
System.out.println("VALIDATION FOR DETAIL [ 2 ]..........");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
cnt = 0;
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if ( childNodeName.equalsIgnoreCase( "item_code" ) )
{
String itemCode = null;
itemCode = genericUtility.getColumnValue( "item_code", dom, "2" );
errCode = null;
System.out.println(" itemCode =====> [" + itemCode + "]");
if( itemCode != null && itemCode.trim().length() > 0 )
{
sql = " SELECT COUNT(*) FROM item WHERE item_code ='" + itemCode.trim() + "'";
System.out.println( " SQL FOR item ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt( 1 );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Item Code Invalid <==== ");
errCode = "VMINVITEM";
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
if( errCode != null )
{
errString = getErrorString( "item_code", errCode, userId );
}
}else if( childNodeName.equalsIgnoreCase( "site_code" ) )
{
String siteCode = null;
siteCode = genericUtility.getColumnValue( "site_code", dom, "2" );
if( siteCode != null && siteCode.trim().length() > 0 )
{
sql = " SELECT COUNT(*) cnt FROM site WHERE site_code ='" + siteCode.trim() + "'";
System.out.println( " SQL FOR siteCode ====> " + sql );
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
if( rs.next() )
{
cnt = rs.getInt( "cnt" );
}
System.out.println(" COUNT =====> [" + cnt + "]");
if( cnt == 0 )
{
System.out.println(" ====> Site invalid or not found <==== ");
errCode = "VMINVSITE";
errString = getErrorString( "SITE_CODE", errCode, userId );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
}else if( childNodeName.equalsIgnoreCase( "qty_perc" ) )
{
String qtyPerc = null;
String calcType = null;
double totalPerc = 0.0;
double percVal = 0.0;
qtyPerc = genericUtility.getColumnValue( "qty_perc", dom, "2" );
calcType = genericUtility.getColumnValue( "calc_type", dom, "2" );
calcType = calcType == null ? "" : calcType;
if( qtyPerc != null && qtyPerc.trim().length() > 0 && !( calcType.indexOf( "U" ) > -1 || calcType.indexOf( "A" ) > -1 ) )
{
String qtyPercArr[] = null;
qtyPercArr = qtyPerc.split( "," );
int qtyPercArrLen = qtyPercArr.length;
for( int percIdx = 0; percIdx < qtyPercArrLen; percIdx++ )
{
try
{
percVal = Double.parseDouble( qtyPercArr[ percIdx ].trim() );
if( percVal < 0 )
{
errCode = "VMNEGPERC";
}
else
{
totalPerc += percVal;
}
}
catch( Exception ex )
{
errCode = "VMINVPERC";
}
}
if( totalPerc > 100 )
{
errCode = "VMPERCGT";
}
if( errCode != null )
{
errString = getErrorString( "qty_perc", errCode, userId );
}
}
if( qtyPerc != null && qtyPerc.trim().length() > 0 && ( calcType.indexOf( "U" ) > -1 || calcType.indexOf( "A" ) > -1 ) )
{
errCode = "VMNOPERC";
errString = getErrorString( "qty_perc", errCode, userId );
}
}else if ( childNodeName.trim().equals( "calc_type" ) )
{
String calcType = null;
String qtyPerc = null;
qtyPerc = genericUtility.getColumnValue( "qty_perc", dom, "2" );
calcType = genericUtility.getColumnValue( "calc_type", dom, "2" );
if( calcType != null && ( calcType.indexOf( "P" ) > -1 || calcType.indexOf( "W" ) > -1 ) && ( qtyPerc == null || qtyPerc.trim().length() == 0 ))
{
errCode = "VMPERCBLK";
errString = getErrorString( "qty_perc", errCode, userId );
}
else if( calcType == null || calcType.trim().length() == 0 )
{
errCode = "VMCALCBLK";
errString = getErrorString( "calc_type", errCode, userId );
}
}else if ( childNodeName.trim().equals( "cal_method" ) )
{
String calcType = null;
String calMethod = null;
calMethod = genericUtility.getColumnValue( "cal_method", dom, "2" );
calcType = genericUtility.getColumnValue( "calc_type", dom, "2" );
if( calcType != null && !( calcType.indexOf( "U" ) > -1 )
&& ( calMethod != null && calMethod.trim().length() > 0 ) )
{
errCode = "VMNOCALM";
errString = getErrorString( "cal_method", errCode, userId );
}
else if( calcType == null || calcType.trim().length() == 0 )
{
errCode = "VMCALCBLK";
errString = getErrorString( "calc_type", errCode, userId );
}
}else if ( childNodeName.trim().equals( "cal_input" ) )
{
String calcType = null;
String calInput = null;
calInput = genericUtility.getColumnValue( "cal_input", dom, "2" );
calcType = genericUtility.getColumnValue( "calc_type", dom, "2" );
if( calcType != null && !( calcType.indexOf( "U" ) > -1 )
&& ( calInput != null && calInput.trim().length() > 0 ) )
{
errCode = "VMNOCALI";
errString = getErrorString( "cal_input", errCode, userId );
}
else if( calcType == null || calcType.trim().length() == 0 )
{
errCode = "VMCALCBLK";
errString = getErrorString( "calc_type", errCode, userId );
}
}
}//END FOR OF CASE2
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::" +e);
e.printStackTrace();
errCode = "VALEXCEP";
errString = getErrorString( "", errCode, userId );
}
finally
{
try
{
if(conn != null)
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if( rs != null )
{
rs.close();
rs = null;
}
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" < ExprProcessIcEJB > CONNECTION IS CLOSED");
}
System.out.println("ErrString ::" + errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = null;
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
System.out.println("xmlString1" + xmlString1);
if (xmlString2.trim().length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [EpaymentICEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pStmt = null;
ResultSet rs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
String loginSite = null;
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
System.out.println("[EpaymentICEJB] [itemChanged] :currentFormNo ....." +currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
valueXmlString.append("<Detail1>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals( "itm_default" ))
{
String loginSiteCode = null;
String siteDescr = null;
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
sql = "select s.descr site_descr from site s "
+" where s.site_code = '" + loginSiteCode + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
if( rs.next() )
{
siteDescr = rs.getString( "site_descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<tran_date>").append("<![CDATA[" + getCurrdateAppFormat() + "]]>").append("</tran_date>");
valueXmlString.append("<site_code>").append("<![CDATA[" + ( loginSiteCode != null ? loginSiteCode.trim() : "" )+ "]]>").append("</site_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + ( siteDescr != null ? siteDescr.trim() : "" )+ "]]>").append("</descr>");
}
if ( currentColumn.trim().equals( "site_code" ) )
{
String siteDescr = null;
if( columnValue != null )
{
sql = "select s.descr site_descr from site s "
+" where s.site_code = '" + columnValue + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
if( rs.next() )
{
siteDescr = rs.getString( "site_descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
}
valueXmlString.append("<descr>").append("<![CDATA[" + ( siteDescr != null ? siteDescr.trim() : "" )+ "]]>").append("</descr>");
}
valueXmlString.append("</Detail1>");
valueXmlString.append("</Root>");
break;
///////////////
case 2:
valueXmlString.append("<Detail2>");
//SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals( "itm_default" ))
{
valueXmlString.append("<qty_perc isSrvCallOnChg='0'>").append("<![CDATA[]]>").append("</qty_perc>");
}
if (currentColumn.trim().equals( "itm_defaultedit" ))
{
String calcType = genericUtility.getColumnValue( "calc_type", dom );
String qtyPerc = genericUtility.getColumnValue( "qty_perc", dom );
String calMethod = genericUtility.getColumnValue( "cal_method", dom );
String calInput = genericUtility.getColumnValue( "cal_input", dom );
if( calcType != null && ( calcType.indexOf( "P" ) > -1 || calcType.indexOf( "W" ) > -1 ) )
{
valueXmlString.append("<qty_perc protect='0'>").append("<![CDATA[" + qtyPerc + "]]>").append("</qty_perc>");
}
else
{
valueXmlString.append("<qty_perc protect='0'>").append("<![CDATA[" + qtyPerc + "]]>").append("</qty_perc>");
}
if( calcType != null && calcType.indexOf( "U" ) > -1 )
{
valueXmlString.append("<cal_method protect='0'>").append("<![CDATA[" + calMethod + "]]>").append("</cal_method>");
valueXmlString.append("<cal_input protect='0'>").append("<![CDATA[" + calInput + "]]>").append("</cal_input>");
}
else
{
valueXmlString.append("<cal_method protect='1'>").append("<![CDATA[]]>").append("</cal_method>");
valueXmlString.append("<cal_input protect='1'>").append("<![CDATA[]]>").append("</cal_input>");
}
}
if (currentColumn.trim().equals( "item_code" ))
{
String descr = null;
sql = "select descr from item where item_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<item_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</item_descr>");
}
if (currentColumn.trim().equals( "site_code" ))
{
String descr = null;
sql = "select descr from site where site_code = '" + ( columnValue != null ? columnValue.trim() : "" ) + "'";
pStmt = conn.prepareStatement( sql );
rs = pStmt.executeQuery();
if( rs.next() )
{
descr = rs.getString( "descr" );
}
rs.close();
rs = null;
pStmt.close();
pStmt = null;
valueXmlString.append("<site_descr>").append("<![CDATA[" + ( descr != null ? descr.trim() : "" )+ "]]>").append("</site_descr>");
}
if (currentColumn.trim().equals( "calc_type" ))
{
System.out.println( "calc_type :: " + columnValue );
String calcType = genericUtility.getColumnValue( "calc_type", dom );
System.out.println( "calc_type :: " + calcType );
String qtyPerc = genericUtility.getColumnValue( "qty_perc", dom );
System.out.println( "qtyPerc :: " + qtyPerc );
String calMethod = genericUtility.getColumnValue( "cal_method", dom );
System.out.println( "calMethod :: " + calMethod );
String calInput = genericUtility.getColumnValue( "cal_input", dom );
System.out.println( "calInput :: " + calInput );
if( currentColumn != null && ( columnValue.indexOf( "P" ) > -1 || columnValue.indexOf( "W" ) > -1 ) )
{
valueXmlString.append("<qty_perc protect='0'>").append("<![CDATA[" + (qtyPerc == null?"":qtyPerc) + "]]>").append("</qty_perc>");
}
else
{
valueXmlString.append("<qty_perc protect='1'>").append("<![CDATA[]]>").append("</qty_perc>");
}
if( currentColumn != null && columnValue.indexOf( "U" ) > -1 )
{
valueXmlString.append("<cal_method protect='0'>").append("<![CDATA[" + (calMethod == null?"":calMethod) + "]]>").append("</cal_method>");
valueXmlString.append("<cal_input protect='0'>").append("<![CDATA[" + (calInput == null?"":calInput) + "]]>").append("</cal_input>");
}
else
{
valueXmlString.append("<cal_method protect='1'>").append("<![CDATA[]]>").append("</cal_method>");
valueXmlString.append("<cal_input protect='1'>").append("<![CDATA[]]>").append("</cal_input>");
}
}
valueXmlString.append("</Detail2>");
valueXmlString.append("</Root>");
////////////////
}//END OF TRY
}
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if ( rs != null )
{
rs.close();
rs = null;
}
if ( pStmt != null )
{
pStmt.close();
pStmt = null;
}
if ( conn != null )
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::" + e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}//END OF ITEMCHANGE
private String getCurrdateAppFormat()
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface ForecastTechICLocal extends ValidatorLocal//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface ForecastTechICRemote extends ValidatorRemote//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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
package ibase.webitm.ejb.mfg;
//import java.sql.Timestamp;
public class Indent
{
public String indNo = "";
final String indType = "M";
public String deptCode = "";
public String itemCode = "";
public String itemDescr= "";
public String unitInd = "";
public String unitStd = "";
public String siteCode = "";
public String siteCodeDlv = "";
public String siteCodeAcct = "";
public String siteCodeCust = "";
public String aprCode = "";
final String priority = "R";
public String acctCode = "";
public String cctrCode = "";
public String empCodePur = "";
public String empCodeReq = "";
public String suppCodePref = "";
public String packCode = "";
final String status = "T";
public String chgUser = "";
public String chgTerm = "";
public double purLeadTime = 0 ;
public double quantity = 0;
public double quantityStdUom = 0;
public double ordQuantity = 0;
public double purcRate = 0;
public double convQtyStdUom = 0;
public java.sql.Timestamp indDate = null;
public java.sql.Timestamp planDueDate = null;
public java.sql.Timestamp reqDate = null;
public java.sql.Timestamp chgDate = new java.sql.Timestamp(System.currentTimeMillis());
public Indent()
{
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
//import java.sql.Timestamp;
public class IndependentDemand
{
public String siteCode = "";
public String siteCodeCust = "";
public String itemCode = "";
public String unit = "";
public String unitStd = "";
public String status = "T";
public double quantity = 0;
public double quantityStdUom = 0;
public double convQtyStdUom = 1;
public java.sql.Timestamp tranDate = null;
public java.sql.Timestamp planDueDate = null;
public java.sql.Timestamp dueDate = null;
public IndependentDemand()
{
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
class InsertPlanDemand
{
}
/*
private String InsertPlanDemand(String winName, ArrayList list)
{
String xmlValues = "";
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header>";
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(winName.equalsIgnoreCase("T_MPS_ORDER"))
{
public String tranId = "";
public String ordType = "";
public String itemCode = "";
public String siteCode = "";
public String mrpRunId = "";
public String addnOrder = "";
public String status = "";
public String routeCode = "";
public String bomCode = "";
public String projCode = "";
public String chgUser = "";
public String chgTerm = "";
public String unit = "";
public String acctCodeWp = "";
public String cctrCodeWp = "";
public double quantity = 0;
public double yieldPerc = 0 ;
public double curBatchQty = 0;
public String ordDate = "";
public String planDueDate = "";
public String dueDate = "";
public String statusDate = "";
public String chgDate = "";
// public java.sql.Timestamp ordDate = null;
// public java.sql.Timestamp planDueDate = null;
// public java.sql.Timestamp dueDate = null;
// public java.sql.Timestamp statusDate = null;
// public java.sql.Timestamp chgDate = null;
logBuff.append("<win_name>").append(winName).append("</win_name>");
logBuff.append("<tran_id>").append(tranId).append("</tran_id>");
xmlBuff.append( "<?xml version='1.0' encoding='UTF-8'?>\n").append("<Root>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("mps_order").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
MPSOrder mpsOrder = null;
for(int count = 0; count<list.size(), count++)
{
mpsOrder = (MpsOrder)list.getMpsOrder(count);
ordTypes = mpsOrder.getOrdTypes(count);
itemCode = mpsOrder.getItemCode(count);
siteCode = mpsOrder.getSiteCode(count);
quantity = mpsOrder.getQuantity(count);
ordDate = sdt.format(mpsOrder.getOrdDate(count))
//mpsOrder.getOrdDate(count);
planDueDate = sdt.format(mpsOrder.getPlanDueDate(count));
//mpsOrder.getPlanDueDate(count);
mrpRunId = mpsOrder.getMrpRunId(count);
addnOrder = mpsOrder.getAddnOrder(count);
dueDate = sdt.format();
//mpsOrder.getDueDate(count);
status = mpsOrder.getStatus(count);
statusDate = sdt.format();
//mpsOrder.getStatusDate(count);
yieldPerc = mpsOrder.getYieldPerc(count);
routeCode = mpsOrder.getRouteCode(count);
bomCode = mpsOrder.getBomCode(count);
projCode = mpsOrder.getProjCode(count);
chgDate = sdt.format();
//mpsOrder.getChgDate(count);
chgUser = mpsOrder.getChgUser(count);
chgTerm = mpsOrder.getChgTerm(count);
unit = mpsOrder.getUnit(count);
acctCodeWp = mpsOrder.getAcctCodeWp(count);
cctrCodeWp = mpsOrder.getCctrCodeWp(count);
curBatchQty = mpsOrder.getCurBatchQty(count);
stdQty = mpsOrder.getStdQty(count);
demandQty = = mpsOrder.getDemandQty(count);
xmlValues = xmlValues + "<Detail>" + (count+1);
xmlValues = xmlValues + "<order_type><![CDATA[" + ordType + "]]></order_type>";
xmlValues = xmlValues + "<item_code><![CDATA[" + itemCode + "]]></item_code>";
xmlValues = xmlValues + "<site_code><![CDATA[" + siteCode + "]]></site_code>";
xmlValues = xmlValues + "<quantity><![CDATA[" + quantity + "]]></quantity>";
xmlValues = xmlValues + "<order_date><![CDATA[" + ordDate + "]]></order_date>";
xmlValues = xmlValues + "<plan_due_date><![CDATA[" + planDueDate + "]]></plan_due_date>";
xmlValues = xmlValues + "<mrp_run_id><![CDATA[" + mrpRunId + "]]></mrp_run_id>";
xmlValues = xmlValues + "<addn_order><![CDATA[" + addnOrder + "]]></addn_order>";
xmlValues = xmlValues + "<due_date><![CDATA[" + dueDate + "]]></due_date>";
xmlValues = xmlValues + "<status><![CDATA[" + status + "]]></status>";
xmlValues = xmlValues + "<status_date><![CDATA[" + statusDate + "]]></status_date>";
xmlValues = xmlValues + "<yield_perc><![CDATA[" + yieldPerc + "]]></yield_perc>";
xmlValues = xmlValues + "<route_code><![CDATA[" + routeCode + "]]></route_code>";
xmlValues = xmlValues + "<bom_code><![CDATA[" + bomCode + "]]></bom_code>";
xmlValues = xmlValues + "<proj_code><![CDATA[" + projCode + "]]></proj_code>";
xmlValues = xmlValues + "<change_date><![CDATA[" + chgDate + "]]></change_date>";
xmlValues = xmlValues + "<change_user><![CDATA[" + chgUser + "]]></change_user>";
xmlValues = xmlValues + "<change_term><![CDATA[" + chgTerm + "]]></change_term>";
xmlValues = xmlValues + "<unit><![CDATA[" + unit + "]]></unit>";
xmlValues = xmlValues + "<acct_code_wp><![CDATA[" + acctCodeWp + "]]></acct_code_wp>";
xmlValues = xmlValues + "<cctr_code_wp><![CDATA[" + cctrCodeWp + "]]></cctr_code_wp>";
xmlValues = xmlValues + "<cur_batch_qty><![CDATA[" + curBatchQty + "]]></cur_batch_qty>";
xmlValues = xmlValues + "<std_qty><![CDATA[" + stdQty + "]]></std_qty>";
xmlValues = xmlValues + "<demand_qty><![CDATA[" + demandQty + "]]></demand_qty>";
xmlValues = xmlValues + "</Detail>" + (count+1);
}
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlBuff.append("</Root>\r\n");
}
if(winName.equalsIgnoreCase("T_DIST_DEMAND"))
{
public String tranId = "";
public String siteCode = "";
public String itemCode = "";
public String unit = "";
public String siteCodeSrc = "";
final String status = "T";
public String chgUser = "";
public String chgTerm = "";
public double qtyRequired = 0;
public String tranDate = "";
public String planDueDate = "";
public String dueDateOrd = "";
public String dueDate = "";
public String chgDate = "";
// public java.sql.Timestamp tranDate = null;
// public java.sql.Timestamp planDueDate = null;
// public java.sql.Timestamp dueDateOrd = null;
// public java.sql.Timestamp dueDate = null;
// public java.sql.Timestamp chgDate = null;
logBuff.append("<win_name>").append(winName).append("</win_name>");
logBuff.append("<tran_id>").append(tranId).append("</tran_id>");
xmlBuff.append( "<?xml version='1.0' encoding='UTF-8'?>\n").append("<Root>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("dist_demand").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
DistDemand distDemand = new DistDemand();
for(int count = 0; count<list.size(), count++)
{
distDemand = (DistDemand)list.getDistDemand(count);
tranDate = distDemand.getTranDate(count);
siteCode = distDemand.getSiteCode(count);
itemCode = distDemand.getItemCode(count);
planDueDate = dueDate = sdt.format(distDemand.getPlanDueDate(count));
//distDemand.getPlanDueDate(count);
dueDate = sdt.format(distDemand.getDueDate(count));
//distDemand.getDueDate(count);
qtyRequired = distDemand.getQtyRequired(count);
unit = distDemand.getUnit(count);
siteCodeSource = distDemand.getSiteCodeSource(count);
dueDateOrd = distDemand.getDueDateOrd(count);
chgDate = sdt.format(distDemand.getChgDate(count));
//distDemand.getChgDate(count);
chgUser = distDemand.getChgUser(count);
chgTerm = distDemand.getChgTerm(count);
xmlValues = xmlValues + "<Detail>" + (count+1);
xmlValues = xmlValues + "<tran_date><![CDATA[" + tranDate + "]]></tran_date>";
xmlValues = xmlValues + "<site_code><![CDATA[" + siteCode + "]]></site_code>";
xmlValues = xmlValues + "<item_code><![CDATA[" + itemCode + "]]></item_code>";
xmlValues = xmlValues + "<plan_due_date><![CDATA[" + planDueDate + "]]></plan_due_date>";
xmlValues = xmlValues + "<due_date><![CDATA[" + dueDate + "]]></due_date>";
xmlValues = xmlValues + "<qty_required><![CDATA[" + qtyRequired + "]]></qty_required>";
xmlValues = xmlValues + "<unit><![CDATA[" + unit + "]]></unit>";
xmlValues = xmlValues + "<site_code_source><![CDATA[" + siteCodeSource + "]]></site_code_source>";
xmlValues = xmlValues + "<status><![CDATA[" + status + "]]></status>";
xmlValues = xmlValues + "<due_date_ord><![CDATA[" + dueDateOrd + "]]></due_date_ord>";
xmlValues = xmlValues + "<change_date><![CDATA[" + chgDate + "]]></change_date>";
xmlValues = xmlValues + "<change_user><![CDATA[" + chgUser + "]]></change_user>";
xmlValues = xmlValues + "<change_term><![CDATA[" + chgTerm + "]]></change_term>";
xmlValues = xmlValues + "</Detail>" + (count+1);
}
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlBuff.append("</Root>\r\n");
}
if(winName.equalsIgnoreCase("T_INDENT"))
{
public String indNo = "";
final String indType = "M";
public String deptCode = "";
public String itemCode = "";
public String itemDescr= "";
public String unitInd = "";
public String unitStd = "";
public String siteCode = "";
public String siteCodeDlv = "";
public String siteCodeAcct = "";
public String siteCodeCust = "";
public String aprCode = "";
final String priority = "R";
public String acctCode = "";
public String cctrCode = "";
public String empCodePur = "";
public String empCodeReq = "";
public String suppCodePref = "";
public String packCode = "";
final String status = "T";
public String chgUser = "";
public String chgTerm = "";
public double purLeadTime = 0 ;
public double quantity = 0;
public double quantityStdUom = 0;
public double ordQuantity = 0;
public double purcRate = 0;
public double convQtyStdUom = 0;
public String indDate = "";
public String planDate = "";
public String reqDate = "";
public String chgDate = "";
// public java.sql.Timestamp indDate = null;
// public java.sql.Timestamp planDate = null;
// public java.sql.Timestamp reqDate = null;
// public java.sql.Timestamp chgDate = null;
logBuff.append("<win_name>").append(winName).append("</win_name>");
logBuff.append("<ind_no>").append(indNo).append("</ind_no>");
xmlBuff.append( "<?xml version='1.0' encoding='UTF-8'?>\n").append("<Root>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("indent").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
Indent indent = new Indent();
for(int count = 0; count<list.size(), count++)
{
indent = (Indent)list.getIndent(count);
tranDate = sdt.format(indent.getTranDate(count));
//indent.getTranDate(count);
tranIdIndent = indent.getTranIdIndent(count);
indDate = sdt.format(indent.getIndDate(count));
//indent.getIndDate(count);
deptCode = indent.getindType(count);
tranDate = sdt.format(indent.getTranDate(count));
//indent.getTranDate(count);
plansdt.format(indent.getPlanDueDate(count));
//indent.getPlanDueDate(count);
reqDate = sdt.format(indent.getReqDate(count));
//indent.getReqDate(count);
itemCode = indent.getItemCode(count);
itemDesc = indent.getItemDesc(count);
quantity = indent.getQuantity(count);
quantityStdUom = indent.getQuantityStdUom(count);
unitInd = indent.getUnitInd(count);
unitStd = indent.getUnitStd(count);
siteCode = indent.getSiteCode(count);
siteCodeDlv = indent.getSiteCodeDlv(count);
siteCodeAcct = indent.getSiteCodeAcct(count);
aprCode = indent.getAprCode(count);
acctCode = indent.getAcctCode(count);
cctrCode = indent.getCctrCode(count);
empCodePur = indent.geTempCodePur(count);
empCodeReq = indent.getEmpCodeReq(count);
suppCodePref = indent.getSuppCodePref(count);
purcRate = indent.getPurcRate(count);
packCode = indent.getPackCode(count);
chgDate = indent.getChgDate(count);
chgUser = indent.getChgUser(count);
chgTerm = indent.getChgTerm(count);
purLeadTime = indent.getPurLeadTime(count);
convQtyStduom = indent.getConvQtyStduom(count);
xmlValues = xmlValues + "<Detail>" + (count+1);
xmlValues = xmlValues + "<tran_date><![CDATA[" + tranDate + "]]></tran_date>";
xmlValues = xmlValues + "<tran_id_indent><![CDATA[" + tranIdIndent + "]]></tran_id_indent>";
xmlValues = xmlValues + "<indent_date><![CDATA[" + indDate + "]]></indent_date>";
xmlValues = xmlValues + "<indent_type><![CDATA[" + indType + "]]></indent_type>";
xmlValues = xmlValues + "<dept_code><![CDATA[" + deptCode + "]]></dept_code>";
xmlValues = xmlValues + "<plan_due_date><![CDATA[" + planDueDate + "]]></plan_due_date>";
xmlValues = xmlValues + "<req_date><![CDATA[" + reqDate + "]]></req_date>";
xmlValues = xmlValues + "<item_code><![CDATA[" + itemCode + "]]></item_code>";
xmlValues = xmlValues + "<item_desc><![CDATA[" + itemDesc + "]]></item_desc>";
xmlValues = xmlValues + "<quantity><![CDATA[" + quantity + "]]></quantity>";
xmlValues = xmlValues + "<quantity_std_uom><![CDATA[" + quantityStdUom + "]]></quantity_std_uom>";
xmlValues = xmlValues + "<unit_ind><![CDATA[" + unitInd + "]]></unit_ind>";
xmlValues = xmlValues + "<unit_std><![CDATA[" + unitStd + "]]></unit_std>";
xmlValues = xmlValues + "<site_code><![CDATA[" + siteCode + "]]></site_code>";
xmlValues = xmlValues + "<site_code_dlv><![CDATA[" + siteCodeDlv + "]]></site_code_dlv>";
xmlValues = xmlValues + "<site_code_acct><![CDATA[" + siteCodeAcct + "]]></site_code_acct>";
xmlValues = xmlValues + "<apr_code><![CDATA[" + aprCode + "]]></apr_code>";
xmlValues = xmlValues + "<priority><![CDATA[" + priority + "]]></priority>";
xmlValues = xmlValues + "<acct_code><![CDATA[" + acctCode + "]]></acct_code>";
xmlValues = xmlValues + "<cctr_code><![CDATA[" + cctrCode + "]]></cctr_code>";
xmlValues = xmlValues + "<emp_code_pur><![CDATA[" + empCodePur + "]]></emp_code_pur>";
xmlValues = xmlValues + "<emp_code_req><![CDATA[" + empCodeReq + "]]></emp_code_req>";
xmlValues = xmlValues + "<supp_code_pref><![CDATA[" + suppCodePref + "]]></supp_code_pref>";
xmlValues = xmlValues + "<purc_rate><![CDATA[" + purcRate + "]]></purc_rate>";
xmlValues = xmlValues + "<pack_code><![CDATA[" + packCode + "]]></pack_ode>";
xmlValues = xmlValues + "<status><![CDATA[" + status + "]]></status>";
xmlValues = xmlValues + "<change_date><![CDATA[" + chgDate + "]]></change_date>";
xmlValues = xmlValues + "<change_user><![CDATA[" + chgUser + "]]></change_user>";
xmlValues = xmlValues + "<change_term><![CDATA[" + chgTerm + "]]></change_term>";
xmlValues = xmlValues + "<pur_lead_time><![CDATA[" + purLeadTime + "]]></pur_lead_time>";
xmlValues = xmlValues + "<conv_qty_std_oum><![CDATA[" + convQtyStduom + "]]></conv_qty_std_oum>";
xmlValues = xmlValues + "</Detail>" + (count+1);
}
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlBuff.append("</Root>\r\n");
}
if(winName.equalsIgnoreCase("T_INDEPENDENT_DEMAND"))
{
public String tranId = "";
public String siteCode = "";
public String siteCodeCust = "";
public String itemCode = "";
public String unit = "";
public String unitStd = "";
public String status = "T";
public double quantity = 0;
public double quantityStdUom = 0;
public double convQtyStdUom = 1;
public String tranDate = "";
public String planDueDate = "";
public String dueDate = "";
// public java.sql.Timestamp tranDate = null;
// public java.sql.Timestamp planDueDate = null;
// public java.sql.Timestamp dueDate = null;
logBuff.append("<win_name>").append(winName).append("</win_name>");
logBuff.append("<tran_id>").append(tranId).append("</tran_id>");
xmlBuff.append( "<?xml version='1.0' encoding='UTF-8'?>\n").append("<Root>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("independent_demand").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("A").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<elementName><![CDATA[").append("").append("]]></elementName>");
xmlBuff.append("<keyValue><![CDATA[").append("1").append("]]></keyValue>");
xmlBuff.append("<taxKeyValue><![CDATA[").append("").append("]]></taxKeyValue>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
IndependentDemand independentDemand = new IndependentDemand();
for(int count = 0; count<list.size(), count++)
{
independentDemand = (IndependentDemand)list.getIndependentDemand(count);
siteCode = independentDemand.getSiteCode(count);
siteCodeCust = independentDemand.getSiteCodeCust(count);
itemCode = independentDemand.getItemCode(count);
unit = independentDemand.getUnit(count);
unitStd = independentDemand.getUnitStd(count);
quantity = independentDemand.getQuantity(count);
quantityStdUom = independentDemand.getQuantityStdUom(count);
convQtyStdUom = indent.getConvQtyStduom(count);
tranDate = sdt.format(indent.getTranDate(count));
//indent.getTranDate(count);
planDueDate = sdt.format(indent.getPlanDueDate(count));
//indent.getPlanDueDate(count);
dueDate = sdt.format(indent.getDueDate(count));
//indent.getDueDate(count);
xmlValues = xmlValues + "<Detail>" + (count+1);
xmlValues = xmlValues + "<site_code><![CDATA[" + siteCode + "]]></site_code>";
xmlValues = xmlValues + "<site_code_cust><![CDATA[" + siteCodeCust + "]]></site_code_cust>";
xmlValues = xmlValues + "<item_code><![CDATA[" + itemCode + "]]></item_code>";
xmlValues = xmlValues + "<unit><![CDATA[" + unit + "]]></unit>";
xmlValues = xmlValues + "<unit_std><![CDATA[" + unitStd + "]]></unit_std>";
xmlValues = xmlValues + "<status><![CDATA[" + status + "]]></status>";
xmlValues = xmlValues + "<quantity><![CDATA[" + quantity + "]]></quantity>";
xmlValues = xmlValues + "<quantity_std_uom><![CDATA[" + quantityStdUom + "]]></quantity_std_uom>";
xmlValues = xmlValues + "<conv_qty_std_oum><![CDATA[" + convQtyStdUom + "]]></conv_qty_std_oum>";
xmlValues = xmlValues + "<tran_date><![CDATA[" + tranDate + "]]></tran_date>";
xmlValues = xmlValues + "<plan_due_date><![CDATA[" + plaDueDate + "]]></plan_due_date>";
xmlValues = xmlValues + "<due_date><![CDATA[" + dueDate + "]]></due_date>";
xmlValues = xmlValues + "</Detail>" + (count+1);
}
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlBuff.append("</Root>\r\n");
}
xmlValues = xmlValues + "</Header>";
xmlValues = xmlValues + "</Root>";
String errStr = saveData(xmlValues);
}
private String saveData(String xmlString)throws ITMException
{
System.out.println("saving data...........");
InitialContext ctx = null;
String retString = null;
try
{
AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty());
MasterStatefulHome masterStatefulHome = (MasterStatefulHome)ctx.lookup("MasterStateful");
MasterStateful masterStateful = masterStatefulHome.create();
String [] authencate = new String[2];
authencate[0] = userId;
authencate[1] = userId;
retString = masterStateful.processRequest(authencate, logInSite, true, xmlString);
}
catch(ITMException itme)
{
System.out.println("ITMException :UpdatePlanDemand :saveData :==>");
throw itme;
}
catch(Exception e)
{
System.out.println("Exception :UpdatePlanDemand :saveData :==>");
throw new ITMException(e);
}
return retString;
}
*/
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.util.ArrayList;
//import ibase.webitm.utility.ITMException;
//import ibase.webitm.utility.GenericUtility;
import java.sql.*;
public class InsertPlanTable
{
PreparedStatement pstmtPlanHdr = null;
PreparedStatement pstmtPlanDet = null;
String resultString = "";
String siteCode = "";
String siteCodeSupp = "";
String itemCode = "";
String itemSer = "";
String itemStru = "";
String masterSch = "";
String bomCode = "";
String suppSour = "";
String suppCodePref = "";
String orderOpt = "";
String dueDateStr = "";
String batchQtyType = "";
String empCodePur = "";
String packCode = "";
String unit = "";
String acctCodePh = "";
String acctCodeWp = "";
String cctrCodePh = "";
String aprCode = "";
String cctrCodeWp = "";
double demand = 0;
double supply = 0;
double planDemand = 0;
double planSupply = 0;
double runningDemand = 0;
double runningSupply = 0;
double runningPlanSupply = 0;
double independentDemand = 0;
double minOrderQty = 0;
double maxOrderQty = 0;
double integralQty = 0;
double maxQty = 0;
double maxStkQty = 0;
double minQty = 0;
double reorderQty = 0;
double yieldPerc = 100;
double minPlanPerc = 0;
double batchQty = 0;
double purcRate = 0;
int purLeadTime = 0;
int qcLeadTime = 0;
int mfgLeadTime = 0;
int minStkDay = 0;
int maxStkDay = 0;
boolean flag = true;
java.sql.Timestamp dueDate = null;
ADPElement adpElement = null;
public String InsertPlanHdrDet(ArrayList adpeList, Connection conn)
{
try
{
String sqlPlanHdr = "INSERT INTO PLAN_HDR(SITE_CODE, ITEM_CODE, ITEM_SER, SITE_CODE__SUPP, "
+ "SUPP_SOUR, BOM_CODE, MIN_QTY, MIN_ORDER_QTY, MIN_STK_DAY, MAX_QTY, "
+ "MAX_STK_DAY, ITEM_STRU, REO_QTY, PUR_LEAD_TIME, QC_LEAD_TIME, "
+ "MFG_LEAD_TIME, INTEGRAL_QTY, BATCH_QTY, BATCH_QTY_TYPE, MASTER_SCH, ORDER_OPT, "
+ "YIELD_PERC, MIN_PLAN_PERC, UNIT, APR_CODE, PACK_CODE, EMP_CODE__PUR, "
+ "SUPP_CODE__PREF, PURC_RATE, ACCT_CODE__PH, CCTR_CODE__PH, ACCT_CODE__WP, CCTR_CODE__WP) "
+ "VALUES( ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? ) ";
pstmtPlanHdr = conn.prepareStatement(sqlPlanHdr);
String sqlPlanDtl = "INSERT INTO PLAN_DTL(SITE_CODE, ITEM_CODE, DEMAND, SUPPLY, PLAN_SUPP, "
+ "RUNNING_DEMAND, RUNNING_SUPP, RUNNING_PLAN_SUPP, IND_DEMAND, DUE_DATE) "
+ "VALUES( ? , ? , ? , ? , ? , ? ,"
+ " ? , ? , ? , ? ) ";
pstmtPlanDet = conn.prepareStatement(sqlPlanDtl);
for(int adpeCount=0; adpeCount<adpeList.size(); adpeCount++)
{
flag = true;
adpElement = (ADPElement)adpeList.get(adpeCount);
siteCode = adpElement.getSiteCode();
itemCode = adpElement.getItemCode();
itemSer = adpElement.getItemSer();
siteCodeSupp = adpElement.getSiteCodeSupp();
suppSour = adpElement.getSuppSour();
bomCode = adpElement.getBomCode();
minQty = adpElement.getMinQty();
minOrderQty = adpElement.getMinOrderQty();
minStkDay = adpElement.getMinStkDay();
maxQty = adpElement.getMaxQty();
maxStkDay = adpElement.getMaxStkDay();
itemStru = adpElement.getItemStru();
reorderQty = adpElement.getReoQty();
purLeadTime = adpElement.getPurLeadTime();
qcLeadTime = adpElement.getQcLeadTime();
mfgLeadTime = adpElement.getMfgLeadTime();
integralQty = adpElement.getIntegralQty();
batchQty = adpElement.getBatchQty();
batchQtyType = adpElement.getBatchQtyType();
masterSch = adpElement.getMasterSch();
orderOpt = adpElement.getOrderOpt();
yieldPerc = adpElement.getYieldPerc();
minPlanPerc = adpElement.getMinPlanPerc();
unit = adpElement.getUnit();
aprCode = adpElement.getAprCode();
packCode = adpElement.getPackCode();
empCodePur = adpElement.getEmpCodePur();
suppCodePref = adpElement.getSuppCodePref();
purcRate = adpElement.getPurcRate();
acctCodePh = adpElement.getAcctCodePh();
cctrCodePh = adpElement.getCctrCodePh();
acctCodeWp = adpElement.getAcctCodeWp();
cctrCodeWp = adpElement.getCctrCodeWp();
ArrayList timeMRParr = adpElement.getTimeMrpList();
for (int timeCtr = 0; timeCtr < timeMRParr.size() ; timeCtr++)
{
TimeMRP timeMrp = (TimeMRP)timeMRParr.get(timeCtr);
demand = timeMrp.getDemand();
supply = timeMrp.getSupply();
planSupply = timeMrp.getPlanSupply();
runningDemand = timeMrp.getRunningDemand();
runningSupply = timeMrp.getRunningSupply();
runningPlanSupply = timeMrp.getRunningPlanSupply();
independentDemand = timeMrp.getIndependentDemand();
dueDate = timeMrp.getDueDate();
pstmtPlanDet.setString(1,siteCode);
pstmtPlanDet.setString(2,itemCode);
pstmtPlanDet.setDouble(3,demand);
pstmtPlanDet.setDouble(4,supply);
pstmtPlanDet.setDouble(5,planSupply);
pstmtPlanDet.setDouble(6,runningDemand);
pstmtPlanDet.setDouble(7,runningSupply);
pstmtPlanDet.setDouble(8,runningPlanSupply);
pstmtPlanDet.setDouble(9,independentDemand);
pstmtPlanDet.setTimestamp(10,dueDate);
pstmtPlanDet.addBatch();
}
pstmtPlanHdr.setString(1,siteCode);
pstmtPlanHdr.setString(2,itemCode);
pstmtPlanHdr.setString(3,itemSer);
pstmtPlanHdr.setString(4,siteCodeSupp);
pstmtPlanHdr.setString(5,suppSour);
pstmtPlanHdr.setString(6,bomCode);
pstmtPlanHdr.setDouble(7,minQty);
pstmtPlanHdr.setDouble(8,minOrderQty);
pstmtPlanHdr.setInt(9,minStkDay);
pstmtPlanHdr.setDouble(10,maxQty);
pstmtPlanHdr.setInt(11,maxStkDay);
pstmtPlanHdr.setString(12,itemStru);
pstmtPlanHdr.setDouble(13,reorderQty);
pstmtPlanHdr.setInt(14,purLeadTime);
pstmtPlanHdr.setInt(15,qcLeadTime);
pstmtPlanHdr.setInt(16,mfgLeadTime);
pstmtPlanHdr.setDouble(17,integralQty);
pstmtPlanHdr.setDouble(18,batchQty);
pstmtPlanHdr.setString(19,batchQtyType);
pstmtPlanHdr.setString(20,masterSch);
pstmtPlanHdr.setString(21,orderOpt);
pstmtPlanHdr.setDouble(22,yieldPerc);
pstmtPlanHdr.setDouble(23,minPlanPerc);
pstmtPlanHdr.setString(24,unit);
pstmtPlanHdr.setString(25,aprCode);
pstmtPlanHdr.setString(26,packCode);
pstmtPlanHdr.setString(27,empCodePur);
pstmtPlanHdr.setString(28,suppCodePref);
pstmtPlanHdr.setDouble(29,purcRate);
pstmtPlanHdr.setString(30,acctCodePh);
pstmtPlanHdr.setString(31,cctrCodePh);
pstmtPlanHdr.setString(32,acctCodeWp);
pstmtPlanHdr.setString(33,cctrCodeWp);
pstmtPlanHdr.addBatch();
}
pstmtPlanHdr.executeBatch();
pstmtPlanHdr.clearParameters();
pstmtPlanHdr.close();
pstmtPlanDet.executeBatch();
pstmtPlanDet.clearParameters();
pstmtPlanDet.close();
}
catch (SQLException se)
{
System.out.println("SQLException :RunMRPPrcEJB :InsertPlanTable():" + se.getMessage());
se.printStackTrace();
resultString = se.getMessage();
// throw new ITMException(e);
}
catch (Exception e)
{
System.out.println("Exception :RunMRPPrcEJB :InsertPlanTable():" + e.getMessage());
e.printStackTrace();
resultString = e.getMessage();
// throw new ITMException(e);
}
return resultString;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
class InterSiteDistance
{
/*
site_code
site_code__from
distance
*/
/*
priority is to be implement
*/
private String siteCode;
private String siteCodeFrom;
private double distance = 0;
public void setSiteCode(String siteCode)
{
this.siteCode = siteCode;
}
public String getSiteCode()
{
return this.siteCode;
}
public void setSiteCodeFrom(String siteCodeFrom)
{
this.siteCodeFrom = siteCodeFrom;
}
public String getSiteCodeFrom()
{
return this.siteCodeFrom;
}
public void setDistance(double distance)
{
this.distance = distance;
}
public double getDistance()
{
return this.distance;
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.annotation.*;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class InventoryAct extends ActionHandlerEJB implements InventoryActLocal,InventoryActRemote // SessionBean
{
GenericUtility genericUtility= GenericUtility.getInstance();
Connection conn=null;
Vector routeVec = null;
String tranId = null;
int lineNo = 0;
/*public void ejbCreate() throws RemoteException, CreateException {}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}
*/
public String actionHandler() throws RemoteException,ITMException{return "";}
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException
{
String retString = "";
Document dom = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
dom = genericUtility.parseString(xmlString);
}
}
catch(Exception e)
{
System.out.println("Exception :InventoryActEJB :actionHandler(String xmlString):" + e.getMessage() + ":");
throw new ITMException(e);
}
return retString;
}
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
String retString = null;
try
{
System.out.println("XML String1:::"+xmlString1);
System.out.println("XML String:::"+xmlString);
System.out.println("Default function executing in progress...................");
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String:::"+xmlString);
dom = GenericUtility.getInstance().parseString(xmlString);
System.out.println("dom :"+dom);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
System.out.println("XML String1:::"+xmlString1);
dom1 = GenericUtility.getInstance().parseString(xmlString1);
System.out.println("dom1 :"+dom1);
}
System.out.println("actionType:::["+actionType+"]");
if (actionType.equalsIgnoreCase("Default"))
{
try
{
if(conn==null)
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
DatabaseMetaData dbmd = conn.getMetaData();
System.out.println("DriverName["+dbmd.getDriverName() );
System.out.println("DriverURI["+dbmd.getURL() );
System.out.println("DriverUSER["+dbmd.getUserName() );
System.out.println("ApplDateFormat["+genericUtility.getApplDateFormat());
System.out.println("DBDateFormat["+genericUtility.getDBDateFormat() );
connDriver = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
retString = actionDefault(dom, dom1, objContext, xtraParams);
}
}
catch(Exception e)
{
System.out.println("Exception :Dispatch :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
routeVec = null;
}
System.out.println("returning String from Despatch : actionHandler"+retString);
return retString;
}
private String actionDefault(Document dom, Document dom1, String objContext, String xtraParams) throws RemoteException, ITMException
{
StringBuffer valueXmlString = null;
routeVec = new Vector();
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
NodeList parentNodeList = null;
NodeList childNodeList = null;
int parentNodeListLength=0;
int childNodeListLength = 0;
Node parentNode =null;
Node childNode =null;
String childNodeName = null;
PreparedStatement pstmt = null;
ResultSet rs =null;
String sql = null;
String workOrder = null;
String operation = null;
String routeCode = null;
String itemCode = null;
String QtyStr = null;
String unit = null;
String descr1 = null;
try
{
// *******************************
parentNodeList = dom1.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength:::::::::"+parentNodeListLength);
for (int row = 0; row < parentNodeListLength; row++)
{
workOrder = null;
operation = null;
parentNode = parentNodeList.item(row);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength::: "+ childNodeListLength+"\n");
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
/*if (childNodeName.equals("route_code"))
{
if(childNode.getFirstChild()!=null)
{
routeCode = childNode.getFirstChild().getNodeValue();
//System.out.println("routeCode ::"+ routeCode ) ;
}
}*/
if (childNodeName.equals("work_order"))
{
if(childNode.getFirstChild()!=null)
{
workOrder = childNode.getFirstChild().getNodeValue();
}
}
}//end for
sql = "SELECT ROUTE_CODE FROM WORKORDER WHERE WORK_ORDER='"+workOrder+"'";
System.out.println("Sql:::["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs= pstmt.executeQuery();
if(rs.next())
{
routeCode = ((rs.getString(1)==null)?" ":rs.getString(1));
}
rs.close();
pstmt.close();
System.out.println("WorkOrder :::["+workOrder+"] RouteCode["+routeCode+"]");
if(!routeVec.contains(routeCode))
{
routeVec.add(routeCode);
sql = "SELECT PROCROUTE_WIP.ITEM_CODE__WIP,PROCROUTE_WIP.PRC_OUTPUT_SIZE,ITEM.UNIT,ITEM.DESCR FROM PROCROUTE_WIP,ITEM WHERE ITEM.ITEM_CODE= PROCROUTE_WIP.ITEM_CODE__WIP AND PROCROUTE_WIP.ROUTE_CODE='"+routeCode+"'";
System.out.println("Sql:::["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs= pstmt.executeQuery();
while(rs.next())
{
itemCode = (rs.getString(1)==null?" ":rs.getString(1));
QtyStr = (rs.getString(2)==null?" ":rs.getString(2));
unit = (rs.getString(3)==null?" ":rs.getString(3));
descr1 = (rs.getString(4)==null?" ":rs.getString(4));
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<descr>").append("<![CDATA[").append(descr1).append("]]>").append("</descr>\r\n");
valueXmlString.append("<operation>").append("<![CDATA[").append("0").append("]]>").append("</operation>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(QtyStr).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<unit>").append("<![CDATA[").append(unit).append("]]>").append("</unit>\r\n");
valueXmlString.append("<reas_code>").append("<![CDATA[").append("").append("]]>").append("</reas_code>\r\n");
valueXmlString.append("<det_remarks>").append("<![CDATA[").append(" ").append("]]>").append("</det_remarks>\r\n");
valueXmlString.append("<loc_code>").append("<![CDATA[").append(" ").append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(" ").append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append("<![CDATA[").append(" ").append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("</Detail>\r\n");
}
}//end if
}
valueXmlString.append("</Root>\r\n");
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println("valueXmlString.toString() :"+valueXmlString.toString());
return valueXmlString.toString();
}
}//end of Ejb
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface InventoryActLocal extends ActionHandlerLocal//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface InventoryActRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : ItemDeptEJB
Date Of Modification : 18/07/07
Name of Developer : Imteyaz-ul haque
********************************************************/
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import java.text.NumberFormat;
import java.io.*;
import javax.ejb.SessionBean;
import javax.ejb.CreateException;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
import ibase.system.config.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class ItemDept extends ValidatorEJB implements ItemDeptLocal,ItemDeptRemote //SessionBean
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
java.sql.Connection conn=null;
GenericUtility genericUtility = GenericUtility.getInstance();
String sql = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("<========= ITEM DEPT_EJB IS IN PROCESS ========>");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
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
{
Document dom = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
System.out.println("<========= ItemDeptEJB ItemChanged Called =========>");
dom = parseString(xmlString1);
if (xmlString.trim().length() > 0 )
{
dom = parseString(xmlString);
}
valueXmlString = itemChanged(dom,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [ItemDeptEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom,String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
boolean isFound=false;
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
String columnValue = "";
int ctr=0;
String ChgDate = "";
String ChgUser = "";
String ChgTerm = "";
String ItemCode="";
String ItDescr="";
String DpDescr="";
String DeptCode="";
int currentFormNo=0;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
System.out.println("<=======[ItemDeptEJB]connection is opened =====>");
ChgDate = getValueFromXTRA_PARAMS(xtraParams, "chg_date");
ChgUser = getValueFromXTRA_PARAMS(xtraParams, "chg_user");
ChgTerm = getValueFromXTRA_PARAMS(xtraParams, "chg_term");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[ItemDeptEJB] [itemChanged] :currentFormNo ====>" +currentFormNo);
System.out.println("FORM NO ====>"+currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
try
{
// SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
int childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[ItemDeptEJB]Column Value ====>"+columnValue);
System.out.println("[ItemDeptEJB]currentColumn =====>"+currentColumn);
valueXmlString.append("<Detail>\r\n");
if (currentColumn.trim().equals("itm_default"))
{
valueXmlString.append("<chg_date>").append(ChgDate).append("</chg_date>\r\n");
valueXmlString.append("<chg_user>").append(ChgUser).append("</chg_user>\r\n");
valueXmlString.append("<chg_term>").append(ChgTerm).append("</chg_term>\r\n");
System.out.println("Chg Date:FROM Dom:::::["+ChgDate+"]");
System.out.println("Chg User:FROM Dom:::::["+ChgUser+"]");
System.out.println("Chg Term:FROM Dom:::::["+ChgTerm+"]");
}
if(currentColumn.trim().equalsIgnoreCase("item_code"))
{
ItemCode = getColumnValue("item_code",dom);
System.out.println("ITEM_CODE:FROM Dom ======>["+ItemCode+"]");
sql ="select DESCR from ITEM where item_code= '"+ItemCode+"'";
System.out.println("sql::::==" +sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
ItDescr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("ItDescr:::["+ItDescr+"]");
valueXmlString.append("<item_descr>").append(ItDescr).append("</item_descr>\r\n");
}
if(currentColumn.trim().equalsIgnoreCase("dept_code"))
{
DeptCode = getColumnValue("dept_code",dom);
System.out.println("DEPT_CODE:FROM Dom ======>["+DeptCode+"]");
sql ="select DESCR from DEPARTMENT where dept_code= '"+DeptCode+"'";
System.out.println("sql::::==" +sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
DpDescr = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("DpDescr =====> ["+DpDescr+"]");
valueXmlString.append("<department_descr>").append(DpDescr).append("</department_descr>\r\n");
}
valueXmlString.append("</Detail>");
valueXmlString.append("</Root>");
}//end of Inner Try
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
}//END OF OUTER TRY
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
rs.close();
rs = null;
stmt.close();
stmt = null;
pstmt.close();
pstmt = null;
conn.close();
conn = null;
System.out.println("[ItemDeptEJB] CONNECTION IS CLOSED =====>");
}
}catch(Exception d){d.printStackTrace();}
System.out.println("[ItemDeptEJB] Connection is Closed");
}
System.out.println("valueXmlString:::::"+valueXmlString.toString());
return valueXmlString.toString();
}//END OF ITEMCHNGE
} // End Of Main
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.ValidatorLocal;
import java.rmi.RemoteException;
import javax.ejb.*;
import ibase.webitm.utility.*;
import org.w3c.dom.*;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface ItemDeptLocal extends ValidatorLocal//, EJBObject
{
public abstract String itemChanged() throws RemoteException, ITMException;
public abstract String itemChanged(String s,String s1, String s2, String s3, String s4, String s5, String s6) throws RemoteException, ITMException;
public abstract String itemChanged(Document dom,String s, String s1, String s2, String s3) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.ValidatorRemote;
import java.rmi.RemoteException;
import javax.ejb.*;
import ibase.webitm.utility.*;
import org.w3c.dom.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface ItemDeptRemote extends ValidatorRemote//, EJBObject
{
public abstract String itemChanged() throws RemoteException, ITMException;
public abstract String itemChanged(String s,String s1, String s2, String s3, String s4, String s5, String s6) throws RemoteException, ITMException;
public abstract String itemChanged(Document dom,String s, String s1, String s2, String s3) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.mfg;
//import java.sql.Timestamp;
public class MPSOrder
{
public String tranId = "";
public String ordType = "";
public String itemCode = "";
public String siteCode = "";
public String mrpRunId = "";
public String addnOrder = "";
public String status = "";
public String routeCode = "";
public String bomCode = "";
public String projCode = "";
public String chgUser = "";
public String chgTerm = "";
public String unit = "";
public String acctCodeWp = "";
public String cctrCodeWp = "";
public double quantity = 0;
public double yieldPerc = 0 ;
public double curBatchQty = 0;
public java.sql.Timestamp ordDate = null;
public java.sql.Timestamp planDueDate = null;
public java.sql.Timestamp dueDate = null;
public java.sql.Timestamp statusDate = null;
public java.sql.Timestamp chgDate = new java.sql.Timestamp(System.currentTimeMillis());
public MPSOrder()
{
//System.out.println("MPSOrder Instantiated.......");
}
public void Test()
{
System.out.println("Inside Test().......");
}
}
\ No newline at end of file
/*
* Created on Mar 6, 2007
*
* TODO To change the template for this generated file go to
* Window - Preferences - Java - Code Style - Code Templates
*/
package ibase.webitm.ejb.mfg;
import ibase.webitm.utility.GenericUtility;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
/**
* @author ashah
*
* TODO To change the template for this generated type comment go to
* Window - Preferences - Java - Code Style - Code Templates
*/
public class MfgCommon {
public String chkStkOpt(String siteCode, String itemCode, Connection conn) {
String stkOpt = "", sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = " SELECT CASE WHEN STK_OPT IS NULL THEN 'N' ELSE STK_OPT END FROM SITEITEM "
+ " WHERE ITEM_CODE = ? AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
System.out.println("Sql ::: " + sql);
System.out.println("Setting params -- itemCode :: " + itemCode + " siteCode :: " + siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
stkOpt = rs.getString(1);
System.out.println("stkOpt in chkStkOpt ::: " + stkOpt);
}
pstmt.close();
rs.close();
if (stkOpt.equalsIgnoreCase("N") || stkOpt == null)
{
sql = "SELECT CASE WHEN STK_OPT IS NULL THEN '0' ELSE STK_OPT END FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
stkOpt = rs.getString(1);
}
pstmt.close();
rs.close();
}
}
catch(Exception e)
{}
System.out.println("stkOpt in chkStkOpt :: " + stkOpt);
return stkOpt;
}
public String chkQcReqd(String siteCode, String itemCode, Connection conn) {
String qcReqd = "", sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
System.out.println("In chkQcReqd :--: siteCode :: " + siteCode + " itemCode :: " + itemCode);
sql = " SELECT CASE WHEN QC_REQD IS NULL THEN 'N' ELSE QC_REQD END FROM SITEITEM "
+ " WHERE ITEM_CODE = ? AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
qcReqd = rs.getString(1);
}
pstmt.close();
rs.close();
if (qcReqd.equalsIgnoreCase("N") || qcReqd == null)
{
sql = "SELECT CASE WHEN QC_REQD IS NULL THEN 'N' ELSE QC_REQD END FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
qcReqd = rs.getString(1);
}
pstmt.close();
rs.close();
}
}
catch(Exception e)
{
System.out.println("Exception in chkQcReqd" + e.getMessage());
}
return qcReqd;
}
public String chkAutoQcReqd(String siteCode, String itemCode, Connection conn) {
String autoQcReqd = "", sql = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
System.out.println("In chkAutoQcReqd :--: siteCode :: " + siteCode + " itemCode :: " + itemCode);
sql = " SELECT CASE WHEN AUTO_REQC IS NULL THEN 'Y' ELSE AUTO_REQC END FROM SITEITEM "
+ " WHERE ITEM_CODE = ? AND SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
autoQcReqd = rs.getString(1);
}
pstmt.close();
rs.close();
if (autoQcReqd.equalsIgnoreCase("N") || autoQcReqd == null)
{
sql = "SELECT CASE WHEN AUTO_REQC IS NULL THEN 'Y' ELSE AUTO_REQC END FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
autoQcReqd = rs.getString(1);
}
pstmt.close();
rs.close();
}
}
catch(Exception e)
{
System.out.println("Exception in chkAutoQcReqd" + e.getMessage());
}
return autoQcReqd;
}
private Timestamp getTimestampFormat(String stDate) {
Timestamp tsDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try {
System.out.println(" Before converting into Timestamp ::: " + stDate);
Object date = null;
SimpleDateFormat sdfApp = new SimpleDateFormat(genericUtility.getApplDateFormat());
date = sdfApp.parse(stDate);
SimpleDateFormat sdfDB = new SimpleDateFormat(genericUtility.getDBDateFormat());
tsDate = java.sql.Timestamp.valueOf(sdfDB.format(date).toString() + " 00:00:00.0");
} catch (Exception e) {
System.out.println("Exception in getTimestampFormat" + e.getMessage());
}
System.out.println(" After converted into Timestamp ::: " + tsDate);
return tsDate;
}
public String getEnvMfg(String prdCode, String varName, Connection conn)
{
String varValue = "";
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
try
{
System.out.println("In getEnvMfg ");
sql= "SELECT VAR_VALUE FROM MFGPARM WHERE PRD_CODE = ? AND VAR_NAME = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, prdCode);
pstmt.setString(2, varName);
rs = pstmt.executeQuery();
if(rs.next())
{
varValue =rs.getString(1);
System.out.println("In getEnvMfg varValue..." + varValue);
}
else
{
System.out.println("No record found for PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'");
varValue = "NULLFOUND";
}
pstmt.close();
rs.close();
}
catch(Exception e)
{
System.out.println("Exception in ..getEnvMfg....");
e.printStackTrace();
}
return varValue;
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.text.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.mfg.MfgCommon;
import ibase.webitm.ejb.fin.FinCommon;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcpBackflushMulti extends ValidatorEJB implements RcpBackflushMultiLocal, RcpBackflushMultiRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("RcpBackflushEJB is in Process..........");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
System.out.println("Validation Start..........");
try
{
System.out.println("xmlString:::"+xmlString);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : RcpBackflushEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
return (errString);
}
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String errString = " ";
String errCode = null;
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs = null, rs1 = null;
String sql = null;
String loginCode = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = null;
int ctr,currentFormNo=0;
int childNodeListLength;
String tranDate = null, siteCode = null, projCode = null, backflushType = null, itemCode = null;
String unit = null, locCode = null, trackShelfLife = null, grade = null, stkGrade = null;
String mfgDateS = null, expDateS = null, packCode = null, bomCode = null, itemCodeFG = null;
String parentHdr = null, parentDet = null, lotNo = null, lotSl = null;
double quantity = 0, stkQty = 0;
int cnt = 0; //for no. of record available in the table
try
{
conn = connDriver.getConnectDB("Driver");
connDriver = null;
loginCode = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
stmt = conn.createStatement();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1:
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 (childNodeName.equals("tran_date"))
{
tranDate = genericUtility.getColumnValue("tran_date", dom);
siteCode = genericUtility.getColumnValue("site_code", dom);
errCode = nfCheckPeriod("PUR", genericUtility.getDateObject(tranDate), siteCode);
if (errCode != null && errCode != "")
{
System.out.println("errCode from nfCheckPeriod :: [" + errCode + "]");
errString = getErrorString("tran_date",errCode,loginCode);
break;
}
}
else if (childNodeName.equals("site_code"))
{
siteCode = genericUtility.getColumnValue("site_code", dom);
errCode = isSiteCode(siteCode,"R-BFS");
if (errCode != null && errCode.trim().length() != 0)
{
System.out.println("errCode from isSiteCode :: [" + errCode + "]");
errString = getErrorString("site_code",errCode,loginCode);
break;
}
}
else if (childNodeName.equals("proj_code"))
{
projCode = genericUtility.getColumnValue("proj_code", dom);
sql = "SELECT COUNT(*) FROM PROJECT WHERE PROJ_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, projCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
if (cnt == 0)
{
errCode = "VTPROJ1";
errString = getErrorString("proj_code",errCode,loginCode);
break;
}
}
rs.close();
pstmt.close();
}
else if (childNodeName.equals("bom_code"))
{
String activeBom = "N",confBom = "N";
bomCode = genericUtility.getColumnValue("bom_code", dom);
if (bomCode != null && bomCode.trim().length() > 0)
{
sql = "select active,confirmed from bom where bom_code = '"+bomCode+"'";
rs = stmt.executeQuery(sql);
if(rs.next()){
activeBom = rs.getString("active");
confBom = rs.getString("confirmed");
}
if(activeBom.equalsIgnoreCase("N") || confBom.equalsIgnoreCase("N")){
errCode = "VTINVBOM";
errString = getErrorString("bom_code",errCode,loginCode);
break;
}
rs.close();
}
}
else if(childNodeName.equals("acct_code__conv_gl")){
String acctCodeConvGl = genericUtility.getColumnValue("acct_code__conv_gl", dom);
int acctCount = 0;
if(acctCodeConvGl == null || acctCodeConvGl.trim().length() == 0){
errString = getErrorString("acct_code__conv_gl","VMACTCDMT",loginCode);
break;
}else{
sql = "select count(*) from accounts where acct_code = '"+acctCodeConvGl+"'";
rs = stmt.executeQuery(sql);
if(rs.next()){
acctCount = rs.getInt(1);
}
if(acctCount == 0){
errString = getErrorString("acct_code__conv_gl","VMACTCDMT",loginCode);
break;
}
rs.close();
}
}else if(childNodeName.equals("cctr_code__conv_gl")){
int cctrCount = 0;
String cctrCodeConvGl = genericUtility.getColumnValue("cctr_code__conv_gl", dom);
if(cctrCodeConvGl == null || cctrCodeConvGl.trim().length() == 0){
errString = getErrorString("cctr_code__conv_gl","VMCCTRMT",loginCode);
break;
}else{
sql = "select count(*) from costctr where cctr_code = '"+cctrCodeConvGl+"'";
rs = stmt.executeQuery(sql);
if(rs.next()){
cctrCount = rs.getInt(1);
}
if(cctrCount == 0){
errString = getErrorString("cctr_code__conv_gl","VMCCTRMT",loginCode);
break;
}
}
}
}//END FOR
break;
case 2:
System.out.println("Validation for Detail..........");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code", dom);
siteCode = genericUtility.getColumnValue("site_code", dom1);
errCode = isItem(siteCode, itemCode, "R-BFS", conn);
if (errCode != null && errCode != "")
{
errString = getErrorString("item_code",errCode,loginCode);
break;
}
}
else if (childNodeName.equals("loc_code"))
{
locCode = genericUtility.getColumnValue("loc_code", dom);
sql = "SELECT COUNT(*) FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
if (cnt == 0)
{
errCode = "VMLOC1";
errString = getErrorString("loc_code",errCode,loginCode);
break;
}
}
pstmt.close();
rs.close();
}
if (childNodeName.equals("unit"))
{
unit = genericUtility.getColumnValue("unit", dom);
sql = "SELECT COUNT(*) FROM UOM WHERE UNIT = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unit);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
if (cnt == 0)
{
errCode = "VTUNIT1";
errString = getErrorString("unit",errCode,loginCode);
break;
}
}
pstmt.close();
rs.close();
}
else if (childNodeName.equals("mfg_date"))
{
// DO NOT CHECK MFG DATE IF STRUCTURE CONVERSION
backflushType = genericUtility.getColumnValue("backflush_type", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
mfgDateS = genericUtility.getColumnValue("mfg_date", dom);
if (backflushType.equalsIgnoreCase("J"))
{
sql = " SELECT CASE WHEN TRACK_SHELF_LIFE IS NULL THEN 'N' ELSE TRACK_SHELF_LIFE END "
+ " FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
trackShelfLife = rs.getString(1);
if (trackShelfLife.equalsIgnoreCase("Y") && mfgDateS == null)
{
errCode = "VTMFGDATE3";
errString = getErrorString("mfg_date",errCode,loginCode);
break;
}
}
else
{
errCode = "VTITEM1";
errString = getErrorString("mfg_date",errCode,loginCode);
break;
}
pstmt.close();
rs.close();
}
}
else if (childNodeName.equals("exp_date"))
{
// DO NOT CHECK EXP DATE IF STRUCTURE CONVERSION
backflushType = genericUtility.getColumnValue("backflush_type", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
expDateS = genericUtility.getColumnValue("exp_date", dom);
if (backflushType.equalsIgnoreCase("J"))
{
sql = " SELECT CASE WHEN TRACK_SHELF_LIFE IS NULL THEN 'N' ELSE TRACK_SHELF_LIFE END "
+ " FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
trackShelfLife = rs.getString(1);
if (trackShelfLife.equalsIgnoreCase("Y") && expDateS == null)
{
errCode = "VTEXPDATE1";
errString = getErrorString("exp_date",errCode,loginCode);
break;
}
}
else
{
errCode = "VTITEM1";
errString = getErrorString("exp_date",errCode,loginCode);
break;
}
pstmt.close();
rs.close();
}
}
else if (childNodeName.equals("quantity"))
{
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
if (quantity > 0)
{
siteCode = genericUtility.getColumnValue("site_code", dom1);
locCode = genericUtility.getColumnValue("loc_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
sql = " SELECT CASE WHEN (QUANTITY - ALLOC_QTY) IS NULL THEN 0 ELSE (QUANTITY - ALLOC_QTY) END"
+ " FROM STOCK WHERE SITE_CODE = ? AND LOC_CODE = ? "
+ " AND ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
stkQty = rs.getDouble(1);
}
rs.close();
pstmt.close();
if (stkQty < Math.abs(quantity))
{
errCode = "VTSTKW";
errString = getErrorString("quantity",errCode,loginCode);
break;
}
}
}
else if (childNodeName.equals("grade"))
{
grade = genericUtility.getColumnValue("grade", dom)== null? "":genericUtility.getColumnValue("grade", dom);
siteCode = genericUtility.getColumnValue("site_code", dom1);
locCode = genericUtility.getColumnValue("loc_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
sql = " SELECT COUNT(*) FROM STOCK WHERE SITE_CODE = ? AND LOC_CODE = ? "
+ " AND ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
pstmt.close();
if (cnt != 0)
{
sql = " SELECT GRADE FROM STOCK WHERE SITE_CODE = ? AND LOC_CODE = ? "
+ " AND ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
stkGrade = rs.getString(1)==null?"":rs.getString(1);
}
rs.close();
pstmt.close();
if (stkGrade != grade)
{
errCode = "VTGRVLD"; //Grade mismatch! Stock for this lot already exists with grade " + ls_stkgrade
// + ", Please change the lot no or lot sl
errString = getErrorString("grade",errCode,loginCode);
break;
}
}
}
}//END FOR
break;
case 3:
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
// if (childNodeName.equals("item_code"))
// {
// itemCode = genericUtility.getColumnValue("item_code", dom);
// siteCode = genericUtility.getColumnValue("site_code", dom1);
// itemCodeFG = genericUtility.getColumnValue("item_code", dom);
// errCode = isItem(siteCode, itemCode, "R-BFS", conn);
// if (errCode != null && errCode != "")
// {
// errString = getErrorString("item_code",errCode,loginCode);
// break;
// }
// else
// {
// backflushType = genericUtility.getColumnValue("backflush_type", dom2);
// // if (backflushType.equalsIgnoreCase("S") || backflushType.equalsIgnoreCase("C"))
//
// if ("S".equalsIgnoreCase(backflushType) || "C".equalsIgnoreCase(backflushType))
// {
//// //FOR SOLVENT & STRUCTURE CONVERSION PARENT ITEM OF BOTH HEADER/DETAIL ITEM SHOULD BE SAME
// sql = "SELECT ITEM_PARNT FROM ITEM WHERE ITEM_CODE = ? ";
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, itemCodeFG);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// parentHdr = rs.getString(1);
// sql = " SELECT ITEM_PARNT FROM ITEM WHERE ITEM_CODE = ? ";
// pstmt1 = conn.prepareStatement(sql);
// pstmt1.setString(1, itemCode);
// rs1 = pstmt1.executeQuery();
// if (rs1.next())
// {
// parentDet = rs1.getString(1);
// }
// rs1.close();
// pstmt1.close();
// }
// rs.close();
// pstmt.close();
// if (parentHdr != parentDet)
// {
// errCode = "VTITEMPAR";
// errString = getErrorString("item_code",errCode,loginCode);
// break;
// }
// }
// //if (backflushType.equalsIgnoreCase("J") || backflushType.equalsIgnoreCase("C"))
// if ("J".equalsIgnoreCase(backflushType) || "C".equalsIgnoreCase(backflushType))
//
// {
// if (itemCodeFG == itemCode)
// {
// errCode = "VTITEMSAME";
// errString = getErrorString("item_code",errCode,loginCode);
// break;
// }
// }
// }
// }
if (childNodeName.equals("loc_code"))
{
String qcReqd = "";
locCode = genericUtility.getColumnValue("loc_code", dom);
qcReqd = genericUtility.getColumnValue("qc_reqd", dom);
sql = "SELECT COUNT(*) FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
if (cnt == 0)
{
errCode = "VMLOC1";
errString = getErrorString("loc_code",errCode,loginCode);
break;
}
}
pstmt.close();
rs.close();
if (errCode == null && errCode.trim().length() == 0 && qcReqd != null && qcReqd.trim().equalsIgnoreCase("Y"))
{
sql = " SELECT COUNT(*) FROM INVSTAT A, LOCATION B WHERE B.INV_STAT = A.INV_STAT "
+ " AND B.LOC_CODE = ? AND A.AVAILABLE = 'N'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
if (cnt <= 0)
{
errCode = "VTLOCSL";
errString = getErrorString("loc_code",errCode,loginCode);
break;
}
}
pstmt.close();
rs.close();
}
}
else if (childNodeName.equals("quantity")){
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
backflushType = genericUtility.getColumnValue("backflush_type", dom1);
if (quantity == 0 && backflushType.equalsIgnoreCase("J"))
{
errCode = "VTQTY";
errString = getErrorString("quantity",errCode,loginCode);
break;
}
else if (quantity < 0){
siteCode = genericUtility.getColumnValue("site_code", dom1);
locCode = genericUtility.getColumnValue("loc_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
sql = " SELECT CASE WHEN (QUANTITY - ALLOC_QTY) IS NULL THEN 0 ELSE (QUANTITY - ALLOC_QTY) END"
+ " FROM STOCK WHERE SITE_CODE = ? AND LOC_CODE = ? "
+ " AND ITEM_CODE = ? AND LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
stkQty = rs.getDouble(1);
}
rs.close();
pstmt.close();
if (stkQty < Math.abs(quantity))
{
errCode = "VTSTKW";
errString = getErrorString("quantity",errCode,loginCode);
break;
}
}
}
else if (childNodeName.equals("unit"))
{
unit = genericUtility.getColumnValue("unit", dom);
sql = "SELECT COUNT(*) FROM UOM WHERE UNIT = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, unit);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
if (cnt == 0)
{
errCode = "VTUNIT1";
errString = getErrorString("unit",errCode,loginCode);
break;
}
}
pstmt.close();
rs.close();
}
else if (childNodeName.equals("lot_sl")){
}
else if (childNodeName.equals("pack_code"))
{
packCode = genericUtility.getColumnValue("pack_code", dom);
sql = "SELECT COUNT(*) FROM ITEM WHERE PACK_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, packCode);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
if (cnt == 0)
{
errCode = "VTPKCD1";
errString = getErrorString("pack_code",errCode,loginCode);
break;
}
}
pstmt.close();
rs.close();
}
}//END FOR
break;
case 4:
parentNodeList = dom.getElementsByTagName("Detail4");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("itm_default"))
{
}
}//END FOR
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
}
finally
{
try {
pstmt.close(); pstmt = null; rs.close(); rs = null;
conn.close();conn = null;
}catch(Exception d){}
}
System.out.println("ErrString ::"+ errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = null;
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
System.out.println("xmlString1" + xmlString1);
if (xmlString2.trim().length() > 0 )
{
System.out.println("xmlString2" + xmlString2);
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [RcpBackflushEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
int currentFormNo = 0;
StringBuffer valueXmlString = new StringBuffer();
String columnValue = null;
String grade = "", backflushType = "", siteCode = "", siteDescr = "", itemCode = "";
String unit = "", packCode = "", itemDescr = "", bomCode = "", lotNo = "", lotSl = "";
String acctStr = "", acctCodeGl = "", cctrCodeGl = "", locCode = "", locDescr = "", qcFlagEdit = "";
String siteCodeMfg = "", projCode = "", projDescr = "", mfgDateS = "", expDateS = "", shelfLife = "";
double quantity = 0, rate = 0, grossWeight = 0, tareWeight = 0, netWeight = 0;
String phyAttrib1 ="",phyAttrib2="",phyAttrib3="",phyAttrib4="",phyAttrib5="",phyAttrib6="";
NodeList parentNodeList = null;
Node parentNode = null;
Node childNode = null;
NodeList childNodeList = null;
String childNodeName = null;
int childNodeListLength = 0;
int ctr = 0;
String itemTypeDescr ="",itemType ="",itemSer ="",descr="";
MfgCommon mfgCommon = new MfgCommon();
FinCommon finCommon = new FinCommon();
String loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[RcpBackflushEJB] [itemChanged] :currentFormNo ....." +currentFormNo);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append("<Detail>");
System.out.println("Current Form No ["+currentFormNo+"]");
switch (currentFormNo)
{
case 1:
// SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals("itm_default"))
{
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + genericUtility.getValidDateString(new Timestamp(System.currentTimeMillis()).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat()) + "]]>").append("</tran_date>");
valueXmlString.append("<backflush_type>").append("<![CDATA[J]]>").append("</backflush_type>");
sql = "SELECT DESCR FROM SITE WHERE SITE_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, loginSite);
rs = pstmt.executeQuery();
if (rs.next())
{
siteDescr = rs.getString(1);
}
rs.close();
pstmt.close();
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr + "]]>").append("</site_descr>");
}
if (currentColumn.trim().equals("site_code"))
{
siteCode = genericUtility.getColumnValue("site_code", dom);
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(1);
}
rs.close();
pstmt.close();
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr + "]]>").append("</site_descr>");
}
else if (currentColumn.trim().equals("bom_code"))
{
String desc = "";
bomCode = genericUtility.getColumnValue("bom_code", dom);
sql = "select descr from bom where bom_code = '"+bomCode+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next()){
desc = rs.getString("descr");
}
valueXmlString.append("<bom_descr>").append("<![CDATA["+desc+"]]>").append("</bom_descr>");
}
else if (currentColumn.trim().equals("proj_code"))
{
projCode = genericUtility.getColumnValue("proj_code", dom);
sql = "SELECT DESCR, SITE_CODE FROM PROJECT WHERE PROJ_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, projCode);
rs = pstmt.executeQuery();
if (rs.next())
{
projDescr = rs.getString(1);
siteCode = rs.getString(2);
}
rs.close();
pstmt.close();
valueXmlString.append("<project_descr>").append("<![CDATA[" + projDescr + "]]>").append("</project_descr>");
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(1);
}
rs.close();
pstmt.close();
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr + "]]>").append("</site_descr>");
}
valueXmlString.append("</Detail>");
break;
case 2:
// SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue();
}
}
ctr++;
} while (ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
// SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE END
if (currentColumn.trim().equals("itm_default"))
{
valueXmlString.append("<amount>").append("<![CDATA[0]]>").append("</amount>");
valueXmlString.append("<quantity>").append("<![CDATA[0]]>").append("</quantity>");
valueXmlString.append("<rate>").append("<![CDATA[0]]>").append("</rate>");
}
else if (currentColumn.trim().equals("itm_defaultedit"))
{
}
else if (currentColumn.trim().equals("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code", dom);
sql = "SELECT DESCR,UNIT FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemDescr = rs.getString(1);
unit = rs.getString(2);
}
rs.close();
pstmt.close();
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
}
else if (currentColumn.trim().equals("loc_code"))
{
locCode = genericUtility.getColumnValue("loc_code", dom);
sql = "SELECT DESCR FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if (rs.next())
{
locDescr = rs.getString(1);
}
rs.close();
pstmt.close();
valueXmlString.append("<location_descr>").append("<![CDATA[" + locDescr + "]]>").append("</location_descr>");
}
else if (currentColumn.trim().equals("lot_sl"))
{
siteCode = genericUtility.getColumnValue("site_code", dom1);
locCode = genericUtility.getColumnValue("loc_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
sql = " SELECT MFG_DATE,EXP_DATE,SITE_CODE__MFG,PACK_CODE, GRADE, RATE, (QUANTITY - ALLOC_QTY) AS QTY"
+ " FROM STOCK WHERE SITE_CODE = ? AND LOC_CODE = ? AND ITEM_CODE = ? AND "
+ " LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
mfgDateS = rs.getTimestamp(1) == null ? "":genericUtility.getValidDateString(rs.getTimestamp(1).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
expDateS = rs.getTimestamp(2) == null ? "":genericUtility.getValidDateString(rs.getTimestamp(2).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
siteCodeMfg = rs.getString(3) == null ? "":rs.getString(3);
packCode = rs.getString(4) == null ? "":rs.getString(4);
grade = rs.getString(5) == null ? "":rs.getString(5);
rate = rs.getDouble(6);
quantity = rs.getDouble(7);
}
rs.close();
pstmt.close();
valueXmlString.append("<grade>").append("<![CDATA[" + grade + "]]>").append("</grade>");
valueXmlString.append("<mfg_date>").append("<![CDATA[" + mfgDateS + "]]>").append("</mfg_date>");
valueXmlString.append("<exp_date>").append("<![CDATA[" + expDateS + "]]>").append("</exp_date>");
valueXmlString.append("<site_code__mfg>").append("<![CDATA[" + siteCodeMfg + "]]>").append("</site_code__mfg>");
valueXmlString.append("<pack_code>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<quantity>").append("<![CDATA[" + quantity + "]]>").append("</quantity>");
valueXmlString.append("<amount>").append("<![CDATA[" + quantity*rate + "]]>").append("</amount>");
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
/*
/// Raman 1/2/02 - Set stock's available quantity ( quantity - alloc_qty ) select quantity,rate
// if quantity in header is negative then do not set the quantity from stock
// as the detail quantity will be a receipt instead of issue
lc_quantity = dw_header.getitemdecimal(1,"quantity")
if lc_quantity >= 0 then
select ( quantity - nvl(alloc_qty,0) ) quantity, rate
into :lc_qty, :lc_rate from stock
where item_code = :ls_itemcode and
site_code = :ls_sitecode and
loc_code = :ls_loccode and
lot_no = :ls_lotno and
lot_sl = :ls_lotsl ;
if get_sqlcode() = 0 then
if isnull(lc_rate) then lc_rate = 0
if isnull(lc_qty) then lc_qty = 0
dw_detedit[ii_currformno].setitem(1,"quantity",lc_qty)
dw_detedit[ii_currformno].setitem(1,"rate",lc_rate)
dw_detedit[ii_currformno].setitem(1,"amount",lc_rate * lc_qty)
dw_detedit[ii_currformno].setitem(1,"net_amt",lc_rate * lc_qty)
end if
gbf_itemchanged_logic(as_form_no,"quantity",as_editflag)
end if
*/
}
else if (currentColumn.trim().equals("quantity") || currentColumn.trim().equals("rate"))
{
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
rate = Double.parseDouble(genericUtility.getColumnValue("rate", dom));
valueXmlString.append("<amount>").append("<![CDATA[" + quantity*rate + "]]>").append("</amount>");
valueXmlString.append("<rate>").append("<![CDATA[" + rate + "]]>").append("</rate>");
}
valueXmlString.append("</Detail>");
break;
case 3: //RECEIPT SCREEN - HEADER OF RECEIPT BKFLSH OLD
// SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals("itm_default"))
{
valueXmlString.append("<site_code__mfg>").append("<![CDATA[" + loginSite + "]]>").append("</site_code__mfg>");
valueXmlString.append("<lot_sl>").append("<![CDATA[1S]]>").append("</lot_sl>");
valueXmlString.append("<loc_code>").append("<![CDATA[QUAR]]>").append("</loc_code>");
valueXmlString.append("<pack_code>").append("<![CDATA[DUMMY]]>").append("</pack_code>");
// valueXmlString.append("<lot_no protect = \"1\"><![CDATA[ ]]></lot_no>");
// set grade from mfgparm
grade = mfgCommon.getEnvMfg("999999","MFG_GRADE", conn);
if (grade.equalsIgnoreCase("NULLFOUND"))
{
grade = "";
}
valueXmlString.append("<grade>").append("<![CDATA[" + grade +"]]>").append("</grade>");
qcFlagEdit = mfgCommon.getEnvMfg("999999", "QC_FLAG_EDITABLE", conn);
if (qcFlagEdit.equalsIgnoreCase("Y")){
valueXmlString.append("<qc_reqd protect = \"0\">").append("<![CDATA[Y]]>").append("</qc_reqd>");
}else{
valueXmlString.append("<qc_reqd protect = \"1\">").append("<![CDATA[Y]]>").append("</qc_reqd>");
}
valueXmlString.append("<amount>").append("<![CDATA[0]]>").append("</amount>");
valueXmlString.append("<quantity>").append("<![CDATA[0]]>").append("</quantity>");
valueXmlString.append("<rate>").append("<![CDATA[0]]>").append("</rate>");
}
else if (currentColumn.trim().equals("itm_defaultedit"))
{
itemCode = genericUtility.getColumnValue("item_code", dom,"3");
String itemCode1 = genericUtility.getColumnValue("item_code", dom);
System.out.println("itemCode1 : " + itemCode1);
System.out.println("itemCode..itm_defaultedit......."+itemCode);
// sql = " SELECT PHY_ATTRIB_1,PHY_ATTRIB_2,PHY_ATTRIB_3,PHY_ATTRIB_4,PHY_ATTRIB_5,"
// + " PHY_ATTRIB_6 FROM ITEM_TYPE WHERE ITEM_TYPE = "
// + " ( SELECT ITEM_TYPE FROM ITEM WHERE ITEM_CODE = '" + itemCode + "')";
// System.out.println("SQL : " + sql);
// pstmt = conn.prepareStatement(sql);
// rs = pstmt.executeQuery();
// System.out.println("Query is executed : ");
// if(rs.next())
// {
// phyAttrib1 = rs.getString("PHY_ATTRIB_1");
// phyAttrib2 = rs.getString("PHY_ATTRIB_2");
// phyAttrib3 = rs.getString("PHY_ATTRIB_3");
// phyAttrib4 = rs.getString("PHY_ATTRIB_4");
// phyAttrib5 = rs.getString("PHY_ATTRIB_5");
// phyAttrib6 = rs.getString("PHY_ATTRIB_6");
// }
// valueXmlString.append("<phy_attrib_lab_1>").append("<![CDATA[" + phyAttrib1 + "]]>").append("</phy_attrib_lab_1>");
// valueXmlString.append("<phy_attrib_lab_2>").append("<![CDATA[" + phyAttrib2 + "]]>").append("</phy_attrib_lab_2>");
// valueXmlString.append("<phy_attrib_lab_3>").append("<![CDATA[" + phyAttrib3 + "]]>").append("</phy_attrib_lab_3>");
// valueXmlString.append("<phy_attrib_lab_4>").append("<![CDATA[" + phyAttrib4 + "]]>").append("</phy_attrib_lab_4>");
// valueXmlString.append("<phy_attrib_lab_5>").append("<![CDATA[" + phyAttrib5 + "]]>").append("</phy_attrib_lab_5>");
// valueXmlString.append("<phy_attrib_lab_6>").append("<![CDATA[" + phyAttrib6 + "]]>").append("</phy_attrib_lab_6>");
//
}
else if(currentColumn.trim().equalsIgnoreCase("item_type"))
{
itemType = genericUtility.getColumnValue("item_type", dom);
itemTypeDescr = getFieldValue("descr", "item_type", "item_type", itemType, conn);
itemTypeDescr = itemTypeDescr == null ? "" : itemTypeDescr ;
valueXmlString.append("<item_type_descr>").append("<![CDATA[" + itemTypeDescr + "]]>").append("</item_type_descr>");
sql = " SELECT PHY_ATTRIB_1,PHY_ATTRIB_2,PHY_ATTRIB_3,PHY_ATTRIB_4,PHY_ATTRIB_5,"
+ " PHY_ATTRIB_6,unit FROM ITEM_TYPE WHERE ITEM_TYPE = '"+itemType+" ' ";
System.out.println("SQL : " + sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("Query is executed : ");
if(rs.next())
{
phyAttrib1 = rs.getString("PHY_ATTRIB_1");
phyAttrib2 = rs.getString("PHY_ATTRIB_2");
phyAttrib3 = rs.getString("PHY_ATTRIB_3");
phyAttrib4 = rs.getString("PHY_ATTRIB_4");
phyAttrib5 = rs.getString("PHY_ATTRIB_5");
phyAttrib6 = rs.getString("PHY_ATTRIB_6");
unit =rs.getString("unit");
}
valueXmlString.append("<lphy_attrib_1>").append("<![CDATA[" + phyAttrib1 + "]]>").append("</lphy_attrib_1>");
valueXmlString.append("<lphy_attrib_2>").append("<![CDATA[" + phyAttrib2 + "]]>").append("</lphy_attrib_2>");
valueXmlString.append("<lphy_attrib_3>").append("<![CDATA[" + phyAttrib3 + "]]>").append("</lphy_attrib_3>");
valueXmlString.append("<lphy_attrib_4>").append("<![CDATA[" + phyAttrib4 + "]]>").append("</lphy_attrib_4>");
valueXmlString.append("<lphy_attrib_5>").append("<![CDATA[" + phyAttrib5 + "]]>").append("</lphy_attrib_5>");
valueXmlString.append("<lphy_attrib_6>").append("<![CDATA[" + phyAttrib6 + "]]>").append("</lphy_attrib_6>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
}
else if(currentColumn.trim().equalsIgnoreCase("item_ser"))
{
itemSer = genericUtility.getColumnValue("item_ser", dom);
System.out.println("itemSer : " + itemSer);
sql = " SELECT DESCR FROM ITEMSER WHERE ITEM_SER ='"+itemSer+"'";
System.out.println("SQL : " + sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("Query is executed : ");
if(rs.next())
{
descr = rs.getString(1);
System.out.println("descr .......... "+descr);
}
valueXmlString.append("<itemser_descr>").append("<![CDATA[" + descr + "]]>").append("</itemser_descr>");
}
else if (currentColumn.trim().equals("item_code"))
{
String qcReqd = null;
itemCode = genericUtility.getColumnValue("item_code", dom);
System.out.println("itemCode from dom [" + itemCode + "]");
siteCode = genericUtility.getColumnValue("site_code", dom1);
System.out.println("siteCode from dom1 [" + siteCode + "]");
sql = "SELECT DESCR,UNIT,PACK_CODE FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemDescr = rs.getString(1);
unit = rs.getString(2);
packCode = rs.getString(3);
}
rs.close();
pstmt.close();
//MfgCommon mfgCommon = new MfgCommon();
String qcRqYn = mfgCommon.getEnvMfg("999999","QC_FLAG_EDITABLE", conn);
//mfgCommon = null;
System.out.println("qcRqYn ["+qcRqYn+"]");
if(!("Y".equalsIgnoreCase(qcRqYn)))
{
sql = "SELECT QC_REQD FROM SITEITEM WHERE ITEM_CODE = '"+itemCode+"'";
System.out.println("sql["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
qcReqd = rs.getString(1);
rs.close();
pstmt.close();
}
else
{
sql = "SELECT QC_REQD FROM ITEM WHERE ITEM_CODE = '"+itemCode+"'";
System.out.println("sql["+sql+"]");
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
qcReqd = rs.getString(1);
rs.close();
pstmt.close();
}
}
System.out.println("Qc Required for the item ["+itemCode+"] is ["+qcReqd+"]");
if("Y".equalsIgnoreCase(qcReqd))
{
valueXmlString.append("<lot_no protect = \"1\"><![CDATA[ ]]></lot_no>");
}
else
{
valueXmlString.append("<lot_no protect = \"0\"><![CDATA[ ]]></lot_no>");
}
}
else
{
valueXmlString.append("<lot_no protect = \"0\"><![CDATA[ ]]></lot_no>");
}
// itemCode = genericUtility.getColumnValue("item_code", dom);
//itemDescr = getFieldValue("descr", "item", "item_code", itemCode, conn);
// itemDescr = itemDescr == null ? "" : itemDescr ;
// unit = getFieldValue("unit", "item", "item_code", itemCode, conn);
// valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
// valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
// sql = " SELECT PHY_ATTRIB_1,PHY_ATTRIB_2,PHY_ATTRIB_3,PHY_ATTRIB_4,PHY_ATTRIB_5,"
// + " PHY_ATTRIB_6 FROM ITEM_TYPE WHERE ITEM_TYPE = "
// + " ( SELECT ITEM_TYPE FROM ITEM WHERE ITEM_CODE = '" + itemCode + "')";
// System.out.println("SQL : " + sql);
// pstmt = conn.prepareStatement(sql);
// rs = pstmt.executeQuery();
// System.out.println("Query is executed : ");
// if(rs.next())
// {
// phyAttrib1 = rs.getString("PHY_ATTRIB_1");
// phyAttrib2 = rs.getString("PHY_ATTRIB_2");
// phyAttrib3 = rs.getString("PHY_ATTRIB_3");
// phyAttrib4 = rs.getString("PHY_ATTRIB_4");
// phyAttrib5 = rs.getString("PHY_ATTRIB_5");
// phyAttrib6 = rs.getString("PHY_ATTRIB_6");
// }
// rs.close();
// valueXmlString.append("<phy_attrib_lab_1>").append("<![CDATA[" + phyAttrib1 + "]]>").append("</phy_attrib_lab_1>");
// valueXmlString.append("<phy_attrib_lab_2>").append("<![CDATA[" + phyAttrib2 + "]]>").append("</phy_attrib_lab_2>");
// valueXmlString.append("<phy_attrib_lab_3>").append("<![CDATA[" + phyAttrib3 + "]]>").append("</phy_attrib_lab_3>");
// valueXmlString.append("<phy_attrib_lab_4>").append("<![CDATA[" + phyAttrib4 + "]]>").append("</phy_attrib_lab_4>");
// valueXmlString.append("<phy_attrib_lab_5>").append("<![CDATA[" + phyAttrib5 + "]]>").append("</phy_attrib_lab_5>");
// valueXmlString.append("<phy_attrib_lab_6>").append("<![CDATA[" + phyAttrib6 + "]]>").append("</phy_attrib_lab_6>");
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
valueXmlString.append("<pack_code><![CDATA[").append(packCode == null ? "":packCode).append("]]></pack_code>");
// GET ACCOUNT CODE CONV GL FROM ITEM ACCT DETR
acctStr = finCommon.getFromAcctDetr(itemCode, "","CONVGL", conn);
if (acctStr != null && acctStr.trim().length() > 0)
{
acctCodeGl = acctStr.substring(0,acctStr.indexOf(","));
cctrCodeGl = acctStr.substring(acctStr.indexOf(",")+1);
}
//valueXmlString.append("<acct_code__conv_gl>").append("<![CDATA[" + acctCodeGl + "]]>").append("</acct_code__conv_gl>");
//valueXmlString.append("<cctr_code__conv_gl>").append("<![CDATA[" + cctrCodeGl + "]]>").append("</cctr_code__conv_gl>");
}
else if (currentColumn.trim().equals("loc_code"))
{
locCode = genericUtility.getColumnValue("loc_code", dom);
backflushType = genericUtility.getColumnValue("backflush_type", dom1);
sql = "SELECT DESCR FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, locCode);
rs = pstmt.executeQuery();
if (rs.next())
{
locDescr = rs.getString(1);
}
rs.close();
pstmt.close();
valueXmlString.append("<location_descr>").append("<![CDATA[" + locDescr + "]]>").append("</location_descr>");
// SETTING OF MFG_DATE AND EXP_DATE FROM STOCK IF PRESENT.
siteCode = genericUtility.getColumnValue("site_code", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
sql = " SELECT SITE_CODE__MFG,PACK_CODE FROM STOCK "
+ " WHERE SITE_CODE = ? AND LOC_CODE = ? AND ITEM_CODE = ? AND "
+ " LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
siteCodeMfg = rs.getString(1);
packCode = rs.getString(2);
}
rs.close();
pstmt.close();
valueXmlString.append("<site_code__mfg>").append("<![CDATA[" + siteCodeMfg + "]]>").append("</site_code__mfg>");
valueXmlString.append("<pack_code>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
// MFG_DATE/EXP_DATE WILL BE SET FROM DETAILS OR WILL BE ENTERED.
}
else if(currentColumn.trim().equalsIgnoreCase("phy_attrib_1") || currentColumn.trim().equalsIgnoreCase("phy_attrib_2") || currentColumn.trim().equalsIgnoreCase("phy_attrib_3") || currentColumn.trim().equalsIgnoreCase("phy_attrib_4") || currentColumn.trim().equalsIgnoreCase("phy_attrib_5") || currentColumn.trim().equalsIgnoreCase("phy_attrib_6"))
{
String phyAttribDom1 = genericUtility.getColumnValue("phy_attrib_1", dom) ;
String phyAttribDom2 = genericUtility.getColumnValue("phy_attrib_2", dom) ;
String phyAttribDom3 = genericUtility.getColumnValue("phy_attrib_3", dom) ;
String phyAttribDom4 = genericUtility.getColumnValue("phy_attrib_4", dom) ;
String phyAttribDom5 = genericUtility.getColumnValue("phy_attrib_5", dom) ;
String phyAttribDom6 = genericUtility.getColumnValue("phy_attrib_6", dom) ;
phyAttribDom1 = phyAttribDom1 == null ? "" : phyAttribDom1 ;
phyAttribDom2 = phyAttribDom2 == null ? "" : phyAttribDom2 ;
phyAttribDom3 = phyAttribDom3 == null ? "" : phyAttribDom3 ;
phyAttribDom4 = phyAttribDom4 == null ? "" : phyAttribDom4 ;
phyAttribDom5 = phyAttribDom5 == null ? "" : phyAttribDom5 ;
phyAttribDom6 = phyAttribDom6 == null ? "" : phyAttribDom6 ;
sql = " SELECT ITEM_CODE FROM ITEM WHERE PHY_ATTRIB_1 = ? AND PHY_ATTRIB_2 = ? "
+ " AND PHY_ATTRIB_3 = ? AND PHY_ATTRIB_4 = ? AND PHY_ATTRIB_5 = ? AND "
+ " PHY_ATTRIB_6 = ? " ;
System.out.println("SQL : " + sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, phyAttribDom1);
pstmt.setString(2, phyAttribDom2);
pstmt.setString(3, phyAttribDom3);
pstmt.setString(4, phyAttribDom4);
pstmt.setString(5, phyAttribDom5);
pstmt.setString(6, phyAttribDom6);
rs = pstmt.executeQuery();
if(rs.next())
{
itemCode = rs.getString("ITEM_CODE");
sql = " SELECT PHY_ATTRIB_1,PHY_ATTRIB_2,PHY_ATTRIB_3,PHY_ATTRIB_4,"
+ " PHY_ATTRIB_5, PHY_ATTRIB_6 FROM ITEM_TYPE WHERE ITEM_TYPE = "
+ " ( SELECT ITEM_TYPE FROM ITEM WHERE ITEM_CODE = '" + itemCode + "')";
System.out.println("SQL : " + sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("Query is executed : ");
if(rs.next())
{
phyAttrib1 = rs.getString("PHY_ATTRIB_1");
phyAttrib2 = rs.getString("PHY_ATTRIB_2");
phyAttrib3 = rs.getString("PHY_ATTRIB_3");
phyAttrib4 = rs.getString("PHY_ATTRIB_4");
phyAttrib5 = rs.getString("PHY_ATTRIB_5");
phyAttrib6 = rs.getString("PHY_ATTRIB_6");
}
itemDescr = getFieldValue("descr", "item", "item_code", itemCode, conn);
itemDescr = itemDescr == null ? "" : itemDescr ;
unit = getFieldValue("unit", "item", "item_code", itemCode, conn);
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
// valueXmlString.append("<phy_attrib_lab_1>").append("<![CDATA[" + phyAttrib1 + "]]>").append("</phy_attrib_lab_1>");
// valueXmlString.append("<phy_attrib_lab_2>").append("<![CDATA[" + phyAttrib2 + "]]>").append("</phy_attrib_lab_2>");
// valueXmlString.append("<phy_attrib_lab_3>").append("<![CDATA[" + phyAttrib3 + "]]>").append("</phy_attrib_lab_3>");
// valueXmlString.append("<phy_attrib_lab_4>").append("<![CDATA[" + phyAttrib4 + "]]>").append("</phy_attrib_lab_4>");
// valueXmlString.append("<phy_attrib_lab_5>").append("<![CDATA[" + phyAttrib5 + "]]>").append("</phy_attrib_lab_5>");
// valueXmlString.append("<phy_attrib_lab_6>").append("<![CDATA[" + phyAttrib6 + "]]>").append("</phy_attrib_lab_6>");
valueXmlString.append("<lphy_attrib_1>").append("<![CDATA[" + phyAttrib1 + "]]>").append("</lphy_attrib_1>");
valueXmlString.append("<lphy_attrib_2>").append("<![CDATA[" + phyAttrib2 + "]]>").append("</lphy_attrib_2>");
valueXmlString.append("<lphy_attrib_3>").append("<![CDATA[" + phyAttrib3 + "]]>").append("</lphy_attrib_3>");
valueXmlString.append("<lphy_attrib_4>").append("<![CDATA[" + phyAttrib4 + "]]>").append("</lphy_attrib_4>");
valueXmlString.append("<lphy_attrib_5>").append("<![CDATA[" + phyAttrib5 + "]]>").append("</lphy_attrib_5>");
valueXmlString.append("<lphy_attrib_6>").append("<![CDATA[" + phyAttrib6 + "]]>").append("</lphy_attrib_6>");
}
else
{
itemCode = "";
itemDescr = "";
phyAttrib1 = "";
phyAttrib2 = "";
phyAttrib3 = "";
phyAttrib4 = "";
phyAttrib5 = "";
phyAttrib6 = "";
unit = "";
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
valueXmlString.append("<phy_attrib_lab_1>").append("<![CDATA[" + phyAttrib1 + "]]>").append("</phy_attrib_lab_1>");
valueXmlString.append("<phy_attrib_lab_2>").append("<![CDATA[" + phyAttrib2 + "]]>").append("</phy_attrib_lab_2>");
valueXmlString.append("<phy_attrib_lab_3>").append("<![CDATA[" + phyAttrib3 + "]]>").append("</phy_attrib_lab_3>");
valueXmlString.append("<phy_attrib_lab_4>").append("<![CDATA[" + phyAttrib4 + "]]>").append("</phy_attrib_lab_4>");
valueXmlString.append("<phy_attrib_lab_5>").append("<![CDATA[" + phyAttrib5 + "]]>").append("</phy_attrib_lab_5>");
valueXmlString.append("<phy_attrib_lab_6>").append("<![CDATA[" + phyAttrib6 + "]]>").append("</phy_attrib_lab_6>");
}
}
else if (currentColumn.trim().equals("lot_no") || currentColumn.trim().equals("lot_sl"))
{
siteCode = genericUtility.getColumnValue("site_code", dom1);
locCode = genericUtility.getColumnValue("loc_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
sql = " SELECT MFG_DATE,EXP_DATE,SITE_CODE__MFG,PACK_CODE, GRADE, RATE FROM STOCK "
+ " WHERE SITE_CODE = ? AND LOC_CODE = ? AND ITEM_CODE = ? AND "
+ " LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
mfgDateS = rs.getTimestamp(1) == null ? "":genericUtility.getValidDateString(rs.getTimestamp(1).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
expDateS = rs.getTimestamp(2) == null ? "":genericUtility.getValidDateString(rs.getTimestamp(2).toString(), genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat());
siteCodeMfg = rs.getString(3);
packCode = rs.getString(4);
grade = rs.getString(5);
rate = rs.getDouble(6);
}
rs.close();
pstmt.close();
valueXmlString.append("<grade>").append("<![CDATA[" + grade + "]]>").append("</grade>");
valueXmlString.append("<mfg_date>").append("<![CDATA[" + mfgDateS + "]]>").append("</mfg_date>");
valueXmlString.append("<exp_date>").append("<![CDATA[" + expDateS + "]]>").append("</exp_date>");
valueXmlString.append("<site_code__mfg>").append("<![CDATA[" + siteCodeMfg + "]]>").append("</site_code__mfg>");
valueXmlString.append("<pack_code>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
// IF QUANTITY IS NEGATIVE SET THE AMOUNT BASED ON STOCK AS ISSUE WILL BE DONE INSTEAD OF RECEIPT
if (quantity < 0)
{
valueXmlString.append("<amount>").append("<![CDATA[" + quantity*rate + "]]>").append("</amount>");
valueXmlString.append("<inv_value>").append("<![CDATA[" + quantity*rate + "]]>").append("</inv_value>");
}
}
else if (currentColumn.trim().equals("mfg_date"))
{
mfgDateS = genericUtility.getColumnValue("mfg_date", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
sql = "SELECT SHELF_LIFE FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
shelfLife = rs.getString(1);
}
rs.close();
pstmt.close();
if (shelfLife == null && shelfLife.trim().length() == 0)
{
expDateS = "";
}
else
{
expDateS = "";
// ??? ldt_exp_date = gf_calc_expiry(ldt_mfg_date,mshlife)
}
valueXmlString.append("<exp_date>").append("<![CDATA[" + expDateS + "]]>").append("</exp_date>");
}
else if (currentColumn.trim().equals("gross_weight") || currentColumn.trim().equals("tare_weight"))
{
grossWeight = Double.parseDouble(genericUtility.getColumnValue("gross_weight", dom));
tareWeight = Double.parseDouble(genericUtility.getColumnValue("tare_weight", dom));
// if (grossWeight == null)
// {
// grossWeight = 0;
// }
// if (tareWeight == null)
// {
// tareWeight = 0;
// }
netWeight = grossWeight - tareWeight;
valueXmlString.append("<net_weight>").append("<![CDATA[" + netWeight + "]]>").append("</net_weight>");
}
else if (currentColumn.trim().equals("amount"))
{
valueXmlString.append("<inv_value>").append("<![CDATA[" + columnValue + "]]>").append("</inv_value>");
}
else if (currentColumn.trim().equals("quantity"))
{
rate = 0;
siteCode = genericUtility.getColumnValue("site_code", dom1);
locCode = genericUtility.getColumnValue("loc_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom);
rate = Double.parseDouble(genericUtility.getColumnValue("rate", dom));
//rate = Double.parseDouble(if(genericUtility.getColumnValue("rate", dom)==null?"0":genericUtility.getColumnValue("rate", dom)));
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
if (quantity < 0)
{
// SET THE INVENTORY VALUE AND AMOUNT BASED ON STOCK AND ISSUE WILL BE DONE INSTEAD OF RECEIPT
sql = " SELECT RATE FROM STOCK WHERE SITE_CODE = ? AND LOC_CODE = ? AND ITEM_CODE = ? AND "
+ " LOT_NO = ? AND LOT_SL = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, locCode);
pstmt.setString(3, itemCode);
pstmt.setString(4, lotNo);
pstmt.setString(5, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
rate = rs.getDouble(1);
}
rs.close();
pstmt.close();
}
valueXmlString.append("<amount>").append("<![CDATA[" + quantity*rate + "]]>").append("</amount>");
valueXmlString.append("<inv_value>").append("<![CDATA[" + quantity*rate + "]]>").append("</inv_value>");
}
else if (currentColumn.trim().equals("rate"))
{
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
rate = Double.parseDouble(genericUtility.getColumnValue("rate", dom));
valueXmlString.append("<amount>").append("<![CDATA[" + quantity*rate + "]]>").append("</amount>");
valueXmlString.append("<inv_value>").append("<![CDATA[" + quantity*rate + "]]>").append("</inv_value>");
}
valueXmlString.append("</Detail>");
break;
case 4:
// SEARCHING THE DOM FOR THE INCOMING COLUMN VALUE START
parentNodeList = dom.getElementsByTagName("Detail4");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'");
if (currentColumn.trim().equals("emp_code"))
{
String empCode = "",fname = "",lname = "";
empCode = genericUtility.getColumnValue("emp_code", dom);
sql = "select emp_fname,emp_lname from employee where emp_code = '"+empCode+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next()){
fname = rs.getString("emp_fname");
lname = rs.getString("emp_lname");
}
rs.close();
pstmt.close();
valueXmlString.append("<emp_fname>").append("<![CDATA["+fname+"]]>").append("</emp_fname>");
valueXmlString.append("<emp_lname>").append("<![CDATA["+lname+"]]>").append("</emp_lname>");
}
valueXmlString.append("</Detail>");
}//END OF SWITCH
valueXmlString.append("</Root>");
}//END OF TRY
catch(Exception e)
{
System.out.println("Exception ::"+ e.getMessage());
e.printStackTrace();
}
finally
{
try
{
if (rs != null)
{
rs.close(); rs = null;
pstmt.close(); pstmt = null;
conn.close();conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
}
}
return valueXmlString.toString();
}//END OF ITEMCHANGE
private String getFieldValue(String column,String tableName, String columnName, String columnValue,Connection conn)
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String value = null;
String sql = null;
sql = " select "+column+" from "+tableName+" where "+columnName+" = '" + columnValue + "' ";
try
{
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("\n\n\n Query Executed " + sql+ "\n\n******************");
if(rs.next())
{
value = rs.getString(1) != null ? rs.getString(1) : " ";
}
else
{
value = " ";
}
rs.close();
pstmt.close();
}
catch(Exception exception)
{
exception.printStackTrace();
System.out.println("Exception ::" + exception.getMessage());
}
return value;
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcpBackflushMultiLocal extends ValidatorLocal//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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;
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import org.w3c.dom.*;
import javax.annotation.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcpBackflushMultiPos extends ValidatorEJB implements RcpBackflushMultiPosLocal,RcpBackflushMultiPosRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}
*/
public String postSave() throws RemoteException,ITMException
{
return "";
}
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)//throws RemoteException //,ITMException for ejb3
{
System.out.println("RcpBackFlushMultiPosEJB called");
System.out.println("xmlString1:::::["+xmlString1+"]");
System.out.println("domId:::::["+domId+"]");
System.out.println("objContext:::::["+objContext+"]");
System.out.println("xtraParams:::::["+xtraParams+"]");
System.out.println("editFlag:::::["+editFlag+"]");
System.out.println("windowName:::::["+windowName+"]");
Document dom = null;
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
executePostSaveRec(dom,domId,objContext,editFlag,xtraParams, conn);
}
}
catch(Exception e)
{
System.out.println("Exception :RcpBackFlushMultiPosEJB ::" + e.getMessage() + ":");
e.printStackTrace();
//throw new ITMException(e); // for ejb3
}
return "";
}
private String executePostSaveRec(Document dom, String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException
{
System.out.println("ExecutePostSaveRec *******************************************");
Statement stmt = null;
ResultSet rs = null;
String siteCodeReq = "", itemCode = "", lineNo = "",locCode = "", lotNo = "", lotSl = "";
String line = "", errString = "";
HashMap strAllocate = null;
double quantity = 0d;
java.sql.Date tranDate = null;
String updateStatus = "",quantityStr = "",tranId = "";
NodeList hdrDom = null;
Node currDetail = null;
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
String windowName = "W_RCP_BACKFLUSH";
try
{
stmt = conn.createStatement();
tranDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("\n tranDate :"+tranDate);
hdrDom = dom.getElementsByTagName("Detail1");
siteCodeReq = GenericUtility.getInstance().getColumnValueFromNode("site_code",hdrDom.item(0));
tranId = GenericUtility.getInstance().getColumnValueFromNode("tran_id",hdrDom.item(0));
System.out.println("\n tranId :"+tranId);
currDetail = getCurrentDetailFromDom(dom,domID);
updateStatus = getCurrentUpdateFlag(currDetail);
System.out.println("updateStatus :: "+updateStatus);
if (currDetail != null && !updateStatus.equalsIgnoreCase("D"))
{
lineNo = GenericUtility.getInstance().getColumnValueFromNode("line_no",currDetail);
itemCode = GenericUtility.getInstance().getColumnValueFromNode("item_code",currDetail);
locCode = GenericUtility.getInstance().getColumnValueFromNode("loc_code",currDetail);
lotNo = GenericUtility.getInstance().getColumnValueFromNode("lot_no",currDetail);
lotSl = GenericUtility.getInstance().getColumnValueFromNode("lot_sl",currDetail);
quantityStr = GenericUtility.getInstance().getColumnValueFromNode("quantity",currDetail);
quantity = Double.parseDouble(quantityStr);
System.out.println("lineNo ["+lineNo+"]");
System.out.println("itemCode ["+itemCode+"]");
System.out.println("locCode ["+locCode+"]");
System.out.println("lotNo ["+lotNo+"]");
System.out.println("lotSl ["+lotSl+"]");
System.out.println("quantity ["+quantity+"]");
line = " " + lineNo;
System.out.println("line :"+line);
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","R-BFS");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line",line.substring(line.length()-3));
strAllocate.put("site_code",siteCodeReq);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win",windowName);
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString ::: " + errString);
if (errString == "")
{
System.out.println("invAllocTrace.updateInvallocTrace : Sucessuful!");
}
}
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in RcpBackFlushMultiPosEJB :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in RcpBackFlushMultiPosEJB :"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.err.println("Exception :RcpBackFlushMultiPosEJB:\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
return "";
}
private Node getCurrentDetailFromDom(Document dom,String domId)
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail2");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
return reqDetail;
}
private String getCurrentUpdateFlag(Node currDetail)
{
NodeList currDetailList = null;
String updateStatus = "",nodeName = "";
int currDetailListLength = 0;
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
nodeName = currDetailList.item(i).getNodeName();
if (nodeName.equalsIgnoreCase("Attribute"))
{
updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
break;
}
}
return updateStatus;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcpBackflushMultiPosLocal extends ValidatorLocal //, EJBObject
{
public String postSave() throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn);
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcpBackflushMultiPosRemote extends ValidatorRemote //, EJBObject
{
public String postSave() throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn);
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcpBackflushMultiPrs extends ValidatorEJB implements RcpBackflushMultiPrsLocal , RcpBackflushMultiPrsRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String preSave() throws RemoteException,ITMException
{
return "";
}
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException
{
System.out.println("RcpBackFlushMultiPrsEJB called");
Document dom = null;
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
executePreSaveRec(dom,domId,objContext,editFlag,xtraParams, conn);
}
}
catch(Exception e)
{
System.out.println("Exception :RcpBackFlushMultiPrsEJB ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return "";
}
private String executePreSaveRec(Document dom, String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException
{
Statement stmt = null;
ResultSet rs = null;
String siteCodeReq = "", itemCode = "", lineNo = "",locCode = "", lotNo = "", lotSl = "";
String sql = "", line = "", errString = "";
HashMap strAllocate = null;
double quantity = 0d;
java.sql.Date tranDate = null;
String updateStatus = "",quantityStr = "",tranId = "";
NodeList hdrDom = null;
Node currDetail = null;
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
String windowName = "W_RCP_BACKFLUSH";
try
{
stmt = conn.createStatement();
tranDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("\n tranDate :"+tranDate);
hdrDom = dom.getElementsByTagName("Detail1");
siteCodeReq = GenericUtility.getInstance().getColumnValueFromNode("site_code",hdrDom.item(0));
tranId = GenericUtility.getInstance().getColumnValueFromNode("tran_id",hdrDom.item(0));
System.out.println("\n tranId :"+tranId);
currDetail = getCurrentDetailFromDom(dom,domID);
updateStatus = getCurrentUpdateFlag(currDetail);
System.out.println("updateStatus :: "+updateStatus);
if (currDetail != null && !updateStatus.equalsIgnoreCase("A"))
{
lineNo = GenericUtility.getInstance().getColumnValueFromNode("line_no",currDetail);
itemCode = GenericUtility.getInstance().getColumnValueFromNode("item_code",currDetail);
locCode = GenericUtility.getInstance().getColumnValueFromNode("loc_code",currDetail);
lotNo = GenericUtility.getInstance().getColumnValueFromNode("lot_no",currDetail);
lotSl = GenericUtility.getInstance().getColumnValueFromNode("lot_sl",currDetail);
if (updateStatus.equalsIgnoreCase("E") || updateStatus.equalsIgnoreCase("D"))
{
sql = "SELECT QUANTITY FROM RCP_BACKFLUSH_ISS WHERE TRAN_ID = '"+tranId+"' AND LINE_NO = '"+lineNo + "'";
rs = stmt.executeQuery(sql);
if (rs.next())
{
quantityStr = rs.getString("QUANTITY");
}
}
quantity = Double.parseDouble(quantityStr);
// if (tranType.equals("I"))
// {
line = " " + lineNo;
System.out.println("line :"+line);
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","R-BFH");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line",line.substring(line.length()-3));
strAllocate.put("site_code",siteCodeReq);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(-1*quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win",windowName);
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString ::: " + errString);
if (errString == "")
{
System.out.println("invAllocTrace.updateInvallocTrace : Sucessuful!");
}
// }
}
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in RcpBackFlushMultiPrsEJB :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in RcpBackFlushMultiPrsEJB :"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.err.println("Exception :RcpBackFlushMultiPrsEJB:\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
return "";
}
private Node getCurrentDetailFromDom(Document dom,String domId)
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail2");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
return reqDetail;
}
private String getCurrentUpdateFlag(Node currDetail)
{
NodeList currDetailList = null;
String updateStatus = "",nodeName = "";
int currDetailListLength = 0;
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
nodeName = currDetailList.item(i).getNodeName();
if (nodeName.equalsIgnoreCase("Attribute"))
{
updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
break;
}
}
return updateStatus;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcpBackflushMultiPrsLocal extends ValidatorLocal//, EJBObject
{
public String preSave() throws RemoteException,ITMException;
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcpBackflushMultiPrsRemote extends ValidatorRemote//, EJBObject
{
public String preSave() throws RemoteException,ITMException;
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcpBackflushMultiRemote extends ValidatorRemote //,EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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;
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcptBackFlushPos extends ValidatorEJB implements RcptBackFlushPosLocal ,RcptBackFlushPosRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String postSave() throws RemoteException,ITMException
{
return "";
}
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
System.out.println("RcptBackFlushPosEJB called");
Document dom = null;
String errString = "";
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
errString = executePostSaveRec(dom,domId,objContext,editFlag,xtraParams, windowName, conn);
}
}
catch(Exception e)
{
System.out.println("Exception :RcptBackFlushPosEJB ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
private String executePostSaveRec(Document dom, String domID,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
Statement stmt = null;
ResultSet rs = null;
String siteCodeReq = "", itemCode = "", lineNo = "",locCode = "", lotNo = "", lotSl = "";
String sql = "", line = "", tranType = "", errString = "";
HashMap strAllocate = null;
double quantity = 0d;
int updateCnt = 0, retVal = 0;
java.sql.Date tranDate = null;
String updateStatus = "",quantityStr = "",tranId = "";
NodeList hdrDom = null;
Node currDetail = null;
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
try
{
stmt = conn.createStatement();
tranDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("\n tranDate :"+tranDate);
hdrDom = dom.getElementsByTagName("Detail1");
tranType = GenericUtility.getInstance().getColumnValueFromNode("tran_type",hdrDom.item(0));
siteCodeReq = GenericUtility.getInstance().getColumnValueFromNode("site_code",hdrDom.item(0));
tranId = GenericUtility.getInstance().getColumnValueFromNode("tran_id",hdrDom.item(0));
System.out.println("\n tranId :"+tranId);
currDetail = getCurrentDetailFromDom(dom,domID);
updateStatus = getCurrentUpdateFlag(currDetail);
System.out.println("updateStatus :: "+updateStatus);
if (currDetail != null && !updateStatus.equalsIgnoreCase("D"))
{
lineNo = GenericUtility.getInstance().getColumnValueFromNode("line_no",currDetail);
itemCode = GenericUtility.getInstance().getColumnValueFromNode("item_code",currDetail);
locCode = GenericUtility.getInstance().getColumnValueFromNode("loc_code",currDetail);
lotNo = GenericUtility.getInstance().getColumnValueFromNode("lot_no",currDetail);
lotSl = GenericUtility.getInstance().getColumnValueFromNode("lot_sl",currDetail);
quantityStr = GenericUtility.getInstance().getColumnValueFromNode("quantity",currDetail);
quantity = Double.parseDouble(quantityStr);
// if (tranType.equals("I"))
// {
if (quantity > 0)
{
line = " " + lineNo;
System.out.println("line :"+line);
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","R-BFS");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line",line.substring(line.length()-3));
strAllocate.put("site_code",siteCodeReq);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win",windowName);
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString ::: " + errString);
if (errString == "")
{
System.out.println("invAllocTrace.updateInvallocTrace : Sucessuful!");
}
}
// }
}
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in RcptBackFlushPosEJB :"+sqx);
sqx.printStackTrace();
errString = "ERROR";
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in RcptBackFlushPosEJB :"+e);
e.printStackTrace();
errString = "ERROR";
throw new ITMException(e);
}
finally
{
try
{
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.err.println("Exception :RcptBackFlushPosEJB:\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
//return errString;
}
private Node getCurrentDetailFromDom(Document dom,String domId)
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail2");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
return reqDetail;
}
private String getCurrentUpdateFlag(Node currDetail)
{
NodeList currDetailList = null;
String updateStatus = "",nodeName = "";
int currDetailListLength = 0;
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
nodeName = currDetailList.item(i).getNodeName();
if (nodeName.equalsIgnoreCase("Attribute"))
{
updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
break;
}
}
return updateStatus;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcptBackFlushPosLocal extends ValidatorLocal//, EJBObject
{
public String postSave() throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcptBackFlushPosRemote extends ValidatorRemote//, EJBObject
{
public String postSave() throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcptBackFlushPrs extends ValidatorEJB implements RcptBackFlushPrsLocal, RcptBackFlushPrsRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String preSave() throws RemoteException,ITMException
{
return "";
}
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
System.out.println("RcptBackFlushPrsEJB called");
Document dom = null;
String errString = "";
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
errString = executePreSaveRec(dom,domId,objContext,editFlag,xtraParams, windowName, conn);
}
}
catch(Exception e)
{
System.out.println("Exception :RcptBackFlushPrsEJB ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
private String executePreSaveRec(Document dom, String domID,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
Statement stmt = null;
ResultSet rs = null;
String siteCodeReq = "", itemCode = "", lineNo = "",locCode = "", lotNo = "", lotSl = "";
String sql = "", line = "", tranType = "", errString = "";
HashMap strAllocate = null;
double quantity = 0d;
int updateCnt = 0, retVal = 0;
java.sql.Date tranDate = null;
String updateStatus = "",quantityStr = "",tranId = "";
NodeList hdrDom = null;
Node currDetail = null;
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
try
{
stmt = conn.createStatement();
tranDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("\n tranDate :"+tranDate);
hdrDom = dom.getElementsByTagName("Detail1");
tranType = GenericUtility.getInstance().getColumnValueFromNode("tran_type",hdrDom.item(0));
siteCodeReq = GenericUtility.getInstance().getColumnValueFromNode("site_code",hdrDom.item(0));
tranId = GenericUtility.getInstance().getColumnValueFromNode("tran_id",hdrDom.item(0));
System.out.println("\n tranId :"+tranId);
currDetail = getCurrentDetailFromDom(dom,domID);
updateStatus = getCurrentUpdateFlag(currDetail);
System.out.println("updateStatus :: "+updateStatus);
if (currDetail != null && !updateStatus.equalsIgnoreCase("A"))
{
lineNo = GenericUtility.getInstance().getColumnValueFromNode("line_no",currDetail);
itemCode = GenericUtility.getInstance().getColumnValueFromNode("item_code",currDetail);
locCode = GenericUtility.getInstance().getColumnValueFromNode("loc_code",currDetail);
lotNo = GenericUtility.getInstance().getColumnValueFromNode("lot_no",currDetail);
lotSl = GenericUtility.getInstance().getColumnValueFromNode("lot_sl",currDetail);
if (updateStatus.equalsIgnoreCase("E") || updateStatus.equalsIgnoreCase("D"))
{
sql = "SELECT QUANTITY FROM RECEIPT_BACKFLUSH_DET WHERE TRAN_ID = '"+tranId+"' AND LINE_NO = '"+lineNo + "'";
rs = stmt.executeQuery(sql);
if (rs.next())
{
quantityStr = rs.getString("QUANTITY");
}
}
quantity = Double.parseDouble(quantityStr);
// if (tranType.equals("I"))
// {
if (quantity > 0)
{
line = " " + lineNo;
System.out.println("line :"+line);
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","R-BFS");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line",line.substring(line.length()-3));
strAllocate.put("site_code",siteCodeReq);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(-1*quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win",windowName);
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString ::: " + errString);
if (errString == "")
{
System.out.println("invAllocTrace.updateInvallocTrace : Sucessuful!");
}
}
// }
}
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in RcptBackFlushPrsEJB :"+sqx);
sqx.printStackTrace();
errString = "ERROR";
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in RcptBackFlushPrsEJB :"+e);
e.printStackTrace();
errString = "ERROR";
throw new ITMException(e);
}
finally
{
try
{
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.err.println("Exception :RcptBackFlushPrsEJB:\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
//return errString;
}
private Node getCurrentDetailFromDom(Document dom,String domId)
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail2");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
return reqDetail;
}
private String getCurrentUpdateFlag(Node currDetail)
{
NodeList currDetailList = null;
String updateStatus = "",nodeName = "";
int currDetailListLength = 0;
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
nodeName = currDetailList.item(i).getNodeName();
if (nodeName.equalsIgnoreCase("Attribute"))
{
updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
break;
}
}
return updateStatus;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcptBackFlushPrsLocal extends ValidatorLocal//, EJBObject
{
public String preSave() throws RemoteException,ITMException;
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcptBackFlushPrsRemote extends ValidatorRemote//, EJBObject
{
public String preSave() throws RemoteException,ITMException;
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.util.Date;
//import java.text.*;
import java.sql.*;
import org.w3c.dom.*;
//import javax.xml.parsers.*;
import javax.ejb.*;
import ibase.webitm.utility.ITMException;
//import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
//import ibase.utility.CommonConstants;
import ibase.webitm.utility.GenericUtility;
import java.text.SimpleDateFormat;
import javax.naming.InitialContext;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RunMRP extends ValidatorEJB implements RunMRPLocal,RunMRPRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Connection conn = null;
SimpleDateFormat simpleDateFormat = null;
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("Create Method Called...");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String wfValData() throws RemoteException,ITMException
{
System.out.println("wfValData()...");
return "";
}
// Item Change
public String itemChanged() throws RemoteException,ITMException
{
System.out.println("itemChanged Called...");
return "";
}
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
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);
}
errString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams);
}
catch (Exception e)
{
System.out.println ("Exception :ProcessControlEJB :itemChanged(String,String):" + e.getMessage() + ":");
errString = genericUtility.createErrorString(e);
throw new ITMException(e);
}
System.out.println ("returning from ProcessControlEJB itemChanged");
return errString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
String returnValue="";
String returnValue1="";
String returnValue2="";
String itemCodeDom="";
String itemCodeDom1="";
String itemCodeDom2="";
ResultSet rs = null;
String sql = "";
String columnValue = "";
String userId = "";
String errString="";
Connection connectionObject = null;
Statement stmt = null;
StringBuffer valueXmlString = new StringBuffer();
int currentFormNo = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
//ITMDBAccessHome itmDBAccessHome = null;
ITMDBAccessLocal itmDBAccess = null;
try
{
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
AppConnectParm appConnect = new AppConnectParm();
Properties p = appConnect.getProperty();
InitialContext ctx = new InitialContext(p);
itmDBAccess = (ITMDBAccessLocal)ctx.lookup("ibase/ITMDBAccessEJB/local");
//itmDBAccess = itmDBAccessHome.create();
connectionObject = itmDBAccess.getConnection();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
columnValue = genericUtility.getColumnValue(currentColumn,dom);
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 1:
valueXmlString.append("<Detail1>");
if(currentColumn.trim().equals("itm_default"))
{
Calendar cal = Calendar.getInstance();
Date d = new Date();
String runDate = simpleDateFormat.format(d); // 01-10-2007 manoharan
cal.setTime(d);
cal.set(Calendar.DATE,1);
d = cal.getTime();
String fromDate = simpleDateFormat.format(d);
cal.setTime(d);
cal.add(Calendar.MONTH,3);
cal.set(Calendar.DATE,0);
d = cal.getTime();
String toDate = simpleDateFormat.format(d);
System.out.println("From Date :" + fromDate + " To Date :" + toDate);
valueXmlString.append("<date_from>").append(fromDate).append("</date_from>");
valueXmlString.append("<date_to>").append(toDate).append("</date_to>");
valueXmlString.append("<site_code__from>").append("0").append("</site_code__from>");
valueXmlString.append("<site_code__to>").append("ZZ").append("</site_code__to>");
valueXmlString.append("<item_code__from>").append("0").append("</item_code__from>");
valueXmlString.append("<item_code__to>").append("ZZ").append("</item_code__to>");
valueXmlString.append("<item_ser__from>").append("0").append("</item_ser__from>");
valueXmlString.append("<item_ser__to>").append("ZZ").append("</item_ser__to>");
valueXmlString.append("<process_cycle>").append("0").append("</process_cycle>");
valueXmlString.append("<run_date>").append(runDate).append("</run_date>"); // 01-10-2007 manoharan
valueXmlString.append("<dis_plan>").append("Y").append("</dis_plan>");
valueXmlString.append("<mfg_plan>").append("Y").append("</mfg_plan>");
valueXmlString.append("<mat_plan>").append("Y").append("</mat_plan>");
valueXmlString.append("<made_to_stock>").append("0").append("</made_to_stock>");
valueXmlString.append("<made_to_order>").append("0").append("</made_to_order>");
valueXmlString.append("<balance_intersite>").append("N").append("</balance_intersite>");
//valueXmlString.append("<cons_supp>").append("1").append("</cons_supp>");
valueXmlString.append("<gen_ind>").append("Y").append("</gen_ind>");
}
valueXmlString.append("</Detail1>");
break;
}
valueXmlString.append("</Root>");
}
catch(Exception e)
{
System.out.println("Exception :[RunMRP][itemChanged::case 1:] :==>\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return valueXmlString.toString();
}
// Validation
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
System.out.println("wfValData(String)>>>");
try
{
dom = parseString(xmlString);
System.out.println("RunMRP : wfValData(String xmlString) : ==>\n" + xmlString );
System.out.println("RunMRP : wfValData(String xmlString1) : ==>\n" + xmlString1 );
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : RunMRP : wfValData(String xmlString) : ==>\n"+e.getMessage());
e.printStackTrace();
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;
String childNodeName = "";
String errString = "";
int ctr,currentFormNo=0;
int childNodeListLength;
int count = 0;
String siteCodeFrom = "";
String siteCodeTo = "";
String itemCodeFrom = "";
String itemCodeTo = "";
String itemSerFrom = "";
String itemSerTo = "";
String errCode = "";
String userId = "";
String sql = "";
String itemcodeTo = "";
//String itemSerTo = "";
//String itemSerFrom = "";
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
conn = getConnection();
userId = getValueFromXTRA_PARAMS(xtraParams,"userId");
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1:
{
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();
int cnt;
System.out.println("childNodeName 0. : " + childNodeName);
if (childNodeName.equals("date_to"))
{
if (childNode.getFirstChild() == null || genericUtility.getColumnValue("date_from",dom) == null)
{
errCode = "VMRPDATE1";
errString = getErrorString("date_to",errCode,userId);
break;
}
String df = genericUtility.getColumnValue("date_from",dom);
String dt = genericUtility.getColumnValue("date_to",dom);
System.out.println("date From -->" + df );
System.out.println("date To -->" + dt );
System.out.println("Parsed " + simpleDateFormat.parse(df));
java.util.Date fromDate = new Date(simpleDateFormat.parse(genericUtility.getColumnValue("date_from",dom)).getTime());
java.util.Date toDate = new Date(simpleDateFormat.parse(genericUtility.getColumnValue("date_to",dom)).getTime());
if(fromDate.after(toDate))
{
System.out.println("Error...");
errCode = "VMRPDATE1";
errString = getErrorString("date_to",errCode,userId);
break;
}
else
System.out.println("No Error...");
}
if (childNodeName.equals("site_code__to"))
{
if (childNode.getFirstChild() == null || genericUtility.getColumnValue("site_code__from",dom) == null)
{
errCode = "VMRPSITE1";
errString = getErrorString("site_code__to",errCode,userId);
break;
}
siteCodeFrom = genericUtility.getColumnValue("site_code__from",dom);
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom);
if(siteCodeTo.compareTo(siteCodeFrom)<0)
{
errCode = "VMRPSITE1";
errString = getErrorString("site_code__to",errCode,userId);
break;
}
count = 0;
}
if (childNodeName.equals("item_code__to"))
{
if (childNode.getFirstChild() == null || genericUtility.getColumnValue("item_code__from",dom) == null)
{
errCode = "VMRPSITE1";
errString = getErrorString("item_code__to",errCode,userId);
break;
}
itemCodeFrom = genericUtility.getColumnValue("item_code__from",dom);
itemCodeTo = genericUtility.getColumnValue("item_code__to",dom);
if(itemCodeTo.compareTo(itemCodeFrom)<0)
{
errCode = "VMRPITEMS1";
errString = getErrorString("item_code__to",errCode,userId);
break;
}
count = 0;
}
if (childNodeName.equals("item_ser__to"))
{
if (childNode.getFirstChild() == null || genericUtility.getColumnValue("item_ser__from",dom) == null)
{
errCode = "VMRPSITE1";
errString = getErrorString("item_ser__to",errCode,userId);
break;
}
itemSerFrom = genericUtility.getColumnValue("item_ser__from",dom);
itemSerTo = genericUtility.getColumnValue("item_ser__to",dom);
if(itemSerTo.compareTo(itemSerFrom)<0)
{
errCode = "VMRPITEMS1";
errString = getErrorString("item_ser__to",errCode,userId);
break;
}
count = 0;
}
if (childNodeName.equals("process_cycle"))
{
if (childNode.getFirstChild() == null || Integer.parseInt(genericUtility.getColumnValue("process_cycle",dom)) < 0)
{
errCode = "VMRPCYCL1";
errString = getErrorString("process_cycle",errCode,userId);
break;
}
}
if (childNodeName.equals("gen_ind"))
{
if (childNode.getFirstChild() == null || genericUtility.getColumnValue("gen_ind",dom) == null)
{
errCode = "VMRPGIND";
errString = getErrorString("gen_ind",errCode,userId);
break;
}
}
}
}
}
}
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
finally
{
try
{
//System.out.println("Closing Connection.....");
//conn.close();
//conn = null;
}catch(Exception se){}
}
return errString;
}
}
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
//import javax.xml.parsers.*;
//import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RunMRPLocal extends ValidatorLocal//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
//import ibase.webitm.ejb.*;
//import javax.xml.parsers.*;
//import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RunMRPPrcLocal extends ibase.webitm.ejb.ProcessLocal//, EJBObject
{
// public String process() throws RemoteException,ITMException;
// public String process(String tabSepDataString, String tabSepMetadataString, String windowName, String xtraParams) throws RemoteException,ITMException;
// public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
//import ibase.webitm.ejb.*;
//import javax.xml.parsers.*;
//import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RunMRPPrcRemote extends ibase.webitm.ejb.ProcessRemote//, EJBObject
{
// public String process() throws RemoteException,ITMException;
// public String process(String tabSepDataString, String tabSepMetadataString, String windowName, String xtraParams) throws RemoteException,ITMException;
// public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
import javax.ejb.EJBObject;
import org.w3c.dom.*;
//import javax.xml.parsers.*;
//import javax.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RunMRPRemote extends ValidatorRemote //,EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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;
}
package ibase.webitm.ejb.mfg;
class SurplusStock
{
/* site_code
item_code
surplus_quantity
*/
private String siteCode;
private String itemCode;
private double surplusQuantity = 0;
public void setSiteCode(String siteCode)
{
this.siteCode = siteCode;
}
public String getSiteCode()
{
return this.siteCode;
}
public void setItemCode(String itemCode)
{
this.itemCode = itemCode;
}
public String getItemCode()
{
return this.itemCode;
}
public void setSurplusQuantity(double surplusQuantity)
{
this.surplusQuantity = surplusQuantity;
}
public double getSurplusQuantity()
{
return this.surplusQuantity;
}
}
package ibase.webitm.ejb.mfg;
//import java.util.ArrayList;
//import java.sql.Timestamp;
import java.text.SimpleDateFormat;
public class TimeMRP
{
private java.sql.Timestamp dueDate;
private double demand = 0;
private double supply = 0;
private double planDemand = 0;
private double planSupply = 0;
private double runningDemand = 0;
private double runningSupply = 0;
private double runningPlanSupply = 0;
private double independentDemand = 0;
boolean createDemand = false;
public TimeMRP()
{
// System.out.println("New TimeMRP Created");
}
public void setDueDate(java.sql.Timestamp dueDate)
{
SimpleDateFormat sdt=new SimpleDateFormat("yyyy-MM-dd");
dueDate = java.sql.Timestamp.valueOf(sdt.format(dueDate) + " 00:00:00.000");
this.dueDate = dueDate;
}
public java.sql.Timestamp getDueDate()
{
return this.dueDate;
}
public void setDemand(double demand)
{
this.demand += demand;
}
public double getDemand()
{
return this.demand;
}
public void setSupply(double supply)
{
this.supply += supply;
}
public double getSupply()
{
return this.supply;
}
public void setRunningDemand(double runningDemand)
{
this.runningDemand = runningDemand;
}
public double getRunningDemand()
{
return this.runningDemand;
}
public void setRunningSupply(double runningSupply)
{
this.runningSupply = runningSupply;
}
public double getRunningSupply()
{
return this.runningSupply;
}
public void setPlanSupply(double supply)
{
this.planSupply += supply;
}
public double getPlanSupply()
{
return this.planSupply;
}
public void setRunningPlanSupply(double supply)
{
this.runningPlanSupply = supply;
}
public double getRunningPlanSupply()
{
return this.runningPlanSupply;
}
public void setIndependentDemand(double demand)
{
this.independentDemand += demand;
}
public double getIndependentDemand()
{
return this.independentDemand;
}
}
\ No newline at end of file
/***
author -Mukesh Upadhayay
date- 22 august 08
***/
package ibase.webitm.ejb.mfg;
import java.io.*;
import java.sql.*;
import java.util.*;
import java.lang.*;
import javax.ejb.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import java.rmi.RemoteException;
import java.text.SimpleDateFormat;
import javax.naming.InitialContext;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.*;
import ibase.system.config.*;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
//import ibase.webitm.ITMDBAccessEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
import org.xml.sax.InputSource;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class UpdateWIPLoc extends ProcessEJB implements UpdateWIPLocLocal, UpdateWIPLocRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
CommonConstants commonConstants = new CommonConstants();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Connection conn = null;
HashMap userRightsMap = null;
HashMap winNameMap = null;
HashMap menuNameMap = null;
String profileId = null;
String processStr = null;
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String process() throws RemoteException,ITMException
{
return "";
}
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String rtrStr = "";
Document headerDom = null;
Document detailDom = null;
try
{
System.out.println("xmlString ["+xmlString+"]");
System.out.println("xmlString2 ["+xmlString2+"]");
System.out.println("windowName ["+windowName+"]");
System.out.println("xtraParams ["+xtraParams+"]");
if(xmlString != null && xmlString.trim().length()!=0 )
{
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :UserRightsEJB :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
return rtrStr;
}
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
StringBuffer retTabSepStrBuff = new StringBuffer();
String userId = null;
Object date = null;
String sql = "";
String errCode = "";
String errString = "";
String resultString = "",workOrder="", sqlStr="";
int count = 0;
int operation =0,lineNo=0;
double quantity =0;
String itemCode="", descr="",lotNo="",unit="",
locCodeWip="",tranId="";
try
{
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
workOrder = genericUtility.getColumnValue("work_order", headerDom);
if(conn == null)
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
}
sqlStr = " select a.tran_id, c.operation,a.Item_Code,b.descr, a.Lot_No, "+
" a.Quantity,a.Unit,a.Loc_Code__wip,a.line_no"+
" from workorder_issdet a, item b, workorder_iss c, workorder d "+
" where a.item_code = b.item_code "+
" and a.tran_id = c.tran_id "+
" and c.work_order = d.work_order "+
" and d.status = 'R' "+
" and c.work_order = ? "+
" and not exists (select 1 from workorder_feedback e "+
" where e.work_order = c.work_order "+
" and e.operation = c.operation ) ";
pstmt = conn.prepareStatement(sqlStr);
System.out.println("The getData sql is:-"+ sqlStr);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
while (rs.next())
{
tranId= rs.getString(1);
operation = rs.getInt(2);
itemCode= rs.getString(3);
descr = rs.getString(4);
lotNo= rs.getString(5);
quantity=rs.getDouble(6);
unit= rs.getString(7);
locCodeWip=rs.getString(8);
lineNo = rs.getInt(9);
System.out.println("\nIn get data >>tranId "+tranId);
retTabSepStrBuff.append(tranId).append("\t");
retTabSepStrBuff.append(operation).append("\t");
retTabSepStrBuff.append(itemCode).append("\t");
retTabSepStrBuff.append(descr).append("\t");
retTabSepStrBuff.append(lotNo).append("\t");
retTabSepStrBuff.append(quantity).append("\t");
retTabSepStrBuff.append(unit).append("\t");
retTabSepStrBuff.append(locCodeWip).append("\t");
retTabSepStrBuff.append(lineNo).append("\t");
retTabSepStrBuff.append(" ").append("\t");
retTabSepStrBuff.append("\n");
}//while
}//try
catch (SQLException e)
{
System.out.println("SQLException ::" + sqlStr + e.getMessage() + ":");
e.printStackTrace();
}
catch(Exception ex)
{
System.out.println("Exception []::" + ex.getMessage());
ex.printStackTrace();
}
finally
{
try
{
if(rs!=null)
{
rs.close();
rs = null;
}
if(pstmt!=null)
{
pstmt.close();
pstmt = null;
}
if(conn!=null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
resultString = retTabSepStrBuff.toString();
return resultString;
}// end of getData()
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
Document detailDom = null;
Document headerDom = null;
System.out.println("xmlString2-->"+ xmlString2);
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
System.out.println("xmlString ["+xmlString+"]");
System.out.println("xmlString2 ["+xmlString2+"]");
System.out.println("windowName ["+windowName+"]");
System.out.println("xtraParams ["+xtraParams+"]");
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :UserRightsEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return retStr;
}// end of process
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
processStr = null;
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pInsertStmt = null;
PreparedStatement pUpdateStmt = null;
PreparedStatement pDeleteStmt = null;
Statement stmt = null;
ResultSet rs = null;
java.sql.Timestamp orderDate = new java.sql.Timestamp(System.currentTimeMillis());
java.sql.Timestamp udfDate = null;
ArrayList relArray = new ArrayList();
String returnString = "";
//Declaring fields of the table User_Rights
String profileId = null;
String application = null;
String level1 = null, level2 = null, level3 = null, level4 = null, level5 = null;
String menuName = null;
String rights = null;
String accFilt = null;
String defFilt = null;
String objName = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
String childNodeName = "";
boolean bDetailFound = false;
int parentNodeListLength = 0;
int childNodeListLength = 0;
String delSql = "";
String actualIssue="",workOrder="";
String locationCodeFromUser="";
String tranId="",lineNo="";
//locCode =genericUtility.getColumnValue("loc_code_wip", headerDom);
String batchUpdateSql = "UPDATE workorder_issdet SET " +
" loc_code__wip = ? , " +
" actual_issue = 'N' "+
" where tran_id= ? and line_no=? ";
String searchKey = null;
int operation = 0;
try
{
if(conn == null)
{
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
pUpdateStmt = conn.prepareStatement(batchUpdateSql);
}
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
operation = 0;
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("loc_code__wip"))
{
if (childNode.getFirstChild() != null) // ****************
{
locationCodeFromUser = (childNode.getFirstChild().getNodeValue()).trim();
}
}
else if (childNodeName.equals("tran_id"))
{
if (childNode.getFirstChild() != null) // ****************
{
//the trim has been removed as it was not updating in old frame work//
tranId = (childNode.getFirstChild().getNodeValue());
}
}
else if (childNodeName.equals("line_no"))
{
if (childNode.getFirstChild() != null) // ****************
{
lineNo = (childNode.getFirstChild().getNodeValue()).trim();
}
}
}
if(locationCodeFromUser!=null && locationCodeFromUser.trim().length()>0)
{
pUpdateStmt.setString(1, locationCodeFromUser);
pUpdateStmt.setString(2, tranId);
pUpdateStmt.setInt(3, Integer.parseInt(lineNo));
pUpdateStmt.addBatch();
}
}//outer for
pUpdateStmt.executeBatch();
conn.commit();
System.out.println("After Commit");
}
catch(BatchUpdateException be)
{
be.printStackTrace();
returnString = be.getMessage();
System.out.println("BatchUpdateException :RunMRPPrcEJB: CreatePlanDemand(ADPElement)" + returnString);
System.out.println("Detail Exception : " + be.getNextException());
}
catch (SQLException ex)
{
returnString = ex.getMessage();
try{conn.rollback();
}catch(Exception e){}
ex.printStackTrace();
}
catch (Exception e)
{
returnString = e.getMessage();
try{
conn.rollback();
}catch(Exception ec){}
e.printStackTrace();
}
finally
{
try
{
if(pUpdateStmt!=null)
{
pUpdateStmt.close();
pUpdateStmt = null;
}
if(conn!=null)
{
conn.close();
conn = null;
}
}catch(Exception e)
{
e.printStackTrace();
}
}
if (returnString == null || returnString.trim().length() == 0)
{
System.out.println("errString is null************** ");
returnString="VTCOMPL";
returnString = itmDBAccessEJB.getErrorString("",returnString,"","",conn);
}
else
{
System.out.println("errString is not null ***************");
returnString="VTPRCERR";
returnString = itmDBAccessEJB.getErrorString("",returnString,"","",conn);
}
return returnString;
}// end of process
/* 1 - insert
2- update
3-delete
Searches HashMap for availability of rights for searchKey
if Not Found and rights is not null then
return 1
else if Found and rights is not null then
return 2
else if Found and rights = null
return 3
*/
}//class
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface UpdateWIPLocLocal extends ibase.webitm.ejb.ProcessLocal//, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface UpdateWIPLocRemote extends ibase.webitm.ejb.ProcessRemote//, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.*;
import java.text.SimpleDateFormat;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import org.w3c.dom.*;
import java.util.Calendar;
import ibase.webitm.ejb.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WOMultiReceipt extends ValidatorEJB implements WOMultiReceiptLocal, WOMultiReceiptRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("WOMultiReceiptEJB is Creating..........");
}
public void ejbRemove()
{
System.out.println("WOMultiReceiptEJB is Removing..........");
}
public void ejbActivate()
{
System.out.println("WOMultiReceiptEJB is Activating..........");
}
public void ejbPassivate()
{
System.out.println("WOMultiReceiptEJB is Passivating..........");
}*/
public String wfValData()throws RemoteException, ITMException
{
return "";
}
public String itemChanged()throws RemoteException, ITMException
{
return "";
}
public String postSaveRec()throws RemoteException,ITMException
{
return "";
}
public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String errString = "";
System.out.println("***********************Validation Start MPSOrder**************************");
try
{
System.out.println("xmlString:::"+xmlString);
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : MPSOrder : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
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;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String childNodeName = null;
String errString = "";
String errCode = "";
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null;
String sql = "";
String userId = "";
java.util.Date orderDate = null, dueDate = null,mfg_date=null,tran_date=null,date_start =null,expDate=null,tranDate=null,dateStart=null,dateCompl=null ;
String itemCode = null;
String siteCode = null;
String childNodeValue = null ;
int cnt = 0;
String saleOrder = null, lineNo = null, tranId = null, bomCode = null,confirmed = null, active = null ;
String workOrder = null, temp = null, cctrCodeWp = null,routeCode = null, unit = null, status = null;
String mfgType = null ;
double quantity = 0, qtyRecived = 0, qtyWorkOrder = 0, qtyMpsOrder = 0, qtySordDet = 0,currentBatchQty=0;
double minBatchQty = 0;
double maxBatchQty = 0,std_qty=0;
int currentFormNo=0;
int childNodeListLength,lineLength=0;
String loginSite = "",operation="",locCode ="";
String tranType="",modName="" ;
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
stmt = conn.createStatement();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
GenericUtility genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println(" ***********Validation for - Detail "+currentFormNo);
switch(currentFormNo)
{
case 1 :
System.out.println("Validation for Detail 1 WOMultiReceiptEJB..........");
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.getFirstChild()!= null)
{
childNodeValue = childNode.getFirstChild().getNodeValue();
}
if(childNodeName.equalsIgnoreCase("tran_date"))
{
System.out.println(" Validaion for field "+childNodeName);
String ordDate = genericUtility.getColumnValue("tran_date", dom);
orderDate = sdf.parse(ordDate);
siteCode = genericUtility.getColumnValue("site_code", dom);
errCode = nfCheckPeriod("PUR", orderDate, siteCode);
if(errCode != null && errCode.trim().length() != 0)
{
errString = getErrorString("tran_date",errCode,userId);
break ;
}
}
// if(childNodeName.equalsIgnoreCase("item_code"))
// {
//
// System.out.println(" Validaion for field "+childNodeName);
// itemCode = genericUtility.getColumnValue("item_code", dom);
// siteCode = genericUtility.getColumnValue("site_code", dom);
// workOrder = genericUtility.getColumnValue("work_order", dom);
// operation = genericUtility.getColumnValue("operation", dom);
// tranId = genericUtility.getColumnValue("tran_id", dom);
// tranId = tranId == null ? "" : tranId ;
// tranType = genericUtility.getColumnValue("tran_type", dom);
// //public String isItem(String siteCode, String itemCode, String modName,Connection conn)
// //errCode = nfCheckPeriod(siteCode, itemCode,modName ,conn); ////////modname
// if(errCode != null && errCode.trim().length() != 0)
// {
// errString = getErrorString("item_code",errCode,userId);
// break ;
// }
//
//
// }
if(childNodeName.equalsIgnoreCase("unit"))
{
System.out.println(" Validaion for field "+childNodeName);
unit = genericUtility.getColumnValue("unit", dom);
if(unit == null || unit.trim().length() == 0)
{
errCode = "VMUNIT1";
errString = itmDBAccessEJB.getErrorString("","VMUNIT1","BASE","",conn);
break ;
}
else
{
cnt = isValueExist("uom", "unit",unit, conn);
if(cnt == 0)
{
errCode = "VMROUTE1";
errString = itmDBAccessEJB.getErrorString("","VMROUTE1","BASE","",conn);
break ;
}
}
}
if(childNodeName.equalsIgnoreCase("item_code"))
{
System.out.println(" Validaion for field "+childNodeName);
itemCode = genericUtility.getColumnValue("item_code", dom);
cnt = isValueExist("item", "item_code",itemCode, conn);
if(cnt == 0)
{
errCode = "VMITEM1";
errString = itmDBAccessEJB.getErrorString("","VMITEM1","BASE","",conn);
break ;
}
}
if(childNodeName.equalsIgnoreCase("work_order"))
{
System.out.println(" Validaion for field "+childNodeName);
workOrder = genericUtility.getColumnValue("work_order", dom);
int count=0;
cnt = isValueExist("workorder", "work_order",workOrder, conn);
if(cnt == 0)
{
errCode = "VTWORDER7";
errString = itmDBAccessEJB.getErrorString("","VTWORDER7","BASE","",conn);
break ;
}
//count=0;
// sql ="select count(*) from workorder_receipt where work_order ='"+workOrder+"' and "
// +" confirmed ='Y' ";
// System.out.println("sql-------------"+sql);
//
// pstmt = conn.prepareStatement(sql);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// count=rs.getInt(1);
//
// }
// rs.close();
// pstmt.close();
// System.out.println("count-------------"+count);
//
// if(count != 0)
// {
// errCode = "VTWOCONF";
// errString = itmDBAccessEJB.getErrorString("","VTWOCONF","BASE");
// break ;
// }
}
if(childNodeName.equalsIgnoreCase("loc_code"))
{
System.out.println(" Validaion for field "+childNodeName);
locCode = genericUtility.getColumnValue("loc_code", dom);
cnt = isValueExist("location", "loc_code",locCode, conn);
if(cnt == 0)
{
errCode = "VMLOCGRCON";
errString = itmDBAccessEJB.getErrorString("","VMLOCGRCON","BASE","",conn);
break ;
}
}
if(childNodeName.equalsIgnoreCase("exp_date"))
{
System.out.println(" Validaion for field "+childNodeName);
expDate = getDateObject(genericUtility.getColumnValue("exp_date",dom));
tranDate = getDateObject(genericUtility.getColumnValue("tran_date",dom));
if(expDate!=null)
{
if( expDate.before(tranDate) )
{
System.out.println(" expDate..................... "+expDate);
errCode = "VTEXPDT";
errString = getErrorString("exp_date",errCode,userId);
break ;
}
}
}
if(childNodeName.equalsIgnoreCase("date__compl"))
{
System.out.println(" Validaion for field "+childNodeName);
dateStart = getDateObject(genericUtility.getColumnValue("date__start",dom));
dateCompl = getDateObject(genericUtility.getColumnValue("date__compl",dom));
// if( dateCompl == null )
// {
// errCode = "VTCOMPLDT";
// //ls_errcode = gf_error_location(ls_errcode)
// errString = getErrorString("date__compl",errCode,userId);
// break ;
// }
if(dateCompl!=null && dateStart!=null)
{
if( dateCompl.before(dateStart))
{
errCode = "VTCOMPLDT";
//ls_errcode = gf_error_location(ls_errcode)
errString = getErrorString("date__compl",errCode,userId);
break ;
}
}
}
if(childNodeName.equalsIgnoreCase("date_start"))
{
System.out.println(" Validaion for field "+childNodeName);
date_start = getDateObject(genericUtility.getColumnValue("date_start",dom));
//mfg_date = getDateObject(genericUtility.getColumnValue("mfg_date",dom));
if( date_start == null )
{
errCode = "INVSTRDT";
//ls_errcode = gf_error_location(ls_errcode)
errString = getErrorString("date_start",errCode,userId);
break ;
}
}
}break; //END FOR
case 2 :
System.out.println("Validation for Detail 2 ..........");
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
cnt = 0;
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNode.getFirstChild()!= null)
{
childNodeValue = childNode.getFirstChild().getNodeValue();
}
if(childNodeName.equalsIgnoreCase("item_code"))
{
System.out.println(" Validaion for field "+childNodeName);
cnt = isValueExist("item", "item_code", childNodeValue, conn);
if(cnt == 0)
{
errCode = "VMITEM1";
errString = itmDBAccessEJB.getErrorString("","VMITEM1","BASE","",conn);
break;
}
}
if(childNodeName.equalsIgnoreCase("pack_code"))
{
System.out.println(" Validaion for field "+childNodeName);
cnt = isValueExist("packing", "pack_code", childNodeValue, conn);
if(cnt == 0)
{
errCode = "VTPKCD1";
errString = itmDBAccessEJB.getErrorString("","VTPKCD1","BASE","",conn);
break;
}
}
}//END FOR
break;
}//END SWITCH
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
errString=e.getMessage();
}
finally
{
try
{
if(conn!=null)
{
conn.close();
}
conn = null;
}
catch(Exception d)
{
d.printStackTrace();
}
System.out.println(" MPSOrder Validation End and Connection is Closed");
}
System.out.println("ErrString ::"+errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
if(xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [MPSOrder][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr=0;
String columnValue = null;
String childNodeName = null;
String errString = "";
String errCode = "";
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String userId = "";
String itemCode = "";
String siteCode = "";
double yieldPerc = 0,currentBatchQty=0 ;
java.util.Date orderDate = null,rdate=null;
String loginSite = "";
String itemDescr = "", unit = "", siteDescr = "" ;
int currentFormNo=0;
int childNodeListLength,shelf_life=0;
boolean flag = false;
int k = 0,opr=0;
java.util.Date currDate = new java.util.Date();
String packCode ="",packDescr="",grossWeight="",tareWeight="";
String tranId="",ls_loc="",ordDate = "",tranDate="",startDate ="",startDate1="",startDate2="",startDate3="";
String qcReqd ="",workOrder ="",var_value="",tranType="",feedbackReqd="",tranIdMps="",refNo="",unitStd="";
double quantity=0,quantityMps=0,netweight=0,grossWeightNbr =0,tareWeightNbr=0,sum_quantity=0,potency_perc=0;
String fname="",lname="",mname="";
String locCode="",site_code__own="",item_ser="",descr="",mfg_date_on="",track_shelf_life="";
Timestamp relDate =null,expDate=null,mfgDateStart=null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
ConnDriver conndriver = new ConnDriver();
conn = conndriver.getConnectDB("DriverITM");
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
//tranDate = sdf.format(currDate);
if(objContext != null && objContext.trim().length() > 0)
k = Integer.parseInt(objContext);
System.out.println("FORM NO:::" + k);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
System.out.println("****************ITEMCHANGE FOR CASE"+k+"*******************");
switch(k)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail1>");
childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}
while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
if (currentColumn.trim().equals("itm_defaultedit"))
{
workOrder = genericUtility.getColumnValue("work_order", dom);
sql ="select sum(nvl(quantity,0)) from workorder_receipt where work_order ='"+workOrder+"' and "
+" tran_type ='F' ";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
sum_quantity= rs.getDouble(1);
}
rs.close();
pstmt.close();
valueXmlString.append("<c_crevqty>").append("<![CDATA[" + sum_quantity+ "]]>").append("</c_crevqty>");
tranType = genericUtility.getColumnValue("tran_type", dom);
if(tranType.equalsIgnoreCase("B"))
{
}
if(tranType.equalsIgnoreCase("F"))
{
valueXmlString.append("<operation protect=\"1\"></operation>\r\n");
}
}
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
tranDate = getCurrdateAppFormat();
siteDescr = getFieldValue("descr", "site", "site_code",loginSite, conn);
siteDescr = siteDescr == null ? "" : siteDescr ;
valueXmlString.append("<tran_date>").append("<![CDATA[" + tranDate + "]]>").append("</tran_date>");
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr+ "]]>").append("</site_descr>");
}
if(currentColumn.trim().equalsIgnoreCase("tran_type"))
{
sql ="select loc_code__insp,loc_code__aprv from siteitem where site_code ='"+siteCode+"' and "
+" item_code ='"+itemCode+"' ";
System.out.println("sql-------------"+sql);
String loc="",ls_loc_code_aprv="";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
loc= rs.getString(1);
ls_loc_code_aprv= rs.getString(2);
}
rs.close();
pstmt.close();
valueXmlString.append("<loc_code>").append("<![CDATA[" + loc+ "]]>").append("</loc_code>");
valueXmlString.append("<loc_code__aprv>").append("<![CDATA[" + ls_loc_code_aprv+ "]]>").append("</loc_code__aprv>");
}
if(currentColumn.trim().equalsIgnoreCase("work_order"))
{ tranDate = getCurrdateAppFormat();
workOrder = genericUtility.getColumnValue("work_order", dom);
tranType = genericUtility.getColumnValue("tran_type", dom);
sql = "select site_code ,ord_date,rel_date,due_date ,item_code,quantity,unit, "
+" lot_sl , mfg_date__start , current_batch_qty , ref_no , unit__std , tran_id__mps,"
+" quantity__mps , exp_date , yield_perc , feedback_reqd from workorder where work_order ='"+workOrder +"' ";
System.out.println("sql:::" + sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
siteCode = (rs.getString("site_code") == null ? "":rs.getString("site_code"));
//ordDate = rs.getTimestamp("ord_date");
relDate = rs.getTimestamp("rel_date") ;
//dueDate = rs.getTimestamp("due_date") ;
itemCode = rs.getString("item_code") ;
System.out.println(" itemCode................"+itemCode);
quantity =rs.getDouble("quantity");
mfgDateStart = rs.getTimestamp("mfg_date__start") ;
currentBatchQty =rs.getDouble("current_batch_qty");
refNo = (rs.getString("ref_no")==null ? " ":rs.getString("ref_no"));
unitStd = (rs.getString("unit__std") ==null ? " ":rs.getString("unit__std"));
tranIdMps = (rs.getString("tran_id__mps")==null ? "":rs.getString("tran_id__mps")) ;
quantityMps = rs.getDouble("quantity__mps") ;
expDate = rs.getTimestamp("exp_date") ;
// tranIdMps = rs.getString("tran_id__mps") ;
unit = rs.getString("unit") ;
//yieldPerc = rs.getDouble("yield_perc") ;
feedbackReqd = (rs.getString("feedback_reqd") ==null ? "N" :rs.getString("feedback_reqd")) ;
}
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
if(relDate!=null)
{
rdate = simpledateformat.parse(relDate.toString());
relDate = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
startDate1 = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(relDate).toString();
}
valueXmlString.append("<date__start>").append("<![CDATA[" + startDate1 + "]]>").append("</date__start>");
if(expDate!=null)
{
rdate = simpledateformat.parse(expDate.toString());
expDate = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
startDate = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(expDate).toString();
}
valueXmlString.append("<exp_date>").append("<![CDATA[" + startDate + "]]>").append("</exp_date>");
if(mfgDateStart!=null)
{
rdate = simpledateformat.parse(mfgDateStart.toString());
mfgDateStart = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
startDate = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(mfgDateStart).toString();
}
valueXmlString.append("<mfg_date>").append("<![CDATA[" + startDate + "]]>").append("</mfg_date>");
itemDescr = getFieldValue("descr", "item", "item_code", itemCode, conn);
itemDescr = itemDescr == null ? "" : itemDescr ;
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
siteDescr = getFieldValue("descr", "site", "site_code",siteCode, conn);
siteDescr = siteDescr == null ? "" : siteDescr ;
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr+ "]]>").append("</site_descr>");
System.out.println(" startDate................"+startDate);
tranId = genericUtility.getColumnValue("tran_id", dom);
//valueXmlString.append("<date__start>").append("<![CDATA[" + startDate + "]]>").append("</date__start>");
valueXmlString.append("<unit__std>").append("<![CDATA[" + unitStd + "]]>").append("</unit__std>");
valueXmlString.append("<quantity__mps>").append("<![CDATA[" + quantityMps + "]]>").append("</quantity__mps>");
valueXmlString.append("<tran_id__mps>").append("<![CDATA[" + tranIdMps + "]]>").append("</tran_id__mps>");
valueXmlString.append("<yield_perc>").append("<![CDATA[" + yieldPerc + "]]>").append("</yield_perc>");
valueXmlString.append("<ref_no>").append("<![CDATA[" + refNo + "]]>").append("</ref_no>");
valueXmlString.append("<date__compl>").append("<![CDATA[" + tranDate + "]]>").append("</date__compl>");
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<site_code>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>");
valueXmlString.append("<workorder_quantity>").append("<![CDATA[" + currentBatchQty + "]]>").append("</workorder_quantity>");
sql ="select max(operation) from worder_route where work_order ='"+workOrder+"' " ;
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
opr= rs.getInt(1);
}
rs.close();
pstmt.close();
valueXmlString.append("<operation>").append("<![CDATA[" + opr + "]]>").append("</operation>");
sql ="select sum(quantity) from workorder_receipt where work_order ='"+workOrder+"' and "
+" tran_type ='F' ";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
sum_quantity= rs.getDouble(1);
}
rs.close();
pstmt.close();
sql ="select loc_code,site_code__own,potency_perc,item_ser,shelf_life, "
+" descr,mfg_date_on,track_shelf_life from item where item_code ='"+itemCode+"'" ;
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
locCode= rs.getString("loc_code");
site_code__own=(rs.getString("site_code__own")==null ? "" :rs.getString("site_code__own"));
potency_perc=rs.getDouble("potency_perc");
item_ser=rs.getString("item_ser");
shelf_life=rs.getInt("shelf_life");
descr=rs.getString("descr");
mfg_date_on = rs.getString("mfg_date_on") ;
track_shelf_life=rs.getString("track_shelf_life");
}
rs.close();
pstmt.close();
valueXmlString.append("<potency_perc>").append("<![CDATA[" + potency_perc + "]]>").append("</potency_perc>");
valueXmlString.append("<site_code__own>").append("<![CDATA[" + site_code__own + "]]>").append("</site_code__own>");
valueXmlString.append("<loc_code>").append("<![CDATA[" + locCode + "]]>").append("</loc_code>");
valueXmlString.append("<c_crevqty>").append("<![CDATA[" + sum_quantity+ "]]>").append("</c_crevqty>");
sql ="select mfg_date_on from itemser where item_ser ='"+item_ser+"' " ;
System.out.println("sql-------------"+sql);
String ls_on="";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
ls_on= ( rs.getString(1)==null ? "": rs.getString(1));
}
rs.close();
pstmt.close();
if(ls_on.equalsIgnoreCase("C"))
{
valueXmlString.append("<mfg_date>").append("<![CDATA[" + tranDate + "]]>").append("</mfg_date>");
}
else if(ls_on.equalsIgnoreCase("S"))
{
valueXmlString.append("<mfg_date>").append("<![CDATA[" + startDate1 + "]]>").append("</mfg_date>");
}
}
if(currentColumn.trim().equalsIgnoreCase("site_code"))
{
siteCode = genericUtility.getColumnValue("site_code", dom);
siteDescr = getFieldValue("descr", "site", "site_code",siteCode, conn);
siteDescr = siteDescr == null ? "" : siteDescr ;
valueXmlString.append("<site_descr>").append("<![CDATA[" + siteDescr+ "]]>").append("</site_descr>");
}
if(currentColumn.trim().equalsIgnoreCase("date__compl"))
{
String ls_on="";
tranType = genericUtility.getColumnValue("tran_type", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
workOrder = genericUtility.getColumnValue("work_order", dom);
sql ="select mfg_date__start,rel_date ,due_date from workorder where work_order ='"+workOrder+"' ";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mfgDateStart= rs.getTimestamp(1);
relDate= rs.getTimestamp(2);
System.out.println("mfgDateStart-------------"+mfgDateStart);
System.out.println("relDate-------------"+relDate);
}
rs.close();
pstmt.close();
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
if(relDate!=null)
{
rdate = simpledateformat.parse(relDate.toString());
relDate = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
startDate1 = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(relDate).toString();
}
valueXmlString.append("<date__start>").append("<![CDATA[" + startDate1 + "]]>").append("</date__start>");
// if(expDate!=null)
// {
// rdate = simpledateformat.parse(expDate.toString());
// expDate = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
// startDate2 = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(expDate).toString();
// System.out.println("startDate2-------------"+startDate2);
// }
// valueXmlString.append("<exp_date>").append("<![CDATA[" + startDate2 + "]]>").append("</exp_date>");
if(mfgDateStart!=null)
{
rdate = simpledateformat.parse(mfgDateStart.toString());
mfgDateStart = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
startDate3 = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(mfgDateStart).toString();
valueXmlString.append("<mfg_date>").append("<![CDATA[" + startDate3 + "]]>").append("</mfg_date>");
}
sql ="select mfg_date_on,case when shelf_life is null then 0 else shelf_life end ,item_ser from item where item_code ='"+itemCode+"' ";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
ls_on= (rs.getString(1)==null ? "" :rs.getString(1));
shelf_life= rs.getInt(2);
item_ser= rs.getString(3);
System.out.println("shelf_life-------------"+shelf_life);
}
rs.close();
pstmt.close();
if(ls_on.trim().length()==0)
{
sql ="select mfg_date_on from itemser where item_ser ='"+item_ser+"' " ;
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
ls_on= (rs.getString(1)==null ? "" :rs.getString(1));
}
rs.close();
pstmt.close();
}
if(mfgDateStart == null)
{
if(ls_on.equalsIgnoreCase("C"))
{
String date__compl = genericUtility.getColumnValue("date__compl", dom);
System.out.println("date__compl-------------"+date__compl);
mfgDateStart=new Timestamp(System.currentTimeMillis() );
valueXmlString.append("<mfg_date>").append("<![CDATA[" + date__compl + "]]>").append("</mfg_date>");
}
else if(ls_on.equalsIgnoreCase("S"))
{
valueXmlString.append("<mfg_date>").append("<![CDATA[" + startDate1 + "]]>").append("</mfg_date>");
mfgDateStart=relDate;
}
}
if(mfgDateStart!=null)
{
java.sql.Timestamp expdatelast =null;
java.sql.Timestamp expdate1 =getRelativeDate(mfgDateStart,shelf_life);
System.out.println("expdate1-------------"+expdate1);
rdate = simpledateformat.parse(expdate1.toString());
expdatelast = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
String expdateStr = (new SimpleDateFormat("yyyy-MM-dd")).format(expdatelast).toString();
expdateStr=expdateStr+"-00.00.00";
System.out.println("expdateStr-------------"+expdateStr);
//sql ="select last_day(?) from dual";
sql ="select FN_RLAST_DAY(timestamp('"+expdateStr+"')) from dual";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
//pstmt.setTimestamp(1,expdate1);
rs = pstmt.executeQuery();
if(rs.next())
{
expdatelast= rs.getTimestamp(1);
System.out.println("expdatelast-------------"+expdatelast);
}
rs.close();
pstmt.close();
rdate = simpledateformat.parse(expdatelast.toString());
expdatelast = Timestamp.valueOf(simpledateformat.format(rdate).toString() + " 00:00:00.0");
expdateStr = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(expdatelast).toString();
valueXmlString.append("<exp_date>").append("<![CDATA[" + expdateStr + "]]>").append("</exp_date>");
}
}
if(currentColumn.trim().equalsIgnoreCase("qc_reqd"))
{
qcReqd = genericUtility.getColumnValue("qc_reqd", dom);
siteCode = genericUtility.getColumnValue("site_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
if(qcReqd.equalsIgnoreCase("Y"))
{
sql ="select loc_code__insp from siteitem where site_code ='"+siteCode+"' and item_code ='"+itemCode+"' ";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
ls_loc= rs.getString(1);
}
rs.close();
pstmt.close();
}
else
{
sql ="select loc_code__aprv from siteitem where site_code ='"+siteCode+"' and item_code ='"+itemCode+"' ";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
ls_loc= rs.getString(1);
}
rs.close();
pstmt.close();
}
valueXmlString.append("<loc_code>").append("<![CDATA[" + ls_loc+ "]]>").append("</loc_code>");
}
if(currentColumn.trim().equalsIgnoreCase("emp_code__aprv"))
{
if (columnValue != null)
{
sql = "select emp_fname,emp_mname,emp_lname from employee where emp_code='"+columnValue+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
fname = rs.getString(1) == null ? "" :rs.getString(1);
mname = rs.getString(2) == null ? "" :rs.getString(2);
lname = rs.getString(3) == null ? "" :rs.getString(3); valueXmlString.append("<emp_fname>").append("<![CDATA[").append(fname).append("]]>").append("</emp_fname>");
valueXmlString.append("<emp_mname>").append("<![CDATA[").append(mname).append("]]>").append("</emp_mname>");
valueXmlString.append("<emp_lname>").append("<![CDATA[").append(lname).append("]]>").append("</emp_lname>");
}
else
{
valueXmlString.append("<emp_fname>").append("<![CDATA[").append("").append("]]>").append("</emp_fname>");
valueXmlString.append("<emp_mname>").append("<![CDATA[").append("").append("]]>").append("</emp_mname>");
valueXmlString.append("<emp_lname>").append("<![CDATA[").append("").append("]]>").append("</emp_lname>");
}
pstmt.close();
pstmt = null;
}
}
valueXmlString.append("</Detail1 >");
System.out.println("itemchange string :::" +valueXmlString);
break;
case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
valueXmlString.append("<Detail2>");
int childListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn.trim()))
{
if (childNode.getFirstChild() != null)
{
columnValue=childNode.getFirstChild().getNodeValue();
}
}
ctr++;
}
while(ctr < childListLength && !childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
String hdrworder = null,hdLocCode="";
hdrworder = genericUtility.getColumnValue("work_order",dom1);
System.out.println("Inside case2 (value of workorder):::::::::"+hdrworder);
String hdItemCode = null;
hdItemCode = genericUtility.getColumnValue("item_code",dom1);
System.out.println("Inside case2 (value of item_code):::::::::"+hdItemCode);
itemDescr = getFieldValue("descr", "item", "item_code", hdItemCode, conn);
itemDescr = itemDescr == null ? "" : itemDescr ;
unit = getFieldValue("unit", "item", "item_code", hdItemCode, conn);
hdLocCode = genericUtility.getColumnValue("loc_code",dom1);
//locDesc = getFieldValue("unit", "item", "item_code", hdItemCode, conn);
valueXmlString.append("<loc_code>").append("<![CDATA[" + hdLocCode + "]]>").append("</loc_code>");
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr + "]]>").append("</item_descr>");
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
valueXmlString.append("<work_order>").append("<![CDATA[").append(hdrworder).append("]]>").append("</work_order>");
valueXmlString.append("<item_code>").append("<![CDATA[").append(hdItemCode).append("]]>").append("</item_code>");
valueXmlString.append("<item_code>").append("<![CDATA[").append(hdItemCode).append("]]>").append("</item_code>");
}
if(currentColumn.trim().equalsIgnoreCase("pack_code"))
{
packCode = genericUtility.getColumnValue("pack_code", dom);
packDescr = getFieldValue("descr", "packing", "pack_code",packCode, conn);
packDescr = packDescr == null ? "" : packDescr ;
valueXmlString.append("<packing_descr>").append("<![CDATA[" + packDescr+ "]]>").append("</packing_descr>");
}
if(currentColumn.trim().equalsIgnoreCase("gross_weight")||currentColumn.trim().equalsIgnoreCase("tare_weight"))
{
grossWeight = genericUtility.getColumnValue("gross_weight", dom);
tareWeight = genericUtility.getColumnValue("tare_weight", dom);
grossWeightNbr =Double.parseDouble(grossWeight);
tareWeightNbr =Double.parseDouble(tareWeight);
netweight = grossWeightNbr - tareWeightNbr;
valueXmlString.append("<net_weight>").append("<![CDATA[" + netweight+ "]]>").append("</net_weight>");
}
valueXmlString.append("</Detail2>");
break;
}// switch end
valueXmlString.append("</Root>");
}// try end
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn != null)
conn.close();
conn = null;
}
catch(Exception e1)
{
e1.printStackTrace();
}
}
System.out.println("[MPSOrder] Connection is Closed");
System.out.println("[MPSOrder] Connection is Closed");
System.out.println("valueXmlString:::::" + valueXmlString.toString());
return valueXmlString.toString();
}
private String getCurrdateAppFormat()
{
String s = "";
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
Timestamp timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in [MPSOrder] getCurrdateAppFormat " + exception.getMessage());
}
return s;
}
private String getFieldValue(String column,String tableName, String columnName, String columnValue,Connection conn)
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String value = null;
String sql = null;
sql = " select "+column+" from "+tableName+" where "+columnName+" = '" + columnValue + "' ";
try
{
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("\n\n\n Query Executed " + sql+ "\n\n******************");
if(rs.next())
{
value = rs.getString(1) != null ? rs.getString(1) : " ";
}
else
{
value = " ";
}
rs.close();
pstmt.close();
}
catch(Exception exception)
{
exception.printStackTrace();
System.out.println("Exception ::" + exception.getMessage());
}
return value;
}
private int isValueExist(String tableName, String columnName, String columnValue,Connection conn)
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = null;
int cnt = 0 ;
sql = " select count(1) as count from "+tableName+" where "+columnName+" = '" + columnValue + "' ";
try
{
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
System.out.println("\n\n\n Query Executed " + sql+ "\n\n******************");
if(rs.next())
{
cnt = rs.getInt("count");
}
rs.close();
pstmt.close();
System.out.println("cnt--------------"+cnt);
}
catch(Exception exception)
{
exception.printStackTrace();
System.out.println("Exception ::" + exception.getMessage());
}
return cnt;
}
private java.sql.Timestamp getRelativeDate(java.sql.Timestamp date, int n )
{
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(cal.DATE, n);
java.util.Date date1 = cal.getTime();
SimpleDateFormat sdt = new SimpleDateFormat("yyyy-MM-dd");
return java.sql.Timestamp.valueOf(sdt.format(date1) + " 00:00:00.000");
}
}
package ibase.webitm.ejb.mfg ;
import ibase.webitm.ejb.ValidatorLocal;
import java.rmi.RemoteException;
import javax.ejb.*;
import ibase.webitm.utility.*;
import org.w3c.dom.*;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WOMultiReceiptLocal extends ValidatorLocal//, EJBObject
{
public abstract String wfValData() throws RemoteException, ITMException;
public abstract String wfValData(String s, String s1, String s2, String s3, String s4,String s5) throws RemoteException, ITMException;
public abstract String wfValData(Document document, Document document1, Document document2, String s, String s1, String s2) throws RemoteException, ITMException;
public abstract String itemChanged() throws RemoteException, ITMException;
public abstract String itemChanged(String s, String s1, String s2, String s3, String s4, String s5, String s6) throws RemoteException, ITMException;
public abstract String itemChanged(Document document, Document document1, Document document2, String s, String s1, String s2, String s3) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.mfg ;
import ibase.webitm.ejb.ValidatorRemote;
import java.rmi.RemoteException;
import javax.ejb.*;
import ibase.webitm.utility.*;
import org.w3c.dom.*;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WOMultiReceiptRemote extends ValidatorRemote//, EJBObject
{
public abstract String wfValData() throws RemoteException, ITMException;
public abstract String wfValData(String s, String s1, String s2, String s3, String s4,String s5) throws RemoteException, ITMException;
public abstract String wfValData(Document document, Document document1, Document document2, String s, String s1, String s2) throws RemoteException, ITMException;
public abstract String itemChanged() throws RemoteException, ITMException;
public abstract String itemChanged(String s, String s1, String s2, String s3, String s4, String s5, String s6) throws RemoteException, ITMException;
public abstract String itemChanged(Document document, Document document1, Document document2, String s, String s1, String s2, String s3) throws RemoteException, ITMException;
}
package ibase.webitm.ejb.mfg;
import java.sql.*;
import java.rmi.RemoteException;
import java.util.*;
import org.w3c.dom.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.system.config.*;
import ibase.webitm.utility.*;
import ibase.utility.*;
import ibase.webitm.ejb.*;
import java.text.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WORPostSave extends ValidatorEJB implements WORPostSaveLocal , WORPostSaveRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String postSaveRec() throws RemoteException, ITMException
{
return "";
}
public String postSaveRec(String xmlString1, String domId, String objContext, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException
{
System.out.println("WORPostSaveEJB Called............!");
System.out.println("xml............!"+xmlString1);
String saveRec = "";
Document dom = null;
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
saveRec = executepostSaveRec(dom,domId,objContext,editFlag,xtraParams,conn);
}
}
catch(Exception e)
{
System.out.println("Exception :WORPostSaveEJB :postSaveRec(): " + e.getMessage()+ ":");
e.printStackTrace();
throw new ITMException(e);
}
return saveRec;
}
private String executepostSaveRec(Document dom, String domID, String ObjContext, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException
{
String trantype = "", workorder = "", itemcode = "", sitecode = "" ,lotno = "";
String ordertypeT = "",genlotnoT = "", sql = "",sql1 = "",keyT = "";
NodeList hdrDom = null;
Node currDetail = null;
Statement stmt = null;
ResultSet rs = null;
String ls_fglotnoon = "",ls_setfg = "";
String ls_win = "fg_lotno";
String tranIdG = "",sqlUpd = "";
String errString = "";
String errCode = "";
String userId = "";
boolean lb_nositeitem = false;
int updCnt = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
try
{ userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
currDetail = getCurrentDetailFromDom(dom,domID);
if (currDetail != null)
{ stmt = conn.createStatement();
trantype = genericUtility.getColumnValueFromNode("tran_type",currDetail);
workorder = genericUtility.getColumnValueFromNode("work_order",currDetail);
itemcode = genericUtility.getColumnValueFromNode("item_code",currDetail);
sitecode = genericUtility.getColumnValueFromNode("site_code",currDetail);
lotno = genericUtility.getColumnValueFromNode("lot_no",currDetail);
workorder = workorder.trim();
sitecode = sitecode.trim();
System.out.println("trantype :: "+trantype);
System.out.println("workorder ::"+workorder);
System.out.println("itemcode :: "+itemcode);
System.out.println("sitecode :: "+sitecode);
System.out.println("lotno :: "+lotno);
try
{
sql = "select ORDER_TYPE from workorder where WORK_ORDER = '"+workorder+"'";
System.out.println("sql ....:"+sql);
rs = stmt.executeQuery(sql);
if(!rs.next())
{
System.out.println("No record found for ORDER_TYPE from workorder where WORK_ORDER = '"+workorder+"'");
}
else
{
ordertypeT = rs.getString(1);
ordertypeT = ordertypeT.trim();
System.out.println("ordertypeT..."+ordertypeT);
}
rs.close();
rs = null;
}
catch(Exception e)
{
System.out.println("Exception in ..WORK_ORDER....");
e.printStackTrace();
}
try
{
sql1 = "SELECT CASE WHEN generate_lot_no IS NULL THEN '0' ELSE generate_lot_no END"
+" from siteitem where site_code = '"+sitecode+"' and item_code = '"+itemcode+"' ";
System.out.println("sql1 ....:"+sql1);
rs = stmt.executeQuery(sql1);
if(!rs.next())
{
lb_nositeitem = true;
System.out.println("lb_nositeitem........."+lb_nositeitem);
System.out.println("No record found for generate_lot_no");
}
else
{
genlotnoT = rs.getString(1);
System.out.println("genlotnoT..."+genlotnoT);
}
rs.close();
rs = null;
}
catch(Exception e)
{
System.out.println("Exception in ..genlotnoT....");
e.printStackTrace();
}
System.out.println("count=>"+("RFP".indexOf(ordertypeT)));
if (!trantype.equalsIgnoreCase("B"))
{
ls_setfg= getDisparams("999999","FG_LOTNO",conn);
System.out.println("ls_setfg..."+ls_setfg);
ls_fglotnoon = getmfgparams("999999","FG_LOT_NO_ON",conn);
System.out.println("ls_fglotnoon..."+ls_fglotnoon);
if (ls_fglotnoon.equalsIgnoreCase("R"))
{
if("RFP".indexOf(ordertypeT)>-1)
{
if(genlotnoT.equalsIgnoreCase("1") || (lb_nositeitem && ls_setfg.trim().indexOf(sitecode.trim()) > -1 ))
{
if(lotno == null || lotno.trim().length() == 0)
{
tranIdG = generateTranId(ls_win,getCurrdateAppFormat(),lotno,sitecode,itemcode,conn);
System.out.println("tranIdG.........."+tranIdG);
if(tranIdG.equalsIgnoreCase("ERROR") || tranIdG.trim().length() == 0)
{
errCode = "NOLOTNO";
errString = getErrorString("",errCode,userId);
}
System.out.println("workorder.........."+workorder);
sqlUpd = " update workorder_receipt set lot_no ='"+tranIdG+"' where work_order = '"+workorder+"'";
updCnt = stmt.executeUpdate(sqlUpd);
if (updCnt == 1)
{
System.out.println("Update Into workorder Successfully....:: " + updCnt);
conn.commit();
}
else if (updCnt == 0)
{
System.out.println("No Updation Occur Into workorder ....:: " + updCnt);
conn.rollback();
errCode = "NOWORKODRNO";
errString = getErrorString("",errCode,userId);
}
}
}
}
}
}
stmt.close();
stmt = null;
}
}
catch(Exception e)
{
System.out.println("The Exception occurs in WORPostSaveEJB........ :"+e);
try
{
conn.rollback();
}
catch (Exception e1){}
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs !=null)
{
rs.close();
rs = null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
}
catch(Exception e)
{
System.err.println("Exception :WORPostSaveEJB......... :\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("errString...2"+errString);
return errString;
}
//Culculate the trantype value from disparm
public String getDisparams(String prdCode,String varName,Connection conn)
{
String retVal = "";
String sql = "";
ResultSet rs = null;
Statement stmt = null;
try
{
System.out.println("In DISPAREM ");
stmt = conn.createStatement();
sql = "SELECT VAR_VALUE FROM DISPARM WHERE PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'";
rs = stmt.executeQuery(sql);
if(!rs.next())
{
System.out.println("No record found for PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'");
}
else
{
retVal = rs.getString(1);
System.out.println("In DISPAREM retVal.... "+retVal);
}
rs.close();
rs = null;
stmt.close();
stmt = null;
}
catch(Exception e)
{
System.out.println("Exception in ..getDIS....");
e.printStackTrace();
}
return(retVal);
}//End of disparm
//Culculate the trantype value from mfgparm
private String getmfgparams(String prdCode,String varName,Connection conn)
{
String retVal = "";
String sql = "";
ResultSet rs = null;
Statement stmt = null;
try
{
System.out.println("In MFGPAREM ");
stmt = conn.createStatement();
sql = "SELECT VAR_VALUE FROM MFGPARM WHERE PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'";
rs = stmt.executeQuery(sql);
if(!rs.next())
{
System.out.println("No record found for PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'");
}
else
{
retVal = rs.getString(1);
System.out.println("In MFGPAREM retVal..."+retVal);
}
rs.close();
rs = null;
stmt.close();
stmt = null;
}
catch(Exception e)
{
System.out.println("Exception in ..getMFG....");
e.printStackTrace();
}
return(retVal);
}//End of MFGparm
private String generateTranId(String windowName,String orderDate,String lot_no, String siteCode,String itemcode,Connection conn)
{
Statement stmt = null;
ResultSet rs = null;
String sql = "",sql1 = "";
String tranId = "";
String newKeystring = "";
String srType = "RS";
String item_ser = "";
System.out.println("itemcode...... :"+itemcode);
try
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW= '"+windowName+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
System.out.println("keyString :"+rs.toString());
String tranSer1 = "";
String keyString = "";
String keyCol = "";
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
rs.close();
rs = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer1 :"+tranSer1);
try
{
sql1 = "SELECT item_ser from item where item_code = '"+itemcode+"'" ;
System.out.println("sql1 ....:"+sql1);
rs = stmt.executeQuery(sql1);
if(rs.next())
{
item_ser = rs.getString(1);
System.out.println("item_ser..."+item_ser);
}
else
{
System.out.println("No record found ");
}
rs.close();
rs = null;
}
catch(Exception e)
{
System.out.println("Exception in ..item_ser....");
e.printStackTrace();
}
stmt.close();
stmt = null;
String xmlValues = "";
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>"+ orderDate + "</tran_date>";
xmlValues = xmlValues + "<item_ser>"+ item_ser + "</item_ser>";
xmlValues = xmlValues + "<item_code>"+itemcode + "</item_code>";
xmlValues = xmlValues + "<lot_no>" + lot_no + "</lot_no>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +sql+ ex.getMessage() + ":");
ex.printStackTrace();
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
}
return tranId;
}//generateTranTd()
private Node getCurrentDetailFromDom(Document dom,String domId)
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail1");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
return reqDetail;
}
//THIS FUNCTION RETURN DATE IN APPLICATION FORMAT
private String getCurrdateAppFormat()
{
String currAppdate = "";
java.sql.Timestamp currDate = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
Object date = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate).toString();
}
catch(Exception e)
{
System.out.println("Exception in :::currdate"+e.getMessage());
}
return (currAppdate);
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WORPostSaveLocal extends ValidatorLocal//, EJBObject
{
public String postSaveRec()throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WORPostSaveRemote extends ValidatorRemote//, EJBObject
{
public String postSaveRec()throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WOrderIssuePos extends ValidatorEJB implements WOrderIssuePosLocal, WOrderIssuePosRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String postSave() throws RemoteException,ITMException
{
return "";
}
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
System.out.println("WOrderIssuePosEJB called");
Document dom = null;
String errString = "";
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
errString = executePostSaveRec(dom,domId,objContext,editFlag,xtraParams, windowName, conn);
}
}
catch(Exception e)
{
System.out.println("Exception :WOrderIssuePosEJB ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
private String executePostSaveRec(Document dom, String domID,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
Statement stmt = null;
ResultSet rs = null;
String siteCodeReq = "", itemCode = "", lineNo = "",locCode = "", lotNo = "", lotSl = "";
String sql = "", line = "", tranType = "", errString = "";
HashMap strAllocate = null;
double quantity = 0d;
int updateCnt = 0, retVal = 0;
java.sql.Date tranDate = null;
String updateStatus = "",quantityStr = "",tranId = "";
NodeList hdrDom = null;
Node currDetail = null;
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
//added by Tarani 20052008
String potencyAdjStr = "0";
double potencyAdj = 0;
try
{
stmt = conn.createStatement();
tranDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("\n tranDate :"+tranDate);
hdrDom = dom.getElementsByTagName("Detail1");
tranType = GenericUtility.getInstance().getColumnValueFromNode("tran_type",hdrDom.item(0));
siteCodeReq = GenericUtility.getInstance().getColumnValueFromNode("site_code",hdrDom.item(0));
tranId = GenericUtility.getInstance().getColumnValueFromNode("tran_id",hdrDom.item(0));
System.out.println("\n tranId :"+tranId);
currDetail = getCurrentDetailFromDom(dom,domID);
updateStatus = getCurrentUpdateFlag(currDetail);
System.out.println("updateStatus :: "+updateStatus);
if (currDetail != null && !updateStatus.equalsIgnoreCase("D"))
{
lineNo = GenericUtility.getInstance().getColumnValueFromNode("line_no",currDetail);
itemCode = GenericUtility.getInstance().getColumnValueFromNode("item_code",currDetail);
locCode = GenericUtility.getInstance().getColumnValueFromNode("loc_code",currDetail);
lotNo = GenericUtility.getInstance().getColumnValueFromNode("lot_no",currDetail);
lotSl = GenericUtility.getInstance().getColumnValueFromNode("lot_sl",currDetail);
quantityStr = GenericUtility.getInstance().getColumnValueFromNode("quantity",currDetail);
potencyAdjStr = GenericUtility.getInstance().getColumnValueFromNode("potency_adj",currDetail);
quantity = Double.parseDouble(quantityStr);
//added by Tarani 20052008
if(potencyAdjStr==null || "null".equalsIgnoreCase(potencyAdjStr))potencyAdjStr="0";
potencyAdj = Double.parseDouble(potencyAdjStr);
quantity = quantity+potencyAdj;
if (!tranType.equals("R"))
{
line = " " + lineNo;
System.out.println("line :"+line);
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","W-ISS");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line",line.substring(line.length()-3));
strAllocate.put("site_code",siteCodeReq);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win",windowName);
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString ::: " + errString);
if (errString == "")
{
System.out.println("invAllocTrace.updateInvallocTrace : Sucessuful!");
}
}
}
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in WOrderIssuePosEJB :"+sqx);
sqx.printStackTrace();
errString = "ERROR";
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in WOrderIssuePosEJB :"+e);
e.printStackTrace();
errString = "ERROR";
throw new ITMException(e);
}
finally
{
try
{
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.err.println("Exception :WOrderIssuePosEJB:\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
//return errString;
}
private Node getCurrentDetailFromDom(Document dom,String domId) throws Exception
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
try
{
detailList = dom.getElementsByTagName("Detail2");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
}
catch(Exception e)
{
System.out.println("The Exception occurs in WOrderIssuePosEJB :"+e);
e.printStackTrace();
throw new ITMException(e);
}
return reqDetail;
}
private String getCurrentUpdateFlag(Node currDetail) throws Exception
{
NodeList currDetailList = null;
String updateStatus = "",nodeName = "";
int currDetailListLength = 0;
try
{
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
nodeName = currDetailList.item(i).getNodeName();
if (nodeName.equalsIgnoreCase("Attribute"))
{
updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
break;
}
}
}
catch(Exception e)
{
System.out.println("The Exception occurs in WOrderIssuePosEJB :"+e);
e.printStackTrace();
throw new ITMException(e);
}
return updateStatus;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WOrderIssuePosLocal extends ValidatorLocal//, EJBObject
{
public String postSave() throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WOrderIssuePosRemote extends ValidatorRemote//, EJBObject
{
public String postSave() throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import javax.ejb.*;
import org.w3c.dom.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WOrderIssuePrs extends ValidatorEJB implements WOrderIssuePrsLocal, WOrderIssuePrsRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String preSave() throws RemoteException,ITMException
{
return "";
}
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
System.out.println("WOrderIssuePrsEJB called");
Document dom = null;
String errString = "";
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
errString = executePreSaveRec(dom,domId,objContext,editFlag,xtraParams, windowName, conn);
}
}
catch(Exception e)
{
System.out.println("Exception :WOrderIssuePrsEJB ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
private String executePreSaveRec(Document dom, String domID,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException
{
Statement stmt = null;
ResultSet rs = null;
String siteCodeReq = "", itemCode = "", lineNo = "",locCode = "", lotNo = "", lotSl = "";
String sql = "", line = "", tranType = "", errString = "";
HashMap strAllocate = null;
double quantity = 0d;
int updateCnt = 0, retVal = 0;
java.sql.Date tranDate = null;
String updateStatus = "",quantityStr = "",tranId = "";
NodeList hdrDom = null;
Node currDetail = null;
InvAllocTraceBean invAllocTrace = new InvAllocTraceBean();
//added by Tarani 20052008
String potencyAdjStr = "0";
double potencyAdj = 0;
try
{
stmt = conn.createStatement();
tranDate = new java.sql.Date(System.currentTimeMillis());
System.out.println("\n tranDate :"+tranDate);
hdrDom = dom.getElementsByTagName("Detail1");
tranType = GenericUtility.getInstance().getColumnValueFromNode("tran_type",hdrDom.item(0));
siteCodeReq = GenericUtility.getInstance().getColumnValueFromNode("site_code",hdrDom.item(0));
tranId = GenericUtility.getInstance().getColumnValueFromNode("tran_id",hdrDom.item(0));
System.out.println("\n tranId :"+tranId);
currDetail = getCurrentDetailFromDom(dom,domID);
updateStatus = getCurrentUpdateFlag(currDetail);
System.out.println("updateStatus :: "+updateStatus);
if (currDetail != null && !updateStatus.equalsIgnoreCase("A"))
{
lineNo = GenericUtility.getInstance().getColumnValueFromNode("line_no",currDetail);
// commented by rajendra on 16/01/08 for taking all parameter from WORKORDER_ISSDET
// itemCode = GenericUtility.getInstance().getColumnValueFromNode("item_code",currDetail);
// locCode = GenericUtility.getInstance().getColumnValueFromNode("loc_code",currDetail);
// lotNo = GenericUtility.getInstance().getColumnValueFromNode("lot_no",currDetail);
// lotSl = GenericUtility.getInstance().getColumnValueFromNode("lot_sl",currDetail);
if (updateStatus.equalsIgnoreCase("E") || updateStatus.equalsIgnoreCase("D"))
{
//added by Tarani 20052008 POTENCY_ADJ
sql = "SELECT ITEM_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY ,POTENCY_ADJ FROM WORKORDER_ISSDET WHERE TRAN_ID = '"+tranId+"' AND LINE_NO = "+lineNo+"";
rs = stmt.executeQuery(sql);
if (rs.next())
{
itemCode = rs.getString("item_Code");
locCode = rs.getString("loc_Code");
lotNo = rs.getString("lot_No");
lotSl = rs.getString("lot_Sl");
quantityStr = rs.getString("QUANTITY");
//added by Tarani 20052008
potencyAdjStr = rs.getString("POTENCY_ADJ");
}
}
quantity = Double.parseDouble(quantityStr);
//added by Tarani 20052008
if(potencyAdjStr==null || "null".equalsIgnoreCase(potencyAdjStr))potencyAdjStr="0";
potencyAdj = Double.parseDouble(potencyAdjStr);
quantity = quantity+potencyAdj;
if (!tranType.equals("R"))
{
line = " " + lineNo;
System.out.println("line :"+line);
strAllocate = new HashMap();
strAllocate.put("tran_date",tranDate);
strAllocate.put("ref_ser","W-ISS");
strAllocate.put("ref_id",tranId);
strAllocate.put("ref_line",line.substring(line.length()-3));
strAllocate.put("site_code",siteCodeReq);
strAllocate.put("item_code",itemCode);
strAllocate.put("loc_code",locCode);
strAllocate.put("lot_no",lotNo);
strAllocate.put("lot_sl",lotSl);
strAllocate.put("alloc_qty",new Double(-1*quantity));
strAllocate.put("chg_user",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"loginCode"));
strAllocate.put("chg_term",GenericUtility.getInstance().getValueFromXTRA_PARAMS(xtraParams,"termId"));
strAllocate.put("chg_win",windowName);
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString ::: " + errString);
if (errString == "")
{
System.out.println("invAllocTrace.updateInvallocTrace : Sucessuful!");
}
}
}
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in WOrderIssuePrsEJB :"+sqx);
sqx.printStackTrace();
errString = "ERROR";
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in WOrderIssuePrsEJB :"+e);
e.printStackTrace();
errString = "ERROR";
throw new ITMException(e);
}
finally
{
try
{
if(stmt != null)
{
stmt.close();
stmt = null;
}
if (rs != null)
{
rs.close();
rs = null;
}
}
catch(Exception e)
{
System.err.println("Exception :WOrderIssuePrsEJB :\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
//return errString;
}
private Node getCurrentDetailFromDom(Document dom,String domId)
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail2");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
return reqDetail;
}
private String getCurrentUpdateFlag(Node currDetail)
{
NodeList currDetailList = null;
String updateStatus = "",nodeName = "";
int currDetailListLength = 0;
currDetailList = currDetail.getChildNodes();
currDetailListLength = currDetailList.getLength();
for (int i=0;i< currDetailListLength;i++)
{
nodeName = currDetailList.item(i).getNodeName();
if (nodeName.equalsIgnoreCase("Attribute"))
{
updateStatus = currDetailList.item(i).getAttributes().getNamedItem("updateFlag").getNodeValue();
break;
}
}
return updateStatus;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WOrderIssuePrsLocal extends ValidatorLocal//, EJBObject
{
public String preSave() throws RemoteException,ITMException;
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import ibase.webitm.ejb.*;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import java.sql.Connection;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WOrderIssuePrsRemote extends ValidatorRemote//, EJBObject
{
public String preSave() throws RemoteException,ITMException;
public String preSaveRec(String xmlString1,String domId,String objContext,String editFlag, String xtraParams, String windowName, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.sql.*;
import java.rmi.RemoteException;
import java.util.*;
import org.w3c.dom.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.system.config.*;
import ibase.webitm.utility.*;
import ibase.utility.*;
import ibase.webitm.ejb.*;
import java.text.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WoPostSave extends ValidatorEJB implements WoPostSaveLocal, WoPostSaveRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String postSaveRec() throws RemoteException, ITMException
{
return "";
}
public String postSaveRec(String xmlString1, String domId, String objContext, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException
{
System.out.println("WoPostSaveEJB Called............!");
System.out.println("xml............!"+xmlString1);
Document dom = null;
String saveRec = "";
try
{
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
saveRec = executepostSaveRec(dom,domId,objContext,editFlag,xtraParams,conn);
}
}
catch(Exception e)
{
System.out.println("Exception :WoPostSaveEJB :postSaveRec(): " + e.getMessage()+ ":");
e.printStackTrace();
throw new ITMException(e);
}
return saveRec;
}
private String executepostSaveRec(Document dom, String domID, String ObjContext, String editFlag, String xtraParams, Connection conn) throws RemoteException, ITMException
{
String ordertype = "", workorder = "", itemcode = "", sitecode = "" ,lotno = "";
String ordertypeT = "",genlotnoT = "", sql = "",sql1 = "",keyT = "";
NodeList hdrDom = null;
Node currDetail = null;
Statement stmt = null;
ResultSet rs = null;
String ls_fglotnoon = "",ls_setfg = "";
String ls_win = "fg_lotno";
String tranIdG = "",sqlUpd = "";
String errString = "";
String errCode = "";
String userId = "";
boolean lb_nositeitem = false;
int updCnt = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("userId :: "+userId);
currDetail = getCurrentHeaderFromDom(dom,domID);
if (currDetail != null)
{
ordertype = genericUtility.getColumnValueFromNode("order_type",currDetail);
workorder = genericUtility.getColumnValueFromNode("work_order",currDetail);
itemcode = genericUtility.getColumnValueFromNode("item_code",currDetail);
sitecode = genericUtility.getColumnValueFromNode("site_code",currDetail);
lotno = genericUtility.getColumnValueFromNode("lot_no",currDetail);
ordertype = ordertype.trim();
sitecode = sitecode.trim();
System.out.println("ordertype :: "+ordertype);
System.out.println("workorder ::"+workorder);
System.out.println("itemcode ::"+itemcode);
System.out.println("sitecode ::"+sitecode);
System.out.println("lotno ::"+lotno);
stmt = conn.createStatement();
try
{
sql1 = "SELECT CASE WHEN generate_lot_no IS NULL THEN '0' ELSE generate_lot_no END "
+" from siteitem where site_code = '"+sitecode+"' and item_code = '"+itemcode+"' ";
System.out.println("sql1 ....:"+sql1);
rs = stmt.executeQuery(sql1);
if(rs.next())
{
genlotnoT = rs.getString(1);
System.out.println("genlotnoT..."+genlotnoT);
}
else
{
lb_nositeitem = true;
System.out.println("lb_nositeitem...."+lb_nositeitem);
System.out.println("No record found for generate_lot_no");
}
rs.close();
rs = null;
}
catch(Exception e)
{
System.out.println("Exception in ..genlotnoT....");
e.printStackTrace();
}
ls_setfg = getDisparams("999999","FG_LOTNO",conn);
ls_setfg = ls_setfg.trim();
System.out.println("ls_setfg..."+ls_setfg);
ls_fglotnoon = getmfgparams("999999","FG_LOT_NO_ON",conn);
System.out.println("ls_fglotnoon......."+ls_fglotnoon);
System.out.println("count=>"+("RFP".indexOf(ordertype)));
if (ls_fglotnoon.equalsIgnoreCase("R"))
{
//Start - Commented by jaimin on 06/01/2009 (MF89DAM004)
/*System.out.println("ls_fglotnoon=R ");
errCode = "NOLOTNO";
errString = getErrorString("",errCode,userId);*/
//End - Commented by jaimin on 06/01/2009 (MF89DAM004)
}
else
{
if("RFP".indexOf(ordertype)>-1)
{
if(genlotnoT.equalsIgnoreCase("1") || (lb_nositeitem && ls_setfg.trim().indexOf(sitecode.trim()) > -1 ))
{
if(lotno == null || lotno.trim().length() == 0)
{
tranIdG=generateTranId(ls_win,getCurrdateAppFormat(),lotno,sitecode,itemcode,conn);
System.out.println("tranIdG......."+tranIdG);
if(tranIdG.equalsIgnoreCase("ERROR") || tranIdG.trim().length() == 0)
{
errCode = "NOLOTNO";
errString = getErrorString("",errCode,userId);
}
System.out.println("workorder ....:"+workorder);
sqlUpd = "update workorder set lot_no ='"+tranIdG+"' where work_order = '"+workorder+"'";
updCnt = stmt.executeUpdate(sqlUpd);
System.out.println("sqlUpd ....:"+sqlUpd);
if (updCnt == 1)
{
System.out.println("Update Into workorder Successfully....:: " + updCnt);
conn.commit();
}
else if (updCnt == 0)
{
System.out.println("No Updation Occur Into workorder ....:: " + updCnt);
conn.rollback();
errCode = "NOWORKODRNO";
errString = getErrorString("",errCode,userId);
}
}
}
}
}
stmt.close();
stmt = null;
}
}
catch(Exception e)
{
System.out.println("The Exception occurs in WoPostSaveEJB....... :"+e);
try
{
conn.rollback();
}
catch (Exception e1){}
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs=null;
}
if(stmt != null)
{
stmt.close();
stmt = null;
}
}
catch(Exception e)
{
System.err.println("Exception :WoPostSaveEJB......... :\n"+e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
System.out.println("errString..."+errString);
return errString;
}
//Culculate the trantype value from disparm
public String getDisparams(String prdCode,String varName,Connection conn)
{
String retVal = "";
String sql = "";
ResultSet rs = null;
Statement stmt = null;
try
{
System.out.println("In DISPAREM ");
stmt = conn.createStatement();
sql = "SELECT VAR_VALUE FROM DISPARM WHERE PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'";
rs = stmt.executeQuery(sql);
if(!rs.next() )
{
System.out.println("No record found for PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'");
retVal = "NULLFOUND";
}
else
{
retVal = rs.getString(1);
System.out.println("In DISPAREM retVal.... "+retVal);
}
rs.close();
rs = null;
stmt.close();
stmt = null;
}
catch(Exception e)
{
System.out.println("Exception in ..getDIS....");
e.printStackTrace();
}
return(retVal);
}//End of disparm
//Culculate the trantype value from mfgparm
private String getmfgparams(String prdCode,String varName,Connection conn)
{
String retVal = "";
String sql = "";
ResultSet rs = null;
Statement stmt = null;
try
{
System.out.println("In MFGPAREM ");
stmt = conn.createStatement();
sql = "SELECT VAR_VALUE FROM MFGPARM WHERE PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'";
rs = stmt.executeQuery(sql);
if(!rs.next() )
{
System.out.println("No record found for PRD_CODE ='"+prdCode+"' AND VAR_NAME ='"+varName+"'");
}
else
{
retVal = rs.getString(1);
System.out.println("retVal ..in mfg parm...."+retVal);
}
rs.close();
rs = null;
stmt.close();
stmt = null;
}
catch(Exception e)
{
System.out.println("Exception in ..getMFG....");
e.printStackTrace();
}
return(retVal);
}//End of MFGparm
private String generateTranId(String windowName,String orderDate,String lot_no, String siteCode,String itemcode, Connection conn)
{
Statement stmt = null;
ResultSet rs = null;
String sql = "",sql1="";
String tranId = "";
String newKeystring = "";
String srType = "RS";
String item_ser="";
System.out.println("windowName...... :"+windowName);
System.out.println("itemcode...... :"+itemcode);
try
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW= '"+windowName+"'";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
System.out.println("sql...... :"+sql);
System.out.println("keyString :"+rs.toString());
String tranSer1 = "";
String keyString = "";
String keyCol = "";
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
rs.close();
rs = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer1 :"+tranSer1);
try
{
sql1 = "SELECT item_ser from item where item_code = '"+itemcode+"'" ;
System.out.println("sql1 ....:"+sql1);
rs = stmt.executeQuery(sql1);
if(rs.next())
{
item_ser = rs.getString(1);
System.out.println("item_ser..."+item_ser);
}
else
{
System.out.println("No record found ");
}
rs.close();
rs = null;
}
catch(Exception e)
{
System.out.println("Exception in ..item_ser....");
e.printStackTrace();
}
stmt.close();
stmt = null;
String xmlValues = "";
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>"+ orderDate + "</tran_date>";
xmlValues = xmlValues + "<item_ser>"+ item_ser + "</item_ser>";
xmlValues = xmlValues + "<item_code>"+itemcode + "</item_code>";
xmlValues = xmlValues + "<lot_no>" + lot_no + "</lot_no>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +sql+ ex.getMessage() + ":");
ex.printStackTrace();
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
}
return tranId;
}//generateTranTd()
private Node getCurrentHeaderFromDom(Document dom,String domId)
{
NodeList detailList = null;
Node currDetail = null,reqDetail = null;
String currDomId = "";
int detailListLength = 0;
detailList = dom.getElementsByTagName("Detail1");
detailListLength = detailList.getLength();
for (int ctr = 0;ctr < detailListLength;ctr++)
{
currDetail = detailList.item(ctr);
currDomId = currDetail.getAttributes().getNamedItem("domID").getNodeValue();
if (currDomId.equals(domId))
{
reqDetail = currDetail;
break;
}
}
return reqDetail;
}
//THIS FUNCTION RETURN DATE IN APPLICATION FORMAT
private String getCurrdateAppFormat()
{
String currAppdate = "";
java.sql.Timestamp currDate = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
Object date = null;
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate).toString();
}
catch(Exception e)
{
System.out.println("Exception in :::currdate"+e.getMessage());
}
return (currAppdate);
}
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorLocal;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WoPostSaveLocal extends ValidatorLocal//, EJBObject
{
public String postSaveRec()throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ValidatorRemote;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WoPostSaveRemote extends ValidatorRemote//, EJBObject
{
public String postSaveRec()throws RemoteException,ITMException;
public String postSaveRec(String xmlString1,String domID,String objContext,String editFlag, String xtraParams, Connection conn)throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : WokCalendarPrcEJB
Date : 23/12/08
Author: pankaj singh
********************************************************/
package ibase.webitm.ejb.mfg;
import ibase.webitm.utility.*;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import java.rmi.RemoteException;
import java.text.*;
import java.util.*;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import java.io.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import java.util.GregorianCalendar;
import java.util.Calendar;
import java.util.Date;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WorkCalendarPrc extends ProcessEJB implements WorkCalendarPrcLocal, WorkCalendarPrcRemote //SessionBean
{
Connection sqlConn = null;
Connection oraConn = null;
String errorString = null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
int ctr = 0,cnt = 0;
String childNodeName = null;
String errCode = "";
int currentFormNo=0;
int childNodeListLength;
String selectQry = "";
String insertQry = "";
String upDateQry = "";
String selectDtl1Qry = "";
String selectDtl2Qry = "";
String insertDtl1Qry = "",newCustCode = "";
String insertDtl2Qry = "";
String selectItem = "";
ResultSet rs = null;
ResultSet detail1Rs = null;
ResultSet detail2Rs = null;
PreparedStatement psmt = null;
PreparedStatement dtl1Psmt = null;
PreparedStatement dtl2Psmt = null;
Statement stmt = null;
Statement dtl2Stmt = null;
ResultSet selectRs = null;
Statement selectStmt = null;
ConnDriver connDriver = null;
ResultSet dtlRs = null;
String working = "";
StringBuffer xmlString = null;
int date = 0,month= 0,year= 0,hour = 0,min = 0,sec = 0;
Date d = null;
//BasePreparedStatement oraPsmt = null;
PreparedStatement oraPsmt = null;
Statement st = null;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
int upd = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("Create Method Called....");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String process() throws RemoteException,ITMException
{
return "";
}
public String process(String xmlString, String xmlString2, String windowName, String xtraParams)
throws RemoteException,ITMException
{
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String retStr = "";
try
{
System.out.println("xmlString[process]::::::::::;;;"+xmlString);
System.out.println("xmlString2[process]::::::::::;;;"+xmlString2);
System.out.println("windowName[process]::::::::::;;;"+windowName);
System.out.println("xtraParams[process]:::::::::;;;"+xtraParams);
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :WokCalendarPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
}
return retStr;
}//END OF PROCESS (1)
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String retStr = "";
PreparedStatement pstmt = null;
PreparedStatement InsertPstmt = null;
ResultSet rs = null;
String sql = "" ,sql1 = "",errString = "";
String retString = "" ,errCode = "",tranId="";
String loginSiteCode="",empCode="",chgUser="",chgTerm="",loginCode="";
String policyNo="",insCertNo="",agent_code="",invoiceId="";
int count =0,cnt =0;
String curr_code="",dayNo = "",shiftOfDay = "";
double exch_rate=0,netAmt=0;
Timestamp tranDate =null;
HashMap insUpdHMap = null;
String siteCode = "",wokCntr = "",datefrom = "",dateto = "",holTblno = "",insertQry = "";
connDriver = new ConnDriver();
Map shift = null;
shift = new HashMap();
Calendar cal = null;
java.sql.Timestamp ToDate =null,FromDate = null;
try
{
System.out.println("xtraParams :::::::::::::::::::::::::::::::::: "+xtraParams);
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode");
empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("empCode..............."+empCode);
System.out.println("Login Site Code............."+loginSiteCode);
System.out.println("userId............."+chgUser);
System.out.println("termId............."+chgTerm);
oraConn = connDriver.getConnectDB("DriverITM");
oraConn.setAutoCommit(false);
connDriver = null;
siteCode = genericUtility.getColumnValue("site_code",headerDom);
wokCntr = genericUtility.getColumnValue("work_cntr",headerDom);
datefrom = genericUtility.getColumnValue("date_from",headerDom);
dateto = genericUtility.getColumnValue("date_to",headerDom);
System.out.println("Values from dom \n sitecode " + siteCode + "\n wokCntr " + wokCntr + "\n datefrom " + datefrom + "\n dateto " + dateto );
sql = "Select Count(*) from site where site_code = '"+siteCode+"' ";
System.out.println("select qry from site_code.." + sql);
pstmt= oraConn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (cnt == 0)
{
return errString = itmDBAccessEJB.getErrorString("","VMSITE1",chgUser);
}
if(datefrom == null || datefrom.trim().length() == 0 || dateto == null || dateto.trim().length() == 0)
{
return errString = itmDBAccessEJB.getErrorString("","VEDAT2",chgUser);
}
else
{
datefrom = genericUtility.getValidDateString(datefrom,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println(" from Date in dbdate format " + datefrom );
FromDate = java.sql.Timestamp.valueOf(datefrom + " 00:00:00.00");
FromDate = new java.sql.Timestamp((FromDate.getTime() - (24*60*60))); // added to change reduce date by 1 day on 2/feb/2009 by pankaj
System.out.println(" from Date in timestamp " + FromDate );
dateto = genericUtility.getValidDateString(dateto,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println(" to Date in dbdate format " + dateto );
ToDate = java.sql.Timestamp.valueOf(dateto + " 00:00:00.00");
System.out.println(" from Date in timestamp " + ToDate );
if(FromDate.after(ToDate))
{
return errString = itmDBAccessEJB.getErrorString("","VMVALIDDT",chgUser);
}
}
if(wokCntr == null || wokCntr.trim().length() == 0)
{
sql = "select count(*) "
+ " from work_calendar "
+ " where site_code = '" + siteCode + "'"
+ " and work_date between ? and ? ";
}
else
{
sql = "select count(*) "
+ " from work_calendar "
+ " where site_code = '" + siteCode + "'"
+ " and work_ctr = '" + wokCntr + "'"
+ " and work_date between ? and ? ";
}
System.out.println("sql for count " + sql);
pstmt = oraConn.prepareStatement(sql);
pstmt.setTimestamp(1,FromDate);
pstmt.setTimestamp(2,ToDate);
rs = pstmt.executeQuery();
while( rs.next() )
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("no of records found " + count);
if( count > 0)
{
if(wokCntr == null || wokCntr.trim().length() == 0)
{
sql = " delete "
+ " from work_calendar "
+ " where site_code = '" + siteCode + "'"
+ " and work_date between ? and ? ";
}
else
{
sql = " delete "
+ " from work_calendar "
+ " where site_code = '" + siteCode + "'"
+ " and work_ctr = '" + wokCntr + "'"
+ " and work_date between ? and ? ";
}
System.out.println("sql for delete " + sql);
pstmt = oraConn.prepareStatement(sql);
pstmt.setTimestamp(1,FromDate);
pstmt.setTimestamp(2,ToDate);
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("records deleted " + count);
//caled insertSchedule to insert schehedule after deleting existing records
//errString = insertSchedule(siteCode,wokCntr,FromDate,ToDate,chgUser,chgTerm);
}
errString = insertSchedule(siteCode,wokCntr,FromDate,ToDate,chgUser,chgTerm,oraConn);
if(errString != null && errString.trim().length() == 0)
{
oraConn.commit();
System.out.println("Connection commited");
errString = itmDBAccessEJB.getErrorString("","WRKCALSUCC",chgUser);
}
else
{
System.out.println("Connection rollbacked");
oraConn.rollback();
}
}
catch(Exception e)
{
System.out.println("Exception in WokCalendarPrcEJB..."+e.getMessage());
e.printStackTrace();
errString = e.getMessage();
}
finally
{
try
{
if(rs != null)rs.close();
rs = null;
if(pstmt != null)pstmt.close();
pstmt = null;
if( InsertPstmt != null)InsertPstmt.close();
InsertPstmt = null;
if(oraConn != null)oraConn.close();
oraConn = null;
}
catch(SQLException sqle)
{
sqle.printStackTrace();
}
}
System.out.println("returning from WokCalendarPrcEJB "+errString);
return errString;
} //end process
public String insertSchedule(String siteCode,String wokCntr,Timestamp FromDate,Timestamp ToDate,String chgUser,String chgTerm,Connection oraConn )
{
String retStr = "";
PreparedStatement pstmt = null;
PreparedStatement InsertPstmt = null;
ResultSet rs = null;
String sql = "" ,sql1 = "",errString = "";
String retString = "" ,errCode = "",tranId="";
String loginSiteCode="",empCode="",loginCode="";
String policyNo="",insCertNo="",agent_code="",invoiceId="";
int count =0,cnt =0;
String curr_code="",dayNo = "",shiftOfDay = "";
double exch_rate=0,netAmt=0;
Timestamp tranDate =null;
HashMap insUpdHMap = null;
String datefrom = "",dateto = "",holTblno = "",insertQry = "";
Map shift = null;
shift = new HashMap();
int upd[] = new int[10];
Calendar cal = null;
//java.sql.Timestamp ToDate =null,FromDate = null;
System.out.println("Inserting records..........");
try
{
sql = "select hol_tblno from site where site_code = '" + siteCode + "'";
System.out.println("sql for hol_tblno " + sql);
pstmt = oraConn.prepareStatement(sql);
rs = pstmt.executeQuery();
while( rs.next() )
{
holTblno = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println(" hol_tblno " + holTblno);
do
{
if(FromDate != null )
{
cal = Calendar.getInstance();
System.out.println("cal today :- " + cal.getTime());
d= new Date(FromDate.getTime());
cal.setTime(d);
//cal.set(year,month,date);
System.out.println("cal :- " + cal.getTime());
cal.add(Calendar.DAY_OF_MONTH,1);
System.out.println("cal incr :- " + cal.getTime());
FromDate = new java.sql.Timestamp(cal.getTime().getTime() );
System.out.println("FromDate :- " + FromDate);
System.out.println(FromDate.toString().substring(0,11) + "00:00:00.0");
String chan = FromDate.toString().substring(0,11) + "00:00:00.0";
System.out.println(chan);
FromDate = Timestamp.valueOf(chan);
System.out.println("FromDate changed :- " + FromDate);
}
sql = " select count(*) "
+ " from holiday "
+ " where hol_tblno = '" + holTblno + "'"
+ " and hol_date = ?";
pstmt = oraConn.prepareStatement(sql);
pstmt.setTimestamp(1,FromDate);
rs = pstmt.executeQuery();
while( rs.next() )
{
count = rs.getInt(1);
}
System.out.println("no of holidays " + count);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( count == 0)
{
working = "Y";
}
else
{
working = "N";
}
System.out.println("working status " + working);
insertQry = " INSERT INTO work_calendar "
+ "("
+ " site_code,work_date,day_no,"
+ " shift ,working,confirmed,"
+ " chg_date,chg_user,chg_term,"
+ " work_ctr )"
+ " VALUES (?,?,?,"
+ " ?,?,?,"
+ " ?,?,?,"
+ " ?)";
System.out.println("Insert query " + insertQry);
InsertPstmt = oraConn.prepareStatement(insertQry);
java.sql.Timestamp currDate = null;
String currAppdate = "";
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
System.out.println("\n today date----" + currDate);
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate).toString();
System.out.println("\n today currDate in apl----" + currAppdate);
currAppdate = genericUtility.getValidDateString(currAppdate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("\n today currDate in DB----" + currAppdate);
currDate = Timestamp.valueOf(currAppdate + " 00:00:00.00");
System.out.println("\n today currDate in timestamp----" + currDate);
TreeMap dayMap = new TreeMap();
TreeMap shiftMap = new TreeMap();
String day[] = new String[100],shiftAr[] = new String[100];
Object name = null,dayOb = null,shiftOb = null;
Object shftName = null,dayNum = null;
int i = 0;
if(wokCntr == null || wokCntr.trim().length() == 0)
{
sql = " SELECT "
+ " DAY_NO ,SHIFT "
+ " FROM WORKSHFT "
+ " WHERE site_code = '" + siteCode + "'";
}
else
{
sql = " SELECT DAY_NO ,SHIFT FROM WORKCNTRSHFT"
+ " WHERE site_code = '" + siteCode + "'"
+ " and work_ctr = '" + wokCntr + "'";
}
System.out.println("select day,shift query " + sql);
pstmt = oraConn.prepareStatement(sql);
rs = pstmt.executeQuery();
while( rs.next() )
{
dayNo = rs.getString(1);
dayMap.put("day[" + i +"]",dayNo);
System.out.println("dayNo : " + dayNo);
shiftOfDay = rs.getString(2);
System.out.println("shiftOfDay : " + shiftOfDay);
shiftMap.put("shiftAr[" + i +"]",shiftOfDay);
i++;
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
Iterator it = dayMap.keySet().iterator();
Iterator itshft = shiftMap.keySet().iterator();
System.out.println("Reading data...... " );
while( itshft.hasNext() )
{
while( it.hasNext() )
{
System.out.println("Inside map..................");
InsertPstmt.setString(1,siteCode);
InsertPstmt.setTimestamp(2,FromDate);
System.out.println("primary setting wor date " + FromDate);
dayNum = it.next();
dayOb = dayMap.get(dayNum) ;
//System.out.println(" primary Day:- " + dayNum + " value:-" + dayOb);
InsertPstmt.setString(3,dayOb.toString());
shftName = itshft.next();
shiftOb = shiftMap.get(shftName) ;
System.out.println(" primary Day:- " + dayNum + " value:-" + dayOb +" primary Shift:- " + shftName + " value:-" + shiftOb);
InsertPstmt.setString(4,shiftOb.toString());
InsertPstmt.setString(5,working);
InsertPstmt.setString(6,"Y");
InsertPstmt.setTimestamp(7,currDate);
InsertPstmt.setString(8,chgUser);
InsertPstmt.setString(9,chgTerm);
System.out.println(" primary setting wokCntr " + wokCntr);
if(wokCntr == null || wokCntr.trim().length() == 0)
{
InsertPstmt.setString(10," ");
}
else
{
InsertPstmt.setString(10,wokCntr);
}
InsertPstmt.addBatch();
}
}
InsertPstmt.executeBatch();
//oraConn.commit();
System.out.println("data inserted in work calendar sucesfully!" + upd);
}
while( FromDate.before(ToDate) );
}//end try
catch (Exception exception)
{
exception.printStackTrace();
errString = exception.getMessage();
}
System.out.println("errString in insert schedule.........." + errString);
return errString;
}//end inser schedule
}//end class
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.xml.parsers.*;
import ibase.webitm.ejb.ProcessLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WorkCalendarPrcLocal extends ProcessLocal//, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import javax.xml.parsers.*;
import ibase.webitm.ejb.ProcessRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WorkCalendarPrcRemote extends ProcessRemote//, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(String string1, String string2, String windowName, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/********************************************************
Title : WorkOrderAmdEJB
Date : 21/01/09
Author: pankaj singh
********************************************************/
package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.GregorianCalendar;
import java.util.Calendar;
import java.util.Date;
import javax.ejb.CreateException;
import javax.ejb.SessionBean;
import java.text.SimpleDateFormat;
import java.sql.Timestamp;
import ibase.webitm.ejb.sys.UtilMethods;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WorkOrderAmd extends ValidatorEJB implements WorkOrderAmdLocal, WorkOrderAmdRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("<======= WorkOrderAmdEJB DISPLAY IS IN PROCESS ! \n Welcome!========>");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String wfValData() throws RemoteException,ITMException
{
return "";
}
public String itemChanged() 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
{
dom = parseString(xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString("<Root>" + xmlString2+ "</Root>");
}
errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : WorkOrderAmdEJB : wfValData(String xmlString) : ==>\n"+e.getMessage());
}
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;
String childNodeName = null;
String errString = "";
String errCode = "",errcode = "";
Connection conn = null;
PreparedStatement pstmt = null ;
ResultSet rs = null , rs1 = null;
String sql = "" ,sql1 = "";
String userId = "";
String effFromStr = null;
String validUptoStr = null;
String divHead="",tranIdRef = "";
double minAmount = 0;
double maxAmount = 0;
int cnt = 0,cnt1 = 0;
int currentFormNo=0;
int childNodeListLength;
String mfgDateStart = "",expDate = "",planDueDate = "";
Timestamp mfgDateStartTs = null,mfgDateStartOldTs = null;
Timestamp expDateTs = null,expDateOldTs = null;
String expDateOld = "";
String mfgDateStartOld = "";
ConnDriver connDriver = new ConnDriver();
String siteCode = "",empCodeAmd = "",startTime = "",confirmed = "",status = "",projCode = "";
Timestamp planDueDateTs = null,planDueDateOldTs = null;
String planDueDateOld = "";
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
GenericUtility genericUtility = GenericUtility.getInstance();
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
switch(currentFormNo)
{
case 1 :
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 (childNodeName.equalsIgnoreCase("site_code"))
{
siteCode = getColumnValue("site_code",dom);
siteCode = siteCode == null ? "" : siteCode;
sql = "Select count(*) from site where site_code ='"+siteCode+"'";
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
errCode = "VMSITE1";
errString = getErrorString("site_code",errCode,userId);
break;
}
}// End Of site_code
else if (childNodeName.equalsIgnoreCase("work_order__ref"))
{
tranIdRef = getColumnValue("work_order__ref",dom);
sql = "Select status from workorder where tran_id ='"+tranIdRef+"'";
System.out.println("Sql for status................:- " + sql);
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
status = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("status>>>>>>>>>>>>>> " + status);
if( status.equalsIgnoreCase("R") || status.equalsIgnoreCase("U"))
{
System.out.println("U r permited>>>>>>>>>>>>>> " + status);
}
else
{
errCode = "VTWOSA";
errString = getErrorString("tran_id__ref",errCode,userId);
break;
}
}// End Of tran_id__ref
else if (childNodeName.equalsIgnoreCase("mfg_date__start"))
{
mfgDateStart = getColumnValue("mfg_date__start",dom);
mfgDateStartOld = getColumnValue("mfg_date__start__o",dom);
expDate = getColumnValue("exp_date",dom);
planDueDate = getColumnValue("plan__due_date",dom);
if( (mfgDateStart == null || mfgDateStart.trim().length() == 0) && (expDate == null || expDate.trim().length() == 0)&&(planDueDate == null || planDueDate.trim().length() == 0))
{
errCode = "VTWOVLNL";
errString = getErrorString("mfg_date__start",errCode,userId);
break;
}// end if any value is null
else
{
mfgDateStart = genericUtility.getValidDateString(mfgDateStart,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("mfgDateStart in dbdate format:- " + mfgDateStart);
System.out.println("mfgDateStart + 00:00:00.0 in dbdate format:- " + (mfgDateStart + " 00:00:00.0"));
mfgDateStartTs = Timestamp.valueOf(mfgDateStart + " 00:00:00.0");
System.out.println("mfgDateStart in Timestamp:- " + mfgDateStart);
if(mfgDateStartOld != null && mfgDateStartOld.trim().length() > 0)
{
mfgDateStartOld = genericUtility.getValidDateString(mfgDateStartOld,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("mfgDateStartOld in dbdate format:- " + mfgDateStartOld);
System.out.println("mfgDateStartOld + 00:00:00.0 in dbdate format:- " + (mfgDateStartOld + " 00:00:00.0"));
mfgDateStartOldTs = Timestamp.valueOf(mfgDateStartOld + " 00:00:00.0");
System.out.println("mfgDateStartOldTs in Timestamp:- " + mfgDateStartOldTs);
if(mfgDateStartTs.compareTo(mfgDateStartOldTs) == 0)
{
errCode = "VTWOMFNL";
errString = getErrorString("mfg_date__start",errCode,userId);
break;
}
if(mfgDateStartTs.before(mfgDateStartOldTs))
{
errCode = "VTWOMFIN";
errString = getErrorString("mfg_date__start",errCode,userId);
break;
}
}
if(mfgDateStartTs.before(getCurrdateAppFormat()))
{
System.out.println("Previous day mfg date:");
errCode = "VTWOMFMFT";
errString = getErrorString("start_time",errCode,userId);
break;
}
}
}//end mfg_date
else if (childNodeName.equalsIgnoreCase("exp_date"))
{
mfgDateStart = getColumnValue("mfg_date__start",dom);
expDateOld = getColumnValue("exp_date__o",dom);
expDate = getColumnValue("exp_date",dom);
planDueDate = getColumnValue("plan__due_date",dom);
if( expDate == null || expDate.trim().length() == 0)
{
}// end if expDate is null
else
{
expDate = genericUtility.getValidDateString(expDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("expDate in dbdate format:- " + expDate);
System.out.println("expDate + 00:00:00.0 in dbdate format:- " + (expDate + " 00:00:00.0"));
expDateTs = Timestamp.valueOf(expDate + " 00:00:00.0");
if(mfgDateStart != null && mfgDateStart.trim().length() > 0)
{
mfgDateStart = genericUtility.getValidDateString(mfgDateStart,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("mfgDateStart in dbdate format:- " + mfgDateStart);
System.out.println("mfgDateStart + 00:00:00.0 in dbdate format:- " + (mfgDateStart + " 00:00:00.0"));
mfgDateStartTs = Timestamp.valueOf(mfgDateStart + " 00:00:00.0");
System.out.println("mfgDateStart in Timestamp:- " + mfgDateStart);
}
if(expDateOld != null && expDateOld.trim().length() > 0)
{
expDateOld = genericUtility.getValidDateString(expDateOld,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("expDateOld in dbdate format:- " + expDateOld);
System.out.println("expDateOld + 00:00:00.0 in dbdate format:- " + (expDateOld + " 00:00:00.0"));
expDateOldTs = Timestamp.valueOf(expDateOld + " 00:00:00.0");
System.out.println("mfgDateStartOldTs in Timestamp:- " + expDateOldTs);
System.out.println("expDateTs.compareTo(mfgDateStartTs)>>>>>>>>> " + expDateTs.compareTo(mfgDateStartTs));
if(expDateTs.compareTo(mfgDateStartTs) <= 0)
{
errCode = "VTWOEXMF";
errString = getErrorString("mfg_date__start",errCode,userId);
break;
}
if(expDateTs.before(expDateOldTs))
{
System.out.println("Changed expiry date less the old exp date:");
errCode = "VTWOEXIN";
errString = getErrorString("mfg_date__start",errCode,userId);
break;
}
}
// if(expDateTs.compareTo(expDateOldTs) == 0)
// {
// errCode = "VTWOVLNL";
// errString = getErrorString("mfg_date__start",errCode,userId);
// break;
// }
if(expDateTs.before(getCurrdateAppFormat()))
{
System.out.println("Previous day expdate:");
errCode = "VTWOMFMFT";
errString = getErrorString("start_time",errCode,userId);
break;
}
}
}// end exp date
else if (childNodeName.equalsIgnoreCase("plan__due_date"))
{
mfgDateStart = getColumnValue("mfg_date__start",dom);
planDueDateOld = getColumnValue("plan_due_date_o",dom);
expDate = getColumnValue("exp_date",dom);
planDueDate = getColumnValue("plan__due_date",dom);
if( planDueDate == null || planDueDate.trim().length() == 0)
{
}// end if planDueDate is null
else
{
planDueDate = genericUtility.getValidDateString(planDueDate,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("planDueDate in dbdate format:- " + planDueDate);
System.out.println("planDueDate + 00:00:00.0 in dbdate format:- " + (planDueDate + " 00:00:00.0"));
planDueDateTs = Timestamp.valueOf(planDueDate + " 00:00:00.0");
System.out.println("planDueDateTs in Timestamp:- " + planDueDateTs);
System.out.println("planDueDateOld:- " + planDueDateOld);
if(planDueDateOld != null && planDueDateOld.trim().length() > 0)
{
planDueDateOld = genericUtility.getValidDateString(planDueDateOld,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("planDueDateOld in dbdate format:- " + planDueDateOld);
System.out.println("planDueDateOld + 00:00:00.0 in dbdate format:- " + (planDueDateOld + " 00:00:00.0"));
planDueDateOldTs = Timestamp.valueOf(planDueDateOld + " 00:00:00.0");
System.out.println("planDueDateOldTs in Timestamp:- " + planDueDateOldTs);
if(planDueDateTs.compareTo(planDueDateOldTs) == 0)
{
errCode = "VTWOPLNL";
errString = getErrorString("mfg_date__start",errCode,userId);
break;
}
if(planDueDateTs.before(planDueDateOldTs))
{
errCode = "VTWOPLIN";
errString = getErrorString("mfg_date__start",errCode,userId);
break;
}
}
if(planDueDateTs.before(getCurrdateAppFormat()))
{
System.out.println("Previous day plan date:");
errCode = "VTWOMFPLT";
errString = getErrorString("start_time",errCode,userId);
break;
}
}//plan__due_date not null
}// end plan__due_date
// end proj_time
}//end for
} //END switch
}//END TRY
catch(Exception e)
{
System.out.println("Exception ::"+e);
e.printStackTrace();
errString=e.getMessage();
}
finally
{
try
{
if(conn!=null)
{
if(pstmt != null )pstmt.close();
if(rs != null )rs.close();
if(rs1 != null )rs.close();
rs = null;
rs1 = null;
pstmt =null;
conn.close();
}
conn = null;
}catch(Exception d)
{
d.printStackTrace();
}
System.out.println("[WorkOrderAmdEJB] Connection is Closed");
}
System.out.println("ErrString ::"+errString);
return errString;
}//END OF VALIDATION
public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document dom2 = null;
String valueXmlString = "";
try
{
dom = parseString(xmlString);
System.out.println("xmlString" + xmlString);
dom1 = parseString(xmlString1);
if (xmlString2.trim().length() > 0 )
{
dom2 = parseString(xmlString2);
}
valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams);
}
catch(Exception e)
{
System.out.println("Exception : [WorkOrderAmdEJB][itemChanged(String,String)] :==>\n"+e.getMessage());
}
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException
{
StringBuffer valueXmlString = new StringBuffer();
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null ;
int ctr=0;
String childNodeName = null;
String columnValue = null;
String Col_name = "";
int currentFormNo = 0 ,cnt = 0;
int ShortId = 0;
String salesPers = "" ,itemSer = "",descr = "", empCodeAprv = "",empCodeAmd = "",tranIdRef = "";
String fName = "",lName = "",mName = "";
String sql = "",sql1 = "",startTime = "",noOfHour = "",endTime = "";
double noOfHourD = 0.0;
int noOfHr =0,noOfMin = 0;
String trackShelfLife = "",mfgDateStartStr = "",expDateStr = "",planDueDateStr = "";
int shelfLife = 0;
Timestamp mfgDateStart = null,expDate = null,planDueDate = null;
String noOfHourStr = "",startTimeStr = "",endTimeStr = "";
Timestamp startTs = null,endTs = null;
String loginSite = "", siteCode = "",status= "",siteDescr = "";
Calendar calender = Calendar.getInstance();
ConnDriver connDriver = new ConnDriver();
Timestamp startTimeTs = null,endTimeTs = null,statusDateTs = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String statusDate = "",projCode="",workCntr = "",workCntrDescr = "";
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver=null;
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("Itemchange called for WorderAmd>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>");
System.out.println("FORM NO:::"+currentFormNo);
System.out.println("\n Extra param........"+xtraParams);
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>");
valueXmlString.append(editFlag).append("</editFlag></header>");
valueXmlString.append("<Detail>");
switch(currentFormNo)
{
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
ctr = 0;
int childNodeListLength = childNodeList.getLength();
do
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn))
{
if (childNode.getFirstChild() != null)
{
columnValue = childNode.getFirstChild().getNodeValue().trim();
}
}
ctr++;
}while(ctr < childNodeListLength && !childNodeName.equals(currentColumn));
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
loginSite = getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
empCodeAmd = getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
sql = "select descr from site where site_code = '"+loginSite+"'";
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
String s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(getCurrdateAppFormat()).toString();
valueXmlString.append("<site_code>").append("<![CDATA["+loginSite.trim()+"]]>").append("</site_code>");
valueXmlString.append("<tran_date>").append("<![CDATA["+s+"]]>").append("</tran_date>");
valueXmlString.append("<site_descr>").append("<![CDATA["+descr.trim()+"]]>").append("</site_descr>");
sql = "select emp_fname,emp_mname,emp_lname from employee where emp_code = '" + empCodeAmd.toUpperCase() + "'";
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
fName = rs.getString("emp_fname") == null ? "" : rs.getString("emp_fname");
mName = rs.getString("emp_mname") == null ? "" : rs.getString("emp_mname");
lName = rs.getString("emp_lname") == null ? "" : rs.getString("emp_lname");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<emp_code__amd protect =\"1\">").append("<![CDATA["+empCodeAmd.toUpperCase().trim()+"]]>").append("</emp_code__amd>");
valueXmlString.append("<emp_fname_1>").append("<![CDATA["+fName.trim()+"]]>").append("</emp_fname_1>");
valueXmlString.append("<emp_mname_1>").append("<![CDATA["+mName.trim()+"]]>").append("</emp_mname_1>");
valueXmlString.append("<emp_lname_1>").append("<![CDATA["+lName.trim()+"]]>").append("</emp_lname_1>");
}
else if(currentColumn.trim().equalsIgnoreCase("itm_defaultedit"))
{
tranIdRef = getColumnValue("work_order__ref",dom);
expDateStr = getColumnValue("exp_date",dom);
sql =" select track_shelf_life,shelf_life "
+ " from item "
+ " where item_code = "
+ " (Select item_code from "
+ " workorder where tran_id = '"+tranIdRef +"')" ;
System.out.println("exp date qry>>>>>> " +sql);
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
trackShelfLife = rs.getString(1);
shelfLife = rs.getInt(2);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("trackShelfLife>>>>> " +trackShelfLife + " shelfLife>>>>>>>> " + shelfLife);
if(trackShelfLife.equalsIgnoreCase("Y"))
{
valueXmlString.append("<exp_date protect =\"1\">").append("<![CDATA["+expDateStr.trim()+"]]>").append("</exp_date>");
}
else
{
valueXmlString.append("<exp_date protect =\"0\">").append("<![CDATA["+expDateStr.trim()+"]]>").append("</exp_date>");
}
}
else if(currentColumn.trim().equalsIgnoreCase("site_code"))
{
siteCode = getColumnValue("site_code",dom);
sql = "select descr from site where site_code = '"+siteCode.toUpperCase()+"'";
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
descr = rs.getString(1) == null ? "" : rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<site_descr>").append("<![CDATA["+descr.trim()+"]]>").append("</site_descr>");
valueXmlString.append("<site_code>").append("<![CDATA["+siteCode.toUpperCase().trim()+"]]>").append("</site_code>");
}
else if(currentColumn.trim().equalsIgnoreCase("work_order__ref"))
{
tranIdRef = getColumnValue("work_order__ref",dom);
sql = " select mfg_date__start,exp_date,plan_due_date "
+ " from workorder where tran_id = '"+tranIdRef +"'";
System.out.println("values from workorder qry>>>>>> " +sql);
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mfgDateStart = rs.getTimestamp(1);
expDate = rs.getTimestamp(2);
planDueDate = rs.getTimestamp(3);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(mfgDateStart != null )
{
mfgDateStartStr = genericUtility.getValidDateString(mfgDateStart.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
}
if(expDate != null )
{
expDateStr = genericUtility.getValidDateString(expDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
}
if(planDueDate != null)
{
planDueDateStr = genericUtility.getValidDateString(planDueDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
}
valueXmlString.append("<mfg_date__start__o>").append("<![CDATA["+mfgDateStartStr.trim()+"]]>").append("</mfg_date__start__o>");
valueXmlString.append("<exp_date__o>").append("<![CDATA["+expDateStr.trim()+"]]>").append("</exp_date__o>");
valueXmlString.append("<plan_due_date_o>").append("<![CDATA["+planDueDateStr.trim()+"]]>").append("</plan_due_date_o>");
// sql =" select track_shelf_life,shelf_life "
// + " from item "
// + " where item_code = "
// + " (Select item_code from "
// + " workorder where tran_id = '"+tranIdRef +"')" ;
// System.out.println("exp date qry>>>>>> " +sql);
// pstmt= conn.prepareStatement(sql);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// trackShelfLife = rs.getString(1);
// shelfLife = rs.getInt(2);
// }
// pstmt.close();
// rs.close();
// pstmt = null;
// rs = null;
// System.out.println("trackShelfLife>>>>> " +trackShelfLife + " shelfLife>>>>>>>> " + shelfLife);
// if(trackShelfLife.equalsIgnoreCase("Y"))
// {
// calender.setTimeInMillis(mfgDateStart.getTime());
// calender.add(Calendar.MONTH,shelfLife);
// System.out.println("exp date old>>>>>> " + expDateStr );
// System.out.println("exp date calculated>>>>>> " + calender.getTime() );
// sql = "select last_day(?) from dual";
// pstmt= conn.prepareStatement(sql);
// pstmt.setTimestamp(1,new Timestamp(calender.getTime().getTime()));
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// expDate = rs.getTimestamp(1);
// }
// System.out.println("last exp date calculated>>>>>> " + expDate + " expDateStr>> " +expDateStr );
// pstmt.close();
// rs.close();
// pstmt = null;
// rs = null;
// expDateStr = genericUtility.getValidDateString(expDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
// valueXmlString.append("<exp_date>").append("<![CDATA["+expDateStr.trim()+"]]>").append("</exp_date>");
// }
// else
// {
// valueXmlString.append("<exp_date>").append("").append("</exp_date>");
// }
}
else if(currentColumn.trim().equalsIgnoreCase("emp_code__aprv"))
{
empCodeAprv = getColumnValue("mfg_date__start",dom);
System.out.println("empCodeAprv:- " + empCodeAprv);
sql = "select emp_fname,emp_mname,emp_lname from employee where emp_code = '" + empCodeAprv.toUpperCase() + "'";
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
fName = rs.getString("emp_fname") == null ? "" : rs.getString("emp_fname");
mName = rs.getString("emp_mname") == null ? "" : rs.getString("emp_mname");
lName = rs.getString("emp_lname") == null ? "" : rs.getString("emp_lname");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<emp_fname>").append("<![CDATA["+fName.trim()+"]]>").append("</emp_fname>");
valueXmlString.append("<emp_fname>").append("<![CDATA["+mName.trim()+"]]>").append("</emp_fname>");
valueXmlString.append("<emp_fname>").append("<![CDATA["+lName.trim()+"]]>").append("</emp_fname>");
System.out.println("valueXmlString for emp_code aprv:- " + valueXmlString);
}
else if(currentColumn.trim().equalsIgnoreCase("mfg_date__start"))
{
mfgDateStartStr = getColumnValue("mfg_date__start",dom);
System.out.println("mfgDateStartStr:- " + mfgDateStartStr);
if(mfgDateStartStr == null || mfgDateStartStr.trim().length() == 0)
{
tranIdRef = getColumnValue("work_order__ref",dom);
sql =" select track_shelf_life,shelf_life "
+ " from item "
+ " where item_code = "
+ " (Select item_code from "
+ " workorder where tran_id = '"+tranIdRef +"')" ;
System.out.println("exp date qry>>>>>> " +sql);
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
trackShelfLife = rs.getString(1);
shelfLife = rs.getInt(2);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("trackShelfLife>>>>> " +trackShelfLife + " shelfLife>>>>>>>> " + shelfLife);
if(trackShelfLife.equalsIgnoreCase("Y"))
{
valueXmlString.append("<exp_date protect =\"1\">").append("<![CDATA[]]>").append("</exp_date>");
}
else
{
valueXmlString.append("<exp_date protect =\"0\">").append("<![CDATA[]]>").append("</exp_date>");
}
}
else
{
mfgDateStartStr = genericUtility.getValidDateString(mfgDateStartStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
System.out.println("mfgDateStartStr in dbdate format:- " + mfgDateStartStr);
System.out.println("mfgDateStartStr + 00:00:00.0 in dbdate format:- " + (mfgDateStartStr + " 00:00:00.0"));
mfgDateStart = Timestamp.valueOf(mfgDateStartStr + " 00:00:00.0");
System.out.println("mfgDateStart in Timestamp:- " + mfgDateStart);
tranIdRef = getColumnValue("work_order__ref",dom);
sql =" select track_shelf_life,shelf_life "
+ " from item "
+ " where item_code = "
+ " (Select item_code from "
+ " workorder where tran_id = '"+tranIdRef +"')" ;
System.out.println("exp date qry>>>>>> " +sql);
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
trackShelfLife = rs.getString(1);
shelfLife = rs.getInt(2);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
System.out.println("trackShelfLife>>>>> " +trackShelfLife + " shelfLife>>>>>>>> " + shelfLife);
if(trackShelfLife.equalsIgnoreCase("Y"))
{
calender.setTimeInMillis(mfgDateStart.getTime());
calender.add(Calendar.MONTH,shelfLife);
System.out.println("exp date old>>>>>> " + expDateStr );
System.out.println("exp date calculated>>>>>> " + calender.getTime() );
sql = "select last_day(?) from dual";
pstmt= conn.prepareStatement(sql);
pstmt.setTimestamp(1,new Timestamp(calender.getTime().getTime()));
rs = pstmt.executeQuery();
if(rs.next())
{
expDate = rs.getTimestamp(1);
}
System.out.println("last exp date calculated>>>>>> " + expDate + " expDateStr>> " +expDateStr );
pstmt.close();
rs.close();
pstmt = null;
rs = null;
expDateStr = genericUtility.getValidDateString(expDate.toString(),genericUtility.getDBDateFormat(),genericUtility.getApplDateFormat());
valueXmlString.append("<exp_date protect =\"1\">").append("<![CDATA["+expDateStr.trim()+"]]>").append("</exp_date>");
}
else
{
valueXmlString.append("<exp_date protect =\"0\">").append("").append("</exp_date>");
}
}
}
valueXmlString.append("</Detail>");
break;
}//end of switch
valueXmlString.append("</Root>");
}//END OF TRY
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception ::"+e.getMessage());
throw new ITMException(e);
}
finally
{
try
{
if(conn!=null)
{
if(pstmt != null)pstmt.close();
if(rs != null)rs.close();
rs = null;
pstmt = null;
conn.close();
}
conn = null;
}catch(Exception d)
{
d.printStackTrace();
}
System.out.println("[WorkOrderAmdEJB] CONNECTION is CLOSED");
}
System.out.println("valueXmlString:::::"+valueXmlString.toString());
return valueXmlString.toString();
}//END OF ITEMCHANGE
private Timestamp getCurrdateAppFormat()
{
String s = "";
Timestamp timestamp = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
// s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return timestamp;
}
}// END OF MAIN CLASS
\ No newline at end of file
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WorkOrderAmdLocal extends ValidatorLocal//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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;
}
package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException;
import org.w3c.dom.*;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WorkOrderAmdRemote extends ValidatorRemote//, EJBObject
{
public String wfValData() throws RemoteException,ITMException;
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() 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 : TaraniseMeher
Company : Base Information Management Pvt. Ltd
Window Name : w_bom
Date :18/09/2006
Menu Reference:Master-ProductStructure-BillOfMaterial(MFG)
Button:ViewAltBOM,Stock
*/
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import java.util.*;
import java.io.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.ejb.*;
import javax.annotation.*;
import ibase.system.config.*;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class BOMAct extends ActionHandlerEJB implements BOMActLocal , BOMActRemote //SessionBean
{
GenericUtility genericUtility = null;
ConnDriver connDriver = new ConnDriver();
Connection conn = null;
PreparedStatement pstmt = null;
@PostConstruct
public void ejbCreate() //throws RemoteException//, CreateException
{
System.out.println("Create Method Called[BOMActEJB].................");
try
{
conn = connDriver.getConnectDB("DriverITM");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in creating Connection");
}
}
/*public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String actionHandler() throws RemoteException,ITMException
{
System.out.println("actionHandler() Method Called....");
return "";
}
public String actionHandlerTransform(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams, String selDataStr) throws RemoteException,ITMException
{
Document dom = null;
Document dom1 = null;
Document selDataDom = null;
String retString = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = GenericUtility.getInstance().parseString(xmlString);
dom1 = GenericUtility.getInstance().parseString(xmlString1);
if(selDataStr != null && selDataStr.length() > 0)
{
selDataDom = GenericUtility.getInstance().parseString(selDataStr);
}
}
System.out.println("actionType:"+actionType+":");
if (actionType.equalsIgnoreCase("Stock"))
{
retString = stockTransform(dom, dom1, objContext, xtraParams, selDataDom);
}
if (actionType.equalsIgnoreCase("ViewAltBOM"))
{
retString = viewAltBOMTransform(dom, dom1, objContext, xtraParams, selDataDom);
}
}
catch(Exception e)
{
System.out.println("Exception :Dispatch :actionHandlerTransform(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from Despatch : actionHandlerTransform"+retString);
return retString;
}
private String viewAltBOMTransform(Document dom,Document dom1, String objContext, String xtraParams, Document selDataDom)throws ITMException
{
System.out.println("TransFomMation Called**************************************");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
valueXmlString.append("</Root>");
return valueXmlString.toString();
}
private String stockTransform(Document dom,Document dom1, String objContext, String xtraParams, Document selDataDom)throws ITMException
{
System.out.println("TransFomMation Called**************************************");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
valueXmlString.append("</Root>");
return valueXmlString.toString();
}
public String actionHandler(String actionType, String xmlString,String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException
{
System.out.println("AdjIssEJB called");
Document dom = null;
Document dom1 = null;
String resString = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
dom = genericUtility.parseString(xmlString);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
System.out.println("XML String1 :"+xmlString1);
dom1 = genericUtility.parseString(xmlString1);
}
System.out.println("actionType:"+actionType);
if (actionType.equalsIgnoreCase("Stock"))
{
resString = actionStock(dom,dom1,objContext,xtraParams);
}
if (actionType.equalsIgnoreCase("ViewAltBOM"))
{
resString = actionViewAltBOM(dom,dom1,objContext,xtraParams);
}
}
catch(Exception e)
{
System.out.println("Exception :AdjIssEJB :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning from action[Stock] actionHandler"+resString);
return (resString);
}
private String actionViewAltBOM(Document dom,Document dom1, String objContext, String xtraParams) throws RemoteException , ITMException
{
ResultSet rs = null;
String sql = null;
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String bomCode = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
if(conn==null)
{
conn = connDriver.getConnectDB("DriverITM");
}
bomCode = genericUtility.getColumnValue("bom_code",dom1);
if(bomCode!=null)
{
sql = "SELECT ITEM_CODE, ITEM_REF, ITEM_CODE__ALT, QUANTITY, ITEM_CODE_ALT_SEQ "
+ "FROM BOM_ALT "
+ "WHERE BOM_CODE = ?"
+ "ORDER BY ITEM_CODE_ALT_SEQ";
System.out.println("Sql Query::::::"+sql);
System.out.println("Setting Parameter:::"+bomCode);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomCode);
rs = pstmt.executeQuery();
while (rs.next())
{
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(rs.getString(1).trim()).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_ref>").append("<![CDATA[").append(rs.getString(2).trim()).append("]]>").append("</item_ref>\r\n");
valueXmlString.append("<item_code__alt>").append("<![CDATA[").append(rs.getString(3).trim()).append("]]>").append("</item_code__alt>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(rs.getString(4).trim()).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<item_code_alt_seq>").append("<![CDATA[").append(rs.getString(5).trim()).append("]]>").append("</item_code_alt_seq>\r\n");
valueXmlString.append("</Detail>\r\n");
}
}
valueXmlString.append("</Root>\r\n");
}
catch (SQLException se)
{
System.out.println("Exception : BOMActEJB : actionViewAltBOM " +se.getMessage());
se.printStackTrace();
System.out.println("SQL : " + sql);
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception : BOMActEJB : actionViewAltBOM :(Document dom)" +e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
conn.close();
conn = null;
pstmt.close();
}catch(Exception e){}
}
//stem.out.println("valueXmlString.toString() "+valueXmlString.toString());
return valueXmlString.toString();
}
private String actionStock(Document dom,Document dom1, String objContext, String xtraParams) throws RemoteException , ITMException
{
//atement stmt = null;
ResultSet rs = null;
String sql = null;
String bomCode=null;
String trackShelfLife = null;
String itemCode = null;
String reqType = null;
Timestamp currDate =null;
double batchQtyD=0.0;
double batchQty = 0.0;
double qtyPar = 0.0;
double minQty = 0.0;
double reqQty =0.0;
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
try
{
if(conn==null)
{
conn = connDriver.getConnectDB("DriverITM");
}
bomCode = genericUtility.getColumnValue("bom_code",dom);
System.out.println("bomCode From Dom::::::"+bomCode);
batchQtyD= Double.parseDouble(genericUtility.getColumnValue("batch_qty",dom1));
System.out.println("batchQtyD From Dom::::::"+batchQtyD);
sql = "SELECT FN_SYSDATE() FROM DUAL";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
currDate = rs.getTimestamp(1);
}
System.out.println("Current Date::::::"+currDate);
rs.close();
pstmt.close();
if(bomCode!=null)
{
sql = "SELECT BOM.ITEM_CODE, BOM.BOM_CODE,BOMDET.ITEM_CODE,ITEM_A.DESCR,BOMDET.REQ_TYPE,"
+"ITEM_B.DESCR,SUM(BOMDET.MIN_QTY) AS MIN_QTY,SUM(BOMDET.QTY_PER) AS QTY_PER, MAX(BOM.BATCH_QTY) AS BATCH_QTY,"
+"ITEM_B.DESCR,SUM(BOMDET.MIN_QTY) AS MIN_QTY,SUM(BOMDET.QTY_PER) AS QTY_PER, MAX(BOM.BATCH_QTY) BATCH_QTY,"
+"0.0 AS STK_QTY,0.0 AS NON_STK_QTY,0.0 AS REQ_QTY,0.0 AS ALLOC_QTY FROM BOM,BOMDET,ITEM ITEM_A,"
+"ITEM ITEM_B "
+" WHERE ( BOM.BOM_CODE = BOMDET.BOM_CODE ) AND"
+"( BOM.ITEM_CODE = ITEM_A.ITEM_CODE ) AND"
+"( BOMDET.ITEM_CODE= ITEM_B.ITEM_CODE ) AND"
+"( ( BOM.BOM_CODE = ?) )"
+"GROUP BY BOM.BOM_CODE,BOM.ITEM_CODE,BOMDET.ITEM_CODE,BOMDET.REQ_TYPE,ITEM_A.DESCR,ITEM_B.DESCR" ;
System.out.println("MainQuery:::"+sql);
pstmt = conn.prepareStatement(sql);
System.out.println("Setting BomCode as "+bomCode);
pstmt.setString(1,bomCode);
rs = pstmt.executeQuery();
while (rs.next())
{
valueXmlString.append("<Detail>\r\n");
itemCode = rs.getString(3);//BOM.ITEM_CODE
reqType = rs.getString(5);//BOMDET.REQ_TYPE
minQty = rs.getDouble(7);//MIN_QTY
qtyPar = rs.getDouble(8);//QTY_PER;
batchQty = rs.getDouble(9);//BATCH_QTY;
valueXmlString.append("<bom_code>").append("<![CDATA[").append(rs.getString(2).trim()).append("]]>").append("</bom_code>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(rs.getString(3).trim()).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<descr>").append("<![CDATA[").append(rs.getString(6).trim()).append("]]>").append("</descr>\r\n");
if(reqType.equalsIgnoreCase("s"))
{
reqQty = (batchQtyD / batchQty) * qtyPar;
}
else if(reqType.equalsIgnoreCase("P"))
{
reqQty = (qtyPar / batchQty) * batchQtyD;
}
else//f
{
reqQty = qtyPar;
}
if (reqQty < minQty)
{
reqQty = minQty;
}
valueXmlString.append("<quantity>").append("<![CDATA[").append(reqQty).append("]]>").append("</quantity>\r\n");
pstmt = null;
pstmt = conn.prepareStatement("select nvl(track_shelf_life,'N') from item where item_code = ?") ;
pstmt.setString(1,itemCode);
ResultSet rs1 = pstmt.executeQuery();
if(rs1.next())
{
trackShelfLife = rs1.getString(1);
}
rs1.close();
StringBuffer sb = new StringBuffer();
sb.append(" select nvl(sum(a.quantity - a.alloc_qty),0), nvl(sum(a.alloc_qty),0) from stock a, invstat b "
+" where a.inv_stat = b.inv_stat and a.item_code = ? and b.available = 'Y' and b.stat_type <> 'S' and (a.quantity - nvl(a.alloc_qty,0)) > 0 " );
if(trackShelfLife.equalsIgnoreCase("Y"))
{
sb.append("and ( a.exp_date is null or a.exp_date >?)");
}
pstmt = conn.prepareStatement(sb.toString());
pstmt.setString(1,itemCode);
if(trackShelfLife.equalsIgnoreCase("Y"))
{
pstmt.setTimestamp(2,currDate);
}
rs1 = pstmt.executeQuery();
while(rs1.next())
{
valueXmlString.append("<stock>").append("<![CDATA[").append(rs1.getDouble(1)).append("]]>").append("</stock>\r\n");
valueXmlString.append("<allock_qty>").append("<![CDATA[").append(rs1.getString(2).trim()).append("]]>").append("</allock_qty>\r\n");
}
valueXmlString.append("</Detail>\r\n");
}
}
valueXmlString.append("</Root>\r\n");
}
catch (SQLException se)
{
System.out.println("Exception : BOMActEJB : actionStock " +se.getMessage());
se.printStackTrace();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception : BOMActEJB : actionStock :(Document dom)" +e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
conn.close();
conn = null;
pstmt.close();
}catch(Exception e){}
}
System.out.println("valueXmlString.toString() "+valueXmlString.toString());
return valueXmlString.toString();
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface BOMActLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface BOMActRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/* Developed by : TaraniseMeher
Company : Base Information Management Pvt. Ltd
Window Name : w_bom_alt
Date :18/09/2006
Menu Reference:Master-ProductStructure-BillOfMaterial(MFG)
Button:Confirm */
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import java.util.*;
import java.io.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.ejb.*;
import javax.annotation.*;
import ibase.system.config.*;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class BOMAltConf extends ActionHandlerEJB implements BOMAltConfLocal , BOMAltConfRemote //SessionBean
{
GenericUtility genericUtility = null;
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
Connection conn = null;
PreparedStatement pstmt = null;
@PostConstruct
public void ejbCreate() //throws RemoteException //, CreateException
{
System.out.println("Create Method Called....");
System.out.println("Create Method Called[BOMAltConfEJB].................");
try
{
conn = connDriver.getConnectDB("DriverITM");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in creating Connection");
}
}
/*public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String actionHandler() throws RemoteException,ITMException
{
System.out.println("actionHandler() Method Called....");
return "";
}
public String actionHandler(String xmlString, String xtraParams, String objContext) throws RemoteException,ITMException
{
Document dom = null;
String retString = null;
System.out.println("Xtra Params : " + xtraParams);
genericUtility = GenericUtility.getInstance();
try
{
retString = ConfirmAltBOM(xmlString, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception :Enquiry :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning from actionPickList actionHandler"+retString);
return (retString);
}
private String ConfirmAltBOM(String tranId, String xtraParams) throws RemoteException , ITMException
{
System.out.println("DeactivateBOM String.......");
String loginEmpCode = "";
String chgUser = null;
String chgTerm = null;
String retString = "";
String active = null;
String sql = null;
int count = 0;
String itemCode = null;
String itemref = null;
String itemCodeAlt = null;
String bomCode = null;
String userId = null;
String confirm = null;
java.sql.Timestamp today = null;
ResultSet rs = null;
try
{
if(conn==null)
{
conn = connDriver.getConnectDB("DriverITM");
}
System.out.println("xtraParams : " + xtraParams);
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
System.out.println("loginEmpCode::::::::"+loginEmpCode);
System.out.println("chgUser::::::::"+chgUser);
if(loginEmpCode == null || loginEmpCode.trim().length()>0)
{
retString = itmDBAccess.getErrorString("","VMEMPORD2","","",conn);
}
System.out.println("TradId::::::::::::::::::::::::::::"+tranId);
String[] token = tranId.split(":");
itemCode = token[0];
itemref = token[1];
itemCodeAlt = token[2];
bomCode = token[3];
System.out.println("itemCode:::"+itemCode);
System.out.println("itemref:::"+itemref);
System.out.println("itemCodeAlt:::"+itemCodeAlt);
System.out.println("bomCode:::"+bomCode);
sql ="SELECT CASE WHEN CONFIRMED IS NULL THEN 'N' ELSE CONFIRMED END "
+" FROM BOM_ALT WHERE BOM_CODE = ? AND ITEM_CODE = ? AND ITEM_REF = ? AND ITEM_CODE__ALT = ?";
System.out.println("Executing Query:::"+sql);
System.out.println("Setting Parameters :::["+bomCode+"] ["+itemCode+"] ["+itemref+"] ["+itemCodeAlt+"]");
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,bomCode);
pstmt.setString(2,itemCode);
pstmt.setString(3,itemref);
pstmt.setString(4,itemCodeAlt);
rs = pstmt.executeQuery();
if(rs.next())
{
confirm = rs.getString(1);
}
rs.close();
System.out.println("Confirm Status:::["+confirm+"]");
if(confirm==null)confirm=" ";
if(confirm.equalsIgnoreCase("Y"))
{
retString = itmDBAccess.getErrorString("", "VTMCONF1", userId);
}
else
{
sql = "UPDATE BOM_ALT SET CONFIRMED ='Y', CONF_DATE = ? WHERE BOM_CODE = ? AND ITEM_CODE = ? AND "
+"ITEM_REF = ? AND ITEM_CODE__ALT = ?" ;
System.out.println("Executing Query:::"+sql);
System.out.println("Setting Parameters :::["+bomCode+"] ["+itemCode+"] ["+itemref+"] ["+itemCodeAlt+"]");
pstmt=conn.prepareStatement(sql);
pstmt.setTimestamp(1,new Timestamp(System.currentTimeMillis()));
pstmt.setString(2,bomCode);
pstmt.setString(3,itemCode);
pstmt.setString(4,itemref);
pstmt.setString(5,itemCodeAlt);
int update = pstmt.executeUpdate();
System.out.println("No Of Record Update:::::"+update);
if(update<=0)
{
retString = itmDBAccess.getErrorString("", "DS0001", userId);
}
else
{
retString = itmDBAccess.getErrorString("","VTMCONF2","","",conn);
}
}
}
catch (SQLException se)
{
System.out.println("Exception : BOMDeactivateEJB : DeactivateBOM " +se.getMessage());
se.printStackTrace();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception : BOMDeactivateEJB : DeactivateBOM :" +e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
conn.close();
conn = null;
pstmt.close();
}
catch(Exception e){}
}
return retString;
}
}//end of ejb
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface BOMAltConfLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface BOMAltConfRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/* Developed by : TaraniseMeher
Company : Base Information Management Pvt. Ltd
Window Name : w_bom
Date :18/09/2006
Menu Reference:Master-ProductStructure-BillOfMaterial(MFG)
Button:Deactivate */
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import java.util.*;
import java.io.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import javax.annotation.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.ejb.*;
import ibase.system.config.*;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class BOMDeactivate extends ActionHandlerEJB implements BOMDeactivateLocal , BOMDeactivateRemote //SessionBean
{
GenericUtility genericUtility = null;
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
Connection conn = null;
PreparedStatement pstmt = null;
@PostConstruct
public void ejbCreate() //throws RemoteException //, CreateException
{
System.out.println("Create Method Called....");
System.out.println("Create Method Called[BOMDeactivateEJB].................");
try
{
conn = connDriver.getConnectDB("DriverITM");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in creating Connection");
}
}
/*public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String actionHandler() throws RemoteException,ITMException
{
System.out.println("actionHandler() Method Called....");
return "";
}
public String actionHandler(String xmlString, String xtraParams, String objContext) throws RemoteException,ITMException
{
Document dom = null;
String retString = null;
System.out.println("Xtra Params : " + xtraParams);
genericUtility = GenericUtility.getInstance();
try
{
retString = DeactivateBOM(xmlString, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception :Enquiry :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning from actionPickList actionHandler"+retString);
return (retString);
}
private String DeactivateBOM(String bomCode, String xtraParams) throws RemoteException , ITMException
{
System.out.println("DeactivateBOM String.......");
String loginEmpCode = "";
String chgUser = "";
String chgTerm = "";
String retString = "";
String active = "";
String sql = "";
int count = 0;
java.sql.Timestamp today = null;
ResultSet rs = null;
try
{
if(conn==null)
{
conn = connDriver.getConnectDB("DriverITM");
}
System.out.println("xtraParams : " + xtraParams);
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("loginEmpCode::::::::"+loginEmpCode);
System.out.println("chgUser::::::::"+chgUser);
if(loginEmpCode == null || loginEmpCode.trim().length()>0)
{
retString = itmDBAccessEJB.getErrorString("","VMEMPORD2","","",conn);
}
if(bomCode!=null)
{
sql = "SELECT ACTIVE FROM BOM WHERE BOM_CODE = ?";
System.out.println("Setting Parmeter:::"+bomCode);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomCode);
rs = pstmt.executeQuery();
if (rs.next())
{
active = (rs.getString(1)==null?" ":rs.getString(1));
}
System.out.println("Bom Code : " + bomCode + " Active : [" + active + "]");
rs.close();
pstmt.close();
if(active.trim().equalsIgnoreCase("N"))
{
System.out.println("Active : " + active);
retString = itmDBAccessEJB.getErrorString("","VTBOMACT1",chgUser);
System.out.println("retString : " + retString);
return retString;
}
today = new java.sql.Timestamp(System.currentTimeMillis());
sql = "UPDATE BOM SET ACTIVE = 'N',CHG_USER = ?, CHG_DATE = ?, CHG_TERM = ?"
+ " WHERE BOM_CODE = '" + bomCode + "'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,chgUser);
pstmt.setTimestamp(2,today);
pstmt.setString(3,chgUser);
int rowsUpdated = pstmt.executeUpdate();
pstmt.close();
System.out.println("No of Rows Updated in BOM : [" + rowsUpdated +"]");
if(rowsUpdated > 0 )
{
conn.commit();
retString = itmDBAccessEJB.getErrorString("","VTBOMACT2",chgUser);
}
else
{
conn.rollback();
itmDBAccessEJB.getErrorString("","VTBOMACT1",chgUser);
}
}
}
catch (SQLException se)
{
System.out.println("Exception : BOMDeactivateEJB : DeactivateBOM " +se.getMessage());
se.printStackTrace();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception : BOMDeactivateEJB : DeactivateBOM :" +e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
conn.close();
conn = null;
pstmt.close();
}catch(Exception e){}
}
return retString;
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface BOMDeactivateLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface BOMDeactivateRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.rmi.RemoteException;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
//import javax.ejb.SessionBean;
import ibase.system.config.ConnDriver;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerEJB;
import org.w3c.dom.Document;
import ibase.webitm.ejb.ITMDBAccessEJB;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class BatchsizeAprvConf extends ActionHandlerEJB implements BatchsizeAprvConfLocal , BatchsizeAprvConfRemote //SessionBean
{
/* public void ejbCreate() throws RemoteException,CreateException{
}
public void ejbRemove(){
}
public void ejbActivate(){
}
public void ejbPassivate(){
}*/
public void setSessionContext(SessionContext se){
}
public String confirm( String tranId,String xtraParams, String forcedFlag ) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
ConnDriver connDriver = null;
String loginEmpCode = null;
ibase.webitm.utility.GenericUtility genericUtility = null;
Document dom = null;
int count=0;
ITMDBAccessEJB itmDBAccessEJB = null;
String errString = null;
int upd = 0;
try
{
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = ibase.webitm.utility.GenericUtility.getInstance();
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
int countDet = 0;
if( errString == null || errString.trim().length() == 0 )
{
sql = " select count( 1 ) cnt from batchsize_aprv where tran_id = '" + tranId.trim() + "' AND CONFIRMED = 'Y' ";
pstmt = conn.prepareStatement( sql );
rs = pstmt.executeQuery();
if( rs.next() )
{
countDet = rs.getInt( "cnt" );
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if( countDet > 0 )
{
errString = itmDBAccessEJB.getErrorString("","VTCONFMD","","",conn);
}
}
if( errString == null || errString.trim().length() == 0 )
{
sql = "update batchsize_aprv set conf_date = ? ,emp_code__aprv = ? ,confirmed = 'Y' where tran_id = '" + tranId.trim() + "'";
pstmt = conn.prepareStatement( sql );
pstmt.setTimestamp( 1, new java.sql.Timestamp( System.currentTimeMillis() ) );
pstmt.setString( 2,loginEmpCode );
pstmt.executeUpdate();
pstmt.close();
pstmt = null;
}
if( errString != null && errString.trim().length() > 0 )
{
System.out.println("Returning Result "+errString);
conn.rollback();
return errString;
}
else
{
conn.commit();
errString = itmDBAccessEJB.getErrorString("","VTCNFSUCC","");
System.out.println("Returnng String From BatchsizeAprvConfEJB : .." + errString);
}
System.out.println("errString : "+errString);
}catch(ITMException ie)
{
System.out.println("ITMException : "+ie);
try{
conn.rollback();
}catch(Exception t){}
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From BatchsizeAprvConfEJB :"+errString);
return errString;
}catch(Exception e){
System.out.println("Returnng String From BatchsizeAprvConfEJB :"+e);
try{
conn.rollback();
}catch(Exception t){}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From BatchsizeAprvConfEJB :"+errString);
return errString;
}
finally
{
try{
if( pstmt != null )
{
pstmt.close();
}
pstmt = null;
if(conn != null)
{
conn.close();
}
conn = null;
}catch(Exception e){System.out.println("Exception : "+e);e.printStackTrace();}
}
System.out.println("BatchsizeAprvConfEJB :"+errString);
return errString;
}
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface BatchsizeAprvConfLocal extends ActionHandlerLocal//,EJBObject
{
public String confirm(String xmlString, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface BatchsizeAprvConfRemote extends ActionHandlerRemote//, EJBObject
{
public String confirm(String xmlString, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
/* Developed by : TaraniseMeher
Company : Base Information Management Pvt. Ltd
Window Name : w_work_calender
Date :21/09/2006
Menu Reference:Master-manufacturingWorkCalender-work center wisework calender(MFG)
Button:Confirm */
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import java.util.*;
import java.io.*;
import java.util.Date;
import java.sql.*;
import org.w3c.dom.*;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import javax.annotation.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.ejb.*;
import ibase.system.config.*;
import java.text.SimpleDateFormat;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class CWWorkCalConf extends ActionHandlerEJB implements CWWorkCalConfLocal , CWWorkCalConfRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
Connection conn = null;
PreparedStatement pstmt = null;
@PostConstruct
public void ejbCreate() //throws RemoteException //, CreateException
{
System.out.println("Create Method Called....");
System.out.println("Create Method Called[BOMAltConfEJB].................");
try
{
conn = connDriver.getConnectDB("DriverITM");
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Exception in creating Connection");
}
}
/*public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String actionHandler() throws RemoteException,ITMException
{
System.out.println("actionHandler() Method Called....");
return "";
}
public String actionHandler(String xmlString, String xtraParams, String objContext) throws RemoteException,ITMException
{
Document dom = null;
String retString = null;
System.out.println("Xtra Params : " + xtraParams);
genericUtility = GenericUtility.getInstance();
try
{
retString = ConfirmWorkCal(xmlString, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception :Enquiry :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning from actionPickList actionHandler"+retString);
return (retString);
}
private String ConfirmWorkCal(String tranId, String xtraParams) throws RemoteException , ITMException
{
System.out.println("DeactivateBOM String.......");
String loginEmpCode = "";
String chgUser = null;
String chgTerm = null;
String retString = "";
String active = null;
String sql = null;
int count = 0;
String siteCode = null;
String workDate = null;
String dayNo = null;
String shift = null;
String workCtr = null;
String userId = null;
String confirm = null;
java.sql.Timestamp today = null;
java.sql.Timestamp workDateTs = null;
ResultSet rs = null;
try
{
if(conn==null)
{
conn = connDriver.getConnectDB("DriverITM");
}
System.out.println("xtraParams : " + xtraParams);
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId");
System.out.println("loginEmpCode::::::::"+loginEmpCode);
System.out.println("chgUser::::::::"+chgUser);
if(loginEmpCode == null || loginEmpCode.trim().length()>0)
{
retString = itmDBAccess.getErrorString("","VMEMPORD2","","",conn);
}
System.out.println("TradId::::::::::::::::::::::::::::"+tranId);
String[] token = tranId.split(":");
workDate = token[0];
dayNo = token[1];
shift = token[2];
siteCode = token[3];
workCtr = token[4];
System.out.println("siteCode:::"+siteCode);
System.out.println("workDate:::"+workDate);
System.out.println("dayNo:::"+dayNo);
System.out.println("shift:::"+shift);
System.out.println("workCtr:::"+workCtr);
System.out.println("genericUtility.getApplDateFormat:::"+genericUtility.getApplDateFormat());
System.out.println("genericUtility.getDBDateFormat:::"+genericUtility.getDBDateFormat());
//converting date
try
{
Object date = null;
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(genericUtility.getApplDateFormat());
date = sdf.parse(workDate);
java.text.SimpleDateFormat sdf1 = new java.text.SimpleDateFormat(genericUtility.getDBDateFormat());
String dateStr = sdf1.format(date).toString();
workDateTs = java.sql.Timestamp.valueOf(dateStr+" 00:00:00");
}
catch(Exception e)
{
e.printStackTrace();
}
sql ="SELECT NVL(CONFIRMED,'N') FROM WORK_CALENDAR "
+" WHERE SITE_CODE = ? AND WORK_DATE = ? AND DAY_NO =? AND SHIFT = ? AND WORK_CTR= ?";
System.out.println("Executing Query:::"+sql);
System.out.println("Setting Parameters :::["+siteCode+"] ["+workDateTs+"] ["+dayNo+"] ["+shift+"] ["+workCtr+"]");
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setTimestamp(2,workDateTs);
pstmt.setString(3,dayNo);
pstmt.setString(4,shift);
pstmt.setString(5,workCtr);
rs = pstmt.executeQuery();
if(rs.next())
{
confirm = rs.getString(1);
}
rs.close();
System.out.println("Confirm Status:::["+confirm+"]");
if(confirm==null)confirm=" ";
if(confirm.equalsIgnoreCase("Y"))
{
retString = itmDBAccess.getErrorString("", "VTMCONF1", userId);
}
else
{
sql = "UPDATE WORK_CALENDAR SET CONFIRMED = 'Y' WHERE SITE_CODE = ? AND "
+"WORK_DATE = ? AND DAY_NO = ? AND SHIFT = ? AND WORK_CTR = ?";
System.out.println("Executing Query:::"+sql);
System.out.println("Setting Parameters :::["+siteCode+"] ["+workDateTs+"] ["+dayNo+"] ["+shift+"] ["+workCtr+"]");
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setTimestamp(2,workDateTs);
pstmt.setString(3,dayNo);
pstmt.setString(4,shift);
pstmt.setString(5,workCtr);
int update = pstmt.executeUpdate();
System.out.println("No Of Record Update:::::"+update);
if(update<=0)
{
retString = itmDBAccess.getErrorString("", "DS0001", userId);
}
else
{
retString = itmDBAccess.getErrorString("","VTMCONF2","","",conn);
}
}
}
catch (SQLException se)
{
System.out.println("Exception : BOMDeactivateEJB : DeactivateBOM " +se.getMessage());
se.printStackTrace();
throw new ITMException(se);
}
catch(Exception e)
{
System.out.println("Exception : BOMDeactivateEJB : DeactivateBOM :" +e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try{
conn.close();
conn = null;
pstmt.close();
}
catch(Exception e){}
}
return retString;
}
}//end of ejb
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface CWWorkCalConfLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface CWWorkCalConfRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import ibase.webitm.utility.*;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.*;
import ibase.system.config.*;
import java.rmi.RemoteException;
import java.util.*;
import java.text.*;
import java.sql.*;
import javax.ejb.*;
import java.util.Calendar;
import java.util.Date;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.webitm.ejb.MasterStatefulEJB;
//import ibase.webitm.ejb.MasterStatefulHome;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class ConfirmWOAmendment extends ActionHandlerEJB implements ConfirmWOAmendmentLocal , ConfirmWOAmendmentRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
String errorString = null;
/*public void ejbCreate() throws RemoteException, CreateException
{
System.out.println("Create Method Called....");
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String actionHandler() throws RemoteException,ITMException
{
System.out.println("actionHandler() Method Called....");
return "";
}
public String actionHandler(String xmlString, String xtraParams, String objContext) throws RemoteException,ITMException
{
String retString = null;
System.out.println("Xtra Params : " + xtraParams);
//genericUtility = GenericUtility.getInstance();
try
{
retString = actionConfirm(xmlString, xtraParams);
}
catch(Exception e)
{
System.out.println("Exception :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning from actionHandler"+retString);
return (retString);
}
private String actionConfirm(String tranID, String xtraParams) throws RemoteException,ITMException, Exception
{
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
String userId ="",loginSite ="",empCode="";
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
empCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
System.out.println("empCode.......... !"+empCode);
String sql = "";
String retString = "";
int count =0,i=0,upd=0;
System.out.println("tranID ...."+tranID );
ArrayList arrayList =new ArrayList();
ArrayList itemList =new ArrayList();
ArrayList arrayListItem =new ArrayList();
HashMap hm =new HashMap();
HashMap currentMap =new HashMap();
HashMap itemLiscontracmap =new HashMap();
String lsConf = "Y",confirmed = "";
java.sql.Timestamp currDate = null;
String itemCode ="",siteCode ="",unit ="",phyAttrib1="",phyAttrib2 ="",phyAttrib3 ="",phyAttrib4 ="",phyAttrib5 ="",phyAttrib6 ="";
String suppSour="",itemCodenew="",returnString="",item_type="",item_ser="",tranIdRef = "";
String contract="",errorCode ="",noOfHour = "",empCodeAmd = "",projCode = "";
double quantity =0;
Timestamp mfgDateStart = null,expDate = null,planDueDate = null;
Timestamp mfgDateStartOld = null,expDateOld = null,planDueDateOld = null;
try
{
System.out.println("In new workorder amd >>>>>>>>>>>>>> ");
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
sql = "select mfg_date__start mfg_date,exp_date,plan__due_date plan_date,"
+ " site_code,work_order__ref work_order_ref,confirmed"
+ " from worder_amd "
+ " where tran_id = '"+tranID+"'";
System.out.println("select sql from worder_amd>>>>>>>>>>>>>> " + sql);
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mfgDateStart = rs.getTimestamp("mfg_date");
expDate = rs.getTimestamp("exp_date");
planDueDate = rs.getTimestamp("plan_date");
siteCode = rs.getString("site_code") == null ? "" : rs.getString("site_code");
tranIdRef = rs.getString("work_order_ref") == null ? "" : rs.getString("work_order_ref");
confirmed = rs.getString("confirmed") == null ? "" : rs.getString("confirmed");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
// changed by pankaj on 17.02.09 to update old date when new is null
sql = "select mfg_date__start mfg_date,exp_date,plan_due_date plan_date"
+ " from workorder where work_order = '" + tranIdRef + "'";
System.out.println("select sql from worder_amd>>>>>>>>>>>>>> " + sql);
pstmt= conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
mfgDateStartOld = rs.getTimestamp("mfg_date");
expDateOld = rs.getTimestamp("exp_date");
planDueDateOld = rs.getTimestamp("plan_date");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if( !confirmed.equalsIgnoreCase("Y"))
{
sql = " Update workorder set "
+ " mfg_date__start =?,"
+ " exp_date = ?,"
+ " site_code = '" + siteCode +"',"
+ " plan_due_date = ?"
+ " where tran_id = '" + tranIdRef + "'" ;
System.out.println("sql workorder>>>>>> ....."+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, mfgDateStart = mfgDateStart == null ? mfgDateStartOld : mfgDateStart );
pstmt.setTimestamp(2, expDate = expDate == null ? expDateOld : expDate);
pstmt.setTimestamp(3, planDueDate = planDueDate == null ? planDueDateOld : planDueDate);
System.out.println("seting mfgDateStart>>>>>> ....."+mfgDateStart);
System.out.println("seting expDate>>>>>> ....."+expDate);
System.out.println("seting planDueDate>>>>>> ....."+planDueDate);
pstmt.executeUpdate();
sql = " Update worder_amd set "
+ " confirmed = 'Y',"
+ " conf_date = ? ,"
+ " emp_code__aprv = '" + empCode + "'"
+ " where tran_id = '" + tranID + "'" ;
System.out.println("sql to update worder_amd>>....."+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, getCurrdateAppFormat() );
pstmt.executeUpdate();
returnString = itmDBAccessEJB.getErrorString("","VTWOASC",userId);
// end changed by pankaj on 17.02.09 to update old date when new is null
//returnString = returnString.substring(0,returnString.indexOf("Amended") ) + " for tran_id = " + tranID + returnString.substring(returnString.indexOf("</description>") );
System.out.println("new returnString changed....."+returnString);
}
else
{
returnString = itmDBAccessEJB.getErrorString("","VTWODASC",userId);
}
}
catch(Exception e)
{
System.out.println("ConfirmWOAmendmentEJB..."+e.getMessage());
e.printStackTrace();
try
{
conn.rollback();
}
catch(Exception e1)
{
System.out.println("ConfirmWOAmendmentEJB..."+e1.getMessage());
e1.printStackTrace();
}
}
finally
{
try
{
conn.commit();
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
if(conn != null)
{
conn.close();
conn = null;
}
}
catch(Exception e)
{
System.out.println("Exception ConfirmWOAmendmentEJB....... :\n"+e.getMessage());
}
}
System.out.println("retString ::"+returnString);
return returnString;
}
private Timestamp getCurrdateAppFormat()
{
String s = "";
Timestamp timestamp = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
java.util.Date date = null;
timestamp = new Timestamp(System.currentTimeMillis());
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat simpledateformat = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = simpledateformat.parse(timestamp.toString());
timestamp = Timestamp.valueOf(simpledateformat.format(date).toString() + " 00:00:00.0");
// s = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(timestamp).toString();
}
catch(Exception exception)
{
System.out.println("Exception in getCurrdateAppFormat " + exception.getMessage());
}
return timestamp;
}
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface ConfirmWOAmendmentLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String xtraParams, String objContext) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface ConfirmWOAmendmentRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String xmlString, String xtraParams, String objContext) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
import java.util.*;
import java.sql.*;
import java.text.SimpleDateFormat;
import org.w3c.dom.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.system.config.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class DefaultQcTab extends ActionHandlerEJB implements DefaultQcTabLocal , DefaultQcTabRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException {}
public void ejbRemove(){}
public void ejbActivate(){}
public void ejbPassivate(){}*/
public String actionHandler() throws RemoteException,ITMException{return "";}
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException
{
String retString = "";
Document dom = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
dom = genericUtility.parseString(xmlString);
}
}
catch(Exception e)
{
System.out.println("Exception :DefaultQcTabEJB :actionHandler(String xmlString):" + e.getMessage() + ":");
throw new ITMException(e);
}
return retString;
}
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException
{
Connection conn=null;
GenericUtility genericUtility = GenericUtility.getInstance();
Document dom = null;
Document dom1 = null;
String retString = null;
try
{
System.out.println("XML String1:::"+xmlString1);
System.out.println("XML String:::"+xmlString);
System.out.println("Default function executing in progress...................");
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String:::"+xmlString);
dom = GenericUtility.getInstance().parseString(xmlString);
System.out.println("dom :"+dom);
}
if(xmlString1 != null && xmlString1.trim().length()!=0)
{
System.out.println("XML String1:::"+xmlString1);
dom1 = GenericUtility.getInstance().parseString(xmlString1);
System.out.println("dom1 :"+dom1);
}
System.out.println("actionType:::["+actionType+"]");
if (actionType.equalsIgnoreCase("Default"))
{
try
{
if(conn==null)
{
System.out.println("Getting Connection From Database......");
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
System.out.println("Connection Established......");
DatabaseMetaData dbmd = conn.getMetaData();
System.out.println("DriverName["+dbmd.getDriverName() );
System.out.println("DriverURI["+dbmd.getURL() );
System.out.println("DriverUSER["+dbmd.getUserName());
//System.out.println("ApplDateFormat["+genericUtility. ());
System.out.println("DBDateFormat["+genericUtility.getDBDateFormat() );
connDriver = null;
}
}
catch (Exception e)
{
e.printStackTrace();
}
retString = actionDefault(dom, dom1, objContext, xtraParams);
}
}
catch(Exception e)
{
System.out.println("Exception :Dispatch :actionHandler(String xmlString):" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from DefaultQcTabdEJB : actionHandler"+retString);
return retString;
}
private String actionDefault(Document dom, Document dom1, String objContext, String xtraParams) throws RemoteException, ITMException
{
System.out.println("Calling the Default function.........");
GenericUtility genericUtility = GenericUtility.getInstance();
Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null , pstmtSpec = null ;
ResultSet rs = null,rs1 = null,rsSpec = null;
StringBuffer valueXmlString = null;
valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
int currentFormNo = 0;
String sql1 = "";
String qcTableNo = "";
String tableDescr = "" ;
Timestamp exprDate = null;
Timestamp chgDate = null;
String chgUser = "";
String chgTerm = "";
int lineNo = 0 ;
String specCode = "";
String expctedRes = "";
String sqlSpec = "";
String descr = "";
try
{
String detCnt = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"detCnt");
System.out.println("detCnt ...... :"+detCnt);
if(conn==null)
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
connDriver=null;
}
if(objContext != null && objContext.trim().length()>0)
{
currentFormNo = Integer.parseInt(objContext);
}
System.out.println("[] :currentFormNo ....." +currentFormNo);
if (dom1 != null)
{
qcTableNo = genericUtility.getColumnValue("qc_tableno",dom1);
qcTableNo = qcTableNo == null ? "" :qcTableNo.trim();
}
System.out.println("qcTableNo>>>>>>>"+qcTableNo);
sql1 = "SELECT b.QC_TABLENO ,b.LINE_NO , b.SPEC_CODE , b.EXPECTED_RESULT FROM QC_TABLES a, QC_TABLEDET b where a.QC_TABLENO = b.QC_TABLENO and b.QC_TABLENO = '"+qcTableNo+"' ";
System.out.println("sql1 is :"+sql1);
pstmt = conn.prepareStatement(sql1);
rs = pstmt.executeQuery();
while (rs.next())
{
qcTableNo = rs.getString(1) == null ? "" :rs.getString(1);
lineNo = rs.getInt(2);
specCode = rs.getString(3) == null ? "" :rs.getString(3);
expctedRes = rs.getString(4) == null ? "" :rs.getString(4);
sqlSpec = "SELECT SPEC_DESCR FROM QLTY_SPECS WHERE SPEC_CODE ='"+specCode.trim()+"' " ;
pstmtSpec = conn.prepareStatement(sqlSpec);
rsSpec = pstmtSpec.executeQuery();
if(rsSpec.next())
{
descr = rsSpec.getString(1) == null ? "" :rsSpec.getString(1);
}
rsSpec.close();
rsSpec = null;
pstmtSpec.close();
pstmtSpec = null;
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<qc_tableno>").append("<![CDATA[").append(qcTableNo.trim()).append("]]>").append("</qc_tableno>\r\n");
valueXmlString.append("<line_no>").append("<![CDATA[").append(lineNo).append("]]>").append("</line_no>\r\n");
valueXmlString.append("<spec_code>").append("<![CDATA[").append(specCode).append("]]>").append("</spec_code>\r\n");
valueXmlString.append("<qlty_specs_spec_descr>").append("<![CDATA[").append(descr).append("]]>").append("</qlty_specs_spec_descr>\r\n");
valueXmlString.append("<expected_result>").append("<![CDATA[").append(expctedRes).append("]]>").append("</expected_result>\r\n");
valueXmlString.append("</Detail>\r\n");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
valueXmlString.append("</Root>\r\n");
}//tryBase1 greyd
catch(SQLException sqx)
{
System.out.println("The Exception caught from DefaultQcTabEJB :"+sqx);
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The Exception caught from DefaultQcTabEJB :"+e);
throw new ITMException(e);
}
finally
{
try
{
conn.close();
conn = null;
}catch(Exception e){}
}
System.out.println("valueXmlString.toString() :"+valueXmlString.toString());
return valueXmlString.toString();
}
}//end of Ejb
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface DefaultQcTabLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface DefaultQcTabRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String objContext, String xtraParams) throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
/**
* Developed by Alka Shah -> 28/03/07
*/
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.mfg.ExplodeBom;
import ibase.webitm.ejb.mfg.MfgCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.sql.Types;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import javax.ejb.CreateException;
//import javax.ejb.SessionBean;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcpBackflushMultiAct extends ActionHandlerEJB implements RcpBackflushMultiActLocal , RcpBackflushMultiActRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException, CreateException {
}
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}*/
public String actionHandler() throws RemoteException, ITMException {
return "";
}
public String actionHandler(String actionType, String xmlString,
String xmlString1, String objContext, String xtraParams)
throws RemoteException, ITMException {
Document dom = null;
Document dom1 = null;
String retString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try {
if (xmlString != null && xmlString.trim().length() != 0) {
System.out.println("XML String :" + xmlString);
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
System.out.println("XML String1 :" + xmlString1);
dom1 = genericUtility.parseString(xmlString1);
}
System.out.println("actionType:" + actionType + ":");
if (actionType.equalsIgnoreCase("Stock")) {
retString = actionStock(dom, dom1, xtraParams);
}
} catch (Exception e) {
System.out
.println("Exception :RcpBackflushMultiActEJB :actionHandler(String xmlString):"
+ e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out
.println("returning String from RcpBackflushMultiActEJB : actionHandler"
+ retString);
return retString;
}
public String actionHandlerTransform(String actionType, String xmlString,
String xmlString1, String objContext, String xtraParams,
String selDataStr) throws RemoteException, ITMException {
System.out.println("actionHandlerTransform is calling.............");
Document dom = null;
Document dom1 = null;
Document selDataDom = null;
String retString = null;
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = GenericUtility.getInstance().parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
dom1 = GenericUtility.getInstance().parseString(xmlString1);
}
if (selDataStr != null && selDataStr.length() > 0) {
selDataDom = GenericUtility.getInstance().parseString(
selDataStr);
}
System.out.println("actionType:" + actionType + ":");
if (actionType.equalsIgnoreCase("Stock")) {
retString = stockTransform(dom, dom1, objContext, xtraParams,
selDataDom);
}
} catch (Exception e) {
System.out
.println("Exception :RcpBackflushMultiActEJB :actionHandlerTransform(String xmlString):"
+ e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out
.println("returning String from RcpBackflushMultiActEJB : actionHandlerTransform"
+ retString);
return retString;
}
private String actionStock(Document dom, Document dom1, String xtraParams) throws RemoteException, ITMException
{
String available = null, backflushType = null, trackShelfLife = null;
String siteCode = null, itemCode = null, qcReqd = null;
String sql = null;
String expDate1 = "", retestDate1 = "",mfgDate1 = "";//updated by nisar on 11/08/07
//CHANGES DONE BY ALKA 31/07/07 FOR DATE PARSING ERROR AND AVAILABLE QUANTITY TO BE DISPLAYED
// Timestamp retestDt = null;
String retestDt = "";
String iDescr = "";//added by nisar on 26/09/07
// java.sql.Date expDate = null, retestDate = null,mfgDate = null;
double totalQty = 0, allocQty = 0;
// CHANGES DONE ENDED BY ALKA 31/07/07 FOR DATE PARSING ERROR AND AVAILABLE QUANTITY TO BE DISPLAYED
Timestamp expDate = null, retestDate = null, mfgDate = null;
PreparedStatement pstmt = null;
ResultSet rs = 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();
}
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
try {
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
// available = "Y"; //CHANGED BY ALKA 31/07/07 AS INSTR FUNCTION REPLACED BY IN();
available = "('Y')";
siteCode = genericUtility.getColumnValue("site_code", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
backflushType = genericUtility.getColumnValue("backflush_type", dom1);
sql = "SELECT (CASE WHEN QC_REQD IS NULL THEN 'N' ELSE QC_REQD END), "
+ " (CASE WHEN TRACK_SHELF_LIFE IS NULL THEN 'N' ELSE TRACK_SHELF_LIFE END) "
+ " FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
qcReqd = rs.getString(1);
trackShelfLife = rs.getString(2);
}
rs.close();
pstmt.close();
if (trackShelfLife != null && trackShelfLife.equalsIgnoreCase("N") && qcReqd != null && qcReqd.equalsIgnoreCase("N"))
{
// retestDt = Timestamp.valueOf("1910-01-01 00:00:00");// CHANGED BY ALKA ON 31/07/07 AS ERROR OCCURING FOR PARSING DATE
retestDt = genericUtility.getValidDateString("01/01/1910","dd/mm/yyyy", genericUtility.getApplDateFormat());
System.out.println("retestDt in if :::: " + retestDt);
}
else // ADDED BY ALKA ON 14/07/07 AS ERROR OCCURING FOR PARSING DATE
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
java.util.Date date = sdf.parse(new Timestamp(System.currentTimeMillis()).toString());
retestDate = Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
retestDt = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(retestDate).toString();
System.out.println("retestDt in else :::: " + retestDt);
}
// ADDITION BY ALKA 31/07/07 ENDED
if (backflushType.equalsIgnoreCase("R"))
{
// available = "Y,N";//CHANGED BY ALKA 31/07/07 AS INSTR FUNCTION REPLACED BY IN();
available = "('Y','N')";
}
sql = " SELECT A.ITEM_SER, A.ITEM_CODE, A.UNIT, A.LOC_CODE, A.LOT_NO, A.LOT_SL, A.QUANTITY, "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END) ALLOC_QTY, A.SITE_CODE, "
+ " A.EXP_DATE , A.RETEST_DATE, A.RATE, A.MFG_DATE, A.SITE_CODE__MFG, A.PACK_CODE, A.GRADE, "
+ " A.DIMENSION, A.GROSS_WEIGHT, A.TARE_WEIGHT, A.NET_WEIGHT,C.DESCR FROM STOCK A, INVSTAT B ,ITEM C "
+ " WHERE (A.INV_STAT = B.INV_STAT) AND C.ITEM_CODE = A.ITEM_CODE "
+ " AND (( A.ITEM_CODE = '"+itemCode+"' ) AND (A.SITE_CODE = '"+siteCode+"' ) AND (A.QUANTITY > 0) AND (A.QUANTITY - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END) > 0 ) "
// + " AND (INSTR('" + available + "',B.AVAILABLE) > 0) AND (A.EXP_DATE IS NULL OR (A.EXP_DATE > ? )) " //CHANGED BY ALKA 31/07/07 AS INSTR FUNCTION REPLACED BY IN();
+ " AND B.AVAILABLE IN " + available + " AND (A.EXP_DATE IS NULL OR (A.EXP_DATE > ? )) "
+ " AND ( A.LOT_NO NOT IN ( SELECT LOT_NO FROM QC_ORDER WHERE SITE_CODE = '"+siteCode+"' AND ITEM_CODE = '"+itemCode+"' "
+ " AND STATUS = 'U' )) AND ( B.STAT_TYPE <> 'S' ))";
pstmt = conn.prepareStatement(sql);
/*if(retestDt == null){
pstmt.setNull(1,Types.TIMESTAMP);
}else{
pstmt.setTimestamp(1,retestDt);
}CHANGED BY ALKA ON 14/07/07 AS ERROR OCCURING FOR PARSING DATE*/
pstmt.setTimestamp(1, Timestamp.valueOf(genericUtility.getValidDateString(retestDt, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())+ " 00:00:00"));
System.out.println("sql :: "+ sql);
System.out.println("Setting parameters ::: itemCode :::[" + itemCode + "] siteCode :::["+ siteCode + "]");
System.out.println("Setting parameters ::: available :::[" + available + "] retestDt :::["+ retestDt + "]");
rs = pstmt.executeQuery();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
while (rs.next())
{
iDescr = rs.getString("DESCR")==null?"":rs.getString("DESCR");//added by nisar on 26/09/07
// expDate = rs.getDate(10);
expDate = rs.getTimestamp(10);
if (expDate != null)
{
expDate1 = sdf.format(expDate);
System.out.println("expDate1 :"+expDate1);
}
// retestDate = rs.getDate(11);
retestDate = rs.getTimestamp(11);
if (retestDate != null)
{
retestDate1 = sdf.format(retestDate);
System.out.println("retestDate1 :"+retestDate1);
}
// mfgDate = rs.getDate(13);
mfgDate = rs.getTimestamp(13);
if(mfgDate != null){
mfgDate1 = sdf.format(mfgDate);
}
if(mfgDate1==null)//added by nisar on 11/08/07 set mfgDate1 to "" if mfgDate1 is null
{
mfgDate1="";
}
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_ser>").append("<![CDATA[").append(rs.getString(1).trim()).append("]]>").append("</item_ser>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(rs.getString(2).trim()).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr>").append("<![CDATA[").append(iDescr.trim()).append("]]>").append("</item_descr>\r\n");//added by nisar on 26/09/07
valueXmlString.append("<unit>").append("<![CDATA[").append(rs.getString(3)).append("]]>").append("</unit>\r\n");
valueXmlString.append("<loc_code>").append("<![CDATA[").append(rs.getString(4).trim()).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(rs.getString(5).trim()).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append("<![CDATA[").append(rs.getString(6).trim()).append("]]>").append("</lot_sl>\r\n");
/* COMMENTED BY ALKA 31/07/07 TO SHOW THE AVAILABLE QUANTITY INSTEAD OF TOTAL QUANTITY
* valueXmlString.append("<quantity>").append("<![CDATA[").append(rs.getDouble(7)).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<alloc_qty>").append("<![CDATA[").append(rs.getDouble(8)).append("]]>").append("</alloc_qty>\r\n");*/
// ADDED BY ALKA 31/07/07 TO SELECT THE AVAILABLE QUANTITY
totalQty = rs.getDouble(7);
allocQty = rs.getDouble(8);
valueXmlString.append("<quantity>").append("<![CDATA[").append(totalQty - allocQty).append("]]>").append("</quantity>\r\n");
// ADDITION BY ALKA 31/07/07 ENDED TO SELECT THE AVAILABLE QUANTITY
valueXmlString.append("<site_code>").append("<![CDATA[").append(rs.getString(9).trim()).append("]]>").append("</site_code>\r\n");
valueXmlString.append("<exp_date><![CDATA[").append(expDate1).append("]]></exp_date>\r\n");
// expDate1 = null;
// if(retestDate1 != null && retestDate1.trim().length() > 0){
valueXmlString.append("<retest_date><![CDATA[").append(retestDate1).append("]]></retest_date>\r\n");
// }
// retestDate1 = null;
valueXmlString.append("<rate><![CDATA[").append(rs.getDouble(12)).append("]]></rate>\r\n");
//// if(mfgDate1==null || mfgDate1.trim().length()==0)
//// {
// valueXmlString.append("<mfg_date><![CDATA[").append(" ").append("]]></mfg_date>\r\n");
//
// }
// else
// {
valueXmlString.append("<mfg_date><![CDATA[").append(mfgDate1).append("]]></mfg_date>\r\n");
// }
// mfgDate1 = null;
String siteCodeMfg = rs.getString(14);
valueXmlString.append("<site_code__mfg><![CDATA[").append(siteCodeMfg == null ? " ":siteCodeMfg.trim()).append("]]></site_code__mfg>\r\n");
String packCode = rs.getString(15);
valueXmlString.append("<pack_code><![CDATA[").append(packCode == null ? " ":packCode).append("]]></pack_code>\r\n");
String grade = rs.getString(16);
valueXmlString.append("<grade><![CDATA[").append(grade == null ? " ":grade).append("]]></grade>\r\n");
String dimension =( rs.getString(17)==null ? " " :rs.getString(17));
valueXmlString.append("<dimension><![CDATA[").append(dimension != null ? dimension:"").append("]]></dimension>\r\n");
valueXmlString.append("<gross_weight>").append("<![CDATA[").append(rs.getDouble(18)).append("]]>").append("</gross_weight>\r\n");
valueXmlString.append("<tare_weight>").append("<![CDATA[").append(rs.getDouble(19)).append("]]>").append("</tare_weight>\r\n");
valueXmlString.append("<net_weight>").append("<![CDATA[").append(rs.getDouble(20)).append("]]>").append("</net_weight>\r\n");
valueXmlString.append("</Detail>\r\n");
}
pstmt.close();
rs.close();
valueXmlString.append("</Root>\r\n");
}//try end
catch (SQLException sqx) {
System.out.println("The SQLException occurs in RcpBackflushMultiActEJB for Stock button :" + sqx);
throw new ITMException(sqx);
} catch (Exception e) {
System.out.println("The Exception occure in RcpBackflushMultiActEJB for Stock button:" + e);
throw new ITMException(e);
} finally {
try {
conn.close();
conn = null;
}catch (Exception e) {}
}
System.out.println("valueXmlString return from actionStock :" + valueXmlString.toString());
return valueXmlString.toString();
}
private String stockTransform(Document dom, Document dom1, String objContext, String xtraParams, Document selDataDom) throws ITMException
{
System.out.println("stockTransform is calling.............");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String sql = null, errCode = "", errString = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String tranId = null, itemCode = null, itemDescr = null, unit = null;
String stkLocCode = null,stkLotNo = null, stkLotSl = null, locDescr = null;
String siteCode = null, dimension = null, grossWeight = null, tareWeight = null, netWeight = null;
String expDate = null, mfgDate = null, siteCodeMfg = null, packCode = null, grade = null;
double quantity = 0, remainingQty = 0, inputQty = 0, stkQty = 0, rate = 0;
Node currDetail = null, currDetail1 = null;
double allocQty =0.0;
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
GenericUtility genericUtility = GenericUtility.getInstance();
try {
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
tranId = genericUtility.getColumnValue("tran_id", dom1);
siteCode = genericUtility.getColumnValue("site_code", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
itemDescr = genericUtility.getColumnValue("item_descr", dom);
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
NodeList detailList = selDataDom.getElementsByTagName("Detail");
int noOfDetails = detailList.getLength();
System.out.println("noOfDetails ...................................... :" + noOfDetails);
for (int ctr = 0; ctr < noOfDetails; ctr++) {
currDetail = detailList.item(ctr);
System.out.println("ctr................................................. :" + ctr);
stkQty = stkQty + Double.parseDouble((genericUtility.getColumnValueFromNode("quantity", currDetail)));
// allocQty = allocQty+Double.parseDouble((genericUtility.getColumnValueFromNode("alloc_qty", currDetail))); //COMMENTED BY ALKA 31/07/07 AS ONLY AVAILABLE QUANTITY WILL BE SHOWN IN THE POPUP FOR STOCK
}
System.out.println("stkQty :" + stkQty);
/*COMMENTED BY ALKA 31/07/07 AS ONLY AVAILABLE QUANTITY WILL BE SHOWN IN THE POPUP FOR STOCK
* System.out.println("allocQty :" + allocQty);
stkQty = stkQty - allocQty;
System.out.println("AvalibleStock :" +stkQty);
*/
// if (stkQty < quantity)
if (quantity != 0 && stkQty < quantity) //CHANGED BY ALKA 19/07/07 FOR HANDLING NO QUANTITY ENTERED.
{
errCode = "VTSTOCK1";
errString = itmDBAccessEJB.getErrorString("", errCode, "", "", conn);
conn.close();
conn = null;
return errString;
}
// remainingQty = quantity; //COMMENTED BY ALKA AS THE FOLLOWING LOGIC IS ADDED
// ADDED BY ALKA ON 19/07/07 FOR SELECTED STOCK TO BE ENTERED IN THE DETAIL IF THE QUANTITY IS 0
if (quantity == 0)
{
remainingQty = stkQty;
}
else
{
remainingQty = quantity;
}
System.out.println("quantity at the start of the forloop :::: " + quantity);
System.out.println("remainingQty at the start of the forloop :::: " + remainingQty);
// ADDITION ENDED BY ALKA 19/07/07
if (noOfDetails >= 0)
{
for (int ctr = 0; ctr < noOfDetails && remainingQty > 0; ctr++)
{
valueXmlString.append("<Detail>\r\n");
currDetail1 = detailList.item(ctr);
stkLocCode = genericUtility.getColumnValueFromNode("loc_code", currDetail1);
stkLotNo = genericUtility.getColumnValueFromNode("lot_no", currDetail1);
stkLotSl = genericUtility.getColumnValueFromNode("lot_sl", currDetail1);
unit = genericUtility.getColumnValueFromNode("unit", currDetail1);
expDate = genericUtility.getColumnValueFromNode("exp_date", currDetail1);
rate = Double.parseDouble(genericUtility.getColumnValueFromNode("rate", currDetail1));
mfgDate = genericUtility.getColumnValueFromNode("mfg_date", currDetail1);
siteCodeMfg = genericUtility.getColumnValueFromNode("site_code__mfg", currDetail1);
packCode = genericUtility.getColumnValueFromNode("pack_code", currDetail1);
grade = genericUtility.getColumnValueFromNode("grade", currDetail1);
dimension = genericUtility.getColumnValueFromNode("dimension", currDetail1);
grossWeight = genericUtility.getColumnValueFromNode("gross_weight", currDetail1);
tareWeight = genericUtility.getColumnValueFromNode("tare_weight", currDetail1);
netWeight = genericUtility.getColumnValueFromNode("net_weight", currDetail1);
// stkQty = Double.parseDouble(genericUtility.getColumnValueFromNode("quantity", currDetail1))-Double.parseDouble(genericUtility.getColumnValueFromNode("alloc_qty", currDetail1));
stkQty = Double.parseDouble(genericUtility.getColumnValueFromNode("quantity", currDetail1));
System.out.println("stkQty==> :" + stkQty);
sql = "SELECT DESCR FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stkLocCode);
rs = pstmt.executeQuery();
if (rs.next())
{
locDescr = rs.getString(1);
}
rs.close();
pstmt.close();
if (stkQty >= remainingQty)
{
inputQty = remainingQty;
remainingQty = 0;
}
else if (stkQty < remainingQty)
{
inputQty = stkQty;
remainingQty = remainingQty - stkQty;
}
valueXmlString.append("<tran_id isSrvCallOnChg='0'>").append("<![CDATA[").append(tranId).append("]]>").append("</tran_id>\r\n");
valueXmlString.append("<item_code isSrvCallOnChg='0'>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr isSrvCallOnChg='0'>").append("<![CDATA[").append(itemDescr).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<unit isSrvCallOnChg='0'>").append("<![CDATA[").append(unit).append("]]>").append("</unit>\r\n");
valueXmlString.append("<loc_code isSrvCallOnChg='0'>").append("<![CDATA[").append(stkLocCode).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<location_descr isSrvCallOnChg='0'>").append("<![CDATA[").append(locDescr).append("]]>").append("</location_descr>\r\n");
valueXmlString.append("<lot_no isSrvCallOnChg='0'>").append("<![CDATA[").append(stkLotNo).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl isSrvCallOnChg='0'>").append("<![CDATA[").append(stkLotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<quantity isSrvCallOnChg='0'>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<rate isSrvCallOnChg='0'>").append("<![CDATA[").append(rate).append("]]>").append("</rate>\r\n");
valueXmlString.append("<amount isSrvCallOnChg='0'>").append("<![CDATA[").append(inputQty*rate).append("]]>").append("</amount>\r\n");
if(mfgDate!=null && mfgDate.trim().length()!=0)
{
valueXmlString.append("<mfg_date isSrvCallOnChg='0'>").append("<![CDATA[").append(mfgDate).append("]]>").append("</mfg_date>\r\n");
}
valueXmlString.append("<site_code__mfg isSrvCallOnChg='0'>").append("<![CDATA[").append(siteCodeMfg).append("]]>").append("</site_code__mfg>\r\n");
valueXmlString.append("<pack_code isSrvCallOnChg='0'>").append("<![CDATA[").append(packCode).append("]]>").append("</pack_code>\r\n");
valueXmlString.append("<grade isSrvCallOnChg='0'>").append("<![CDATA[").append(grade).append("]]>").append("</grade>\r\n");
valueXmlString.append("<dimension isSrvCallOnChg='0'>").append("<![CDATA[").append(dimension).append("]]>").append("</dimension>\r\n");
valueXmlString.append("<gross_weight isSrvCallOnChg='0'>").append("<![CDATA[").append(grossWeight).append("]]>").append("</gross_weight>\r\n");
valueXmlString.append("<tare_weight isSrvCallOnChg='0'>").append("<![CDATA[").append(tareWeight).append("]]>").append("</tare_weight>\r\n");
valueXmlString.append("<net_weight isSrvCallOnChg='0'>").append("<![CDATA[").append(netWeight).append("]]>").append("</net_weight>\r\n");
valueXmlString.append("</Detail>");
if (remainingQty == 0)
{
break;
}
}// for end
}// end if
valueXmlString.append("</Root>");
}// end try
catch (ITMException itme) {
throw itme;
} catch (Exception e) {
throw new ITMException(e);
} finally {
try {
System.out.println("Closing Connection...");
conn.close();
conn = null;
} catch (Exception e) {
}
}
System.out.println("valueXmlString from :" + valueXmlString.toString());
return valueXmlString.toString();
}
private String allocateItem(Document dom1, String siteCode, String itemCode, double quantity, String xtraParams)throws RemoteException, ITMException
{
String locDescr = null, itemDescr = null, sql = "", siteDescr = null, tranId = null;
String stkLocCode = null, stkLotNo = null, stkLotSl = null, unit = null;
String convReqd = null, bkflshType = null, convQty = null, convRate = null;
double remainingQty = 0d, inputQty = 0d, stkQtyLot = 0d, rate = 0;
PreparedStatement pstmt = null;
Connection conn = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
GenericUtility genericUtility = GenericUtility.getInstance();
MfgCommon mfgCommon = new MfgCommon();
DistCommon distCommon = new DistCommon();
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
System.out.println("[Allocating .....]");
sql = "SELECT DESCR FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemDescr = rs.getString(1);
}
sql = " SELECT (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), A.UNIT, A.LOC_CODE, A.LOT_NO, "
+ " A.LOT_SL, A.RATE FROM STOCK A, LOCATION B, INVSTAT C WHERE A.LOC_CODE = B.LOC_CODE "
+ " AND ((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)) > 0 AND B.INV_STAT = C.INV_STAT "
+ " AND A.SITE_CODE = ? AND A.ITEM_CODE = ? "
+ " AND (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END) >= 0 AND C.AVAILABLE = 'Y' "
+ " ORDER BY (CASE WHEN A.EXP_DATE IS NULL THEN A.CREA_DATE ELSE A.EXP_DATE END), A.CREA_DATE, "
+ " A.LOT_NO , A.LOT_SL";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
while (rs.next())
{
stkQtyLot = rs.getDouble(1);
unit = rs.getString(6);
stkLocCode = rs.getString(1);
stkLotNo = rs.getString(2);
stkLotSl = rs.getString(3);
rate = rs.getDouble(5);
remainingQty = quantity;
if (stkQtyLot >= remainingQty)
{
inputQty = remainingQty;
remainingQty = 0;
}
else
{
inputQty = stkQtyLot;
remainingQty = remainingQty - inputQty;
}
sql = "SELECT DESCR FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stkLocCode);
rs = pstmt.executeQuery();
if (rs.next())
{
locDescr = rs.getString(1);
}
rs.close();
pstmt.close();
siteDescr = genericUtility.getColumnValue("site_descr", dom1);
tranId = genericUtility.getColumnValue("tran_id", dom1);
bkflshType = genericUtility.getColumnValue("backflush_type", dom1);
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<tran_id>").append("<![CDATA[").append(tranId).append("]]>").append("</tran_id>\r\n");
valueXmlString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>\r\n");
valueXmlString.append("<site_descr>").append("<![CDATA[").append(siteDescr).append("]]>").append("</site_descr>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr>").append("<![CDATA[").append(itemDescr).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<unit>").append("<![CDATA[").append(unit).append("]]>").append("</unit>\r\n");
valueXmlString.append("<loc_code>").append("<![CDATA[").append(stkLocCode).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<location_descr>").append("<![CDATA[").append(locDescr).append("]]>").append("</location_descr>\r\n");
valueXmlString.append("<unit__doc>").append("<![CDATA[").append(unit).append("]]>").append("</unit__doc>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(stkLotNo).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append("<![CDATA[").append(stkLotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<rate>").append("<![CDATA[").append(rate).append("]]>").append("</rate>\r\n");
convReqd = mfgCommon.getEnvMfg("999999", "RBKFSH_CONV_REQD", conn);
if (convReqd.equalsIgnoreCase("NULLFOUND"))
{
convReqd = "Y";
}
if (convReqd.equalsIgnoreCase("Y") && bkflshType.equalsIgnoreCase("J"))
{
ArrayList convQtyList = new ArrayList();
ArrayList convRateList = new ArrayList();
convQtyList = distCommon.getConvQuantityFact(unit, "", itemCode, inputQty, 0, conn);
convQty = (String)convQtyList.get(1);
convRateList = distCommon.getConvQuantityFact(unit, "", itemCode, rate, 0, conn);
convRate = (String)convRateList.get(1);
valueXmlString.append("<conv_qty_doc>").append("<![CDATA[").append("0").append("]]>").append("</conv_qty_doc>\r\n");
valueXmlString.append("<qty_doc>").append("<![CDATA[").append(convQty).append("]]>").append("</qty_doc>\r\n");
valueXmlString.append("<rate_doc>").append("<![CDATA[").append(convRate).append("]]>").append("</rate_doc>\r\n");
}
valueXmlString.append("</Detail>");
if (remainingQty == 0)
{
break;
}
}
valueXmlString.append("</Root>\r\n");
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in RcpBackflushMultiActEJB :(Allocate) Button :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch (Exception e)
{
System.out.println("The Exception occurs in RcpBackflushMultiActEJB : (Allocate) Button :"+e);
throw new ITMException(e);
}
finally
{
try
{
conn.close();
conn = null;
}
catch (Exception e){}
}
System.out.println("valueXmlString return from RcpBackflushMultiActEJB :"+valueXmlString.toString());
return valueXmlString.toString();
}
private String getCurrdateAppFormat()
{
String currAppdate = null;
java.sql.Timestamp currDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
Object date = null;
currDate =new java.sql.Timestamp(System.currentTimeMillis()) ;
System.out.println("currDate :::: [" + currDate + "]");
System.out.println(genericUtility.getDBDateFormat());
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
System.out.println("currDate :::: [" + currDate + "]");
currAppdate = new SimpleDateFormat(genericUtility.getApplDateFormat()).format(currDate).toString();
System.out.println("currDate :::: [" + currDate + "]");
}
catch(Exception e)
{
System.out.println("Exception in getCurrdateAppFormat"+e.getMessage());
}
return (currAppdate);
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcpBackflushMultiActLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcpBackflushMultiActRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
/*
Modification:
1- lot lot generate problem [ 290052007]
*/
package ibase.webitm.ejb.mfg.adv;
import java.util.*;
import java.sql.*;
import java.rmi.RemoteException;
import java.text.*;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
//import javax.ejb.SessionBean;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.fin.FinCommonInvAcct;
import ibase.webitm.utility.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcpBackflushMultiConf extends ActionHandlerEJB implements RcpBackflushMultiConfLocal , RcpBackflushMultiConfRemote //SessionBean
{
/* public void ejbCreate() throws RemoteException,CreateException{
}
public void ejbRemove(){
}
public void ejbActivate(){
}
public void ejbPassivate(){
}*/
public void setSessionContext(SessionContext se){
}
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
Connection conn = null;
Statement stmt = null,stmt1 = null;
PreparedStatement pstmt = null;
ResultSet rs = null,rs1 = null;
String sql = "";
ConnDriver connDriver = null;
String issLineNo = "",issItemCode = "",issUnit = "",issLocCode = "",issLotNo = "";
String issLotSl ="";
double issQuantity = 0,issRate =0;
String rcpConfirm = "",rcpItemCode = "",rcpLocCode = "",rcpLotNo = "",rcpLotSl = "";
String rcpUnit = "",rcpQcReqd = "",rcpSiteCodeMfg = "",rcpPackCOde = "",rcpGrade = "";
String rcpDimension = "";
double rcpQuantity = 0,rcpGrossWt = 0,rcpTareWt = 0,rcpNetWt = 0,rcpInvValue = 0,rcpCapacity = 0;
long rcpNoArt = 0;
java.sql.Date rcpMfgDate = null,rcpExpDate = null;
String stkGrade= "",stkBatchNo = "",stkAcctCodeInv = "",stkCctrCodeInv = "",stkSuppCodeMfg = "";
long stkNoArt = 0;
double stkRate = 0,stkGrossRate = 0,stkPotencyPerc = 0;
java.sql.Timestamp stkRetestDate = null;
String acctCodeDr = "",cctrCodeDr = "",acctCodeCr = "",cctrCodeCr = "";
String itemSer = "",itemStru = "";
String errString = "",backFlushType = "",unitAlt = "",siteCodeHdr = "",projCodeHdr = "",prjIndNo = "";
double amount = 0,grossAmount = 0,convQtyStdUom = 0;
Timestamp tranDate = null;
HashMap stkUpdMap = null;
ITMDBAccessEJB itmDBAccessEJB = null;
FinCommon finCommon = null;
GenericUtility genericUtility = null;
FinCommonInvAcct finCommonInvAcct = null;
try{
finCommon = new FinCommon();
finCommonInvAcct = new FinCommonInvAcct();
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = new GenericUtility();
stkUpdMap = new HashMap();
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("Driver");
conn.setAutoCommit(false);
stmt = conn.createStatement();
stmt1 = conn.createStatement();
sql = "select confirmed,site_code,backflush_type,tran_date,proj_code from rcp_backflush where tran_id = '"+tranID+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
rcpConfirm = rs1.getString("confirmed");
siteCodeHdr = rs1.getString("site_code");
backFlushType = rs1.getString("backflush_type");
tranDate = rs1.getTimestamp("tran_date");
projCodeHdr = rs1.getString("proj_code");
}
rs1.close();
if(rcpConfirm != null && rcpConfirm.trim().equalsIgnoreCase("Y")){
System.out.println("The Selected ransaction is already confirmed..........");
errString = itmDBAccessEJB.getErrorString("","VTCONF8","","",conn);
return errString;
}
String itemCodeHdr = "",lotNoHdr = "",lotSlHdr = "",locCodeHdr = "";
String acctCodeHdr = "",cctrCodeHdr = "";
sql = "select item_code,loc_code,lot_no,lot_sl from rcp_backflush_rcpt";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
itemCodeHdr = rs1.getString("item_code");
locCodeHdr = rs1.getString("loc_code");
lotNoHdr = rs1.getString("lot_no");
lotSlHdr = rs1.getString("lot_sl");
}
rs1.close();
sql = "select item_ser from item where item_code = '"+itemCodeHdr+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
itemSer = rs1.getString("item_ser");
}
rs1.close();
sql = "select acct_code__inv, cctr_code__inv from stock where " +
"item_code = '"+itemCodeHdr+"' " +
"and site_code = '"+siteCodeHdr+"' " +
"and loc_code = '"+locCodeHdr+"' " +
"and lot_no = '"+lotNoHdr+"' " +
"and lot_sl = '"+lotSlHdr+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
acctCodeHdr = rs1.getString("acct_code__inv");
cctrCodeHdr = rs1.getString("cctr_code__inv");
}
rs1.close();
sql = "select line_no,item_code,unit,rate,loc_code,lot_no,lot_sl,quantity from rcp_backflush_iss " +
"where tran_id = '"+tranID+"'";
System.out.println("SQL : "+sql);
rs = stmt.executeQuery(sql);
//Issue Update
while(rs.next()){
issLineNo = rs.getString("line_no");
issItemCode = rs.getString("item_code");
issUnit = rs.getString("unit");
issRate = rs.getDouble("rate");
issLocCode = rs.getString("loc_code");
issLotNo = rs.getString("lot_no");
issLotSl = rs.getString("lot_sl");
issQuantity = rs.getDouble("quantity");
sql = "select rate,gross_rate,grade,batch_no,no_art,retest_date,acct_code__inv,cctr_code__inv," +
"potency_perc,supp_code__mfg from stock " +
"where item_code = '"+issItemCode+"' and " +
"site_code = '"+siteCodeHdr+"' and " +
"loc_code = '"+issLocCode+"' and " +
"lot_no = '"+issLotNo+"' and " +
"lot_sl = '"+issLotSl+"'";
rs1 = stmt1.executeQuery(sql);
System.out.println("SQL : "+sql);
if(rs1.next()){
stkRate = rs1.getDouble("rate");
stkGrossRate = rs1.getDouble("gross_rate");
stkGrade = rs1.getString("grade");
stkBatchNo = rs1.getString("batch_no");
stkNoArt = rs1.getLong("no_art");
stkRetestDate = rs1.getTimestamp("retest_date");
stkAcctCodeInv = rs1.getString("acct_code__inv");
stkCctrCodeInv = rs1.getString("cctr_code__inv");
stkPotencyPerc = rs1.getDouble("potency_perc");
stkSuppCodeMfg = rs1.getString("supp_code__mfg");
}else{
if(issQuantity > 0){
errString = itmDBAccessEJB.getErrorString("","VXSTK2","","",conn);
return errString;
}
}
rs1.close();
sql = "select item_ser,item_stru " +
"from item " +
"where item_code = '"+issItemCode+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(issQuantity < 0){
stkRate = issRate;
stkGrossRate = issRate;
if(rs1.next()){
itemSer = rs1.getString("item_ser");
itemStru = rs1.getString("item_stru");
acctCodeDr = stkAcctCodeInv;
cctrCodeDr = stkCctrCodeInv;
}else{
String acctCodeDrTemp = "";
acctCodeDrTemp = finCommon.getFromAcctDetr(issItemCode,itemSer,"IN",conn);
if(acctCodeDr != null && acctCodeDr.trim().length() > 0){
acctCodeDr = acctCodeDrTemp.substring(0,acctCodeDr.indexOf(","));
cctrCodeDr = acctCodeDrTemp.substring(acctCodeDr.indexOf(",")+1);
}
acctCodeDrTemp = null;
}
acctCodeCr = acctCodeHdr;
cctrCodeCr = cctrCodeHdr;
if(cctrCodeCr == null || cctrCodeCr.trim().length() == 0){
cctrCodeCr = stkCctrCodeInv;
}
}else{
acctCodeCr = stkAcctCodeInv;
cctrCodeCr = stkCctrCodeInv;
}
rs1.close();
/*if (isnull(ls_cctrcodedr) or len(trim(ls_cctrcodedr)) = 0) and lc_quantity_hdr >= 0 then
ls_cctrcodedr = ls_cctrcodecr
elseif (isnull(ls_cctrcodecr) or len(trim(ls_cctrcodecr)) = 0) and lc_quantity_hdr < 0 then
ls_cctrcodecr = ls_cctrcodedr
end if*/
if(issQuantity > 0){
amount = amount + (stkRate * issQuantity);
grossAmount = grossAmount + (grossAmount * issQuantity);
}
if(backFlushType.equalsIgnoreCase("S") || backFlushType.equalsIgnoreCase("C")){
if(backFlushType.equalsIgnoreCase("C")){
stkUpdMap.put("potency_perc",Double.toString(stkPotencyPerc));
stkUpdMap.put("supp_code__mfg",stkSuppCodeMfg);
}
if(unitAlt == null || unitAlt.trim().length() == 0){
sql = "select unit__alt from stock where item_code = '"+issItemCode+"' " +
"and lot_no = '"+issLotNo+"' " +
"and unit__alt is not null " +
"and length(trim(unit__alt)) > 0";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
unitAlt = rs1.getString("unit__alt");
}
rs1.close();
}
if(convQtyStdUom == 0){
sql = "select conv__qty_stduom " +
"from stock " +
"where item_code = '"+issItemCode+"' " +
"and lot_no = '"+issLotNo+"' " +
"and conv__qty_stduom is not null " +
"and conv__qty_stduom <> 0 ";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
convQtyStdUom = rs1.getDouble("conv__qty_stduom");
}
}
}
if(cctrCodeCr == null || cctrCodeCr.trim().length() == 0){
cctrCodeCr = " ";
}
if(cctrCodeDr == null || cctrCodeDr.trim().length() == 0){
cctrCodeDr = " ";
}
stkUpdMap.put("line_no",issLineNo);
stkUpdMap.put("item_code",issItemCode);
stkUpdMap.put("site_code",siteCodeHdr);
stkUpdMap.put("loc_code",issLocCode);
stkUpdMap.put("lot_no",issLotNo);
stkUpdMap.put("lot_sl",issLotSl);
stkUpdMap.put("unit",issUnit);
stkUpdMap.put("quantity",Double.toString(issQuantity));
stkUpdMap.put("qty_stduom",Double.toString(issQuantity));
stkUpdMap.put("tran_id",tranID);
stkUpdMap.put("tran_ser","R-BFS");
stkUpdMap.put("tran_date",tranDate);
stkUpdMap.put("acct_code__cr",acctCodeCr);
stkUpdMap.put("cctr_code__cr",cctrCodeCr);
stkUpdMap.put("acct_code__dr",acctCodeDr);
stkUpdMap.put("cctr_code__dr",cctrCodeDr);
if(issQuantity >= 0){
stkUpdMap.put("tran_type","ID");
}else{
stkUpdMap.put("tran_type","R");
stkUpdMap.put("quantity",Double.toString(-1 * issQuantity));
stkUpdMap.put("qty_stduom",Double.toString(-1 * issQuantity));
stkUpdMap.put("acct_code_inv",acctCodeDr);
stkUpdMap.put("cctr_code_inv",cctrCodeDr);
}
stkUpdMap.put("grade",stkGrade);
if(issQuantity < 0){
stkUpdMap.put("rate",Double.toString(stkRate));
stkUpdMap.put("gross_rate",Double.toString(stkGrossRate));
}
if(itemStru == null || !itemStru.equalsIgnoreCase("R")){
StockUpdate stkUpd = new StockUpdate();
errString = stkUpd.updateStock(stkUpdMap,xtraParams,conn);
stkUpd = null;
if(errString.indexOf("Error") != -1){
break;
}
}
stkUpdMap.clear();
}//while end (Issue)
rs.close();
stmt.close();
//Recipt stock update
stkUpdMap.clear();
if(errString.indexOf("Error") != -1){
System.out.println("Returning Result "+errString);
conn.rollback();
return errString;
}
////////Creating QC Order
System.out.println("Creating QC Order....");
errString = createQCOrder(tranID,siteCodeHdr,backFlushType,xtraParams,conn);
if(errString.indexOf("Error") != -1){
System.out.println("Create QC Order Failed........");
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
conn.rollback();
return errString;
}
/////////////
sql = "select item_code,loc_code,lot_no,lot_sl," +
"quantity,unit,qc_reqd,mfg_date,exp_date,site_code__mfg,pack_code," +
"grade, dimension, gross_weight, tare_weight, net_weight, no_art, inv_value " +
"from rcp_backflush_rcpt where tran_id = '"+tranID+"'";
System.out.println("SQL : "+sql);
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while(rs.next()){
rcpItemCode = rs.getString("item_code");
rcpLocCode = rs.getString("loc_code");
rcpLotNo = rs.getString("lot_no");
rcpLotSl = rs.getString("lot_sl");
rcpQuantity = rs.getDouble("quantity");
rcpUnit = rs.getString("unit");
rcpQcReqd = rs.getString("qc_reqd");
rcpMfgDate = rs.getDate("mfg_date");
rcpExpDate = rs.getDate("exp_date");
rcpSiteCodeMfg = rs.getString("site_code__mfg");
rcpPackCOde = rs.getString("pack_code");
rcpGrade = rs.getString("grade");
rcpDimension = rs.getString("dimension");
rcpGrossWt = rs.getDouble("gross_weight");
rcpTareWt = rs.getDouble("tare_weight");
rcpNetWt = rs.getDouble("net_weight");
rcpNoArt = rs.getLong("no_art");
rcpInvValue = rs.getDouble("inv_value");
sql = "select case when capacity is null then 0 else capacity end from location where " +
"loc_code = '"+rcpLocCode+"'";
System.out.println("SQL : "+sql);
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
rcpCapacity = rs1.getDouble(1);
}
rs1.close();
if(rcpQuantity > rcpCapacity){
errString = itmDBAccessEJB.getErrorString("","VTCAPACITY","","",conn);
return errString;
}
if(rcpQuantity > 0){
stkRate = rcpInvValue / rcpQuantity;
if(backFlushType.equalsIgnoreCase("S") || backFlushType.equalsIgnoreCase("C")){
stkGrossRate = grossAmount / rcpQuantity;
}else{
stkGrossRate = rcpInvValue / rcpQuantity;
}
}
stkUpdMap.put("item_code",rcpItemCode);
stkUpdMap.put("site_code",siteCodeHdr);
stkUpdMap.put("loc_code",rcpLocCode);
stkUpdMap.put("lot_no",rcpLotNo);
stkUpdMap.put("lot_sl",rcpLotSl);
stkUpdMap.put("unit",rcpUnit);
if(rcpQuantity >= 0){
stkUpdMap.put("quantity",Double.toString(rcpQuantity));
stkUpdMap.put("qty_stduom",Double.toString(rcpQuantity));
}else{
stkUpdMap.put("quantity",Double.toString(-1 * rcpQuantity));
stkUpdMap.put("qty_stduom",Double.toString(-1 * rcpQuantity));
}
stkUpdMap.put("tran_id",tranID);
stkUpdMap.put("tran_ser","R-BFS");
stkUpdMap.put("tran_date",tranDate);
sql = "select acct_code__inv, cctr_code__inv from stock " +
"where item_code = '"+rcpItemCode+"' " +
"and site_code = '"+siteCodeHdr+"' " +
"and loc_code = '"+rcpLocCode+"' " +
"and lot_no = '"+rcpLotNo+"' " +
"and lot_sl = '"+rcpLotSl+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next())
{
acctCodeDr = rs1.getString("acct_code__inv");
cctrCodeDr = rs1.getString("cctr_code__inv");
rs1.close();
stmt1.close();
}
else
{
//added by tarani else part
sql = "select item_ser from item where item_code = '"+rcpItemCode+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next())
{
itemSer = rs1.getString(1);
}
rs1.close();
stmt1.close();
if(itemSer !=null)itemSer.trim();
System.out.println("Parameter goes to getFromAcctDetr.....");
System.out.println("rcpItemCode :::["+rcpItemCode+"]");
System.out.println("itemSer:::["+itemSer+"]");
System.out.println("Parameter goes to getFromAcctDetr.....");
String acctCctr = finCommon.getFromAcctDetr(rcpItemCode,itemSer, "IN",conn);
System.out.println("acct @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@"+acctCctr);
acctCodeDr = acctCctr.substring(0,acctCctr.indexOf(","));
cctrCodeDr = acctCctr.substring(acctCctr.indexOf(",")+1);
acctCctr = null;
}
if(rcpQuantity >= 0){
stkUpdMap.put("acct_code__dr",acctCodeDr);
stkUpdMap.put("cctr_code__dr",cctrCodeDr);
stkUpdMap.put("acct_code_inv",acctCodeDr);
stkUpdMap.put("cctr_code_inv",cctrCodeDr);
}else{
stkUpdMap.put("acct_code__cr",acctCodeDr);
stkUpdMap.put("cctr_code__cr",cctrCodeDr);
stkUpdMap.put("acct_code_inv",acctCodeDr);
stkUpdMap.put("cctr_code_inv",cctrCodeDr);
}
stkUpdMap.put("acct_code__cr"," ");
stkUpdMap.put("cctr_code__cr"," ");
stkUpdMap.put("rate",Double.toString(stkRate));
stkUpdMap.put("gross_rate",Double.toString(stkGrossRate));
if(rcpQuantity >= 0){
stkUpdMap.put("tran_type","R");
}else{
stkUpdMap.put("tran_type","I");
}
stkUpdMap.put("mfg_date",rcpMfgDate);
stkUpdMap.put("exp_date",rcpExpDate);
stkUpdMap.put("site_code__mfg",rcpSiteCodeMfg);
stkUpdMap.put("pack_code",rcpPackCOde);
stkUpdMap.put("retest_date",stkRetestDate);
if(rcpGrade == null || rcpGrade.trim().length() == 0) rcpGrade = " ";
stkUpdMap.put("grade",rcpGrade);
stkUpdMap.put("batch_no",stkBatchNo);
stkUpdMap.put("no_art",Double.toString(rcpNoArt));
stkUpdMap.put("dimension",rcpDimension);
stkUpdMap.put("gross_weight",Double.toString(rcpGrossWt));
stkUpdMap.put("tare_weight",Double.toString(rcpTareWt));
stkUpdMap.put("net_weight",Double.toString(rcpNetWt));
if(backFlushType.equalsIgnoreCase("S") || backFlushType.equalsIgnoreCase("C")){
stkUpdMap.put("unit__alt",unitAlt);
stkUpdMap.put("conv__qty_stduom",Double.toString(convQtyStdUom));
}
StockUpdate stkUpd = new StockUpdate();
errString = stkUpd.updateStock(stkUpdMap,xtraParams,conn);
stkUpd =null;
if(errString != null && errString.indexOf("Error") != -1 ) //added by rajendra on 09/07/07 for checking null value
{
break;
}
stkUpdMap.clear();
}//while end
System.out.println("errString : "+errString);
if(errString == null || errString.indexOf("Error") == -1){ //comment by rajendra 0n 17/07/07
// if(errString ==null ){
errString = finCommonInvAcct.rbfpost(tranID,"R-BFS",conn);
System.out.println("ErrString from RbfPost :: "+errString);
if(errString.indexOf("Error") == -1 && projCodeHdr != null && projCodeHdr.trim().length() > 0){
sql = "select ind_no from project where proj_code = '"+projCodeHdr+"'";
stmt1 = conn.createStatement();
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
prjIndNo = rs1.getString("ind_no");
}
if(prjIndNo != null && prjIndNo.trim().length() > 0){
sql = "update indent set status = 'C',status_date = ? ," +
"chg_date = ? ,chg_user = ? ,chg_term = ? " +
"where ind_no = ? ";
System.out.println("SQL : "+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,new Timestamp(System.currentTimeMillis()));
pstmt.setTimestamp(2,new Timestamp(System.currentTimeMillis()));
pstmt.setString(3,"SYSTEM");
pstmt.setString(4,"SYSTEM");
pstmt.setString(5,prjIndNo);
int updCnt = pstmt.executeUpdate();
System.out.println("Update in Indent : "+updCnt);
}
sql = "update project set quantity = (select sum(quantity) from rcp_backflush_rcpt " +
"where tran_id = '"+tranID+"') where proj_code = '"+projCodeHdr+"'";
System.out.println("SQL :"+sql);
stmt1.executeUpdate(sql);
}else{
conn.rollback();
//errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
return errString;
}
String empCodeAprv = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
sql = "update rcp_backflush set confirmed = 'Y',conf_date = ? ,emp_code__aprv = ? where tran_id = '"+tranID+"' ";
System.out.println("SQL : "+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,new Timestamp(System.currentTimeMillis()));
pstmt.setString(2,empCodeAprv);
int upd = pstmt.executeUpdate();
System.out.println("Receipt Backflush Multi Confirm :: "+upd);
if(upd > 0){
conn.commit();
errString = itmDBAccessEJB.getErrorString("","VTDIST30","");
System.out.println("ReceiptBackflush Multi Confirmed .."+errString);
}
}else{
conn.rollback();
//errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
return errString;
}
}catch(ITMException ie){
System.out.println("ITMException : "+ie);
try{conn.rollback();}catch(Exception t){}
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From RcpBackflushMultiConf :"+errString);
return errString;
}catch(Exception e){
System.out.println("Exception in Confirm [RcpBackflushConfEJB]"+e);
try{conn.rollback();}catch(Exception t){}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From RcpBackflushMultiConf :"+errString);
return errString;
}finally{
try{
stkUpdMap = null;
if(rs != null){rs.close();rs = null;}
if(rs1 != null){rs1.close();rs1 = null;}
if(stmt != null){stmt.close();stmt = null;}
if(stmt1 != null){stmt1.close();stmt1 = null;}
if(conn != null){//conn.close();//To be uncommented - checked for error
conn = null;}
}catch(Exception e){System.out.println("Exception : "+e);e.printStackTrace();}
}
System.out.println("Returnng String From RcpBackflushMultiConf :"+errString);
return errString;
}
private String createQCOrder(String tranId,String rcpSiteCode,String rcpBackflushType,String xtraParm,Connection conn) throws ITMException
{
String winName = "w_qcorder_new",sql = "";
Statement stmt = null,stmt1 = null;
PreparedStatement pstmt = null;
ResultSet rs = null,rs1 = null;
String rcpLineNo = "",rcpItemCode = "",rcpUnit = "";
String rcpLocCode = "",rcpLotNo = "",rcpLotSl = "";
double rcpQuantity = 0;
int qcLeadTime = 0;
String itemSer = "",siteItemSer = "",qOrderType = "";
String keyString = "";
String qcNo = "",userId = "",porcpLineNo = "";
int porcpline = 1;
String sqlInsert = "";
String currDate = "",errString = "",loginEmpCode = "";
GenericUtility genericUtility = null;
SimpleDateFormat sdf = null;
java.util.Date qcDueDate = null;
java.sql.Date expDate = null;
try{
genericUtility = new GenericUtility();
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
stmt = conn.createStatement();
stmt1 = conn.createStatement();
currDate = sdf.format(new java.sql.Date(System.currentTimeMillis()));
loginEmpCode = genericUtility.getValueFromXTRA_PARAMS(xtraParm,"loginEmpCode");
sqlInsert ="insert into qc_order (qorder_no,qorder_type,qorder_date,site_code,item_code, " +
"route_code,quantity,qty_passed,qty_rejected," +
"start_date,due_date,rel_date,porcp_no,porcp_line_no, " +
"lot_no,lot_sl,chg_date,chg_user,chg_term,loc_code," +
"qty_sample,status, unit,qc_create_type, batch_no,expiry_date," +
"loc_code__aprv,loc_code__rej,unit__sample,lot_no__new,retest_date,emp_code,item_code__new ) " +
"values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
sql = "select line_no,item_code, quantity, unit, loc_code, lot_no, lot_sl, exp_date " +
"from rcp_backflush_rcpt where tran_id = '"+tranId+"' and upper(qc_reqd) = 'Y'" ;
System.out.println("SQL : "+sql);
rs = stmt.executeQuery(sql);
while(rs.next()){
rcpLineNo = rs.getString("line_no");
rcpItemCode = rs.getString("item_code");
rcpQuantity = rs.getDouble("quantity");
rcpUnit = rs.getString("unit");
rcpLocCode = rs.getString("loc_code");
rcpLotNo = rs.getString("lot_no");
rcpLotSl = rs.getString("lot_sl");
expDate = rs.getDate("exp_date");
sql = "select case when qc_lead_time is null then 0 else qc_lead_time end , item_ser " +
"from item where item_code = '"+rcpItemCode+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
qcLeadTime = rs1.getInt(1);
itemSer = rs1.getString(2);
}
rs1.close();
qcDueDate = getRelativeDate(new java.util.Date(System.currentTimeMillis()),qcLeadTime);
sql = "select item_ser from siteitem where site_code = '"+rcpSiteCode+"' and item_code = '"+rcpItemCode+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
siteItemSer = rs1.getString("item_ser");
}
if(siteItemSer != null && siteItemSer.trim().length() > 0){
itemSer = siteItemSer;
}
rs1.close();
sql = "select key_string from transetup where tran_window = '"+winName+"'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
keyString = rs1.getString("key_string");
}
rs1.close();
if(keyString == null || keyString.trim().length() == 0){
sql = "select key_string from transetup where tran_window = 'GENERAL'";
System.out.println("SQL : "+sql);
rs1 = stmt1.executeQuery(sql);
if(rs1.next()){
keyString = rs1.getString("key_string");
}
rs1.close();
}
//comment by tarani lot no generated for the qc item
/* if(rcpBackflushType != null && rcpBackflushType.trim().equalsIgnoreCase("S")){
qOrderType = "I";
rcpLotNo = qcNo;
}else{
qOrderType = "S";
}*/
//290052007
qOrderType = "I";
String 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>"+rcpSiteCode+"</site_code>";
xmlValues = xmlValues + "<qorder_type>"+ qOrderType + "</qorder_type>";
xmlValues = xmlValues + "<qorder_date>"+currDate+"</qorder_date>";
xmlValues = xmlValues + "<lot_no>"+rcpLotNo+"</lot_no>";
xmlValues = xmlValues + "<item_ser>"+itemSer+"</item_ser>";
xmlValues = xmlValues + "</Detail1></Root>";
userId = genericUtility.getValueFromXTRA_PARAMS("loginCode",xtraParm);
TransIDGenerator tg1 = new TransIDGenerator(xmlValues, userId, CommonConstants.DB_NAME);
qcNo = tg1.generateTranSeqID("QC-ORD", "qorder_no", keyString, conn);
System.out.println("Generated QC No : "+qcNo);
if(qcNo.indexOf("Error") != -1){
errString = "Error";
return errString;
}
//290052007
if(rcpLotNo==null || rcpLotNo.trim().length()==0)
{
rcpLotNo = qcNo;
}
sql = "update rcp_backflush_rcpt set lot_no = '"+rcpLotNo+"' where tran_id = '"+tranId+"' and line_no = "+rcpLineNo+"";
System.out.println("SQL :"+sql);
int upd = stmt1.executeUpdate(sql);
System.out.println("Update in rcp_backflush_rcpt : "+upd);
System.out.println("Inserting QC Order ::");
pstmt = conn.prepareStatement(sqlInsert);
pstmt.setString(1,qcNo);
pstmt.setString(2,qOrderType);
pstmt.setTimestamp(3,new Timestamp(System.currentTimeMillis()));
pstmt.setString(4,rcpSiteCode);
pstmt.setString(5,rcpItemCode);
pstmt.setString(6," ");
pstmt.setDouble(7,rcpQuantity);
pstmt.setDouble(8,0);
pstmt.setDouble(9,0);
pstmt.setTimestamp(10,new Timestamp(System.currentTimeMillis()));
pstmt.setTimestamp(11,new Timestamp(qcDueDate.getTime()));
pstmt.setTimestamp(12,new Timestamp(System.currentTimeMillis()));
pstmt.setString(13,tranId);
porcpLineNo = " " + porcpline;
porcpLineNo = porcpLineNo.substring(porcpLineNo.length() - 3);
pstmt.setString(14,porcpLineNo);
pstmt.setString(15,rcpLotNo);
pstmt.setString(16,rcpLotSl);
pstmt.setTimestamp(17,new Timestamp(System.currentTimeMillis()));
pstmt.setString(18,"SYSTEM");
pstmt.setString(19,"SYSTEM");
pstmt.setString(20,rcpLocCode);
pstmt.setDouble(21,0);
pstmt.setString(22,"U");
pstmt.setString(23,rcpUnit);
pstmt.setString(24,"T");
pstmt.setString(25,"");
if(expDate == null){
pstmt.setNull(26,Types.TIMESTAMP);
}else{
pstmt.setTimestamp(26,new Timestamp(expDate.getTime()));
}
pstmt.setNull(27,Types.VARCHAR);
pstmt.setNull(28,Types.VARCHAR);
pstmt.setString(29,rcpUnit);
pstmt.setString(30,rcpLotNo);
pstmt.setNull(31,Types.TIMESTAMP);
pstmt.setString(32,loginEmpCode);
pstmt.setString(33,rcpItemCode);
int intCount = pstmt.executeUpdate();
System.out.println("Inserting Qc_order :"+intCount);
pstmt.clearParameters();
}
}catch(Exception e){
errString = "Error";
System.out.println("Exception in RcpBackflushMultiConf [createQCOrder]"+e);
e.printStackTrace();
throw new ITMException(e);
}
return errString;
}
private java.util.Date getRelativeDate(java.util.Date currDate,int leadTime )throws ITMException
{
java.util.Date relativeDate = null;
try{
Calendar cal = Calendar.getInstance();
cal.setTime(currDate);
cal.add(Calendar.DATE,leadTime);
relativeDate = cal.getTime();
}catch(Exception e){
System.out.println("Exception "+e);
e.printStackTrace();
throw new ITMException(e);
}
return relativeDate;
}
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcpBackflushMultiConfLocal extends ActionHandlerLocal//,EJBObject
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcpBackflushMultiConfRemote extends ActionHandlerRemote//, EJBObject
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
/*
Developed by : Alka Shah
Company : Base Information Management Pvt. Ltd
Version : 1.0
Date :31/03/2007
*/
package ibase.webitm.ejb.mfg.adv;
import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.mfg.ExplodeBom;
import ibase.webitm.ejb.mfg.MfgCommon;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
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 javax.ejb.CreateException;
//import javax.ejb.SessionBean;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class RcptBackflushAct extends ActionHandlerEJB implements RcptBackflushActLocal , RcptBackflushActRemote //SessionBean
{
/**
*
*/
/*public void ejbCreate() throws RemoteException, CreateException {
}
public void ejbRemove() {
}
public void ejbActivate() {
}
public void ejbPassivate() {
}*/
public String actionHandler() throws RemoteException, ITMException {
return "";
}
public String actionHandler(String actionType, String xmlString,
String xmlString1, String objContext, String xtraParams)
throws RemoteException, ITMException {
Document dom = null;
Document dom1 = null;
String retString = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try {
if (xmlString != null && xmlString.trim().length() != 0) {
System.out.println("XML String :" + xmlString);
dom = genericUtility.parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0) {
System.out.println("XML String1 :" + xmlString1);
dom1 = genericUtility.parseString(xmlString1);
}
System.out.println("actionType:" + actionType + ":");
if (actionType.equalsIgnoreCase("BOM")) {
retString = actionBOM(dom, dom1, xtraParams);
}
if (actionType.equalsIgnoreCase("Stock")) {
retString = actionStock(dom, dom1, xtraParams);
}
} catch (Exception e) {
System.out
.println("Exception :RcptBackflushActEJB :actionHandler(String xmlString):"
+ e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out
.println("returning String from RcptBackflushActEJB : actionHandler"
+ retString);
return retString;
}
public String actionHandlerTransform(String actionType, String xmlString,
String xmlString1, String objContext, String xtraParams,
String selDataStr) throws RemoteException, ITMException {
System.out.println("actionHandlerTransform is calling.............");
Document dom = null;
Document dom1 = null;
Document selDataDom = null;
String retString = null;
try {
if (xmlString != null && xmlString.trim().length() != 0) {
dom = GenericUtility.getInstance().parseString(xmlString);
}
if (xmlString1 != null && xmlString1.trim().length() != 0)
{
dom1 = GenericUtility.getInstance().parseString(xmlString1);
}
if (selDataStr != null && selDataStr.length() > 0) {
selDataDom = GenericUtility.getInstance().parseString(selDataStr);
}
System.out.println("selDataStr:" + selDataStr + ":");
System.out.println("actionType:" + actionType + ":");
if (actionType.equalsIgnoreCase("Stock")) {
retString = stockTransform(dom, dom1, objContext, xtraParams,
selDataDom);
}
} catch (Exception e) {
System.out.println("Exception :RcptBackflushActEJB :actionHandlerTransform(String xmlString):"
+ e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("returning String from RcptBackflushActEJB : actionHandlerTransform"
+ retString);
return retString;
}
private String actionBOM(Document dom, Document dom1, String xtraParams) throws RemoteException, ITMException {
String siteCode = null, itemCode = null, bomCode = null;
String mfgLeadTime = null, qcLeadTime = null;
double quantity = 0;
String sql = "", varValue = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
Connection conn = null;
MfgCommon mfgCommon = new MfgCommon();
GenericUtility genericUtility = GenericUtility.getInstance();
ExplodeBom explodeBomObj = new ExplodeBom();
ConnDriver connDriver = new ConnDriver();
String returnString = "";
try
{
conn = connDriver.getConnectDB("DriverITM");
siteCode = genericUtility.getColumnValue("site_code", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom1);
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom1));
bomCode = genericUtility.getColumnValue("bom_code", dom1);
varValue = mfgCommon.getEnvMfg("999999", "SITE_SPECIFIC", conn);
if (varValue.equalsIgnoreCase("Y"))
{
sql = "SELECT MFG_LEAD_TIME, QC_LEAD_TIME FROM SITEITEM WHERE SITE_CODE = ? AND ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
mfgLeadTime = rs.getString(1);
qcLeadTime = rs.getString(2);
}
rs.close();
pstmt.close();
}
else
{
sql = "SELECT MFG_LEAD, QC_LEAD_TIME FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
mfgLeadTime = rs.getString(1);
qcLeadTime = rs.getString(2);
}
rs.close();
pstmt.close();
}
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
StringBuffer xmlString = new StringBuffer("<Root>");
String retXMLStr = null;
xmlString.append("<Detail>");
xmlString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>");
xmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>");
xmlString.append("<line_type>").append("<![CDATA[").append("B").append("]]>").append("</line_type>");
xmlString.append("<quantity>").append("<![CDATA[").append(quantity).append("]]>").append("</quantity>");
xmlString.append("<bom_code>").append("<![CDATA[").append(bomCode).append("]]>").append("</bom_code>");
xmlString.append("<due_date>").append("<![CDATA[").append(sdf.format(new java.util.Date())).append("]]>").append("</due_date>");
xmlString.append("<mfg_lead_time>").append("<![CDATA[").append(mfgLeadTime).append("]]>").append("</mfg_lead_time>");
xmlString.append("<qc_lead_time>").append("<![CDATA[").append(qcLeadTime).append("]]>").append("</qc_lead_time>");
xmlString.append("</Detail>");
xmlString.append("</Root>");
retXMLStr = explodeBomObj.explodeBom(xmlString.toString()).toString();
if (xmlString != null || xmlString.toString().trim().length() != 0)
{
returnString = updateDetail(dom1, retXMLStr, xtraParams);
}
} catch (SQLException sqx) {
System.out.println("The sqlException occure in RcptBackflushActEJB :" + sqx);
throw new ITMException(sqx);
} catch (Exception e) {
System.out.println("The Exception occure in RcptBackflushActEJB :" + e);
throw new ITMException(e);
} finally {
try {
conn.close();
conn = null;
} catch (Exception e) {
}
}
// System.out.println("returnString from RcptBackflushActEJB :" + returnString);
return returnString;
}
private String updateDetail(Document dom1, String expXmlString, String xtraParams)
{
Document expDom;
String siteCode = null, itemCode = null;
String allocateStr = null;
double quantity = 0;
Node currDetail = null;
int ctr = 0;
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String errString = "";
try
{
expDom = genericUtility.parseString(expXmlString);
NodeList detailList = expDom.getElementsByTagName("Detail");
int noOfDetails = detailList.getLength();
System.out.println("noOfDetails :: " + noOfDetails);
if (noOfDetails > 0)
{
for(ctr = 0; ctr < noOfDetails; ctr++)
{
currDetail = detailList.item(ctr);
siteCode = genericUtility.getColumnValueFromNode("site_code", currDetail);
itemCode = genericUtility.getColumnValueFromNode("item_code", currDetail);
System.out.println("siteCode ::: " + siteCode + " itemCode :: " + itemCode);
quantity = Double.parseDouble(genericUtility.getColumnValueFromNode("quantity", currDetail));
allocateStr = allocateItem(dom1, siteCode, itemCode, quantity, xtraParams);
System.out.println("allocateStr ::: " + allocateStr);
if (allocateStr.indexOf("<Errors>") > 0)
{
return allocateStr;
}
// ADDED BY ALKA ON 20/07/07 FOR VALIDATING THAT
if (allocateStr.indexOf("<Detail>") == -1)
{
errString = itmDBAccessEJB.getErrorString("", "VTSTKBOM", "");
errString = updateMessage(errString, "Stock for Item_code :::: " + itemCode + " is not available");
return errString;
}
// ADDITION ENDED BY ALKA 20/07/07
valueXmlString.append(allocateStr.substring(allocateStr.indexOf("<Detail>"), allocateStr.indexOf("</Root>")));
}
}
valueXmlString.append("</Root>\r\n");
}
catch(Exception e)
{
System.out.println("Exception :RcptBackflushActEJB : updateDetail.." +e.getMessage());
e.printStackTrace();
}
System.out.println("valueXmlString return from RcptBackflushActEJB :" + valueXmlString.toString());
return valueXmlString.toString();
}
private String actionStock(Document dom, Document dom1, String xtraParams)
throws RemoteException, ITMException {
/*
* ALLOWS THE USER TO SELECT STOCK FROM DIFF. LOC_CODE, LOT_NO, LOT_SL
GETS ALL STOCK FROM STOCK TABLE FOR FOLLOWING CONDITIONS:
SITE_CODE = HEADER SITE_CODE ---- ITEM_CODE = ITEM CODE ENTERED
INVSTAT.AVAILABLE = 'Y' --- EXPIRY DATE IS NULL OR EXPIRY DATE IS > HEADER EFF_DATE
RETEST_DATE > HEADER EFF_DATE ---- QUANTITY - ALLOC_QTY > 0
IF QC_REQD = 'Y' THEN ONLY EXPIRY DATE AND RETEST DATE TO BE CONSIDERED
*/
String available = "", backflushType = "", trackShelfLife = "";
String siteCode = "", itemCode = "", qcReqd = "";
String sql = "";
String expDate1 = "", retestDate1 = "", retestDt = "";
double totalQty = 0, allocQty = 0;
Timestamp expDate = null, retestDate = null;
PreparedStatement pstmt = null;
ResultSet rs = 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();
}
GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver();
try {
conn = connDriver.getConnectDB("DriverITM");
available = "('Y')";
siteCode = genericUtility.getColumnValue("site_code", dom);
itemCode = genericUtility.getColumnValue("item_code", dom);
backflushType = genericUtility.getColumnValue("backflush_type", dom1);
sql = "SELECT (CASE WHEN QC_REQD IS NULL THEN 'N' ELSE QC_REQD END), "
+ " (CASE WHEN TRACK_SHELF_LIFE IS NULL THEN 'N' ELSE TRACK_SHELF_LIFE END) "
+ " FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
qcReqd = rs.getString(1);
trackShelfLife = rs.getString(2);
}
rs.close();
pstmt.close();
if (trackShelfLife != null && trackShelfLife.equalsIgnoreCase("N") && qcReqd != null && qcReqd.equalsIgnoreCase("N"))
{
retestDt = genericUtility.getValidDateString("01/01/1910","dd/mm/yyyy", genericUtility.getApplDateFormat());
}
else
{
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
// ADDED BY ALKA ON 14/07/07 AS ERROR OCCURING FOR PARSING DATE
java.util.Date date = sdf.parse(new Timestamp(System.currentTimeMillis()).toString());
retestDate = Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
retestDt = (new SimpleDateFormat(genericUtility.getApplDateFormat())).format(retestDate).toString();
// COMMENTED BY ALKA ON 14/07/07 AS ERROR OCCURING FOR PARSING DATE
// retestDt = sdf.format(new Timestamp(System.currentTimeMillis()));
}
if (backflushType.equalsIgnoreCase("R"))
{
available = "('Y','N')";
}
// sql = " SELECT A.ITEM_SER, A.ITEM_CODE, A.UNIT, A.LOC_CODE, A.LOT_NO, A.LOT_SL, A.QUANTITY, "
sql = " SELECT A.ITEM_SER, A.ITEM_CODE, A.UNIT, A.LOC_CODE, A.LOT_NO, A.LOT_SL, A.QUANTITY - A.ALLOC_QTY AS QUANTITY, "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END) ALLOC_QTY, A.SITE_CODE, "
+ " A.EXP_DATE , A.RETEST_DATE, A.RATE, A.MFG_DATE, A.SITE_CODE__MFG, A.PACK_CODE, A.GRADE, "
+ " A.DIMENSION, A.GROSS_WEIGHT, A.TARE_WEIGHT, A.NET_WEIGHT FROM STOCK A, INVSTAT B "
+ " WHERE (A.INV_STAT = B.INV_STAT) "
+ " AND (( A.ITEM_CODE = '" + itemCode + "' ) AND (A.SITE_CODE = '" + siteCode + "' ) AND (A.QUANTITY > 0) AND (A.QUANTITY - "
+ " (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END) > 0 ) "
+ " AND B.AVAILABLE IN " + available + " AND (A.EXP_DATE IS NULL OR (A.EXP_DATE > ? )) "
+ " AND ( A.LOT_NO NOT IN ( SELECT LOT_NO FROM QC_ORDER WHERE SITE_CODE = '" + siteCode + "' AND ITEM_CODE = '" + itemCode + "' "
+ " AND STATUS = 'U' )) AND ( B.STAT_TYPE <> 'S' ))";
System.out.println("sql :: "+ sql);
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, Timestamp.valueOf(genericUtility.getValidDateString(retestDt, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat())+ " 00:00:00"));
rs = pstmt.executeQuery();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
while (rs.next())
{
expDate = rs.getTimestamp(10);
if (expDate != null)
{
expDate1 = sdf.format(expDate);
System.out.println("expDate1 :"+expDate1);
}
retestDate = rs.getTimestamp(11);
if (retestDate != null)
{
retestDate1 = sdf.format(retestDate);
System.out.println("retestDate1 :"+retestDate1);
}
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_ser>").append("<![CDATA[").append(rs.getString(1).trim()).append("]]>").append("</item_ser>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(rs.getString(2).trim()).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<unit>").append("<![CDATA[").append(rs.getString(3)).append("]]>").append("</unit>\r\n");
valueXmlString.append("<loc_code>").append("<![CDATA[").append(rs.getString(4).trim()).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(rs.getString(5).trim()).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl>").append("<![CDATA[").append(rs.getString(6).trim()).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(rs.getDouble(7)).append("]]>").append("</quantity>\r\n");
// valueXmlString.append("<alloc_qty>").append("<![CDATA[").append(rs.getDouble(8)).append("]]>").append("</alloc_qty>\r\n");*/
valueXmlString.append("<site_code>").append("<![CDATA[").append(rs.getString(9).trim()).append("]]>").append("</site_code>\r\n");
if (expDate != null)
{
valueXmlString.append("<exp_date>").append("<![CDATA[").append(expDate1).append("]]>").append("</exp_date>\r\n");
}
if (retestDate != null)
{
valueXmlString.append("<retest_date>").append("<![CDATA[").append(retestDate1).append("]]>").append("</retest_date>\r\n");
}
valueXmlString.append("<dimension>").append("<![CDATA[").append(rs.getString(11) == null?"":rs.getString(11).trim()).append("]]>").append("</dimension>\r\n");
valueXmlString.append("</Detail>\r\n");
}
pstmt.close();
rs.close();
valueXmlString.append("</Root>\r\n");
}//try end
catch (SQLException sqx) {
System.out.println("The SQLException occurs in RcptBackflushActEJB for Stock button :" + sqx);
throw new ITMException(sqx);
} catch (Exception e) {
System.out.println("The Exception occure in RcptBackflushActEJB for Stock button:" + e);
throw new ITMException(e);
} finally {
try {
conn.close();
conn = null;
} catch (Exception e) {
}
}
System.out.println("valueXmlString return from actionStock :" + valueXmlString.toString());
return valueXmlString.toString();
}
private String stockTransform(Document dom, Document dom1, String objContext, String xtraParams, Document selDataDom)
throws ITMException {
System.out.println("stockTransform is calling.............");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String sql = null, errCode = "", errString = "";
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String tranId = null, siteDescr = null, itemCode = null, itemDescr = null, unit = null;
String stkLocCode = null,stkLotNo = null, stkLotSl = null, locDescr = null;
String siteCode = null;
double quantity = 0, remainingQty = 0, inputQty = 0, stkQty = 0;
Node currDetail = null, currDetail1 = null;
ConnDriver connDriver = new ConnDriver();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
GenericUtility genericUtility = GenericUtility.getInstance();
try {
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
tranId = genericUtility.getColumnValue("tran_id", dom1);
siteCode = genericUtility.getColumnValue("site_code", dom1);
siteDescr = genericUtility.getColumnValue("site_descr", dom1);
itemCode = genericUtility.getColumnValue("item_code", dom);
itemDescr = genericUtility.getColumnValue("item_descr", dom);
quantity = Double.parseDouble(genericUtility.getColumnValue("quantity", dom));
NodeList detailList = selDataDom.getElementsByTagName("Detail");
int noOfDetails = detailList.getLength();
for (int ctr = 0; ctr < noOfDetails; ctr++) {
currDetail = detailList.item(ctr);
stkQty = stkQty + Double.parseDouble((genericUtility.getColumnValueFromNode("quantity", currDetail)));
}
System.out.println("stkQty :" + stkQty);
System.out.println("remainingQty :" + remainingQty);
// if (stkQty < quantity)
if (quantity != 0 && stkQty < quantity) //CHANGED BY ALKA 19/07/07 FOR HANDLING NO QUANTITY ENTERED.
{
errCode = "VTSTOCK1";
errString = itmDBAccessEJB.getErrorString("", errCode, "", "", conn);
conn.close();
conn = null;
return errString;
}
// remainingQty = quantity; //COMMENTED BY ALKA AS THE FOLLOWING LOGIC IS ADDED
// ADDED BY ALKA ON 19/07/07 FOR SELECTED STOCK TO BE ENTERED IN THE DETAIL IF THE QUANTITY IS 0
if (quantity == 0)
{
remainingQty = stkQty;
}
else
{
remainingQty = quantity;
}
System.out.println("quantity at the start of the forloop :::: " + quantity);
System.out.println("remainingQty at the start of the forloop :::: " + remainingQty);
// ADDITION ENDED BY ALKA 19/07/07
if (noOfDetails > 0)
{
for (int ctr = 0; ctr < noOfDetails && remainingQty > 0; ctr++)
{
valueXmlString.append("<Detail>\r\n");
currDetail1 = detailList.item(ctr);
stkLocCode = genericUtility.getColumnValueFromNode("loc_code", currDetail1);
stkLotNo = genericUtility.getColumnValueFromNode("lot_no", currDetail1);
stkLotSl = genericUtility.getColumnValueFromNode("lot_sl", currDetail1);
unit = genericUtility.getColumnValueFromNode("unit", currDetail1);
stkQty = Double.parseDouble(genericUtility.getColumnValueFromNode("quantity", currDetail1));
System.out.println("stkQty ==> :" + stkQty);
sql = "SELECT DESCR FROM LOCATION WHERE LOC_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, stkLocCode);
System.out.println("sql ::" + sql + " with stkLocCode :: " + stkLocCode);
rs = pstmt.executeQuery();
if (rs.next())
{
locDescr = rs.getString(1);
System.out.println("locDescr : " + locDescr);
}
rs.close();
pstmt.close();
if (stkQty >= remainingQty)
{
inputQty = remainingQty;
remainingQty = 0;
}
else if (stkQty < remainingQty)
{
inputQty = stkQty;
remainingQty = remainingQty - stkQty;
}
System.out.println("inputQty :: " + inputQty + " remainingQty :: " + remainingQty);
valueXmlString.append("<tran_id isSrvCallOnChg='0'>").append("<![CDATA[").append(tranId).append("]]>").append("</tran_id>\r\n");
valueXmlString.append("<site_code isSrvCallOnChg='0'>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>\r\n");
valueXmlString.append("<site_descr isSrvCallOnChg='0'>").append("<![CDATA[").append(siteDescr).append("]]>").append("</site_descr>\r\n");
valueXmlString.append("<item_code isSrvCallOnChg='0'>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr isSrvCallOnChg='0'>").append("<![CDATA[").append(itemDescr).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<unit isSrvCallOnChg='0'>").append("<![CDATA[").append(unit).append("]]>").append("</unit>\r\n");
valueXmlString.append("<loc_code isSrvCallOnChg='0'>").append("<![CDATA[").append(stkLocCode).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<location_descr isSrvCallOnChg='0'>").append("<![CDATA[").append(locDescr).append("]]>").append("</location_descr>\r\n");
valueXmlString.append("<unit__doc isSrvCallOnChg='0'>").append("<![CDATA[").append(unit).append("]]>").append("</unit__doc>\r\n");
valueXmlString.append("<lot_no isSrvCallOnChg='0'>").append("<![CDATA[").append(stkLotNo).append("]]>").append("</lot_no>\r\n");
//changed by ALKA on 12/09/07 for no_art column added in the receipt_backflush_set and itemChange enabled for lot_sl for request id "MF78GIN014"
// valueXmlString.append("<lot_sl isSrvCallOnChg='0'>").append("<![CDATA[").append(stkLotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<lot_sl isSrvCallOnChg='1'>").append("<![CDATA[").append(stkLotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<quantity isSrvCallOnChg='0'>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n");
valueXmlString.append("</Detail>");
System.out.println("remainingQty at the end of the forloop :::: " + remainingQty); //SOP ADDED BY ALKA TO CHECK THE REMAINING STOCK 19/07/07
if (remainingQty == 0)
{
break;
}
}// for end
}// end if
valueXmlString.append("</Root>");
}// end try
catch (ITMException itme) {
itme.printStackTrace();
throw itme;
} catch (Exception e) {
e.printStackTrace();
throw new ITMException(e);
} finally {
try {
System.out.println("Closing Connection...");
conn.close();
conn = null;
} catch (Exception e) {
}
}
System.out.println("valueXmlString from :" + valueXmlString.toString());
return valueXmlString.toString();
}
private String allocateItem(Document dom1, String siteCode, String itemCode, double quantity, String xtraParams)throws RemoteException, ITMException
{
String locDescr = null, itemDescr = null, sql = "", siteDescr = null, tranId = null;
String stkLocCode = null, stkLotNo = null, stkLotSl = null, unit = null;
String convReqd = null, bkflshType = null, convQty = null, convRate = null;
double remainingQty = 0d, inputQty = 0d, stkQtyLot = 0d, rate = 0;
PreparedStatement pstmt = null;
Connection conn = null;
ResultSet rs = null;
ConnDriver connDriver = new ConnDriver();
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
GenericUtility genericUtility = GenericUtility.getInstance();
MfgCommon mfgCommon = new MfgCommon();
DistCommon distCommon = new DistCommon();
try
{
conn = connDriver.getConnectDB("DriverITM");
System.out.println("[Allocating .....]");
sql = "SELECT DESCR FROM ITEM WHERE ITEM_CODE = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemDescr = rs.getString(1);
}
remainingQty = quantity; //added by rajendra
sql = " SELECT (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), A.UNIT, A.LOC_CODE, A.LOT_NO, "
+ " A.LOT_SL, A.RATE ,B.DESCR FROM STOCK A, LOCATION B, INVSTAT C WHERE A.LOC_CODE = B.LOC_CODE "
+ " AND ((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)) > 0 AND B.INV_STAT = C.INV_STAT "
+ " AND A.SITE_CODE = ? AND A.ITEM_CODE = ? "
+ " AND (CASE WHEN A.ALLOC_QTY IS NULL THEN 0 ELSE A.ALLOC_QTY END) >= 0 AND C.AVAILABLE = 'Y' "
+ " ORDER BY (CASE WHEN A.EXP_DATE IS NULL THEN A.CREA_DATE ELSE A.EXP_DATE END), A.CREA_DATE, "
+ " A.LOT_NO , A.LOT_SL";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteCode);
pstmt.setString(2, itemCode);
rs = pstmt.executeQuery();
while (rs.next())
{
stkQtyLot = rs.getDouble(1);
unit = rs.getString(2);
stkLocCode = rs.getString(3);
stkLotNo = rs.getString(4);
stkLotSl = rs.getString(5);
rate = rs.getDouble(6);
locDescr = rs.getString(7); //added by rajendra on 19/05/08
// remainingQty = quantity;
if (stkQtyLot >= remainingQty)
{
inputQty = remainingQty;
remainingQty = 0;
}
else
{
inputQty = stkQtyLot;
remainingQty = remainingQty - inputQty;
}
//commented by rajendra on 19/05/08
// sql = "SELECT DESCR FROM LOCATION WHERE LOC_CODE = ?";
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, stkLocCode);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// locDescr = rs.getString(1);
// }
// rs.close();
// pstmt.close();
siteDescr = genericUtility.getColumnValue("site_descr", dom1);
tranId = genericUtility.getColumnValue("tran_id", dom1);
bkflshType = genericUtility.getColumnValue("backflush_type", dom1);
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<tran_id>").append("<![CDATA[").append(tranId).append("]]>").append("</tran_id>\r\n");
valueXmlString.append("<site_code>").append("<![CDATA[").append(siteCode).append("]]>").append("</site_code>\r\n");
valueXmlString.append("<site_descr>").append("<![CDATA[").append(siteDescr).append("]]>").append("</site_descr>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
valueXmlString.append("<item_descr>").append("<![CDATA[").append(itemDescr).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<unit>").append("<![CDATA[").append(unit).append("]]>").append("</unit>\r\n");
valueXmlString.append("<loc_code>").append("<![CDATA[").append(stkLocCode).append("]]>").append("</loc_code>\r\n");
valueXmlString.append("<location_descr>").append("<![CDATA[").append(locDescr).append("]]>").append("</location_descr>\r\n");
valueXmlString.append("<unit__doc>").append("<![CDATA[").append(unit).append("]]>").append("</unit__doc>\r\n");
valueXmlString.append("<lot_no>").append("<![CDATA[").append(stkLotNo).append("]]>").append("</lot_no>\r\n");
//changed by ALKA on 12/09/07 for no_art column added in the receipt_backflush_set and itemChange enabled for lot_sl for request id "MF78GIN014"
// valueXmlString.append("<lot_sl>").append("<![CDATA[").append(stkLotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<lot_sl isSrvCallOnChg='1'>").append("<![CDATA[").append(stkLotSl).append("]]>").append("</lot_sl>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n");
valueXmlString.append("<rate>").append("<![CDATA[").append(rate).append("]]>").append("</rate>\r\n");
convReqd = mfgCommon.getEnvMfg("999999", "RBKFSH_CONV_REQD", conn);
if (convReqd.equalsIgnoreCase("NULLFOUND"))
{
convReqd = "Y";
}
if (convReqd.equalsIgnoreCase("Y") && bkflshType.equalsIgnoreCase("J"))
{
ArrayList convQtyList = new ArrayList();
ArrayList convRateList = new ArrayList();
convQtyList = distCommon.getConvQuantityFact(unit, "", itemCode, inputQty, 0, conn);
convQty = (String)convQtyList.get(1);
convRateList = distCommon.getConvQuantityFact(unit, "", itemCode, rate, 0, conn);
convRate = (String)convRateList.get(1);
valueXmlString.append("<conv_qty_doc>").append("<![CDATA[").append("0").append("]]>").append("</conv_qty_doc>\r\n");
valueXmlString.append("<qty_doc>").append("<![CDATA[").append(convQty).append("]]>").append("</qty_doc>\r\n");
valueXmlString.append("<rate_doc>").append("<![CDATA[").append(convRate).append("]]>").append("</rate_doc>\r\n");
}
valueXmlString.append("</Detail>");
if (remainingQty == 0)
{
break;
}
}
valueXmlString.append("</Root>\r\n");
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in RcptBackflushActEJB :(Allocate) Button :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch (Exception e)
{
System.out.println("The Exception occurs in RcptBackflushActEJB : (Allocate) Button :"+e);
throw new ITMException(e);
}
finally
{
try
{
conn.close();
conn = null;
}
catch (Exception e){}
}
System.out.println("valueXmlString return from RcptBackflushActEJB :"+valueXmlString.toString());
return valueXmlString.toString();
}
private String updateMessage(String resultString,String message)
{
StringBuffer stbf = new StringBuffer();
try{
System.out.println("resultString : "+resultString);
stbf.append(resultString.substring(0,resultString.indexOf("<trace>")));
if(message != null && message.trim().length() > 0){
stbf.append("<trace>"+message+"</trace>");
stbf.append(resultString.substring(resultString.indexOf("</trace>")+8));
}else{
stbf.append(resultString.substring(resultString.indexOf("<trace>")));
}
System.out.println("Resulting String : "+stbf.toString());
}catch(Exception e){
System.out.println("Exception in updateMessage : "+e);
e.printStackTrace();
}
return stbf.toString();
}
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface RcptBackflushActLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface RcptBackflushActRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.util.*;
import java.sql.*;
import java.rmi.RemoteException;
import java.text.*;
import javax.ejb.SessionContext;
import javax.ejb.CreateException;
//import javax.ejb.SessionBean;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.ejb.fin.FinCommon;
import ibase.webitm.ejb.fin.FinCommonInvAcct;
import ibase.webitm.utility.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WOMultipRcpConf extends ActionHandlerEJB implements WOMultipRcpConfLocal , WOMultipRcpConfRemote //SessionBean
{
/*public void ejbCreate() throws RemoteException,CreateException{
}
public void ejbRemove(){
}
public void ejbActivate(){
}
public void ejbPassivate(){
}*/
public void setSessionContext(SessionContext se){
}
public String confirm(String tranID,String xtraParams, String forcedFlag) throws RemoteException,ITMException
{
Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null;
String sql = "";
ConnDriver connDriver = null;
String rcpDimension = "";
long rcpNoArt = 0;
long stkNoArt = 0;
java.sql.Timestamp stkRetestDate = null;
String acctCodeDr = "",cctrCodeDr = "",acctCodeCr = "",cctrCodeCr = "",workOrder="";
String itemSer = "",itemStru = "";
String errString = "",backFlushType = "",unitAlt = "",siteCodeHdr = "";
double quantity=0,quantity1=0,sumQuantity=0,QuantityWO=0,remQuantity=0;
Timestamp tranDate = null;
HashMap stkUpdMap = null,hm;
String itemCodenew="",returnString="",item_type="",item_ser="",loc_type ="";
String itemCode="",locCode="",lotNo="",lotSl="",lineNo="",unit="",rcpConfirm = "";
ITMDBAccessEJB itmDBAccessEJB = null;
ArrayList arrayList =new ArrayList();
FinCommon finCommon = null;
GenericUtility genericUtility = null;
FinCommonInvAcct finCommonInvAcct = null;
int count=0;
try{
finCommon = new FinCommon();
finCommonInvAcct = new FinCommonInvAcct();
itmDBAccessEJB = new ITMDBAccessEJB();
genericUtility = GenericUtility.getInstance();
stkUpdMap = new HashMap();
connDriver = new ConnDriver();
conn = connDriver.getConnectDB("Driver");
conn.setAutoCommit(false);
sql = "select confirmed,site_code,tran_date,work_order,quantity from workorder_receipt where tran_id = '"+tranID+"'";
System.out.println("SQL : "+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
rcpConfirm = rs.getString("confirmed");
siteCodeHdr = rs.getString("site_code");
tranDate = rs.getTimestamp("tran_date");
workOrder = rs.getString("work_order");
quantity1 = rs.getDouble("quantity");
}
rs.close();
pstmt.close();
count=0;
// sql ="select count(*) from workorder_receipt where work_order ='"+workOrder+"' and "
// +" confirmed ='Y' ";
// System.out.println("sql-------------"+sql);
//
// pstmt = conn.prepareStatement(sql);
// rs = pstmt.executeQuery();
// if(rs.next())
// {
// count=rs.getInt(1);
//
// }
// rs.close();
// pstmt.close();
// System.out.println("count-------------"+count);
// if(count != 0)
// {
//
// errString = itmDBAccessEJB.getErrorString("","VTWOCONF","BASE");
// return errString;
// }
sql ="select sum(quantity) from workorder_receipt where work_order ='"+workOrder+"' and "
+" confirmed ='Y' ";
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
sumQuantity=rs.getDouble(1);
}
rs.close();
pstmt.close();
System.out.println("sumQuantity-------------"+sumQuantity);
sql ="select quantity from workorder where work_order ='"+workOrder+"' " ;
System.out.println("sql-------------"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
QuantityWO=rs.getDouble(1);
}
rs.close();
pstmt.close();
System.out.println("QuantityWO-------------"+QuantityWO);
remQuantity=QuantityWO-sumQuantity;
if(remQuantity < quantity1)
{
errString = itmDBAccessEJB.getErrorString("","VTWOQUTY","BASE");
return errString;
}
if(rcpConfirm != null && rcpConfirm.trim().equalsIgnoreCase("Y"))
{
System.out.println("The Selected ransaction is already confirmed..........");
errString = itmDBAccessEJB.getErrorString("","VTCONF8","","",conn);
return errString;
}
String acctCodeHdr = "",cctrCodeHdr = "";
sql = "select item_code,loc_code,lot_no,lot_sl,line_no,quantity,unit from workorder_rcp_det "
+" where tran_id = '"+tranID+"'";
System.out.println(" sql................"+sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next())
{
itemCode = rs.getString("item_code");
locCode = rs.getString("loc_code");
lotNo = rs.getString("lot_no");
lotSl = rs.getString("lot_sl");
lineNo = rs.getString("line_no");
quantity =rs.getDouble("quantity");
unit =rs.getString("unit");
sql = "select item_ser from item where item_code = '"+itemCode+"'";
System.out.println("SQL : "+sql);
pstmt = conn.prepareStatement(sql);
rs1 = pstmt.executeQuery();
if(rs1.next())
{
itemSer = rs1.getString("item_ser");
}
rs1.close();
String acctCodeInv="";
String cctrCodeInv="";
System.out.println("itemSer-------------"+itemSer);
String acctDetrType = finCommon.getFromAcctDetr(itemCode,itemSer,"STKINV", conn) ;
System.out.println("acctDetrType.....STKINV........" + acctDetrType);
if (acctDetrType != null && acctDetrType.trim().length() > 0)
{
acctCodeInv = acctDetrType.substring(0,acctDetrType.indexOf(","));
cctrCodeInv = acctDetrType.substring(acctDetrType.indexOf(",")+1);
}
System.out.println("acctStr.....STKINV........" + acctCodeInv);
System.out.println("acctStr.....STKINV........" + cctrCodeInv);
stkUpdMap.put("site_code",siteCodeHdr);
stkUpdMap.put("item_code",itemCode);
stkUpdMap.put("loc_code",locCode);
stkUpdMap.put("lot_no",lotNo);
stkUpdMap.put("lot_sl",lotSl);
stkUpdMap.put("unit",unit);
stkUpdMap.put("quantity",Double.toString(quantity));
stkUpdMap.put("qty_stduom",Double.toString(quantity));
stkUpdMap.put("tran_type","R");
stkUpdMap.put("tran_date",tranDate);
stkUpdMap.put("tran_ser","W-RCP");
stkUpdMap.put("tran_id",tranID);
stkUpdMap.put("line_no",lineNo);
stkUpdMap.put("rate",Double.toString(0));
stkUpdMap.put("gross_rate",Double.toString(0));
stkUpdMap.put("sitecode_mfg",siteCodeHdr);
stkUpdMap.put("potency_perc",Double.toString(0));
stkUpdMap.put("mfg_date",tranDate);
stkUpdMap.put("acct_code_inv",acctCodeInv);
stkUpdMap.put("cctr_code_inv",cctrCodeInv);
stkUpdMap.put("rate_oh",Double.toString(0));
stkUpdMap.put("acct_code_oh",acctCodeInv);
stkUpdMap.put("cctr_code_oh",cctrCodeInv);
stkUpdMap.put("dimension"," ");
stkUpdMap.put("no_art",Double.toString(1));
stkUpdMap.put("grade","LOC");
stkUpdMap.put("batch_no",lotNo);
StockUpdate stkUpd = new StockUpdate();
errString = stkUpd.updateStock(stkUpdMap,xtraParams,conn);
System.out.println("Returning Result "+errString);
stkUpd = null;
stkUpdMap.clear();
}//while end (Issue)
rs.close();
pstmt.close();
stkUpdMap.clear();
if(errString !=null && errString.indexOf("Error") != -1)
{
System.out.println("Returning Result "+errString);
conn.rollback();
return errString;
}
System.out.println("errString : "+errString);
String empCodeAprv = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginEmpCode");
sql = "update workorder_receipt set confirmed = 'Y',conf_date = ? ,emp_code__aprv = ? where tran_id = '"+tranID+"' ";
System.out.println("SQL : "+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1,new Timestamp(System.currentTimeMillis()));
pstmt.setString(2,empCodeAprv);
int upd = pstmt.executeUpdate();
System.out.println("Receipt Multi Confirm :: "+upd);
if(upd > 0)
{
conn.commit();
errString = itmDBAccessEJB.getErrorString("","VTDIST30","");
System.out.println("Receipt Multi Confirmed .."+errString);
}
}catch(ITMException ie)
{
System.out.println("ITMException : "+ie);
try{conn.rollback();}catch(Exception t){}
ie.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From RcpBackflushMultiConf :"+errString);
return errString;
}catch(Exception e){
System.out.println("Exception in Confirm [RcpBackflushConfEJB]"+e);
try{conn.rollback();}catch(Exception t){}
e.printStackTrace();
errString = itmDBAccessEJB.getErrorString("","VTDESNCONF","","",conn);
System.out.println("Returnng String From RcpBackflushMultiConf :"+errString);
return errString;
}
finally
{
try{
stkUpdMap = null;
if(rs != null){rs.close();rs = null;}
if(rs1 != null){rs1.close();rs1 = null;}
if(conn != null)
{
conn = null;
}
}catch(Exception e){System.out.println("Exception : "+e);e.printStackTrace();}
}
System.out.println("Returnng String From RcpBackflushMultiConf :"+errString);
return errString;
}
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerLocal;
import ibase.webitm.utility.ITMException;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WOMultipRcpConfLocal extends ActionHandlerLocal//,EJBObject
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.ejb.ActionHandlerRemote;
import ibase.webitm.utility.ITMException;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WOMultipRcpConfRemote extends ActionHandlerRemote//, EJBObject
{
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException,ITMException;
}
This source diff could not be displayed because it is too large. You can view the blob instead.
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WOrderIssueActLocal extends ActionHandlerLocal//,EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ActionHandlerRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WOrderIssueActRemote extends ActionHandlerRemote//, EJBObject
{
public String actionHandler() throws RemoteException,ITMException;
public String actionHandler(String actionType, String xmlString, String xmlString1, String objContext, String xtraParams) throws RemoteException,ITMException;
}
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import javax.xml.transform.*;
import javax.xml.transform.dom.*;
import org.xml.sax.InputSource;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.Transformer;
import javax.xml.transform.stream.StreamSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.TransformerException;
import javax.xml.transform.TransformerConfigurationException;
import java.rmi.RemoteException;
import java.util.*;
import java.util.Date;
import java.sql.*;
import java.io.*;
import org.omg.CORBA.ORB;
import org.w3c.dom.*;
import java.util.Properties;
import javax.xml.parsers.*;
import javax.ejb.*;
import javax.naming.InitialContext;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.*;
import ibase.webitm.utility.TransIDGenerator;
import ibase.utility.CommonConstants;
import ibase.ejb.*;
import ibase.system.config.*;
import java.text.SimpleDateFormat;
import java.util.*;
import javax.ejb.Stateless; // added for ejb3
@Stateless // added for ejb3
public class WorkorderPrc extends ProcessEJB implements WorkorderPrcLocal,WorkorderPrcRemote //SessionBean
{
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
CommonConstants commonConstants = new CommonConstants();
Connection conn = null;
StringBuffer retBuf = null;
String itemCode=null;
String itemDescr=null;
String mfgType=null;
String dueDate=null;
String siteCode=null;
String errorString=null;
String loginCode=null;
String chgTerm=null;
int quantity=0;
int demand=0;
int minQty=0;
int maxQty=0;
int batches=0;
double amount=0.0;
double demandAmt=0.0;
/*public void ejbCreate() throws RemoteException, CreateException
{
}
public void ejbRemove()
{
}
public void ejbActivate()
{
}
public void ejbPassivate()
{
}*/
public String process() throws RemoteException,ITMException
{
return "";
}
//=>getData Method
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException
{
System.out.println("WorkorderPrcEJB :getData() function called");
String rtrStr = "";
Document headerDom = null;
Document detailDom = null;
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
System.out.println("XML String :"+xmlString);
headerDom = genericUtility.parseString(xmlString);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
System.out.println("XML String :"+xmlString2);
detailDom = genericUtility.parseString(xmlString2);
}
rtrStr = getData(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :WorkorderPrcEJB :getData(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
rtrStr = e.getMessage();
}
return rtrStr;
}//END OF GETDATA(1)
public String getData(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
String errString=null;
String errCode = "";
String getDataSql= "" ;
String sql= "" ;
String resultString = "";
ResultSet rs1 = null;
PreparedStatement pstmt = null;
Statement st = null;
StringBuffer retTabSepStrBuff = new StringBuffer();
String siteCode=null;
java.util.HashMap refMap = new java.util.HashMap();
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
}
catch (Exception e)
{
System.out.println("Exception :WorkorderPrcEJB :ejbCreate :==>"+e);
e.printStackTrace();
}
try
{
siteCode = genericUtility.getColumnValue("site_code",headerDom);
if(siteCode!=null && siteCode.equals(""))
{
siteCode = "";
System.out.println("Site Code From is Null...");
errString = itmDBAccessEJB.getErrorString("","VTMRPPARM","","",conn);
return errString;
}
if ( siteCode == null || siteCode.trim().length() == 0 )
{
siteCode = "";
System.out.println("Site Code From is Null...");
errString = itmDBAccessEJB.getErrorString("","VTMRPPARM","","",conn);
return errString;
}
if((commonConstants.DB_NAME).equalsIgnoreCase("ORACLE"))
{
getDataSql="SELECT A.ITEM_CODE,C.DESCR,(CASE WHEN RTRIM(B.MFG_TYPE) IS NULL THEN RTRIM(C.MFG_TYPE)ELSE RTRIM(B.MFG_TYPE) END) "
+" AS MFG_TYPE,A.DUE_DATE,(CASE WHEN B.MIN_QTY IS NULL THEN C.MIN_QTY ELSE B.MIN_QTY END )"
+" AS MIN_QTY,(CASE WHEN B.MAX_QTY IS NULL THEN C.MAX_QTY ELSE B.MAX_QTY END)AS MAX_QTY,"
+" A.QUANTITY,A.DEMAND_QTY,A.SITE_CODE,A.TRAN_ID,"
+" CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END * CASE WHEN DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,null,'L') IS NULL THEN 0 ELSE "
+" DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,null,'L') END AS AMOUNT ,"
+" CASE WHEN A.DEMAND_QTY IS NULL THEN 0 ELSE A.DEMAND_QTY END * CASE WHEN "
+" DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,null,'L') IS NULL THEN 0 ELSE "
+" DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,null,'L') END AS DEMAND_AMT "
+" FROM MPS_ORDER A,SITEITEM B,ITEM C "
+" WHERE ( A.ITEM_CODE = B.ITEM_CODE (+)) AND "
+" ( A.SITE_CODE = B.SITE_CODE (+)) AND ( A.ITEM_CODE = C.ITEM_CODE ) "
+" AND ( ( A.STATUS <> 'C' ) AND ( A.SITE_CODE =?) )";
}
else if((commonConstants.DB_NAME).equalsIgnoreCase("DB2")||(commonConstants.DB_NAME).equalsIgnoreCase("MSSQL"))
{
getDataSql="SELECT A.ITEM_CODE ,C.DESCR ,(CASE WHEN RTRIM(B.MFG_TYPE) IS NULL THEN RTRIM(C.MFG_TYPE)ELSE RTRIM(B.MFG_TYPE) END) "
+" AS MFG_TYPE,A.DUE_DATE ,(CASE WHEN B.MIN_QTY IS NULL THEN C.MIN_QTY ELSE B.MIN_QTY END )AS"
+" MIN_QTY,(CASE WHEN B.MAX_QTY IS NULL THEN C.MAX_QTY ELSE B.MAX_QTY END)AS MAX_QTY,"
+" A.QUANTITY ,A.DEMAND_QTY ,A.SITE_CODE ,A.TRAN_ID, "
+" CASE WHEN A.QUANTITY IS NULL THEN 0 ELSE A.QUANTITY END * CASE WHEN DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,' ','L') IS NULL THEN 0 ELSE "
+" DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,' ','L') END AS AMOUNT ,"
+" CASE WHEN A.DEMAND_QTY IS NULL THEN 0 ELSE A.DEMAND_QTY END * CASE WHEN "
+" DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,' ','L') IS NULL THEN 0 ELSE "
+" DDF_PICK_RATE(ddf_get_mrp_plist(),(fn_sysdate()),a.item_code,' ','L') END AS DEMAND_AMT "
+" FROM MPS_ORDER A LEFT OUTER JOIN SITEITEM B ON A.ITEM_CODE = B.ITEM_CODE AND "
+" A.SITE_CODE = B.SITE_CODE , ITEM C "
+" WHERE ( A.ITEM_CODE = C.ITEM_CODE) AND ( ( A.STATUS <> 'C' ) "
+" AND ( A.SITE_CODE = ? ) ) ";
}
System.out.println("getDataSql..."+ getDataSql);
pstmt = conn.prepareStatement(getDataSql);
pstmt.setString(1,siteCode);
rs1 = pstmt.executeQuery();
while(rs1.next())
{
System.out.println("Inside while...");
//item code
retTabSepStrBuff.append(rs1.getString(1)).append("\t");
//ITEM DESC
retTabSepStrBuff.append(rs1.getString(2)).append("\t");
//mfg TYPE
retTabSepStrBuff.append(rs1.getString(3)).append("\t");
//DUE_DATE
dueDate=this.genericUtility.getValidDateString(rs1.getTimestamp(4).toString(),this.genericUtility.getDBDateFormat(),this.genericUtility.getApplDateFormat());
retTabSepStrBuff.append(dueDate).append("\t");
//min_qty
retTabSepStrBuff.append(rs1.getDouble(5)).append("\t");
//max_qty
retTabSepStrBuff.append(rs1.getDouble(6)).append("\t");
//Quantity
retTabSepStrBuff.append(rs1.getDouble(7)).append("\t");
//demand qty
retTabSepStrBuff.append(rs1.getDouble(8)).append("\t");
//site_code
retTabSepStrBuff.append(rs1.getString(9)).append("\t");
//for tranid
retTabSepStrBuff.append(rs1.getString(10)).append("\t");
//FOR AMOUNT
retTabSepStrBuff.append(rs1.getDouble(11)).append("\t");
//FOR DEMAND AMOUNT
retTabSepStrBuff.append(rs1.getDouble(12)).append("\t");
retTabSepStrBuff.append("\n");
}
resultString = retTabSepStrBuff.toString();
System.out.println("ResultString....." + resultString);
rs1.close();
pstmt.close();
}
catch (SQLException e)
{
System.out.println("SQLException :WorkorderPrcEJB :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
catch (Exception e)
{
System.out.println("Exception :WorkorderPrcEJB :getData(Document headerDom, Document detailDom, String windowName, String xtraParams):" + e.getMessage() + ":");
throw new ITMException(e);
}
finally
{
try
{
retTabSepStrBuff = null;
if(conn != null && !conn.isClosed())
{
if(rs1 != null)
{
rs1.close();
rs1=null;
}
if(pstmt != null)
{
pstmt.close();
pstmt=null;
}
conn.rollback();
conn.close();
}
}
catch(Exception e)
{
errString = e.getMessage();
e.printStackTrace();
throw new ITMException(e);
}
}
return resultString;
}//END OF GETDATA(2)
public String process(String xmlString, String xmlString2, String windowName, String xtraParams)
throws RemoteException,ITMException
{
Document detailDom = null;
Document headerDom = null;
GenericUtility genericUtility = GenericUtility.getInstance();
String retStr = "";
try
{
System.out.println("xmlString[process]::::::::::;;;"+xmlString);
System.out.println("xmlString2[process]::::::::::;;;"+xmlString2);
System.out.println("windowName[process]::::::::::;;;"+windowName);
System.out.println("xtraParams[process]:::::::::;;;"+xtraParams);
}
catch(Exception e)
{
System.out.println(e.getMessage());
e.printStackTrace();
}
try
{
if(xmlString != null && xmlString.trim().length()!=0)
{
headerDom = genericUtility.parseString(xmlString);
System.out.println("headerDom" + headerDom);
}
if(xmlString2 != null && xmlString2.trim().length()!=0)
{
detailDom = genericUtility.parseString(xmlString2);
System.out.println("detailDom" + detailDom);
}
retStr = process(headerDom, detailDom, windowName, xtraParams);
}
catch (Exception e)
{
System.out.println("Exception :WorkorderPrcEJB :process(String xmlString, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
retStr = e.getMessage();
}
return retStr;
}//END OF PROCESS (1)
public String process(Document headerDom, Document detailDom, String windowName, String xtraParams) throws RemoteException,ITMException
{
int updCnt = 0;
int parentNodeListLength = 0;
int childNodeListLength = 0;
String errString=null;
String childNodeName = "";
String siteCode = null;//this.siteCode;
String itemCode=null;//for item code
String dueDate=null;//for due date
String tranId1=null;//for tran id
String siteCode1=null;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
Node childNode = null;
ArrayList tranList = new ArrayList();
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
loginCode=genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
loginCode=blanknull(loginCode).trim();
chgTerm=genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
chgTerm=blanknull(chgTerm).trim();
System.out.println("[WorkorderPrc][loginCode]=>"+loginCode);
System.out.println("[WorkorderPrc][chgTerm]=>"+chgTerm);
siteCode1 = genericUtility.getColumnValue("site_code",headerDom); //from header
System.out.println("[WorkorderPrc][SiteCode]=>"+siteCode1);
siteCode1=blanknull(siteCode1).trim();
parentNodeList = detailDom.getElementsByTagName("Detail2");
parentNodeListLength = parentNodeList.getLength();
System.out.println("parentNodeListLength:::::::::"+parentNodeListLength);
for (int selectedRow = 0; selectedRow < parentNodeListLength; selectedRow++)
{
parentNode = parentNodeList.item(selectedRow);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
System.out.println("childNodeListLength::: "+ childNodeListLength+"\n");
for (int childRow = 0; childRow < childNodeListLength; childRow++)
{
childNode = childNodeList.item(childRow);
childNodeName = childNode.getNodeName();
if (childNodeName.equals("tran_id"))
{
tranId1 = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("item_code"))
{
itemCode = childNode.getFirstChild().getNodeValue();
}
if (childNodeName.equals("due_date"))
{
dueDate = childNode.getFirstChild().getNodeValue();
}
}//inner for loop
tranList.add(tranId1);
System.out.println("[workorderPrc]tranId=>"+tranId1);
/*errorString=calWorkorderPrc(tranId1,conn);
if(errorString!=null)
{
try
{
conn.rollback();
System.out.println("Connection is roll back");
break;
}
catch(Exception d)
{
System.out.println("Exception : WorkorderPrcEJB =>"+d.toString());
d.printStackTrace();
break;
}
}//end of if*/
}// OUT FOR LOOP
errString=calWorkorderPrc(tranList,conn);
if(errString !=null && errString.trim().length() > 0 )
{
try
{
conn.rollback();
System.out.println("Connection is roll back");
//break;
}
catch(Exception d)
{
System.out.println("Exception : WorkorderPrcEJB =>"+d.toString());
d.printStackTrace();
//break;
}
}//end of if
else
{
try
{
System.out.println("Connection Commited");
conn.commit();
errString= itmDBAccessEJB.getErrorString("","VTSUCC","","",conn);
System.out.println("errString from itmDBAccessEJB " + errString) ;
}
catch(Exception d)
{
System.out.println("Exception : WorkorderPrcEJB =>"+d.toString());
d.printStackTrace();
//break;
}
}
}//try end
catch(Exception e)
{
try
{
conn.rollback();
}
catch(Exception d)
{
System.out.println("Exception : WorkorderPrcEJB =>"+d.toString());
d.printStackTrace();
}
System.out.println("Exception :WorkorderPrcEJB :process(String xmlString2, String xmlString2, String windowName, String xtraParams):" + e.getMessage() + ":");
e.printStackTrace();
errString = e.getMessage();
return errString ;
}
finally
{
System.out.println("errorString...." + errString);
System.out.println("Closing Connection....");
try
{
if(conn != null && !conn.isClosed())
{
conn.rollback();
conn.close();
conn = null;
}
}
catch(Exception e)
{
errString = e.getMessage();
e.printStackTrace();
return errString ;
}
}
System.out.println("Error Message=>"+errString);
return errString;
}//END OF PROCESS(2)
private String calWorkorderPrc(ArrayList tranList,Connection conn)
{
ResultSet rs1 = null,rsSql1=null,rsSql2=null;
PreparedStatement pstmt = null,pstmtInsert=null,pstmtUpdate=null,pstmtSql1=null,pstmtSql2=null;
int i=0;
double quantity=0.0;
double yieldPerc=0.0;
String workOrder=null;
String orderType=null;
String routeCode=null;
String bomCode=null;
String unit=null;
String mrpRunId=null;
String acctCodeWp=null;
String cctrCodeWp=null;
String addnOrder=null;
String planDueDate=null;
String tranId=null;
String dbdate=null;
String tranId_db=null;
String itemSer=null;
String siteCode=null;
String itemCode=null;
String dueDate=null;
String tranDate=null;
String itemSer1=null,itemSer2=null,strResult=null;
String xmlValues = "";
String feedBackValue=null;
StringTokenizer st=null;//for itemSeries
ArrayList ar=new ArrayList();
Timestamp chgDate=null;
GenericUtility genericUtility = GenericUtility.getInstance();
String tranId1 = null; //blanknull(tranId1).trim();
String sqlSelect = " SELECT WORK_ORDER,ORDER_TYPE,QUANTITY,YIELD_PERC, ROUTE_CODE, "
+" BOM_CODE, UNIT, MRP_RUN_ID, ACCT_CODE__WP, CCTR_CODE__WP,ADDN_ORDER,"
+" PLAN_DUE_DATE,TRAN_ID,SITE_CODE,ITEM_CODE,DUE_DATE "
+" FROM MPS_ORDER WHERE TRAN_ID=?";
String sqlInsert = "INSERT INTO WORKORDER(WORK_ORDER,ORDER_TYPE,QUANTITY,YIELD_PERC,ROUTE_CODE,BOM_CODE,"
+" UNIT,MRP_RUN_ID,ACCT_CODE__WP,CCTR_CODE__WP,ADDN_ORDER,PLAN_DUE_DATE,TRAN_ID,SITE_CODE,"
+" ITEM_CODE,ORD_DATE,DUE_DATE,STATUS,STATUS_DATE,FEEDBACK_REQD,CHG_DATE,CHG_USER,CHG_TERM,QUANTITY__RCVD,"
+" CURRENT_BATCH_QTY,UNIT__STD,STD_QTY,CONV__QTY_STDUOM,QUANTITY__MPS,TRAN_ID__MPS) "
+" VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
String sqlUpdate = " UPDATE MPS_ORDER SET STATUS = 'C' WHERE TRAN_ID =?" ;
String sql1="SELECT VAR_VALUE FROM MFGPARM WHERE PRD_CODE='999999' AND VAR_NAME='PROC_FDBK_INTEGRATED'";
String sql2=null;
System.out.println("[WorkorderPrc]calWorkorderPrc() method called");
try
{
//=========Code to seperate tokens and add to array list===============
pstmtSql1=conn.prepareStatement(sql1);
rsSql1=pstmtSql1.executeQuery();
while(rsSql1.next())
{
strResult=rsSql1.getString(1);
st=new StringTokenizer(strResult,",");
while(st.hasMoreElements())
{
ar.add(st.nextToken());//tokens are added to array list
}
}
rsSql1.close();//close rsSql1
pstmtSql1.close();//close pstmtSql1
//=================================================
pstmtInsert=conn.prepareStatement(sqlInsert);
pstmt = conn.prepareStatement(sqlSelect);
pstmtUpdate = conn.prepareStatement(sqlUpdate);
for (int ctr = 0; ctr < tranList.size(); ctr++)
{
tranId1 = (String) tranList.get(ctr);
pstmt.setString(1,tranId1.trim());
rs1 = pstmt.executeQuery();
while(rs1.next())
{
workOrder=rs1.getString(1);
orderType=rs1.getString(2);
quantity=rs1.getDouble(3);
yieldPerc=rs1.getDouble(4);
routeCode=rs1.getString(5);
bomCode=rs1.getString(6);
unit=rs1.getString(7);
mrpRunId=rs1.getString(8);
acctCodeWp=rs1.getString(9);
cctrCodeWp=rs1.getString(10);
addnOrder=rs1.getString(11);
planDueDate=rs1.getString(12);
tranId_db=rs1.getString(13);//selected from mps_order table
siteCode=rs1.getString(14);//for sitecode
itemCode=rs1.getString(15);//for itemcode
dueDate=rs1.getString(16);//for dueDate
//=====FUNCTION blanknull() is to avoid NullPointerException==========
workOrder=blanknull(workOrder);
orderType=blanknull(orderType);
routeCode=blanknull(routeCode);
bomCode=blanknull(bomCode);
unit=blanknull(unit);
mrpRunId=blanknull(mrpRunId);
acctCodeWp=blanknull(acctCodeWp);
cctrCodeWp=blanknull(cctrCodeWp);
addnOrder=blanknull(addnOrder);
planDueDate=blanknull(planDueDate);
tranId_db=blanknull(tranId_db);
siteCode=blanknull(siteCode);
itemCode=blanknull(itemCode);
dueDate=blanknull(dueDate);
tranDate=genericUtility.getValidDateString(new Timestamp(System.currentTimeMillis()).toString(),
genericUtility.getDBDateFormat(),
genericUtility.getApplDateFormat());
tranDate=blanknull(tranDate);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<work_order>"+workOrder.trim()+"</work_order>";
xmlValues = xmlValues + "<site_code>"+siteCode.trim()+"</site_code>";
xmlValues = xmlValues + "<ord_date>"+tranDate.trim()+"</ord_date>";
xmlValues = xmlValues + "<order_type>"+orderType.trim()+"</order_type>";
xmlValues = xmlValues + "</Detail1></Root>";
tranId = generateTranId("w_worder",xmlValues);//function to generate NEW transaction id
//tranId = generateTranId("w_work_order",xmlValues);//function to generate NEW transaction id
if(tranId==null || blanknull(tranId).trim().equals("") || tranId.equalsIgnoreCase("error"))
{
errorString="Error Occured";
break;
}
//************* if tranidfenerator returned error what?
System.out.println("[WorkorderPrcEJB][workorder]=>"+workOrder);
System.out.println("[WorkorderPrcEJB][orderType]=>"+orderType);
System.out.println("[WorkorderPrcEJB][quantity]=>"+quantity);
System.out.println("[WorkorderPrcEJB][yieldPerc]=>"+yieldPerc);
System.out.println("[WorkorderPrcEJB][routeCode]=>"+routeCode);
System.out.println("[WorkorderPrcEJB][bomCode]=>"+bomCode);
System.out.println("[WorkorderPrcEJB][unit]=>"+unit);
System.out.println("[WorkorderPrcEJB][mrpRunId]=>"+mrpRunId);
System.out.println("[WorkorderPrcEJB][acctCodeWp]=>"+acctCodeWp);
System.out.println("[WorkorderPrcEJB][cctrCodeWp]=>"+cctrCodeWp);
System.out.println("[WorkorderPrcEJB][addnOrder]=>"+addnOrder);
System.out.println("[WorkorderPrcEJB][planDueDate]=>"+planDueDate);
System.out.println("[WorkorderPrcEJB][tranId]=>"+tranId);
System.out.println("[WorkorderPrcEJB][siteCode]=>"+siteCode);
System.out.println("[WorkorderPrcEJB][itemCode]=>"+itemCode);
System.out.println("[WorkorderPrcEJB][dueDate]=>"+dueDate);
System.out.println("[WorkorderPrcEJB][tranDate]=>"+tranDate);
System.out.println("[WorkorderPrcEJB][tranIddb]=>"+tranId_db);
pstmtInsert.setString(1,tranId.trim());//for work_order
pstmtInsert.setString(2,orderType.trim());//for ordertype
pstmtInsert.setDouble(3,quantity);//for quantity
pstmtInsert.setDouble(4,yieldPerc);//for yield_perc
if(routeCode.equalsIgnoreCase("null"))
{
pstmtInsert.setNull(5,java.sql.Types.VARCHAR);
}
else
{
pstmtInsert.setString(5,routeCode);//for route_code
}
pstmtInsert.setString(6,bomCode.trim());//for bom_code
pstmtInsert.setString(7,unit.trim());//for unit
pstmtInsert.setString(8,mrpRunId.trim());//for mrs_run_id
pstmtInsert.setString(9,acctCodeWp.trim());//for acct_code_wp
pstmtInsert.setString(10,cctrCodeWp.trim());//for cctr_code_wp
pstmtInsert.setString(11,addnOrder.trim());//for addn_order
//conversion of date from string to timestamp
if (planDueDate != null && planDueDate.trim().length() > 0 )
{
chgDate=java.sql.Timestamp.valueOf(planDueDate.trim());
}
else
{
chgDate = java.sql.Timestamp.valueOf(dueDate.trim());
}
pstmtInsert.setTimestamp(12,chgDate);//for plan_duedate
pstmtInsert.setString(13,tranId.trim());//for tranid
pstmtInsert.setString(14,siteCode.trim());//for site_code
pstmtInsert.setString(15,itemCode.trim());//for item_code
System.out.println("[WorkorderPrc]=>"+java.sql.Timestamp.valueOf(getCurrdateAppFormat().toString()));
pstmtInsert.setTimestamp(16,java.sql.Timestamp.valueOf(getCurrdateAppFormat().toString()));//for ord_date
pstmtInsert.setTimestamp(17,java.sql.Timestamp.valueOf(dueDate.trim()));//for due_date
pstmtInsert.setString(18,"P");//for status
pstmtInsert.setTimestamp(19,new Timestamp(System.currentTimeMillis()));//for status_date
sql2="SELECT ITEM_SER FROM ITEM WHERE ITEM_CODE='"+itemCode.trim()+"'";
pstmtSql2=conn.prepareStatement(sql2);
rsSql2=pstmtSql2.executeQuery();
while(rsSql2.next())
{
itemSer=rsSql2.getString(1);
}
itemSer=blanknull(itemSer).trim();
feedBackValue="N";
for(i=0;i<ar.size();i++)
{
itemSer2=ar.get(i).toString();
itemSer2=blanknull(itemSer2).trim();
if(itemSer.equalsIgnoreCase(itemSer2))
{
feedBackValue="Y";
break;
}
}
pstmtInsert.setString(20,feedBackValue);//for feedback_reqd
rsSql2.close();
pstmtSql2.close();
pstmtInsert.setTimestamp(21,new Timestamp(System.currentTimeMillis()));//for chg_date
pstmtInsert.setString(22,loginCode.trim());//for chg_user
pstmtInsert.setString(23,chgTerm.trim());//for chg_term
pstmtInsert.setDouble(24,0);//for quantity_rcvd
pstmtInsert.setDouble(25,quantity);//for current_batch_qty.
pstmtInsert.setString(26,unit.trim());//for unit__std
pstmtInsert.setDouble(27,quantity);//for std_qty
pstmtInsert.setDouble(28,1);//foR con__qty_stduom
pstmtInsert.setDouble(29,quantity);//for quantity__mps
pstmtInsert.setString(30,tranId_db);//for tran_id__mps
pstmtInsert.addBatch();
//===========Code to update Record in MPS_ORDER table==========
pstmtUpdate.setString(1,tranId_db.trim());
pstmtUpdate.addBatch();
}//end of while loop
}
pstmtInsert.executeBatch();
pstmtUpdate.executeBatch();
rs1.close();
pstmt.close();
pstmtInsert.close();
pstmtUpdate.close();
}
catch(SQLException se)
{
System.out.println("SQLException in WorkorderPrcEJB:"+sqlInsert+"<====>"+sqlUpdate);
se.printStackTrace();
errorString=se.getMessage();
}
catch(Exception e)
{
System.out.println("SQLException in WorkorderPrcEJB:"+sqlInsert+"<====>"+sqlUpdate);
e.printStackTrace();
errorString=e.getMessage();
}
return errorString;
}//END OF Method
public String blanknull(String s)
{
if(s==null)
return "";
else
return s;
}//end of blanknull()
private String generateTranId(String windowName,String xmlValues)
{
Statement stmt = null;
ResultSet rs = null;
String sql = "";
String tranId = null;
String newKeystring = "";
String srType = "RS";
try
{
sql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE UPPER(TRAN_WINDOW)=UPPER('"+windowName+"')";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
System.out.println("keyString :"+rs.toString());
String tranSer1 = "";
String keyString = "";
String keyCol = "";
if (rs.next())
{
keyString = rs.getString(1);
keyCol = rs.getString(2);
tranSer1 = rs.getString(3);
}
System.out.println("keyString=>"+keyString);
System.out.println("keyCol=>"+keyCol);
System.out.println("tranSer1"+tranSer1);
System.out.println("xmlValues :["+xmlValues+"]");
loginCode=blanknull(loginCode);
TransIDGenerator tg = new TransIDGenerator(xmlValues, loginCode.trim(), commonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer1, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
if(rs!=null)
{
rs.close();
}
if(stmt!=null)
{
stmt.close();
}
}
catch(SQLException ex)
{
System.out.println("Exception ::" +sql+ ex.getMessage() + ":");
ex.printStackTrace();
tranId=null;
}
catch(Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
tranId=null;
}
return tranId;
}//generateTranTd()
private Timestamp getCurrdateAppFormat()
{
String currAppdate ="";
java.sql.Timestamp currDate = null;
try
{
Object date = null;
currDate =new java.sql.Timestamp(System.currentTimeMillis()) ;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
date = sdf.parse(currDate.toString());
currDate = java.sql.Timestamp.valueOf(sdf.format(date).toString() + " 00:00:00.0");
}
catch(Exception e)
{
System.out.println("Exception in :::WorkorderPrcEJB"+e.getMessage());
e.printStackTrace();
}
return (currDate);
}
}//END OF EJB
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessLocal;
import javax.ejb.Local; // added for ejb3
@Local // added for ejb3
public interface WorkorderPrcLocal extends ibase.webitm.ejb.ProcessLocal//, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}//END OF REMOTE INTERFACE
\ No newline at end of file
package ibase.webitm.ejb.mfg.adv;
import java.rmi.RemoteException;
//import javax.ejb.EJBObject;
import org.w3c.dom.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.ProcessRemote;
import javax.ejb.Remote; // added for ejb3
@Remote // added for ejb3
public interface WorkorderPrcRemote extends ibase.webitm.ejb.ProcessRemote//, EJBObject
{
public String process() throws RemoteException,ITMException;
public String process(Document dom, Document dom2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException;
public String getData(Document dom, Document dom2, String windowNamem, String xtraParams) throws RemoteException,ITMException;
}//END OF REMOTE INTERFACE
\ No newline at end of file
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