Commit 10b4ac50 authored by vkadam's avatar vkadam

Merge by C Patil. Change converted quantity for different units.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@96592 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c0d4c1e8
package ibase.webitm.ejb.mfg; package ibase.webitm.ejb.mfg;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon; import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.dis.StockUpdate; import ibase.webitm.ejb.dis.StockUpdate;
import ibase.webitm.ejb.sys.CreateRCPXML; import ibase.webitm.ejb.sys.CreateRCPXML;
import org.w3c.dom.*; import org.w3c.dom.*;
import java.sql.*; import java.sql.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import ibase.webitm.utility.GenericUtility; import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import javax.ejb.Stateless; import javax.ejb.Stateless;
import java.util.Calendar; import java.util.Calendar;
import java.util.HashMap; import java.util.HashMap;
@Stateless @Stateless
public class QCTransferConf extends ActionHandlerEJB implements public class QCTransferConf extends ActionHandlerEJB implements
QCTransferConfLocal, QCTransferConfRemote QCTransferConfLocal, QCTransferConfRemote
{ {
public String actionHandler() throws RemoteException, ITMException public String actionHandler() throws RemoteException, ITMException
{ {
return ""; return "";
} }
public String actionHandler(String actionType, String xmlString, public String actionHandler(String actionType, String xmlString,
String objContext, String xtraParams) throws RemoteException, String objContext, String xtraParams) throws RemoteException,
ITMException ITMException
{ {
System.out.println("item actionHandler(...) called............"); System.out.println("item actionHandler(...) called............");
String str = ""; String str = "";
System.out.println("actionType---" + actionType); System.out.println("actionType---" + actionType);
System.out.println("xmlString---" + xmlString); System.out.println("xmlString---" + xmlString);
System.out.println("objContext---" + objContext); System.out.println("objContext---" + objContext);
System.out.println("xtraParams---" + xtraParams); System.out.println("xtraParams---" + xtraParams);
return str; return str;
} }
public String confirm(String tranId, String xtraParams, String forcedFlag) public String confirm(String tranId, String xtraParams, String forcedFlag)
throws RemoteException, ITMException throws RemoteException, ITMException
{ {
System.out.println("QCTransferConf confirm called...230914..........."); System.out.println("QCTransferConf confirm called...230914...........");
String confirmed = ""; String confirmed = "";
String sql = ""; String sql = "";
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ITMDBAccessEJB itmDBAccessEJB = null; ITMDBAccessEJB itmDBAccessEJB = null;
String errString = "",errCode=""; String errString = "",errCode="";
ResultSet rs = null; ResultSet rs = null;
//int recCnt = 0, cnt = 0; //int recCnt = 0, cnt = 0;
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
try try
{ {
itmDBAccessEJB = new ITMDBAccessEJB(); itmDBAccessEJB = new ITMDBAccessEJB();
ConnDriver connDriver = null; ConnDriver connDriver = null;
connDriver = new ConnDriver(); connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
conn.setAutoCommit(false); conn.setAutoCommit(false);
if (errString == null || errString.trim().length() == 0) if (errString == null || errString.trim().length() == 0)
{ {
//if ( tranIdFr.equalsIgnoreCase(tranIdTo) ) //if ( tranIdFr.equalsIgnoreCase(tranIdTo) )
//{ //{
// tranId = tranIdFr; // tranId = tranIdFr;
//} //}
if (tranId != null && tranId.trim().length() > 0) if (tranId != null && tranId.trim().length() > 0)
{ {
sql = " select confirmed from qc_transfer where tran_id = ? "; sql = " select confirmed 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())
{ {
confirmed = rs.getString(1); confirmed = rs.getString(1);
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if ("Y".equalsIgnoreCase(confirmed)) if ("Y".equalsIgnoreCase(confirmed))
{ {
errCode = "QCTRFCONF"; //'QC Transfer Already Confirmed' errCode = "QCTRFCONF"; //'QC Transfer Already Confirmed'
errString = itmDBAccessLocal.getErrorString("",errCode,""); errString = itmDBAccessLocal.getErrorString("",errCode,"");
} }
else else
{ {
//errCode = confirmQcTransfer(tranId,1, xtraParams,conn); //errCode = confirmQcTransfer(tranId,1, xtraParams,conn);
errString = confirmQcTransfer(tranId,1, xtraParams,conn); errString = confirmQcTransfer(tranId,1, xtraParams,conn);
System.out.println("@@@@ confirmQcTransfer::errCode["+errString+"]"); System.out.println("@@@@ confirmQcTransfer::errCode["+errString+"]");
/*Commented by Manoj dtd 03/06/2014 /*Commented by Manoj dtd 03/06/2014
if( errCode != null && errCode.trim().length() > 0 ) if( errCode != null && errCode.trim().length() > 0 )
{ {
errString = itmDBAccessLocal.getErrorString("",errCode,""); errString = itmDBAccessLocal.getErrorString("",errCode,"");
}*/ }*/
} }
} }
if (errString == null || errString.trim().length() == 0) if (errString == null || errString.trim().length() == 0)
{ {
errCode = "VTCONFIRM"; errCode = "VTCONFIRM";
errString = itmDBAccessLocal.getErrorString("",errCode,""); errString = itmDBAccessLocal.getErrorString("",errCode,"");
return errString; return errString;
} }
} // end if errstrng } // end if errstrng
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
finally finally
{ {
try try
{ {
if (errString != null && errString.trim().length() > 0 && !("VTCONFIRM".equalsIgnoreCase(errCode))) if (errString != null && errString.trim().length() > 0 && !("VTCONFIRM".equalsIgnoreCase(errCode)))
{ {
conn.rollback(); conn.rollback();
System.out.println("@@@@ Transaction rollback...["+errString+"]::errCode["+errCode+"]"); System.out.println("@@@@ Transaction rollback...["+errString+"]::errCode["+errCode+"]");
conn.close(); conn.close();
conn = null; conn = null;
} }
else else
{ {
conn.commit(); // test conn.commit(); // test
System.out.println("@@@@ Transaction commit....["+errString+"]::errCode["+errCode+"]"); System.out.println("@@@@ Transaction commit....["+errString+"]::errCode["+errCode+"]");
conn.close(); conn.close();
conn = null; conn = null;
} }
} }
catch (Exception e) catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
} }
return errString; return errString;
} }
private String confirmQcTransfer(String tranId, int i, String xtraParams, Connection conn) private String confirmQcTransfer(String tranId, int i, String xtraParams, Connection conn)
throws RemoteException, ITMException throws RemoteException, ITMException
{ {
PreparedStatement pstmt = null, pstmtSql = null; PreparedStatement pstmt = null, pstmtSql = null;
ResultSet rs = null; ResultSet rs = null;
int cnt = 0,updCnt=0; int cnt = 0,updCnt=0;
String retString = "", sql = "", errCode = ""; String retString = "", sql = "", errCode = "";
Timestamp sysDate = null, tranDate = null; Timestamp sysDate = null, tranDate = null;
GenericUtility genericUtility = GenericUtility.getInstance(); GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
String confirmed="",qorderNo="",siteCode="",toLoc="",lotSl="",lotNo="",porcpNo="",fromLoc="",itemCode=""; String confirmed="",qorderNo="",siteCode="",toLoc="",lotSl="",lotNo="",porcpNo="",fromLoc="",itemCode="";
String status="",ediOption="",dataStr = ""; String status="",ediOption="",dataStr = "";
double qty=0,qcQty=0,stkGrossWt=0,stkTareWt=0,stkNetWt=0,qtyPerArt=0,grossWtPerArt=0,tareWtPerArt=0,stockQty=0; double qty=0,qcQty=0,stkGrossWt=0,stkTareWt=0,stkNetWt=0,qtyPerArt=0,grossWtPerArt=0,tareWtPerArt=0,stockQty=0;
HashMap stockUpd = new HashMap(); HashMap stockUpd = new HashMap();
String available=""; String available="";
double aprvLeadTime = 0; double aprvLeadTime = 0;
Timestamp qcOrderDate = null,newQCOrderDate=null; // added by cpatil on 02/11/13 Timestamp qcOrderDate = null,newQCOrderDate=null; // added by cpatil on 02/11/13
String qcOrderItem=""; String qcOrderItem="";
String qcOrdItemUnit="",byprodUnit=""; String qcOrdItemUnit="",byprodUnit="";
double convertedQty=0,netWeight=0; double convertedQty=0,netWeight=0;
boolean isByProduct=false; boolean isByProduct=false;
double noArt=0,convertedNoArt=0,convertedNetWeight=0; double noArt=0,convertedNoArt=0,convertedNetWeight=0;
double rate=0; double rate=0;
double grossRate=0; double grossRate=0;
String dimension=""; String dimension="";
boolean isFound=false; boolean isFound=false;
try double noArtQCTransfer=0,netWeightQCTransfer=0;
{ try
StockUpdate stockUpdate = new StockUpdate(); {
DistCommon dcommon=new DistCommon(); StockUpdate stockUpdate = new StockUpdate();
System.out.println("@@@@@@@@@@@@@@@ confirmQcTransfer method called next.............."); DistCommon dcommon=new DistCommon();
Calendar currentDate = Calendar.getInstance(); System.out.println("@@@@@@@@@@@@@@@ confirmQcTransfer method called next..............");
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); Calendar currentDate = Calendar.getInstance();
String sysDateStr = sdf.format(currentDate.getTime()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
System.out.println("Now the date is :=> " + sysDateStr); String sysDateStr = sdf.format(currentDate.getTime());
sysDate= Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0"); System.out.println("Now the date is :=> " + sysDateStr);
sysDate= Timestamp.valueOf(genericUtility.getValidDateString(sysDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql = " Select confirmed, qorder_no, tran_date ,site_code,loc_code__trf,quantity," +
" lot_sl,lot_no,porcp_no, loc_code,item_code,case when dimension is null then '' else dimension end as dimension " + sql = " Select confirmed, qorder_no, tran_date ,site_code,loc_code__trf,quantity," +
" from qc_transfer where tran_id = ? "; " lot_sl,lot_no,porcp_no, loc_code,item_code,case when dimension is null then '' else dimension end as dimension" +
pstmt = conn.prepareStatement(sql); " , no_art, net_weight " + //added by cpatil on 10/10/14
pstmt.setString(1, tranId); " from qc_transfer where tran_id = ? ";
rs = pstmt.executeQuery(); pstmt = conn.prepareStatement(sql);
if (rs.next()) pstmt.setString(1, tranId);
{ rs = pstmt.executeQuery();
confirmed = rs.getString("confirmed"); if (rs.next())
qorderNo= rs.getString("qorder_no"); {
tranDate= rs.getTimestamp("tran_date"); confirmed = rs.getString("confirmed");
siteCode= rs.getString("site_code"); qorderNo= rs.getString("qorder_no");
toLoc= rs.getString("loc_code__trf"); tranDate= rs.getTimestamp("tran_date");
qty= rs.getDouble("quantity"); siteCode= rs.getString("site_code");
lotSl= rs.getString("lot_sl"); toLoc= rs.getString("loc_code__trf");
lotNo= rs.getString("lot_no"); qty= rs.getDouble("quantity");
porcpNo= rs.getString("porcp_no"); lotSl= rs.getString("lot_sl");
fromLoc= rs.getString("loc_code"); lotNo= rs.getString("lot_no");
itemCode= rs.getString("item_code"); porcpNo= rs.getString("porcp_no");
//noArtQCTransfer= rs.getDouble("no_art"); fromLoc= rs.getString("loc_code");
//netWeightQCTransfer= rs.getDouble("net_weight"); itemCode= rs.getString("item_code");
dimension=rs.getString("dimension"); dimension=rs.getString("dimension");
noArtQCTransfer= rs.getDouble("no_art"); // remove comment by cpatil on 10/10/14
} netWeightQCTransfer= rs.getDouble("net_weight"); // remove comment by cpatil on 10/10/14
rs.close();
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
pstmt.close();
pstmt = null;
sql = " Select status,Quantity, item_code, net_weight, no_art from qc_order where qorder_no = ? "; // added net_weight by cpatil on 05/04/14
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo); sql = " Select status,Quantity, item_code, net_weight, no_art from qc_order where qorder_no = ? "; // added net_weight by cpatil on 05/04/14
rs = pstmt.executeQuery(); pstmt = conn.prepareStatement(sql);
if (rs.next()) pstmt.setString(1, qorderNo);
{ rs = pstmt.executeQuery();
cnt++; if (rs.next())
status = rs.getString("status"); {
qcQty= rs.getDouble("Quantity"); cnt++;
qcOrderItem= rs.getString("item_code"); status = rs.getString("status");
netWeight= rs.getDouble("net_weight"); qcQty= rs.getDouble("Quantity");
noArt= rs.getDouble("no_art"); qcOrderItem= rs.getString("item_code");
} netWeight= rs.getDouble("net_weight");
rs.close(); noArt= rs.getDouble("no_art");
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
pstmt.close();
pstmt = null;
if ( cnt == 0)
{
errCode = "QCTRFORD"; //'QC order is not found' if ( cnt == 0)
return itmDBAccessLocal.getErrorString("",errCode,""); {
//return errCode;//Commented by Manoj dtd 03/06/2014 errCode = "QCTRFORD"; //'QC order is not found'
} return itmDBAccessLocal.getErrorString("",errCode,"");
else if("C".equalsIgnoreCase(status)) //return errCode;//Commented by Manoj dtd 03/06/2014
{ }
errCode = "QCTRFORD"; //'QC order is CONFIRMED cannot Transfer Quantity' else if("C".equalsIgnoreCase(status))
//return errCode; {
return itmDBAccessLocal.getErrorString("",errCode,""); errCode = "QCTRFORD"; //'QC order is CONFIRMED cannot Transfer Quantity'
//return errCode;//Commented by Manoj dtd 03/06/2014 //return errCode;
} return itmDBAccessLocal.getErrorString("",errCode,"");
//return errCode;//Commented by Manoj dtd 03/06/2014
///added by cpatil on 12/12/13 for date validation with approval lead time start }
System.out.println("@@@@ tranDate new validation start--------- "); ///added by cpatil on 12/12/13 for date validation with approval lead time start
if (toLoc != null) System.out.println("@@@@ tranDate new validation start--------- ");
{
sql = " Select Available from location a, invstat b " if (toLoc != null)
+ " Where a.loc_code = ? and a.inv_stat = b.inv_stat "; {
pstmt = conn.prepareStatement(sql); sql = " Select Available from location a, invstat b "
pstmt.setString(1, toLoc); + " Where a.loc_code = ? and a.inv_stat = b.inv_stat ";
rs = pstmt.executeQuery(); pstmt = conn.prepareStatement(sql);
if (rs.next()) pstmt.setString(1, toLoc);
{ rs = pstmt.executeQuery();
available = rs.getString("available"); if (rs.next())
} {
rs.close(); available = rs.getString("available");
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
pstmt.close();
if("Y".equalsIgnoreCase(available)) pstmt = null;
{
sql = " Select aprv_lead_time from siteitem where site_code = ? and item_code = ? "; if("Y".equalsIgnoreCase(available))
pstmt = conn.prepareStatement(sql); {
pstmt.setString(1, siteCode); sql = " Select aprv_lead_time from siteitem where site_code = ? and item_code = ? ";
pstmt.setString(2, itemCode); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); pstmt.setString(1, siteCode);
if (rs.next()) pstmt.setString(2, itemCode);
{ rs = pstmt.executeQuery();
aprvLeadTime = rs.getDouble("aprv_lead_time"); if (rs.next())
} {
rs.close(); aprvLeadTime = rs.getDouble("aprv_lead_time");
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
pstmt.close();
sql = " select qorder_date from qc_order where qorder_no = ? "; pstmt = null;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, qorderNo); sql = " select qorder_date from qc_order where qorder_no = ? ";
rs = pstmt.executeQuery(); pstmt = conn.prepareStatement(sql);
if (rs.next()) pstmt.setString(1, qorderNo);
{ rs = pstmt.executeQuery();
qcOrderDate = rs.getTimestamp("qorder_date"); if (rs.next())
} {
rs.close(); qcOrderDate = rs.getTimestamp("qorder_date");
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
pstmt.close();
System.out.println("@@@@ site code[" + siteCode+ "]::item code[" + itemCode+ "]::aprvLeadTime[" + aprvLeadTime pstmt = null;
+ "]::qcOrderDate[" + qcOrderDate + "]:::tranDate["+tranDate+"]");
System.out.println("@@@@ site code[" + siteCode+ "]::item code[" + itemCode+ "]::aprvLeadTime[" + aprvLeadTime
Calendar cal = Calendar.getInstance(); + "]::qcOrderDate[" + qcOrderDate + "]:::tranDate["+tranDate+"]");
cal.setTime(qcOrderDate);
cal.add(Calendar.DAY_OF_WEEK,(int) Math.round(aprvLeadTime)); Calendar cal = Calendar.getInstance();
newQCOrderDate = new Timestamp(cal.getTime().getTime()); cal.setTime(qcOrderDate);
System.out.println("@@@@ tranDate ["+ tranDate + "]:::: newQCOrderDate ["+ newQCOrderDate + "]:::::"); cal.add(Calendar.DAY_OF_WEEK,(int) Math.round(aprvLeadTime));
newQCOrderDate = new Timestamp(cal.getTime().getTime());
if( tranDate.before(newQCOrderDate)) System.out.println("@@@@ tranDate ["+ tranDate + "]:::: newQCOrderDate ["+ newQCOrderDate + "]:::::");
{
errCode = "VTAPPRLEAD"; if( tranDate.before(newQCOrderDate))
return itmDBAccessLocal.getErrorString("",errCode,""); {
//return errCode;//Commented by Manoj dtd 03/06/2014 errCode = "VTAPPRLEAD";
return itmDBAccessLocal.getErrorString("",errCode,"");
} //return errCode;//Commented by Manoj dtd 03/06/2014
} }
}
System.out.println("@@@@ tranDate new validation end---------errCode["+ errCode + "]"); }
}
///added by cpatil on 12/12/13 for date validation with approval lead time end System.out.println("@@@@ tranDate new validation end---------errCode["+ errCode + "]");
if( errCode == null || errCode.trim().length() == 0 ) ///added by cpatil on 12/12/13 for date validation with approval lead time end
{
sql = " Select quantity from qc_order where qorder_no = ? "; if( errCode == null || errCode.trim().length() == 0 )
pstmt = conn.prepareStatement(sql); {
pstmt.setString(1, qorderNo); sql = " Select quantity from qc_order where qorder_no = ? ";
rs = pstmt.executeQuery(); pstmt = conn.prepareStatement(sql);
if (rs.next()) pstmt.setString(1, qorderNo);
{ rs = pstmt.executeQuery();
cnt++; if (rs.next())
qcQty= rs.getDouble("Quantity"); {
} cnt++;
rs.close(); qcQty= rs.getDouble("Quantity");
rs = null; }
pstmt.close(); rs.close();
pstmt = null; rs = null;
sql="SELECT UNIT FROM ITEM WHERE ITEM_CODE=?"; pstmt.close();
pstmt=conn.prepareStatement(sql); pstmt = null;
pstmt.setString(1,itemCode); sql="SELECT UNIT FROM ITEM WHERE ITEM_CODE=?";
rs=pstmt.executeQuery(); pstmt=conn.prepareStatement(sql);
if(rs.next()) pstmt.setString(1,itemCode);
{ rs=pstmt.executeQuery();
byprodUnit=rs.getString("UNIT"); if(rs.next())
} {
rs.close(); byprodUnit=rs.getString("UNIT");
rs=null; }
pstmt.close(); rs.close();
pstmt=null; rs=null;
pstmt.close();
sql="SELECT UNIT FROM ITEM WHERE ITEM_CODE=?"; pstmt=null;
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,qcOrderItem); sql="SELECT UNIT FROM ITEM WHERE ITEM_CODE=?";
rs=pstmt.executeQuery(); pstmt=conn.prepareStatement(sql);
if(rs.next()) pstmt.setString(1,qcOrderItem);
{ rs=pstmt.executeQuery();
qcOrdItemUnit=rs.getString("UNIT"); if(rs.next())
} {
rs.close(); qcOrdItemUnit=rs.getString("UNIT");
rs=null; }
pstmt.close(); rs.close();
pstmt=null; rs=null;
pstmt.close();
//if(!byprodUnit.equalsIgnoreCase(qcOrdItemUnit)) pstmt=null;
if(!qcOrderItem.equalsIgnoreCase(itemCode))
{ //if(!byprodUnit.equalsIgnoreCase(qcOrdItemUnit))
convertedQty=roundVal(dcommon.convQtyFactor(byprodUnit, qcOrdItemUnit, "X", qty, conn),3); // commented by cpatil on 05/04/14 // remove comment on 08/10/14 by cpatil if(!qcOrderItem.equalsIgnoreCase(itemCode))
{
// modify by cpatil 05/04/14 start // // modify by cpatil on 09/04/14 /* // comment this code as per suggestion of sandip
convertedQty=roundVal(dcommon.convQtyFactor(byprodUnit, qcOrdItemUnit, "X", qty, conn),3); // commented by cpatil on 05/04/14 // remove comment on 08/10/14 by cpatil
System.out.println("@@@@ qc order Qty[qcQty]["+qcQty+"]qc transfer qty[qty]["+qty+"]netWeight["+netWeight+"]noArt["+noArt+"]");
// modify by cpatil 05/04/14 start // // modify by cpatil on 09/04/14
// convertedQty = qty * qcQty / netWeight ; // comment line as per suggestion on 08/10/14 by cpatil and remove comment from above line of convertedQty calculation
System.out.println("@@@@ qc order Qty[qcQty]["+qcQty+"]qc transfer qty[qty]["+qty+"]netWeight["+netWeight+"]noArt["+noArt+"]");
//convertedNetWeight = netWeight ;
convertedNetWeight = netWeight * convertedQty / qcQty ; // convertedQty = qty * qcQty / netWeight ; // comment line as per suggestion on 08/10/14 by cpatil and remove comment from above line of convertedQty calculation
convertedNoArt = noArt * qty / netWeight ; //convertedNetWeight = netWeight ;
convertedNetWeight = netWeight * convertedQty / qcQty ;
System.out.println("@@@@convertedQty["+convertedQty+"]convertedNetWeight["+convertedNetWeight+"]convertedNoArt["+convertedNoArt+"]");
convertedNoArt = noArt * qty / netWeight ;
//// cpatil end // modify by cpatil on 09/04/14 end
System.out.println("@@@@convertedQty["+convertedQty+"]convertedNetWeight["+convertedNetWeight+"]convertedNoArt["+convertedNoArt+"]");
System.out.println("@@@----qcQty["+qcQty+"]convertedQty["+convertedQty+"]");
if(qcQty < convertedQty ) //// cpatil end // modify by cpatil on 09/04/14 end
{
errCode = "QCTRFQTY"; //'QC Transfer quantity more then QC Order Quantity' System.out.println("@@@----qcQty["+qcQty+"]convertedQty["+convertedQty+"]");
return itmDBAccessLocal.getErrorString("",errCode,""); if(qcQty < convertedQty )
//return errCode;//Commented by Manoj dtd 03/06/2014 {
} errCode = "QCTRFQTY"; //'QC Transfer quantity more then QC Order Quantity'
isByProduct=true; return itmDBAccessLocal.getErrorString("",errCode,"");
//itemCode=qcOrderItem; //return errCode;//Commented by Manoj dtd 03/06/2014
}
} isByProduct=true;
else //itemCode=qcOrderItem;
{ */
System.out.println("@@@----qcQty["+qcQty+"]qty["+qty+"]"); // added by cpatil start on 10/10/14 as per suggestion and logic of sandip maurya
if(qcQty < qty ) if(byprodUnit.equalsIgnoreCase(qcOrdItemUnit))
{ {
errCode = "QCTRFQTY"; //'QC Transfer quantity more then QC Order Quantity' convertedQty=roundVal(dcommon.convQtyFactor(byprodUnit, qcOrdItemUnit, "X", qty, conn),3); // commented by cpatil on 05/04/14 // remove comment on 08/10/14 by cpatil
return itmDBAccessLocal.getErrorString("",errCode,""); }
//return errCode;//Commented by Manoj dtd 03/06/2014 else
} {
} convertedQty = qty * qcQty / netWeight ;
}
System.out.println("@@@----qcQty order ["+qcQty+"]qty qc transfer["+qty+"]");
} System.out.println("@@@@ qc order netWeight["+netWeight+"]qc transfer netWeightQCTransfer["+netWeightQCTransfer+"]");
System.out.println("@@@@ qc order noArt["+noArt+"]qc transfer noArtQCTransfer["+noArtQCTransfer+"]");
if( netWeight < netWeightQCTransfer )
if ( errCode == null || errCode.trim().length() == 0 ) {
{ errCode = "QCTRFNTWET"; //'QC Transfer net weight more then QC Order net weight'
cnt=0; return itmDBAccessLocal.getErrorString("",errCode,"");
sql = " Select item_ser,mfg_date,exp_date,retest_date,site_code__mfg,potency_perc,pack_code,inv_stat," + }
" unit,gross_weight,tare_weight, net_weight,pack_instr,dimension,rate,rate__oh,acct_code__inv," + if( noArt < noArtQCTransfer )
" cctr_code__inv,acct_code__oh,cctr_code__oh,supp_code__mfg,grade,gross_rate,conv__qty_stduom," + {
" unit__alt,batch_no,no_art,qty_per_art,gross_wt_per_art,tare_wt_per_art,quantity " + errCode = "QCTRFNOART"; //'QC Transfer no art more then QC Order no art'
" from Stock" + return itmDBAccessLocal.getErrorString("",errCode,"");
" Where item_code = ? and site_code = ? and loc_code = ? and lot_no = ? and lot_Sl = ? "; }
pstmt = conn.prepareStatement(sql); isByProduct=true;
if(isByProduct)
{ convertedNetWeight = netWeightQCTransfer;
pstmt.setString(1, qcOrderItem); convertedNoArt = noArtQCTransfer;
} System.out.println("@@@@convertedQty["+convertedQty+"]convertedNetWeight["+convertedNetWeight+"]convertedNoArt["+convertedNoArt+"]");
else // ended by cpatil 10/10/14
{ }
pstmt.setString(1, itemCode); else
} {
System.out.println("@@@----qcQty["+qcQty+"]qty["+qty+"]");
pstmt.setString(2, siteCode); if(qcQty < qty )
pstmt.setString(3, fromLoc); {
pstmt.setString(4, lotNo); errCode = "QCTRFQTY"; //'QC Transfer quantity more then QC Order Quantity'
pstmt.setString(5, lotSl); return itmDBAccessLocal.getErrorString("",errCode,"");
rs = pstmt.executeQuery(); //return errCode;//Commented by Manoj dtd 03/06/2014
if (rs.next()) }
{ }
cnt++; }
stockUpd.put("item_ser",rs.getString("item_ser"));
stockUpd.put("mfg_date", rs.getTimestamp("mfg_date")); if ( errCode == null || errCode.trim().length() == 0 )
stockUpd.put("exp_date", rs.getTimestamp("exp_date")); {
stockUpd.put("retest_date", rs.getTimestamp("retest_date")); cnt=0;
stockUpd.put("site_code__mfg", rs.getString("site_code__mfg")); sql = " Select item_ser,mfg_date,exp_date,retest_date,site_code__mfg,potency_perc,pack_code,inv_stat," +
stockUpd.put("potency_perc", rs.getString("potency_perc")); " unit,gross_weight,tare_weight, net_weight,pack_instr,dimension,rate,rate__oh,acct_code__inv," +
stockUpd.put("pack_code", rs.getString("pack_code")); " cctr_code__inv,acct_code__oh,cctr_code__oh,supp_code__mfg,grade,gross_rate,conv__qty_stduom," +
stockUpd.put("inv_stat", rs.getString("inv_stat")); " unit__alt,batch_no,no_art,qty_per_art,gross_wt_per_art,tare_wt_per_art,quantity " +
stockUpd.put("unit", rs.getString("unit")); " from Stock" +
stkGrossWt = rs.getDouble("gross_weight"); " Where item_code = ? and site_code = ? and loc_code = ? and lot_no = ? and lot_Sl = ? ";
stkTareWt = rs.getDouble("tare_weight"); pstmt = conn.prepareStatement(sql);
stkNetWt = rs.getDouble("net_weight"); if(isByProduct)
stockUpd.put("pack_instr", rs.getString("pack_instr")); {
//stockUpd.put("dimension", rs.getString("dimension")); //Commented by Manoj dtd 30/05/2014 set from qc_transfer pstmt.setString(1, qcOrderItem);
stockUpd.put("dimension", dimension); }
stockUpd.put("rate", rs.getString("rate")); else
stockUpd.put("rate_oh", rs.getString("rate__oh")); {
stockUpd.put("acct_code_inv", rs.getString("acct_code__inv")); pstmt.setString(1, itemCode);
stockUpd.put("cctr_code_inv", rs.getString("cctr_code__inv")); }
stockUpd.put("acct_code_oh", rs.getString("acct_code__oh"));
stockUpd.put("cctr_code_oh", rs.getString("cctr_code__oh")); pstmt.setString(2, siteCode);
stockUpd.put("supp_code__mfg", rs.getString("supp_code__mfg")); pstmt.setString(3, fromLoc);
stockUpd.put("grade", rs.getString("grade")); pstmt.setString(4, lotNo);
stockUpd.put("gross_rate", rs.getString("gross_rate")); pstmt.setString(5, lotSl);
stockUpd.put("conv__qty_stduom", rs.getString("conv__qty_stduom")); rs = pstmt.executeQuery();
stockUpd.put("unit__alt", rs.getString("unit__alt")); if (rs.next())
stockUpd.put("batch_no", rs.getString("batch_no")); {
stockUpd.put("no_art", rs.getString("no_art")); cnt++;
qtyPerArt = rs.getDouble("qty_per_art"); stockUpd.put("item_ser",rs.getString("item_ser"));
grossWtPerArt = rs.getDouble("gross_wt_per_art"); stockUpd.put("mfg_date", rs.getTimestamp("mfg_date"));
tareWtPerArt = rs.getDouble("tare_wt_per_art"); stockUpd.put("exp_date", rs.getTimestamp("exp_date"));
stockQty = rs.getDouble("quantity"); stockUpd.put("retest_date", rs.getTimestamp("retest_date"));
rate=rs.getDouble("rate"); stockUpd.put("site_code__mfg", rs.getString("site_code__mfg"));
grossRate=rs.getDouble("gross_rate"); stockUpd.put("potency_perc", rs.getString("potency_perc"));
} stockUpd.put("pack_code", rs.getString("pack_code"));
rs.close(); stockUpd.put("inv_stat", rs.getString("inv_stat"));
rs = null; stockUpd.put("unit", rs.getString("unit"));
pstmt.close(); stkGrossWt = rs.getDouble("gross_weight");
pstmt = null; stkTareWt = rs.getDouble("tare_weight");
stkNetWt = rs.getDouble("net_weight");
if( cnt == 0 ) stockUpd.put("pack_instr", rs.getString("pack_instr"));
{ //stockUpd.put("dimension", rs.getString("dimension")); //Commented by Manoj dtd 30/05/2014 set from qc_transfer
errCode = "QCTRFSTK"; //'Item Not Found in Stock...' stockUpd.put("dimension", dimension);
System.out.println("@@@@@@@@@@@@ [QCTRFSTK]"); stockUpd.put("rate", rs.getString("rate"));
return itmDBAccessLocal.getErrorString("",errCode,""); stockUpd.put("rate_oh", rs.getString("rate__oh"));
//return errCode;//Commented by Manoj dtd 03/06/2014 stockUpd.put("acct_code_inv", rs.getString("acct_code__inv"));
}//End if stockUpd.put("cctr_code_inv", rs.getString("cctr_code__inv"));
stockUpd.put("acct_code_oh", rs.getString("acct_code__oh"));
if( errCode == null || errCode.trim().length() == 0 ) stockUpd.put("cctr_code_oh", rs.getString("cctr_code__oh"));
{ stockUpd.put("supp_code__mfg", rs.getString("supp_code__mfg"));
//Added by manoj dtd 31/05/2014 to set rate for byproduct stockUpd.put("grade", rs.getString("grade"));
if(isByProduct) stockUpd.put("gross_rate", rs.getString("gross_rate"));
{ stockUpd.put("conv__qty_stduom", rs.getString("conv__qty_stduom"));
String considerYield="N"; stockUpd.put("unit__alt", rs.getString("unit__alt"));
double costRate=0; stockUpd.put("batch_no", rs.getString("batch_no"));
sql="select case when consider_yield is null then 'N' else consider_yield end consider_yield from byproduct where item_code__byprod=? and item_code=?"; stockUpd.put("no_art", rs.getString("no_art"));
pstmt=conn.prepareStatement(sql); qtyPerArt = rs.getDouble("qty_per_art");
pstmt.setString(1,itemCode); grossWtPerArt = rs.getDouble("gross_wt_per_art");
pstmt.setString(2,qcOrderItem); tareWtPerArt = rs.getDouble("tare_wt_per_art");
rs = pstmt.executeQuery(); stockQty = rs.getDouble("quantity");
if(rs.next()) rate=rs.getDouble("rate");
{ grossRate=rs.getDouble("gross_rate");
considerYield=rs.getString(1); }
} rs.close();
rs.close(); rs = null;
rs=null; pstmt.close();
pstmt.close(); pstmt = null;
pstmt=null;
if(considerYield.equalsIgnoreCase("N")) if( cnt == 0 )
{ {
errCode = "QCTRFSTK"; //'Item Not Found in Stock...'
sql="select cost_rate from siteitem where site_code=? and item_code=?"; System.out.println("@@@@@@@@@@@@ [QCTRFSTK]");
pstmt=conn.prepareStatement(sql); return itmDBAccessLocal.getErrorString("",errCode,"");
pstmt.setString(1,siteCode); //return errCode;//Commented by Manoj dtd 03/06/2014
pstmt.setString(2,itemCode); }//End if
rs=pstmt.executeQuery();
if(rs.next()) if( errCode == null || errCode.trim().length() == 0 )
{ {
costRate=rs.getDouble(1); //Added by manoj dtd 31/05/2014 to set rate for byproduct
isFound=true; if(isByProduct)
{
} String considerYield="N";
rs.close(); double costRate=0;
rs=null; sql="select case when consider_yield is null then 'N' else consider_yield end consider_yield from byproduct where item_code__byprod=? and item_code=?";
pstmt.close(); pstmt=conn.prepareStatement(sql);
pstmt=null; pstmt.setString(1,itemCode);
pstmt.setString(2,qcOrderItem);
if(!isFound) rs = pstmt.executeQuery();
{ if(rs.next())
sql="select cost_rate from item where item_code=?"; {
pstmt=conn.prepareStatement(sql); considerYield=rs.getString(1);
pstmt.setString(1,itemCode); }
rs=pstmt.executeQuery(); rs.close();
if(rs.next()) rs=null;
{ pstmt.close();
costRate=rs.getDouble(1); pstmt=null;
} if(considerYield.equalsIgnoreCase("N"))
rs.close(); {
rs=null;
pstmt.close(); sql="select cost_rate from siteitem where site_code=? and item_code=?";
pstmt=null; pstmt=conn.prepareStatement(sql);
} pstmt.setString(1,siteCode);
stockUpd.put("rate", costRate); pstmt.setString(2,itemCode);
stockUpd.put("gross_rate", costRate); rs=pstmt.executeQuery();
if(rs.next())
} {
else costRate=rs.getDouble(1);
{ isFound=true;
double convQty=0;
}
convQty=dcommon.convQtyFactor(qcOrdItemUnit,byprodUnit, "X", convertedQty, conn); rs.close();
rs=null;
System.out.println("convQty-----"+convQty); pstmt.close();
System.out.println("rate before conversion-----"+rate); pstmt=null;
rate=roundVal((rate/convertedQty)*convQty,3);
System.out.println("rate after conversion-----"+rate); if(!isFound)
grossRate=roundVal((grossRate/convertedQty)*convQty,3); {
stockUpd.put("rate", rate); sql="select cost_rate from item where item_code=?";
stockUpd.put("gross_rate", grossRate); pstmt=conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
} rs=pstmt.executeQuery();
if(rs.next())
{
costRate=rs.getDouble(1);
} }
sql = " Select unit From item where item_code = ? "; rs.close();
pstmt = conn.prepareStatement(sql); rs=null;
if(isByProduct) pstmt.close();
{ pstmt=null;
pstmt.setString(1,qcOrderItem); }
} stockUpd.put("rate", costRate);
else stockUpd.put("gross_rate", costRate);
{
pstmt.setString(1,itemCode); }
} else
rs = pstmt.executeQuery(); {
if(rs.next()) double convQty=0;
{
stockUpd.put("unit", rs.getString("unit")); convQty=dcommon.convQtyFactor(qcOrdItemUnit,byprodUnit, "X", convertedQty, conn);
}
rs.close(); System.out.println("convQty-----"+convQty);
rs = null; System.out.println("rate before conversion-----"+rate);
pstmt.close(); rate=roundVal((rate/convertedQty)*convQty,3);
pstmt = null; System.out.println("rate after conversion-----"+rate);
grossRate=roundVal((grossRate/convertedQty)*convQty,3);
sql = " Select inv_stat from location Where loc_code = ? "; stockUpd.put("rate", rate);
pstmt = conn.prepareStatement(sql); stockUpd.put("gross_rate", grossRate);
pstmt.setString(1,fromLoc);
rs = pstmt.executeQuery(); }
if(rs.next())
{
stockUpd.put("inv_stat", rs.getString("inv_stat"));
} }
rs.close(); sql = " Select unit From item where item_code = ? ";
rs = null; pstmt = conn.prepareStatement(sql);
pstmt.close(); if(isByProduct)
pstmt = null; {
pstmt.setString(1,qcOrderItem);
stockUpd.put("tran_type", "I"); }
stockUpd.put("tran_ser","QC-TRF" ); else
stockUpd.put("tranid",tranId ); //pending {
if(isByProduct) pstmt.setString(1,itemCode);
{ }
stockUpd.put("item_code", qcOrderItem); rs = pstmt.executeQuery();
} if(rs.next())
else {
{ stockUpd.put("unit", rs.getString("unit"));
stockUpd.put("item_code", itemCode); }
} rs.close();
rs = null;
stockUpd.put("site_code", siteCode); pstmt.close();
stockUpd.put("loc_code", fromLoc ); pstmt = null;
stockUpd.put("lot_no",lotNo );
stockUpd.put("lot_sl",lotSl ); sql = " Select inv_stat from location Where loc_code = ? ";
stockUpd.put("tran_date", tranDate); pstmt = conn.prepareStatement(sql);
if(isByProduct) pstmt.setString(1,fromLoc);
{ rs = pstmt.executeQuery();
stockUpd.put("quantity",convertedQty ); if(rs.next())
stockUpd.put("qty_stduom",convertedQty ); {
} stockUpd.put("inv_stat", rs.getString("inv_stat"));
else }
{ rs.close();
stockUpd.put("quantity",qty ); rs = null;
stockUpd.put("qty_stduom",qty ); pstmt.close();
} pstmt = null;
stockUpd.put("tran_type", "I");
if ( qtyPerArt == 0 ) //isnull(lc_qtyperart) or lc_qtyperart = 0 then stockUpd.put("tran_ser","QC-TRF" );
{ stockUpd.put("tranid",tranId ); //pending
qtyPerArt = 1; if(isByProduct)
} {
stockUpd.put("item_code", qcOrderItem);
stockUpd.put("no_art",Math.ceil(Double.parseDouble(stockUpd.get("qty_stduom").toString())/qtyPerArt)); }
if(stockQty != 0 ) else
{ {
stockUpd.put("net_weight",stkNetWt / stockQty * Double.parseDouble( stockUpd.get("qty_stduom").toString())); stockUpd.put("item_code", itemCode);
stockUpd.put("tare_weight", tareWtPerArt * Double.parseDouble(stockUpd.get("no_art").toString())); }
stockUpd.put("gross_weight", ( Double.parseDouble(stockUpd.get("net_weight").toString()) + Double.parseDouble(stockUpd.get("tare_weight").toString())) );
}//end if stockUpd.put("site_code", siteCode);
// ls_errcode = nvo_dis.gbf_update_stock(lstr_stkupd) stockUpd.put("loc_code", fromLoc );
errCode = stockUpdate.updateStock(stockUpd,xtraParams, conn); stockUpd.put("lot_no",lotNo );
if(errCode !=null && errCode.trim().length() >0) //if(retString !=null && retString.trim().length() >0) stockUpd.put("lot_sl",lotSl );
{ stockUpd.put("tran_date", tranDate);
return errCode; if(isByProduct)
} {
stockUpd.put("quantity",convertedQty );
}//end if stockUpd.put("qty_stduom",convertedQty );
}
if( errCode == null || errCode.trim().length() == 0 ) else
{ {
sql = " Select inv_stat from location Where loc_code = ? "; stockUpd.put("quantity",qty );
pstmt = conn.prepareStatement(sql); stockUpd.put("qty_stduom",qty );
pstmt.setString(1,toLoc); }
rs = pstmt.executeQuery();
if(rs.next())
{ if ( qtyPerArt == 0 ) //isnull(lc_qtyperart) or lc_qtyperart = 0 then
stockUpd.put("inv_stat", rs.getString("inv_stat")); {
} qtyPerArt = 1;
rs.close(); }
rs = null;
pstmt.close(); stockUpd.put("no_art",Math.ceil(Double.parseDouble(stockUpd.get("qty_stduom").toString())/qtyPerArt));
pstmt = null; if(stockQty != 0 )
{
stockUpd.put("net_weight",stkNetWt / stockQty * Double.parseDouble( stockUpd.get("qty_stduom").toString()));
if(isByProduct) stockUpd.put("tare_weight", tareWtPerArt * Double.parseDouble(stockUpd.get("no_art").toString()));
{ stockUpd.put("gross_weight", ( Double.parseDouble(stockUpd.get("net_weight").toString()) + Double.parseDouble(stockUpd.get("tare_weight").toString())) );
stockUpd.put("quantity",qty ); }//end if
stockUpd.put("qty_stduom",qty ); // ls_errcode = nvo_dis.gbf_update_stock(lstr_stkupd)
stockUpd.put("item_code",itemCode); errCode = stockUpdate.updateStock(stockUpd,xtraParams, conn);
} if(errCode !=null && errCode.trim().length() >0) //if(retString !=null && retString.trim().length() >0)
stockUpd.put("tran_type", "R"); {
stockUpd.put("loc_code", toLoc ); return errCode;
}
if ( qtyPerArt == 0 )
{ }//end if
qtyPerArt = 1;
} if( errCode == null || errCode.trim().length() == 0 )
{
stockUpd.put("no_art", Math.ceil( Double.parseDouble(stockUpd.get("qty_stduom").toString()) / qtyPerArt)); sql = " Select inv_stat from location Where loc_code = ? ";
pstmt = conn.prepareStatement(sql);
if ( stockQty != 0 ) pstmt.setString(1,toLoc);
{ rs = pstmt.executeQuery();
stockUpd.put("net_weight",stkNetWt / stockQty * Double.parseDouble(stockUpd.get("qty_stduom").toString())); if(rs.next())
stockUpd.put("tare_weight", tareWtPerArt * Double.parseDouble(stockUpd.get("no_art").toString())); {
stockUpd.put("gross_weight", ( Double.parseDouble(stockUpd.get("net_weight").toString()) + Double.parseDouble(stockUpd.get("tare_weight").toString()))); stockUpd.put("inv_stat", rs.getString("inv_stat"));
}//end if }
//ls_errcode = nvo_dis.gbf_update_stock(lstr_stkupd) rs.close();
errCode = stockUpdate.updateStock(stockUpd,xtraParams, conn); rs = null;
pstmt.close();
if(errCode !=null && errCode.trim().length() >0) //if(retString !=null && retString.trim().length() >0) pstmt = null;
{
return errCode;
} if(isByProduct)
} //End if {
} //End if stockUpd.put("quantity",qty );
stockUpd.put("qty_stduom",qty );
stockUpd.put("item_code",itemCode);
if (errCode == null || errCode.trim().length() == 0 ) }
{ //if gs_run_mode = 'I' then stockUpd.put("tran_type", "R");
stockUpd.put("loc_code", toLoc );
if ( qtyPerArt == 0 )
{
if(isByProduct) qtyPerArt = 1;
{ }
if ( qcQty > convertedQty )
{ stockUpd.put("no_art", Math.ceil( Double.parseDouble(stockUpd.get("qty_stduom").toString()) / qtyPerArt));
sql = " Update qc_order set quantity = ( quantity - ? ) " +
" , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14 if ( stockQty != 0 )
" where qorder_no = ? "; {
pstmt = conn.prepareStatement(sql); stockUpd.put("net_weight",stkNetWt / stockQty * Double.parseDouble(stockUpd.get("qty_stduom").toString()));
pstmt.setDouble(1, convertedQty ); stockUpd.put("tare_weight", tareWtPerArt * Double.parseDouble(stockUpd.get("no_art").toString()));
pstmt.setDouble(2, convertedNetWeight ); stockUpd.put("gross_weight", ( Double.parseDouble(stockUpd.get("net_weight").toString()) + Double.parseDouble(stockUpd.get("tare_weight").toString())));
pstmt.setDouble(3, convertedNoArt ); }//end if
pstmt.setString(4, qorderNo); //ls_errcode = nvo_dis.gbf_update_stock(lstr_stkupd)
updCnt = pstmt.executeUpdate(); errCode = stockUpdate.updateStock(stockUpd,xtraParams, conn);
pstmt.close();
pstmt = null; if(errCode !=null && errCode.trim().length() >0) //if(retString !=null && retString.trim().length() >0)
} {
else return errCode;
{ }
sql = " Update qc_order set quantity = (quantity - ? ), status = 'C' " + } //End if
" , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14 } //End if
" where qorder_no = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setDouble(1, convertedQty ); if (errCode == null || errCode.trim().length() == 0 )
pstmt.setDouble(2, convertedNetWeight ); { //if gs_run_mode = 'I' then
pstmt.setDouble(3, convertedNoArt );
pstmt.setString(4, qorderNo);
updCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null; if(isByProduct)
} //end if {
if ( qcQty > convertedQty )
} {
else sql = " Update qc_order set quantity = ( quantity - ? ) " +
{ " , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14
System.out.println("@@@ noArt["+noArt+"]qty["+qty+"]qcQty["+qcQty+"]netWeight["+netWeight+"]"); // modify by cpatil on 09/04/14 " where qorder_no = ? ";
pstmt = conn.prepareStatement(sql);
convertedNoArt = noArt * qty / qcQty ; pstmt.setDouble(1, convertedQty );
convertedNetWeight = netWeight * qty / qcQty ; pstmt.setDouble(2, convertedNetWeight );
pstmt.setDouble(3, convertedNoArt );
System.out.println("@@@ convertedNoArt["+convertedNoArt+"]convertedNetWeight["+convertedNetWeight+"]"); pstmt.setString(4, qorderNo);
updCnt = pstmt.executeUpdate();
if ( qcQty > qty ) pstmt.close();
{ pstmt = null;
sql = " Update qc_order set quantity = (quantity - ? ) " + }
" , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14 else
" where qorder_no = ? "; {
pstmt = conn.prepareStatement(sql); sql = " Update qc_order set quantity = (quantity - ? ), status = 'C' " +
pstmt.setDouble(1, qty); " , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14
pstmt.setDouble(2, convertedNetWeight); " where qorder_no = ? " ;
pstmt.setDouble(3, convertedNoArt); pstmt = conn.prepareStatement(sql);
pstmt.setString(4, qorderNo); pstmt.setDouble(1, convertedQty );
updCnt = pstmt.executeUpdate(); pstmt.setDouble(2, convertedNetWeight );
pstmt.close(); pstmt.setDouble(3, convertedNoArt );
pstmt = null; pstmt.setString(4, qorderNo);
} updCnt = pstmt.executeUpdate();
else pstmt.close();
{ pstmt = null;
sql = " Update qc_order set quantity = (quantity - ? ), status = 'C' " + } //end if
" , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14
" where qorder_no = ? " ; }
pstmt = conn.prepareStatement(sql); else
pstmt.setDouble(1, qty); {
pstmt.setDouble(2, convertedNetWeight); System.out.println("@@@ noArt["+noArt+"]qty["+qty+"]qcQty["+qcQty+"]netWeight["+netWeight+"]"); // modify by cpatil on 09/04/14
pstmt.setDouble(3, convertedNoArt);
pstmt.setString(4, qorderNo); convertedNoArt = noArt * qty / qcQty ;
updCnt = pstmt.executeUpdate(); convertedNetWeight = netWeight * qty / qcQty ;
pstmt.close();
pstmt = null; System.out.println("@@@ convertedNoArt["+convertedNoArt+"]convertedNetWeight["+convertedNetWeight+"]");
} //end if
} if ( qcQty > qty )
{
if (updCnt == 0) // get_sqlcode() <> 0 then sql = " Update qc_order set quantity = (quantity - ? ) " +
{ " , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14
errCode = "QCTRFUPDT"; //'Unable to confirm QC Transfer ' + sqlca.sqlerrtext " where qorder_no = ? ";
return itmDBAccessLocal.getErrorString("",errCode,""); pstmt = conn.prepareStatement(sql);
//return errCode;//Commented by Manoj dtd 03/06/2014 pstmt.setDouble(1, qty);
} //End if pstmt.setDouble(2, convertedNetWeight);
pstmt.setDouble(3, convertedNoArt);
// Update to qc_order_lot table if it QC is split into to different lots pstmt.setString(4, qorderNo);
if( errCode == null || errCode.trim().length() == 0 ) updCnt = pstmt.executeUpdate();
{ pstmt.close();
sql = " update qc_order_lots set quantity = (quantity - ? ) " + pstmt = null;
" where qc_order = ? and lot_no = ? and lot_sl = ? "; }
pstmt = conn.prepareStatement(sql); else
//if(convertedQty>0) {
if(isByProduct) sql = " Update qc_order set quantity = (quantity - ? ), status = 'C' " +
{ " , net_weight = ( net_weight - ? ) , no_art = ( no_art - ? ) " + // modify by cpatil on 09/04/14
pstmt.setDouble(1, convertedQty); " where qorder_no = ? " ;
} pstmt = conn.prepareStatement(sql);
else pstmt.setDouble(1, qty);
{ pstmt.setDouble(2, convertedNetWeight);
pstmt.setDouble(1, qty); pstmt.setDouble(3, convertedNoArt);
} pstmt.setString(4, qorderNo);
pstmt.setString(2, qorderNo); updCnt = pstmt.executeUpdate();
pstmt.setString(3, lotNo); pstmt.close();
pstmt.setString(4, lotSl); pstmt = null;
updCnt = pstmt.executeUpdate(); } //end if
pstmt.close(); }
pstmt = null;
if (updCnt == 0) // get_sqlcode() <> 0 then
// if( updCnt == 0 ) {
// { errCode = "QCTRFUPDT"; //'Unable to confirm QC Transfer ' + sqlca.sqlerrtext
// errCode = "QCTRFUPDT"; //'Unable to confirm QC Transfer ' + sqlca.sqlerrtext return itmDBAccessLocal.getErrorString("",errCode,"");
// return errCode; //return errCode;//Commented by Manoj dtd 03/06/2014
// }//End if } //End if
} //end if
// Update to qc_order_lot table if it QC is split into to different lots
// update po receipt as accept on external approval if( errCode == null || errCode.trim().length() == 0 )
if(( errCode == null || errCode.trim().length() == 0 ) && ( porcpNo != null && porcpNo.trim().length() == 0 )) {
{ sql = " update qc_order_lots set quantity = (quantity - ? ) " +
sql = " select count(1) from porcp where tran_id = ? "; " where qc_order = ? and lot_no = ? and lot_sl = ? ";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1,porcpNo); //if(convertedQty>0)
rs = pstmt.executeQuery(); if(isByProduct)
if(rs.next()) {
{ pstmt.setDouble(1, convertedQty);
cnt = rs.getInt(1); }
} else
rs.close(); {
rs = null; pstmt.setDouble(1, qty);
pstmt.close(); }
pstmt = null; pstmt.setString(2, qorderNo);
pstmt.setString(3, lotNo);
if( cnt==1 ) // ll_count = 1 then pstmt.setString(4, lotSl);
{ updCnt = pstmt.executeUpdate();
sql = " update porcp set ACCEPT_CRITERIA = 'E' where tran_id = ? "; pstmt.close();
pstmt = conn.prepareStatement(sql); pstmt = null;
pstmt.setString(1, qorderNo);
updCnt = pstmt.executeUpdate(); // if( updCnt == 0 )
pstmt.close(); // {
pstmt = null; // errCode = "QCTRFUPDT"; //'Unable to confirm QC Transfer ' + sqlca.sqlerrtext
// return errCode;
if( updCnt == 0 ) // get_sqlcode() <> 0 then // }//End if
{ } //end if
System.out.println("@@@@@@@@@@@@ no record");
}//end if // update po receipt as accept on external approval
} //end if if(( errCode == null || errCode.trim().length() == 0 ) && ( porcpNo != null && porcpNo.trim().length() == 0 ))
} //end if {
sql = " select count(1) from porcp where tran_id = ? ";
if( errCode == null || errCode.trim().length() == 0 ) pstmt = conn.prepareStatement(sql);
{ pstmt.setString(1,porcpNo);
sql = " Update qc_transfer Set confirmed = 'Y', conf_date = ? Where tran_id = ? "; rs = pstmt.executeQuery();
pstmt = conn.prepareStatement(sql); if(rs.next())
pstmt.setTimestamp(1, sysDate ); {
pstmt.setString(2, tranId); cnt = rs.getInt(1);
updCnt = pstmt.executeUpdate(); }
pstmt.close(); rs.close();
pstmt = null; rs = null;
pstmt.close();
///// pstmt = null;
if( updCnt == 0 ) //get_sqlcode() <> 0 then
{ if( cnt==1 ) // ll_count = 1 then
errCode = "QCTRFUPDT"; //'Unable to confirm QC Transfer ' + sqlca.sqlerrtext {
return itmDBAccessLocal.getErrorString("",errCode,""); sql = " update porcp set ACCEPT_CRITERIA = 'E' where tran_id = ? ";
//return errCode;//Commented by Manoj dtd 03/06/2014 pstmt = conn.prepareStatement(sql);
}//End if pstmt.setString(1, qorderNo);
// ADDED BY RITESH ON 23/SEP/2014 START updCnt = pstmt.executeUpdate();
else pstmt.close();
{ pstmt = null;
double holdQty = 0d;
sql = " SELECT HOLD_QTY FROM STOCK " if( updCnt == 0 ) // get_sqlcode() <> 0 then
+ " WHERE ITEM_CODE = ? " {
+ " AND SITE_CODE = ? " System.out.println("@@@@@@@@@@@@ no record");
+ " AND LOC_CODE = ? " }//end if
+ " AND LOT_NO = ? " } //end if
+ " AND LOT_SL = ? "; } //end if
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode); if( errCode == null || errCode.trim().length() == 0 )
pstmt.setString(2,siteCode); {
pstmt.setString(3,fromLoc); sql = " Update qc_transfer Set confirmed = 'Y', conf_date = ? Where tran_id = ? ";
pstmt.setString(4,lotNo); pstmt = conn.prepareStatement(sql);
pstmt.setString(5,lotSl); pstmt.setTimestamp(1, sysDate );
rs = pstmt.executeQuery(); pstmt.setString(2, tranId);
if(rs.next()) updCnt = pstmt.executeUpdate();
{ pstmt.close();
holdQty = rs.getDouble("HOLD_QTY"); pstmt = null;
}
pstmt.close(); /////
pstmt = null; if( updCnt == 0 ) //get_sqlcode() <> 0 then
rs.close(); {
rs = null; errCode = "QCTRFUPDT"; //'Unable to confirm QC Transfer ' + sqlca.sqlerrtext
if(holdQty > 0) return itmDBAccessLocal.getErrorString("",errCode,"");
{ //return errCode;//Commented by Manoj dtd 03/06/2014
sql = "UPDATE STOCK SET HOLD_QTY = HOLD_QTY - ?" }//End if
+ " WHERE ITEM_CODE = ? " // ADDED BY RITESH ON 23/SEP/2014 START
+ " AND SITE_CODE = ? " else
+ " AND LOC_CODE = ? " {
+ " AND LOT_NO = ? " double holdQty = 0d;
+ " AND LOT_SL = ? "; sql = " SELECT HOLD_QTY FROM STOCK "
pstmt = conn.prepareStatement(sql); + " WHERE ITEM_CODE = ? "
pstmt.setDouble(1, qty ); + " AND SITE_CODE = ? "
pstmt.setString(2,itemCode); + " AND LOC_CODE = ? "
pstmt.setString(3,siteCode); + " AND LOT_NO = ? "
pstmt.setString(4,fromLoc); + " AND LOT_SL = ? ";
pstmt.setString(5,lotNo); pstmt = conn.prepareStatement(sql);
pstmt.setString(6,lotSl); pstmt.setString(1,itemCode);
updCnt = pstmt.executeUpdate(); pstmt.setString(2,siteCode);
pstmt.close(); pstmt.setString(3,fromLoc);
pstmt = null; pstmt.setString(4,lotNo);
System.out.println("hiold_qty updated in from location "+updCnt); pstmt.setString(5,lotSl);
sql = "UPDATE STOCK SET HOLD_QTY = ?" rs = pstmt.executeQuery();
+ " WHERE ITEM_CODE = ? " if(rs.next())
+ " AND SITE_CODE = ? " {
+ " AND LOC_CODE = ? " holdQty = rs.getDouble("HOLD_QTY");
+ " AND LOT_NO = ? " }
+ " AND LOT_SL = ? "; pstmt.close();
pstmt = conn.prepareStatement(sql); pstmt = null;
pstmt.setDouble(1, qty ); rs.close();
pstmt.setString(2,itemCode); rs = null;
pstmt.setString(3,siteCode); if(holdQty > 0)
pstmt.setString(4,toLoc); {
pstmt.setString(5,lotNo); sql = "UPDATE STOCK SET HOLD_QTY = HOLD_QTY - ?"
pstmt.setString(6,lotSl); + " WHERE ITEM_CODE = ? "
updCnt = pstmt.executeUpdate(); + " AND SITE_CODE = ? "
pstmt.close(); + " AND LOC_CODE = ? "
pstmt = null; + " AND LOT_NO = ? "
System.out.println("hiold_qty updated in to location "+updCnt); + " AND LOT_SL = ? ";
} pstmt = conn.prepareStatement(sql);
} pstmt.setDouble(1, qty );
// ADDED BY RITESH ON 23/SEP/2014 END pstmt.setString(2,itemCode);
} //end if pstmt.setString(3,siteCode);
pstmt.setString(4,fromLoc);
pstmt.setString(5,lotNo);
sql = "select edi_option from transetup where tran_window = 'w_qc_transfer' "; pstmt.setString(6,lotSl);
pstmtSql = conn.prepareStatement(sql); updCnt = pstmt.executeUpdate();
rs = pstmtSql.executeQuery(); pstmt.close();
if (rs.next()) pstmt = null;
{ System.out.println("hiold_qty updated in from location "+updCnt);
ediOption = rs.getString("EDI_OPTION"); sql = "UPDATE STOCK SET HOLD_QTY = ?"
} + " WHERE ITEM_CODE = ? "
rs.close(); + " AND SITE_CODE = ? "
rs = null; + " AND LOC_CODE = ? "
pstmtSql.close(); + " AND LOT_NO = ? "
pstmtSql = null; + " AND LOT_SL = ? ";
System.out.println("@@@@@@@@@@@@@@@ ediOption called next.............."); pstmt = conn.prepareStatement(sql);
if ("2".equals(ediOption)) pstmt.setDouble(1, qty );
{ pstmt.setString(2,itemCode);
CreateRCPXML createRCPXML = new CreateRCPXML("w_qc_transfer","tran_id"); pstmt.setString(3,siteCode);
dataStr = createRCPXML.getTranXML(tranId, conn); pstmt.setString(4,toLoc);
System.out.println("dataStr =[ " + dataStr + "]"); pstmt.setString(5,lotNo);
Document ediDataDom = genericUtility.parseString(dataStr); pstmt.setString(6,lotSl);
updCnt = pstmt.executeUpdate();
E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb(); pstmt.close();
retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_qc_transfer", "2", xtraParams, conn); pstmt = null;
createRCPXML = null; System.out.println("hiold_qty updated in to location "+updCnt);
e12CreateBatchLoad = null; }
}
if (retString != null && "SUCCESS".equalsIgnoreCase(retString)) // ADDED BY RITESH ON 23/SEP/2014 END
{ } //end if
System.out.println("retString from batchload = [" + retString + "]");
}
} sql = "select edi_option from transetup where tran_window = 'w_qc_transfer' ";
pstmtSql = conn.prepareStatement(sql);
else rs = pstmtSql.executeQuery();
{ if (rs.next())
CreateRCPXML createRCPXML = new CreateRCPXML("w_qc_transfer","tran_id"); {
dataStr = createRCPXML.getTranXML(tranId, conn); ediOption = rs.getString("EDI_OPTION");
System.out.println("dataStr =[ " + dataStr + "]"); }
Document ediDataDom = genericUtility.parseString(dataStr); rs.close();
rs = null;
E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb(); pstmtSql.close();
retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_qc_transfer", ediOption, xtraParams, conn); pstmtSql = null;
createRCPXML = null; System.out.println("@@@@@@@@@@@@@@@ ediOption called next..............");
e12CreateBatchLoad = null; if ("2".equals(ediOption))
{
if (retString != null && "SUCCESS".equalsIgnoreCase(retString)) CreateRCPXML createRCPXML = new CreateRCPXML("w_qc_transfer","tran_id");
{ dataStr = createRCPXML.getTranXML(tranId, conn);
System.out.println("retString from batchload = ["+ retString + "]"); System.out.println("dataStr =[ " + dataStr + "]");
} Document ediDataDom = genericUtility.parseString(dataStr);
}
System.out.println("@@@@@@@@@@@@@@@ ediOption called end.............."); E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb();
retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_qc_transfer", "2", xtraParams, conn);
} //End if createRCPXML = null;
e12CreateBatchLoad = null;
} // end try
catch (Exception e) if (retString != null && "SUCCESS".equalsIgnoreCase(retString))
{ {
e.printStackTrace(); System.out.println("retString from batchload = [" + retString + "]");
System.out.println("Exception ::" + e.getMessage()); }
throw new ITMException(e); }
}
else
return errCode; {
} CreateRCPXML createRCPXML = new CreateRCPXML("w_qc_transfer","tran_id");
/* dataStr = createRCPXML.getTranXML(tranId, conn);
private String checkNull(String string) System.out.println("dataStr =[ " + dataStr + "]");
{ Document ediDataDom = genericUtility.parseString(dataStr);
if (string == null)
{ E12CreateBatchLoadEjb e12CreateBatchLoad = new E12CreateBatchLoadEjb();
string = ""; retString = e12CreateBatchLoad.createBatchLoad(ediDataDom,"w_qc_transfer", ediOption, xtraParams, conn);
} createRCPXML = null;
return string; e12CreateBatchLoad = null;
}
*/ if (retString != null && "SUCCESS".equalsIgnoreCase(retString))
private double roundVal(double round,int scale) {
{ System.out.println("retString from batchload = ["+ retString + "]");
return Math.round(round*Math.pow(10, scale))/Math.pow(10, scale); }
} }
System.out.println("@@@@@@@@@@@@@@@ ediOption called end..............");
} //End if
} // end try
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e);
}
return errCode;
}
/*
private String checkNull(String string)
{
if (string == null)
{
string = "";
}
return string;
}
*/
private double roundVal(double round,int scale)
{
return Math.round(round*Math.pow(10, scale))/Math.pow(10, scale);
}
} }
\ 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