Commit 2fb091fd authored by dsawant's avatar dsawant

updated


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95847 ce508802-f39f-4f6c-b175-0d175dae99d5
parent df6ec260
......@@ -7,28 +7,22 @@
package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.TransIDGenerator;
import org.w3c.dom.CDATASection;
import java.io.*;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import javax.ejb.Stateless;
import org.w3c.dom.CDATASection;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
......@@ -42,9 +36,9 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
String chgTerm = null;
NumberFormat nf = null;
boolean isError=false;
public WorkOrdRcpDet() {
System.out.println("^^^^^^^ inside Work Order Receipt Detail ^^^^^^^");
}
......@@ -110,19 +104,19 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
PreparedStatement pstmt = null ;
ResultSet rs = null;
String sql = "";
String workOrder = "",squantity="",wotatus="",itemCode="";
double quantity = 0,noOfArt=0;
try {
System.out.println("editFlag>>>>wf"+editFlag);
System.out.println("xtraParams>>>wf"+xtraParams);
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
......@@ -140,15 +134,15 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
childNodeListLength = childNodeList.getLength();
for (ctr = 0; ctr < childNodeListLength; ctr++) {
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("work_order"))
{
workOrder = genericUtility.getColumnValue("work_order",dom);
if (workOrder == null || workOrder.trim().length() == 0)
{
errCode = "WORDWIWONU";
......@@ -189,43 +183,108 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
rs.close();
pstmt = null;
rs = null;
if(!wotatus.equals("R"))
{
errCode = "WORDWIWOSR";
errString = getErrorString("work_order",errCode,userId);
break;
}
}
}
}
}
break;
/*case 2:
parentNodeList = dom.getElementsByTagName("Detail2");
case 2:
System.out.println("DOM>>>> Elements>>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM1>> Elements>>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM2>> Elements>>["+genericUtility.serializeDom(dom2).toString()+"]");
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
System.out.println("parentNode >>>{"+parentNode+"}");
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
/* boolean flag = false;
parentNodeList = dom.getElementsByTagName("Detail2");
if(parentNodeList != null)
{
System.out.println("for dom >>>>");
parentNode = parentNodeList.item(0);
if(parentNode != null)
{
try{
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}catch(Exception e)
{
e.printStackTrace();
flag = true;
}
}
}
if(flag)
{
flag = false;
parentNodeList = dom1.getElementsByTagName("Detail2");
if(parentNodeList != null)
{
System.out.println("for dom 1");
parentNode = parentNodeList.item(0);
if(parentNode != null)
{
try{
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}catch(Exception e)
{
e.printStackTrace();
flag = true;
}
}
}
if(flag)
{
System.out.println("for dom 2");
parentNodeList = dom2.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
if(parentNode != null)
{
try{
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
}catch(Exception e)
{
e.printStackTrace();
flag = true;
}
}
}
}
*/
for(ctr = 0; ctr < childNodeListLength; ctr++)
{
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("value of child node : "+childNode);
if(childNodeName.equalsIgnoreCase("work_order"))
{
workOrder = genericUtility.getColumnValue("work_order",dom);
workOrder = genericUtility.getColumnValue("work_order",dom2);
if (workOrder == null || workOrder.trim().length() == 0)
{
errCode = "WORDWIWONU";
......@@ -266,24 +325,24 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
rs.close();
pstmt = null;
rs = null;
if(!wotatus.equals("R"))
{
errCode = "WORDWIWOSR";
errString = getErrorString("work_order",errCode,userId);
break;
}
}
}
}
else if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code",dom);
itemCode = genericUtility.getColumnValue("item_code",dom2);
if (itemCode == null || itemCode.trim().length() == 0)
{
errCode = "";
......@@ -311,14 +370,14 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
errString = getErrorString("item_code",errCode,userId);
break;
}
}
}
else if(childNodeName.equalsIgnoreCase("no_art"))
{
String noArt = genericUtility.getColumnValue("no_art",dom);
String noArt = genericUtility.getColumnValue("no_art",dom2);
if (noArt == null || noArt.trim().length() == 0)
{
noOfArt = 0;
......@@ -327,7 +386,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
{
noOfArt = Double.parseDouble(noArt);
}
if(noOfArt == 0)
{
errCode = "WORDWINANU";
......@@ -335,11 +394,11 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
break;
}
}
else if(childNodeName.equalsIgnoreCase("quantity"))
{
squantity = genericUtility.getColumnValue("quantity",dom);
squantity = genericUtility.getColumnValue("quantity",dom2);
if (squantity == null || squantity.trim().length() == 0)
{
quantity = 0;
......@@ -348,7 +407,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
{
quantity = Double.parseDouble(squantity);
}
if(quantity == 0)
{
errCode = "WORDWIQANU";
......@@ -356,162 +415,162 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
break;
}
}
}
break;*/
case 3:
parentNodeList = dom.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++)
break;
case 3:
parentNodeList = dom2.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();
System.out.println("value of child node : "+childNode);
if(childNodeName.equalsIgnoreCase("work_order"))
{
workOrder = genericUtility.getColumnValue("work_order",dom2);
childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName();
System.out.println("value of child node : "+childNode);
if(childNodeName.equalsIgnoreCase("work_order"))
if (workOrder == null || workOrder.trim().length() == 0)
{
workOrder = genericUtility.getColumnValue("work_order",dom);
if (workOrder == null || workOrder.trim().length() == 0)
errCode = "WORDWIWONU";
errString = getErrorString("work_order",errCode,userId);
break;
}
else
{
sql = "select count(1) from workorder where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
errCode = "WORDWIWONU";
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
errCode = "WORDWIWONE";
errString = getErrorString("work_order",errCode,userId);
break;
}
else
}else
{
sql = "select count(1) from workorder where work_order = ?";
sql = "select status from workorder where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
wotatus = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
if(!wotatus.equals("R"))
{
errCode = "WORDWIWONE";
errCode = "WORDWIWOSR";
errString = getErrorString("work_order",errCode,userId);
break;
}else
{
sql = "select status from workorder where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
wotatus = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(!wotatus.equals("R"))
{
errCode = "WORDWIWOSR";
errString = getErrorString("work_order",errCode,userId);
break;
}
}
}
}
else if(childNodeName.equalsIgnoreCase("no_art"))
}
else if(childNodeName.equalsIgnoreCase("no_art"))
{
String noArt = genericUtility.getColumnValue("no_art",dom2);
if (noArt == null || noArt.trim().length() == 0)
{
String noArt = genericUtility.getColumnValue("no_art",dom);
if (noArt == null || noArt.trim().length() == 0)
{
noOfArt = 0;
}
else
{
noOfArt = Double.parseDouble(noArt);
}
if(noOfArt == 0)
{
errCode = "WORDWINANU";
errString = getErrorString("no_art",errCode,userId);
break;
}
noOfArt = 0;
}
else if(childNodeName.equalsIgnoreCase("quantity"))
else
{
squantity = genericUtility.getColumnValue("quantity",dom);
noOfArt = Double.parseDouble(noArt);
}
if (squantity == null || squantity.trim().length() == 0)
{
quantity = 0;
}
else
{
quantity = Double.parseDouble(squantity);
}
if(quantity == 0)
{
errCode = "WORDWIQANU";
errString = getErrorString("quantity",errCode,userId);
break;
}
if(noOfArt == 0)
{
errCode = "WORDWINANU";
errString = getErrorString("no_art",errCode,userId);
break;
}
}
else if(childNodeName.equalsIgnoreCase("quantity"))
{
squantity = genericUtility.getColumnValue("quantity",dom2);
if (squantity == null || squantity.trim().length() == 0)
{
quantity = 0;
}
else
{
quantity = Double.parseDouble(squantity);
}
if(quantity == 0)
{
errCode = "WORDWIQANU";
errString = getErrorString("quantity",errCode,userId);
break;
}
}
else if(childNodeName.equalsIgnoreCase("item_code"))
{
itemCode = genericUtility.getColumnValue("item_code",dom2);
if (itemCode == null || itemCode.trim().length() == 0)
{
errCode = "WORDWIICCB";
errString = getErrorString("item_code",errCode,userId);
break;
}
else if(childNodeName.equalsIgnoreCase("item_code"))
else
{
itemCode = genericUtility.getColumnValue("item_code",dom);
if (itemCode == null || itemCode.trim().length() == 0)
sql = "select count(1) from item where item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
errCode = "WORDWIICCB";
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
errCode = "WORDWIICNE";
errString = getErrorString("item_code",errCode,userId);
break;
}
else
{
sql = "select count(1) from item where item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
errCode = "WORDWIICNE";
errString = getErrorString("item_code",errCode,userId);
break;
}
}
}
}
break;
}
break;
}
} catch (Exception e) {
e.printStackTrace();
......@@ -544,8 +603,8 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
System.out.println("currentColumn"+currentColumn);
System.out.println("editFlag"+editFlag);
System.out.println("xtraParams"+xtraParams);
System.out.println("xmlString111>>"+xmlString);
System.out.println("xmlString222>>"+xmlString1);
System.out.println("xmlString333>>"+xmlString2);
......@@ -562,7 +621,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
return valueXmlString;
}
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException {
String siteCodeTo = "", siteCodeFr = "", fromTranDate = "", toTranDate = "", insertQuery = "", path = "", objName = "intercomp_reconcile";
......@@ -579,21 +638,28 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
ConnDriver connDriver = new ConnDriver();
SimpleDateFormat simpleDateFormat = null;
GenericUtility genutility = new GenericUtility();
String locCode="",lotNo="",lotsl="",itmdesc="",loginSite="",siteCode="";
String locCode="",lotNo="",lotsl="",itmdesc="",loginSite="",siteCode="",atranid="";
System.out.println("DOM111 Elements>>["+genericUtility.serializeDom(dom).toString()+"]");
System.out.println("DOM222 Elements>>["+genericUtility.serializeDom(dom1).toString()+"]");
System.out.println("DOM322 Elements>>["+genericUtility.serializeDom(dom2).toString()+"]");
String workOrder = "",itemCode = "",itemDescr="",sql="",lineNo="";
java.sql.Timestamp currDate = null;
String workOrder = "",itemCode = "",itemDescr="",sql="",lineNo="",unit="",packCode="",qcReqd="",locGrp="";
double totDetQuan = 0.0,totNoArt=0.0;
java.sql.Timestamp currDate = null,mfgDateStart = null,startDate=null,expDate=null;
double quantity = 0,grossWeight = 0,tareWeight = 0,netWeight = 0,noOfArt=0,shippsize = 0;
SimpleDateFormat sdf = null;
String currAppdate = "";
String currAppdate = "",woSiteCode="",sStartDate="",sExpDate="",sMfgDateStart="";
String tranid ="";
double rate = 0,conquan,conOldRate,oldAmount,amount,amtdiff,oldRate=0,getquantity=0;
int cnt = 0;
TransIDGenerator generator = null;
String autoTranid = "";
String scrFlag = "";
String xmlString = "";
String todayDate = "";
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
......@@ -602,7 +668,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
if (objContext != null && objContext.trim().length() > 0) {
currentFormNo = Integer.parseInt(objContext);
}
......@@ -617,83 +683,315 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
break;
case 2 :
case 2 :
parentNodeList = dom.getElementsByTagName("Detail2");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
System.out.println("DOM2 Elements["+genericUtility.serializeDom(dom2).toString()+"]");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
System.out.println("itm_default >>>>> 2>>");
workOrder = genericUtility.getColumnValue("work_order", dom1);
sql = "select count(1) from workorder_receipt where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
System.out.println("itm_default >>>>> 3");
workOrder = genericUtility.getColumnValue("work_order", dom1);
System.out.println("work order from header is"+workOrder);
System.out.println(">>>>>>>>>>>SXD"+workOrder);
sql = "select a.tran_id,a.work_order,a.tran_date,a.item_code,a.no_art,a.quantity,a.gross_weight,"
+ "a.tare_weight,a.net_weight,b.descr from workorder_receipt a,item b where "
+ "a.item_code=b.item_code and work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
while(rs.next())
cnt = rs.getInt(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(cnt == 0)
{
System.out.println("for new tran id");
sql = "update obj_forms set scr_flag = ? where win_name = 'w_worder_rcp_det_wiz' and form_no = '2'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "F");
cnt = pstmt.executeUpdate();
System.out.println(">>>>>>>successfully updated record bom post save cnt1:" + cnt);
conn.commit();
pstmt.close();
pstmt = null;
sdf=new SimpleDateFormat(genutility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis()) ;
todayDate = simpleDateFormat.format(currDate);
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>" + loginSite + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + todayDate + "</tran_date>";
xmlValues = xmlValues + "<tran_type>F</tran_type>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
atranid = tg.generateTranSeqID("W-RCP","tran_id","_spsite_code,T,tran_type,_pptran_date,seq04",conn);
System.out.println(">>>>>NEW id"+atranid);
}else
{
System.out.println("for existing tran id");
sql = "update obj_forms set scr_flag = ? where win_name = 'w_worder_rcp_det_wiz' and form_no = '2'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, "T");
cnt = pstmt.executeUpdate();
System.out.println(">>>>>>>successfully updated record bom post save cnt1:" + cnt);
conn.commit();
pstmt.close();
pstmt = null;
}
sql = "select scr_flag from obj_forms where win_name = 'w_worder_rcp_det_wiz' and form_no = '2'";
pstmt=conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
scrFlag = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(scrFlag.equals("T"))
{
System.out.println("non add record");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
tranid = rs.getString(1) == null ? "":rs.getString(1);
workOrder = rs.getString(2) == null ? "":rs.getString(2);
currDate = rs.getTimestamp(3);
itemCode = rs.getString(4) == null ? "":rs.getString(4);
noOfArt = rs.getDouble(5);
quantity = rs.getDouble(6);
grossWeight = rs.getDouble(7);
tareWeight = rs.getDouble(8);
netWeight = rs.getDouble(9);
itemDescr = rs.getString(10) == null ? "":rs.getString(10);
simpleDateFormat=new SimpleDateFormat(genutility.getApplDateFormat());
currAppdate = simpleDateFormat.format(currDate);
valueXmlString.append("<Detail2>");
valueXmlString.append("<tran_id>").append("<![CDATA[" + tranid + "]]>").append("</tran_id>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + currAppdate + "]]>").append("</tran_date>");
System.out.println("work order from header is"+workOrder);
System.out.println(">>>>>>>>>>>SXD"+workOrder);
sql = "select a.tran_id,a.work_order,a.tran_date,a.item_code,a.no_art,a.quantity,a.gross_weight,"
+ "a.tare_weight,a.net_weight,b.descr from workorder_receipt a,item b where "
+ "a.item_code=b.item_code and work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
while(rs.next())
{
tranid = rs.getString(1) == null ? "":rs.getString(1);
workOrder = rs.getString(2) == null ? "":rs.getString(2);
currDate = rs.getTimestamp(3);
itemCode = rs.getString(4) == null ? "":rs.getString(4);
noOfArt = rs.getDouble(5);
quantity = rs.getDouble(6);
grossWeight = rs.getDouble(7);
tareWeight = rs.getDouble(8);
netWeight = rs.getDouble(9);
itemDescr = rs.getString(10) == null ? "":rs.getString(10);
simpleDateFormat=new SimpleDateFormat(genutility.getApplDateFormat());
currAppdate = simpleDateFormat.format(currDate);
valueXmlString.append("<Detail2 objContext = '"+currentFormNo+"' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id>").append("<![CDATA[" + tranid + "]]>").append("</tran_id>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + currAppdate + "]]>").append("</tran_date>");
valueXmlString.append("<work_order>").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + itemDescr + "]]>").append("</descr>");
valueXmlString.append("<no_art>").append("<![CDATA[" + noOfArt + "]]>").append("</no_art>");
valueXmlString.append("<quantity>").append("<![CDATA[" + quantity + "]]>").append("</quantity>");
valueXmlString.append("<gross_weight>").append("<![CDATA[" + grossWeight + "]]>").append("</gross_weight>");
valueXmlString.append("<tare_weight>").append("<![CDATA[" + tareWeight + "]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[" + netWeight + "]]>").append("</net_weight>");
valueXmlString.append("</Detail2>");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
}else
{
System.out.println("add record");
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
sql = "select site_code,rel_date,item_code,lot_no,exp_date,mfg_date__start from workorder where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
woSiteCode = rs.getString(1) == null ? "":rs.getString(1);
startDate = rs.getTimestamp(2);
itemCode = rs.getString(3) == null ? "":rs.getString(3);
lotNo = rs.getString(4) == null ? "":rs.getString(4);
expDate = rs.getTimestamp(5);
mfgDateStart = rs.getTimestamp(6);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
sdf=new SimpleDateFormat(genutility.getApplDateFormat());
sStartDate = simpleDateFormat.format(startDate);
sExpDate = simpleDateFormat.format(expDate);
sMfgDateStart = simpleDateFormat.format(mfgDateStart);
valueXmlString.append("<Detail2 objContext = '"+currentFormNo+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id>").append("<![CDATA[" + atranid + "]]>").append("</tran_id>");
valueXmlString.append("<tran_date>").append("<![CDATA[" + todayDate + "]]>").append("</tran_date>");
valueXmlString.append("<site_code>").append("<![CDATA[" + loginSite + "]]>").append("</site_code>");
valueXmlString.append("<work_order>").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<date__start>").append("<![CDATA[" + sStartDate + "]]>").append("</date__start>");
valueXmlString.append("<date__compl>").append("<![CDATA[" + todayDate + "]]>").append("</date__compl>");
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("<descr>").append("<![CDATA[" + itemDescr + "]]>").append("</descr>");
valueXmlString.append("<no_art>").append("<![CDATA[" + noOfArt + "]]>").append("</no_art>");
valueXmlString.append("<quantity>").append("<![CDATA[" + quantity + "]]>").append("</quantity>");
valueXmlString.append("<gross_weight>").append("<![CDATA[" + grossWeight + "]]>").append("</gross_weight>");
valueXmlString.append("<tare_weight>").append("<![CDATA[" + tareWeight + "]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[" + netWeight + "]]>").append("</net_weight>");
valueXmlString.append("<loc_code>").append("<![CDATA[ ]]>").append("</loc_code>");
valueXmlString.append("<lot_no>").append("<![CDATA[" + lotNo + "]]>").append("</lot_no>");
valueXmlString.append("<lot_sl>").append("<![CDATA[ ]]>").append("</lot_sl>");
valueXmlString.append("<exp_date>").append("<![CDATA[" + sExpDate + "]]>").append("</exp_date>");
valueXmlString.append("<site_code__own>").append("<![CDATA[" + woSiteCode + "]]>").append("</site_code__own>");
sql = "select sum(quantity) from workorder_rcp_det where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
totDetQuan = rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<quantity>").append("<![CDATA[" + totDetQuan + "]]>").append("</quantity>");
sql = "select unit from item where item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
unit = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<unit>").append("<![CDATA[" + unit + "]]>").append("</unit>");
sql = "select pack_code from item where item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
packCode = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<pack_code>").append("<![CDATA[" + packCode + "]]>").append("</pack_code>");
valueXmlString.append("<potency_perc>").append("<![CDATA[0]]>").append("</potency_perc>");
valueXmlString.append("<chg_user>").append("<![CDATA[" + chgUser + "]]>").append("</chg_user>");
valueXmlString.append("<chg_term>").append("<![CDATA[" + chgTerm + "]]>").append("</chg_term>");
valueXmlString.append("<chg_date>").append("<![CDATA[" + todayDate + "]]>").append("</chg_date>");
valueXmlString.append("<confirmed>").append("<![CDATA[N]]>").append("</confirmed>");
valueXmlString.append("<mfg_date>").append("<![CDATA[" + sMfgDateStart + "]]>").append("</mfg_date>");
valueXmlString.append("<tran_type>").append("<![CDATA[F]]>").append("</tran_type>");
valueXmlString.append("<operation>").append("<![CDATA[0]]>").append("</operation>");
sql = "select qc_reqd from siteitem where site_code = ? and item_code = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,loginSite);
pstmt.setString(2,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
qcReqd = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<qc_reqd>").append("<![CDATA[" + qcReqd + "]]>").append("</qc_reqd>");
valueXmlString.append("<conv__qty_stduom>").append("<![CDATA[1]]>").append("</conv__qty_stduom>");
sql = "select sum(no_art) from workorder_rcp_det where work_order = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
totNoArt = rs.getDouble(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
valueXmlString.append("<no_art>").append("<![CDATA[" + totNoArt + "]]>").append("</no_art>");
valueXmlString.append("<unit__std>").append("<![CDATA[" + unit + "]]>").append("</unit__std>");
valueXmlString.append("<std_qty>").append("<![CDATA[" + totDetQuan + "]]>").append("</std_qty>");
valueXmlString.append("<create_stab>").append("<![CDATA[N]]>").append("</create_stab>");
valueXmlString.append("<gross_weight>").append("<![CDATA[0]]>").append("</gross_weight>");
valueXmlString.append("<tare_weight>").append("<![CDATA[0]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[0]]>").append("</net_weight>");
if(qcReqd.equalsIgnoreCase("Y"))
{
sql = "select var_value from mfgparm where var_name = 'WORCP_LOCK_GROUP'";
pstmt=conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if(rs.next())
{
locGrp = rs.getString(1) == null ? "":rs.getString(1);
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if(locGrp != null && locGrp.trim().length() > 0)
{
valueXmlString.append("<lock_group>").append("<![CDATA[" + locGrp + "]]>").append("</lock_group>");
}
}
valueXmlString.append("</Detail2>");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
break;
case 3 :
parentNodeList = dom.getElementsByTagName("Detail3");
case 3 :
parentNodeList = dom2.getElementsByTagName("Detail3");
parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes();
tranid = genericUtility.getColumnValue("tran_id", dom2, "2").trim();
//childNodeListLength = childNodeList.getLength();
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("tran id is"+tranid);
sql = "select work_order,item_code,lot_sl,lot_no,no_art,quantity,gross_weight,tare_weight,net_weight,line_no "
+ "from workorder_rcp_det where tran_id = ?";
pstmt=conn.prepareStatement(sql);
......@@ -701,7 +999,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
rs = pstmt.executeQuery();
while(rs.next())
{
workOrder = rs.getString(1) == null ? "":rs.getString(1);
itemCode = rs.getString(2) == null ? "":rs.getString(2);
lotsl = rs.getString(3) == null ? "":rs.getString(3);
......@@ -712,8 +1010,8 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
tareWeight = rs.getDouble(8);
netWeight = rs.getDouble(9);
lineNo = rs.getString(10) == null ? "":rs.getString(10);
valueXmlString.append("<Detail3 domID='" + lineNo+ "' objContext = '"+currentFormNo+"' selected=\"Y\">\r\n");
valueXmlString.append("<attribute selected=\"Y\" updateFlag=\"E\" status=\"O\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id>").append("<![CDATA[" + tranid + "]]>").append("</tran_id>");
......@@ -729,21 +1027,23 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
valueXmlString.append("<tare_weight>").append("<![CDATA[" + tareWeight + "]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[" + netWeight + "]]>").append("</net_weight>");
valueXmlString.append("</Detail3>");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
}
else if(currentColumn.trim().equalsIgnoreCase("itm_default_add"))
{
tranid = genericUtility.getColumnValue("tran_id", dom2, "2").trim();
workOrder = genericUtility.getColumnValue("work_order", dom2, "2").trim();
itemCode = genericUtility.getColumnValue("item_code", dom2, "2").trim();
System.out.println("TRANID IS>>>"+tranid);
NodeList nodeList = dom2.getElementsByTagName("Detail3");
......@@ -751,16 +1051,16 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
String domId = nodeList.item(0).getAttributes().getNamedItem("domID").getNodeValue();
System.out.println("domId=="+domId);
System.out.println("tran id is"+tranid);
sql = "select work_order,item_code,lot_sl,lot_no,no_art,quantity,gross_weight,tare_weight,net_weight "
System.out.println("tran id is"+tranid);
/* sql = "select work_order,item_code,lot_sl,lot_no,no_art,quantity,gross_weight,tare_weight,net_weight "
+ "from workorder_receipt where tran_id = ?";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,tranid);
rs = pstmt.executeQuery();
if(rs.next())
{
workOrder = rs.getString(1) == null ? "":rs.getString(1);
itemCode = rs.getString(2) == null ? "":rs.getString(2);
lotsl = rs.getString(3) == null ? "":rs.getString(3);
......@@ -770,9 +1070,9 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
grossWeight = rs.getDouble(7);
tareWeight = rs.getDouble(8);
netWeight = rs.getDouble(9);
valueXmlString.append("<Detail3 domID='" + domId+ "' objContext = '"+currentFormNo+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id><![CDATA[" + tranid + "]]></tran_id>");
......@@ -782,7 +1082,7 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
valueXmlString.append("<lot_no>").append("<![CDATA[" + lotNo + "]]>").append("</lot_no>");
valueXmlString.append("<lot_sl>").append("<![CDATA[" + lotsl + "]]>").append("</lot_sl>");
valueXmlString.append("<no_art>").append("<![CDATA[" + noOfArt + "]]>").append("</no_art>");
//select shipper_size from item_lot_packsize where item_code = 'EF0050';
sql = "select shipper_size from item_lot_packsize where item_code = ?";
pstmt1=conn.prepareStatement(sql);
......@@ -790,17 +1090,17 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
shippsize = rs1.getDouble(1);
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
quantity = shippsize * noOfArt;
if(quantity == 0)
{
valueXmlString.append("<quantity protect=\"0\">").append("<![CDATA[" + quantity + "]]>").append("</quantity>");
......@@ -810,9 +1110,9 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
{
valueXmlString.append("<quantity protect=\"1\">").append("<![CDATA[" + quantity + "]]>").append("</quantity>");
setNodeValue( dom, "quantity", getAbsString(""+quantity));
}
sql = "select loc_code__insp from siteitem where item_code = ? and site_code = ?";
pstmt1=conn.prepareStatement(sql);
pstmt1.setString(1,itemCode);
......@@ -820,38 +1120,43 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
locCode = rs1.getString(1) == null ? "":rs1.getString(1);
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
valueXmlString.append("<loc_code>").append("<![CDATA[" + locCode + "]]>").append("</loc_code>");
valueXmlString.append("<gross_weight>").append("<![CDATA[" + grossWeight + "]]>").append("</gross_weight>");
valueXmlString.append("<tare_weight>").append("<![CDATA[" + tareWeight + "]]>").append("</tare_weight>");
valueXmlString.append("<net_weight>").append("<![CDATA[" + netWeight + "]]>").append("</net_weight>");
valueXmlString.append("</Detail3>");
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
rs = null;*/
valueXmlString.append("<Detail3 domID='" + domId+ "' objContext = '"+currentFormNo+"' selected=\"N\">\r\n");
valueXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>\r\n");
valueXmlString.append("<tran_id><![CDATA[" + tranid + "]]></tran_id>");
valueXmlString.append("<line_no><![CDATA[" + domId + "]]></line_no>");
valueXmlString.append("<work_order>").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<item_code>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>");
valueXmlString.append("</Detail3>");
}
break;
}
valueXmlString.append("</Root>");
}
......@@ -894,247 +1199,30 @@ public class WorkOrdRcpDet extends ValidatorEJB implements WorkOrdRcpDetLocal, W
return valueXmlString.toString();
}
private StringBuffer getXMLTransData(Connection conn, String sql, String objName) throws Exception
private static String getAbsString( String str )
{
System.out.println("In getXMLTransData");
ConnDriver connDriver1 = new ConnDriver();
Connection conn1=null;
StringBuffer valueXmlString = new StringBuffer("");
HashMap<String,Double> issueSiteMap=new HashMap<String,Double>();
HashMap<String,Double> reseiverSiteMap=new HashMap<String,Double>();
HashMap<String,String> issueSiteRefMap=new HashMap<String,String>();
HashMap<String,String> reseiverSiteRefMap=new HashMap<String,String>();
ArrayList<ArrayList> arrayListData = null;
ArrayList traceData = null;
Document dom = null;
String rType="";
TransIDGenerator generator = null;
if(conn!=null){
ResultSet rs = null;
PreparedStatement pstmt = null;
int columnCnt = 0;
int columnItr = 0, detailListCnt = 1;
ResultSetMetaData resultSetMetaData = null;
try {
//Added by Dadaso pawar on 26-MAy-14 [Start]
// check reconcile type if Auto then following query will executed otherwise
// manually--> then only those ref id compare or reconcile whose amount is matched.
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if ( rs != null ) {
System.out.println("In First If");
System.out.println("In CallByItemChange");
resultSetMetaData = rs.getMetaData();
columnCnt = resultSetMetaData.getColumnCount();
while(rs.next())
{
valueXmlString.append("<Detail2 domID='"+ detailListCnt++ +"' selected = 'N'>\r\n");
for (columnItr = 1;columnItr <= columnCnt;columnItr++) {
valueXmlString.append("<");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr).toLowerCase());
valueXmlString.append(">");
valueXmlString.append("<![CDATA[");
valueXmlString.append(rs.getString(columnItr) == null ? "" : rs.getString(columnItr).trim());
valueXmlString.append("]]>");
valueXmlString.append("</");
valueXmlString.append(resultSetMetaData.getColumnLabel(columnItr).toLowerCase());
valueXmlString.append(">\r\n");
}
valueXmlString.append("</Detail2>\r\n");
}
pstmt = null;
rs = null;
}
}
catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
try{
conn.rollback();
}
catch(Exception e1){
e1.printStackTrace();
}
}
catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
try{
conn.rollback();
}
catch(Exception e1){
e1.printStackTrace();
}
ex.printStackTrace();
} finally {
try{
if(pstmt!=null){
pstmt.close();
pstmt = null;
}
if(rs!=null){
rs.close();
rs = null;
}
if(conn1!=null){
conn1.close();
conn1=null;
}
}catch (SQLException se) {
se.printStackTrace();
}
sql = null;
objName = null;
}
}else{
try {
throw new SQLException("Connection passed to InterCompReconcileProcess.getXMLTransData() method is null");
} catch (SQLException e) {
e.printStackTrace();
}
}
return valueXmlString;
return ( str == null || str.trim().length() == 0 || "null".equalsIgnoreCase( str.trim() ) ? "" : str.trim() );
}
public String preSaveForm(String tranid)throws ITMException
private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception
{
String errString = "";
Document dom = null;
System.out.println("@@@@@@@@@---------preSaveForm EJB called...");
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
try
{
conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false);
connDriver = null;
System.out.println("@@@@@@@xmlString1["+tranid+"]");
if (tranid != null && tranid.trim().length() > 0)
{
try{
writeFile(tranid,"/home/deepak/myfile.txt");
}catch (Exception e) {
e.printStackTrace();
}
}
}
catch(SQLException e) {
System.out.println("SQL Exception In getXMLTransData method of InterCompReconcileProcess Class : "+e.getMessage());
e.printStackTrace();
}
catch(Exception ex) {
System.out.println("Exception In getXMLTransData method of InterCompReconcileProcess Class : "+ex.getMessage());
ex.printStackTrace();
} finally {
try {
if(conn != null) {
conn.close();
}
conn = null;
} catch(Exception d) {
d.printStackTrace();
}
}
return "";
}
private String readFile(String file) throws Exception
{
String errString = "";
String sqlQry = "";
try
{
System.out.println("File "+file);
FileInputStream fin = new FileInputStream(file);
BufferedReader br = new BufferedReader(new InputStreamReader(fin));
String tempStr = "";
while ((tempStr = br.readLine()) != null)
{
sqlQry = sqlQry + tempStr;
}
tempStr = null;
br = null;
fin.close();
} catch (FileNotFoundException fe)
{
System.out.println("FileNotFoundException :InterCompReconcileProcess :readFile(String).." + fe.getMessage());
fe.printStackTrace();
errString = fe.getMessage();
throw new ITMException(fe);
}
Node tempNode = dom.getElementsByTagName( nodeName ).item(0);
catch (Exception e)
{
System.out.println("Exception :InterCompReconcileProcess :readFile(String).." + e.getMessage());
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
}
return sqlQry;
}
private void writeFile(String adpQuery,String fileName) throws Exception
if( tempNode != null )
{
String errString;
try
if( tempNode.getFirstChild() == null )
{
System.out.println("fileName "+fileName);
FileOutputStream fout = null;
BufferedWriter bw = null;
fout = new FileOutputStream(fileName);
bw = new BufferedWriter(new OutputStreamWriter(fout));
bw.write(adpQuery);
bw.close();
fout.close();
} catch (FileNotFoundException fe)
{
System.out.println("FileNotFoundException :InterCompReconcileProcess :writeFile(String,String).." + fe.getMessage());
fe.printStackTrace();
errString = fe.getMessage();
throw new ITMException(fe);
CDATASection cDataSection = dom.createCDATASection( nodeVal );
tempNode.appendChild( cDataSection );
}
catch (Exception e)
else
{
System.out.println("Exception :InterCompReconcileProcess :writeFile(String,String).." + e.getMessage());
e.printStackTrace();
errString = e.getMessage();
throw new ITMException(e);
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
private static String getAbsString( String str )
{
return ( str == null || str.trim().length() == 0 || "null".equalsIgnoreCase( str.trim() ) ? "" : str.trim() );
}
private static void setNodeValue( Document dom, String nodeName, String nodeVal ) throws Exception
{
Node tempNode = dom.getElementsByTagName( nodeName ).item(0);
if( tempNode != null )
{
if( tempNode.getFirstChild() == null )
{
CDATASection cDataSection = dom.createCDATASection( nodeVal );
tempNode.appendChild( cDataSection );
}
else
{
tempNode.getFirstChild().setNodeValue(nodeVal);
}
}
tempNode = null;
}
}
\ 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