Commit cb8b3e19 authored by sbade's avatar sbade

updated source code for production vs budget and machin utilization as at client side


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97710 ce508802-f39f-4f6c-b175-0d175dae99d5
parent b6bea4e1
package ibase.dashboard.mfg.ejb; package ibase.dashboard.mfg.ejb;
import ibase.system.config.ConnDriver; import ibase.system.config.ConnDriver;
import ibase.utility.EMail; import ibase.utility.EMail;
import ibase.webitm.ejb.ValidatorEJB; import ibase.webitm.ejb.ValidatorEJB;
...@@ -66,11 +65,12 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -66,11 +65,12 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
// cal.add(cal.MONTH,-1); // cal.add(cal.MONTH,-1);
cal.set(Calendar.DATE, cal.getActualMinimum(Calendar.DATE)); cal.set(Calendar.DATE, cal.getActualMinimum(Calendar.DATE));
sql = "select g.fld_value, g.descr from gencodes g where fld_name = 'GEO_LOC' and mod_name = 'X' and instr((select trim(var_value) from disparm where var_name = 'DWH_SITE_GEO_LOC'),trim(g.fld_value)) >0"; sql = "select g.fld_value, g.descr from gencodes g where fld_name = 'GEO_LOC' and mod_name = 'X' and instr((select trim(var_value) from disparm where var_name = 'DWH_SITE_GEO_LOC'),trim(g.fld_value)) >0";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
xmlDataForGeo = new StringBuffer("<?xml version='1.0' encoding='ISO-8859-1'?><Root>"); xmlDataForGeo = new StringBuffer("<?xml version='1.0' encoding='ISO-8859-1'?><Root>");
while (rs.next()) while (rs.next())
{ {
xmlDataForGeo.append("<Detail>"); xmlDataForGeo.append("<Detail>");
xmlDataForGeo.append("<fld_value>").append("<![CDATA[" + checkNull(rs.getString("fld_value")) + "]]>").append("</fld_value>"); xmlDataForGeo.append("<fld_value>").append("<![CDATA[" + checkNull(rs.getString("fld_value")) + "]]>").append("</fld_value>");
xmlDataForGeo.append("<descr>").append("<![CDATA[" + checkNull(rs.getString("descr")) + "]]>").append("</descr>"); xmlDataForGeo.append("<descr>").append("<![CDATA[" + checkNull(rs.getString("descr")) + "]]>").append("</descr>");
...@@ -82,7 +82,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -82,7 +82,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
pstmt.close(); pstmt.close();
rs.close(); rs.close();
pstmt = null; pstmt = null;
rs = null; rs = null;
sql = "select distinct (i.unit__form),u.descr from item_type i ,uom u where i.unit__form=u.unit and i.unit__form is not null"; sql = "select distinct (i.unit__form),u.descr from item_type i ,uom u where i.unit__form=u.unit and i.unit__form is not null";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
...@@ -95,6 +95,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -95,6 +95,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
xmlDataForUnit.append("</Detail>"); xmlDataForUnit.append("</Detail>");
} }
xmlDataForUnit.append("</Root>"); xmlDataForUnit.append("</Root>");
System.out.println("unitForm Drop Down List==" + xmlDataForUnit);
pstmt.close(); pstmt.close();
rs.close(); rs.close();
pstmt = null; pstmt = null;
...@@ -160,7 +161,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -160,7 +161,7 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
String unit = ""; String unit = "";
String previousUnit = ""; String previousUnit = "";
String geoLocationPrevious = ""; String geoLocationPrevious = "";
int count = 0;
double dailyBudgetQty = 0; double dailyBudgetQty = 0;
String geol_Descr = ""; String geol_Descr = "";
String unit_Descr = ""; String unit_Descr = "";
...@@ -168,39 +169,16 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -168,39 +169,16 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
String month = ""; String month = "";
String[] tempfrmDate = null; String[] tempfrmDate = null;
String[] temptoDate = null; String[] temptoDate = null;
ArrayList<String> countryList = new ArrayList<String>();
ArrayList<String> countryDescrList = new ArrayList<String>();
int firstDayOfMonth = 0; int firstDayOfMonth = 0;
int lastDayOfMonth = 0; int lastDayOfMonth = 0;
listDate = new ArrayList<String>(); listDate = new ArrayList<String>();
xmlData = new StringBuffer("<?xml version='1.0' encoding='ISO-8859-1'?><Root>");
xmlData.append("<Detail>");
String country = "";
String varValue = "";
int count = 0;
String geoLocationArr[] = null;
String varValueArr[] = null;
StringBuffer prsntGeoLocForCntry = null;
int cntFrBudget = 0;
String curCumQty = "";
String missingDate = "";
String pyrCumqty = "0.0";
int dayCount = 0;
String descr="";
try try
{ {
countryList.add("DWH_GEOLOC_IND");
countryList.add("DWH_GEOLOC_US");
countryList.add("DWH_GEOLOC_ROW");
countryDescrList.add("INDIA");
countryDescrList.add("UNITED STATES");
countryDescrList.add("ROW");
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver = null;
// change on date 11/11/2013 System.out.println("comming from date from jsp =" + frmDate + "To Date comming from jsp==" + toDate);
tempfrmDate = frmDate.split("-"); tempfrmDate = frmDate.split("-");
firstDayOfMonth = Integer.parseInt(tempfrmDate[0]); firstDayOfMonth = Integer.parseInt(tempfrmDate[0]);
month = tempfrmDate[1]; month = tempfrmDate[1];
...@@ -208,198 +186,62 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -208,198 +186,62 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
// case2 // case2
temptoDate = toDate.split("-"); temptoDate = toDate.split("-");
lastDayOfMonth = Integer.parseInt(temptoDate[0]); lastDayOfMonth = Integer.parseInt(temptoDate[0]);
System.out.println("First of Month==" + firstDayOfMonth + "& Last of Month===" + lastDayOfMonth + "Month from jsp ==" + month + "Year from jsp ==" + year);
for (int i = firstDayOfMonth; i <= lastDayOfMonth; i++) for (int i = firstDayOfMonth; i <= lastDayOfMonth; i++)
{ {
listDate.add(String.valueOf(i)); listDate.add(String.valueOf(i));
} }
// end of changes // end of changes
System.out.println("select Final initGeoLocation inside in EJB ===" + geoLoc + "selected initUnitForm inside in java ==" + unitForm + "length of List ====" + listDate.size() + "AND Value of ===" + listDate);
//sql(OLD_10/02/2015) = "select geo_loc, unit__form,to_char (tran_date,'DD') as tran_date, day_quantity, pyr_cumqty, " + "cum_budqty , sum(day_quantity) over (partition by geo_loc, unit__form order by tran_date) " + "as cur_cumqty from ( select s.GEO_LOC,p.tran_date, t.unit__form, " + "sum(fn_qty_form(p.item_code,p.unit,t.unit__form,i.phy_attrib_6, p.quantity)) " + "as day_quantity, fn_get_pyr_cumqty( to_date(add_months(p.tran_date,-12)),s.geo_loc,t.unit__form ) " + "as pyr_cumqty, fn_get_budgetqty(p.tran_date,s.GEO_LOC,t.unit__form ) " + "as cum_budqty from dwh_production_day_events p, item i, item_type t, " + "site s where p.site_code = s.site_code and p.item_code = i.item_code " + "and i.item_type = t.item_type and p.tran_date >= ? " + "and p.tran_date <= ? " + "and p.ref_type = (case when t.item_type in('AMPOULES','BOTTLES','DROPS','INHALER','POWDER','POUCH','SUSPENSION','TUBE','VIALS','GRANULES') then 'F' when t.item_type in('CAPSULES','TABLETS',' SOFTGELCAP') then 'F' else '' end ) " + "and p.ref_ser = 'W-RCP' and s.geo_loc in(" + geoLoc + ") " + "and t.unit__form in(" + unitForm + ") group by s.GEO_LOC, p.tran_date, t.unit__form ) " + "order by geo_loc, unit__form,tran_date";
sql = "select geo_loc, unit__form,to_char (tran_date,'DD') as tran_date, day_quantity, pyr_cumqty, " + "cum_budqty , sum(day_quantity) over (partition by geo_loc, unit__form order by tran_date) " + "as cur_cumqty from ( select s.GEO_LOC,p.tran_date, t.unit__form, " + "sum(fn_qty_form(p.item_code,p.unit,t.unit__form,i.phy_attrib_6, p.quantity)) " + "as day_quantity, fn_get_pyr_cumqty( to_date(add_months(p.tran_date,-12)),s.geo_loc,t.unit__form ) " + "as pyr_cumqty, fn_get_budgetqty(p.tran_date,s.GEO_LOC,t.unit__form ) " + "as cum_budqty from dwh_production_day_events p, item i, item_type t, " + "site s where p.site_code = s.site_code and p.item_code = i.item_code " + "and i.item_type = t.item_type and p.tran_date >= ? " + "and p.tran_date <= ? " + "and p.ref_type = (case when t.item_type in (select trim(item_type) from item_type where unit__form is not null) then 'F' when t.item_type in (select trim(item_type) from item_type where unit__form is not null) then 'F' else '' end ) " + "and p.ref_ser = 'W-RCP' and s.geo_loc in(" + geoLoc + ") " + "and t.unit__form in(" + unitForm + ") group by s.GEO_LOC, p.tran_date, t.unit__form ) " + "order by geo_loc, unit__form,tran_date";
System.out.println("select Final initGeoLocation inside in EJB ===" + geoLoc + "selected initUnitForm inside in java ==" + unitForm + "length of List ====" + listDate.size() + "AND Value of ===" + listDate); pstmt = conn.prepareStatement(sql);
// geoLoc = "'105','110','117','145','120','129','130'"; pstmt.setString(1, frmDate);
geoLocationArr = geoLoc.replace("'", "").split(","); pstmt.setString(2, toDate);
// End of setter statement
//////****Added new code by sachin on 06-02-15***\\\\\\\\\\ rs = pstmt.executeQuery();
xmlData = new StringBuffer("<?xml version='1.0' encoding='ISO-8859-1'?><Root>");
xmlData.append("<Detail>");
int cntFrBudget = 0;
String curCumQty = "";
String missingDate = "";
String pyrCumqty = "0.0";
int dayCount = 0;
for (int countryCnt = 0; countryCnt < countryList.size(); countryCnt++) while (rs.next())
{ {
count = 0; count++;
country = countryList.get(countryCnt); geoLocation = checkNull(rs.getString("geo_loc"));
descr=""; unit = checkNull(rs.getString("unit__form"));
sql = "select trim(var_value) as var_value, descr from disparm where var_name = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, country);
// End of setter statement
rs = pstmt.executeQuery();
if (rs.next())
{
varValue = checkNull(rs.getString("var_value"));
//descr=checkNull(rs.getString("descr"));
}
pstmt.close();
pstmt = null;
rs.close();
rs = null;
descr=countryDescrList.get(countryCnt);
//varValue = "110,105,200";
varValueArr = varValue.split(",");
prsntGeoLocForCntry = new StringBuffer();
for (int i = 0; i < geoLocationArr.length; i++)
{
for (int j = 0; j < varValueArr.length; j++)
{
if (geoLocationArr[i].equalsIgnoreCase(varValueArr[j]))
{
if (prsntGeoLocForCntry.length() != 0)
{
prsntGeoLocForCntry.append(",'" + varValueArr[j] + "'");
} else
{
prsntGeoLocForCntry.append("'" + varValueArr[j] + "'");
}
}
}
}
geoLoc = prsntGeoLocForCntry.toString();
if(geoLoc!=null && geoLoc.trim().length() > 0)
{
sql = "select geo_loc, unit__form,to_char (tran_date,'DD') as tran_date, day_quantity, pyr_cumqty, " + "cum_budqty , sum(day_quantity) over (partition by geo_loc, unit__form order by tran_date) " + "as cur_cumqty from ( select s.GEO_LOC,p.tran_date, t.unit__form, " + "sum(fn_qty_form(p.item_code,p.unit,t.unit__form,i.phy_attrib_6, p.quantity)) " + "as day_quantity, fn_get_pyr_cumqty( to_date(add_months(p.tran_date,-12)),s.geo_loc,t.unit__form ) " + "as pyr_cumqty, fn_get_budgetqty(p.tran_date,s.GEO_LOC,t.unit__form ) " + "as cum_budqty from dwh_production_day_events p, item i, item_type t, " + "site s where p.site_code = s.site_code and p.item_code = i.item_code " + "and i.item_type = t.item_type and p.tran_date >= ? " + "and p.tran_date <= ? " + "and p.ref_type = (case when t.item_type in('AMPOULES','BOTTLES','DROPS','INHALER','POWDER','POUCH','SUSPENSION','TUBE','VIALS','GRANULES') then 'F' when t.item_type in('CAPSULES','TABLETS',' SOFTGELCAP') then 'F' else '' end ) " + "and p.ref_ser = 'W-RCP' and s.geo_loc in(" + geoLoc + ") " + "and t.unit__form in(" + unitForm + ") group by s.GEO_LOC, p.tran_date, t.unit__form ) " + "order by geo_loc, unit__form,tran_date";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, frmDate);
pstmt.setString(2, toDate);
// End of setter statement
rs = pstmt.executeQuery();
cntFrBudget = 0;
curCumQty = "";
missingDate = "";
pyrCumqty = "0.0";
dayCount = 0;
xmlData.append("<country_code id=\"" + country + "\" descr=\"" + descr + "\">");
while (rs.next())
{
count++;
geoLocation = checkNull(rs.getString("geo_loc"));
unit = checkNull(rs.getString("unit__form"));
if (count > 1 && ((!previousUnit.equals(unit)) || (!geoLocationPrevious.equals(geoLocation))))
{
if (dayCount <= lastDayOfMonth)
{
int cntr = dayCount;
for (int j = 0; j < lastDayOfMonth - cntr; j++)
{
cntFrBudget++;
xmlData.append("<tran_date date=\"" + (listDate.get(dayCount)) + "\">");
xmlData.append("<day_quantity quantity=\"0\">");
// Add new Block for preyear Cumulative
// sql="select to_date(add_months(?,-12)) from dual ";
missingDate = listDate.get(dayCount) + "-" + month + "-" + year;
sql = "select fn_get_pyr_cumqty( to_date(add_months('" + missingDate + "',-12))," + geoLocationPrevious + ",'" + previousUnit + "') as pyr_cumqty from dual";
pstmt1 = conn.prepareStatement(sql);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
if (rs1.getDouble("pyr_cumqty") != 0)
{
pyrCumqty = checkNull(rs1.getString("pyr_cumqty"));
System.out.println("preyrcumulative ===" + pyrCumqty);
System.out.println("preyrcumulative for missing date:" + missingDate + "===geoloc:" + geoLocationPrevious + ":previousUnit:" + previousUnit);
}
}
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
// End of preyearCumulative
xmlData.append("<pyr_cumqty>").append("<![CDATA[" + pyrCumqty + "]]>").append("</pyr_cumqty>");
xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>");
xmlData.append("<cur_cumqty>").append("<![CDATA[" + curCumQty + "]]>").append("</cur_cumqty>");
xmlData.append("</day_quantity>");
xmlData.append("</tran_date>");
dayCount++;
}
}
xmlData.append("</unit_form>");
xmlData.append("</geo_loc>");
// dayCount=0;
}
if ((count == 1) || (!previousUnit.equals(unit)) || (!geoLocationPrevious.equals(geoLocation)))
{
// Add here for decr pupose
sql = "select descr from gencodes where FLD_NAME='GEO_LOC' and fld_value= ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, geoLocation);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
geol_Descr = checkNull(rs1.getString("descr"));
}
pstmt1 = null;
rs1 = null;
// **************************************************
sql = "select descr from uom where unit= ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, unit);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
unit_Descr = checkNull(rs1.getString("descr"));
} if (count > 1 && ((!previousUnit.equals(unit)) || (!geoLocationPrevious.equals(geoLocation))))
pstmt1.close(); {
pstmt1 = null;
rs1.close();
rs1 = null;
// End here decr pupose for Unit_form and geo_location
cntFrBudget = 0;
xmlData.append("<geo_loc location=\"" + geoLocation + "\" glocdescr =\"" + geol_Descr + "\" >");
xmlData.append("<unit_form unit=\"" + checkNull(rs.getString("unit__form")) + "\" unitdescr =\"" + unit_Descr + "\">");
dayCount = 0;
curCumQty = "0.0";
pyrCumqty = "0.0";
geoLocationPrevious = geoLocation = checkNull(rs.getString("geo_loc"));
previousUnit = checkNull(rs.getString("unit__form"));
// Add descr
geol_Descr = "";
unit_Descr = "";
}
dailyBudgetQty = rs.getDouble("cum_budqty");
cntFrBudget++;
if (!listDate.get(dayCount).equals(rs.getString("tran_date"))) if (dayCount <= lastDayOfMonth)
{ {
int cnt = dayCount; int cntr = dayCount;
for (int i = 0; i < Integer.parseInt(rs.getString("tran_date")) - (cnt + 1); i++) for (int j = 0; j < lastDayOfMonth - cntr; j++)
{ {
// Add new Block for preyear Cumulative cntFrBudget++;
// sql="select to_date(add_months(?,-12)) from dual "; xmlData.append("<tran_date date=\"" + (listDate.get(dayCount)) + "\">");
xmlData.append("<day_quantity quantity=\"0\">");
missingDate = listDate.get(dayCount) + "-" + month + "-" + year; missingDate = listDate.get(dayCount) + "-" + month + "-" + year;
sql = "select fn_get_pyr_cumqty( to_date(add_months('" + missingDate + "',-12))," + geoLocation + ",'" + unit + "') as pyr_cumqty from dual"; sql = "select fn_get_pyr_cumqty( to_date(add_months('" + missingDate + "',-12))," + geoLocationPrevious + ",'" + previousUnit + "') as pyr_cumqty from dual";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
if (rs1.next()) if (rs1.next())
{ {
// Modify by birendra Pandey
if (rs1.getDouble("pyr_cumqty") != 0) if (rs1.getDouble("pyr_cumqty") != 0)
{ {
pyrCumqty = checkNull(rs1.getString("pyr_cumqty")); pyrCumqty = checkNull(rs1.getString("pyr_cumqty"));
System.out.println("preyrcumulative ===" + pyrCumqty); System.out.println("preyrcumulative ===" + pyrCumqty);
System.out.println("preyrcumulative for missing date:" + missingDate + "===geoloc:" + geoLocationPrevious + ":previousUnit:" + previousUnit);
} }
} }
pstmt1.close(); pstmt1.close();
rs1.close(); rs1.close();
...@@ -407,86 +249,176 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -407,86 +249,176 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
rs1 = null; rs1 = null;
// End of preyearCumulative // End of preyearCumulative
xmlData.append("<tran_date date=\"" + (listDate.get(dayCount)) + "\">");
xmlData.append("<day_quantity quantity=\"0\">");
xmlData.append("<pyr_cumqty>").append("<![CDATA[" + pyrCumqty + "]]>").append("</pyr_cumqty>"); xmlData.append("<pyr_cumqty>").append("<![CDATA[" + pyrCumqty + "]]>").append("</pyr_cumqty>");
xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>"); xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>");
xmlData.append("<cur_cumqty>").append("<![CDATA[" + curCumQty + "]]>").append("</cur_cumqty>"); xmlData.append("<cur_cumqty>").append("<![CDATA[" + curCumQty + "]]>").append("</cur_cumqty>");
xmlData.append("</day_quantity>"); xmlData.append("</day_quantity>");
xmlData.append("</tran_date>"); xmlData.append("</tran_date>");
dayCount++; dayCount++;
cntFrBudget++;
} }
} }
xmlData.append("<tran_date date=\"" + checkNull(rs.getString("tran_date")) + "\">"); xmlData.append("</unit_form>");
xmlData.append("<day_quantity quantity=\"" + checkNull(rs.getString("day_quantity")) + "\">"); xmlData.append("</geo_loc>");
xmlData.append("<pyr_cumqty>").append("<![CDATA[" + checkNull(rs.getString("pyr_cumqty")) + "]]>").append("</pyr_cumqty>"); // dayCount=0;
xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>");
xmlData.append("<cur_cumqty>").append("<![CDATA[" + checkNull(rs.getString("cur_cumqty")) + "]]>").append("</cur_cumqty>");
xmlData.append("</day_quantity>");
xmlData.append("</tran_date>");
curCumQty = checkEmpty(checkNull(rs.getString("cur_cumqty")));
pyrCumqty = checkEmpty(checkNull(rs.getString("pyr_cumqty")));
dayCount++;
} }
pstmt.close();
pstmt = null;
rs.close();
rs = null;
if (count > 0) if ((count == 1) || (!previousUnit.equals(unit)) || (!geoLocationPrevious.equals(geoLocation)))
{ {
if (dayCount < lastDayOfMonth)
// Add here for decr pupose
sql = "select descr from gencodes where FLD_NAME='GEO_LOC' and fld_value= ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, geoLocation);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{ {
geol_Descr = checkNull(rs1.getString("descr"));
}
pstmt1 = null;
rs1 = null;
// **************************************************
sql = "select descr from uom where unit= ?";
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, unit);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
unit_Descr = checkNull(rs1.getString("descr"));
for (int p = dayCount; p < lastDayOfMonth; p++) }
pstmt1.close();
pstmt1 = null;
rs1.close();
rs1 = null;
// End here decr pupose for Unit_form and geo_location
cntFrBudget = 0;
xmlData.append("<geo_loc location=\"" + geoLocation + "\" glocdescr =\"" + geol_Descr + "\" >");
xmlData.append("<unit_form unit=\"" + checkNull(rs.getString("unit__form")) + "\" unitdescr =\"" + unit_Descr + "\">");
dayCount = 0;
curCumQty = "0.0";
pyrCumqty = "0.0";
geoLocationPrevious = geoLocation = checkNull(rs.getString("geo_loc"));
previousUnit = checkNull(rs.getString("unit__form"));
// Add descr
geol_Descr = "";
unit_Descr = "";
}
dailyBudgetQty = rs.getDouble("cum_budqty");
cntFrBudget++;
if (!listDate.get(dayCount).equals(rs.getString("tran_date")))
{
int cnt = dayCount;
for (int i = 0; i < Integer.parseInt(rs.getString("tran_date")) - (cnt + 1); i++)
{
// Add new Block for preyear Cumulative
// sql="select to_date(add_months(?,-12)) from dual ";
missingDate = listDate.get(dayCount) + "-" + month + "-" + year;
sql = "select fn_get_pyr_cumqty( to_date(add_months('" + missingDate + "',-12))," + geoLocation + ",'" + unit + "') as pyr_cumqty from dual";
pstmt1 = conn.prepareStatement(sql);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{ {
cntFrBudget++; // Modify by birendra Pandey
// sql="select to_date(add_months(?,-12)) from dual "; if (rs1.getDouble("pyr_cumqty") != 0)
missingDate = listDate.get(dayCount) + "-" + month + "-" + year;
sql = "select fn_get_pyr_cumqty( to_date(add_months('" + missingDate + "',-12))," + geoLocation + ",'" + unit + "') as pyr_cumqty from dual";
pstmt1 = conn.prepareStatement(sql);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{ {
if (rs1.getDouble("pyr_cumqty") != 0) pyrCumqty = checkNull(rs1.getString("pyr_cumqty"));
{ System.out.println("preyrcumulative ===" + pyrCumqty);
pyrCumqty = checkNull(rs1.getString("pyr_cumqty")); }
System.out.println("pyrCumqty As New ===" + pyrCumqty);
} }
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
// End of preyearCumulative
xmlData.append("<tran_date date=\"" + (listDate.get(dayCount)) + "\">");
xmlData.append("<day_quantity quantity=\"0\">");
xmlData.append("<pyr_cumqty>").append("<![CDATA[" + pyrCumqty + "]]>").append("</pyr_cumqty>");
xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>");
xmlData.append("<cur_cumqty>").append("<![CDATA[" + curCumQty + "]]>").append("</cur_cumqty>");
xmlData.append("</day_quantity>");
xmlData.append("</tran_date>");
dayCount++;
cntFrBudget++;
} }
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
// End of preyearCumulative
xmlData.append("<tran_date date=\"" + (listDate.get(dayCount)) + "\">"); }
xmlData.append("<day_quantity quantity=\"0\">");
xmlData.append("<pyr_cumqty>").append("<![CDATA[" + pyrCumqty + "]]>").append("</pyr_cumqty>"); xmlData.append("<tran_date date=\"" + checkNull(rs.getString("tran_date")) + "\">");
xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>"); xmlData.append("<day_quantity quantity=\"" + checkNull(rs.getString("day_quantity")) + "\">");
xmlData.append("<cur_cumqty>").append("<![CDATA[" + curCumQty + "]]>").append("</cur_cumqty>"); xmlData.append("<pyr_cumqty>").append("<![CDATA[" + checkNull(rs.getString("pyr_cumqty")) + "]]>").append("</pyr_cumqty>");
xmlData.append("</day_quantity>"); xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>");
xmlData.append("</tran_date>"); xmlData.append("<cur_cumqty>").append("<![CDATA[" + checkNull(rs.getString("cur_cumqty")) + "]]>").append("</cur_cumqty>");
dayCount++; xmlData.append("</day_quantity>");
xmlData.append("</tran_date>");
curCumQty = checkEmpty(checkNull(rs.getString("cur_cumqty")));
pyrCumqty = checkEmpty(checkNull(rs.getString("pyr_cumqty")));
dayCount++;
}
if (count > 0)
{
if (dayCount < lastDayOfMonth)
{
for (int p = dayCount; p < lastDayOfMonth; p++)
{
cntFrBudget++;
// sql="select to_date(add_months(?,-12)) from dual ";
missingDate = listDate.get(dayCount) + "-" + month + "-" + year;
sql = "select fn_get_pyr_cumqty( to_date(add_months('" + missingDate + "',-12))," + geoLocation + ",'" + unit + "') as pyr_cumqty from dual";
pstmt1 = conn.prepareStatement(sql);
rs1 = pstmt1.executeQuery();
if (rs1.next())
{
if (rs1.getDouble("pyr_cumqty") != 0)
{
pyrCumqty = checkNull(rs1.getString("pyr_cumqty"));
System.out.println("pyrCumqty As New ===" + pyrCumqty);
}
} }
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
// End of preyearCumulative
xmlData.append("<tran_date date=\"" + (listDate.get(dayCount)) + "\">");
xmlData.append("<day_quantity quantity=\"0\">");
xmlData.append("<pyr_cumqty>").append("<![CDATA[" + pyrCumqty + "]]>").append("</pyr_cumqty>");
xmlData.append("<cum_budqty>").append("<![CDATA[" + dailyBudgetQty * (cntFrBudget) + "]]>").append("</cum_budqty>");
xmlData.append("<cur_cumqty>").append("<![CDATA[" + curCumQty + "]]>").append("</cur_cumqty>");
xmlData.append("</day_quantity>");
xmlData.append("</tran_date>");
dayCount++;
} }
xmlData.append("</unit_form>");
xmlData.append("</geo_loc>");
} }
xmlData.append("</country_code>"); xmlData.append("</unit_form>");
} xmlData.append("</geo_loc>");
} }
xmlData.append("</Detail>"); xmlData.append("</Detail>");
xmlData.append("</Root>"); xmlData.append("</Root>");
pstmt.close();
pstmt = null;
rs.close();
rs = null;
} catch (Exception e) } catch (Exception e)
{ {
...@@ -518,13 +450,11 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -518,13 +450,11 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
throw new ITMException(d); throw new ITMException(d);
} }
} }
System.out.println("xmlData.toString() is" + xmlData.toString());
return xmlData.toString(); return xmlData.toString();
} }
// End main method which are performed to all chart // End main method which are performed to all chart
private String checkNull(String input) private String checkNull(String input)
{ {
...@@ -550,8 +480,8 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -550,8 +480,8 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
} }
return input; return input;
} }
// start method for roule validation // start method for roule validation
public boolean getRoleValid(String userId, String roleCode) throws RemoteException, ITMException public boolean getRoleValid(String userId, String roleCode) throws RemoteException, ITMException
{ {
boolean flag = false; boolean flag = false;
...@@ -599,288 +529,249 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -599,288 +529,249 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
return flag; return flag;
} }
//end Role validation //end Role validation
//start method for PDF generate //start method for PDF generate
public String generatePDF(HashMap<String, List<String>> hashMap, String exportPDFPath, String exportImagePath, String preyearMonth, String rptTitle, String userID, HashMap<String, List<String>> chartNameMap,HashMap<String, String> cntryIdNDescrMap) throws RemoteException, ITMException public String generatePDF(HashMap<String, List<String>> hashMap, String exportPDFPath, String exportImagePath, String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException
{ {
// System.out.print("Country list in generate pdf="+countryList );
System.out.print("hashMap is=" + hashMap);
System.out.print("chartNameMap is =" + chartNameMap);
@SuppressWarnings("unused") @SuppressWarnings("unused")
PdfWriter writer = null; PdfWriter writer = null;
OutputStream file = null; OutputStream file = null;
Document document = null; Document document = null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null; PreparedStatement pstmt = null;
ResultSet rs = null; ResultSet rs = null;
ArrayList<String> mailInfo = null; ArrayList<String> mailInfo=null;
String imageName = null; String imageName = null;
List<String> gridDataList = null; List<String> gridDataList = null;
Image image = null; Image image = null;
File attachFile = null; File attachFile = null;
String imgFilePath = null; String imgFilePath =null;
File existImgFile = null; File existImgFile =null;
String pdfFileName = null; String pdfFileName =null;
String toMailId = ""; String toMailId ="";
String ccMailId = ""; String ccMailId ="";
String bccAddress = ""; String bccAddress ="";
String subject = ""; String subject ="";
String userWiseBodytext = ""; String userWiseBodytext="";
String resultFlage = "false"; String resultFlage ="false";
int keyListSize = 0; System.out.print("Calling for PDF created step1");
int mod = 0;
int devide = 0;
int prntTblNo = 0;
int parentCnt = 0;
int childTblCnt = 0;
PdfPTable parentTable = null;
int imageCounter = 0;
String country = "";
SimpleDateFormat simpleDateFormat = null;
Calendar calendar = null;
String currDate = "";
Paragraph preface = null;
Paragraph countryTitle = null;
List<String> countyWiseDataList = new ArrayList<String>();
System.out.print("Calling for PDF created step1");
try try
{ {
simpleDateFormat = new SimpleDateFormat("dd-MMM-yy"); SimpleDateFormat simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
currDate = simpleDateFormat.format(calendar.getTime()); String currDate = simpleDateFormat.format(calendar.getTime());
document = new Document(); document = new Document();
pdfFileName = exportPDFPath + rptTitle + "-" + userID + ".pdf"; pdfFileName = exportPDFPath+rptTitle+"-"+userID+".pdf";
System.out.println("modify PDF file name " + pdfFileName + " current date formate===" + currDate); System.out.println("modify PDF file name "+ pdfFileName+"current date formate==="+currDate);
file = new FileOutputStream(new File(pdfFileName)); file = new FileOutputStream(new File(pdfFileName));
writer = PdfWriter.getInstance(document, file); writer = PdfWriter.getInstance(document, file);
document.open(); document.open();
preface = new Paragraph(); Paragraph preface = new Paragraph();
preface.setAlignment(Element.ALIGN_CENTER); preface.setAlignment(Element.ALIGN_CENTER);
preface.add(new Paragraph(rptTitle, FontFactory.getFont(FontFactory.TIMES_ROMAN, 15))); preface.add(new Paragraph(rptTitle, FontFactory.getFont(FontFactory.TIMES_ROMAN, 15)));
preface.add(new Paragraph(" ")); preface.add(new Paragraph(" "));
document.add(preface); document.add(preface);
ArrayList<String> keyList=new ArrayList<String>();
//ArrayList<List<String>> valueList = new ArrayList<List<String>>(); ArrayList<List<String>> valueList=new ArrayList<List<String>>();
for (Map.Entry<String, List<String>> entry : hashMap.entrySet())
for (Map.Entry<String, List<String>> entry : chartNameMap.entrySet())
{ {
country = entry.getKey(); keyList.add(entry.getKey());
String countryDescr=cntryIdNDescrMap.get(country); valueList.add(entry.getValue());
countryTitle = new Paragraph(); }
countryTitle.setAlignment(Element.ALIGN_CENTER); int keyListSize =keyList.size();
// countryTitle.add(new Paragraph(countryDescr, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); int mod =keyListSize%3;
countryTitle.add(new Paragraph(countryDescr, FontFactory.getFont(FontFactory.TIMES_ROMAN, 12))); int devide =keyListSize/3;
countryTitle.add(new Paragraph(" ")); int prntTblNo =mod+devide;
//PdfPTable countryLblTbl = new PdfPTable(1); int parentCnt=0;
//countryLblTbl.addCell(countryTitle); int childTblCnt=0;
PdfPTable parentTable=null;
document.add(countryTitle); int imageCounter=0;
System.out.println(" countryDescr is = " + countryDescr);
countyWiseDataList = entry.getValue(); for(int size=1;size<=prntTblNo;size++)
{
//keyList.add(entry.getKey()); parentCnt++;
//countyWiseDataList.add(hashMap.get(entry.getKey())); parentTable = new PdfPTable(3);
parentTable.setWidthPercentage(100);
/*parentTable = new PdfPTable(3);*/
PdfPTable childtable = null;
PdfPTable table = null;
PdfPCell cell = null;
childTblCnt=0;
keyListSize = countyWiseDataList.size(); for(int i= 0; i < 3; i++)
System.out.println(" keyListSize is = " + keyListSize);
mod = keyListSize % 3;
devide = keyListSize / 3;
prntTblNo = mod + devide;
parentCnt = 0;
childTblCnt = 0;
imageCounter = 0;
System.out.println("prntTblNo is = " + prntTblNo);
for (int size = 1; size <= prntTblNo; size++)
{ {
parentCnt++; if(imageCounter < keyListSize)
parentTable = new PdfPTable(3);
parentTable.setWidthPercentage(100);
PdfPTable childtable = null;
PdfPTable table = null;
PdfPCell cell = null;
childTblCnt = 0;
for (int i = 0; i < 3; i++)
{ {
if (imageCounter < keyListSize) childTblCnt++;
{ childtable = new PdfPTable(1);
childTblCnt++; childtable.setWidthPercentage(90);
childtable = new PdfPTable(1);
childtable.setWidthPercentage(90); imageName =keyList.get(imageCounter);
imageName = countyWiseDataList.get(imageCounter); gridDataList =valueList.get(imageCounter);
System.out.println("imageName is ==" + imageName); //Add by Birendra Pandey
gridDataList = hashMap.get(imageName); imageCounter++;
//Add by Birendra Pandey imgFilePath = exportImagePath+imageName+userID+".png";
imageCounter++; image = Image.getInstance(imgFilePath);
System.out.println("Image name with image path =="+imageName+"imgFilePath=="+imgFilePath);
//imgFilePath = exportImagePath + imageName + userID + ".png";
imgFilePath = exportImagePath + imageName + ".png"; childtable.addCell(image);
//code for images deleted
System.out.println("Image name with image path ==" + imageName + " imgFilePath==" + imgFilePath); existImgFile= new File(imgFilePath);
if(existImgFile.exists()){
image = Image.getInstance(imgFilePath); existImgFile.delete();
System.out.println("Image Deleted after status *******"+imgFilePath );
childtable.addCell(image);
//code for images deleted
existImgFile = new File(imgFilePath);
if (existImgFile.exists())
{
existImgFile.delete();
System.out.println("Image Deleted after status *******" + imgFilePath);
}
image.scaleAbsolute(320f, 250f);// image width,height
image.setAlignment(5);
table = new PdfPTable(7);
table.setWidthPercentage(50); // Code 2
table.setHorizontalAlignment(Element.ALIGN_CENTER);
Font font = FontFactory.getFont(FontFactory.TIMES_ROMAN, 5);
cell = new PdfPCell(new Paragraph("Month", font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Actual", font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Work Plan", font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Actual/Work Plan", font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Pace(EOM)", font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Pace(EOM)/Work Plan", font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(preyearMonth, font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(0), font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(1), font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(2), font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(3), font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(4), font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(5), font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(6), font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
//2
childtable.addCell(table);
cell = new PdfPCell(childtable);
cell.setBorder(Rectangle.NO_BORDER);
parentTable.addCell(cell);
}
} }
image.scaleAbsolute(320f, 250f);// image width,height
image.setAlignment(5);
table = new PdfPTable(7);
table.setWidthPercentage(50); // Code 2
table.setHorizontalAlignment(Element.ALIGN_CENTER);
Font font= FontFactory.getFont(FontFactory.TIMES_ROMAN, 5);
cell = new PdfPCell(new Paragraph("Month",font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Actual",font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
if (childTblCnt == 1) cell = new PdfPCell(new Paragraph("Work Plan",font));
{ cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell = new PdfPCell(); cell.setBackgroundColor(Color.GREEN);
cell.setBorder(Rectangle.NO_BORDER); table.addCell(cell);
parentTable.addCell(cell);
parentTable.addCell(cell); cell = new PdfPCell(new Paragraph("Actual/Work Plan",font));
} else if (childTblCnt == 2) cell.setHorizontalAlignment(Element.ALIGN_CENTER);
{ cell.setBackgroundColor(Color.GREEN);
cell = new PdfPCell(); table.addCell(cell);
cell.setBorder(Rectangle.NO_BORDER);
parentTable.addCell(cell); cell = new PdfPCell(new Paragraph("Pace(EOM)",font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph("Pace(EOM)/Work Plan",font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(preyearMonth,font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.GREEN);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(0),font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(1),font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(2),font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(3),font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(4),font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(5),font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
cell = new PdfPCell(new Paragraph(gridDataList.get(6),font));
cell.setHorizontalAlignment(Element.ALIGN_CENTER);
cell.setBackgroundColor(Color.YELLOW);
table.addCell(cell);
//2
childtable.addCell(table);
cell = new PdfPCell(childtable);
cell.setBorder(Rectangle.NO_BORDER);
parentTable.addCell(cell);
} }
document.add(parentTable); }
if(childTblCnt==1)
{
cell = new PdfPCell();
cell.setBorder(Rectangle.NO_BORDER);
parentTable.addCell(cell);
parentTable.addCell(cell);
}
else if(childTblCnt==2)
{
cell = new PdfPCell();
cell.setBorder(Rectangle.NO_BORDER);
parentTable.addCell(cell);
} }
document.newPage(); document.add(parentTable);
} }
document.close(); document.close();
file.close(); file.close();
System.out.println("PDF Created succesfully"); System.out.println("PDF Created succesfully");
conn = connDriver.getConnectDB("DriverITM"); conn = connDriver.getConnectDB("DriverITM");
connDriver = null; connDriver =null;
toMailId = ""; toMailId ="";
ccMailId = ""; ccMailId ="";
bccAddress = ""; bccAddress ="";
subject = rptTitle; subject =rptTitle;
userWiseBodytext = "Dear Sir, Please find attached herewith is the Daily Output:" + rptTitle + " Report in PDF format."; userWiseBodytext ="Dear Sir, Please find attached herewith is the Daily Output:"+rptTitle+" Report in PDF format.";
String sql = "select name,user_type,email_id FROM users WHERE code='" + userID + "'"; String sql = "select name,user_type,email_id FROM users WHERE code='"+userID+"'";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next())
{ {
toMailId = checkNull(rs.getString("email_id")); toMailId = checkNull(rs.getString("email_id"));
System.out.println("No of Users =" + userID + "AND According to Email ID=======" + toMailId); System.out.println("No of Users ="+userID +"AND According to Email ID======="+toMailId);
} }
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
conn.close(); conn.close();
conn = null; conn = null;
rs.close(); rs.close();
rs = null; rs = null;
System.out.println("Export Pdf path is ="+pdfFileName);
//toMailId ="sachin.shinde57@gmail.com"; attachFile = new File(pdfFileName);
System.out.println("Export Pdf path is =" + pdfFileName); if(attachFile.exists() && attachFile.length()>0)
attachFile = new File(pdfFileName); {
if (attachFile.exists() && attachFile.length() > 0) mailInfo =new ArrayList<String>();
{ mailInfo.add(toMailId);
mailInfo = new ArrayList<String>(); mailInfo.add(ccMailId);
mailInfo.add(toMailId); mailInfo.add(bccAddress);
mailInfo.add(ccMailId); mailInfo.add(subject);
mailInfo.add(bccAddress); mailInfo.add(userWiseBodytext);
mailInfo.add(subject); mailInfo.add(attachFile.getPath());
mailInfo.add(userWiseBodytext); this.sendingMail(mailInfo);
mailInfo.add(attachFile.getPath()); resultFlage="true";
this.sendingMail(mailInfo); }
resultFlage = "true"; System.out.println("*********** Pdf and send mail done succesfully This is final state*********");
}
System.out.println("*********** Pdf and sending mail done succesfully (Final)**************");
} catch (Exception e) } catch (Exception e)
{ {
System.out.println("Exception :ProductionVsBudgetReport :generatePDF(HashMap<String, List<String>>,String,String,String,String" + e.getMessage()); System.out.println("Exception :ProductionVsBudgetReport :generatePDF(HashMap<String, List<String>>,String,String,String,String"+e.getMessage());
e.printStackTrace(); e.printStackTrace();
} finally }
finally
{ {
try try
{ {
...@@ -895,11 +786,10 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -895,11 +786,10 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
} }
} }
return resultFlage; return resultFlage;
} }
//end method for PDF generate //end method for PDF generate
//start method for sending mail*************** //start method for sending mail***************
public void sendingMail(ArrayList<String> mailInfo) public void sendingMail(ArrayList<String> mailInfo)
{ {
...@@ -911,16 +801,16 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production ...@@ -911,16 +801,16 @@ public class ProductionVsBudgetReport extends ValidatorEJB implements Production
commInfo.append("<CC_ADD>").append("<![CDATA[" + mailInfo.get(1) + "]]>").append("</CC_ADD>"); commInfo.append("<CC_ADD>").append("<![CDATA[" + mailInfo.get(1) + "]]>").append("</CC_ADD>");
commInfo.append("<BCC_ADD>").append("<![CDATA[" + mailInfo.get(2) + "]]>").append("</BCC_ADD>"); commInfo.append("<BCC_ADD>").append("<![CDATA[" + mailInfo.get(2) + "]]>").append("</BCC_ADD>");
commInfo.append("<SUBJECT>").append("<![CDATA[" + mailInfo.get(3) + "]]>").append("</SUBJECT>"); commInfo.append("<SUBJECT>").append("<![CDATA[" + mailInfo.get(3) + "]]>").append("</SUBJECT>");
commInfo.append("<BODY_TEXT>").append("<![CDATA[" + mailInfo.get(4) + "]]>").append("</BODY_TEXT>"); commInfo.append("<BODY_TEXT>").append("<![CDATA[" + mailInfo.get(4) + "]]>").append("</BODY_TEXT>");
commInfo.append("<XML_DATA_FILE_PATH>").append("<![CDATA[" + mailInfo.get(5) + "]]>").append("</XML_DATA_FILE_PATH>"); commInfo.append("<XML_DATA_FILE_PATH>").append("<![CDATA[" + mailInfo.get(5) + "]]>").append("</XML_DATA_FILE_PATH>");
commInfo.append("</MAILINFO>"); commInfo.append("</MAILINFO>");
commInfo.append("</ROOT>"); commInfo.append("</ROOT>");
EMail email = new EMail(); EMail email = new EMail();
try try
{ {
System.out.println(" calling sendMail method()"); System.out.println(" calling sendMail method()");
email.sendMail(commInfo.toString(), "ITM", null); email.sendMail(commInfo.toString(), "ITM", null);
System.out.println(" ********Email send succesfully ***********"); System.out.println(" ********Email send succesfully ***********");
} catch (Exception e) } catch (Exception e)
{ {
e.printStackTrace(); e.printStackTrace();
......
...@@ -15,6 +15,6 @@ public interface ProductionVsBudgetReportLocal extends ValidatorLocal{ ...@@ -15,6 +15,6 @@ public interface ProductionVsBudgetReportLocal extends ValidatorLocal{
public String getGeoLoCodeXmlData() throws RemoteException, ITMException; public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException; public String getUnitFormXmlData() throws RemoteException, ITMException;
public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException; public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException;
public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID,HashMap<String,List<String>> chartNameMap,HashMap<String, String> cntryIdNDescrMap) throws RemoteException, ITMException; public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
} }
...@@ -16,6 +16,6 @@ public interface ProductionVsBudgetReportRemote extends ValidatorRemote ...@@ -16,6 +16,6 @@ public interface ProductionVsBudgetReportRemote extends ValidatorRemote
public String getGeoLoCodeXmlData() throws RemoteException, ITMException; public String getGeoLoCodeXmlData() throws RemoteException, ITMException;
public String getUnitFormXmlData() throws RemoteException, ITMException; public String getUnitFormXmlData() throws RemoteException, ITMException;
public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException; public boolean getRoleValid(String userCode, String roleCode) throws RemoteException, ITMException;
public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID,HashMap<String,List<String>> chartNameMap,HashMap<String, String> cntryIdNDescrMap) throws RemoteException, ITMException; public String generatePDF(HashMap<String, List<String>> hashMap ,String exportPDFPath,String exportImagePath,String preyearMonth,String rptTitle,String userID) throws RemoteException, ITMException;
} }
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