Commit d1b39e73 authored by cpatil's avatar cpatil

add itemchange of quantity,no_art,net_weight


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93864 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0b3bf0d0
package ibase.webitm.ejb.mfg; package ibase.webitm.ejb.mfg;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.ejb.dis.DistCommon;
//import ibase.webitm.ejb.fin.FinCommon; //import ibase.webitm.ejb.fin.FinCommon;
//import ibase.webitm.ejb.mfg.MfgCommon; //import ibase.webitm.ejb.mfg.MfgCommon;
//import ibase.webitm.ejb.mfg.WorkOrderAmd; //import ibase.webitm.ejb.mfg.WorkOrderAmd;
...@@ -21,45 +22,42 @@ import org.w3c.dom.Node; ...@@ -21,45 +22,42 @@ import org.w3c.dom.Node;
import org.w3c.dom.NodeList; import org.w3c.dom.NodeList;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import java.sql.Timestamp; import java.sql.Timestamp;
@Stateless
public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCTransferICRemote @Stateless
{ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal,
QCTransferICRemote {
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
//method for validation // method for validation
public String wfValData(String xmlString, String xmlString1, String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException public String wfValData(String xmlString, String xmlString1,
{ String xmlString2, String objContext, String editFlag,
String xtraParams) throws RemoteException, ITMException {
String errString = ""; String errString = "";
System.out.println("wfValdata() called for QCTransferIC"); System.out.println("wfValdata() called for QCTransferIC");
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
try try {
{ if (xmlString != null && xmlString.trim().length() > 0) {
if (xmlString != null && xmlString.trim().length() > 0 )
{
dom = parseString(xmlString); dom = parseString(xmlString);
} }
if (xmlString1 != null && xmlString1.trim().length() > 0 ) if (xmlString1 != null && xmlString1.trim().length() > 0) {
{
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
} }
if (xmlString2 != null && xmlString2.trim().length() > 0 ) if (xmlString2 != null && xmlString2.trim().length() > 0) {
{
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
} }
errString = wfValData(dom, dom1, dom2, objContext, editFlag, xtraParams); errString = wfValData(dom, dom1, dom2, objContext, editFlag,
} xtraParams);
catch(Exception e) } catch (Exception e) {
{
throw new ITMException(e); throw new ITMException(e);
} }
return(errString); return (errString);
} }
public String wfValData(Document dom, Document dom1, Document dom2, 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 {
String childNodeName = null; String childNodeName = null;
String errString = ""; String errString = "";
String errCode = ""; String errCode = "";
...@@ -67,7 +65,7 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -67,7 +65,7 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
String sql = ""; String sql = "";
String errorType = ""; String errorType = "";
int cnt = 0; int cnt = 0;
int ctr=0; int ctr = 0;
int childNodeListLength; int childNodeListLength;
NodeList parentNodeList = null; NodeList parentNodeList = null;
NodeList childNodeList = null; NodeList childNodeList = null;
...@@ -76,61 +74,59 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -76,61 +74,59 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errList = new ArrayList<String>();
ArrayList<String> errFields = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>();
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
StringBuffer errStringXml = new StringBuffer("<?xml version = \"1.0\"?> \r\n <Root> <Errors>"); StringBuffer errStringXml = new StringBuffer(
"<?xml version = \"1.0\"?> \r\n <Root> <Errors>");
int currentFormNo =0,recCnt=0; int currentFormNo = 0, recCnt = 0;
int noOfParent=0,ctr1=0; int noOfParent = 0, ctr1 = 0;
double maxQty=0,minQty = 0 ; double maxQty = 0, minQty = 0;
String tranDateStr="",qorderNo="",refNo="",tranId="",itemCode="",locCode="",lotNo="",lotSl="",siteCode=""; String tranDateStr = "", qorderNo = "", refNo = "", tranId = "", itemCode = "", locCode = "", lotNo = "", lotSl = "", siteCode = "";
String status="",porcpNo="",porcpLineNo="",qcLocCode="",minQtyStr="",available="",keyFlag=""; String status = "", porcpNo = "", porcpLineNo = "", qcLocCode = "", minQtyStr = "", available = "", keyFlag = "";
Timestamp date2=null,tranDate=null ; Timestamp date2 = null, tranDate = null;
double aprvLeadTime=0; double aprvLeadTime = 0;
Timestamp qcOrderDate = null; // added by cpatil on 02/11/13 Timestamp qcOrderDate = null; // added by cpatil on 02/11/13
try try {
{
System.out.println("@@@@@@@@ wfvaldata called"); System.out.println("@@@@@@@@ wfvaldata called");
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); userId = getValueFromXTRA_PARAMS(xtraParams, "loginCode");
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0) {
{
currentFormNo = Integer.parseInt(objContext); currentFormNo = Integer.parseInt(objContext);
} }
switch(currentFormNo) switch (currentFormNo) {
{ case 1:
case 1 :
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
childNodeListLength = childNodeList.getLength(); childNodeListLength = childNodeList.getLength();
for(ctr = 0; ctr < childNodeListLength; ctr++) for (ctr = 0; ctr < childNodeListLength; ctr++) {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("tran_id")) if (childNodeName.equalsIgnoreCase("tran_id")) {
{ tranId = checkNull(genericUtility.getColumnValue(
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom)); "tran_id", dom));
System.out.println("@@@@ tran_id validation "); System.out.println("@@@@ tran_id validation ");
keyFlag = setDescription("key_flag", "transetup", "tran_window", "w_qc_transfer", conn); keyFlag = setDescription("key_flag", "transetup",
System.out.println("@@@@ tran_id ["+tranId+"]:::::keyFlag["+keyFlag+"]"); "tran_window", "w_qc_transfer", conn);
System.out.println("@@@@ tran_id [" + tranId
+ "]:::::keyFlag[" + keyFlag + "]");
if( tranId != null && tranId.length() > 0 && "M".equalsIgnoreCase(keyFlag)) if (tranId != null && tranId.length() > 0
{ && "M".equalsIgnoreCase(keyFlag)) {
sql = " Select count(1) from qc_transfer where tran_id = ? "; sql = " Select count(1) from qc_transfer where tran_id = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId); pstmt.setString(1, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close(); rs.close();
...@@ -138,9 +134,8 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -138,9 +134,8 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("@@@@ cnt["+cnt+"]"); System.out.println("@@@@ cnt[" + cnt + "]");
if( cnt > 0 ) if (cnt > 0) {
{
errCode = "VMTRANIDEX"; errCode = "VMTRANIDEX";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
...@@ -149,24 +144,25 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -149,24 +144,25 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
} }
} }
if (childNodeName.equalsIgnoreCase("tran_date")) {
tranDateStr = checkNull(genericUtility.getColumnValue(
"tran_date", dom));
qorderNo = checkNull(genericUtility.getColumnValue(
"qorder_no", dom));
siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
itemCode = checkNull(genericUtility.getColumnValue(
"item_code", dom));
if(childNodeName.equalsIgnoreCase("tran_date")) System.out.println("@@@@ tranDate [" + tranDateStr
{ + "]:::qorderNo[" + qorderNo + "]");
tranDateStr = checkNull(genericUtility.getColumnValue("tran_date", dom)); if (qorderNo != null && qorderNo.length() > 0) {
qorderNo = checkNull(genericUtility.getColumnValue("qorder_no", dom)); sql = " Select qorder_date from qc_order"
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom)); + " where qorder_no = ? ";
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
System.out.println("@@@@ tranDate ["+tranDateStr+"]:::qorderNo["+qorderNo+"]");
if( qorderNo != null && qorderNo.length() > 0 )
{
sql = " Select qorder_date from qc_order" +
" where qorder_no = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,qorderNo); pstmt.setString(1, qorderNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
date2 = rs.getTimestamp("qorder_date"); date2 = rs.getTimestamp("qorder_date");
} }
rs.close(); rs.close();
...@@ -174,31 +170,37 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -174,31 +170,37 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( tranDateStr != null && tranDateStr.length() > 0 ) if (tranDateStr != null && tranDateStr.length() > 0) {
{ tranDate = Timestamp.valueOf(genericUtility
tranDate= Timestamp.valueOf(genericUtility.getValidDateString(tranDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); .getValidDateString(tranDateStr,
genericUtility
.getApplDateFormat(),
genericUtility
.getDBDateFormat())
+ " 00:00:00.0");
} }
System.out.println("@@@@ tranDate ["+tranDate+"]:::qorder_date["+date2+"]"); System.out.println("@@@@ tranDate [" + tranDate
+ "]:::qorder_date[" + date2 + "]");
if( tranDate.before(date2)) if (tranDate.before(date2)) {
{
errCode = "QCTRFDATE"; errCode = "QCTRFDATE";
//ls_errcode = 'QCTRFDATE~t' + 'QC Transfer Date cannot be less then QC Order Date' // ls_errcode = 'QCTRFDATE~t' + 'QC Transfer
// Date cannot be less then QC Order Date'
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
/// added by cpatil on 01/11/13 start // / added by cpatil on 01/11/13 start
System.out.println("@@@@ tranDate new validation start--------- "); System.out
.println("@@@@ tranDate new validation start--------- ");
sql = " Select aprv_lead_time from siteitem where site_code = ? and item_code = ? "; sql = " Select aprv_lead_time from siteitem where site_code = ? and item_code = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2,itemCode); pstmt.setString(2, itemCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
aprvLeadTime = rs.getDouble("aprv_lead_time"); aprvLeadTime = rs.getDouble("aprv_lead_time");
} }
rs.close(); rs.close();
...@@ -206,66 +208,75 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -206,66 +208,75 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("@@@@ site code["+siteCode+"]::item code["+itemCode+"]::aprvLeadTime["+aprvLeadTime+"]::date2["+date2+"]"); System.out.println("@@@@ site code[" + siteCode
+ "]::item code[" + itemCode
+ "]::aprvLeadTime[" + aprvLeadTime
+ "]::date2[" + date2 + "]");
Calendar cal = Calendar.getInstance(); Calendar cal = Calendar.getInstance();
cal.setTime(date2); cal.setTime(date2);
cal.add(Calendar.DAY_OF_WEEK, (int) Math.round(aprvLeadTime)); cal.add(Calendar.DAY_OF_WEEK,
(int) Math.round(aprvLeadTime));
qcOrderDate = new Timestamp(cal.getTime().getTime()); qcOrderDate = new Timestamp(cal.getTime().getTime());
System.out.println("@@@@ tranDate new date ["+qcOrderDate+"]:::::tranDate["+tranDate+"]"); System.out.println("@@@@ tranDate new date ["
if ( tranDate.before(qcOrderDate) ) + qcOrderDate + "]:::::tranDate["
{ + tranDate + "]");
if (tranDate.before(qcOrderDate)) {
errCode = "QCTRFDATEI"; errCode = "QCTRFDATEI";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
System.out.println("@@@@ tranDate new validation end---------errCode["+errCode+"]"); System.out
/// added by cpatil on 01/11/13 end .println("@@@@ tranDate new validation end---------errCode["
+ errCode + "]");
// / added by cpatil on 01/11/13 end
} }
} }
if(childNodeName.equalsIgnoreCase("qorder_no")) if (childNodeName.equalsIgnoreCase("qorder_no")) {
{
cnt = 0; cnt = 0;
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom)); tranId = checkNull(genericUtility.getColumnValue(
qorderNo = checkNull(genericUtility.getColumnValue("qorder_no", dom)); "tran_id", dom));
itemCode = checkNull( genericUtility.getColumnValue("item_code", dom)); qorderNo = checkNull(genericUtility.getColumnValue(
locCode = checkNull( genericUtility.getColumnValue("loc_code", dom)); "qorder_no", dom));
lotNo = checkNull( genericUtility.getColumnValue("lot_no", dom)); itemCode = checkNull(genericUtility.getColumnValue(
lotSl = checkNull( genericUtility.getColumnValue("lot_sl", dom)); "item_code", dom));
siteCode = checkNull( genericUtility.getColumnValue("site_code", dom)); locCode = checkNull(genericUtility.getColumnValue(
"loc_code", dom));
if ( qorderNo == null ) lotNo = checkNull(genericUtility.getColumnValue(
{ "lot_no", dom));
lotSl = checkNull(genericUtility.getColumnValue(
"lot_sl", dom));
siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
if (qorderNo == null) {
qorderNo = " "; qorderNo = " ";
} }
if ( lotNo == null ) if (lotNo == null) {
{
lotNo = " "; lotNo = " ";
} }
if ( locCode == null ) if (locCode == null) {
{
locCode = " "; locCode = " ";
} }
sql = " Select count(1) from qc_order " + sql = " Select count(1) from qc_order "
" Where qorder_no <> ? " + + " Where qorder_no <> ? "
" and site_code = ? " + + " and site_code = ? "
" and item_code = ? " + + " and item_code = ? "
" and lot_no = ? " + + " and lot_no = ? "
" and loc_code = ? " + + " and loc_code = ? "
" and status = 'U' "; + " and status = 'U' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,qorderNo); pstmt.setString(1, qorderNo);
pstmt.setString(2,siteCode); pstmt.setString(2, siteCode);
pstmt.setString(3,itemCode); pstmt.setString(3, itemCode);
pstmt.setString(4,lotNo); pstmt.setString(4, lotNo);
pstmt.setString(5,locCode); pstmt.setString(5, locCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close(); rs.close();
...@@ -273,54 +284,50 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -273,54 +284,50 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("@@@@@@@@9 cnt["+cnt+"]:::tranId["+tranId+"]"); System.out.println("@@@@@@@@9 cnt[" + cnt
if( cnt > 0 ) + "]:::tranId[" + tranId + "]");
{ if (cnt > 0) {
errCode = "VTINVQN1"; errCode = "VTINVQN1";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
System.out.println("@@@@@@@@ tranId["+tranId+"]"); System.out.println("@@@@@@@@ tranId[" + tranId + "]");
if ( tranId == null ) if (tranId == null) {
{
tranId = " "; tranId = " ";
} }
sql = " Select count(1) from qc_transfer " + sql = " Select count(1) from qc_transfer "
" Where qorder_no = ? and confirmed = 'N' and tran_id <> ? "; + " Where qorder_no = ? and confirmed = 'N' and tran_id <> ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,qorderNo); pstmt.setString(1, qorderNo);
pstmt.setString(2,tranId); pstmt.setString(2, tranId);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
cnt = rs.getInt(1); cnt = rs.getInt(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("@@@@@@@@8 cnt["+cnt+"]"); System.out.println("@@@@@@@@8 cnt[" + cnt + "]");
if( cnt > 0 ) if (cnt > 0) {
{ System.out.println("@@@@@@@@@111QCTRFUCONF:cnt["
System.out.println("@@@@@@@@@111QCTRFUCONF:cnt["+cnt+"]"); + cnt + "]");
errCode = "QCTRFUCONF"; errCode = "QCTRFUCONF";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
// if gs_runmode <> 'B' then // if gs_runmode <> 'B' then
if( errCode== null || errCode.trim().length() == 0 ) if (errCode == null || errCode.trim().length() == 0) {
{ cnt = 0;
cnt=0; sql = " Select status , porcp_no, porcp_line_no from qc_order "
sql = " Select status , porcp_no, porcp_line_no from qc_order " + + " where qorder_no = ? ";
" where qorder_no = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,qorderNo); pstmt.setString(1, qorderNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
cnt++; cnt++;
status = rs.getString("status"); status = rs.getString("status");
porcpNo = rs.getString("porcp_no"); porcpNo = rs.getString("porcp_no");
...@@ -331,32 +338,36 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -331,32 +338,36 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if ( cnt == 0 ) if (cnt == 0) {
{ // ls_errcode = 'QCTRFORD~t' + 'QC order is not
// ls_errcode = 'QCTRFORD~t' + 'QC order is not found'; // found';
errCode = "QCTRFORD"; errCode = "QCTRFORD";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} } else if ("C".equalsIgnoreCase(status)) {
else if("C".equalsIgnoreCase(status))
{
errCode = "QCTRF0001"; errCode = "QCTRF0001";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
// ls_errcode = 'QCTRF0001~t' + 'QC order is Confirmed. You cannot do transfer for QC order no: ' + ls_qorder_no // ls_errcode = 'QCTRF0001~t' + 'QC order is
} // Confirmed. You cannot do transfer for QC
} // order no: ' + ls_qorder_no
}
if ( errCode== null || errCode.trim().length() == 0 ) }
{
refNo = checkNull(genericUtility.getColumnValue("porcp_no", dom)); if (errCode == null || errCode.trim().length() == 0) {
if (( lotSl != null && lotSl.trim().length() > 0 ) && (refNo != null && refNo.trim().length()>0)) refNo = checkNull(genericUtility.getColumnValue(
{ "porcp_no", dom));
// ls_errcode = gf_chk_pck_dtl(ls_sitecode,ls_itemcode,ls_loc,ls_lotno,ls_qorderno,ls_ref_no,ls_lot_sl) if ((lotSl != null && lotSl.trim().length() > 0)
errCode = chkPckDtl(siteCode,itemCode,locCode,lotNo,qorderNo,refNo,lotSl,conn); && (refNo != null && refNo.trim().length() > 0)) {
if( errCode != null && errCode.trim().length() > 0 ) // ls_errcode =
{ // gf_chk_pck_dtl(ls_sitecode,ls_itemcode,ls_loc,ls_lotno,ls_qorderno,ls_ref_no,ls_lot_sl)
System.out.println("@@@@@ errCode["+errCode+"]"); errCode = chkPckDtl(siteCode, itemCode,
locCode, lotNo, qorderNo, refNo, lotSl,
conn);
if (errCode != null
&& errCode.trim().length() > 0) {
System.out.println("@@@@@ errCode["
+ errCode + "]");
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
...@@ -364,38 +375,39 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -364,38 +375,39 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
} }
} }
if(childNodeName.equalsIgnoreCase("lot_sl")) if (childNodeName.equalsIgnoreCase("lot_sl")) {
{ porcpNo = checkNull(genericUtility.getColumnValue(
porcpNo = checkNull(genericUtility.getColumnValue("porcp_no", dom)); "porcp_no", dom));
itemCode = checkNull( genericUtility.getColumnValue("item_code", dom)); itemCode = checkNull(genericUtility.getColumnValue(
siteCode = checkNull( genericUtility.getColumnValue("site_code", dom)); "item_code", dom));
qcLocCode = genericUtility.getColumnValue("loc_code", dom); siteCode = checkNull(genericUtility.getColumnValue(
"site_code", dom));
qcLocCode = genericUtility.getColumnValue("loc_code",
dom);
lotNo = genericUtility.getColumnValue("lot_no", dom); lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom); lotSl = genericUtility.getColumnValue("lot_sl", dom);
if( lotSl == null || lotSl.trim().length() == 0 ) if (lotSl == null || lotSl.trim().length() == 0) {
{ errCode = "QCTRFLOTSL"; // 'Invalid Lot Sl Please
errCode = "QCTRFLOTSL"; //'Invalid Lot Sl Please enter Lot Sl' // enter Lot Sl'
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
if(errCode == null || errCode.trim().length() == 0 ) if (errCode == null || errCode.trim().length() == 0) {
{ sql = " Select Quantity from stock"
sql = " Select Quantity from stock" + + " Where item_code = ? and site_code = ? "
" Where item_code = ? and site_code = ? " + + " and loc_code = ? and lot_no = ? "
" and loc_code = ? and lot_no = ? " + + " and lot_sl = ? ";
" and lot_sl = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode); pstmt.setString(1, itemCode);
pstmt.setString(2,siteCode); pstmt.setString(2, siteCode);
pstmt.setString(3,qcLocCode); pstmt.setString(3, qcLocCode);
pstmt.setString(4,lotNo); pstmt.setString(4, lotNo);
pstmt.setString(5,lotSl); pstmt.setString(5, lotSl);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
maxQty = rs.getDouble("Quantity"); maxQty = rs.getDouble("Quantity");
cnt++; cnt++;
} }
...@@ -404,9 +416,8 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -404,9 +416,8 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
//If isnull(lc_maxqty) then lc_maxqty = 0 // If isnull(lc_maxqty) then lc_maxqty = 0
if ( cnt == 0) if (cnt == 0) {
{
errCode = "VTQTY51"; errCode = "VTQTY51";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
...@@ -414,28 +425,29 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -414,28 +425,29 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
} }
} }
if( childNodeName.equalsIgnoreCase("quantity")) if (childNodeName.equalsIgnoreCase("quantity")) {
{ itemCode = checkNull(genericUtility.getColumnValue(
itemCode = checkNull( genericUtility.getColumnValue("item_code", dom)); "item_code", dom));
siteCode = checkNull( genericUtility.getColumnValue("site_code", dom)); siteCode = checkNull(genericUtility.getColumnValue(
qcLocCode = genericUtility.getColumnValue("loc_code", dom); "site_code", dom));
qcLocCode = genericUtility.getColumnValue("loc_code",
dom);
lotNo = genericUtility.getColumnValue("lot_no", dom); lotNo = genericUtility.getColumnValue("lot_no", dom);
lotSl = genericUtility.getColumnValue("lot_sl", dom); lotSl = genericUtility.getColumnValue("lot_sl", dom);
sql = " Select Quantity from stock" + sql = " Select Quantity from stock"
" Where item_code = ? and site_code = ? " + + " Where item_code = ? and site_code = ? "
" and loc_code = ? and lot_no = ? " + + " and loc_code = ? and lot_no = ? "
" and lot_sl = ? "; + " and lot_sl = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode); pstmt.setString(1, itemCode);
pstmt.setString(2,siteCode); pstmt.setString(2, siteCode);
pstmt.setString(3,qcLocCode); pstmt.setString(3, qcLocCode);
pstmt.setString(4,lotNo); pstmt.setString(4, lotNo);
pstmt.setString(5,lotSl); pstmt.setString(5, lotSl);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
maxQty = rs.getDouble("quantity"); maxQty = rs.getDouble("quantity");
cnt++; cnt++;
} }
...@@ -444,43 +456,44 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -444,43 +456,44 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if ( cnt == 0) if (cnt == 0) {
{
errCode = "VTQTY51"; errCode = "VTQTY51";
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
//If isnull(lc_maxqty) then lc_maxqty = 0 // If isnull(lc_maxqty) then lc_maxqty = 0
if( errCode == null || errCode.trim().length() == 0 ) if (errCode == null || errCode.trim().length() == 0) {
{ minQtyStr = genericUtility.getColumnValue(
minQtyStr = genericUtility.getColumnValue("quantity", dom); "quantity", dom);
minQty = minQtyStr==null ? 0:Double.parseDouble(minQtyStr); minQty = minQtyStr == null ? 0 : Double
if( minQty > maxQty ) .parseDouble(minQtyStr);
{ if (minQty > maxQty) {
errCode = "QCTRFQTY"; // 'QC Transfer Quantity cannot be more then Stock Quantity ' + string(lc_maxqty) errCode = "QCTRFQTY"; // 'QC Transfer Quantity
// cannot be more then
// Stock Quantity ' +
// string(lc_maxqty)
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} }
if(childNodeName.equalsIgnoreCase("loc_code__trf")) if (childNodeName.equalsIgnoreCase("loc_code__trf")) {
{ qcLocCode = genericUtility.getColumnValue("loc_code",
qcLocCode = genericUtility.getColumnValue("loc_code", dom); dom);
locCode = genericUtility.getColumnValue("loc_code__trf", dom); locCode = genericUtility.getColumnValue(
"loc_code__trf", dom);
if( locCode != null) if (locCode != null) {
{ sql = " Select Available from location a, invstat b "
sql = " Select Available from location a, invstat b " + + " Where a.loc_code = ? and a.inv_stat = b.inv_stat ";
" Where a.loc_code = ? and a.inv_stat = b.inv_stat ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,locCode); pstmt.setString(1, locCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
available = rs.getString("available"); available = rs.getString("available");
} }
rs.close(); rs.close();
...@@ -489,25 +502,23 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -489,25 +502,23 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt = null; pstmt = null;
} }
if(!("N".equalsIgnoreCase(available))) if (!("N".equalsIgnoreCase(available))) {
{ errCode = "QCTRFLOC"; // "Invalid location, location should not be usable"
errCode = "QCTRFLOC"; //"Invalid location, location should not be usable"
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
if( errCode == null || errCode.trim().length()==0 ) if (errCode == null || errCode.trim().length() == 0) {
{ if (qcLocCode.trim().equalsIgnoreCase(
if( qcLocCode.trim().equalsIgnoreCase(locCode.trim())) locCode.trim())) {
{ errCode = "QCTRFLOC"; // 'From and To Location
errCode = "QCTRFLOC"; //'From and To Location Should be different' // Should be different'
errList.add(errCode); errList.add(errCode);
errFields.add(childNodeName.toLowerCase()); errFields.add(childNodeName.toLowerCase());
} }
} }
} }
} // end for } // end for
break; // case 1 end break; // case 1 end
...@@ -516,24 +527,25 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -516,24 +527,25 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
int errListSize = errList.size(); int errListSize = errList.size();
cnt = 0; cnt = 0;
String errFldName = null; String errFldName = null;
if(errList != null && errListSize > 0) if (errList != null && errListSize > 0) {
{ for (cnt = 0; cnt < errListSize; cnt++) {
for(cnt = 0; cnt < errListSize; cnt ++)
{
errCode = errList.get(cnt); errCode = errList.get(cnt);
errFldName = errFields.get(cnt); errFldName = errFields.get(cnt);
System.out.println("errCode .........." + errCode); System.out.println("errCode .........." + errCode);
errString = getErrorString(errFldName, errCode, userId); errString = getErrorString(errFldName, errCode, userId);
errorType = errorType(conn , errCode); errorType = errorType(conn, errCode);
if(errString.length() > 0) if (errString.length() > 0) {
{ String bifurErrString = errString.substring(
String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8, errString.indexOf("<trace>")); errString.indexOf("<Errors>") + 8,
bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8, errString.indexOf("</Errors>")); errString.indexOf("<trace>"));
bifurErrString = bifurErrString
+ errString.substring(
errString.indexOf("</trace>") + 8,
errString.indexOf("</Errors>"));
errStringXml.append(bifurErrString); errStringXml.append(bifurErrString);
errString = ""; errString = "";
} }
if(errorType.equalsIgnoreCase("E")) if (errorType.equalsIgnoreCase("E")) {
{
break; break;
} }
} }
...@@ -542,72 +554,58 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -542,72 +554,58 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
errFields.clear(); errFields.clear();
errFields = null; errFields = null;
errStringXml.append("</Errors> </Root> \r\n"); errStringXml.append("</Errors> </Root> \r\n");
} } else {
else
{
errStringXml = new StringBuffer(""); errStringXml = new StringBuffer("");
} }
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
errString = e.getMessage(); errString = e.getMessage();
throw new ITMException(e); throw new ITMException(e);
} } finally {
finally try {
{ if (conn != null) {
try if (rs != null) {
{
if(conn != null)
{
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
conn.close(); conn.close();
} }
conn = null; conn = null;
} } catch (Exception d) {
catch(Exception d)
{
d.printStackTrace(); d.printStackTrace();
throw new ITMException(d); throw new ITMException(d);
} }
} }
errString = errStringXml.toString(); errString = errStringXml.toString();
return errString; return errString;
}//end of validation }// end of validation
private String chkPckDtl(String siteCode, String itemCode, private String chkPckDtl(String siteCode, String itemCode, String locCode,
String locCode, String lotNo, String qorderNo, String refNo, String lotNo, String qorderNo, String refNo, String lotSl,
String lotSl,Connection conn) throws SQLException Connection conn) throws SQLException {
{
String sql = "",errCode=""; String sql = "", errCode = "";
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null;
int cnt=0; int cnt = 0;
String conf=""; String conf = "";
double noArt=0; double noArt = 0;
sql = " select no_art from stock " + sql = " select no_art from stock "
" where item_code = ? and site_code = ? and loc_code = ? " + + " where item_code = ? and site_code = ? and loc_code = ? "
" and lot_no = ? and lot_sl = ? "; + " and lot_no = ? and lot_sl = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode); pstmt.setString(1, itemCode);
pstmt.setString(2,siteCode); pstmt.setString(2, siteCode);
pstmt.setString(3,locCode); pstmt.setString(3, locCode);
pstmt.setString(4,lotNo); pstmt.setString(4, lotNo);
pstmt.setString(5,lotSl); pstmt.setString(5, lotSl);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
noArt = rs.getInt("no_art"); noArt = rs.getInt("no_art");
} }
rs.close(); rs.close();
...@@ -615,27 +613,25 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -615,27 +613,25 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("@@@@@@ noArt["+noArt+"]"); System.out.println("@@@@@@ noArt[" + noArt + "]");
if ( noArt > 1 ) if (noArt > 1) {
{ sql = " select confirmed from inv_pack_rcp,inv_pack "
sql = " select confirmed from inv_pack_rcp,inv_pack " + + " where inv_pack_rcp.tran_id = inv_pack.tran_id "
" where inv_pack_rcp.tran_id = inv_pack.tran_id " + + " and inv_pack_rcp.order_no = inv_pack.order_no "
" and inv_pack_rcp.order_no = inv_pack.order_no " + + " and inv_pack_rcp.order_no = ? "
" and inv_pack_rcp.order_no = ? " + + " and inv_pack_rcp.item_code = ? "
" and inv_pack_rcp.item_code = ? " + + " and inv_pack_rcp.loc_code = ? "
" and inv_pack_rcp.loc_code = ? " + + " and inv_pack_rcp.lot_no = ? "
" and inv_pack_rcp.lot_no = ? " + + " and inv_pack_rcp.lot_sl = ? "
" and inv_pack_rcp.lot_sl = ? " + + " and case when inv_pack.status is null then 'U' else inv_pack.status end <> 'X' ";
" and case when inv_pack.status is null then 'U' else inv_pack.status end <> 'X' ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refNo); pstmt.setString(1, refNo);
pstmt.setString(2,itemCode); pstmt.setString(2, itemCode);
pstmt.setString(3,locCode); pstmt.setString(3, locCode);
pstmt.setString(4,lotNo); pstmt.setString(4, lotNo);
pstmt.setString(5,lotSl); pstmt.setString(5, lotSl);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
cnt++; cnt++;
conf = rs.getString("confirmed"); conf = rs.getString("confirmed");
} }
...@@ -644,58 +640,55 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -644,58 +640,55 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.println("@@@@@@ cnt["+cnt+"]::::conf:["+conf+"]"); System.out
if( cnt == 0 ) .println("@@@@@@ cnt[" + cnt + "]::::conf:[" + conf + "]");
{ if (cnt == 0) {
errCode = "VTNOPCKLST"; errCode = "VTNOPCKLST";
return errCode; return errCode;
} }
if(!("Y".equalsIgnoreCase(conf) )) if (!("Y".equalsIgnoreCase(conf))) {
{
errCode = "VTPKNOCF"; errCode = "VTPKNOCF";
return errCode; return errCode;
} }
} }
return errCode; return errCode;
} }
// method for item change // method for item change
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException public String itemChanged(String xmlString, String xmlString1,
{ String xmlString2, String objContext, String currentColumn,
String editFlag, String xtraParams) throws RemoteException,
ITMException {
Document dom = null; Document dom = null;
Document dom1 = null; Document dom1 = null;
Document dom2 = null; Document dom2 = null;
System.out.println("itemChanged() called for QCTransferIC"); System.out.println("itemChanged() called for QCTransferIC");
String valueXmlString = ""; String valueXmlString = "";
try try {
{ if (xmlString != null && xmlString.trim().length() > 0) {
if(xmlString != null && xmlString.trim().length() > 0)
{
dom = parseString(xmlString); dom = parseString(xmlString);
} }
if(xmlString1 != null && xmlString1.trim().length() > 0) if (xmlString1 != null && xmlString1.trim().length() > 0) {
{
dom1 = parseString(xmlString1); dom1 = parseString(xmlString1);
} }
if(xmlString2 != null && xmlString2.trim().length() > 0) if (xmlString2 != null && xmlString2.trim().length() > 0) {
{
dom2 = parseString(xmlString2); dom2 = parseString(xmlString2);
} }
valueXmlString = itemChanged(dom, dom1, dom2, objContext, currentColumn, editFlag, xtraParams); valueXmlString = itemChanged(dom, dom1, dom2, objContext,
} currentColumn, editFlag, xtraParams);
catch(Exception e) } catch (Exception e) {
{ System.out
System.out.println("Exception : [QCTransferIC][itemChanged( String, String )] :==>\n" + e.getMessage()); .println("Exception : [QCTransferIC][itemChanged( String, String )] :==>\n"
+ e.getMessage());
} }
return valueXmlString; return valueXmlString;
} }
// method for item change // method for item change
public String itemChanged(Document dom, Document dom1, Document dom2, 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 {
String childNodeName = null; String childNodeName = null;
String sql = ""; String sql = "";
StringBuffer valueXmlString = new StringBuffer(); StringBuffer valueXmlString = new StringBuffer();
...@@ -706,20 +699,27 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -706,20 +699,27 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
Node childNode = null; Node childNode = null;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
int currentFormNo =0; int currentFormNo = 0;
String columnValue="",itemCode="",itemDescr=""; String columnValue = "", itemCode = "", itemDescr = "";
String siteDescr="",qorderNo="",loginSiteCode="",locCode="",porcpNo="",lotSl="",batchNo="",siteCode="",lotNo=""; String siteDescr = "", qorderNo = "", loginSiteCode = "", locCode = "", porcpNo = "", lotSl = "", batchNo = "", siteCode = "", lotNo = "";
String locDescr="",locCodeTrf=""; String locDescr = "", locCodeTrf = "";
double quantity=0; double quantity = 0;
try DistCommon discommon = new DistCommon();
{ double stdQty1=0,convTemp=0,noArt=0,netWeight=0,stdQty2=0;
ArrayList setNoartWeightQtyList = null,quantityList=null;
String quantityStr="",noArtUnit="",unit="",weightUnit="",netWeightStr="",noArtStr="";
try {
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(
genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime()); String sysDate = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDate); System.out.println("Now the date is :=> " + sysDate);
...@@ -727,265 +727,458 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT ...@@ -727,265 +727,458 @@ public class QCTransferIC extends ValidatorEJB implements QCTransferICLocal, QCT
conn.setAutoCommit(false); conn.setAutoCommit(false);
connDriver = null; connDriver = null;
if(objContext != null && objContext.trim().length()>0) if (objContext != null && objContext.trim().length() > 0) {
{
currentFormNo = Integer.parseInt(objContext.trim()); currentFormNo = Integer.parseInt(objContext.trim());
} }
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?> <Root> <header> <editFlag>"); valueXmlString = new StringBuffer(
"<?xml version = \"1.0\"?> <Root> <header> <editFlag>");
valueXmlString.append(editFlag).append("</editFlag> </header>"); valueXmlString.append(editFlag).append("</editFlag> </header>");
System.out.println("**********ITEMCHANGE FOR CASE"+currentFormNo+"**************"); System.out.println("**********ITEMCHANGE FOR CASE" + currentFormNo
switch(currentFormNo) + "**************");
{ switch (currentFormNo) {
case 1 : case 1:
parentNodeList = dom.getElementsByTagName("Detail1"); parentNodeList = dom.getElementsByTagName("Detail1");
parentNode = parentNodeList.item(0); parentNode = parentNodeList.item(0);
childNodeList = parentNode.getChildNodes(); childNodeList = parentNode.getChildNodes();
ctr = 0; ctr = 0;
valueXmlString.append("<Detail1>"); valueXmlString.append("<Detail1>");
int childNodeListLength = childNodeList.getLength(); int childNodeListLength = childNodeList.getLength();
do do {
{
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if(childNodeName.equals(currentColumn)) if (childNodeName.equals(currentColumn)) {
{ if (childNode.getFirstChild() != null) {
if (childNode.getFirstChild()!= null) columnValue = childNode.getFirstChild()
{ .getNodeValue().trim();
columnValue = childNode.getFirstChild().getNodeValue().trim();
} }
} }
ctr++; ctr++;
} } while (ctr < childNodeListLength
while(ctr < childNodeListLength && !childNodeName.equals(currentColumn)); && !childNodeName.equals(currentColumn));
System.out.println("[" + currentColumn + "] ==> '" + columnValue + "'"); System.out.println("[" + currentColumn + "] ==> '"
+ columnValue + "'");
if (currentColumn.trim().equalsIgnoreCase("itm_default")) {
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
System.out.println("@@@@@@@@ itm_default called @@@@@@@@"); System.out.println("@@@@@@@@ itm_default called @@@@@@@@");
loginSiteCode = genericUtility.getValueFromXTRA_PARAMS( xtraParams, "loginSiteCode" ); loginSiteCode = genericUtility.getValueFromXTRA_PARAMS(
System.out.println("@@@@@@@@loginSiteCode["+loginSiteCode+"]"); xtraParams, "loginSiteCode");
valueXmlString.append("<tran_date>").append("<![CDATA["+sysDate+"]]>").append("</tran_date>"); System.out.println("@@@@@@@@loginSiteCode[" + loginSiteCode
valueXmlString.append("<site_code>").append("<![CDATA["+loginSiteCode+"]]>").append("</site_code>"); + "]");
siteDescr = setDescription("descr","site","site_code", loginSiteCode, conn); valueXmlString.append("<tran_date>")
valueXmlString.append("<site_descr>").append("<![CDATA["+siteDescr+"]]>").append("</site_descr>"); .append("<![CDATA[" + sysDate + "]]>")
} .append("</tran_date>");
valueXmlString.append("<site_code>")
else if(currentColumn.trim().equalsIgnoreCase("qorder_no")) .append("<![CDATA[" + loginSiteCode + "]]>")
{ .append("</site_code>");
siteDescr = setDescription("descr", "site", "site_code",
loginSiteCode, conn);
valueXmlString.append("<site_descr>")
.append("<![CDATA[" + siteDescr + "]]>")
.append("</site_descr>");
}
else if (currentColumn.trim().equalsIgnoreCase("qorder_no")) {
System.out.println("@@@@@@@@ qorder_no called @@@@@@@@"); System.out.println("@@@@@@@@ qorder_no called @@@@@@@@");
qorderNo = checkNull(genericUtility.getColumnValue("qorder_no", dom)); qorderNo = checkNull(genericUtility.getColumnValue(
"qorder_no", dom));
sql = " Select quantity, item_code, loc_code, porcp_no, lot_no, lot_sl, batch_no, site_code" + sql = " Select quantity, item_code, loc_code, porcp_no, lot_no, lot_sl, batch_no, site_code"
" from qc_order where qorder_no = ? "; + " from qc_order where qorder_no = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo); pstmt.setString(1, qorderNo);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{
quantity = rs.getDouble("quantity"); quantity = rs.getDouble("quantity");
itemCode = checkNull( rs.getString("item_code")); itemCode = checkNull(rs.getString("item_code"));
locCode = checkNull( rs.getString("loc_code")); locCode = checkNull(rs.getString("loc_code"));
porcpNo = checkNull( rs.getString("porcp_no")); porcpNo = checkNull(rs.getString("porcp_no"));
lotNo = checkNull( rs.getString("lot_no")); lotNo = checkNull(rs.getString("lot_no"));
lotSl = checkNull( rs.getString("lot_sl")); lotSl = checkNull(rs.getString("lot_sl"));
batchNo = checkNull( rs.getString("batch_no")); batchNo = checkNull(rs.getString("batch_no"));
siteCode = checkNull( rs.getString("site_code")); siteCode = checkNull(rs.getString("site_code"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
valueXmlString.append("<quantity__o>").append("<![CDATA["+quantity+"]]>").append("</quantity__o>"); valueXmlString.append("<quantity__o>")
valueXmlString.append("<item_code>").append("<![CDATA["+itemCode+"]]>").append("</item_code>"); .append("<![CDATA[" + quantity + "]]>")
valueXmlString.append("<loc_code>").append("<![CDATA["+locCode+"]]>").append("</loc_code>"); .append("</quantity__o>");
valueXmlString.append("<porcp_no>").append("<![CDATA["+porcpNo+"]]>").append("</porcp_no>"); valueXmlString.append("<item_code>")
valueXmlString.append("<lot_no>").append("<![CDATA["+lotNo+"]]>").append("</lot_no>"); .append("<![CDATA[" + itemCode + "]]>")
valueXmlString.append("<lot_sl>").append("<![CDATA["+lotSl+"]]>").append("</lot_sl>"); .append("</item_code>");
valueXmlString.append("<site_code>").append("<![CDATA["+siteCode+"]]>").append("</site_code>"); valueXmlString.append("<loc_code>")
valueXmlString.append("<batch_no>").append("<![CDATA["+batchNo+"]]>").append("</batch_no>"); .append("<![CDATA[" + locCode + "]]>")
.append("</loc_code>");
if( locCode != null && locCode.trim().length() > 0 ) valueXmlString.append("<porcp_no>")
{ .append("<![CDATA[" + porcpNo + "]]>")
locDescr = setDescription("descr","location","loc_code", locCode, conn); .append("</porcp_no>");
valueXmlString.append("<location_descr>").append("<![CDATA["+locDescr+"]]>").append("</location_descr>"); valueXmlString.append("<lot_no>")
} .append("<![CDATA[" + lotNo + "]]>")
.append("</lot_no>");
if( itemCode != null && itemCode.trim().length() > 0 ) valueXmlString.append("<lot_sl>")
{ .append("<![CDATA[" + lotSl + "]]>")
itemDescr = setDescription("descr","item","item_Code", itemCode, conn); .append("</lot_sl>");
valueXmlString.append("<item_descr>").append("<![CDATA["+itemDescr+"]]>").append("</item_descr>"); valueXmlString.append("<site_code>")
} .append("<![CDATA[" + siteCode + "]]>")
.append("</site_code>");
} valueXmlString.append("<batch_no>")
.append("<![CDATA[" + batchNo + "]]>")
else if(currentColumn.trim().equalsIgnoreCase("lot_sl")) .append("</batch_no>");
{
if (locCode != null && locCode.trim().length() > 0) {
locDescr = setDescription("descr", "location",
"loc_code", locCode, conn);
valueXmlString.append("<location_descr>")
.append("<![CDATA[" + locDescr + "]]>")
.append("</location_descr>");
}
if (itemCode != null && itemCode.trim().length() > 0) {
itemDescr = setDescription("descr", "item",
"item_Code", itemCode, conn);
valueXmlString.append("<item_descr>")
.append("<![CDATA[" + itemDescr + "]]>")
.append("</item_descr>");
}
}
else if (currentColumn.trim().equalsIgnoreCase("lot_sl")) {
System.out.println("@@@@@@@@ lot_sl called @@@@@@@@"); System.out.println("@@@@@@@@ lot_sl called @@@@@@@@");
qorderNo = checkNull(genericUtility.getColumnValue("qorder_no", dom)); qorderNo = checkNull(genericUtility.getColumnValue(
"qorder_no", dom));
if( qorderNo != null && qorderNo.trim().length() > 0 ) if (qorderNo != null && qorderNo.trim().length() > 0) {
{ locCode = setDescription("loc_code", "qc_order",
locCode = setDescription("loc_code","qc_order","qorder_no", qorderNo, conn); "qorder_no", qorderNo, conn);
} }
if ( locCode == null || locCode.trim().length() == 0 ) if (locCode == null || locCode.trim().length() == 0) {
{
lotSl = genericUtility.getColumnValue("lot_sl", dom); lotSl = genericUtility.getColumnValue("lot_sl", dom);
lotNo = genericUtility.getColumnValue("lot_no", dom); lotNo = genericUtility.getColumnValue("lot_no", dom);
siteCode = checkNull(genericUtility.getColumnValue("site_code", dom)); siteCode = checkNull(genericUtility.getColumnValue(
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom)); "site_code", dom));
itemCode = checkNull(genericUtility.getColumnValue(
"item_code", dom));
sql = " select loc_code from stock " + sql = " select loc_code from stock "
" where item_code = ? and lot_no = ? and lot_sl = ? and site_code = ? and quantity > 0 "; + " where item_code = ? and lot_no = ? and lot_sl = ? and site_code = ? and quantity > 0 ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode); pstmt.setString(1, itemCode);
pstmt.setString(2, lotNo); pstmt.setString(2, lotNo);
pstmt.setString(3, lotSl); pstmt.setString(3, lotSl);
pstmt.setString(4, siteCode); pstmt.setString(4, siteCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ locCode = checkNull(rs.getString("loc_code"));
locCode = checkNull( rs.getString("loc_code"));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if( locCode != null && locCode.trim().length() > 0 ) if (locCode != null && locCode.trim().length() > 0) {
{ valueXmlString.append("<loc_code>")
valueXmlString.append("<loc_code>").append("<![CDATA["+locCode+"]]>").append("</loc_code>"); .append("<![CDATA[" + locCode + "]]>")
.append("</loc_code>");
} }
} }
} }
else if(currentColumn.trim().equalsIgnoreCase("loc_code__trf")) else if (currentColumn.trim().equalsIgnoreCase("loc_code__trf"))
{ {
System.out.println("@@@@@@@@ loc_code__trf called @@@@@@@@"); System.out.println("@@@@@@@@ loc_code__trf called @@@@@@@@");
locCodeTrf = checkNull(genericUtility.getColumnValue("loc_code__trf", dom)); locCodeTrf = checkNull(genericUtility.getColumnValue(
if ( locCodeTrf.trim().length() < 8 ) "loc_code__trf", dom));
{ if (locCodeTrf.trim().length() < 8) {
locCodeTrf = locCodeTrf + " "; locCodeTrf = locCodeTrf + " ";
locCodeTrf = locCodeTrf.substring(0, 8); locCodeTrf = locCodeTrf.substring(0, 8);
} }
locDescr = setDescription("descr", "location", "loc_code", locCodeTrf , conn); locDescr = setDescription("descr", "location", "loc_code",
valueXmlString.append("<location_transfer>").append("<![CDATA["+locDescr+"]]>").append("</location_transfer>"); locCodeTrf, conn);
valueXmlString.append("<location_transfer>")
.append("<![CDATA[" + locDescr + "]]>")
.append("</location_transfer>");
}
// // added by cpatil on 12-11-13 start
else if (currentColumn.trim().equalsIgnoreCase("quantity"))
{
System.out.println("@@@@@@@@ quantity called @@@@@@@@");
quantityStr = checkNull(genericUtility.getColumnValue("quantity", dom));
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
unit = setDescription("unit", "item", "item_code", itemCode, conn);
quantity = quantityStr==null?0:Double.parseDouble(quantityStr);
System.out.println("@@@@@@ unit["+unit+"]:::::quantity["+quantity+"]");
setNoartWeightQtyList = setNoartWeightQty("Q",quantity,unit,itemCode, conn);
if(setNoartWeightQtyList != null && setNoartWeightQtyList.size() > 0 )
{
stdQty1 = Double.parseDouble( setNoartWeightQtyList.get(0).toString() );
}
valueXmlString.append("<no_art>").append("<![CDATA[" + stdQty1 + "]]>").append("</no_art>");
if(setNoartWeightQtyList != null && setNoartWeightQtyList.size() > 1 )
{
stdQty2 = Double.parseDouble( setNoartWeightQtyList.get(1).toString() );
}
valueXmlString.append("<net_weight>").append("<![CDATA[" + stdQty2 + "]]>").append("</net_weight>");
}
else if (currentColumn.trim().equalsIgnoreCase("no_art"))
{
System.out.println("@@@@@@@@ no_art called @@@@@@@@");
noArtStr = checkNull(genericUtility.getColumnValue("no_art", dom));
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
unit = setDescription("unit", "item", "item_code", itemCode, conn);
System.out.println("@@@@@@ unit["+unit+"]:::::noArt["+noArt+"]");
noArt = noArtStr==null?0:Double.parseDouble(noArtStr);
setNoartWeightQtyList = setNoartWeightQty("A",noArt,unit,itemCode, conn);
if(setNoartWeightQtyList != null && setNoartWeightQtyList.size() > 0 )
{
stdQty1 = Double.parseDouble( setNoartWeightQtyList.get(0).toString() );
}
valueXmlString.append("<quantity>").append("<![CDATA[" + stdQty1 + "]]>").append("</quantity>");
if(setNoartWeightQtyList != null && setNoartWeightQtyList.size() > 1 )
{
stdQty2 = Double.parseDouble( setNoartWeightQtyList.get(1).toString() );
}
valueXmlString.append("<net_weight>").append("<![CDATA[" + stdQty2 + "]]>").append("</net_weight>");
} }
else if (currentColumn.trim().equalsIgnoreCase("net_weight"))
{
System.out.println("@@@@@@@@ net_weight called @@@@@@@@");
netWeightStr = checkNull(genericUtility.getColumnValue("net_weight", dom));
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
unit = setDescription("unit", "item", "item_code", itemCode, conn);
System.out.println("@@@@@@ unit["+unit+"]:::::netWeight["+netWeight+"]");
netWeight = netWeightStr==null?0:Double.parseDouble(netWeightStr);
setNoartWeightQtyList = setNoartWeightQty("W",netWeight,unit,itemCode, conn);
if(setNoartWeightQtyList != null && setNoartWeightQtyList.size() > 0 )
{
stdQty1 = Double.parseDouble( setNoartWeightQtyList.get(0).toString() );
}
valueXmlString.append("<quantity>").append("<![CDATA[" + stdQty1 + "]]>").append("</quantity>");
if(setNoartWeightQtyList != null && setNoartWeightQtyList.size() > 1 )
{
stdQty2 = Double.parseDouble( setNoartWeightQtyList.get(1).toString() );
}
valueXmlString.append("<no_art>").append("<![CDATA[" + stdQty2 + "]]>").append("</no_art>");
}
// // added by cpatil on 12-11-13 end
valueXmlString.append("</Detail1>"); valueXmlString.append("</Detail1>");
break; break;
} // case 1 end } // case 1 end
valueXmlString.append("</Root>"); valueXmlString.append("</Root>");
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception ::"+ e.getMessage()); System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} finally {
try {
if (conn != null) {
if (rs != null) {
rs.close();
rs = null;
} }
finally if (pstmt != null) {
pstmt.close();
pstmt = null;
}
conn.close();
}
conn = null;
} catch (Exception d) {
d.printStackTrace();
}
}
return valueXmlString.toString();
}
private ArrayList setNoartWeightQty(String flag,Double quantity,String unit,String itemCode,Connection conn) throws ITMException, Exception
{ {
try
System.out.println("@@@@@@@@ setNoartWeightQty() called ["+flag+"]@@@@@@@@");
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
ArrayList retValue = new ArrayList();
ArrayList convQtyFactorList = new ArrayList();
MfgCommon mfgcommon = new MfgCommon();
String mfgAutoConv = "", phyAattributeArt = "", phyAttributeWeight = "", noArtUnit = "", weightUnit = "";
double stdQty1=0,convTemp=0,stdQty2=0;
DistCommon discommon= new DistCommon();
mfgAutoConv = mfgcommon.getEnvMfg("999999", "MFG_AUTO_CONV", conn);
if (mfgAutoConv == null || "NULLFOUND".equalsIgnoreCase(mfgAutoConv) || mfgAutoConv.trim().length() == 0)
{ {
if(conn != null) mfgAutoConv = "N";
return retValue;
}
phyAattributeArt = mfgcommon.getEnvMfg("999999", "MFG_NO_ART_UNIT",conn);
phyAattributeArt = phyAattributeArt == null ? "" : phyAattributeArt.trim();
phyAttributeWeight = mfgcommon.getEnvMfg("999999", "MFG_WEIGHT_UNIT",conn);
phyAttributeWeight = phyAattributeArt == null ? "" : phyAttributeWeight.trim();
if (phyAattributeArt == null || "NULLFOUND".equalsIgnoreCase(phyAattributeArt) || phyAattributeArt.trim().length() == 0)
{
phyAattributeArt = "";
}
else
{ {
if(rs != null) if ("Y".equalsIgnoreCase(mfgAutoConv))
{ {
sql = "SELECT " + phyAattributeArt + " FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
noArtUnit = checkNull(rs.getString(1));
}
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close();
pstmt = null;
}
} }
if(pstmt != null)
if (phyAttributeWeight == null || "NULLFOUND".equalsIgnoreCase(phyAttributeWeight) || phyAttributeWeight.trim().length() == 0)
{
phyAttributeWeight = "";
}
else
{
if ("Y".equalsIgnoreCase(mfgAutoConv))
{
sql = "SELECT " + phyAttributeWeight + " FROM ITEM WHERE ITEM_CODE = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{ {
weightUnit = checkNull(rs.getString(1));
}
rs.close();
rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
}
}
System.out.println("@@@@@@@@@ noArtUnit["+noArtUnit+"]:::::weightUnit["+weightUnit+"]");
if( noArtUnit != null && noArtUnit.trim().length() > 0 )
{ if("Q".equalsIgnoreCase(flag))
{
convQtyFactorList = discommon.convQtyFactor(unit,noArtUnit,itemCode, quantity, convTemp, conn);
} }
conn.close(); else if("A".equalsIgnoreCase(flag))
{
convQtyFactorList = discommon.convQtyFactor(noArtUnit,unit,itemCode, quantity, convTemp, conn);
} }
conn = null; else if("W".equalsIgnoreCase(flag))
{
convQtyFactorList = discommon.convQtyFactor(weightUnit,unit,itemCode, quantity, convTemp, conn);
} }
catch(Exception d)
stdQty1 = Double.parseDouble( convQtyFactorList.get(1).toString() );
retValue.add(stdQty1);
convTemp = 0;
if("Q".equalsIgnoreCase(flag))
{ {
d.printStackTrace(); convQtyFactorList = discommon.convQtyFactor(unit,weightUnit,itemCode, quantity, convTemp, conn);
} }
else if("A".equalsIgnoreCase(flag))
{
convQtyFactorList = discommon.convQtyFactor(noArtUnit,weightUnit,itemCode, quantity, convTemp, conn);
} }
return valueXmlString.toString(); else if("W".equalsIgnoreCase(flag))
{
convQtyFactorList = discommon.convQtyFactor(weightUnit,noArtUnit,itemCode, quantity, convTemp, conn);
} }
private String setDescription(String descrCol, String table,String field, String value,Connection conn) throws SQLException stdQty2 = Double.parseDouble( convQtyFactorList.get(1).toString() );
{ retValue.add(stdQty2);
}
System.out.println("stdQty1["+stdQty1+"]::::stdQty2["+stdQty2+"]");
return retValue;
}
private String setDescription(String descrCol, String table, String field,
String value, Connection conn) throws SQLException {
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null ; ResultSet rs = null;
String sql="",descr=""; String sql = "", descr = "";
System.out.println("@@@@@@@@table["+table+"]:::field["+field+"]::value["+value+"]"); System.out.println("@@@@@@@@table[" + table + "]:::field[" + field
sql = "select "+ descrCol +" from "+ table +" where " + field + " = ? "; + "]::value[" + value + "]");
sql = "select " + descrCol + " from " + table + " where " + field
+ " = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, value); pstmt.setString(1, value);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ descr = checkNull(rs.getString(1));
descr = checkNull( rs.getString(1));
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
System.out.print("========>::descr["+descr+"]"); System.out.print("========>::descr[" + descr + "]");
return descr; return descr;
} }
private String checkNull(String input) private String checkNull(String input) {
{ if (input == null) {
if(input == null)
{
input = ""; input = "";
} }
return input; return input;
} }
private String errorType(Connection conn , String errorCode) private String errorType(Connection conn, String errorCode) {
{
String msgType = ""; String msgType = "";
PreparedStatement pstmt = null ; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
try try {
{
String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?"; String sql = "SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,errorCode); pstmt.setString(1, errorCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while(rs.next()) while (rs.next()) {
{ msgType = checkNull(rs.getString("MSG_TYPE"));
msgType = checkNull( rs.getString("MSG_TYPE"));
}
} }
catch(Exception ex) } catch (Exception ex) {
{
ex.printStackTrace(); ex.printStackTrace();
} } finally {
finally try {
{ if (rs != null) {
try
{
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
} }
} }
......
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