Commit 5fc928fd authored by hkonda's avatar hkonda

New Rep_jar

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@216639 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 469782b7
// Changes done by Sagar on 25-06-2014 as no of labels were showing wrong if no of label arg left blank
// Changes done by Sagar on 02-06-2014 as Report was not giving output as per ITM
package ibase.webitm.reports.sun;
import java.io.Serializable;
import java.sql.Timestamp;
import java.sql.*;
import javax.ejb.*;
import java.rmi.*;
import java.util.*;
import java.text.*;
import javax.naming.*;
import ibase.system.config.*;
import ibase.system.config.resource.*; // uncommented by Rajni dated on 18/11/16 for DB connection from new package import
//import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException; // added by Pankaj dated on 23-03-17 to use exception handling.
/* Class for setting and getting of arguments */
public class labelQcApproved implements Serializable
{
String emp_code__aprv=null;
String loc_code__aprv=null;
java.util.Date retest_date=null;
Double no_art=0.0;
String item_code__new=null;
String type=null;
String sh_descr=null;
java.util.Date expiry_date =null;
String flag=null;
String lot_no__new=null;
java.util.Date rel_date=null;
String auto_reqc=null;
String city=null;
String reprint=null;
String descr=null;
Integer reprint_cnt=0; //Added variable by Rajni dated on 27/12/16 for reprint count as per C Raja new ccf CQ16-CS037
Statement statement=null;
ResultSet resultSet=null;
public String getemp_code__aprv()
{
return emp_code__aprv;
}
public void setemp_code__aprv(String emp_code__aprv)
{
try
{
this.emp_code__aprv = emp_code__aprv;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getloc_code__aprv()
{
return loc_code__aprv;
}
public void setloc_code__aprv(String loc_code__aprv)
{
try
{
this.loc_code__aprv = loc_code__aprv;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public java.util.Date getretest_date()
{
return retest_date;
}
public void setretest_date(java.util.Date retest_date)
{
try
{
this.retest_date = retest_date;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public Double getno_art()
{
return no_art;
}
public void setno_art(Double no_art)
{
try
{
this.no_art = no_art;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getitem_code__new()
{
return item_code__new;
}
public void setitem_code__new(String item_code__new)
{
try
{
this.item_code__new = item_code__new;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String gettype()
{
return type;
}
public void settype(String type)
{
try
{
this.type = type;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getsh_descr()
{
return sh_descr;
}
public void setsh_descr(String sh_descr)
{
try
{
this.sh_descr = sh_descr;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public java.util.Date getexpiry_date()
{
return expiry_date;
}
public void setexpiry_date(java.util.Date expiry_date)
{
try
{
this.expiry_date = expiry_date;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getflag()
{
return flag;
}
public void setflag(String flag)
{
try
{
this.flag = flag;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getlot_no__new()
{
return lot_no__new;
}
public void setlot_no__new(String lot_no__new)
{
try
{
this.lot_no__new = lot_no__new;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public java.util.Date getrel_date()
{
return rel_date;
}
public void setrel_date(java.util.Date rel_date)
{
try
{
this.rel_date = rel_date;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getauto_reqc()
{
return auto_reqc;
}
public void setauto_reqc(String auto_reqc)
{
try
{
this.auto_reqc = auto_reqc;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getcity()
{
return city;
}
public void setcity(String city)
{
try
{
this.city = city;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getreprint()
{
return reprint;
}
public void setreprint(String reprint)
{
try
{
this.reprint = reprint;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public String getdescr()
{
return descr;
}
public void setdescr(String descr)
{
try
{
this.descr = descr;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public Integer getreprint_cnt() //Added variable by rajni dated on 18/11/16 for reprint count new logic as per C Raja new ccf CQ16-CS044
{
return reprint_cnt;
}
public void setreprint_cnt(Integer reprint_cnt) //Added by rajni dated on 18/11/16 for reprint count new logic as per C Raja new ccf CQ16-CS044
{
try
{
this.reprint_cnt = reprint_cnt;
}
catch(Exception e)
{
e.printStackTrace();
//throw e;
}
}
public ArrayList setDataInXmlTemplet( TreeMap argMap,BaseDBConnection con)
{
String sql=null;
ArrayList returnArray =new ArrayList();
HashMap returnArray2=new HashMap();
String siteCode=(String)argMap.get("as_site_code");
//String fromDate=(String)argMap.get("as_qc_date__fr");
//String toDate= (String)argMap.get("as_qc_date__to");
String lotNo=(String)argMap.get("as_lotno_fr");
String noOflabel =(String)argMap.get("as_no_of_lable");
noOflabel=(noOflabel==null)?"0":noOflabel;
PreparedStatement statement = null;
//java.util.Date tranDateFrom=(java.util.Date)argMap.get("as_qc_date__fr");
//java.util.Date tranDateTo=(java.util.Date)argMap.get("as_qc_date__to");
String rptName=(String)argMap.get("as_rpt_name"); //Added by rajni dated on 17/11/16 for reprint count new logic as per C Raja new ccf CQ16-CS044
Integer reprintcnt = 0; //Added by Rajni dated on 11/11/16 for reprint count new logic as per C Raja new ccf CQ16-CS044
String lssiteCode="";
java.sql.Timestamp frmDateTstmpFr =null; // added by Pankaj dated on 23-03-17 to declate timestamp value
java.sql.Timestamp frmDateTstmpTo =null; // added by Pankaj dated on 23-03-17 to declate timestamp value
//SimpleDateFormat dateFormat1 = new SimpleDateFormat("dd/MM/yyyy");
//String fromDate=dateFormat1.format(tranDateFrom);
//String toDate=dateFormat1.format(tranDateTo);
//Added By Ramachandra on 30/03/2011...............[Retriving data For Multiple Site Code and Multiple Lot No's]
String siteCode1 = "";
java.util.Date lsord_date=null;
System.out.println("siteCode.indexOf(',')"+siteCode.indexOf(','));
if(siteCode.indexOf(',')>0)
{
String[] siteCodeAr = null;
siteCodeAr = siteCode.split(",");
for (int k1 = 0; k1 < siteCodeAr.length ; k1++ )
{
if (k1 == 0)
{
siteCode1 = "'" + siteCodeAr[k1] + "'";
}
else
{
siteCode1 = siteCode1 + ",'" + siteCodeAr[k1] + "'";
}
}
siteCode = siteCode1;
}
else
{
siteCode = "'" + siteCode + "'";
}
System.out.println("siteCode"+siteCode);
String lotNo1 = "";
String[] lotNoAr = null;
System.out.println("lotNo.indexOf(',')"+lotNo.indexOf(','));
if(lotNo.indexOf(',')>0)
{
lotNoAr = lotNo.split(",");
for (int k2 = 0; k2 < lotNoAr.length ; k2++ )
{
lotNoAr[k2] = "'" + lotNoAr[k2] + "'";
}
}
else
{
lotNoAr = new String[1];
lotNoAr[0] = "'"+lotNo+"'";
}
System.out.println("lotNoAr"+lotNoAr.length);
//Ended by Ramchandra on 30/03/2012.............
try
{
for(int j1 = 0; j1<lotNoAr.length ; j1++)
{
frmDateTstmpFr=java.sql.Timestamp.valueOf(argMap.get("as_qc_date__fr")+""); // added by Pankaj dated on 23-03-17 to use timestamp parameter.
frmDateTstmpTo=java.sql.Timestamp.valueOf(argMap.get("as_qc_date__to")+""); // added by Pankaj dated on 23-03-17 to use timestamp parameter.ss
sql="SELECT qc_order.lot_no__NEW,qc_order.rel_date,QC_ORDER.retest_date retest_date,QC_ORDER.EXPIRY_DATE expiry_date,(CASE WHEN qc_order.retest_date IS NULL THEN 'I' ELSE 'V' END) FLAG,qc_order.item_code__new,site.descr,site.city,site.sh_descr,(CASE WHEN qc_order.qc_create_type ='T' THEN 'RE-APPROVED' ELSE 'APPROVED' END) AS TYPE, qc_order.emp_code__aprv,qc_order.emp_code as AUTO_REQC,qc_order.loc_code__aprv,'' AS REPRINT,SUM(STOCK.NO_ART) no_art,QC_ORDER.QORDER_DATE,QC_ORDER.SITE_CODE,0 AS reprint_cnt FROM qc_order,stock,site,siteitem WHERE QC_ORDER.QORDER_DATE >=? AND QC_ORDER.QORDER_DATE <=? AND qc_order.status = 'C' AND QC_ORDER.SITE_CODE IN ("+siteCode+") AND QC_ORDER.LOT_NO__NEW IN ("+lotNoAr[j1]+" ) AND NVL(qc_order.qty_passed,0) > 0 AND qc_order.site_code = site.site_code AND site.site_code = siteitem.site_code AND qc_order.item_code__NEW = siteitem.item_code AND qc_order.site_Code = stock.site_code AND qc_order.item_code__new = stock.item_code AND qc_order.lot_no__new = stock.lot_no AND stock.inv_stat ='SALE' AND STOCK.QUANTITY > 0 GROUP BY qc_order.lot_no__NEW, qc_order.rel_date,QC_ORDER.retest_date,QC_ORDER.EXPIRY_DATE,(CASE WHEN qc_order.retest_date IS NULL THEN 'I' ELSE 'V' END),qc_order.item_code__new,site.descr, site.city,site.sh_descr,( CASE WHEN qc_order.qc_create_type ='T' THEN 'RE-APPROVED' ELSE 'APPROVED' END),qc_order.emp_code__aprv,AUTO_REQC,qc_order.loc_code__aprv, STOCK.NO_ART,QC_ORDER.QORDER_DATE,QC_ORDER.SITE_CODE , qc_order.emp_code ";
System.out.println("SQL:--> "+sql);
System.out.println("CON:--> "+con);
statement=con.prepareStatement(sql);
statement.setTimestamp(1, frmDateTstmpFr); // added by pankaj dated on 23-03-17. Set timestamp value from sql.
statement.setTimestamp(2, frmDateTstmpTo); // added by pankaj dated on 23-03-17. Set timestamp value from sql.
resultSet=statement.executeQuery();
//statement = con.createStatement();
//resultSet=statement.executeQuery(sql);
System.out.println("resultSet:--> "+resultSet);
Integer NoofLable=Integer.parseInt(noOflabel);
HashMap<String, Integer> hmCount = getReprintCount(rptName,siteCode ,frmDateTstmpFr ,frmDateTstmpTo, lotNoAr[j1],con); //Added by rajni dated on 17/11/16 to get return value from function.
System.out.println("hmCount:--> "+ hmCount.toString()); //Added by rajni dated on 17-11-16 to get return value from function for reprint count new logic as per C Raja new ccf CQ16-CS044.
while(resultSet.next())
{
lot_no__new=resultSet.getString(1);
rel_date=resultSet.getDate(2);
retest_date=resultSet.getDate(3);
expiry_date=resultSet.getDate(4);
flag=resultSet.getString(5);
item_code__new=resultSet.getString(6);
descr=resultSet.getString(7);
city=resultSet.getString(8);
sh_descr=resultSet.getString(9);
type=resultSet.getString(10);
emp_code__aprv=resultSet.getString(11);
auto_reqc=resultSet.getString(12);
loc_code__aprv=resultSet.getString(13);
reprint=resultSet.getString(14);
no_art=resultSet.getDouble(15);
lsord_date=resultSet.getDate(16);
lssiteCode=resultSet.getString(17);
int NO_ART=0;
/* Commented by Sagar on 25-06-2014 as no of labels were showing wrong if no of label arg left blank */
/* if(NoofLable==0)
{
NoofLable = 1;
} */
/* Commented by Sagar on 25-06-2014 as no of labels were showing wrong if no of label arg left blank */
if(NoofLable < no_art && NoofLable > 0)
{
NO_ART=NoofLable;
}
else
{
NO_ART=(int)no_art.doubleValue();
}
System.out.println("NO_ART: in ELseIF->"+NO_ART);
int i=0;
while(i<NO_ART)
{
HashMap returnArray1=new HashMap();
returnArray1.put("lot_no__new",lot_no__new);
returnArray1.put("rel_date",rel_date);
returnArray1.put("retest_date",retest_date);
returnArray1.put("expiry_date",expiry_date);
returnArray1.put("flag",flag);
returnArray1.put("item_code__new",item_code__new);
returnArray1.put("descr",descr);
returnArray1.put("city",city);
returnArray1.put("sh_descr",sh_descr);
returnArray1.put("type",type);
returnArray1.put("emp_code__aprv",emp_code__aprv);
returnArray1.put("auto_reqc",auto_reqc);
returnArray1.put("loc_code__aprv",loc_code__aprv);
returnArray1.put("reprint",reprint);
returnArray1.put("no_art",no_art);
HashMap returnmap=new HashMap();
returnmap=returnArray1;
System.out.println("returnArray1://///----->"+returnmap);
returnArray.add(returnArray1);
System.out.println("returnArray2:-->"+returnmap);
i++;
SimpleDateFormat dtFormat = new SimpleDateFormat("dd-MM-yy");
String date3 = dtFormat.format(lsord_date);
System.out.println("Date3:-->"+date3);
String key3 = lssiteCode + date3.trim()+ lot_no__new.trim(); //Added by rajni dated on 11/11/16 for reprint count new logic as per C Raja new ccf CQ16-CS044
System.out.println("key:--> "+key3);
reprintcnt=hmCount.get(key3); //Added by rajni dated on 11/11/16 for reprint count new logic as per C Raja new ccf CQ16-CS044
System.out.println("hmCount--> "+hmCount);
System.out.println("Check1--> "+reprintcnt);
returnArray1.put("reprint_cnt",reprintcnt); //Added by rajni dated on 11/11/16 for reprint count new logic as per C Raja new ccf CQ16-CS044
}
}
}
}
catch(Exception e)
{
e.printStackTrace();
System.out.println("Inside setDataInXmlTemplet Exception *******"+e.getMessage());
}
//Added By Ramchandra on 30/03/2012...............[To Close Connections of Data Base]
finally
{
try
{
if(resultSet!= null)
{
resultSet.close();
resultSet = null;
}
if(statement != null)
{
statement.close();
statement = null;
}
if(con != null)
{
con.close();
con = null;
}
}
catch ( Exception eFinal)
{
eFinal.printStackTrace();
}
}
//Ended by Ramchandra on 30/03/2012.............
return (returnArray);
}
public HashMap<String, Integer> getReprintCount(String rptName,String siteCode ,java.sql.Timestamp Date1 ,java.sql.Timestamp Date2 ,String lotNoAr,Connection con)
{
String sql="";
HashMap<String, Integer> hmCount = new HashMap<String, Integer>();
PreparedStatement pstmt = null;
ResultSet rs = null;
try
{
sql = "SELECT distinct(qc_order.site_code|| to_char(QC_ORDER.QORDER_DATE,'dd-mm-yy')|| trim(QC_ORDER.LOT_NO__NEW)),ddf_get_reprintcnt(qc_order.site_code||trim(QC_ORDER.QORDER_DATE)||trim(QC_ORDER.LOT_NO__NEW),'"+rptName+"') FROM qc_order,stock, site,siteitem WHERE QC_ORDER.QORDER_DATE >= ? AND QC_ORDER.QORDER_DATE <= ? AND qc_order.status = 'C' AND QC_ORDER.SITE_CODE IN ("+siteCode+") AND QC_ORDER.LOT_NO__NEW IN "+lotNoAr+" AND NVL(qc_order.qty_passed,0) > 0 AND qc_order.site_code = site.site_code AND site.site_code = siteitem.site_code AND qc_order.item_code__NEW = siteitem.item_code AND qc_order.site_Code = stock.site_code AND qc_order.item_code__new = stock.item_code AND qc_order.lot_no__new = stock.lot_no AND stock.inv_stat='SALE' AND STOCK.QUANTITY > 0" ;
pstmt = con.prepareStatement(sql);
pstmt.setTimestamp(1, Date1);
pstmt.setTimestamp(2, Date2);
rs = pstmt.executeQuery();
//pstmt = con.prepareStatement(sql);
//rs = pstmt.executeQuery();
while(rs.next()){
hmCount.put(rs.getString(1),rs.getInt(2));
System.out.println("ABCD1 " + hmCount);
}
if(pstmt != null){
pstmt.close();
pstmt= null;
}
if(rs != null){
rs.close();
rs = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
System.out.println("Returning from ["+ this.getClass().getSimpleName() + "] : getReprintCount ["+ hmCount.toString()+"]");
return hmCount;
}
}
\ 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