Commit 387cc9ff authored by rbhogale's avatar rbhogale

Changed by Rohan on 12-10-12 for hazmat report


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@91978 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0f93a2d0
package ibase.webitm.ejb.wms;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.reports.utility.XSDParser;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
import java.io.File;
import java.rmi.RemoteException;
import java.sql.*;
import java.util.*;
......@@ -41,6 +43,11 @@ public class ConsolidatToDoc {
ResultSet rsitem = null;
String tranMode = "";
String sqlTran = "";
String sql2 = "";
PreparedStatement pstmt2 = null;
ResultSet rs2 = null;
String target = "";
String source = "";
//Changed by Rohan on 06-10-12 to define variable for hazmap report.end
PreparedStatement pstmt = null, pstmt1 = null,pstmtHdr = null;
......@@ -95,6 +102,9 @@ public class ConsolidatToDoc {
System.out.println("dataMap====>"+dataMap);
boolean isTasksConfirmed = isAllTaskConfirmed(dataMap,conn);
ArrayList tempList = null;
//Changed by Rohan on 10-11-12 for hazmaterial report
ArrayList tempList1 = null;
if(isTasksConfirmed)
{
......@@ -320,7 +330,8 @@ public class ConsolidatToDoc {
System.out.println("Wave ID======>"+waveId);
expLev = rs.getString("EXP_LEV");
lineNoSord = rs.getString("LINE_NO__SORD");//Gulzar on 12/28/2011
//Changed by Rohan on 10-11-12 to call report in at end of despacth populate.start
/*
//Changed by Rohan on 10-06-12 to get reports for hazardous material.start
if(!key.equalsIgnoreCase("R-TASK") || !key.equalsIgnoreCase("S-DOC") || !key.equalsIgnoreCase("RS-DSO") || !key.equalsIgnoreCase("RO-DSO") || !key.equalsIgnoreCase("R-DSO") || !key.equalsIgnoreCase("R-PND") || !"RP-PND".equalsIgnoreCase(key))
{
......@@ -395,6 +406,8 @@ public class ConsolidatToDoc {
}
}
//Changed by Rohan on 10-06-12 to get reports for hazardous material.end
Changed by Rohan on 10-11-12 to call report in at end of despacth populate.end
*/
//CHANGED BY PRAGYAN 12-JUL-12 To ADD PND LOCATION
//if( key.equalsIgnoreCase("R-TASK"))
......@@ -793,6 +806,223 @@ public class ConsolidatToDoc {
System.out.println("NO OF ROW UPDATED = "+upctr);
pstmtHdr.close();
pstmtHdr = null;
System.out.println("***************START***********************");
//Changed by Rohan on 10-06-12 to get reports for hazardous material.start
Set itemList = dataMap.keySet();
Iterator itr = itemList.iterator();
while( itr.hasNext())
{
String keyList = (String)itr.next();
System.out.println("CURRENT KEY ["+keyList+"]");
if("A-PICK".equalsIgnoreCase(keyList) || "C-PICK".equalsIgnoreCase(keyList))
{
sql2 = " SELECT P.ITEM_CODE,PO.WAVE_ID "+
" FROM PICK_ISS_DET P, PICK_ORD_HDR PO , PICK_ORD_DET POD,PICK_ISS_HDR PH "+
" WHERE POD.PICK_ORDER = PO.PICK_ORDER "+
" AND POD.PICK_ORDER = P.PICK_ORDER "+
" AND POD.LINE_NO = P.LINE_NO__ORD "+
" AND PH.PICK_ORDER = P.PICK_ORDER "+
" AND PO.PICK_ORDER = ? ";
}
else if("M-PACK".equalsIgnoreCase(keyList))
{
sql2 = "SELECT PKD.ITEM_CODE,PO.WAVE_ID "
+ " FROM PACK_DET PKD, PACK_HDR PKH, PICK_ISS_DET P, PICK_ORD_HDR PO , PICK_ORD_DET POD,PICK_ISS_HDR PH "
+ " WHERE PKD.TRAN_ID = PKH.TRAN_ID "
+ " AND POD.PICK_ORDER = PO.PICK_ORDER "
+ " AND PKD.ITEM_CODE = P.ITEM_CODE "
+ " AND PO.PICK_ORDER IN ( SELECT REF_ID FROM WAVE_TASK_DET W WHERE W.WAVE_ID = PO.WAVE_ID "
+ " AND W.REF_SER = 'M-PICK' AND W.REF_ID = PO.PICK_ORDER and w.ptcn = pkh.ptcn ) "
+ " AND POD.PICK_ORDER = P.PICK_ORDER "
+ " AND POD.LINE_NO = P.LINE_NO__ORD "
+ " AND PH.TRAN_ID = P.TRAN_ID "
+ " AND PKH.TRAN_ID = ? "
+ " GROUP BY POD.PICK_ORDER, POD.LINE_NO, POD.SITE_CODE,POD.ITEM_CODE, "
+ " PKD.ITEM_CODE, P.LOC_CODE, P.LOC_CODE__TO, P.LOT_NO, P.LOT_SL, POD.SALE_ORDER, POD.EXP_LEV, PO.WAVE_ID, "
+ " POD.LINE_NO__SORD,PKH.OUTER_CARTON_NO " ;
}
else if(keyList.equalsIgnoreCase("R-TASK") || keyList.equalsIgnoreCase("S-DOC") || keyList.equalsIgnoreCase("RS-DSO") || keyList.equalsIgnoreCase("RO-DSO") || keyList.equalsIgnoreCase("R-DSO") || keyList.equalsIgnoreCase("R-PND") || "RP-PND".equalsIgnoreCase(keyList) )
{
sql2 = " SELECT P.ITEM_CODE,PO.WAVE_ID " +
" FROM REPL_ISS_DET P, REPL_ORD_HDR PO , REPL_ORD_DET POD ,REPL_ISS_HDR RPH " +
" WHERE PO.REPL_ORDER = P.REPL_ORDER " +
" AND POD.REPL_ORDER = PO.REPL_ORDER " +
" AND RPH.REPL_ORDER = P.REPL_ORDER " +
" AND POD.LINE_NO = P.LINE_NO__ORD " +
" AND PO.ORDER_TYPE in ('D','L') " +
" AND PO.REPL_ORDER = ?";
}
else
{
continue;
}
System.out.println("CURRENT SQL ["+sql2+"]");
tempList1 = (ArrayList)dataMap.get(keyList);
pstmt2 = conn.prepareStatement(sql2);
int orderLen = tempList1.size();
if ( orderLen > 0 )
{
for(int i = 0;i < orderLen; i++)
{
String refIdList = (String)tempList1.get(i);
System.out.println("CURRENT REF ID ["+refIdList+"]");
pstmt2.setString(1,refIdList);
rs2 = pstmt2.executeQuery();
System.out.println("after excute query---------------");
while(rs2.next())
{
itemCode = rs2.getString("ITEM_CODE");
waveId = rs2.getString("WAVE_ID");
sqlitem = "SELECT HAZARDOUS FROM ITEM WHERE ITEM_CODE=? ";
pstmtitem = conn.prepareStatement(sqlitem);
pstmtitem.setString(1,itemCode);
rsitem = pstmtitem.executeQuery();
if(rsitem.next())
{
hazMaterial = rsitem.getString("HAZARDOUS") == null?"":rsitem.getString("HAZARDOUS");
System.out.println("hazardous*"+hazMaterial);
}
if(pstmtitem != null)
{
pstmtitem.close();
pstmtitem = null;
}
if(rsitem != null)
{
rsitem.close();
rsitem = null;
}
//to check item is hazarous.end
//to check transporter mode.start
sqlTran = "SELECT TRANS_MODE FROM DESPATCH WHERE DESP_ID IN(SELECT REF_ID FROM WAVE_TASK_DET "
+" WHERE WAVE_ID = ? AND REF_SER = ? AND PTCN = ? )";
pstmtitem = conn.prepareStatement(sqlTran);
pstmtitem.setString(1,waveId);
pstmtitem.setString(2,"S-DSP");
pstmtitem.setString(3,ptcn);
rsitem = pstmtitem.executeQuery();
if(rsitem.next())
{
tranMode = rsitem.getString("TRANS_MODE") == null?"":rsitem.getString("TRANS_MODE");
System.out.println("tranMode*****"+tranMode);
}
if(pstmtitem != null)
{
pstmtitem.close();
pstmtitem = null;
}
if(rsitem != null)
{
rsitem.close();
rsitem = null;
}
//to check transporter mode.end
if("Y".equalsIgnoreCase(hazMaterial) && "A".equalsIgnoreCase(tranMode))
{
reportObjName = disCommon.getDisparams("999999","HAZMAT_LABLE_OBJ_NAME",conn);
errString = generateReport(ptcn,reportObjName,"Label",conn,xtraParams);
target = CommonConstants.JBOSSHOME+File.separator+"server"+File.separator+"default"+File.separator+
"deploy"+File.separator+"ibase.ear"+File.separator+"ibase.war"+File.separator+"webitm"+File.separator+
"reports"+File.separator+"hazardous";
File dir=new File(target);
boolean exists = dir.exists();
if (!exists)
{
if(dir.mkdir())
{
System.out.println("Hazardous Directory created");
}
else
{
System.out.println("Hazardous Directory not created");
}
}
if( errString.trim().length() == 0)
{
System.out.println(" Lable report genetrated successfully");
source = CommonConstants.JBOSSHOME+File.separator+"server"+File.separator+"default"+File.separator+
"deploy"+File.separator+"ibase.ear"+File.separator+"ibase.war"+File.separator+"webitm"+File.separator+
"reports"+File.separator+"finalreport"+File.separator+"BASE"+File.separator+ptcn+"_Label.pdf";
File sourceFile = new File(source);
String name = sourceFile.getName();
if(sourceFile.renameTo(new File(target+File.separator+sourceFile.getName())))
{
System.out.println(ptcn+"+_Label move succesfully");
}
else
{
System.out.println(ptcn+"_Lable is failed to move");
}
}
reportObjName = disCommon.getDisparams("999999","HAZMAT_FORM_OBJ_NAME",conn);
errString = generateReport(ptcn,reportObjName,"Form",conn,xtraParams);
if( errString.trim().length() == 0)
{
System.out.println(" Form report genetrated successfully");
source = CommonConstants.JBOSSHOME+File.separator+"server"+File.separator+"default"+File.separator+
"deploy"+File.separator+"ibase.ear"+File.separator+"ibase.war"+File.separator+"webitm"+File.separator+
"reports"+File.separator+"finalreport"+File.separator+"BASE"+File.separator+ptcn+"_Form.pdf";
File sourceFile = new File(source);
String name = sourceFile.getName();
System.out.println("NAME of form report"+name);
//File targetFile = new File(target+File.separator+name);
if(sourceFile.renameTo(new File(target+File.separator+sourceFile.getName())))
{
System.out.println(ptcn+"+_Form move succesfully");
}
else
{
System.out.println(ptcn+"_Form is failed to move");
}
//copy file from one location to other
//FileUtils.copyFile(sourceFile, targetFile);
}
}
}//while close
}//for close
}//if close
if(pstmt2 != null)
{
pstmt2.close();
pstmt2 = null;
}
if(rs2 != null)
{
rs2.close();
rs2 = null;
}
}//while itr close
System.out.println("***************END***********************");
//Changed by Rohan on 10-06-12 to get reports for hazardous material.end
}//if(!isShipExist)
else
......@@ -826,6 +1056,8 @@ public class ConsolidatToDoc {
errString = b.getMessage();
//Changed by Rohan on 10-12-12 to throw error.start
/*
try
{
if(conn != null)
......@@ -838,8 +1070,11 @@ public class ConsolidatToDoc {
e1.printStackTrace();
throw new ITMException(e1) ;
}
return errString;
*/
throw new ITMException(b) ;
//Changed by Rohan on 10-12-12 to throw error.end
}
catch(SQLException se)
......@@ -849,6 +1084,8 @@ public class ConsolidatToDoc {
se.printStackTrace();
System.out.println("error ****"+se.getMessage());
errString = se.getMessage();
//Changed by Rohan on 10-12-12 to throw error.start
/*
try
{
if(conn != null)
......@@ -861,14 +1098,19 @@ public class ConsolidatToDoc {
se = e1;
throw new ITMException(se) ;
}
return errString;
*/
throw new ITMException(se) ;
//Changed by Rohan on 10-12-12 to throw error.end
}
catch(Exception e)
{
isError = true;
System.out.println("Exception :" + e);
errString = e.getMessage();
e.printStackTrace();
//Changed by Rohan on 10-12-12 to throw error.start
/*
System.out.println("error-->"+e.getMessage());
try
{
......@@ -884,7 +1126,26 @@ public class ConsolidatToDoc {
}
return errString ;
}
*/
throw new ITMException(e) ;
//Changed by Rohan on 10-12-12 to throw error.end
}
//Changed by Rohan on 10-12-12 to rollback connection.start
finally
{
try
{
if(conn != null)
{
conn.rollback();
}
}
catch(Exception e1)
{
throw new ITMException(e1) ;
}
}
//Changed by Rohan on 10-12-12 to rollback connection.end
return errString;
......
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