Commit f7b5934d authored by dkasliwal's avatar dkasliwal

Modify WIPStatusEBJ for Add sitecode parameter in EJB,

Add WIPStatusSchedule file in bean package for WIP Dashboard shedule on weekly
Modify HalolMFGReleaseSchedule file for URI Change like clause in SQL


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98529 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 04be5c5d
......@@ -53,8 +53,11 @@ public class HalolMFGReleaseSchedule implements Schedule
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
sendFinalURIList = new ArrayList<String>();
//sql = " select user_id,uri from dashboard_comp where uri like '%ProductionVsBudgetReportExport.jsp%'";
sql = "select user_id,uri from dashboard_comp where uri like '%ExportExample/GwtDashboardPage.html%'";
/*change like clause by Dhanendra on 27-08-15*/
//sql = "select user_id,uri from dashboard_comp where uri like '%ExportExample/GwtDashboardPage.html%'";
sql = "select user_id,uri from dashboard_comp where uri like '%ExportExample/GwtDashboardPage.html?metadataname=halolmfgmonth%'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
......
package ibase.dashboard.mfg.bean;
import ibase.scheduler.utility.interfaces.Schedule;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.awt.Desktop;
import java.net.URI;
public class WIPStatusSchedule implements Schedule
{
public String schedule(HashMap map) throws Exception
{
System.out.println(schedule((String) map.get("PROCESS_NAME")));
return schedule((String) map.get("PROCESS_NAME"));
}
public String schedule(String schedule) throws Exception
{
System.out.println("inside WIPStatusSchedule.........");
this.runSchedule();
return schedule;
}
public String schedulePriority(String arg0) throws Exception
{
return null;
}
private void runSchedule() throws ITMException
{
// Add new code on dated 10/01/2013
String sql = "";
ResultSet rs = null;
Connection conn = null;
PreparedStatement pstmt = null;
ConnDriver connDriver = new ConnDriver();
String userID = "";
String uri = "";
String finalURI = "";
List<String> sendFinalURIList = null;
//add new variable on dated1/02/2013
String os = System.getProperty("os.name").toLowerCase();
String browserPathForLinex = "";
try
{
conn = connDriver.getConnectDB("DriverITM");
connDriver = null;
sendFinalURIList = new ArrayList<String>();
sql = "select user_id,uri from dashboard_comp where uri like '%ExportExample/GwtDashboardPage.html?metadataname=wipstatus%'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
userID = rs.getString("user_id").trim();
uri = rs.getString("uri").trim();
finalURI = CommonConstants.TOMCAT_HOME + uri +"&EMP_MAILCODE="+ userID;
System.out.println("direct uri from dashboard_comp for WIPStatusSchedule =" + uri);
System.out.println("User id is for WIPStatusSchedule =" + userID);
System.out.println("Final url for WIPStatusSchedule including userID+uri =" + finalURI);
sendFinalURIList.add(finalURI.trim());
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
if (os.indexOf("win") >= 0)
{
System.out.println("Start Window Section part execution for WIPStatusSchedule");
if (Desktop.isDesktopSupported())
{
Desktop desktop = Desktop.getDesktop();
for (String resourcePath : sendFinalURIList)
{
try
{
desktop.browse(new URI(resourcePath));
Thread.sleep(90000);
System.out.println("End run on browser through window insde WIPStatusSchedule ");
} catch (Exception e)
{
e.printStackTrace();
}
}
}
System.out.println("End of Window Machine section part execution WIPStatusSchedule");
}
/* Ended Added new code for windows palform */
if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0)
{
browserPathForLinex = "/usr/bin/firefox";
System.out.println("path of firefox inside WIPStatusSchedule"+browserPathForLinex);
for (String resourcePath : sendFinalURIList)
{
callURL(browserPathForLinex, resourcePath); //call synchronized method
}
}
}// end try block
catch (Exception e)
{
e.printStackTrace();
} finally
{
try
{
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
conn = null;
} catch (Exception e)
{
e.printStackTrace();
System.out.println("ibase.dashboard.mfg.bean: WIPStatusSchedule :runSchedule() " + e.getMessage());
}
}
}
synchronized void callURL(String browserPath, String resourcePath)
{
try
{
int second = (int) (System.currentTimeMillis() / 1000) % 60;
System.out.println("View for Time when next URL are comming in WIPStatusSchedule===" + second);
Runtime.getRuntime().exec(new String[]
{ browserPath, resourcePath });
Thread.sleep(90000);
} catch (Exception e)
{
System.out.println("exception in WIPStatusSchedule for callURL " + e.getMessage());
}
}
// This method call for check null
private String checkNull(String input)
{
if (input == null)
{
input = "";
} else
{
input = input.trim();
}
return input;
}
}
package ibase.dashboard.mfg.ejb;
import ibase.dashboard.Report.Utility.DashboardUtility;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.utility.EMail;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.awt.Color;
import java.io.File;
import java.io.FileOutputStream;
import java.io.OutputStream;
......@@ -26,10 +28,10 @@ import org.json.simple.JSONObject;
import com.lowagie.text.Document;
import com.lowagie.text.Element;
import com.lowagie.text.Font;
import com.lowagie.text.FontFactory;
import com.lowagie.text.Image;
import com.lowagie.text.Paragraph;
import com.lowagie.text.Rectangle;
import com.lowagie.text.pdf.PdfPCell;
import com.lowagie.text.pdf.PdfPTable;
import com.lowagie.text.pdf.PdfWriter;
......@@ -43,7 +45,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
// TODO Auto-generated constructor stub
}
@SuppressWarnings("unchecked")
public JSONObject getWIPStatus(String loginId , String city, String dataSourceName) throws RemoteException, ITMException
public JSONObject getWIPStatus(String city, String siteCode, String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataWIPStatusDtlJson = new JSONObject();
JSONObject rowData = null;
......@@ -52,14 +54,19 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
System.out.println(" Inside WIPStatus for getWIPStatus Data Soruc Name ="+dataSourceName);
System.out.println("In getWIPStatus Method loginId :"+loginId+"-------dataSourceName :"+dataSourceName);
System.out.println("In getWIPStatus Method dataSourceName :"+dataSourceName);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
int count = 0;
dashboardUtility = new DashboardUtility();
city = dashboardUtility.getCommaSeparated(city);
siteCode = dashboardUtility.getCommaSeparated(siteCode);
/*sql="SELECT z.assending, Z.city, z.no_of_days_text, z.sub_type, SUM (z.wip) wip, SUM (z.batch_cost) batch_cost " +
"FROM (SELECT a.site_code__mfg AS site_code,s.city, " +
"CASE WHEN TO_CHAR (a.wo_release_date,'YYYY') =TO_CHAR (SYSDATE, 'YYYY') " +
......@@ -110,7 +117,8 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
"GROUP BY z.city,z.no_of_days_text, z.sub_type, z.assending " +
"ORDER BY z.assending "; */
if(city.trim().length()>0 && city!=null && siteCode!=null && siteCode.trim().length()>0)
{
sql=" SELECT assending, city, no_of_days_text, sub_type, wip, batch_cost, CHK_VAL "
+ "FROM ( SELECT z.assending AS assending, Z.city as city, z.no_of_days_text as no_of_days_text, z.sub_type as sub_type, SUM (z.wip) as wip, SUM (z.batch_cost) batch_cost, "
+ "CHK_VAL FROM (SELECT a.site_code__mfg AS site_code, s.city, "
......@@ -119,56 +127,58 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
+ "a.bom_sub_type AS sub_type, COUNT (a.work_order) wip, SUM (a.actual_prod_value) AS batch_cost, "
+ "(CASE WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 15 THEN 1 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 15 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 30 THEN 2 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 30 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 60 THEN 3 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 60 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 120 THEN 4 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 120 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 180 THEN 5 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 180 THEN 6 WHEN TO_CHAR (a.wo_release_date, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') THEN TO_NUMBER ( 6 + ABS ( TO_NUMBER (TO_CHAR (a.wo_release_date, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) as CHK_VAL "
+ "FROM dwh_production a, item b, SITE s "
+ "WHERE a.item_code = b.item_code AND a.site_code__mfg = s.site_code AND s.city IN ('"+city+"') "
+ "WHERE a.item_code = b.item_code AND a.site_code__mfg = s.site_code AND s.city IN ("+city+") AND a.site_code__mfg in("+siteCode+") "
+ "AND (a.item_code >= '00' AND a.item_code <= 'ZZ') AND a.work_order_status = 'R' "
+ "AND b.stk_opt = '2' AND a.bom_sub_type <> 'CLEANING' "
+ "AND a.wo_release_date <= TRUNC (SYSDATE) "
+ "GROUP BY a.site_code__mfg,a.wo_release_date, a.bom_sub_type, s.city ) z "
+ "GROUP BY z.city, z.no_of_days_text, z.sub_type, z.assending, CHK_VAL ORDER BY z.assending, z.no_of_days_text, z.sub_type ) "
+ "ORDER BY CHK_VAL ASC";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int wipValue=0;
String noOfDay="",subType="";
List<String> noOfDayList= new ArrayList<String>();
List<String> subTypeList= new ArrayList<String>();
String key="";
LinkedHashMap<String, Integer> graphDataMap = new LinkedHashMap<String, Integer>();
LinkedHashMap<String, Integer> sortedGraphDataMap = new LinkedHashMap<String, Integer>();
while (rs.next())
{
wipValue=0;
wipValue = rs.getInt("WIP");
noOfDay = rs.getString("NO_OF_DAYS_TEXT");
subType= rs.getString("SUB_TYPE");
if(!noOfDayList.contains(noOfDay))
{
noOfDayList.add(noOfDay);
}
if(!subTypeList.contains(subType))
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
int wipValue=0;
String noOfDay="",subType="";
List<String> noOfDayList= new ArrayList<String>();
List<String> subTypeList= new ArrayList<String>();
String key="";
LinkedHashMap<String, Integer> graphDataMap = new LinkedHashMap<String, Integer>();
LinkedHashMap<String, Integer> sortedGraphDataMap = new LinkedHashMap<String, Integer>();
while (rs.next())
{
subTypeList.add(subType);
wipValue=0;
wipValue = rs.getInt("WIP");
noOfDay = rs.getString("NO_OF_DAYS_TEXT");
subType= rs.getString("SUB_TYPE");
if(!noOfDayList.contains(noOfDay))
{
noOfDayList.add(noOfDay);
}
if(!subTypeList.contains(subType))
{
subTypeList.add(subType);
}
key = (noOfDay.trim()+"@"+subType.trim());
if(graphDataMap.size()==0)
{
graphDataMap.put(key, wipValue);
}
if(graphDataMap !=null && graphDataMap.size()>0)
{
if(graphDataMap.containsKey(key))
{
//wipValue = wipValue + graphDataMap.get(key);
wipValue = graphDataMap.get(key);
}
else if(! graphDataMap.containsKey(key))
{
wipValue = wipValue;
}
graphDataMap.put(key, wipValue);
}
}
key = (noOfDay.trim()+"@"+subType.trim());
if(graphDataMap.size()==0)
{
graphDataMap.put(key, wipValue);
}
if(graphDataMap !=null && graphDataMap.size()>0)
{
if(graphDataMap.containsKey(key))
{
//wipValue = wipValue + graphDataMap.get(key);
wipValue = graphDataMap.get(key);
}
else if(! graphDataMap.containsKey(key))
{
wipValue = wipValue;
}
graphDataMap.put(key, wipValue);
}
}
System.out.println("graphDataMap: "+graphDataMap);
String sbType="";
String grpKey="";
......@@ -241,9 +251,67 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
}
prvsubType1=subType1;
}
}
System.out.println("rawDataWIPStatusDtlJson :"+rawDataWIPStatusDtlJson);
/*Document document = new Document();
String subtype = "";
PdfWriter.getInstance(document,new FileOutputStream("HelloWorld-Table.pdf"));
JSONObject fetchRowWiseValJsn = null;
document.open();
PdfPTable table = null; // 3 columns.
PdfPCell cell1 = null;
PdfPCell cell2 = null;
for (int jsnCnt = 0; jsnCnt < rawDataWIPStatusDtlJson.size(); jsnCnt++)
{
catValues = new LinkedHashMap<String, Integer>();
fetchRowWiseValJsn = new JSONObject();
fetchRowWiseValJsn = (JSONObject) rawDataWIPStatusDtlJson.get(jsnCnt);
subtype = ""+fetchRowWiseValJsn.get("product_category");
System.out.println("subtype :"+subtype);
catValues = (LinkedHashMap<String, Integer>) fetchRowWiseValJsn.get("category_value");
System.out.println("catValues :"+catValues);
System.out.println("catValues.size() :"+catValues.size());
if(jsnCnt == 0)
{
table = new PdfPTable(catValues.size()+1);
cell1 = new PdfPCell(new Paragraph("OPEN SINCE", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new Color(255,255,255))));
cell1.setBackgroundColor(Color.gray);
table.addCell(cell1);
for (Map.Entry<String, Integer> entry : catValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph(entry.getKey(), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new Color(255,255,255))));
cell2.setBackgroundColor(Color.gray);
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
}
table.setWidthPercentage(100);
document.add(table);
}
table = new PdfPTable(catValues.size()+1);
cell1 = new PdfPCell(new Paragraph(subtype, FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)));
table.addCell(cell1);
for (Map.Entry<String, Integer> entry : catValues.entrySet())
{
int val = entry.getValue();
cell2 = new PdfPCell(new Paragraph(""+val, FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
}
table.setWidthPercentage(100);
document.add(table);
}
document.close();
System.out.println("PDF Create Successfully");*/
}
catch (Exception e)
{
......@@ -278,7 +346,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
}
@SuppressWarnings("unchecked")
public JSONObject getWIPStatusGrid(String loginId , String city,String dataSourceName) throws RemoteException, ITMException
public JSONObject getWIPStatusGrid(String city, String siteCode, String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataWIPStatusGridDtlJson = new JSONObject();
JSONObject rowData = null;
......@@ -287,14 +355,17 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
System.out.println(" Inside WIPStatus for getWIPStatusGrid Data Soruc Name ="+dataSourceName);
System.out.println("In getWIPStatusGrid Method loginId :"+loginId+"-------dataSourceName :"+dataSourceName);
System.out.println("In getWIPStatusGrid Method dataSourceName :"+dataSourceName);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
int count = 0;
dashboardUtility = new DashboardUtility();
city = dashboardUtility.getCommaSeparated(city);
siteCode = dashboardUtility.getCommaSeparated(siteCode);
/*sql="SELECT z.assending, Z.city, z.no_of_days_text, z.sub_type, SUM (z.wip) wip, SUM (z.batch_cost) batch_cost " +
"FROM (SELECT a.site_code__mfg AS site_code,s.city, " +
......@@ -345,8 +416,9 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
"WHEN TO_CHAR (a.wo_release_date, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') THEN TO_CHAR ( 6 + ABS ( TO_NUMBER (TO_CHAR (a.wo_release_date, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) END, a.bom_sub_type,s.city) z " +
"GROUP BY z.city,z.no_of_days_text, z.sub_type, z.assending " +
"ORDER BY z.assending, z.no_of_days_text, z.sub_type ";*/
sql=" SELECT assending, city, no_of_days_text, sub_type, wip, batch_cost, CHK_VAL "
if(city.trim().length()>0 && city!=null && siteCode!=null && siteCode.trim().length()>0)
{
sql=" SELECT assending, city, no_of_days_text, sub_type, wip, batch_cost, CHK_VAL "
+ "FROM ( SELECT z.assending AS assending, Z.city as city, z.no_of_days_text as no_of_days_text, z.sub_type as sub_type, SUM (z.wip) as wip, SUM (z.batch_cost) batch_cost, "
+ "CHK_VAL FROM (SELECT a.site_code__mfg AS site_code, s.city, "
+ "CASE WHEN TO_CHAR (a.wo_release_date,'YYYY') =TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 15 THEN '<15 days' WHEN TO_CHAR (a.wo_release_date, 'YYYY') =TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 15 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 30 THEN '>15-30 days' WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 30 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 60 THEN '>30-60 days' WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 60 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 120 THEN '>60-120 days' WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 120 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 180 THEN '>120-180 days' WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 180 THEN '>180 days' WHEN TO_CHAR (a.wo_release_date, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') THEN TO_CHAR (a.wo_release_date, 'YYYY') END no_of_days_text, "
......@@ -354,7 +426,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
+ "a.bom_sub_type AS sub_type, COUNT (a.work_order) wip, SUM (a.actual_prod_value) AS batch_cost, "
+ "(CASE WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 15 THEN 1 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 15 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 30 THEN 2 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 30 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 60 THEN 3 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 60 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 120 THEN 4 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 120 AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) < 180 THEN 5 WHEN TO_CHAR (a.wo_release_date, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - a.wo_release_date) >= 180 THEN 6 WHEN TO_CHAR (a.wo_release_date, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') THEN TO_NUMBER ( 6 + ABS ( TO_NUMBER (TO_CHAR (a.wo_release_date, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) as CHK_VAL "
+ "FROM dwh_production a, item b, SITE s "
+ "WHERE a.item_code = b.item_code AND a.site_code__mfg = s.site_code AND s.city IN ('"+city+"') "
+ "WHERE a.item_code = b.item_code AND a.site_code__mfg = s.site_code AND s.city IN ("+city+") AND a.site_code__mfg in("+siteCode+") "
+ "AND (a.item_code >= '00' AND a.item_code <= 'ZZ') AND a.work_order_status = 'R' "
+ "AND b.stk_opt = '2' AND a.bom_sub_type <> 'CLEANING' "
+ "AND a.wo_release_date <= TRUNC (SYSDATE) "
......@@ -362,22 +434,22 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
+ "GROUP BY z.city, z.no_of_days_text, z.sub_type, z.assending, CHK_VAL ORDER BY z.assending, z.no_of_days_text, z.sub_type ) "
+ "ORDER BY CHK_VAL ASC";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
rowData = new JSONObject();
rowData.put("no_of_days_text", rs.getString("NO_OF_DAYS_TEXT"));
rowData.put("sub_type", rs.getString("SUB_TYPE"));
rowData.put("wip", rs.getString("WIP"));
rowData.put("batch_cost", rs.getString("BATCH_COST"));
rowData.put("city", rs.getString("CITY"));
rawDataWIPStatusGridDtlJson.put(count, rowData);
count++;
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
rowData = new JSONObject();
rowData.put("no_of_days_text", rs.getString("NO_OF_DAYS_TEXT"));
rowData.put("sub_type", rs.getString("SUB_TYPE"));
rowData.put("wip", rs.getString("WIP"));
rowData.put("batch_cost", rs.getString("BATCH_COST"));
rowData.put("city", rs.getString("CITY"));
rawDataWIPStatusGridDtlJson.put(count, rowData);
count++;
}
}
System.out.println("rawDataWIPStatusDtlJson :"+rawDataWIPStatusGridDtlJson);
}
......@@ -413,7 +485,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
}
@SuppressWarnings("unchecked")
public JSONObject getWIPStatusLinkGrid(String loginId, String city,String period,String catagory,String dataSourceName) throws RemoteException, ITMException
public JSONObject getWIPStatusLinkGrid(String city, String siteCode, String period,String catagory,String dataSourceName) throws RemoteException, ITMException
{
JSONObject rawDataWIPStatusLinkGridDtlJson = new JSONObject();
JSONObject rowData = null;
......@@ -422,10 +494,16 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
System.out.println(" Inside WIPStatus for getWIPStatusLinkGrid Data Soruc Name ="+dataSourceName);
System.out.println("In getWIPStatusLinkGrid Method period :"+period+"-------dataSourceName :"+dataSourceName);
dashboardUtility = new DashboardUtility();
city = dashboardUtility.getCommaSeparated(city);
siteCode = dashboardUtility.getCommaSeparated(siteCode);
System.out.println(" Inside WIPStatus for getWIPStatusLinkGrid siteCode ="+siteCode+"===city :"+city);
System.out.println("In getWIPStatusLinkGrid Method period :"+period+"-------catagory :"+catagory+ "-------dataSourceName :"+dataSourceName);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
int count = 0;
......@@ -482,7 +560,8 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
" FROM dwh_production a, item b,SITE s "+
" WHERE a.item_code = b.item_code "+
" AND a.site_code__mfg = s.site_code "+
" AND s.city in ('"+city+"') " +
" AND s.city in ("+city+") " +
" AND a.site_code__mfg in( "+siteCode+") "+
" AND (a.item_code >= '00' AND a.item_code <= 'ZZ') "+
" AND a.work_order_status = 'R' "+
" AND b.stk_opt = '2' "+
......@@ -512,7 +591,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
rowData.put("status", rs.getString("STATUS"));
rowData.put("std_yield_perc", rs.getString("STD_YIELD_PERC"));
rowData.put("actual_yield", rs.getString("ACTUAL_YIELD"));
rowData.put("batch_cost", checkNull(rs.getString("BATCH_COST")));
rowData.put("batch_cost", rs.getString("BATCH_COST"));
rawDataWIPStatusLinkGridDtlJson.put(count, rowData);
......@@ -553,8 +632,9 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
return rawDataWIPStatusLinkGridDtlJson;
}
/*Start- this method add for generatePDF on 6Apr2015*/
public String getPDFByScheduler(String rptTitle, String remark, String userID, String imgName) throws RemoteException, ITMException
/*Start- this method add for generatePDF on 13Aug2015*/
@SuppressWarnings("unchecked")
public String getPDFByScheduler(String rptTitle, String remark, String userID, String imgName, String city, String siteCode, String dataSourceName) throws RemoteException, ITMException
{
System.out.println("In WIPStatus EJB.getPDFByScheduler Method ");
PdfWriter writer = null;
......@@ -586,17 +666,31 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
int prntTblNo =1;
PdfPTable parentTable=null;
Paragraph preface = null;
PdfPTable table = null;
PdfPCell cell1 = null;
PdfPCell cell2 = null;
String subtype = "";
JSONObject fetchRowWiseValJsn = null;
LinkedHashMap<String, Integer> catValues = null;
JSONObject rowDataforGrid = null;
System.out.print("Calling for PDF created step1");
try
{
System.out.println("In WIPStatus getPDFByScheduler city :"+city+"----siteCode :"+siteCode+"-----dataSourceName :"+dataSourceName);
rowDataforGrid = this.getWIPStatus(city, siteCode, dataSourceName);
System.out.println("rowDataforGrid in getPDFByScheduler :"+rowDataforGrid);
//START CODE FOR WINDOWS
//exportPDFPath ="C://jboss-5.1.0.GA//server//default//deploy//ibase.ear//ibase.war//dashboard//mfg//Scheduler//ExportExample//ExportPDF//";
//exportImagePath ="C://jboss-5.1.0.GA//server//default//deploy//ibase.ear//ibase.war//dashboard//mfg//Scheduler//ExportExample//ExportImages//";
//END CODE FOR WINDOWS
//START CODE FOR LINUX
// exportPDFPath = CommonConstants.APPLICATION_CONTEXT + "dashboard" + File.separator + "mfg"+ File.separator + "Scheduler"+File.separator +"ExportExample"+ File.separator + "ExportPDF"+File.separator;
//exportPDFPath = CommonConstants.APPLICATION_CONTEXT + "dashboard" + File.separator + "mfg"+ File.separator + "Scheduler"+File.separator +"ExportExample"+ File.separator + "ExportPDF"+File.separator;
exportPDFPath = CommonConstants.JBOSSHOME + File.separator +"server"+File.separator +"default"+File.separator +"deploy"+File.separator +"ibase.ear"+File.separator + "ibase.war" +File.separator + "dashboard" + File.separator + "mfg"+ File.separator + "Scheduler"+File.separator +"ExportExample"+ File.separator + "ExportPDF"+File.separator;
exportImagePath = CommonConstants.JBOSSHOME + File.separator +"server"+File.separator +"default"+File.separator +"deploy"+File.separator +"ibase.ear"+File.separator + "ibase.war" +File.separator + "dashboard" + File.separator + "mfg"+ File.separator + "Scheduler"+File.separator +"ExportExample"+ File.separator + "ExportImages"+File.separator;
//END CODE FOR LINUX
......@@ -605,9 +699,13 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
calendar = Calendar.getInstance();
currDate = simpleDateFormat.format(calendar.getTime());
document = new Document();
rptTitle = rptTitle+"-"+currDate;
pdfFileName = exportPDFPath+rptTitle+"-"+userID+".pdf";
//rptTitle = rptTitle+"-"+currDate;
rptTitle = rptTitle+" ("+siteCode+")"+" Plant Open Work Order Status as on " +currDate;
System.out.println("rptTitle in WIPStatus getPDFByScheduler :"+rptTitle);
pdfFileName = exportPDFPath+rptTitle+".pdf";
System.out.println("modify PDF file name "+ pdfFileName+"current date formate==="+currDate);
file = new FileOutputStream(new File(pdfFileName));
writer = PdfWriter.getInstance(document, file);
document.open();
......@@ -642,7 +740,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
}
document.add(parentTable);
preface = new Paragraph();
preface.add(new Paragraph(" "));
/*preface.add(new Paragraph(" "));*/
document.add(preface);
if(size==0)
{
......@@ -650,8 +748,50 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
preface.add(new Paragraph("Remark: "+remark, FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)));
preface.add(new Paragraph(" "));
document.add(preface);
}
}
}
preface.add(new Paragraph(" "));
for (int jsnCnt = 0; jsnCnt < rowDataforGrid.size(); jsnCnt++)
{
catValues = new LinkedHashMap<String, Integer>();
fetchRowWiseValJsn = new JSONObject();
fetchRowWiseValJsn = (JSONObject) rowDataforGrid.get(jsnCnt);
subtype = ""+fetchRowWiseValJsn.get("product_category");
System.out.println("subtype :"+subtype);
catValues = (LinkedHashMap<String, Integer>) fetchRowWiseValJsn.get("category_value");
System.out.println("catValues :"+catValues);
if(jsnCnt == 0)
{
table = new PdfPTable(catValues.size()+1);
cell1 = new PdfPCell(new Paragraph("OPEN SINCE", FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new Color(255,255,255))));
cell1.setBackgroundColor(Color.gray);
table.addCell(cell1);
for (Map.Entry<String, Integer> entry : catValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph(entry.getKey(), FontFactory.getFont(FontFactory.TIMES_ROMAN, 8, Font.BOLD, new Color(255,255,255))));
cell2.setBackgroundColor(Color.gray);
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
}
table.setWidthPercentage(100);
document.add(table);
}
table = new PdfPTable(catValues.size()+1);
cell1 = new PdfPCell(new Paragraph(subtype, FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)));
table.addCell(cell1);
for (Map.Entry<String, Integer> entry : catValues.entrySet())
{
int val = entry.getValue();
cell2 = new PdfPCell(new Paragraph(""+val, FontFactory.getFont(FontFactory.TIMES_ROMAN, 8)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
}
table.setWidthPercentage(100);
document.add(table);
}
document.close();
file.close();
......@@ -663,23 +803,32 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
ccMailId ="";
bccAddress ="";
subject =rptTitle;
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+"'";
userWiseBodytext ="Dear Sir, Please find attached herewith is the Weekly Output:"+rptTitle+" Report in PDF format.";
/*String sql = "select name,user_type,email_id FROM users WHERE code='"+userID+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
toMailId = checkNull(rs.getString("email_id"));
System.out.println("No of Users for WIPStatus.getPDFByScheduler ="+userID +"AND According to the Email ID======="+toMailId);
}*/
city = "WIP_"+city.trim();
System.out.println("Add WIP in city :" +city);
String sql = "SELECT SEND_TO, COPY_TO, BLIND_COPY FROM MAIL_FORMAT WHERE FORMAT_CODE = '"+city+"'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next())
{
toMailId = checkNull(rs.getString("SEND_TO").trim());
ccMailId = checkNull(rs.getString("COPY_TO").trim());
bccAddress = checkNull(rs.getString("BLIND_COPY").trim());
System.out.println("No of Users for WIPStatus.getPDFByScheduler city = "+city+" --- toMailId ="+toMailId +"AND According to the ccMailId ======="+ccMailId+"---- bccAddress == "+bccAddress);
}
pstmt.close();
pstmt = null;
conn.close();
conn = null;
rs.close();
rs = null;
System.out.println("Export Pdf path for WIPStatus.getPDFByScheduler ="+pdfFileName);
attachFile = new File(pdfFileName);
if(attachFile.exists() && attachFile.length()>0)
......@@ -704,15 +853,23 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
{
try
{
if (pstmt != null)
if (conn != null)
{
if (rs != null)
rs.close();
rs = null;
if (pstmt != null)
pstmt.close();
pstmt = null;
conn.close();
conn = null;
}
} catch (Exception e)
conn = null;
} catch (Exception d)
{
e.printStackTrace();
d.printStackTrace();
System.out.println("Exception in WIPStatusEJB.getPDFByScheduler" + d.getMessage());
throw new ITMException(d);
}
}
return resultFlage;
......@@ -746,7 +903,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
}
email = null;
}
/*End- this method add for generatePDF on 6Apr2015*/
/*End- this method add for generatePDF on 13Aug2015*/
private String checkNull(String str)
{
if(str == null)
......
......@@ -11,8 +11,10 @@ import org.json.simple.JSONObject;
@Local
public interface WIPStatusLocal extends ValidatorLocal
{
public JSONObject getWIPStatus(String loginId ,String city, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusGrid(String loginId ,String city, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusLinkGrid(String loginId ,String city,String days,String category,String dataSourceName) throws RemoteException, ITMException;
public String getPDFByScheduler(String rptTitle,String remark,String userID, String imgName) throws RemoteException, ITMException;
/*Add new siteCode Parameter by Dhanendra on Date 27-08-15 */
public JSONObject getWIPStatus(String city, String siteCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusGrid(String city, String siteCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusLinkGrid(String city, String siteCode, String days,String category,String dataSourceName) throws RemoteException, ITMException;
public String getPDFByScheduler(String rptTitle,String remark,String userID, String imgName, String city, String siteCode, String dataSourceName) throws RemoteException, ITMException;
}
......@@ -12,9 +12,11 @@ import org.json.simple.JSONObject;
@Remote
public interface WIPStatusRemote extends ValidatorRemote
{
public JSONObject getWIPStatus(String loginId ,String city, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusGrid(String loginId ,String city, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusLinkGrid(String loginId ,String city,String days,String category,String dataSourceName) throws RemoteException, ITMException;
public String getPDFByScheduler(String rptTitle,String remark,String userID, String imgName) throws RemoteException, ITMException;
/*Add new siteCode Parameter by Dhanendra on Date 27-08-15 */
public JSONObject getWIPStatus(String city, String siteCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusGrid(String city, String siteCode, String dataSourceName) throws RemoteException, ITMException;
public JSONObject getWIPStatusLinkGrid(String city, String siteCode, String days,String category,String dataSourceName) throws RemoteException, ITMException;
public String getPDFByScheduler(String rptTitle,String remark,String userID, String imgName, String city, String siteCode, String dataSourceName) throws RemoteException, ITMException;
}
......@@ -10,6 +10,7 @@ import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
@SuppressWarnings("serial")
public class WIPStatusExportPDFServlet extends HttpServlet
......@@ -35,6 +36,17 @@ public class WIPStatusExportPDFServlet extends HttpServlet
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
String sessionCity = (String) session.getAttribute("city");
String sessionSiteCode = (String) session.getAttribute("siteCode");
String sessionDataSrcName = (String) session.getAttribute("dataSourceName");
System.out.println("sessionCity :"+sessionCity+"=======sessionSiteCode :"+sessionSiteCode);
System.out.println("sessionDataSrcName :"+sessionDataSrcName);
session.invalidate();
userID = request.getParameter("userID");
rptTitle = request.getParameter("rptTitle");
remark = request.getParameter("remark");
......@@ -43,7 +55,7 @@ public class WIPStatusExportPDFServlet extends HttpServlet
// call EJB method for PDF creation*******************
context = new InitialContext(appConnectParm.getProperty());
wipStatusRemote = (WIPStatusRemote) context.lookup("ibase/WIPStatus/remote");
resultString = wipStatusRemote.getPDFByScheduler(rptTitle,remark,userID,imgName);
resultString = wipStatusRemote.getPDFByScheduler(rptTitle,remark,userID,imgName,sessionCity,sessionSiteCode,sessionDataSrcName);
response.setContentType("text/html");
if(resultString.equals("false"))
{
......
......@@ -31,11 +31,11 @@ public class WIPStatusGridLinkServlet extends HttpServlet
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String loginId = "";
String month = "";
String city = "";
String category = "";
String siteCode = "";
try
{
response.setContentType("application/xml");
......@@ -47,13 +47,15 @@ public class WIPStatusGridLinkServlet extends HttpServlet
month = request.getParameter("month");
city = request.getParameter("city");
category = request.getParameter("category");
siteCode = request.getParameter("siteCode");
System.out.println("WIPStatusGridLinkServlet siteCode :"+siteCode);
System.out.println("category :"+category);
System.out.println("month :"+month+"---city :"+city+"----category :"+category);
dataSourceName = request.getParameter("dataSourceName");
context = new InitialContext(appConnectParm.getProperty());
wipStatusRemote = (WIPStatusRemote) context.lookup("ibase/WIPStatus/remote");
JSONObject jsonObjData = (JSONObject)wipStatusRemote.getWIPStatusLinkGrid(loginId,city,month,category,dataSourceName);
JSONObject jsonObjData = (JSONObject)wipStatusRemote.getWIPStatusLinkGrid(city,siteCode,month,category,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
......
......@@ -31,9 +31,8 @@ public class WIPStatusGridServlet extends HttpServlet
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String loginId = "";
String city = "";
String siteCode = "";
try
{
response.setContentType("application/xml");
......@@ -42,11 +41,12 @@ public class WIPStatusGridServlet extends HttpServlet
ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
loginId = userInfo.getLoginCode();*/
city = request.getParameter("city");
System.out.println("in WIPStatusGridServlet city :"+city);
siteCode = request.getParameter("siteCode");
System.out.println("in WIPStatusGridServlet city :"+city+"====siteCode :"+siteCode);
dataSourceName = request.getParameter("dataSourceName");
context = new InitialContext(appConnectParm.getProperty());
wipStatusRemote = (WIPStatusRemote) context.lookup("ibase/WIPStatus/remote");
JSONObject jsonObjData = (JSONObject)wipStatusRemote.getWIPStatusGrid(loginId,city,dataSourceName);
JSONObject jsonObjData = (JSONObject)wipStatusRemote.getWIPStatusGrid(city, siteCode, dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
......
......@@ -31,21 +31,24 @@ public class WIPStatusServlet extends HttpServlet
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String loginId = "";
String city = "";
String siteCode = "";
try
{
response.setContentType("application/xml");
/*HttpSession session = request.getSession(true);
ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
loginId = userInfo.getLoginCode();*/
city = request.getParameter("city");
HttpSession session = request.getSession(true);
city = request.getParameter("city");
siteCode = request.getParameter("siteCode");
dataSourceName = request.getParameter("dataSourceName");
System.out.println("in WIPStatusServlet city :"+city);
dataSourceName = request.getParameter("dataSourceName");
session.setAttribute("city", city);
session.setAttribute("siteCode", siteCode);
session.setAttribute("dataSourceName", dataSourceName);
context = new InitialContext(appConnectParm.getProperty());
wipStatusRemote = (WIPStatusRemote) context.lookup("ibase/WIPStatus/remote");
JSONObject jsonObjData = (JSONObject)wipStatusRemote.getWIPStatus(loginId,city,dataSourceName);
JSONObject jsonObjData = (JSONObject)wipStatusRemote.getWIPStatus(city, siteCode, dataSourceName);
//String jsonObjData = "{'0':{'month':0,'product_catagory':'F','product_value':{'2013':'6','2014':'6'}},'1':{'month':1,'product_catagory':'FRESH','product_value':{'2014':'13','<15 days':'9','>120-180 days':'1','>180 days':'1','>30-60 days':'4','>60-120 days':'5'}}}";
OutputStream outputStream = response.getOutputStream();
//outputStream.write(jsonObjData.toString().replace('\'', '"').getBytes());
......
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