Commit bdcd8905 authored by manohar's avatar manohar

Preconfirm check for pending weighing, etc added


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95682 ce508802-f39f-4f6c-b175-0d175dae99d5
parent e25f8256
......@@ -19,6 +19,7 @@ import ibase.webitm.ejb.mfg.LotWiseScanBean;
import ibase.webitm.ejb.mfg.WOBean;
import ibase.webitm.ejb.mfg.GenWOIssue;
import ibase.webitm.ejb.mfg.adv.WorkorderIssConf;
import ibase.webitm.ejb.sys.UtilMethods;
import java.rmi.RemoteException;
import java.sql.Connection;
......@@ -95,12 +96,18 @@ public class WorkorderIssConf extends ActionHandlerEJB implements WorkorderIssCo
connDriver = null;
localConnection = true;
}
errString = preConfirmChk(tranID, issType, xtraParams, conn);
System.out.println("After preConfirmChk errString ["+ errString+ "] length [" + errString.trim().length() +"]");
if (errString != null && errString.trim().length() > 0)
{
return errString;
}
System.out.println("After preConfirmChk processing");
genericUtility = GenericUtility.getInstance();
stkUpdMap = new HashMap();
DistCommon distCommon = new DistCommon();
MfgCommon mfgCommon = new MfgCommon();
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
tranID = rsSL.getString(1);
sql = "select (case when LEDG_POST_CONF is null then 'N' else LEDG_POST_CONF end ) "
+" from transetup where lower(tran_window) = 'w_worder_iss' ";
pstmt = conn.prepareStatement(sql);
......@@ -149,14 +156,16 @@ public class WorkorderIssConf extends ActionHandlerEJB implements WorkorderIssCo
pstmt1 = null;
if("Y".equalsIgnoreCase(ledgpostconf))
{
//tranDate = new Timestamp(System.currentTimeMillis());
SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy-MM-dd");
tranDate = java.sql.Timestamp.valueOf(sdf1.format(new Timestamp(System.currentTimeMillis())) + " 00:00:00.0");
System.out.println("18/08/10 tranDate !"+tranDate);
//String timeStr = genericUtility.getValidDateString(new Timestamp(System.currentTimeMillis()).toString(),genericUtility.getDBDateFormat(), genericUtility.getApplDateFormat()) + " 00:00:00.000" ;
//System.out.println("18/08/10 timeStr [" +timeStr + "]");
//tranDate = Timestamp.valueOf(timeStr);
sql =" update "+hdrTable+" set tran_date = ? "
+" where tran_id = ? ";
pstmt = conn.prepareStatement(sql); //conf_date
pstmt.setTimestamp(1,tranDate);
pstmt.setString(2,tranID);
upd = pstmt.executeUpdate();
pstmt.close();
pstmt = null ;
}
sql =" select acct_code__wp , cctr_code__wp, order_type "
+" from workorder where work_order ='"+workOrder+"' ";
......@@ -691,7 +700,6 @@ public class WorkorderIssConf extends ActionHandlerEJB implements WorkorderIssCo
if( localConnection )
{
conn.rollback();
}
}
......@@ -737,6 +745,582 @@ public class WorkorderIssConf extends ActionHandlerEJB implements WorkorderIssCo
}
return errString;
}
////////////////////////////////////////////////////////////////
private String preConfirmChk(String tranID, String issType, String xtraParams, Connection conn) throws RemoteException,ITMException
{
String errCode ="",errString = "", confirmed = "",runOpt ="I", siteCode = "", itemCode = "", locCode = "",autoReQc = "";
String lotNo = "", lotSl = "", unit = "", deptCode = "", workOrder = "",expLev = "";
String tranType = "",qcReqd = "", itemCodeser = "", matched = "", itemCodeunit = "",scanBarcode = "";
String trackShelfLife = "",itemCodecodemain = "",itemCodecoderef = "",useInvStatus = "",bomCode ="";
String sql ="",scannedBarcode = "",itemCodeDetail = "",scanned = "", stkOpt = "", scannedbarcode = "";
String qorderNo = "", xmlString = "" ,xmlString2 = "",itemCodeCode = "";
String procMth = "",siteCodecode = "", detTable = "", hdrTable = "";
int lineNo =0,operation = 0, cnt = 0, preOp = 0, ctr = 0 , count = 0, noArt = 0, curRow = 0;
double qty = 0, stkQty = 0, rate = 0,drate = 0,potencyAdjQty = 0, qtystduom = 0;
Timestamp today = null ,tranDate = null,effDate = null, expDate = null,retestDate = null;
PreparedStatement pstmt = null,pstmt1 = null;
ResultSet rs = null,rs1 = null;
try
{
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
MfgCommon mfgCommon = new MfgCommon();
GenericUtility genericUtility = GenericUtility.getInstance();
if("R".equalsIgnoreCase(issType))
{
detTable ="WORDER_ISSDET_RND";
hdrTable ="WORDER_ISS_RND";
}
else
{
detTable ="workorder_issdet";
hdrTable ="workorder_iss";
}
//xtraParams :[loginCode=BASE~~loginEmpCode=E01712 ~~loginSiteCode=SP110~~entityCode=E08135 ~~profileId=SUPER ~~userType=E~~runMode=I~~user_lang=en~~user_country=US~~charEnc=UTF-8~~timeZone=Asia/Calcutta~~termId=192.168.0.78~~chgTerm=localhost.local~~detCnt=1~~focusRow=1~~mfr_date=01/07/14~~mto_date=31/07/14~~REC_CTR=-1~~saveLevel=0]
runOpt = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"runMode");
if (runOpt == null || runOpt.trim().length() == 0)
{
runOpt = "I";
}
today = new java.sql.Timestamp(System.currentTimeMillis()) ;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
tranDate = java.sql.Timestamp.valueOf(sdf.format(today) + " 00:00:00.000");
sql = "select confirmed , site_code,tran_type,tran_date,dept_code,work_order, operation, eff_date "
+ " from " + hdrTable + " where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranID);
rs = pstmt.executeQuery();
if (rs.next())
{
confirmed = rs.getString("confirmed");
siteCode = rs.getString("site_code");
tranType = rs.getString("tran_type");
tranDate = rs.getTimestamp("tran_date");
deptCode = rs.getString("dept_code");
workOrder = rs.getString("work_order");
operation = rs.getInt("operation");
effDate = rs.getTimestamp("eff_date");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ("Y".equals(confirmed))
{
errCode = "VTMCONF1";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
if (!"R".equals(tranType))
{
sql = "select max(operation) "
+ " from workorder_bill where work_order = ? and operation < ? and usage_type = 'R' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
pstmt.setInt(2,operation);
rs = pstmt.executeQuery();
if (rs.next())
{
preOp = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (preOp > 0 )
{
sql = "select count(*) from " + hdrTable + " where work_order = ? and operation < ? "
+ " and tran_type <> 'R' and case when confirmed is null then 'N' else confirmed end <> 'Y' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
pstmt.setInt(2,preOp);
rs = pstmt.executeQuery();
if (rs.next())
{
ctr = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (ctr > 0 )
{
errCode = "VTWOINEOPE";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
else if (ctr == 0 )
{
sql = "select count(*) from " + hdrTable + " where work_order = ? and operation = ? "
+ " and tran_type <> 'R' and case when confirmed is null then 'N' else confirmed end <> 'Y' "
+ " and case when status is null then 'O' else status end <> 'X'";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
pstmt.setInt(2,preOp);
rs = pstmt.executeQuery();
if (rs.next())
{
ctr = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (ctr > 0 )
{
errCode = "VTWOINEOPE";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
}
}
//Added By Rutuja on 02-06-12 - MF2CSUN003
sql = "select count(*) from woi_scan_hdr where WO_ISS_TRANID = ? "
+ " and case when confirmed is null then 'N' else confirmed end = 'N' ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranID);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (count > 0 )
{
errCode = "VTWOICONF" ;
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
//Ended by Rutuja on 02-06-12 - MF2CSUN003
// Start pravin --20/02/2012--MF89SUN092////////////
// 07/06/13 manoharan in case scan only update the scanned as Y if record found in workorder_issdet_sl as per no_art
itemCodeDetail = "";
sql = " select b.item_code,b.loc_code,b.lot_no,b.lot_sl,b.quantity ,b.unit,b.line_no,b.exp_lev, "
+ " b.qc_reqd,b.potency_adj,b.scanned,a.site_code, case when c.scanned_barcode is null then '0' else c.scanned_barcode end as scanned_barcode, "
+ " b.no_art from workorder_iss a,workorder_issdet b,siteitem c "
+ " where a.tran_id = b.tran_id "
+ " AND c.item_code = b.item_code "
+ " and a.site_code = c.site_code "
+ " and (trim(case when c.scanned_barcode is null then '0' else c.scanned_barcode end) = '1' or trim(case when c.scanned_barcode is null then '0' else c.scanned_barcode end) = '2' ) "
+ " and b.tran_id = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,tranID);
rs1 = pstmt1.executeQuery();
while (rs1.next())
{
itemCode = rs1.getString("item_code");
locCode = rs1.getString("loc_code");
lotNo = rs1.getString("lot_no");
lotSl = rs1.getString("lot_sl");
qty = rs1.getDouble("quantity");
unit = rs1.getString("unit");
lineNo = rs1.getInt("line_no");
expLev = rs1.getString("exp_lev");
qcReqd = rs1.getString("qc_reqd");
potencyAdjQty = rs1.getDouble("potency_adj");
scanned = rs1.getString("scanned");
//siteCode = rs1.getString("");
scannedbarcode = rs1.getString("scanned_barcode");
noArt = rs1.getInt("no_art");
if ( scanned == null || "null".equals(scanned) || scanned.trim().length() == 0 || "N".equals(scanned) )
{
if ("1".equals(scannedbarcode) )
{
sql = "select count(1) from workorder_issdet_sl "
+ " where tran_id__iss = ? and line_no__iss = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranID);
pstmt.setInt(2,lineNo);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (count >= noArt )
{
sql = "update workorder_issdet set scanned = 'Y' "
+ " where tran_id = ? and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranID);
pstmt.setInt(2,lineNo);
count = pstmt.executeUpdate();
}
else
{
itemCodeDetail = itemCodeDetail + "Line_no ["+ lineNo +"]\t Item Code [" + itemCode + "]\t Exp_Lev ["+expLev+ "]\t Lot_no ["+lotNo+ "]\t Lot_sl ["+lotSl+ "]\t" ;
}
}
else
{
itemCodeDetail = itemCodeDetail + "Line_no ["+ lineNo+"]\t Item Code ["+itemCode + "]\t Exp_Lev ["+expLev+ "]\t Lot_no ["+lotNo+ "]\t Lot_sl ["+lotSl+ "]\t";
}
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if (itemCodeDetail.trim().length() > 0 )
{
errCode = "VTNOWEIGH";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
}
// End Pravin --20/02/12--////////////////
sql = " select item_code,loc_code,lot_no,lot_sl,quantity,unit,line_no,exp_lev,qc_reqd,potency_adj "
+ "from workorder_issdet "
+ " where tran_id = ? ";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,tranID);
rs1 = pstmt1.executeQuery();
while (rs1.next())
{
itemCode = rs1.getString("item_code");
locCode = rs1.getString("loc_code");
lotNo = rs1.getString("lot_no");
lotSl = rs1.getString("lot_sl");
qty = rs1.getDouble("quantity");
unit = rs1.getString("unit");
lineNo = rs1.getInt("line_no");
expLev = rs1.getString("exp_lev");
qcReqd = rs1.getString("qc_reqd");
potencyAdjQty = rs1.getDouble("potency_adj");
System.out.println("Current lineNo [" + lineNo + "] itemCode ["+itemCode + "] qcReqd [" + qcReqd + "]" );
// below condition added by stkOpt added by pravin -- 23/04/12--
sql ="select case when stk_opt is null then '0' else stk_opt end, item_ser, unit, nvl(track_shelf_life,'N') "
+" from item where item_code = ? " ;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
stkOpt = rs.getString(1);
itemCodeser = rs.getString(2);
itemCodeunit = rs.getString(3);
trackShelfLife = rs.getString(4);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
if (!"0".equals(stkOpt))
{
//rahul on 07-08-03 for qc_reqd to be checked first from siteitem & then from item
qcReqd = mfgCommon.chkQcReqd(siteCode, itemCode, conn);
autoReQc = mfgCommon.chkAutoQcReqd(siteCode, itemCode, conn);
if ("I".equals(tranType) || "O".equals(tranType) || "D".equals(tranType) || "F".equals(tranType) )
{
sql ="select exp_date,retest_date "
+ " from stock where item_code = ? "
+ " and site_code = ? "
+ " and loc_code = ? "
+ " and lot_no = ? "
+ " and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
expDate = rs.getTimestamp("exp_date");
retestDate = rs.getTimestamp("retest_date");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
if ("I".equals(runOpt))
{
if ("Y".equals(qcReqd) && "Y".equals(autoReQc) && "Y".equals(trackShelfLife))
{
if (expDate != null)
{
if (expDate.compareTo(today) <= 0)
{
errCode = "VTLOTAEUR";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
break;
}
}
if (retestDate != null )
{
if (retestDate.compareTo(today) <= 0)
{
errCode = "VTLOTAEUR";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
break;
}
}
}
else if ("Y".equals(qcReqd) && "N".equals(autoReQc) && "Y".equals(trackShelfLife))
{
if (expDate != null)
{
if (expDate.compareTo(today) <= 0)
{
errCode = "VTLOTAEUR";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
break;
}
}
}
else if ("N".equals(qcReqd) && "Y".equals(trackShelfLife))
{
if (expDate != null)
{
if (expDate.compareTo(today) <= 0)
{
errCode = "VTLOTAEUR";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
break;
}
}
}
else if ("Y".equals(qcReqd) && "Y".equals(autoReQc) && "N".equals(trackShelfLife))
{
if (retestDate != null )
{
if (retestDate.compareTo(today) <= 0)
{
errCode = "VTLOTAEUR";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
break;
}
}
}
}
sql ="select bom_code from workorder where work_order = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
rs = pstmt.executeQuery();
if (rs.next())
{
bomCode = rs.getString("bom_code");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
sql ="select item_code, item_code__ref from workorder_bill "
+ " where work_order = ? "
+ " and operation = ? "
+ " and exp_lev = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,workOrder);
pstmt.setInt(2,operation);
pstmt.setString(3,expLev);
rs = pstmt.executeQuery();
if (rs.next())
{
itemCodecodemain = rs.getString("item_code");
itemCodecoderef = rs.getString("item_code__ref");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
sql ="select case when use_invstatus is null then 'U' else use_invstatus end as use_invstatus "
+ " from bomdet where bom_code = ? "
+ " and item_code = ? "
+ " and item_ref = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,bomCode);
pstmt.setString(2,itemCodecodemain);
pstmt.setString(3,itemCodecoderef);
rs = pstmt.executeQuery();
if (rs.next())
{
useInvStatus = rs.getString("use_invstatus");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
sql ="select a.quantity,rate from stock a ,location b, invstat c "
+ "where a.loc_code = b.loc_code "
+ " and b.inv_stat = c.inv_stat "
+ " and a.item_code = ? "
+ " and a.site_code = ? "
+ " and a.loc_code = ? "
+ " and a.lot_no = ? "
+ " and a.lot_sl = ? " ;
if ("I".equals(runOpt))
{
sql = sql + " and c.stat_type <> 'S'";
if ("Y".equals(trackShelfLife) && "U".equals(useInvStatus))
{
sql = sql + " and ( a.exp_date > ? or a.exp_date is null) " ;
sql = sql + " and c.available = 'Y' " ;
if ("Y".equals(qcReqd) && "Y".equals(autoReQc))
{
sql = sql + " and a.retest_date > ? " ;
}
}
}
else
{
if ("U".equals(useInvStatus))
{
sql = sql + "and c.available = 'Y' ";
}
else
{
sql = sql + "and c.stat_type <> 'S'";
}
}
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
pstmt.setString(3,locCode);
pstmt.setString(4,lotNo);
pstmt.setString(5,lotSl);
if ("I".equals(runOpt))
{
if ("Y".equals(trackShelfLife) && "U".equals(useInvStatus))
{
pstmt.setTimestamp(6,effDate);
if ("Y".equals(qcReqd) && "Y".equals(autoReQc))
{
pstmt.setTimestamp(7,effDate);
}
}
}
rs = pstmt.executeQuery();
if (rs.next())
{
stkQty = rs.getDouble(1);
rate = rs.getDouble(2);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
if ("I".equals(tranType) || "O".equals(tranType) || "D".equals(tranType) || "F".equals(tranType) )
{
if (qtystduom > stkQty )
{
errCode = "VTSTK5";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
break;
}
}
}
}
if (!"0".equals(stkOpt) && "R".equals(tranType) && "Y".equals(qcReqd))
{
System.out.println("Calling CreateQcorder for tranID ["+tranID + "] siteCode [ "+ siteCode + "] itemCode [" + itemCode + "] lineNo [" + lineNo + "]" );
errString = CreateQcorder(tranID,siteCode,itemCode,lineNo, xtraParams, conn);
System.out.println("After Calling CreateQcorder errString ["+errString + "]" );
if( errString != null && errString.trim().length() > 0 )
{
break;
}
}
}
rs1.close();
rs1 = null;
pstmt1.close();
pstmt1 = null;
if (errString != null && errString.trim().length() > 0 )
{
return errString;
}
/*if isnull(errCode) or len(trim(errCode)) = 0 then
If tranType = 'R' Then
for curRow = 1 to upperbound(ls_qcord_no[])
qorderNo = ls_qcord_no[curRow]
if lds_qcorder.retrieve(qorderNo) = 1 then
itemCodeCode = lds_qcorder.getitemstring (1,"item_code")
select proc_mth into :procMth from siteitem
where item_code =:itemCodeCode
and site_code =:siteCode ;
if sqlca.sqlcode < 0 then
errCode = 'DS000' + trim(string(sqlca.SqlDbCode)) + "~t" + sqlca.sqlerrtext
exit
elseif sqlca.sqlcode = 100 or isnull(procMth) or len(trim(procMth)) =0 then
select proc_mth into :procMth from item
where item_code =:itemCodeCode;
end if
if (not isnull(procMth)) and len(trim(procMth)) > 0 then
gf_add_glob_args(is_extra_arg)
gs_start_xml = true
gs_end_xml = true
xmlString = gbf_convert_xml_tofile_ds(lds_qcorder,'1',"N",'A','1')
xmlString2 = xmlString
errCode = nvo_webservice.gbf_webservice_call("w_worder_iss",xmlString,xmlString2,"process",is_extra_arg)
if len(trim(errCode)) > 0 then
exit
end if
lds_qcorder.reset()
end if
setnull(is_extra_arg)
end if
next
destroy nvo_webservice
destroy lds_qcorder
end if
end if
//Ended by shahid 02/12/2008 for MF78SUN040
*/
}
catch(SQLException ex)
{
ex.printStackTrace();
errString = "VTCONFERR";
throw new ITMException(ex);
}
catch(Exception e)
{
e.printStackTrace();
errString = "VTCONFERR";
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
throw new ITMException(e);
}
}
return errString;
}
////////////////////////////////////////////////////////////////
public double getReqDecimal(double actVal, int prec) throws ITMException, Exception
{
DecimalFormat decFormat = null;
......@@ -775,4 +1359,307 @@ public class WorkorderIssConf extends ActionHandlerEJB implements WorkorderIssCo
//return reqVal;
return strValue;
}
//added by prajakta 27/12/06
// 22/08/00 manohar batch_no, expiry_date added in qc_order
private String CreateQcorder(String tranID,String siteCode,String itemCode,int lineNo, String xtraParams, Connection conn) throws ITMException, Exception
{
String errCode = "", errString = "", qcReqd = "", lotNo = "", lotNoRcp = "", lotSl = "", keyString = "", xmlValues = "";
String winName = "", qcorderNo = "", lotRcp = "", locCode = "", tranId = "", unit = "",batchNo = "", userid = "SYSTEM", termid = "SYSTEM";
String locCodeAprv = "", locCodeRej = "", itemSer = "", routeCode = "", suppCodeMfg = "", suppCode = "", sql = "";
double quantity = 0;
Timestamp today = null, expiryDate = null, qcDueDate = null, relDate = null, retestDate= null , expDate = null, mfgDate = null, tranDate = null;
int count = 0,qcLeadTime = 0;
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
GenericUtility genericUtility = GenericUtility.getInstance();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
today = new java.sql.Timestamp(System.currentTimeMillis()) ;
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
tranDate = java.sql.Timestamp.valueOf(sdf.format(today) + " 00:00:00.000");
//xtraParams :[loginCode=BASE~~loginEmpCode=E01712 ~~loginSiteCode=SP110~~entityCode=E08135 ~~profileId=SUPER ~~userType=E~~runMode=I~~user_lang=en~~user_country=US~~charEnc=UTF-8~~timeZone=Asia/Calcutta~~termId=192.168.0.78~~chgTerm=localhost.local~~detCnt=1~~focusRow=1~~mfr_date=01/07/14~~mto_date=31/07/14~~REC_CTR=-1~~saveLevel=0]
userid = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
termid = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"termId");
retestDate = tranDate;
winName = "w_qcorder_new";
sql ="select loc_code,lot_no, lot_sl,quantity, unit from workorder_issdet "
+ " where tran_id = ? "
+ " and line_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranID);
pstmt.setInt(2,lineNo);
rs = pstmt.executeQuery();
if (rs.next())
{
locCode = rs.getString("loc_code");
lotNoRcp = rs.getString("lot_no");
lotSl = rs.getString("lot_sl");
quantity = rs.getDouble("quantity");
unit = rs.getString("unit");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
sql ="select item_ser from siteitem "
+ " where item_code = ? "
+ " and site_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,siteCode);
rs = pstmt.executeQuery();
if (rs.next())
{
itemSer = rs.getString("item_ser");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
// Navin : 29/08/00 Calculate QC Due Date
//select :today + nvl(qc_lead_time,0) into :qcDueDate from item where item_code = :itemCode ;//Commented by Tushar instr by subu 12/02/10.
sql ="select qc_lead_time from item "
+ " where item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
qcLeadTime = rs.getInt("qc_lead_time");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
UtilMethods utilMethods = UtilMethods.getInstance();
qcDueDate = utilMethods.RelativeDate(tranDate, qcLeadTime);
sql ="select key_string from transetup "
+ " where tran_window = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,winName);
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("key_string");
}
else
{
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
sql ="select key_string from transetup "
+ " where tran_window = 'GENERAL' ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("key_string");
}
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<qorder_no></qorder_no>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + sdf.format(tranDate) + "</tran_date>";
xmlValues = xmlValues + "<qorder_date>" + sdf.format(tranDate) + "</qorder_date>";
xmlValues = xmlValues + "<lot_no>" + lotNoRcp + "</lot_no>";
xmlValues = xmlValues + "<qorder_type>M</qorder_type>";
xmlValues = xmlValues + "<item_ser>" + itemSer + "</item_ser>";
xmlValues = xmlValues + "<porcp_no>" + tranID + "</porcp_no>";
xmlValues = xmlValues + "<porcp_line_no>" + lineNo + "</porcp_line_no>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
qcorderNo = tg.generateTranSeqID("QC-ORD", "", keyString, conn);
System.out.println("New QC order number ["+qcorderNo + "]");
if ("ERROR".equals(qcorderNo))
{
errCode = "VTTRANID";
errString = itmDBAccessEJB.getErrorString("",errCode,"","",conn);
return errString;
}
if (quantity < 0 )
{
quantity = quantity * -1;
}
sql ="select loc_code__aprv,loc_code__rej from siteitem "
+ " where site_code = ? and item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,siteCode);
pstmt.setString(2,itemCode);
rs = pstmt.executeQuery();
if (rs.next())
{
locCodeAprv = rs.getString("loc_code__aprv");
locCodeRej = rs.getString("loc_code__rej");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
sql ="select count (*) from item_lot_info "
+ " where item_code = ? and lot_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,lotNoRcp);
rs = pstmt.executeQuery();
if (rs.next())
{
count = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
if (count > 0 )
{
sql ="select supp_code__mfg , supp_code, exp_date, mfg_date,retest_date from item_lot_info "
+ " where item_code = ? and lot_no = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,lotNoRcp);
rs = pstmt.executeQuery();
if (rs.next())
{
suppCodeMfg = rs.getString("supp_code__mfg");
suppCode = rs.getString("supp_code");
expDate = rs.getTimestamp("exp_date");
mfgDate = rs.getTimestamp("mfg_date");
retestDate = rs.getTimestamp("retest_date");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
}
else
{
sql ="select exp_date, mfg_date, supp_code__mfg from stock "
+ " where item_code = ? and lot_no = ? and lot_sl = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
pstmt.setString(2,lotNoRcp);
pstmt.setString(3,lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
suppCodeMfg = rs.getString("supp_code__mfg");
expDate = rs.getTimestamp("exp_date");
mfgDate = rs.getTimestamp("mfg_date");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null ;
}
//Navin:26/12/00 - set qorder_type = 'S', it was 'M' ( Tarun)
//by rahul 01-09-2003 to add new column item_code__new
sql ="insert into qc_order "
+ " (qorder_no, qorder_type, qorder_date, site_code, "
+ " item_code, route_code, quantity, qty_passed, "
+ " qty_rejected, start_date, due_date, rel_date, "
+ " porcp_no, porcp_line_no, lot_no, lot_sl, "
+ " chg_date, chg_user, chg_term, loc_code, "
+ " qty_sample, status, unit, qc_create_type, "
+ " unit__sample, loc_code__aprv, loc_code__rej, lot_no__new, "
+ " retest_date, expiry_date, item_code__new, mfg_date, "
+ " supp_code, supp_code__mfg) "
+ " values "
+ " ( ?, ?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?, ?,?) ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,qcorderNo);
pstmt.setString(2,"S");
pstmt.setTimestamp(3,tranDate);
pstmt.setString(4,siteCode);
pstmt.setString(5,itemCode);
pstmt.setString(6,routeCode);
pstmt.setDouble(7,quantity);
pstmt.setDouble(8,0);
pstmt.setDouble(9,0);
pstmt.setTimestamp(10,tranDate);
pstmt.setTimestamp(11,qcDueDate);
pstmt.setTimestamp(12,relDate);
pstmt.setString(13,tranID);
pstmt.setString(14, "" +lineNo);
pstmt.setString(15,lotNoRcp);
pstmt.setString(16,lotSl);
pstmt.setTimestamp(17,today);
pstmt.setString(18,userid);
pstmt.setString(19,termid);
pstmt.setString(20,locCode);
pstmt.setDouble(21,0);
pstmt.setString(22,"U");
pstmt.setString(23,unit);
pstmt.setString(24,"A");
pstmt.setString(25,unit);
pstmt.setString(26,locCodeAprv);
pstmt.setString(27,locCodeRej);
pstmt.setString(28,lotNoRcp);
pstmt.setTimestamp(29,retestDate);
pstmt.setTimestamp(30,expDate);
pstmt.setString(31,itemCode);
pstmt.setTimestamp(32,mfgDate);
pstmt.setString(33,suppCode);
pstmt.setString(34,suppCodeMfg);
count = pstmt.executeUpdate();
}
catch(SQLException ex)
{
ex.printStackTrace();
errString = "VTCONFERR";
throw new ITMException(ex);
}
catch(Exception e)
{
e.printStackTrace();
errString = "VTCONFERR";
throw new ITMException(e);
}
finally
{
try
{
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e)
{
System.out.println(e.getMessage());
throw new ITMException(e);
}
}
return errCode;
}
//end added by prajakta 27/12/06
}
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