Commit 7eaa70ff authored by dkasliwal's avatar dkasliwal

Change SQL in WIPStatus, PendingQCPurchase, PendingQCWorkOrder EJB, for Graph, Grid Excel

Add Code Graph and Grid, Excel PDF for Manual QC Order In PendingQC Purchase EJB,
schedule mail with 3 file attached in PendingQCPurchase and 2 file with PendingQCWorkOrder.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@98672 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 295a3f52
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 PendingQCPurchaseSchedule 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 PendingQCPurchaseSchedule.........");
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=pendingqcpurchase%'";
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 PendingQCPurchaseSchedule =" + uri);
System.out.println("User id is for PendingQCPurchaseSchedule =" + userID);
System.out.println("Final url for PendingQCPurchaseSchedule 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 PendingQCPurchaseSchedule");
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 PendingQCPurchaseSchedule ");
} catch (Exception e)
{
e.printStackTrace();
}
}
}
System.out.println("End of Window Machine section part execution PendingQCPurchaseSchedule");
}
/* 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 PendingQCPurchaseSchedule"+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: PendingQCPurchaseSchedule :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 PendingQCPurchaseSchedule===" + second);
Runtime.getRuntime().exec(new String[]
{ browserPath, resourcePath });
Thread.sleep(90000);
} catch (Exception e)
{
System.out.println("exception in PendingQCPurchaseSchedule 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.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 PendingQCReceiptSchedule 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 PendingQCReceiptSchedule.........");
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=pendingqcreceipt%'";
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 PendingQCReceiptSchedule =" + uri);
System.out.println("User id is for PendingQCReceiptSchedule =" + userID);
System.out.println("Final url for PendingQCReceiptSchedule 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 PendingQCReceiptSchedule");
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 PendingQCReceiptSchedule ");
} catch (Exception e)
{
e.printStackTrace();
}
}
}
System.out.println("End of Window Machine section part execution PendingQCReceiptSchedule");
}
/* 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 PendingQCReceiptSchedule"+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: PendingQCReceiptSchedule :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 PendingQCReceiptSchedule===" + second);
Runtime.getRuntime().exec(new String[]
{ browserPath, resourcePath });
Thread.sleep(90000);
} catch (Exception e)
{
System.out.println("exception in PendingQCReceiptSchedule 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;
}
}
......@@ -14,16 +14,24 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.json.simple.JSONObject;
import com.lowagie.text.Document;
......@@ -67,10 +75,11 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
dashboardUtility = new DashboardUtility();
siteCode = dashboardUtility.getCommaSeparated(siteCode);
geoLocation = dashboardUtility.getCommaSeparated(geoLocation);
System.out.println("geoLocation :"+geoLocation);
if(geoLocation.trim().length()>0 && geoLocation!=null && siteCode!=null && siteCode.trim().length()>0)
{
sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,GIM_VALUE_In_Rs" +
/* sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,GIM_VALUE_In_Rs" +
" FROM (SELECT z.no_of_days AS no_of_days, z.ITEM_SER AS ITEM_SER," +
" SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, z.CHK_VAL AS CHK_VAL, " +
" sum(z.amt) as GIM_VALUE_IN_RS FROM (SELECT CASE " +
......@@ -104,7 +113,46 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
" A.CONFIRMED='Y' AND G.STATUS='U' AND A.TRAN_ID=B.TRAN_ID " +
" AND B.ITEM_CODE=C.ITEM_CODE AND A.SUPP_CODE=D.SUPP_CODE AND G.LOT_NO=B.LOT_NO " +
" AND g.PORCP_NO=A.TRAN_ID AND G.ITEM_CODE=B.ITEM_CODE GROUP BY A.item_ser,A.TRAN_DATE) z GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC ";
*/
sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL, " +
" ROUND((GIM_VALUE)/100000,3) As GIM_VALUE " +
" FROM ( SELECT z.no_of_days AS no_of_days, " +
" z.ITEM_SER AS ITEM_SER, SUM(z.NO_OF_OPEN_QCORDER) " +
" AS NO_OF_OPEN_QCORDER, z.CHK_VAL AS CHK_VAL, sum(z.amt) as GIM_VALUE " +
" FROM (SELECT CASE WHEN TO_CHAR(A.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>=0 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)<90 " +
" THEN '>0-90 days' WHEN TO_CHAR(a.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)<180 " +
" THEN '>90-180 days' WHEN TO_CHAR(a.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>=180 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)<365 " +
" THEN '>180-365 days' WHEN TO_CHAR(a.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>365 THEN '>365 days' " +
" WHEN TO_CHAR(a.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
" THEN TO_CHAR(a.TRAN_DATE,'YYYY') END no_of_days, A.ITEM_SER,COUNT(DISTINCT(G.QORDER_NO)) " +
" AS NO_OF_OPEN_QCORDER, (CASE WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 0 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) < 90 " +
" THEN 1 WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 90 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) < 180 " +
" THEN 2 WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 180 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) < 365 " +
" THEN 3 WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 365 THEN 4 " +
" WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
" THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (a.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
" AS CHK_VAL, sum(b.quantity*b.rate*A.EXCH_RATE) as amt " +
" FROM PORCP A,PORCPDET B,ITEM C,SUPPLIER D,QC_ORDER G,SITE H " +
" WHERE " +
" A.SITE_CODE IN ("+siteCode+") " +
" AND A.ITEM_SER IN ('RM1','BD','PM1','BDI') " +
" AND " +
" A.CONFIRMED='Y' AND G.STATUS='U' AND G.QC_CREATE_TYPE='A' AND A.TRAN_ID=B.TRAN_ID AND B.ITEM_CODE=C.ITEM_CODE " +
" AND A.SUPP_CODE=D.SUPP_CODE AND G.LOT_NO=B.LOT_NO AND g.PORCP_NO=A.TRAN_ID " +
" AND G.ITEM_CODE=B.ITEM_CODE AND A.SITE_CODE=H.SITE_CODE " +
" AND H.CITY in("+geoLocation+") " +
" GROUP BY A.item_ser,A.TRAN_DATE) z GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL " +
" ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String noOfOpenQCOrderVal="";
......@@ -117,10 +165,12 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
LinkedHashMap<String, String> sortedGraphDataMap = new LinkedHashMap<String, String>();
while (rs.next())
{
noOfOpenQCOrderVal = rs.getString("NO_OF_OPEN_QCORDER");
noOfDay = rs.getString("NO_OF_DAYS");
subType= rs.getString("ITEM_SER");
gimValue=rs.getString("GIM_VALUE_IN_RS");
gimValue= rs.getString("GIM_VALUE");
if(!noOfDayList.contains(noOfDay))
{
noOfDayList.add(noOfDay);
......@@ -184,12 +234,12 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
cnt++;
String mapKey = entry.getKey();
String value = entry.getValue();// need to split
String[] temp;
String[] temp = null;
temp = mapKey.split("@");
noDays = temp[0].trim();
subType1 = temp[1].trim();
String[] qcOrdArr;
String[] qcOrdArr = null;
qcOrdArr = value.split("-");
qcOrd = qcOrdArr[0].trim();
......@@ -208,7 +258,7 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
catValues.put(noDays,qcOrd);
catGimValues.put(noDays,value);
}
if(!("").equals(prvsubType1) && ! prvsubType1.equals(subType1))
else if(!("").equals(prvsubType1) && ! prvsubType1.equals(subType1))
{
rowData.put("month",cnt);
rowData.put("product_category",prvsubType1);
......@@ -224,21 +274,61 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
}
if(cnt==sortedGraphDataMap.size())
{
rowData.put("month",cnt);
rowData.put("product_category",prvsubType1);
rowData.put("month",++cnt);
rowData.put("product_category",subType1);
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catGimValues);
rowDataPendingQCOrderPurc.put(count, rowData);
}
prvsubType1=subType1;
}
if(rowDataPendingQCOrderPurc.isEmpty())
{
System.out.println("**** rowDataPendingQCOrderPurc is Empty **** ");
catValues.put(">0-90 days", "0");
catValues.put(">90-180 days", "0");
catValues.put(">180-365 days", "0");
catGimValues.put(">0-90 days", "0-0");
catGimValues.put(">90-180 days", "0-0");
catGimValues.put(">180-365 days", "0-0");
rowData = new JSONObject();
rowData.put("month",cnt);
rowData.put("product_category","RM1");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catGimValues);
rowDataPendingQCOrderPurc.put(count, rowData);
rowData = new JSONObject();
rowData.put("month",++cnt);
rowData.put("product_category","BD");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catGimValues);
rowDataPendingQCOrderPurc.put(++count, rowData);
rowData = new JSONObject();
rowData.put("month",++cnt);
rowData.put("product_category","PM1");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catGimValues);
rowDataPendingQCOrderPurc.put(++count, rowData);
rowData = new JSONObject();
rowData.put("month",++cnt);
rowData.put("product_category","BDI");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catGimValues);
rowDataPendingQCOrderPurc.put(++count, rowData);
}
}
System.out.println("rowDataPendingQCOrderPurc :"+rowDataPendingQCOrderPurc);
/*Code for PDF*/
/*Document document = new Document();
String subtype = "";
PdfWriter.getInstance(document,new FileOutputStream("/home/base/Desktop/HelloWorld-Table.pdf"));
PdfWriter.getInstance(document,new FileOutputStream("/home/support-1/Desktop/HelloWorld-Table.pdf"));
JSONObject fetchRowWiseValJsn = null;
document.open();
PdfPTable table = null; // 3 columns.
......@@ -246,9 +336,9 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
PdfPCell cell2 = null;
PdfPCell cell3 = null;
// LinkedHashMap<String, Integer> catValues = null;
LinkedHashMap<String, String> catGimValues = null;
DecimalFormat df = new DecimalFormat("#.###");
List<String> valList = new ArrayList<String>();
HashMap<Integer, String> totalMap = new HashMap<Integer, String>();
for (int jsnCnt = 0; jsnCnt < rowDataPendingQCOrderPurc.size(); jsnCnt++)
{
catGimValues = new LinkedHashMap<String, String>();
......@@ -258,7 +348,7 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
System.out.println("subtype :"+subtype);
catGimValues = (LinkedHashMap<String, String>) fetchRowWiseValJsn.get("category_gimvalue");
System.out.println("catValuesTemp :"+catGimValues);
System.out.println("catGimValues :"+catGimValues);
count = 0;
......@@ -282,13 +372,13 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
table.setWidthPercentage(100);
document.add(table);
table = new PdfPTable(catGimValues.size()+1+catGimValues.size());
table = new PdfPTable(catGimValues.size()*2+1);
cell1 = new PdfPCell(new Paragraph("", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6, Font.BOLD, new Color(255,255,255))));
table.addCell(cell1);
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph("Open QC Order Count", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("GIM Value", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("GIM Value In Lacs", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
......@@ -309,14 +399,11 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
String[] temp;
String noOfQC = "";
String gimVal = "";
double total= 0.0;
temp = val.split("-");
noOfQC = temp[0].trim();
gimVal = temp[1].trim();
total = Double.parseDouble(noOfQC) + Double.parseDouble(gimVal);
System.out.println("noOfQC :"+noOfQC+"---- gimVal :"+gimVal);
String totalStrVal = "";
cell2 = new PdfPCell(new Paragraph(noOfQC, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph(gimVal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
......@@ -325,40 +412,66 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
table.addCell(cell2);
table.addCell(cell3);
if(count == jsnCnt && jsnCnt == 0)
{
valList.add(""+total);
}
else if(count >=0 && count<catValues.size())
{
double sum = total + Double.parseDouble(valList.get(count));
valList.set(count, df.format(sum));
count++;
}
if(jsnCnt == 0)
{
totalStrVal = noOfQC+"@"+gimVal;
totalMap.put(count, totalStrVal);
count++;
System.out.println("totalMap in if:"+totalMap);
}
else
{
totalStrVal = totalMap.get(count);
System.out.println("str in else :"+totalStrVal);
String[] totalStrValArr;
totalStrValArr = totalStrVal.split("@");
String noOfQC1 = totalStrValArr[0].trim();
String gimVal1 = totalStrValArr[1].trim();
int noOfQCTotal = Integer.parseInt(noOfQC) + Integer.parseInt(noOfQC1);
double gimValTotal = Double.parseDouble(gimVal) + Double.parseDouble(gimVal1);
totalStrVal = ""+noOfQCTotal+"@"+""+gimValTotal;
System.out.println("str in else:"+totalStrVal);
totalMap.put(count, totalStrVal);
count++;
}
}
table.setWidthPercentage(100);
document.add(table);
}
System.out.println("valList :"+valList);
table = new PdfPTable(catValues.size()* 2 +1);
System.out.println("totalMap :"+totalMap);
table = new PdfPTable(catGimValues.size()* 2 +1);
cell1 = new PdfPCell(new Paragraph("TOTAL", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
table.addCell(cell1);
for (int i=0; i<valList.size(); i++)
for (Map.Entry<Integer, String> entry : totalMap.entrySet())
{
cell2 = new PdfPCell(new Paragraph(""+valList.get(i), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell2.setColspan(2);
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
String val = entry.getValue();
String[] temp;
String noOfQC = "";
String gimVal = "";
double total= 0.0;
temp = val.split("@");
noOfQC = temp[0].trim();
gimVal = temp[1].trim();
table.addCell(cell2);
cell2 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(noOfQC)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell3 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(gimVal)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
}
table.setWidthPercentage(100);
document.add(table);
document.close();
System.out.println("PDF Create Successfully");*/
}
catch (Exception e)
{
......@@ -410,11 +523,12 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
int count = 0;
dashboardUtility = new DashboardUtility();
siteCode = dashboardUtility.getCommaSeparated(siteCode);
geoLocation = dashboardUtility.getCommaSeparated(geoLocation);
System.out.println("geoLocation in getPendingQCOrderPurchaseGrid :"+geoLocation);
if(geoLocation.trim().length()>0 && geoLocation!=null && siteCode!=null && siteCode.trim().length()>0)
{
sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,GIM_VALUE_In_Rs" +
/* sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,GIM_VALUE_In_Rs" +
" FROM (SELECT z.no_of_days AS no_of_days, z.ITEM_SER AS ITEM_SER," +
" SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, z.CHK_VAL AS CHK_VAL, " +
" sum(z.amt) as GIM_VALUE_In_Rs FROM (SELECT CASE " +
......@@ -448,17 +562,56 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
" A.CONFIRMED='Y' AND G.STATUS='U' AND A.TRAN_ID=B.TRAN_ID " +
" AND B.ITEM_CODE=C.ITEM_CODE AND A.SUPP_CODE=D.SUPP_CODE AND G.LOT_NO=B.LOT_NO " +
" AND g.PORCP_NO=A.TRAN_ID AND G.ITEM_CODE=B.ITEM_CODE GROUP BY A.item_ser,A.TRAN_DATE) z GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC ";
*/
sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL, " +
" ROUND((GIM_VALUE)/100000,3) As GIM_VALUE FROM ( SELECT z.no_of_days AS no_of_days, " +
" z.ITEM_SER AS ITEM_SER, SUM(z.NO_OF_OPEN_QCORDER) " +
" AS NO_OF_OPEN_QCORDER, z.CHK_VAL AS CHK_VAL, sum(z.amt) as GIM_VALUE " +
" FROM (SELECT CASE WHEN TO_CHAR(A.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>=0 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)<90 " +
" THEN '>0-90 days' WHEN TO_CHAR(a.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)<180 " +
" THEN '>90-180 days' WHEN TO_CHAR(a.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>=180 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)<365 " +
" THEN '>180-365 days' WHEN TO_CHAR(a.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE)>365 THEN '>365 days' " +
" WHEN TO_CHAR(a.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
" THEN TO_CHAR(a.TRAN_DATE,'YYYY') END no_of_days, A.ITEM_SER,COUNT(DISTINCT(G.QORDER_NO)) " +
" AS NO_OF_OPEN_QCORDER, (CASE WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 0 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) < 90 " +
" THEN 1 WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 90 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) < 180 " +
" THEN 2 WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 180 AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) < 365 " +
" THEN 3 WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - a.TRAN_DATE) >= 365 THEN 4 " +
" WHEN TO_CHAR (a.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
" THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (a.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
" AS CHK_VAL, sum(b.quantity*b.rate*A.EXCH_RATE) as amt " +
" FROM PORCP A,PORCPDET B,ITEM C,SUPPLIER D,QC_ORDER G,SITE H " +
" WHERE " +
" A.SITE_CODE IN ("+siteCode+") " +
" AND A.ITEM_SER IN ('RM1','BD','PM1','BDI') " +
" AND " +
" A.CONFIRMED='Y' AND G.STATUS='U' AND G.QC_CREATE_TYPE='A' AND A.TRAN_ID=B.TRAN_ID AND B.ITEM_CODE=C.ITEM_CODE " +
" AND A.SUPP_CODE=D.SUPP_CODE AND G.LOT_NO=B.LOT_NO AND g.PORCP_NO=A.TRAN_ID " +
" AND G.ITEM_CODE=B.ITEM_CODE AND A.SITE_CODE=H.SITE_CODE " +
" AND H.CITY in("+geoLocation+") " +
" GROUP BY A.item_ser,A.TRAN_DATE) z GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL " +
" ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
rowData = new JSONObject();
rowData.put("no_of_days", rs.getString("NO_OF_DAYS"));
rowData.put("no_of_days", rs.getString("no_of_days"));
rowData.put("item_ser", rs.getString("ITEM_SER"));
rowData.put("no_of_open_qcorder", rs.getString("NO_OF_OPEN_QCORDER"));
rowData.put("gim_value_in_rs", rs.getString("GIM_VALUE_In_Rs"));
rowData.put("gim_value_in_rs", rs.getString("GIM_VALUE"));
rowDataPendingQCOrderPurcGrid.put(count, rowData);
count++;
}
......@@ -513,10 +666,13 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
String imageName = null;
Image image = null;
File attachFile = null;
File attachExcleFile = null;
File attachManualQCExcleFile = null;
String imgFilePath =null;
File existImgFile =null;
String pdfFileName =null;
String excelFileName = null;
String excelManualQCFileName = null;
String toMailId ="";
String ccMailId ="";
String bccAddress ="";
......@@ -541,19 +697,29 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
JSONObject fetchRowWiseValJsn = null;
JSONObject rowDataforGrid = null;
List<String> valList = new ArrayList<String>();
//List<String> valList = new ArrayList<String>();
int count = 0;
LinkedHashMap<String, String> catGimValues = null;
DecimalFormat df = new DecimalFormat("#.###");
HashMap<Integer, String> totalMap = null;
String noOfQC = "";
String gimVal = "";
String totalStrVal = "";
String val = "";
int noOfQCTotal = 0;
double gimValTotal = 0.0;
String noOfQCPrev = "";
String gimValPrev = "";
String titleForManualQCExcel = "";
System.out.print("Calling for PDF created step1");
try
{
System.out.println("In PendingQCPurchaseOrder getPDFByScheduler city :"+city+"----siteCode :"+siteCode);
rowDataforGrid = this.getPendingQCOrderPurchase(city, siteCode, "DriverITM");
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//";
......@@ -569,168 +735,215 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
calendar = Calendar.getInstance();
currDate = simpleDateFormat.format(calendar.getTime());
document = new Document();
//rptTitle = rptTitle+"-"+currDate;
rptTitle = rptTitle+" ("+siteCode+")"+" Pending QC Against Purchase as on " +currDate;
//rptTitle = rptTitle.replace("@", "&");
rptTitle = city+" ("+siteCode+")"+" Pending QC Against Purchase as on " +currDate;
titleForManualQCExcel = city+" ("+siteCode+")"+" Pending Manual QC as on " +currDate;
System.out.println("rptTitle in PendingQCPurchaseOrder getPDFByScheduler :"+rptTitle);
pdfFileName = exportPDFPath+rptTitle+".pdf";
System.out.println("modify PDF file name "+ pdfFileName+"current date formate==="+currDate);
excelFileName = exportPDFPath+rptTitle+".xls";
excelManualQCFileName = exportPDFPath+titleForManualQCExcel+".xls";
System.out.println("excelFileName :"+excelFileName);
System.out.println("pdfFileName "+ pdfFileName);
file = new FileOutputStream(new File(pdfFileName));
writer = PdfWriter.getInstance(document, file);
document.open();
preface = new Paragraph();
preface.setAlignment(Element.ALIGN_CENTER);
preface.add(new Paragraph(rptTitle, FontFactory.getFont(FontFactory.TIMES_ROMAN, 15)));
preface.add(new Paragraph(" "));
document.add(preface);
imgNameArray = imgName.split(",");
for(int size=0;size<prntTblNo;size++)
for(int size=0;size<imgNameArray.length;size++)
{
totalMap = new HashMap<Integer, String>();
imageName= imgNameArray[size];
System.out.println("imageName in PendingQCPurchaseOrder getPDFByScheduler =="+imageName);
if(size==0)
imgFilePath = exportImagePath+imageName+".png";
existImgFile= new File(imgFilePath);
if(existImgFile.exists())
{
imageName= imgNameArray[size];
parentTable = new PdfPTable(1);
imgFilePath = exportImagePath+imageName+".png";
image = Image.getInstance(imgFilePath);
parentTable.addCell(image);
existImgFile= new File(imgFilePath);
if(existImgFile.exists())
if(size == 0)
{
existImgFile.delete();
System.out.println("Image Deleted after status **First*****"+imgFilePath );
rptTitle = city+" ("+siteCode+")"+" Pending QC Against Purchase as on " +currDate;
subject = rptTitle;
rowDataforGrid = this.getPendingQCOrderPurchase(city, siteCode, "DriverITM");
System.out.println("rowDataforGrid in getPDFByScheduler :"+rowDataforGrid);
this.getExcelGenerate(city, siteCode, "DriverITM");
}else if(size == 1)
{
rptTitle = city+" ("+siteCode+")"+" Pending Manual QC as on " +currDate;
rowDataforGrid = this.getPendingManualQCOrder(city, siteCode, "DriverITM");
System.out.println("rowDataforGrid in getPDFByScheduler :"+rowDataforGrid);
this.getPendingManualQCExcelGenerate(city, siteCode, "DriverITM");
}
preface = new Paragraph();
preface.setAlignment(Element.ALIGN_CENTER);
preface.add(new Paragraph(rptTitle, FontFactory.getFont(FontFactory.TIMES_ROMAN, 15)));
preface.add(new Paragraph(" "));
document.add(preface);
parentTable = new PdfPTable(1);
parentTable.addCell(image);
existImgFile.delete();
System.out.println("Image Deleted after status *******"+imgFilePath );
parentTable.setWidthPercentage(100);
}
document.add(parentTable);
preface = new Paragraph();
/*preface.add(new Paragraph(" "));*/
document.add(preface);
if(size==0)
{
document.add(parentTable);
preface = new Paragraph();
/*preface.add(new Paragraph(" "));*/
document.add(preface);
preface = new Paragraph();
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++)
{
catGimValues = new LinkedHashMap<String, String>();
fetchRowWiseValJsn = new JSONObject();
fetchRowWiseValJsn = (JSONObject) rowDataforGrid.get(jsnCnt);
subtype = ""+fetchRowWiseValJsn.get("product_category");
System.out.println("subtype :"+subtype);
catGimValues = (LinkedHashMap<String, String>) fetchRowWiseValJsn.get("category_gimvalue");
System.out.println("catGimValues :"+catGimValues);
count = 0;
System.out.println("catValuesGim.size() :"+catGimValues.size());
if(jsnCnt == 0)
{
table = new PdfPTable(catGimValues.size()*2+1);
cell1 = new PdfPCell(new Paragraph("OPEN SINCE", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6, Font.BOLD, new Color(255,255,255))));
cell1.setBackgroundColor(Color.gray);
table.addCell(cell1);
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph(entry.getKey(), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6, Font.BOLD, new Color(255,255,255))));
cell2.setColspan(2);
cell2.setBackgroundColor(Color.gray);
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
}
table.setWidthPercentage(100);
document.add(table);
table = new PdfPTable(catGimValues.size()*2+1);
cell1 = new PdfPCell(new Paragraph("", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6, Font.BOLD, new Color(255,255,255))));
table.addCell(cell1);
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph("Open QC Order Count", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("GIM Value Rs(In Lacs)", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
}
table.setWidthPercentage(100);
document.add(table);
}
table = new PdfPTable(catGimValues.size() * 2 + 1);
cell1 = new PdfPCell(new Paragraph(subtype, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
table.addCell(cell1);
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
val = entry.getValue();
String[] temp = null;
noOfQC = "";
gimVal = "";
totalStrVal = "";
temp = val.split("-");
noOfQC = temp[0].trim();
gimVal = temp[1].trim();
System.out.println("noOfQC :"+noOfQC+"---- gimVal :"+gimVal);
cell2 = new PdfPCell(new Paragraph(noOfQC, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph(gimVal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
if(jsnCnt == 0)
{
totalStrVal = noOfQC+"@"+gimVal;
totalMap.put(count, totalStrVal);
count++;
}
else
{
noOfQCTotal = 0;
gimValTotal = 0.0;
noOfQCPrev = "";
gimValPrev = "";
totalStrVal = totalMap.get(count);
String[] totalStrValArr;
totalStrValArr = totalStrVal.split("@");
noOfQCPrev = totalStrValArr[0].trim();
gimValPrev = totalStrValArr[1].trim();
noOfQCTotal = Integer.parseInt(noOfQC) + Integer.parseInt(noOfQCPrev);
gimValTotal = Double.parseDouble(gimVal) + Double.parseDouble(gimValPrev);
totalStrVal = ""+noOfQCTotal+"@"+""+gimValTotal;
totalMap.put(count, totalStrVal);
count++;
}
}
table.setWidthPercentage(100);
document.add(table);
}
/*Add code for total by Dhanendra on 08-09-15*/
table = new PdfPTable(catGimValues.size()* 2 +1);
cell1 = new PdfPCell(new Paragraph("TOTAL", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
table.addCell(cell1);
System.out.println("totalMap in PendingQCPurchaseOrder :"+totalMap);
for (Map.Entry<Integer, String> entry : totalMap.entrySet())
{
val = entry.getValue();
String[] tempArr;
noOfQC = "";
gimVal = "";
tempArr = val.split("@");
noOfQC = tempArr[0].trim();
gimVal = tempArr[1].trim();
cell2 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(noOfQC)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell3 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(gimVal)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
}
table.setWidthPercentage(100);
document.add(table);
document.newPage();
}
}
preface.add(new Paragraph(" "));
for (int jsnCnt = 0; jsnCnt < rowDataforGrid.size(); jsnCnt++)
{
catGimValues = new LinkedHashMap<String, String>();
fetchRowWiseValJsn = new JSONObject();
fetchRowWiseValJsn = (JSONObject) rowDataforGrid.get(jsnCnt);
subtype = ""+fetchRowWiseValJsn.get("product_category");
System.out.println("subtype :"+subtype);
catGimValues = (LinkedHashMap<String, String>) fetchRowWiseValJsn.get("category_gimvalue");
System.out.println("catGimValues :"+catGimValues);
count = 0;
System.out.println("catValuesGim.size() :"+catGimValues.size());
if(jsnCnt == 0)
{
table = new PdfPTable(catGimValues.size()*2+1);
cell1 = new PdfPCell(new Paragraph("OPEN SINCE", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6, Font.BOLD, new Color(255,255,255))));
cell1.setBackgroundColor(Color.gray);
table.addCell(cell1);
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph(entry.getKey(), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6, Font.BOLD, new Color(255,255,255))));
cell2.setColspan(2);
cell2.setBackgroundColor(Color.gray);
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
}
table.setWidthPercentage(100);
document.add(table);
table = new PdfPTable(catGimValues.size()*2+1);
cell1 = new PdfPCell(new Paragraph("", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6, Font.BOLD, new Color(255,255,255))));
table.addCell(cell1);
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph("Open QC Order Count", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("GIM Value", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
}
table.setWidthPercentage(100);
document.add(table);
}
table = new PdfPTable(catGimValues.size() * 2 + 1);
cell1 = new PdfPCell(new Paragraph(subtype, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
table.addCell(cell1);
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
String val = entry.getValue();
String[] temp;
String noOfQC = "";
String gimVal = "";
double total= 0.0;
temp = val.split("-");
noOfQC = temp[0].trim();
gimVal = temp[1].trim();
total = Double.parseDouble(noOfQC) + Double.parseDouble(gimVal);
System.out.println("noOfQC :"+noOfQC+"---- gimVal :"+gimVal);
cell2 = new PdfPCell(new Paragraph(noOfQC, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph(gimVal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
if(count == jsnCnt && jsnCnt == 0)
{
valList.add(""+total);
}
else if(count >=0 && count<catGimValues.size())
{
double sum = total + Double.parseDouble(valList.get(count));
valList.set(count, df.format(sum));
count++;
}
}
table.setWidthPercentage(100);
document.add(table);
}
/*Add code for total by Dhanendra on 08-09-15*/
System.out.println("valList :"+valList);
table = new PdfPTable(catGimValues.size()* 2 +1);
cell1 = new PdfPCell(new Paragraph("TOTAL", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
table.addCell(cell1);
for (int i=0; i<valList.size(); i++)
{
cell2 = new PdfPCell(new Paragraph(""+valList.get(i), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell2.setColspan(2);
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
}
table.setWidthPercentage(100);
document.add(table);
/*End code for total by Dhanendra on 08-09-15*/
document.close();
......@@ -738,59 +951,53 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
System.out.println("PDF Created succesfully in PendingQCPurchaseOrder getPDFByScheduler");
conn = connDriver.getConnectDB("DriverITM");
connDriver =null;
toMailId ="";
ccMailId ="";
bccAddress ="";
subject =rptTitle;
userWiseBodytext ="Dear Sir, Please find attached here with 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);
connDriver =null;
toMailId ="";
ccMailId ="";
bccAddress ="";
//subject =rptTitle;
userWiseBodytext ="Dear Sir, Please find attached here with is the Weekly Output:"+subject+" Report in PDF format.";
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);
}*/
city = "PQCPAR_"+city.trim();
System.out.println("Add PQCPAR 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 PendingQCWorkOrder.getPDFByScheduler city = "+city+" --- toMailId ="+toMailId +"AND According to the ccMailId ======="+ccMailId+"---- bccAddress == "+bccAddress);
}
toMailId = "Julian.Soares@sunpharma.com,Bhaumik.Joshi@sunpharma.com,Jigar.Gohil@sunpharma.com";
ccMailId = "";
bccAddress = "";
/*toMailId = "Julian.Soares@sunpharma.com,Bhaumik.Joshi@sunpharma.com,Jigar.Gohil@sunpharma.com";
ccMailId = "birendra.pandey@baseinformation.com,nikhil.sawalakhe@baseinformation.com,dhanendra.kasliwal@baseinformation.com";
bccAddress = "";*/
/*toMailId = "dhanendra.kasliwal@baseinformation.com,nikhil.sawalakhe@baseinformation.com";
ccMailId = "";
bccAddress = "";*/
/*toMailId = "Julian.Soares@sunpharma.com,Bhaumik.Joshi@sunpharma.com,Jigar.Gohil@sunpharma.com";
ccMailId = "dhanendra.kasliwal@baseinformation.com";
bccAddress = "";*/
System.out.println("Export Pdf path for PendingQCPurchaseOrder.getPDFByScheduler ="+pdfFileName);
attachFile = new File(pdfFileName);
if(attachFile.exists() && attachFile.length()>0)
{
mailInfo =new ArrayList<String>();
mailInfo.add(toMailId);
mailInfo.add(ccMailId);
mailInfo.add(bccAddress);
mailInfo.add(subject);
mailInfo.add(userWiseBodytext);
mailInfo.add(attachFile.getPath());
this.sendingMail(mailInfo);
resultFlage="true";
}
System.out.println("*sending mail done succesfully for WIPStatus.getPDFByScheduler*");
System.out.println("Export Pdf path for PendingQCPurchaseOrder.getPDFByScheduler ="+pdfFileName);
attachFile = new File(pdfFileName);
attachExcleFile = new File(excelFileName);
attachManualQCExcleFile = new File(excelManualQCFileName);
if(attachFile.exists() && attachFile.length()>0 && attachExcleFile.exists() && attachExcleFile.length()>0 && attachManualQCExcleFile.exists() && attachManualQCExcleFile.length()>0)
{
mailInfo =new ArrayList<String>();
mailInfo.add(toMailId);
mailInfo.add(ccMailId);
mailInfo.add(bccAddress);
mailInfo.add(subject);
mailInfo.add(userWiseBodytext);
mailInfo.add(attachFile.getPath());
mailInfo.add(attachExcleFile.getPath());
mailInfo.add(attachManualQCExcleFile.getPath());
this.sendingMail(mailInfo);
resultFlage="true";
}
System.out.println("*sending mail done succesfully for PendingQCPurchaseOrder.getPDFByScheduler*");
} catch (Exception e)
{
System.out.println("Exception :PendingQCPurchaseOrder :getPDFByScheduler "+e.getMessage());
......@@ -823,9 +1030,9 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
}
public void sendingMail(ArrayList<String> mailInfo)
public void sendingMail(ArrayList<String> mailInfo)
{
StringBuffer commInfo = new StringBuffer();
StringBuffer commInfo = new StringBuffer();
commInfo.append("<ROOT>");
commInfo.append("<MAILINFO>");
commInfo.append("<EMAIL_TYPE>").append("page").append("</EMAIL_TYPE>");
......@@ -834,7 +1041,7 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
commInfo.append("<BCC_ADD>").append("<![CDATA[" + mailInfo.get(2) + "]]>").append("</BCC_ADD>");
commInfo.append("<SUBJECT>").append("<![CDATA[" + mailInfo.get(3) + "]]>").append("</SUBJECT>");
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)+";"+ mailInfo.get(6)+";"+ mailInfo.get(7)+ "]]>").append("</XML_DATA_FILE_PATH>");
commInfo.append("</MAILINFO>");
commInfo.append("</ROOT>");
EMail email = new EMail();
......@@ -851,4 +1058,740 @@ public class PendingQCPurchaseOrder implements PendingQCPurchaseOrderLocal, Pen
email = null;
}
/*End- this method add for generatePDF on 13Aug2015*/
/*Add this method for generate Excel file on Date 21-09-15 by Nikhil*/
public void getExcelGenerate(String city, String siteCode, String dataSourceName)throws RemoteException, ITMException
{
System.out.println("in getExcelGenerate getPendingQCOrderPurchase city :"+city+"-----siteCode :"+siteCode);
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String excelFileName = null;
String exportPDFPath = "";
String currDate="";
SimpleDateFormat simpleDateFormat = null;
Calendar calendar = null;
DashboardUtility dashboardUtility = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
dashboardUtility = new DashboardUtility();
calendar = Calendar.getInstance();
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;
currDate = simpleDateFormat.format(calendar.getTime());
excelFileName = city+" ("+siteCode+")"+" Pending QC Against Purchase as on " +currDate;
System.out.println("excelFileName in getPendingQCOrderPurchase :"+excelFileName);
city = dashboardUtility.getCommaSeparated(city);
siteCode = dashboardUtility.getCommaSeparated(siteCode);
System.out.println("in getExcelGenerate after dashboardUtility city :"+city+"-----siteCode :"+siteCode);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow(0);
HSSFCellStyle cellStyleLeft=wb.createCellStyle() ;
cellStyleLeft.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFCellStyle cellStyleRight=wb.createCellStyle() ;
cellStyleRight.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
HSSFFont font=wb.createFont();
font.setFontName("Calibri");
font.setFontHeightInPoints((short)10);
cellStyleLeft.setFont(font);
cellStyleRight.setFont(font);
sql = "SELECT A.SITE_CODE, A.TRAN_ID AS GIM_NO, to_char(A.TRAN_DATE,'dd/mm/yy') AS GIM_DATE, " +
"A.TRAN_SER, TRUNC(SYSDATE)-TRUNC(A.TRAN_DATE) AS DAYS, A.SUPP_CODE, " +
"D.SUPP_NAME, A.ITEM_SER, B.PURC_ORDER, B.ITEM_CODE AS ITEM_CODE," +
" C.DESCR AS ITEM_DESCR, B.UNIT, sum(B.QUANTITY) as QTY," +
" B.ACCT_CODE__DR, B.CCTR_CODE__dr, B.ACCT_CODE__CR, " +
"sum(b.quantity*b.rate*A.EXCH_RATE) as AMT, B.LOT_NO, " +
"G.STATUS , A.EXCH_RATE, b.RATE, A.CURR_CODE ,to_char(G.MFG_DATE,'dd/mm/yy') AS MFG_DATE, to_char(G.EXPIRY_DATE,'dd/mm/yy') AS EXPIRY_DATE " +
" FROM PORCP A, PORCPDET B,ITEM C,SUPPLIER D,QC_ORDER G," +
"SITE H WHERE " +
"A.SITE_CODE IN ("+siteCode+") " +
"AND " +
"A.ITEM_SER IN ('RM1','BD','PM1','BDI') " +
"AND " +
"A.CONFIRMED='Y' AND G.STATUS='U' AND G.QC_CREATE_TYPE='A' AND A.TRAN_ID=B.TRAN_ID " +
"AND B.ITEM_CODE=C.ITEM_CODE AND A.SUPP_CODE=D.SUPP_CODE " +
"AND G.LOT_NO=B.LOT_NO and g.PORCP_NO=A.TRAN_ID " +
"AND G.ITEM_CODE=B.ITEM_CODE AND A.SITE_CODE=H.SITE_CODE " +
"AND H.CITY in("+city+") " +
"group by A.SITE_CODE,A.TRAN_ID, " +
"A.TRAN_DATE, B.ITEM_CODE, C.DESCR, B.UNIT, B.LOt_no, " +
"A.SUPP_CODE, D.SUPP_NAME, B.PURC_ORDER, G.STATUS, " +
"A.ITEM_SER, B.ACCT_CODE__DR, B.CCTR_CODE__dr, B.ACCT_CODE__CR," +
"A.EXCH_RATE, A.CURR_CODE,A.TRAN_SER,b.rate,g.mfg_date,g.expiry_date ORDER BY A.TRAN_DATE ";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
ResultSetMetaData rsmtdt= rs.getMetaData();
int columncount=rsmtdt.getColumnCount();
int index = 0;
boolean flag=true;
HSSFRow row=null;
while(rs.next())
{
//System.out.println("index :"+index);
row = sheet.createRow(index);
if(flag)
{
for(int i=1;i<=columncount;i++)
{
createCell(wb, rowhead, i-1,cellStyleLeft, rsmtdt.getColumnLabel(i), "String");
}
flag=false;
index++;
row = sheet.createRow(index);
}
createCell(wb,row, 0,cellStyleLeft,checkNull(rs.getString(1)).trim(),"String"); //SITE_CODE
createCell(wb,row, 1,cellStyleLeft,checkNull(rs.getString(2)).trim(),"String"); //GIM_NO
createCell(wb,row, 2,cellStyleLeft,checkNull(rs.getString(3)).trim(),"String"); //GIM_DATE
createCell(wb,row, 3,cellStyleLeft,checkNull(rs.getString(4)).trim(),"String"); //TRAN_SER
createCell(wb,row, 4,cellStyleRight,checkZero(rs.getString(5)).trim(),"String"); //DAYS
createCell(wb,row, 5,cellStyleLeft,checkNull(rs.getString(6)).trim(),"String"); //SUPP_CODE
createCell(wb,row, 6,cellStyleLeft,checkNull(rs.getString(7)).trim(),"String"); //SUPP_NAME
createCell(wb,row, 7,cellStyleLeft,checkNull(rs.getString(8)).trim(),"String"); //ITEM_SER
createCell(wb,row, 8,cellStyleLeft,checkNull(rs.getString(9)).trim(),"String"); //PURC_ORDER
createCell(wb,row, 9,cellStyleLeft,checkNull(rs.getString(10)).trim(),"String"); //ITEM_CODE
createCell(wb,row, 10,cellStyleLeft,checkNull(rs.getString(11)).trim(),"String"); //ITEM_DESCR
createCell(wb,row, 11,cellStyleLeft,checkNull(rs.getString(12)).trim(),"String"); //UNIT
createCell(wb,row, 12,cellStyleRight,checkZero(rs.getString(13)).trim(),"Number"); //QTY
createCell(wb,row, 13,cellStyleLeft,checkNull(rs.getString(14)).trim(),"String"); //ACCT_CODE__DR
createCell(wb,row, 14,cellStyleLeft,checkNull(rs.getString(15)).trim(),"String"); //CCTR_CODE__dr
createCell(wb,row, 15,cellStyleLeft,checkNull(rs.getString(16)).trim(),"String"); //ACCT_CODE__CR
createCell(wb,row, 16,cellStyleRight,checkZero(rs.getString(17)).trim(),"Number"); //AMT
createCell(wb,row, 17,cellStyleLeft,checkNull(rs.getString(18)).trim(),"String"); //LOT_NO
createCell(wb,row, 18,cellStyleLeft,checkNull(rs.getString(19)).trim(),"String"); //STATUS
createCell(wb,row, 19,cellStyleRight,checkZero(rs.getString(20)).trim(),"Number"); //EXCH_RATE
createCell(wb,row, 20,cellStyleRight,checkZero(rs.getString(21)).trim(),"Number"); //RATE
createCell(wb,row, 21,cellStyleLeft,checkNull(rs.getString(22)).trim(),"String"); //CURR_CODE
createCell(wb,row, 22,cellStyleLeft,checkNull(rs.getString(23)).trim(),"String"); //MFG_DATE
createCell(wb,row, 23,cellStyleLeft,checkNull(rs.getString(24)).trim(),"String"); //EXPIRY_DATE
index++;
}
excelFileName = exportPDFPath+excelFileName+".xls";
System.out.println("excelFileName in getExcelGenerate :"+excelFileName);
FileOutputStream out = new FileOutputStream(excelFileName);
wb.write(out);
out.close();
}catch (Exception e)
{
System.out.println("Exception :PendingQCPurchaseOrder :getExcelGenerate(String city, String siteCode, String dataSourceName :"+e.getMessage());
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 d)
{
d.printStackTrace();
System.out.println("Exception in PendingQCPurchaseOrder.getPDFByScheduler" + d.getMessage());
throw new ITMException(d);
}
}
}
@SuppressWarnings("deprecation")
private void createCell(HSSFWorkbook wb, HSSFRow row, int column, HSSFCellStyle cellStyle, String data, String dataType)
{
HSSFCell cell = null;
if("String".equalsIgnoreCase(dataType))
{
cell = row.createCell((short) column, HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(data);
}
if("Number".equalsIgnoreCase(dataType))
{
cellStyle.setDataFormat((short)2);
cell = row.createCell((short) column, HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(Double.parseDouble(data));
}
cell.setCellStyle(cellStyle);
}
/*End this method for generate Excel file on Date 21-09-15 by Nikhil*/
private String checkNull(String str)
{
if(str == null)
{
return "";
}
else
{
return str ;
}
}
private String checkZero(String str)
{
if(str == null || str.equals(null) || str.equalsIgnoreCase(""))
{
return "0";
}
else
{
return str ;
}
}
/*Start Method add for PendingManualQCOrder Stack Chart by Dhanendra On 01-10-2015 */
@SuppressWarnings("unchecked")
public JSONObject getPendingManualQCOrder(String geoLocation, String siteCode, String dataSourceName) throws RemoteException, ITMException
{
System.out.println("In PendingQCOrder getPendingManualQCOrder geoLocation :"+geoLocation+"----siteCode :"+siteCode+"---dataSourceName :"+dataSourceName);
JSONObject rowDataPendingManualQCOrder = null;
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
int count = 0;
if(geoLocation.trim().length()>0 && geoLocation!=null && siteCode!=null && siteCode.trim().length()>0)
{
rowDataPendingManualQCOrder = new JSONObject();
dashboardUtility = new DashboardUtility();
siteCode = dashboardUtility.getCommaSeparated(siteCode);
geoLocation = dashboardUtility.getCommaSeparated(geoLocation);
sql= " Select NO_OF_DAYS,ITEM_SER,NO_OF_OPEN_QCORDER,CHK_VAL, ROUND((VALUE)/100000,3) AS VALUE " +
"FROM( SELECT z.no_of_days AS no_of_days, z.ITEM_SER AS ITEM_SER, SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, " +
"z.CHK_VAL AS CHK_VAL, sum(z.QUANTITY*Z.RATE) as VALUE " +
"FROM (SELECT CASE WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>=0 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)<90 THEN '>0-90 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)<180 THEN '>90-180 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>=180 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)<365 THEN '>180-365 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>365 THEN '>365 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') THEN TO_CHAR(A.QORDER_DATE,'YYYY') END no_of_days, " +
"C.ITEM_SER, COUNT(DISTINCT(A.QORDER_NO)) AS NO_OF_OPEN_QCORDER, (CASE WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 0 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) < 90 THEN 1 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 90 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) < 180 THEN 2 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 180 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) < 365 THEN 3 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 365 THEN 4 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (A.QORDER_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) AS CHK_VAL, " +
"A.quantity, MIN(b.rate) as RATE FROM QC_ORDER A,ITEM C,STOCK B,SITE H " +
"WHERE A.STATUS='U' " +
"AND A.SITE_CODE IN ("+siteCode+") " +
"AND B.ITEM_SER IN ('RM1','BD','PM1','BDI') " +
"AND A.ITEM_CODE=C.ITEM_CODE " +
"AND A.SITE_CODE=B.SITE_CODE " +
"AND B.QUANTITY>0 AND B.INV_STAT in ('NOSL','REJ') AND A.ITEM_CODE=B.ITEM_CODE AND A.LOT_NO=A.LOT_NO " +
"AND A.SITE_CODE=H.SITE_CODE AND A.QC_CREATE_TYPE='M' " +
"AND H.CITY in ("+geoLocation+") " +
"GROUP BY C.item_ser,A.QORDER_DATE,A.QUANTITY,A.QORDER_NO ) z " +
"GROUP BY no_of_days,ITEM_SER,CHK_VAL ORDER BY z.ITEM_SER) " +
"ORDER BY CHK_VAL ASC";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String noOfOpenQCOrderVal="";
String qcValue="";
String noOfDay="",subType="";
List<String> noOfDayList= new ArrayList<String>();
List<String> subTypeList= new ArrayList<String>();
String key="";
LinkedHashMap<String, String> graphDataMap = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> sortedGraphDataMap = new LinkedHashMap<String, String>();
while (rs.next())
{
noOfOpenQCOrderVal = rs.getString("NO_OF_OPEN_QCORDER");
noOfDay = rs.getString("NO_OF_DAYS");
subType= rs.getString("ITEM_SER");
qcValue=rs.getString("VALUE");
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, (noOfOpenQCOrderVal+"-"+qcValue));
}
if(graphDataMap !=null && graphDataMap.size()>0)
{
if(graphDataMap.containsKey(key))
{
//wipValue = wipValue + graphDataMap.get(key);
noOfOpenQCOrderVal = graphDataMap.get(key);
}
else if(! graphDataMap.containsKey(key))
{
noOfOpenQCOrderVal = noOfOpenQCOrderVal+"-"+qcValue;
}
graphDataMap.put(key, noOfOpenQCOrderVal);
}
}
System.out.println("graphDataMap: "+graphDataMap);
String sbType="";
String grpKey="";
for(int itmCtr=0;itmCtr<subTypeList.size();itmCtr++)
{
sbType = subTypeList.get(itmCtr);
for (Map.Entry<String, String> grpentry : graphDataMap.entrySet())
{
for(int dayCtr=0;dayCtr<noOfDayList.size();dayCtr++)
{
grpKey = (noOfDayList.get(dayCtr).trim()+"@"+sbType.trim());
if(graphDataMap.containsKey(grpKey))
{
sortedGraphDataMap.put(grpKey, graphDataMap.get(grpKey));
}
if(!graphDataMap.containsKey(grpKey) )
{
sortedGraphDataMap.put(grpKey, "0-0");
}
}
}
}
System.out.println("sortedGraphDataMap: "+sortedGraphDataMap);
rowData = new JSONObject();
String noDays="",qcOrd="";
String subType1="",prvsubType1="";
LinkedHashMap<String, String> catValues = new LinkedHashMap<String, String>();
LinkedHashMap<String, String> catQCValues = new LinkedHashMap<String, String>();
int cnt=0;
for (Map.Entry<String, String> entry : sortedGraphDataMap.entrySet())
{
cnt++;
String mapKey = entry.getKey();
String value = entry.getValue();// need to split
String[] temp;
temp = mapKey.split("@");
noDays = temp[0].trim();
subType1 = temp[1].trim();
String[] qcOrdArr;
qcOrdArr = value.split("-");
qcOrd = qcOrdArr[0].trim();
if( subType1 != null && ("").equals(prvsubType1) && subType1.trim().length()>0)
{
catValues.put(noDays,qcOrd);
catQCValues.put(noDays,value);
rowData.put("month",cnt);
rowData.put("product_category",subType1);
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catQCValues);
}
else if(!("").equals(prvsubType1) && prvsubType1.equals(subType1))
{
catValues.put(noDays,qcOrd);
catQCValues.put(noDays,value);
}
else if(!("").equals(prvsubType1) && ! prvsubType1.equals(subType1))
{
rowData.put("month",cnt);
rowData.put("product_category",prvsubType1);
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catQCValues);
rowDataPendingManualQCOrder.put(count, rowData);
count++;
rowData = new JSONObject();
catValues = new LinkedHashMap<String, String>();
catQCValues = new LinkedHashMap<String, String>();
catQCValues.put(noDays,value);
catValues.put(noDays,qcOrd);
}
if(cnt==sortedGraphDataMap.size())
{
rowData.put("month",++cnt);
rowData.put("product_category",subType1);
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catQCValues);
rowDataPendingManualQCOrder.put(count, rowData);
}
prvsubType1=subType1;
}
if(rowDataPendingManualQCOrder.isEmpty())
{
System.out.println("**** rowDataPendingManualQCOrder is Empty **** ");
catValues.put(">0-90 days", "0");
catValues.put(">90-180 days", "0");
catValues.put(">180-365 days", "0");
catQCValues.put(">0-90 days", "0-0");
catQCValues.put(">90-180 days", "0-0");
catQCValues.put(">180-365 days", "0-0");
rowData = new JSONObject();
rowData.put("month",cnt);
rowData.put("product_category","RM1");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catQCValues);
rowDataPendingManualQCOrder.put(count, rowData);
rowData = new JSONObject();
rowData.put("month",++cnt);
rowData.put("product_category","BD");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catQCValues);
rowDataPendingManualQCOrder.put(++count, rowData);
rowData = new JSONObject();
rowData.put("month",++cnt);
rowData.put("product_category","PM1");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catQCValues);
rowDataPendingManualQCOrder.put(++count, rowData);
rowData = new JSONObject();
rowData.put("month",++cnt);
rowData.put("product_category","BDI");
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catQCValues);
rowDataPendingManualQCOrder.put(++count, rowData);
}
}
System.out.println("rowDataPendingManualQCOrder :"+rowDataPendingManualQCOrder);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
} 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 d)
{
d.printStackTrace();
System.out.println("Exception in :PendingQCPurchaseOrder : getPendingManualQCOrder():" + d.getMessage());
throw new ITMException(d);
}
}
return rowDataPendingManualQCOrder;
}
/*End Method add for PendingManualQCOrder Stack Chart by Dhanendra On 01-10-2015 */
/*Start Method add for PendingManualQCOrder Stack Chart by Dhanendra On 01-10-2015 */
@SuppressWarnings("unchecked")
public JSONObject getPendingManualQCOrderGrid(String geoLocation, String siteCode, String dataSourceName) throws RemoteException, ITMException
{
JSONObject rowDataPendingManualQCOrderGrid = new JSONObject();
JSONObject rowData = null;
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
DashboardUtility dashboardUtility = null;
try
{
System.out.println(" Inside getPendingQCOrderPurchase for getPendingManualQCOrderGrid Data Soruc Name ="+dataSourceName);
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
int count = 0;
dashboardUtility = new DashboardUtility();
siteCode = dashboardUtility.getCommaSeparated(siteCode);
geoLocation = dashboardUtility.getCommaSeparated(geoLocation);
System.out.println("geoLocation in getPendingManualQCOrderGrid :"+geoLocation);
if(geoLocation.trim().length()>0 && geoLocation!=null && siteCode!=null && siteCode.trim().length()>0)
{
sql= " Select NO_OF_DAYS,ITEM_SER,NO_OF_OPEN_QCORDER,CHK_VAL,ROUND((VALUE)/100000,3) AS VALUE " +
"FROM( SELECT z.no_of_days AS no_of_days, z.ITEM_SER AS ITEM_SER, SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, " +
"z.CHK_VAL AS CHK_VAL, sum(z.QUANTITY*Z.RATE) as VALUE " +
"FROM (SELECT CASE WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>=0 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)<90 THEN '>0-90 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)<180 THEN '>90-180 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>=180 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)<365 THEN '>180-365 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE)>365 THEN '>365 days' " +
"WHEN TO_CHAR(A.QORDER_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') THEN TO_CHAR(A.QORDER_DATE,'YYYY') END no_of_days, " +
"C.ITEM_SER, COUNT(DISTINCT(A.QORDER_NO)) AS NO_OF_OPEN_QCORDER, (CASE WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 0 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) < 90 THEN 1 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 90 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) < 180 THEN 2 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 180 AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) < 365 THEN 3 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') AND TRUNC (TRUNC (SYSDATE) - A.QORDER_DATE) >= 365 THEN 4 " +
"WHEN TO_CHAR (A.QORDER_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (A.QORDER_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) AS CHK_VAL, " +
"A.quantity, MIN(b.rate) as RATE FROM QC_ORDER A,ITEM C,STOCK B,SITE H " +
"WHERE A.STATUS='U' " +
"AND A.SITE_CODE IN ("+siteCode+") " +
"AND B.ITEM_SER IN ('RM1','BD','PM1','BDI') " +
"AND A.ITEM_CODE=C.ITEM_CODE " +
"AND A.SITE_CODE=B.SITE_CODE " +
"AND B.QUANTITY>0 AND B.INV_STAT in ('NOSL','REJ') AND A.ITEM_CODE=B.ITEM_CODE AND A.LOT_NO=A.LOT_NO " +
"AND A.SITE_CODE=H.SITE_CODE AND A.QC_CREATE_TYPE='M' " +
"AND H.CITY in ("+geoLocation+") " +
"GROUP BY C.item_ser,A.QORDER_DATE,A.QUANTITY,A.QORDER_NO ) z " +
"GROUP BY no_of_days,ITEM_SER,CHK_VAL ORDER BY z.ITEM_SER) " +
"ORDER BY CHK_VAL ASC";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
while (rs.next())
{
rowData = new JSONObject();
rowData.put("no_of_days", rs.getString("NO_OF_DAYS"));
rowData.put("item_ser", rs.getString("ITEM_SER"));
rowData.put("no_of_open_qcorder", rs.getString("NO_OF_OPEN_QCORDER"));
rowData.put("value", rs.getString("VALUE"));
rowDataPendingManualQCOrderGrid.put(count, rowData);
count++;
}
}
System.out.println("rowDataPendingManualQCOrderGrid :"+rowDataPendingManualQCOrderGrid);
}
catch (Exception e)
{
e.printStackTrace();
throw new ITMException(e);
}
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 d)
{
d.printStackTrace();
System.out.println("Exception in PendingQCPurchaseOrder : getPendingManualQCOrderGrid:" + d.getMessage());
throw new ITMException(d);
}
}
return rowDataPendingManualQCOrderGrid;
}
/*End Method add for PendingManualQCOrder Stack Chart by Dhanendra On 01-10-2015 */
public void getPendingManualQCExcelGenerate(String city, String siteCode, String dataSourceName)throws RemoteException, ITMException
{
System.out.println("in getPendingManualQCExcelGenerate getPendingQCOrderPurchase city :"+city+"-----siteCode :"+siteCode);
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String excelFileName = null;
String exportPDFPath = "";
String currDate="";
SimpleDateFormat simpleDateFormat = null;
Calendar calendar = null;
DashboardUtility dashboardUtility = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
dashboardUtility = new DashboardUtility();
calendar = Calendar.getInstance();
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;
currDate = simpleDateFormat.format(calendar.getTime());
excelFileName = city+" ("+siteCode+")"+" Pending Manual QC as on " +currDate;
System.out.println("excelFileName in getPendingManualQCExcelGenerate :"+excelFileName);
city = dashboardUtility.getCommaSeparated(city);
siteCode = dashboardUtility.getCommaSeparated(siteCode);
System.out.println("in getPendingManualQCExcelGenerate after dashboardUtility city :"+city+"-----siteCode :"+siteCode);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow(0);
HSSFCellStyle cellStyleLeft=wb.createCellStyle() ;
cellStyleLeft.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFCellStyle cellStyleRight=wb.createCellStyle() ;
cellStyleRight.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
HSSFFont font=wb.createFont();
font.setFontName("Calibri");
font.setFontHeightInPoints((short)10);
cellStyleLeft.setFont(font);
cellStyleRight.setFont(font);
/*sql = " SELECT to_char(A.QORDER_DATE,'dd/mm/yy') AS QORDER_DATE, A.QORDER_NO, A.SITE_CODE, TRUNC(SYSDATE)-TRUNC(A.QORDER_DATE) AS DAYS, " +
"C.ITEM_SER, B.ITEM_CODE AS ITEM_CODE, C.DESCR AS ITEM_DESCR, A.LOT_NO, A.UNIT, A.QUANTITY as QTY ," +
"MIN(B.RATE) AS RATE, (A.QUANTITY*MIN(RATE)) AS VALUE " +
"FROM QC_ORDER A, ITEM C, STOCK B ,SITE H " +
"WHERE A.STATUS='U' " +
"AND A.SITE_CODE IN ("+siteCode+") " +
"AND B.ITEM_SER IN ('RM1','BD','PM1','BDI') " +
"AND A.ITEM_CODE=C.ITEM_CODE AND A.SITE_CODE=B.SITE_CODE AND B.QUANTITY>0 " +
"AND B.INV_STAT='NOSL' AND A.ITEM_CODE=B.ITEM_CODE AND A.LOT_NO=A.LOT_NO AND A.SITE_CODE=H.SITE_CODE AND A.QC_CREATE_TYPE='M' " +
"AND H.CITY in("+city+") " +
"group by A.SITE_CODE, C.ITEM_SER, B.ITEM_CODE, C.DESCR , A.UNIT, A.QORDER_DATE, A.QUANTITY,A.LOT_NO,A.QORDER_NO";*/
sql= "SELECT to_char(A.QORDER_DATE,'dd/mm/yy') AS QORDER_DATE, A.QORDER_NO, A.SITE_CODE, MIN(B.SUPP_CODE__MFG) AS SUPP_MFG_CODE, " +
"DDF_GET_MULTI_SUPP_NAME_CITY(MIN(B.SUPP_CODE__MFG),'S') AS SUPP_NAME, TRUNC(SYSDATE)-TRUNC(A.QORDER_DATE) AS DAYS, " +
"C.ITEM_SER, B.ITEM_CODE AS ITEM_CODE, C.DESCR AS ITEM_DESCR, A.LOT_NO, A.UNIT, A.QUANTITY as QTY ," +
"MIN(B.RATE) AS RATE, (A.QUANTITY*MIN(RATE)) AS VALUE, to_char(A.MFG_DATE,'dd/mm/yy') AS MFG_DATE, to_char(A.EXPIRY_DATE,'dd/mm/yy') AS EXPIRY_DATE " +
"FROM QC_ORDER A, ITEM C, STOCK B,SITE H " +
"WHERE A.SITE_CODE IN ("+siteCode+") " +
"AND B.ITEM_SER IN ('RM1','BD','PM1','BDI') " +
"AND A.STATUS='U' AND A.ITEM_CODE=C.ITEM_CODE " +
"AND A.SITE_CODE=B.SITE_CODE AND B.QUANTITY>0 " +
"AND B.INV_STAT in ('NOSL','REJ') AND A.ITEM_CODE=B.ITEM_CODE AND A.LOT_NO=A.LOT_NO AND A.SITE_CODE=H.SITE_CODE " +
"AND A.QC_CREATE_TYPE='M' " +
"AND H.CITY in ("+city+") " +
"group by A.SITE_CODE, C.ITEM_SER, B.ITEM_CODE, C.DESCR , A.UNIT, A.QORDER_DATE, A.QUANTITY," +
"A.LOT_NO,A.QORDER_NO ,A.MFG_DATE,A.EXPIRY_DATE ORDER BY A.QORDER_DATE";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
ResultSetMetaData rsmtdt= rs.getMetaData();
int columncount=rsmtdt.getColumnCount();
int index = 0;
boolean flag=true;
HSSFRow row=null;
while(rs.next())
{
//System.out.println("index :"+index);
row = sheet.createRow(index);
if(flag)
{
for(int i=1;i<=columncount;i++)
{
createCell(wb, rowhead, i-1,cellStyleLeft, rsmtdt.getColumnLabel(i), "String");
}
flag=false;
index++;
row = sheet.createRow(index);
}
createCell(wb,row, 0,cellStyleLeft,checkNull(rs.getString(1)).trim(),"String"); //QORDER_DATE
createCell(wb,row, 1,cellStyleLeft,checkNull(rs.getString(2)).trim(),"String"); //QORDER_NO
createCell(wb,row, 2,cellStyleLeft,checkNull(rs.getString(3)).trim(),"String"); //SITE_CODE
createCell(wb,row, 3,cellStyleLeft,checkNull(rs.getString(4)).trim(),"String"); //SUPP_MFG_CODE
createCell(wb,row, 4,cellStyleLeft,checkNull(rs.getString(5)).trim(),"String"); //SUPP_NAME
createCell(wb,row, 5,cellStyleRight,checkZero(rs.getString(6)).trim(),"String"); //DAYS
createCell(wb,row, 6,cellStyleLeft,checkNull(rs.getString(7)).trim(),"String"); //ITEM_SER
createCell(wb,row, 7,cellStyleLeft,checkNull(rs.getString(8)).trim(),"String"); //ITEM_CODE
createCell(wb,row, 8,cellStyleLeft,checkNull(rs.getString(9)).trim(),"String"); //ITEM_DESCR
createCell(wb,row, 9,cellStyleLeft,checkNull(rs.getString(10)).trim(),"String"); //LOT_NO
createCell(wb,row, 10,cellStyleLeft,checkNull(rs.getString(11)).trim(),"String"); //UNIT
createCell(wb,row, 11,cellStyleRight,checkZero(rs.getString(12)).trim(),"Number"); //QTY
createCell(wb,row, 12,cellStyleRight,checkZero(rs.getString(13)).trim(),"Number"); //RATE
createCell(wb,row, 13,cellStyleRight,checkZero(rs.getString(14)).trim(),"Number"); //VALUE
createCell(wb,row, 14,cellStyleLeft,checkNull(rs.getString(15)).trim(),"String"); //MFG_DATE
createCell(wb,row, 15,cellStyleLeft,checkNull(rs.getString(16)).trim(),"String"); //EXPIRY_DATE
index++;
}
excelFileName = exportPDFPath+excelFileName+".xls";
System.out.println("excelFileName in getExcelGenerate :"+excelFileName);
FileOutputStream out = new FileOutputStream(excelFileName);
wb.write(out);
out.close();
}catch (Exception e)
{
System.out.println("Exception :PendingQCPurchaseOrder :getExcelGenerate(String city, String siteCode, String dataSourceName :"+e.getMessage());
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 d)
{
d.printStackTrace();
System.out.println("Exception in PendingQCPurchaseOrder.getPendingManualQCExcelGenerate" + d.getMessage());
throw new ITMException(d);
}
}
}
}
......@@ -10,8 +10,10 @@ import org.json.simple.JSONObject;
@Local
public interface PendingQCPurchaseOrderLocal
{
public JSONObject getPendingQCOrderPurchase(String itemSer, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingQCOrderPurchaseGrid(String itemSer, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingQCOrderPurchase(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingQCOrderPurchaseGrid(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingManualQCOrder(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingManualQCOrderGrid(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public String getPDFByScheduler(String rptTitle,String remark,String userID, String imgName, String city, String siteCode) throws RemoteException, ITMException;
}
......@@ -10,8 +10,10 @@ import org.json.simple.JSONObject;
@Remote
public interface PendingQCPurchaseOrderRemote
{
public JSONObject getPendingQCOrderPurchase(String itemSer, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingQCOrderPurchaseGrid(String itemSer, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingQCOrderPurchase(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingQCOrderPurchaseGrid(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingManualQCOrder(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public JSONObject getPendingManualQCOrderGrid(String geoLocation, String siteCode, String dataSourceName)throws RemoteException, ITMException;
public String getPDFByScheduler(String rptTitle,String remark,String userID, String imgName, String city, String siteCode) throws RemoteException, ITMException;
}
......@@ -14,16 +14,24 @@ import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.ResultSetMetaData;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import javax.ejb.Stateless;
import org.apache.poi.hssf.usermodel.HSSFCell;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFRow;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.json.simple.JSONObject;
import com.lowagie.text.Document;
......@@ -68,53 +76,98 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
dashboardUtility = new DashboardUtility();
siteCode = dashboardUtility.getCommaSeparated(siteCode);
geoLocation= dashboardUtility.getCommaSeparated(geoLocation);
if(geoLocation.trim().length()>0 && geoLocation!=null && siteCode!=null && siteCode.trim().length()>0)
{
sql = " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,PRODUCTION_VALUE " +
" FROM ( SELECT z.NO_OF_DAYS AS NO_OF_DAYS,z.ITEM_SER " +
" AS ITEM_SER,SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, z.CHK_VAL " +
" AS CHK_VAL,sum(z.production_value) as Production_Value " +
" FROM( SELECT ITEM.ITEM_SER, CASE WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY')" +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<90 THEN '>0-90 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<180 THEN '>90-180 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<365 THEN '>180-365 days'" +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>365 THEN '>365 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
" THEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY') END NO_OF_DAYS,COUNT(DISTINCT QC_ORDER.QORDER_NO) NO_OF_OPEN_QCORDER, " +
" (CASE WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 90 THEN 1 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 180 THEN 2 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 180 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 365 " +
" THEN 3 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 365 THEN 4 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
" THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
" AS CHK_VAL, sum(d.ACTUAL_PROD_VALUE) as production_value FROM WORKORDER_RECEIPT,ITEM,qc_order,WORKORDER,dwh_production d " +
" WHERE (WORKORDER_RECEIPT.ITEM_CODE = ITEM.ITEM_CODE) " +
" AND workorder_RECEIPT.site_code in(" + siteCode + ") " +
" AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER " +
" AND WORKORDER.ORDer_TYPE IN ('F','I','R','X','T') " +
" AND WORKORDER_RECEIPT.CONFIRMED='Y'" +
" AND workorder_receipt.lot_no=qc_order.lot_no " +
" AND workorder_receipt.tran_id=qc_order.porcp_no " +
" AND workorder_receipt.item_code=qc_order.item_code " +
" AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_order " +
" GROUP BY WORKORDER_RECEIPT.TRAN_DATE, ITEM.ITEM_SER ORDER BY CHK_VAL,no_of_days,ITEM.ITEM_SER) z " +
" GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC ";
/*sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL, ROUND((PRODUCTION_VALUE)/100000,3) As PRODUCTION_VALUE " +
" FROM ( SELECT z.NO_OF_DAYS AS NO_OF_DAYS,z.ITEM_SER AS ITEM_SER,SUM(z.NO_OF_OPEN_QCORDER) " +
" AS NO_OF_OPEN_QCORDER, z.CHK_VAL AS CHK_VAL,sum(z.production_value) " +
" as Production_Value FROM( SELECT ITEM.ITEM_SER, CASE " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<90 " +
" THEN '>0-90 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<180 " +
" THEN '>90-180 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<365 " +
" THEN '>180-365 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>365 THEN '>365 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
" THEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY') " +
" END NO_OF_DAYS,COUNT(DISTINCT QC_ORDER.QORDER_NO) NO_OF_OPEN_QCORDER, " +
" (CASE WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 90 THEN 1 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 180 " +
" THEN 2 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 180 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 365 THEN 3 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 365 THEN 4 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
" THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
" AS CHK_VAL, sum(d.ACTUAL_PROD_VALUE) as production_value " +
"FROM WORKORDER_RECEIPT,ITEM,qc_order,WORKORDER,dwh_production d,site e " +
" WHERE (WORKORDER_RECEIPT.ITEM_CODE = ITEM.ITEM_CODE) " +
" AND workorder_RECEIPT.site_code in("+siteCode+") " +
" and workorder_receipt.site_code=e.site_code " +
" and e.city in("+geoLocation+") " +
" AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER " +
" AND WORKORDER_RECEIPT.CONFIRMED='Y' " +
" AND workorder_receipt.lot_no=qc_order.lot_no " +
" AND workorder_receipt.tran_id=qc_order.porcp_no " +
" AND workorder_receipt.item_code=qc_order.item_code " +
" AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_order " +
" GROUP BY WORKORDER_RECEIPT.TRAN_DATE, ITEM.ITEM_SER " +
" ORDER BY CHK_VAL,no_of_days,ITEM.ITEM_SER) z " +
" GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) " +
" ORDER BY CHK_VAL ASC ";*/
sql = "SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,ROUND((PRODUCTION_VALUE)/100000,3) As PRODUCTION_VALUE " +
"FROM ( SELECT z.NO_OF_DAYS AS NO_OF_DAYS,z.ITEM_SER AS ITEM_SER,SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, " +
"z.CHK_VAL AS CHK_VAL,sum(z.production_value) as Production_Value FROM( SELECT SITEITEM.ITEM_SER, " +
"CASE WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=0 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<90 " +
"THEN '>0-90 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<180 " +
"THEN '>90-180 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<365 " +
"THEN '>180-365 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>365 THEN '>365 days' " +
"WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
"THEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY') END NO_OF_DAYS,COUNT(DISTINCT QC_ORDER.QORDER_NO) NO_OF_OPEN_QCORDER, " +
"(CASE WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 0 " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 90 " +
"THEN 1 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 90 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 180 " +
"THEN 2 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 180 " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 365 THEN 3 " +
"WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 365 THEN 4 " +
"WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
"THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
"AS CHK_VAL, sum(d.ACTUAL_PROD_VALUE) as production_value " +
"FROM WORKORDER_RECEIPT,SITEITEM,qc_order,WORKORDER,dwh_production d," +
"site e WHERE (WORKORDER_RECEIPT.ITEM_CODE = SITEITEM.ITEM_CODE) " +
"AND workorder_RECEIPT.site_code in("+siteCode+") " +
"and workorder_receipt.site_code=e.site_code " +
"and e.city in("+geoLocation+") " +
"AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER AND WORKORDER_RECEIPT.CONFIRMED='Y' " +
"AND workorder_receipt.lot_no=qc_order.lot_no AND workorder_receipt.tran_id=qc_order.porcp_no " +
"AND workorder_receipt.item_code=qc_order.item_code AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_order " +
"GROUP BY WORKORDER_RECEIPT.TRAN_DATE, SITEITEM.ITEM_SER ORDER BY CHK_VAL,no_of_days,SITEITEM.ITEM_SER) z " +
"GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC";
pstmt = conn.prepareStatement(sql);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
String noOfOpenQCOrderVal="";
String productionVal="";
......@@ -182,6 +235,8 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
}
}
System.out.println("sortedGraphDataMap: "+sortedGraphDataMap);
rowData = new JSONObject();
String noDays="",qcOrd="";
String subType1="",prvsubType1="";
......@@ -218,7 +273,7 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
catValues.put(noDays,qcOrd);
catGimValues.put(noDays,value);
}
if(!("").equals(prvsubType1) && ! prvsubType1.equals(subType1))
else if(!("").equals(prvsubType1) && ! prvsubType1.equals(subType1))
{
rowData.put("month",cnt);
rowData.put("product_category",prvsubType1);
......@@ -236,8 +291,8 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
}
if(cnt==sortedGraphDataMap.size())
{
rowData.put("month",cnt);
rowData.put("product_category",prvsubType1);
rowData.put("month",++cnt);
rowData.put("product_category",subType1);
rowData.put("category_value",catValues);
rowData.put("category_gimvalue",catGimValues);
rowDataPendingQCWorkOrder.put(count, rowData);
......@@ -250,7 +305,7 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
/*Document document = new Document();
String subtype = "";
PdfWriter.getInstance(document,new FileOutputStream("/home/base/Desktop/HelloWorld-Table.pdf"));
PdfWriter.getInstance(document,new FileOutputStream("/home/support-1/Desktop/HelloWorld-Table.pdf"));
JSONObject fetchRowWiseValJsn = null;
document.open();
PdfPTable table = null; // 3 columns.
......@@ -258,14 +313,15 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
PdfPCell cell2 = null;
PdfPCell cell3 = null;
// LinkedHashMap<String, Integer> catValues = null;
LinkedHashMap<String, String> catGimValues = null;
DecimalFormat df = new DecimalFormat("#.###");
List<String> valList = new ArrayList<String>();
for (int jsnCnt = 0; jsnCnt < rowDataPendingQCOrderPurc.size(); jsnCnt++)
HashMap<Integer, String> totalMap = new HashMap<Integer, String>();
for (int jsnCnt = 0; jsnCnt < rowDataPendingQCWorkOrder.size(); jsnCnt++)
{
catGimValues = new LinkedHashMap<String, String>();
fetchRowWiseValJsn = new JSONObject();
fetchRowWiseValJsn = (JSONObject) rowDataPendingQCOrderPurc.get(jsnCnt);
fetchRowWiseValJsn = (JSONObject) rowDataPendingQCWorkOrder.get(jsnCnt);
subtype = ""+fetchRowWiseValJsn.get("product_category");
System.out.println("subtype :"+subtype);
......@@ -300,7 +356,7 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph("Open QC Order Count", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("GIM Value", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("Production Value In Lacs", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
......@@ -326,8 +382,8 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
noOfQC = temp[0].trim();
gimVal = temp[1].trim();
total = Double.parseDouble(noOfQC) + Double.parseDouble(gimVal);
System.out.println("noOfQC :"+noOfQC+"---- gimVal :"+gimVal);
String totalStrVal = "";
System.out.println("noOfQC :"+noOfQC+"---- productionVal :"+gimVal);
cell2 = new PdfPCell(new Paragraph(noOfQC, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph(gimVal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
......@@ -337,23 +393,41 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
table.addCell(cell2);
table.addCell(cell3);
if(count == jsnCnt && jsnCnt == 0)
{
valList.add(""+total);
}
else if(count >=0 && count<catValues.size())
{
double sum = total + Double.parseDouble(valList.get(count));
valList.set(count, df.format(sum));
count++;
}
if(jsnCnt == 0)
{
totalStrVal = noOfQC+"@"+gimVal;
totalMap.put(count, totalStrVal);
count++;
System.out.println("totalMap in if:"+totalMap);
}
else
{
totalStrVal = totalMap.get(count);
System.out.println("str in else :"+totalStrVal);
String[] totalStrValArr;
totalStrValArr = totalStrVal.split("@");
String noOfQC1 = totalStrValArr[0].trim();
String gimVal1 = totalStrValArr[1].trim();
int noOfQCTotal = Integer.parseInt(noOfQC) + Integer.parseInt(noOfQC1);
double gimValTotal = Double.parseDouble(gimVal) + Double.parseDouble(gimVal1);
totalStrVal = ""+noOfQCTotal+"@"+""+gimValTotal;
System.out.println("str in else:"+totalStrVal);
totalMap.put(count, totalStrVal);
count++;
}
}
table.setWidthPercentage(100);
document.add(table);
}
System.out.println("valList :"+valList);
table = new PdfPTable(catValues.size()* 2 +1);
System.out.println("totalMap :"+totalMap)toMailId = "birendra.pandey@baseinformation.com";
ccMailId = "dhanendra.kasliwal@baseinformation.com";
bccAddress = "";;
table = new PdfPTable(catGimValues.size()* 2 +1);
cell1 = new PdfPCell(new Paragraph("TOTAL", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
table.addCell(cell1);
for (int i=0; i<valList.size(); i++)
......@@ -364,13 +438,31 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
table.addCell(cell2);
}
for (Map.Entry<Integer, String> entry : totalMap.entrySet())
{
String val = entry.getValue();
String[] temp;
String noOfQC = "";
String gimVal = "";
temp = val.split("@");
noOfQC = temp[0].trim();
gimVal = temp[1].trim();
cell2 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(noOfQC)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell3 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(gimVal)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
}
table.setWidthPercentage(100);
document.add(table);
document.close();
System.out.println("PDF Create Successfully");*/
}
catch (Exception e)
{
......@@ -420,53 +512,98 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
int count = 0;
dashboardUtility = new DashboardUtility();
siteCode = dashboardUtility.getCommaSeparated(siteCode);
geoLocation= dashboardUtility.getCommaSeparated(geoLocation);
if(geoLocation.trim().length()>0 && geoLocation!=null && siteCode!=null && siteCode.trim().length()>0)
{
sql = " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,PRODUCTION_VALUE " +
" FROM ( SELECT z.NO_OF_DAYS AS NO_OF_DAYS,z.ITEM_SER " +
" AS ITEM_SER,SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, z.CHK_VAL " +
" AS CHK_VAL,sum(z.production_value) as Production_Value " +
" FROM( SELECT ITEM.ITEM_SER, CASE WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY')" +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<90 THEN '>0-90 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<180 THEN '>90-180 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<365 THEN '>180-365 days'" +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>365 THEN '>365 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
" THEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY') END NO_OF_DAYS,COUNT(DISTINCT QC_ORDER.QORDER_NO) NO_OF_OPEN_QCORDER, " +
" (CASE WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 90 THEN 1 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 180 THEN 2 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 180 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 365 " +
" THEN 3 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 365 THEN 4 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
" THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
" AS CHK_VAL, sum(d.ACTUAL_PROD_VALUE) as production_value FROM WORKORDER_RECEIPT,ITEM,qc_order,WORKORDER,dwh_production d " +
" WHERE (WORKORDER_RECEIPT.ITEM_CODE = ITEM.ITEM_CODE) " +
" AND workorder_RECEIPT.site_code in(" + siteCode + ") " +
" AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER " +
" AND WORKORDER.ORDer_TYPE IN ('F','I','R','X','T') " +
" AND WORKORDER_RECEIPT.CONFIRMED='Y'" +
" AND workorder_receipt.lot_no=qc_order.lot_no " +
" AND workorder_receipt.tran_id=qc_order.porcp_no " +
" AND workorder_receipt.item_code=qc_order.item_code " +
" AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_order " +
" GROUP BY WORKORDER_RECEIPT.TRAN_DATE, ITEM.ITEM_SER ORDER BY CHK_VAL,no_of_days,ITEM.ITEM_SER) z " +
" GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC ";
/* sql= " SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,ROUND((PRODUCTION_VALUE)/100000,3) As PRODUCTION_VALUE " +
" FROM ( SELECT z.NO_OF_DAYS AS NO_OF_DAYS,z.ITEM_SER AS ITEM_SER,SUM(z.NO_OF_OPEN_QCORDER) " +
" AS NO_OF_OPEN_QCORDER, z.CHK_VAL AS CHK_VAL,sum(z.production_value) " +
" as Production_Value FROM( SELECT ITEM.ITEM_SER, CASE " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<90 " +
" THEN '>0-90 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<180 " +
" THEN '>90-180 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<365 " +
" THEN '>180-365 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>365 THEN '>365 days' " +
" WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
" THEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY') " +
" END NO_OF_DAYS,COUNT(DISTINCT QC_ORDER.QORDER_NO) NO_OF_OPEN_QCORDER, " +
" (CASE WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 0 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 90 THEN 1 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 90 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 180 " +
" THEN 2 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 180 " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 365 THEN 3 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
" AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 365 THEN 4 " +
" WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
" THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
" AS CHK_VAL, sum(d.ACTUAL_PROD_VALUE) as production_value FROM WORKORDER_RECEIPT,ITEM,qc_order,WORKORDER,dwh_production d,site e " +
" WHERE (WORKORDER_RECEIPT.ITEM_CODE = ITEM.ITEM_CODE) " +
" AND workorder_RECEIPT.site_code in("+siteCode+") " +
" and workorder_receipt.site_code=e.site_code " +
" and e.city in("+geoLocation+") " +
" AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER " +
" AND WORKORDER_RECEIPT.CONFIRMED='Y' " +
" AND workorder_receipt.lot_no=qc_order.lot_no " +
" AND workorder_receipt.tran_id=qc_order.porcp_no " +
" AND workorder_receipt.item_code=qc_order.item_code " +
" AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_order " +
" GROUP BY WORKORDER_RECEIPT.TRAN_DATE, ITEM.ITEM_SER " +
" ORDER BY CHK_VAL,no_of_days,ITEM.ITEM_SER) z " +
" GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) " +
" ORDER BY CHK_VAL ASC ";*/
sql = "SELECT no_of_days, ITEM_SER, NO_OF_OPEN_QCORDER, CHK_VAL,ROUND((PRODUCTION_VALUE)/100000,3) As PRODUCTION_VALUE " +
"FROM ( SELECT z.NO_OF_DAYS AS NO_OF_DAYS,z.ITEM_SER AS ITEM_SER,SUM(z.NO_OF_OPEN_QCORDER) AS NO_OF_OPEN_QCORDER, " +
"z.CHK_VAL AS CHK_VAL,sum(z.production_value) as Production_Value FROM( SELECT SITEITEM.ITEM_SER, " +
"CASE WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=0 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<90 " +
"THEN '>0-90 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<180 " +
"THEN '>90-180 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>=90 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)<365 " +
"THEN '>180-365 days' WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')= TO_CHAR(SYSDATE,'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE)>365 THEN '>365 days' " +
"WHEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY')<> TO_CHAR(SYSDATE,'YYYY') " +
"THEN TO_CHAR(WORKORDER_RECEIPT.TRAN_DATE,'YYYY') END NO_OF_DAYS,COUNT(DISTINCT QC_ORDER.QORDER_NO) NO_OF_OPEN_QCORDER, " +
"(CASE WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 0 " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 90 " +
"THEN 1 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 90 AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 180 " +
"THEN 2 WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 180 " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) < 365 THEN 3 " +
"WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') = TO_CHAR (SYSDATE, 'YYYY') " +
"AND TRUNC (TRUNC (SYSDATE) - WORKORDER_RECEIPT.TRAN_DATE) >= 365 THEN 4 " +
"WHEN TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY') <> TO_CHAR (SYSDATE, 'YYYY') " +
"THEN TO_NUMBER ( 4 + ABS ( TO_NUMBER (TO_CHAR (WORKORDER_RECEIPT.TRAN_DATE, 'YYYY' ) ) - TO_NUMBER (TO_CHAR (SYSDATE, 'YYYY')) ) ) ELSE 0 END) " +
"AS CHK_VAL, sum(d.ACTUAL_PROD_VALUE) as production_value " +
"FROM WORKORDER_RECEIPT,SITEITEM,qc_order,WORKORDER,dwh_production d," +
"site e WHERE (WORKORDER_RECEIPT.ITEM_CODE = SITEITEM.ITEM_CODE) " +
"AND workorder_RECEIPT.site_code in("+siteCode+") " +
"and workorder_receipt.site_code=e.site_code " +
"and e.city in("+geoLocation+") " +
"AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER AND WORKORDER_RECEIPT.CONFIRMED='Y' " +
"AND workorder_receipt.lot_no=qc_order.lot_no AND workorder_receipt.tran_id=qc_order.porcp_no " +
"AND workorder_receipt.item_code=qc_order.item_code AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_order " +
"GROUP BY WORKORDER_RECEIPT.TRAN_DATE, SITEITEM.ITEM_SER ORDER BY CHK_VAL,no_of_days,SITEITEM.ITEM_SER) z " +
"GROUP BY z.no_of_days,z.ITEM_SER,z.CHK_VAL ORDER BY z.ITEM_SER) ORDER BY CHK_VAL ASC";
pstmt = conn.prepareStatement(sql);
......@@ -532,10 +669,11 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
String imageName = null;
Image image = null;
File attachFile = null;
File attachExcleFile = null;
String imgFilePath =null;
File existImgFile =null;
String pdfFileName =null;
String excelFileName = null;
String toMailId ="";
String ccMailId ="";
String bccAddress ="";
......@@ -560,10 +698,21 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
JSONObject fetchRowWiseValJsn = null;
JSONObject rowDataforGrid = null;
List<String> valList = new ArrayList<String>();
//List<String> valList = new ArrayList<String>();
int count = 0;
LinkedHashMap<String, String> catGimValues = null;
DecimalFormat df = new DecimalFormat("#.###");
HashMap<Integer, String> totalMap = new HashMap<Integer, String>();
String noOfQC = "";
String productionVal = "";
String totalStrVal = "";
String val = "";
int noOfQCTotal = 0;
double gimValTotal = 0.0;
String noOfQCPrev = "";
String productionValPrev = "";
System.out.print("Calling for PDF created step1");
try
{
......@@ -573,6 +722,7 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
rowDataforGrid = this.getPendingQCWorkOrder(city, siteCode, "DriverITM");
System.out.println("rowDataforGrid in getPDFByScheduler :"+rowDataforGrid);
this.getExcelGenerate(city, siteCode, "DriverITM");
//START CODE FOR WINDOWS
//exportPDFPath ="C://jboss-5.1.0.GA//server//default//deploy//ibase.ear//ibase.war//dashboard//mfg//Scheduler//ExportExample//ExportPDF//";
......@@ -588,12 +738,15 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
calendar = Calendar.getInstance();
currDate = simpleDateFormat.format(calendar.getTime());
document = new Document();
//rptTitle = rptTitle+"-"+currDate;
rptTitle = rptTitle+" ("+siteCode+")"+" Pending QC Against Workorder Receipt as on " +currDate;
rptTitle = city+" ("+siteCode+")"+" Pending QC Against Workorder Receipt as on " +currDate;
System.out.println("rptTitle in PendingQCWorkOrderGrid getPDFByScheduler :"+rptTitle);
pdfFileName = exportPDFPath+rptTitle+".pdf";
excelFileName = exportPDFPath+rptTitle+".xls";
System.out.println("excelFileName :"+excelFileName);
System.out.println("modify PDF file name "+ pdfFileName+"current date formate==="+currDate);
file = new FileOutputStream(new File(pdfFileName));
......@@ -681,7 +834,7 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
cell2 = new PdfPCell(new Paragraph("Open QC Order Count", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("Production Value", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph("Production Value Rs(In Lacs)", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
......@@ -697,28 +850,25 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
for (Map.Entry<String, String> entry : catGimValues.entrySet())
{
String val = entry.getValue();
val = entry.getValue();
String[] temp;
String noOfQC = "";
String gimVal = "";
double total= 0.0;
noOfQC = "";
productionVal = "";
temp = val.split("-");
noOfQC = temp[0].trim();
gimVal = temp[1].trim();
total = Double.parseDouble(noOfQC) + Double.parseDouble(gimVal);
System.out.println("noOfQC :"+noOfQC+"---- gimVal :"+gimVal);
productionVal = temp[1].trim();
//System.out.println("noOfQC :"+noOfQC+"---- productionVal :"+productionVal);
cell2 = new PdfPCell(new Paragraph(noOfQC, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph(gimVal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell3 = new PdfPCell(new Paragraph(productionVal, FontFactory.getFont(FontFactory.TIMES_ROMAN, 6)));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
if(count == jsnCnt && jsnCnt == 0)
/*if(count == jsnCnt && jsnCnt == 0)
{
valList.add(""+total);
}
......@@ -727,7 +877,32 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
double sum = total + Double.parseDouble(valList.get(count));
valList.set(count, df.format(sum));
count++;
}
}*/
if(jsnCnt == 0)
{
totalStrVal = noOfQC+"@"+productionVal;
totalMap.put(count, totalStrVal);
count++;
}
else
{
noOfQCTotal = 0;
gimValTotal = 0.0;
noOfQCPrev = "";
productionValPrev = "";
totalStrVal = totalMap.get(count);
String[] totalStrValArr;
totalStrValArr = totalStrVal.split("@");
noOfQCPrev = totalStrValArr[0].trim();
productionValPrev = totalStrValArr[1].trim();
noOfQCTotal = Integer.parseInt(noOfQC) + Integer.parseInt(noOfQCPrev);
gimValTotal = Double.parseDouble(productionVal) + Double.parseDouble(productionValPrev);
totalStrVal = ""+noOfQCTotal+"@"+""+gimValTotal;
totalMap.put(count, totalStrVal);
count++;
}
}
table.setWidthPercentage(100);
document.add(table);
......@@ -735,11 +910,10 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
}
/*Add code for total by Dhanendra on 08-09-15*/
System.out.println("valList :"+valList);
table = new PdfPTable(catGimValues.size()* 2 +1);
table = new PdfPTable(catGimValues.size()* 2 +1);
cell1 = new PdfPCell(new Paragraph("TOTAL", FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
table.addCell(cell1);
for (int i=0; i<valList.size(); i++)
/*for (int i=0; i<valList.size(); i++)
{
cell2 = new PdfPCell(new Paragraph(""+valList.get(i), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell2.setColspan(2);
......@@ -747,6 +921,26 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
table.addCell(cell2);
}*/
System.out.println("totalMap in getPendingQCWorkOrder :"+totalMap);
for (Map.Entry<Integer, String> entry : totalMap.entrySet())
{
val = entry.getValue();
String[] tempArr;
noOfQC = "";
productionVal = "";
tempArr = val.split("@");
noOfQC = tempArr[0].trim();
productionVal = tempArr[1].trim();
cell2 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(noOfQC)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell3 = new PdfPCell(new Paragraph(df.format(Double.parseDouble(productionVal)), FontFactory.getFont(FontFactory.TIMES_ROMAN, 6,Font.BOLD, new Color(255,0,0))));
cell2.setHorizontalAlignment(Element.ALIGN_CENTER);
cell3.setHorizontalAlignment(Element.ALIGN_CENTER);
table.addCell(cell2);
table.addCell(cell3);
}
table.setWidthPercentage(100);
document.add(table);
......@@ -755,64 +949,56 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
document.close();
file.close();
System.out.println("PDF Created succesfully in PendingQCWorkOrderGrid getPDFByScheduler");
System.out.println("PDF Created succesfully in getPendingQCWorkOrder getPDFByScheduler");
conn = connDriver.getConnectDB("DriverITM");
connDriver =null;
toMailId ="";
ccMailId ="";
bccAddress ="";
subject =rptTitle;
userWiseBodytext ="Dear Sir, Please find attached here with 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);
}*/
connDriver =null;
toMailId ="";
ccMailId ="";
bccAddress ="";
subject =rptTitle;
userWiseBodytext ="Dear Sir, Please find attached here with is the Weekly Output:"+rptTitle+" Report in PDF format.";
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);
}*/
city = "PQCPAR_"+city.trim();
System.out.println("Add PQCPAR 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 PendingQCWorkOrder.getPDFByScheduler city = "+city+" --- toMailId ="+toMailId +"AND According to the ccMailId ======="+ccMailId+"---- bccAddress == "+bccAddress);
}
toMailId = "Julian.Soares@sunpharma.com,Bhaumik.Joshi@sunpharma.com,Jigar.Gohil@sunpharma.com";
ccMailId = "";
bccAddress = "";
/*toMailId = "dhanendra.kasliwal@baseinformation.com,nikhil.sawalakhe@baseinformation.com";
ccMailId = "";
bccAddress = "";*/
System.out.println("Export Pdf path for PendingQCPurchaseOrder.getPDFByScheduler ="+pdfFileName);
attachFile = new File(pdfFileName);
if(attachFile.exists() && attachFile.length()>0)
{
mailInfo =new ArrayList<String>();
mailInfo.add(toMailId);
mailInfo.add(ccMailId);
mailInfo.add(bccAddress);
mailInfo.add(subject);
mailInfo.add(userWiseBodytext);
mailInfo.add(attachFile.getPath());
this.sendingMail(mailInfo);
resultFlage="true";
}
System.out.println("*sending mail done succesfully for WIPStatus.getPDFByScheduler*");
/*toMailId = "Julian.Soares@sunpharma.com,Bhaumik.Joshi@sunpharma.com,Jigar.Gohil@sunpharma.com";
ccMailId = "birendra.pandey@baseinformation.com,nikhil.sawalakhe@baseinformation.com,dhanendra.kasliwal@baseinformation.com";
bccAddress = "";*/
/*toMailId = "birendra.pandey@baseinformation.com";
ccMailId = "dhanendra.kasliwal@baseinformation.com";
bccAddress = "";*/
System.out.println("Export Pdf path for PendingQCWorkOrder.getPDFByScheduler ="+pdfFileName);
attachFile = new File(pdfFileName);
attachExcleFile = new File(excelFileName);
if(attachFile.exists() && attachFile.length()>0 && attachExcleFile.exists() && attachExcleFile.length()>0)
{
mailInfo =new ArrayList<String>();
mailInfo.add(toMailId);
mailInfo.add(ccMailId);
mailInfo.add(bccAddress);
mailInfo.add(subject);
mailInfo.add(userWiseBodytext);
mailInfo.add(attachFile.getPath());
mailInfo.add(attachExcleFile.getPath());
this.sendingMail(mailInfo);
resultFlage="true";
}
System.out.println("*sending mail done succesfully for PendingQCWorkOrder.getPDFByScheduler*");
} catch (Exception e)
{
System.out.println("Exception :PendingQCWorkOrderGrid :getPDFByScheduler "+e.getMessage());
System.out.println("Exception :PendingQCWorkOrder :getPDFByScheduler "+e.getMessage());
e.printStackTrace();
}
finally
......@@ -853,15 +1039,15 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
commInfo.append("<BCC_ADD>").append("<![CDATA[" + mailInfo.get(2) + "]]>").append("</BCC_ADD>");
commInfo.append("<SUBJECT>").append("<![CDATA[" + mailInfo.get(3) + "]]>").append("</SUBJECT>");
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)+";"+ mailInfo.get(6) + "]]>").append("</XML_DATA_FILE_PATH>");
commInfo.append("</MAILINFO>");
commInfo.append("</ROOT>");
EMail email = new EMail();
try
{
System.out.println(" calling sendMail method() for PendingQCWorkOrderGrid.getPDFByScheduler");
System.out.println(" calling sendMail method() for PendingQCWorkOrder.getPDFByScheduler");
email.sendMail(commInfo.toString(), "ITM", null);
System.out.println(" ********Email send succesfully for WIPStatus.getPDFByScheduler ***********");
System.out.println(" ********Email send succesfully for PendingQCWorkOrder.getPDFByScheduler ***********");
} catch (Exception e)
{
e.printStackTrace();
......@@ -871,6 +1057,266 @@ public class PendingQCWorkOrder implements PendingQCWorkOrderLocal, PendingQCWo
}
/*End- this method add for generatePDF on 13Aug2015*/
/*Add this method for generate Excel file on Date 21-09-15 by Nikhil*/
public void getExcelGenerate(String city, String siteCode, String dataSourceName)throws RemoteException, ITMException
{
System.out.println("in getExcelGenerate PendingQCWorkOrder city :"+city+"-----siteCode :"+siteCode);
System.out.println("dataSourceName :"+dataSourceName);
String sql = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String excelFileName = null;
String exportPDFPath = "";
String currDate="";
SimpleDateFormat simpleDateFormat = null;
Calendar calendar = null;
DashboardUtility dashboardUtility = null;
try
{
conn = connDriver.getConnectDB(dataSourceName);
connDriver = null;
simpleDateFormat = new SimpleDateFormat("dd-MMM-yy");
dashboardUtility = new DashboardUtility();
calendar = Calendar.getInstance();
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;
currDate = simpleDateFormat.format(calendar.getTime());
excelFileName = city+" ("+siteCode+")"+" Pending QC Against Workorder Receipt as on " +currDate;
city = dashboardUtility.getCommaSeparated(city);
siteCode = dashboardUtility.getCommaSeparated(siteCode);
System.out.println("in getExcelGenerate after dashboardUtility city :"+city+"-----siteCode :"+siteCode);
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow(0);
HSSFCellStyle cellStyleLeft=wb.createCellStyle() ;
cellStyleLeft.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFCellStyle cellStyleRight=wb.createCellStyle() ;
cellStyleRight.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
HSSFFont font=wb.createFont();
font.setFontName("Calibri");
font.setFontHeightInPoints((short)10);
cellStyleLeft.setFont(font);
cellStyleRight.setFont(font);
/*
sql = "SELECT WORKORDER_RECEIPT.TRAN_ID, WORKORDER_RECEIPT.TRAN_DATE, WORKORDER_RECEIPT.WORK_ORDER, wORKORDER.ORDER_TYPE, " +
"WORKORDER_RECEIPT.DATE__START, WORKORDER_RECEIPT.DATE__COMPL, WORKORDER_RECEIPT.ITEM_CODE, ITEM.ITEM_SER, " +
"TRUNC(SYSDATE)-TRUNC(WORKORDER_RECEIPT.TRAN_DATE) AS DAYS, ITEM.DESCR as descr, WORKORDER_RECEIPT.lot_no, " +
"WORKORDER_RECEIPT.QUANTITY AS quantity, WORKORDER_RECEIPT.UNIT, QC_ORDER.QORDER_NO, qc_order.status as Qc_Release_Pending, " +
"sum(d.ACTUAL_PROD_VALUE) as production_value " +
"FROM WORKORDER_RECEIPT,ITEM,qc_order,WORKORDER ,dwh_production d,SITE E " +
"WHERE (WORKORDER_RECEIPT.ITEM_CODE = ITEM.ITEM_CODE) " +
"and workorder_RECEIPT.site_code IN ("+siteCode+") " +
"AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER AND WORKORDER_RECEIPT.CONFIRMED='Y' " +
"and workorder_receipt.lot_no=qc_order.lot_no and workorder_receipt.tran_id=qc_order.porcp_no " +
"and workorder_receipt.item_code=qc_order.item_code AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_ordeR " +
"AND workorder_RECEIPT.site_code=E.SITE_CODE " +
"AND E.CITY in("+city+") " +
"GROUP By WORKORDER_RECEIPT.lot_no," +
"workorder_receipt.confirmed, WORKORDER_RECEIPT.TRAN_DATE,wORKORDER.ORDER_TYPE,WORKORDER_RECEIPT.TRAN_ID, " +
"WORKORDER_RECEIPT.WORK_ORDER,WORKORDER_RECEIPT.DATE__START,WORKORDER_RECEIPT.DATE__COMPL, " +
"WORKORDER_RECEIPT.ITEM_CODE,ITEM.ITEM_SER,ITEM.DESCR,WORKORDER_RECEIPT.UNIT,QC_ORDER.QORDER_NO ," +
"qc_order.status,workorder_receipt.quantity ORDER BY WORKORDER_RECEIPT.TRAN_DATE ";
*/
sql = "SELECT WORKORDER_RECEIPT.TRAN_ID, to_char(WORKORDER_RECEIPT.TRAN_DATE,'dd/mm/yy') AS TRAN_DATE, WORKORDER_RECEIPT.WORK_ORDER, " +
"WORKORDER.ORDER_TYPE, to_char(WORKORDER_RECEIPT.DATE__START,'dd/mm/yy') AS DATE__START, to_char(WORKORDER_RECEIPT.DATE__COMPL,'dd/mm/yy') AS DATE__COMPL, WORKORDER_RECEIPT.ITEM_CODE, " +
"SITEITEM.ITEM_SER, TRUNC(SYSDATE)-TRUNC(WORKORDER_RECEIPT.TRAN_DATE) AS DAYS, ITEM.DESCR as DESCR, " +
"WORKORDER_RECEIPT.LOT_NO, WORKORDER_RECEIPT.QUANTITY AS QUANTITY, WORKORDER_RECEIPT.UNIT, QC_ORDER.QORDER_NO, " +
"qc_order.status as QC_RELEASE_PENDING, to_char(QC_ORDER.MFG_DATE,'dd/mm/yy') AS MFG_DATE, to_char(QC_ORDER.EXPIRY_DATE,'dd/mm/yy') AS EXPIRY_DATE, sum(D.ACTUAL_PROD_VALUE) as PRODUCTION_VALUE " +
"FROM WORKORDER_RECEIPT," +
"SITEITEM,qc_order,WORKORDER ,dwh_production d,SITE E,ITEM WHERE (WORKORDER_RECEIPT.ITEM_CODE = SITEITEM.ITEM_CODE) " +
"AND SITEITEM.ITEM_CODE=ITEM.ITEM_CODE " +
"and workorder_RECEIPT.site_code IN ("+siteCode+") " +
"AND WORKORDER.WORK_ORDER=WORKORDER_RECEIPT.WORK_ORDER " +
"AND WORKORDER_RECEIPT.CONFIRMED='Y' " +
"and workorder_receipt.lot_no=qc_order.lot_no " +
"and workorder_receipt.tran_id=qc_order.porcp_no and workorder_receipt.item_code=qc_order.item_code " +
"AND QC_ORDER.STATUS='U' and d.work_order=workorder.work_ordeR " +
"AND workorder_RECEIPT.site_code=E.SITE_CODE " +
"AND E.CITY in("+city+") " +
"GROUP By WORKORDER_RECEIPT.lot_no,workorder_receipt.confirmed, " +
"WORKORDER_RECEIPT.TRAN_DATE,wORKORDER.ORDER_TYPE,WORKORDER_RECEIPT.TRAN_ID, " +
"WORKORDER_RECEIPT.WORK_ORDER,WORKORDER_RECEIPT.DATE__START,WORKORDER_RECEIPT.DATE__COMPL, " +
"WORKORDER_RECEIPT.ITEM_CODE,SITEITEM.ITEM_SER,ITEM.DESCR,WORKORDER_RECEIPT.UNIT,QC_ORDER.QORDER_NO ," +
"qc_order.status,workorder_receipt.quantity,QC_ORDER.MFG_DATE,QC_ORDER.EXPIRY_DATE ORDER BY WORKORDER_RECEIPT.TRAN_DATE";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
ResultSetMetaData rsmtdt= rs.getMetaData();
int columncount=rsmtdt.getColumnCount();
int index = 0;
boolean flag=true;
HSSFRow row=null;
while(rs.next())
{
//System.out.println("index :"+index);
row = sheet.createRow(index);
if(flag)
{
for(int i=1;i<=columncount;i++)
{
createCell(wb, rowhead, i-1,cellStyleLeft, rsmtdt.getColumnLabel(i), "String");
}
flag=false;
index++;
row = sheet.createRow(index);
}
/*for(int i=1;i<=columncount;i++)
{
if(isNumeric(checkNull(rs.getString(i)).trim()))
{
if("QUANTITY".equalsIgnoreCase(rsmtdt.getColumnLabel(i)))
{
createCell(wb,row, i-1,cellStyleRight,checkNull(rs.getString(i)).trim(),"Number");
}else if("PRODUCTION_VALUE".equalsIgnoreCase(rsmtdt.getColumnLabel(i)))
{
createCell(wb,row, i-1,cellStyleRight,checkNull(rs.getString(i)).trim(),"Number");
}
else if("DAYS".equalsIgnoreCase(rsmtdt.getColumnLabel(i)))
{
HSSFCell cell = row.createCell((short) (i-1), HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(rs.getLong(i));
}else
{
createCell(wb,row, i-1,cellStyleLeft,checkNull(rs.getString(i)).trim(),"String");
}
}else
{
createCell(wb,row, i-1,cellStyleLeft,checkNull(rs.getString(i)).trim(),"String");
}
}*/
createCell(wb,row, 0,cellStyleLeft,checkNull(rs.getString(1)).trim(),"String"); //TRAN_ID
createCell(wb,row, 1,cellStyleLeft,checkNull(rs.getString(2)).trim(),"String"); //TRAN_DATE
createCell(wb,row, 2,cellStyleLeft,checkNull(rs.getString(3)).trim(),"String"); //WORK_ORDER
createCell(wb,row, 3,cellStyleLeft,checkNull(rs.getString(4)).trim(),"String"); //ORDER_TYPE
createCell(wb,row, 4,cellStyleLeft,checkNull(rs.getString(5)).trim(),"String"); //DATE__START
createCell(wb,row, 5,cellStyleLeft,checkNull(rs.getString(6)).trim(),"String"); //DATE__COMPL
createCell(wb,row, 6,cellStyleLeft,checkNull(rs.getString(7)).trim(),"String"); //ITEM_CODE
createCell(wb,row, 7,cellStyleLeft,checkNull(rs.getString(8)).trim(),"String"); //ITEM_SER
createCell(wb,row, 8,cellStyleRight,checkZero(rs.getString(9)).trim(),"String"); //DAYS
createCell(wb,row, 9,cellStyleLeft,checkNull(rs.getString(10)).trim(),"String"); //DESCR
createCell(wb,row, 10,cellStyleLeft,checkNull(rs.getString(11)).trim(),"String"); //LOT_NO
createCell(wb,row, 11,cellStyleRight,checkZero(rs.getString(12)).trim(),"Number"); //QUANTITY
createCell(wb,row, 12,cellStyleLeft,checkNull(rs.getString(13)).trim(),"String"); //UNIT
createCell(wb,row, 13,cellStyleLeft,checkNull(rs.getString(14)).trim(),"String"); //QORDER_NO
createCell(wb,row, 14,cellStyleLeft,checkNull(rs.getString(15)).trim(),"String"); //QC_RELEASE_PENDING
createCell(wb,row, 15,cellStyleLeft,checkNull(rs.getString(16)).trim(),"String"); //MFG_DATE
createCell(wb,row, 16,cellStyleLeft,checkNull(rs.getString(17)).trim(),"String"); //EXPIRY_DATE
createCell(wb,row, 17,cellStyleRight,checkZero(rs.getString(18)).trim(),"Number"); //PRODUCTION_VALUE
index++;
}
excelFileName = exportPDFPath+excelFileName+".xls";
System.out.println("excelFileName in getExcelGenerate :"+excelFileName);
FileOutputStream out = new FileOutputStream(excelFileName);
wb.write(out);
out.close();
}catch (Exception e)
{
System.out.println("Exception :PendingQCWorkOrder :getExcelGenerate(String city, String siteCode, String dataSourceName :"+e.getMessage());
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 d)
{
d.printStackTrace();
System.out.println("Exception in PendingQCWorkOrder.getPDFByScheduler" + d.getMessage());
throw new ITMException(d);
}
}
}
@SuppressWarnings("deprecation")
private void createCell(HSSFWorkbook wb, HSSFRow row, int column, HSSFCellStyle cellStyle, String data, String dataType)
{
HSSFCell cell = null;
if("String".equalsIgnoreCase(dataType))
{
cell = row.createCell((short) column, HSSFCell.CELL_TYPE_STRING);
cell.setCellValue(data);
}
if("Number".equalsIgnoreCase(dataType))
{
cellStyle.setDataFormat((short)2);
cell = row.createCell((short) column, HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(Double.parseDouble(data));
}
cell.setCellStyle(cellStyle);
}
/*End this method for generate Excel file on Date 21-09-15 by Nikhil*/
private String checkNull(String str)
{
if(str == null || str == "null")
{
return "";
}
else
{
return str ;
}
}
public boolean isNumeric(String str)
{
try
{
double d = Double.parseDouble(str);
}
catch(NumberFormatException nfe)
{
return false;
}
return true;
}
private String checkZero(String str)
{
if(str == null || str.equals(null) || str.equalsIgnoreCase(""))
{
return "0";
}
else
{
return str ;
}
}
}
......
......@@ -313,7 +313,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
catValues.put(noDays,valueForGraph);
catValuesPDF.put(noDays, statusArrStr);
}
if(!("").equals(prvsubType1) && ! prvsubType1.equals(subType1))
else if(!("").equals(prvsubType1) && ! prvsubType1.equals(subType1))
{
rowData.put("month",cnt);
rowData.put("product_category",prvsubType1);
......@@ -332,8 +332,8 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
}
if(cnt==sortedGraphDataMap.size())
{
rowData.put("month",cnt);
rowData.put("product_category",prvsubType1);
rowData.put("month",++cnt);
rowData.put("product_category",subType1);
rowData.put("category_value",catValues);
rowData.put("value_pdf",catValuesPDF);
rawDataWIPStatusDtlJson.put(count, rowData);
......@@ -861,7 +861,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
currDate = simpleDateFormat.format(calendar.getTime());
document = new Document();
//rptTitle = rptTitle+"-"+currDate;
rptTitle = rptTitle+" ("+siteCode+")"+" Plant Open Work Order Status as on " +currDate;
rptTitle = city+" ("+siteCode+")"+" Plant Open Work Order Status as on " +currDate;
System.out.println("rptTitle in WIPStatus getPDFByScheduler :"+rptTitle);
......@@ -1069,11 +1069,11 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
System.out.println("No of Users for WIPStatus.getPDFByScheduler city = "+city+" --- toMailId ="+toMailId +"AND According to the ccMailId ======="+ccMailId+"---- bccAddress == "+bccAddress);
}
/*toMailId = "Julian.Soares@sunpharma.com,Bhaumik.Joshi@sunpharma.com,Jigar.Gohil@sunpharma.com,Prachi.Joshi@sunpharma.com";
ccMailId = "dhanendra.kasliwal@baseinformation.com";
/*toMailId = "Julian.Soares@sunpharma.com,Bhaumik.Joshi@sunpharma.com,Jigar.Gohil@sunpharma.com";
ccMailId = "dhanendra.kasliwal@baseinformation.com,birendra.pandey@baseinformation.com";
bccAddress = "";*/
/*toMailId = "nikhil.sawalakhe@baseinformation.com";
/*toMailId = "birendra.pandey@baseinformation.com";
ccMailId = "dhanendra.kasliwal@baseinformation.com";
bccAddress = "";*/
......@@ -1192,18 +1192,18 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
HSSFSheet sheet = wb.createSheet("Excel Sheet");
HSSFRow rowhead = sheet.createRow(0);
HSSFCellStyle cellStyleC=wb.createCellStyle() ;
cellStyleC.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFCellStyle cellStyleLeft=wb.createCellStyle() ;
cellStyleLeft.setAlignment(HSSFCellStyle.ALIGN_LEFT);
HSSFCellStyle cellStyleSR=wb.createCellStyle() ;
cellStyleSR.setAlignment(HSSFCellStyle.ALIGN_CENTER);
HSSFCellStyle cellStyleRight=wb.createCellStyle() ;
cellStyleRight.setAlignment(HSSFCellStyle.ALIGN_RIGHT);
HSSFFont font=wb.createFont();
font.setFontName("Calibri");
font.setFontHeightInPoints((short)10);
cellStyleC.setFont(font);
cellStyleSR.setFont(font);
cellStyleLeft.setFont(font);
cellStyleRight.setFont(font);
/*sql="SELECT a.site_code__mfg AS SITE_CODE, a.WORK_ORDER, a.wo_release_date AS REL_DATE, TRUNC (TRUNC (SYSDATE) - a.wo_release_date) AS NO_OF_DAYS, " +
" a.ORDER_TYPE, a.bom_sub_type AS SUB_TYPE, a.ITEM_CODE, b.ITEM_PARNT, b.descr AS ITEM_NAME, a.UNIT, a.lot_no AS BATCH_NO, " +
......@@ -1223,7 +1223,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
" AND a.work_order_status = 'R' AND b.stk_opt = '2' AND a.bom_sub_type <> 'CLEANING' " +
" AND a.wo_release_date <= TRUNC (SYSDATE) ORDER BY a.item_code, a.lot_no";*/
sql="SELECT A.SITE_CODE__MFG AS SITE_CODE, A.WORK_ORDER, A.WO_RELEASE_DATE AS REL_DATE, TRUNC(TRUNC(SYSDATE) - A.WO_RELEASE_DATE) AS NO_OF_DAYS, " +
sql="SELECT A.SITE_CODE__MFG AS SITE_CODE, A.WORK_ORDER, to_char(A.WO_RELEASE_DATE,'dd/mm/yy') AS REL_DATE, TRUNC(TRUNC(SYSDATE) - A.WO_RELEASE_DATE) AS NO_OF_DAYS, " +
"A.ORDER_TYPE, A.BOM_SUB_TYPE AS SUB_TYPE, A.ITEM_CODE, B.ITEM_PARNT, B.DESCR AS ITEM_NAME, A.UNIT, A.LOT_NO AS BATCH_NO, " +
"A.CURRENT_BATCH_SIZE, A.PRODUCTION_QTY, ((A.CURRENT_BATCH_SIZE * A.STD_YIELD_PERC/100) - A.PRODUCTION_QTY) AS WIP," +
" A.WORK_ORDER_STATUS, A.STD_YIELD_PERC, A.ACTUAL_YIELD, A.ACTUAL_PROD_VALUE AS BATCH_COST, QORDER_NO, " +
......@@ -1233,7 +1233,7 @@ 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 in("+siteCode+") " +
"AND A.WORK_ORDER_STATUS = 'R' AND B.STK_OPT = '2' AND A.BOM_SUB_TYPE <> 'CLEANING' AND a.site_code__mfg = s.site_code " +
"AND s.city IN ("+city+") AND A.WO_RELEASE_DATE <= TRUNC(SYSDATE) ORDER BY A.ITEM_CODE, A.LOT_NO";
"AND s.city IN ("+city+") AND A.WO_RELEASE_DATE <= TRUNC(SYSDATE) ORDER BY A.WO_RELEASE_DATE";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
......@@ -1252,16 +1252,44 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
{
for(int i=1;i<=columncount;i++)
{
createCell(wb, rowhead, i-1,cellStyleC, rsmtdt.getColumnLabel(i), "String");
createCell(wb, rowhead, i-1,cellStyleLeft, rsmtdt.getColumnLabel(i), "String");
}
flag=false;
index++;
row = sheet.createRow(index);
}
for(int i=1;i<=columncount;i++)
/*for(int i=1;i<=columncount;i++)
{
createCell(wb,row, i-1,cellStyleC,checkNull(rs.getString(i)).trim(),"String");
}
}*/
createCell(wb,row, 0,cellStyleLeft,checkNull(rs.getString(1)).trim(),"String"); //SITE_CODE
createCell(wb,row, 1,cellStyleLeft,checkNull(rs.getString(2)).trim(),"String"); //WORK_ORDER
createCell(wb,row, 2,cellStyleLeft,checkNull(rs.getString(3)).trim(),"String"); //REL_DATE
createCell(wb,row, 3,cellStyleRight,checkZero(rs.getString(4)).trim(),"String"); //NO_OF_DAYS
createCell(wb,row, 4,cellStyleLeft,checkNull(rs.getString(5)).trim(),"String"); //ORDER_TYPE
createCell(wb,row, 5,cellStyleLeft,checkNull(rs.getString(6)).trim(),"String"); //SUB_TYPE
createCell(wb,row, 6,cellStyleLeft,checkNull(rs.getString(7)).trim(),"String"); //ITEM_CODE
createCell(wb,row, 7,cellStyleLeft,checkNull(rs.getString(8)).trim(),"String"); //ITEM_PARNT
createCell(wb,row, 8,cellStyleLeft,checkNull(rs.getString(9)).trim(),"String"); //ITEM_NAME
createCell(wb,row, 9,cellStyleLeft,checkNull(rs.getString(10)).trim(),"String"); //UNIT
createCell(wb,row, 10,cellStyleLeft,checkNull(rs.getString(11)).trim(),"String"); //BATCH_NO
createCell(wb,row, 11,cellStyleLeft,checkNull(rs.getString(12)).trim(),"String"); //CURRENT_BATCH_SIZE
createCell(wb,row, 12,cellStyleRight,checkZero(rs.getString(13)).trim(),"Number"); //PRODUCTION_QTY
createCell(wb,row, 13,cellStyleRight,checkZero(rs.getString(14)).trim(),"Number"); //WIP
createCell(wb,row, 14,cellStyleLeft,checkNull(rs.getString(15)).trim(),"String"); //WORK_ORDER_STATUS
createCell(wb,row, 15,cellStyleRight,checkZero(rs.getString(16)).trim(),"String"); //STD_YIELD_PERC
createCell(wb,row, 16,cellStyleRight,checkZero(rs.getString(17)).trim(),"String"); //ACTUAL_YIELD
createCell(wb,row, 17,cellStyleRight,checkZero(rs.getString(18)).trim(),"Number"); //BATCH_COST
createCell(wb,row, 18,cellStyleLeft,checkNull(rs.getString(19)).trim(),"String"); //QORDER_NO
createCell(wb,row, 19,cellStyleLeft,checkNull(rs.getString(20)).trim(),"String"); //STATUS
index++;
}
......@@ -1314,7 +1342,7 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
{
cellStyle.setDataFormat((short)2);
cell = row.createCell((short) column, HSSFCell.CELL_TYPE_NUMERIC);
cell.setCellValue(Double.parseDouble(data.trim()));
cell.setCellValue(Double.parseDouble(data));
}
cell.setCellStyle(cellStyle);
}
......@@ -1331,4 +1359,16 @@ public class WIPStatus extends ValidatorEJB implements WIPStatusLocal, WIPStatus
}
}
private String checkZero(String str)
{
if(str == null || str.equals(null) || str.equalsIgnoreCase(""))
{
return "0";
}
else
{
return str ;
}
}
}
\ No newline at end of file
package ibase.dashboard.mfg.servlet;
import ibase.dashboard.mfg.ejb.PendingQCPurchaseOrderRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.simple.JSONObject;
public class PendingManualQCOrderGridServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
PendingQCPurchaseOrderRemote pendingQCOrderRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String siteCode = "";
String geoLocation = "";
try
{
System.out.println("in PendingManualQCOrderGridServlet " );
response.setContentType("application/xml");
dataSourceName = request.getParameter("dataSourceName");
siteCode = request.getParameter("sitecode");
geoLocation = request.getParameter("geoLocation");
geoLocation = geoLocation.replace("@", "&");
System.out.println("in PendingManualQCOrderGridServlet SiteCode :"+siteCode+"----geoLocation :"+geoLocation);
context = new InitialContext(appConnectParm.getProperty());
pendingQCOrderRemote = (PendingQCPurchaseOrderRemote) context.lookup("ibase/PendingQCPurchaseOrder/remote");
JSONObject jsonObjData = (JSONObject) pendingQCOrderRemote.getPendingManualQCOrderGrid(geoLocation,siteCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" in servlet Final data set for PendingManualQCOrderGridServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : PendingManualQCOrderGridServlet :doPost(HttpServletRequest request, HttpServletResponse response) :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
package ibase.dashboard.mfg.servlet;
import ibase.dashboard.mfg.ejb.PendingQCPurchaseOrderRemote;
import ibase.system.config.AppConnectParm;
import ibase.webitm.utility.ITMException;
import java.io.IOException;
import java.io.OutputStream;
import javax.naming.InitialContext;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import org.json.simple.JSONObject;
public class PendingManualQCOrderServlet extends HttpServlet
{
private static final long serialVersionUID = 1L;
public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
doPost(request, response);
}
public void doPost(HttpServletRequest request, HttpServletResponse response) throws IOException, ServletException
{
PendingQCPurchaseOrderRemote pendingQCOrderRemote = null;
InitialContext context = null;
AppConnectParm appConnectParm = new AppConnectParm();
String dataSourceName = "";
String siteCode = "";
String geoLocation = "";
try
{
System.out.println("in PendingManualQCOrderServlet " );
response.setContentType("application/xml");
dataSourceName = request.getParameter("dataSourceName");
siteCode = request.getParameter("sitecode");
geoLocation = request.getParameter("geoLocation");
geoLocation = geoLocation.replace("@", "&");
System.out.println("in PendingQCOrderPurchaseServlet SiteCode :"+siteCode+"----geoLocation :"+geoLocation);
context = new InitialContext(appConnectParm.getProperty());
pendingQCOrderRemote = (PendingQCPurchaseOrderRemote) context.lookup("ibase/PendingQCPurchaseOrder/remote");
JSONObject jsonObjData = (JSONObject) pendingQCOrderRemote.getPendingManualQCOrder(geoLocation,siteCode,dataSourceName);
OutputStream outputStream = response.getOutputStream();
outputStream.write(jsonObjData.toString().getBytes());
outputStream.flush();
outputStream.close();
System.out.println(" in servlet Final data set for PendingManualQCOrderServlet build the Graph is===" + jsonObjData);
} catch (Exception e)
{
System.out.println("Exception : PendingManualQCOrderServlet :doPost(HttpServletRequest request, HttpServletResponse response) :" + e);
try
{
throw new ITMException(e);
} catch (ITMException e1)
{
e1.printStackTrace();
}
}
}
}
\ No newline at end of file
......@@ -41,7 +41,7 @@ public class PendingQCOrderPurchaseGridServlet extends HttpServlet
dataSourceName = request.getParameter("dataSourceName");
siteCode = request.getParameter("sitecode");
geoLocation = request.getParameter("geoLocation");
geoLocation = geoLocation.replace("@", "&");
System.out.println("in PendingQCOrderPurchaseGridServlet SiteCode :"+siteCode+"----geoLocation :"+geoLocation);
......
......@@ -44,7 +44,7 @@ public class PendingQCOrderPurchaseServlet extends HttpServlet
dataSourceName = request.getParameter("dataSourceName");
siteCode = request.getParameter("sitecode");
geoLocation = request.getParameter("geoLocation");
geoLocation = geoLocation.replace("@", "&");
session.setAttribute("geoLocation", geoLocation);
session.setAttribute("siteCode", siteCode);
......
......@@ -41,7 +41,7 @@ public class PendingQCWorkOrderGridServlet extends HttpServlet
dataSourceName = request.getParameter("dataSourceName");
siteCode = request.getParameter("sitecode");
geoLocation = request.getParameter("geoLocation");
geoLocation = geoLocation.replace("@", "&");
System.out.println("in PendingQCWorkOrderGridServlet SiteCode :"+siteCode+"----geoLocation :"+geoLocation);
......
......@@ -45,7 +45,7 @@ public class PendingQCWorkOrderServlet extends HttpServlet
dataSourceName = request.getParameter("dataSourceName");
siteCode = request.getParameter("sitecode");
geoLocation = request.getParameter("geoLocation");
geoLocation = geoLocation.replace("@", "&");
session.setAttribute("geoLocation", geoLocation);
session.setAttribute("siteCode", siteCode);
......
......@@ -40,7 +40,7 @@ public class WIPStatusGridServlet extends HttpServlet
/*HttpSession session = request.getSession(true);
ibase.utility.UserInfoBean userInfo = (ibase.utility.UserInfoBean) session.getAttribute("USER_INFO");
loginId = userInfo.getLoginCode();*/
city = request.getParameter("city");
city = request.getParameter("city").replace("@", "&");
siteCode = request.getParameter("siteCode");
System.out.println("in WIPStatusGridServlet city :"+city+"====siteCode :"+siteCode);
dataSourceName = request.getParameter("dataSourceName");
......
......@@ -37,7 +37,7 @@ public class WIPStatusServlet extends HttpServlet
{
response.setContentType("application/xml");
HttpSession session = request.getSession(true);
city = request.getParameter("city");
city = request.getParameter("city").replace("@", "&");
siteCode = request.getParameter("siteCode");
dataSourceName = request.getParameter("dataSourceName");
System.out.println("in WIPStatusServlet city :"+city);
......
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