Commit dc160708 authored by dpingle's avatar dpingle

* updated src file of AttendanceWorkBal

AttendanceWorkBal.java


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@215269 ce508802-f39f-4f6c-b175-0d175dae99d5
parent a9474925
package ibase.webitm.ejb.adm; import java.rmi.RemoteException;import java.sql.Connection;import java.sql.PreparedStatement;import java.sql.ResultSet;import java.sql.Statement;import java.sql.Timestamp;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Calendar;import java.util.Date; import org.w3c.dom.Document;import org.w3c.dom.Node;import org.w3c.dom.NodeList; import ibase.utility.E12GenericUtility;import ibase.webitm.ejb.ITMDBAccessEJB;import ibase.webitm.ejb.ValidatorEJB;import ibase.webitm.utility.ITMException; //Modified By Dipesh on[18/07/2019][Start] //@Stateless // added for ejb3 //Modified By Dipesh on[18/07/2019][End] public class AttendanceWorkBal extends ValidatorEJB implements AttendanceWorkBalLocal,AttendanceWorkBalRemote // SessionBean { //Modified By Dipesh on[18/07/2019][Start] //GenericUtility genericUtility = GenericUtility.getInstance(); E12GenericUtility genericUtility = new E12GenericUtility(); //Modified By Dipesh on[18/07/2019][End] ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); //Modified By Dipesh on[18/07/2019][Start] //ConnDriver connDriver = new ConnDriver(); Connection conn = null; //Modified By Dipesh on[18/07/2019][End] /* public void ejbCreate() throws RemoteException, CreateException { System.out.println("Entering into AttendancesEJB............."); } public void ejbRemove() { } public void ejbActivate() { } public void ejbPassivate() { }*/ public String wfValData() throws RemoteException,ITMException { return ""; } public String itemChanged() throws RemoteException,ITMException { return ""; } public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException { Document dom = null; Document dom1 = null; Document dom2 = null; String valueXmlString = ""; try { dom = parseString(xmlString); //returns the DOM Object for the passed XML Stirng System.out.println("xmlString :" + xmlString); dom1 = parseString(xmlString1); //returns the DOM Object for the passed XML Stirng System.out.println("xmlString1 :" + xmlString1); System.out.println("xmlString2 :" + xmlString2); if (xmlString2.trim().length() > 0 ) { dom2 = parseString(xmlString2); } valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams); } catch(Exception e) { System.out.println("Exception : [AttendancesEJB][itemChanged(String,String)] :==>\n"+e.getMessage()); } return valueXmlString; }
public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException { System.out.println(" in itemChanged "); StringBuffer valueXmlString = new StringBuffer(); StringBuffer retString = new StringBuffer(); PreparedStatement pstmt = null; ResultSet rs = null; String errCode = ""; String sql = ""; String sundrySql= ""; String columnValue = ""; String loginSite = ""; String format = ""; String accPrd = ""; String childNodeName = ""; String dateStr=""; String endDateStr=""; String endTime=null; String stsrtTime=null; int childListLength=0; NodeList parentNodeList = null; NodeList childNodeList = null; Node parentNode = null; Node childNode = null; int ctr = 0; int n = 0; int currentFormNo = 0; String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId"); System.out.println("userId ::-"+userId); loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"); System.out.println("loginSiteCode ::-"+loginSite); System.out.println("currentColumn ::-"+currentColumn); try { conn=getConnection(); if(objContext != null && objContext.trim().length()>0) { currentFormNo = Integer.parseInt(objContext); } valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>"); valueXmlString.append(editFlag).append("</editFlag></header>"); switch (currentFormNo) { case 1: parentNodeList = dom.getElementsByTagName("Detail1"); parentNode = parentNodeList.item(0); childNodeList = parentNode.getChildNodes(); valueXmlString.append("<Detail1>"); //Modified By Dipesh on[18/07/2019][Start] //if(currentColumn.trim().equals("itm_default")) if(currentColumn.trim().equalsIgnoreCase("itm_default")) //Modified By Dipesh on[18/07/2019][End] { Calendar cal=Calendar.getInstance(); Date date=cal.getTime(); //Changed by Pawan on 5/2/2011 [AD01SUN007] for date formating.start //SimpleDateFormat dateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat dateFormat = null; if( xtraParams.indexOf("user_lang=") <= 0 ) { dateFormat = new SimpleDateFormat("yyyy-MM-dd"); } else { dateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); } //Changed by Pawan on 5/2/2011 [AD01SUN009] for date formating.end dateStr=dateFormat.format(date); System.out.println("Today's Date "+dateStr); valueXmlString.append("<start_date>").append(dateStr).append("</start_date>\r\n"); } /*else if(currentColumn.trim().equals("end_date") || currentColumn.trim().equals("start_date")) { parentNodeList = dom.getElementsByTagName("Detail1"); parentNode = parentNodeList.item(0); childNodeList = parentNode.getChildNodes(); ctr = 0; childListLength = childNodeList.getLength(); while(ctr<childListLength) { String dateString=childNodeList.item(ctr).getNodeName(); if("end_date".equals(dateString)) endTime=childNodeList.item(ctr).getFirstChild().getNodeValue(); else if("start_date".equals(dateString)) stsrtTime=childNodeList.item(ctr).getFirstChild().getNodeValue(); ctr++; } if(endTime.indexOf(' ')!=-1) { endTime=endTime.substring(0,endTime.indexOf(' ')); } if(stsrtTime.indexOf(' ')!=-1) { stsrtTime=stsrtTime.substring(0,stsrtTime.indexOf(' ')); } if(endTime.indexOf('-')!=-1) { endTime=endTime.replace('-','/'); } if(stsrtTime.indexOf('-')!=-1) { stsrtTime=stsrtTime.replace('-','/'); } System.out.println(">>>>>>.. endTime "+endTime); System.out.println(">>>>>>.. stsrtTime "+stsrtTime); if(stsrtTime !=null && endTime !=null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); Date stDate = simpleDateFormat.parse(stsrtTime); Date edDate = simpleDateFormat.parse(endTime); // Date stDate = new Date(stsrtTime); // Date edDate = new Date(endTime); long stTimeImMilsec=stDate.getTime(); long edTimeImMilsec=edDate.getTime(); long dayTminMilsec=24*60*60*1000; long noOfDays =(edTimeImMilsec - stTimeImMilsec)/dayTminMilsec; if(noOfDays !=0) { noOfDays=noOfDays + 1; } System.out.println(">>>>>>.. stTimeImMilsec "+stTimeImMilsec); System.out.println(">>>>>>.. edTimeImMilsec "+edTimeImMilsec); System.out.println(">>>>>>.. noOfDays "+noOfDays); valueXmlString.append("<paid_prdcode>").append(noOfDays).append("</paid_prdcode>\r\n"); } }*/ valueXmlString.append("</Detail1>\r\n"); break; } valueXmlString.append("</Root>"); } catch(Exception e) { System.out.println("Exception ::"+e.getMessage()); e.printStackTrace(); } finally { try { if (conn != null) { conn.close(); conn = null; } if (rs != null) { rs.close(); rs = null; } if (pstmt != null) { pstmt.close(); pstmt = null; } } catch (Exception e) { System.out.println("Exception ::" + e); e.printStackTrace(); throw new ITMException(e); } } return valueXmlString.toString(); }
private long getTimeInMinit(String timeStr) { String hr=timeStr.substring(0,timeStr.indexOf(':')); String min=timeStr.substring(timeStr.indexOf(':')+1); long timinMin=Integer.parseInt(hr)*60+Integer.parseInt(min); return timinMin; } public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException { Document dom = null; Document dom1 = null; Document dom2 = null; String errString = null; System.out.println("Entering into validations ..................."); System.out.println("xmlString : "+xmlString); System.out.println("xmlString1 : "+xmlString1); System.out.println("xmlString2 : "+xmlString2); try { dom = parseString(xmlString); dom1 = parseString(xmlString1); if (xmlString2.trim().length() > 0 ) { dom2 = parseString(xmlString2); } errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams); } catch(Exception e) { System.out.println("Exception : PayableOpeningsEJB : wfValData(String xmlString) : ==>\n"+e.getMessage()); } return (errString); }
public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException { System.out.println(" IN wfValData 2"); Connection conn = null; Statement stmt = null; PreparedStatement pstmt = null; ResultSet rs = null; String errString = ""; String errCode = ""; String sql = ""; String userId = ""; String loginSite = ""; String startDateStr = ""; String endDateStr = ""; String shiftPattern = ""; String periodCode = ""; String itemSer = ""; String currCode = ""; String childNodeName = ""; NodeList parentNodeList = null; NodeList childNodeList = null; Node parentNode = null; Node childNode = null; int currentFormNo=0; int childNodeListLength =0; int cnt; Date startDate=null; Date endDate=null; String workTblNo = ""; int lineNo = 0; String lineNoStr = ""; SimpleDateFormat simpleDateFormat = null; userId = getValueFromXTRA_PARAMS(xtraParams,"userId"); StringBuffer errStringXml = null; //Modified By Dipesh on[13/08/2019][Start] ITMDBAccessEJB itmDbAcess = null; //Modified By Dipesh on[13/08/2019][End] errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>(); try { //Modified By Dipesh on[13/08/2019][Start] itmDbAcess =new ITMDBAccessEJB(); //Modified By Dipesh on[13/08/2019][End] conn = getConnection(); simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); if(objContext != null && objContext.trim().length()>0) { currentFormNo = Integer.parseInt(objContext); } //parentNodeList = dom.getElementsByTagName("Detail" + currentFormNo); //Modified By Dipesh on[19/07/2019][Start] //startDateStr = genericUtility.getColumnValue("start_date",dom); //endDateStr = genericUtility.getColumnValue("end_date",dom); //workTblNo = genericUtility.getColumnValue("work_tblno",dom); startDateStr = checkNull(genericUtility.getColumnValue("start_date",dom)); endDateStr = checkNull(genericUtility.getColumnValue("end_date",dom)); workTblNo = checkNull(genericUtility.getColumnValue("work_tblno",dom)); //Modified By Dipesh on[19/07/2019][End] lineNoStr = genericUtility.getColumnValue("line_no",dom); System.out.println("Line No : "+lineNoStr); if(lineNoStr != null && lineNoStr.trim().length() > 0) { lineNo = Integer.parseInt(lineNoStr); } if(startDateStr !=null && endDateStr !=null) { if(startDateStr.indexOf(" ")!= -1) { startDateStr=startDateStr.substring(0,startDateStr.indexOf(" ")); } if(endDateStr.indexOf(" ")!=-1) { endDateStr=endDateStr.substring(0,endDateStr.indexOf(" ")); } if(startDateStr.indexOf('-')!=-1) { startDateStr=startDateStr.replace('-','/'); } if(endDateStr.indexOf('-')!=-1) { endDateStr=endDateStr.replace('-','/'); } if(startDateStr != null && startDateStr.trim().length() > 0) { //startDate = simpleDateFormat.parse(startDateStr); startDate = Timestamp.valueOf(genericUtility.getValidDateString(startDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); } System.out.println("startDate::::::"+startDate); if(endDateStr != null && endDateStr.trim().length() > 0) { //endDate = simpleDateFormat.parse(endDateStr); endDate = Timestamp.valueOf(genericUtility.getValidDateString(endDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); } System.out.println("endDate::::::"+endDate); } switch (currentFormNo) { case 1: parentNodeList = dom.getElementsByTagName("Detail" + currentFormNo); parentNode = parentNodeList.item(0); System.out.println("parentNode:::::::"+parentNode); childNodeList = parentNode.getChildNodes(); System.out.println("childNodeList:::::::"+childNodeList); childNodeListLength = childNodeList.getLength(); System.out.println("childNodeListLength:::::::"+childNodeListLength); for (int ctr = 0; ctr < childNodeListLength; ctr++) { childNode = childNodeList.item(ctr); System.out.println("childNode:::::::"+childNode); childNodeName = childNode.getNodeName(); System.out.println("childNodeName:::::::"+childNodeName); //Changed by Pawan on 5/14/2011 [AD01SUN007] to check blank work_tblno and line_no.start //Modified By Dipesh on[18/07/2019][Start] //if (childNodeName.equals("work_tblno")) if ("work_tblno".equalsIgnoreCase(childNodeName)) //Modified By Dipesh on[18/07/2019][End] { workTblNo = checkNull(genericUtility.getColumnValue("work_tblno",dom)); System.out.println("childNode.getFirstChild()------" +childNode.getFirstChild()); if (childNode.getFirstChild() == null) { errCode = "INVWORKTBL"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("work_tblno",errCode,userId); errString = itmDbAcess.getErrorString("work_tblno", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] } else { cnt = 0 ; lineNoStr = checkNull(genericUtility.getColumnValue("line_no",dom)); lineNo = Integer.parseInt(lineNoStr); sql="select count(*) as cnt from work_table where work_tblno=? and line_no=?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1, workTblNo); pstmt.setInt(2, lineNo); rs = pstmt.executeQuery(); if (rs.next()) { cnt = rs.getInt("cnt"); } System.out.println("cnt:::: " + cnt+editFlag); if (rs != null) { rs.close(); rs = null; } if (pstmt != null) { pstmt.close(); pstmt = null; } if (cnt > 0 && !"E".equalsIgnoreCase(editFlag)) { errCode = "INVLVEDT01";//The Work table cannot Blank or Already Existed in Work Table errString = itmDbAcess.getErrorString("work_tblno", errCode, userId, "", conn); break; } } } //Modified By Dipesh on[18/07/2019][Start] //if (childNodeName.equals("line_no")) else if (childNodeName.equalsIgnoreCase("line_no")) //Modified By Dipesh on[18/07/2019][Start] { if (childNode.getFirstChild() == null) { errCode = "INVDLINENO"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("line_no",errCode,userId); errString = itmDbAcess.getErrorString("line_no", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } } //Changed by Pawan on 5/14/2011 [AD01SUN007] to check blank work_tblno and line_no.end //if (childNodeName.equals("paid_prdcode")) //Modified By Dipesh on[18/07/2019][Start] //if (childNodeName.equals("prd_code__pay")) else if (childNodeName.equalsIgnoreCase("prd_code__pay")) //Modified By Dipesh on[18/07/2019][Start] { if (childNode.getFirstChild() == null) { errCode = "VTCALPRD"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("prd_code__pay",errCode,userId); errString = itmDbAcess.getErrorString("prd_code__pay", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } periodCode=childNode.getFirstChild().getNodeValue(); //Modified By Dipesh on[18/07/2019][Start] //sql = "SELECT COUNT(*) AS COUNT FROM PERIOD WHERE CODE = '"+periodCode+"'"; //stmt = conn.createStatement(); //rs = stmt.executeQuery(sql); sql = "SELECT COUNT(*) AS COUNT FROM PERIOD WHERE CODE = ?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1,periodCode); //Modified By Dipesh on[18/07/2019][End] rs = pstmt.executeQuery(); if (rs.next()) { cnt = rs.getInt("COUNT"); if (cnt == 0) { errCode = "STARTPRD"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("prd_code__pay",errCode,userId); errString = itmDbAcess.getErrorString("prd_code__pay", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } } //Modified By Dipesh on[18/07/2019][Start] //stmt.close(); //rs.close(); if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[18/07/2019][End] } else startDateStr = checkNull(genericUtility.getColumnValue("start_date",dom)); System.out.println("startDateStr::::"+startDateStr); if((startDateStr == null || startDateStr.trim().length() == 0)) { errCode = "VEDAT2"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else //Modified By Dipesh on[22/08/2019][Start] //if((endDateStr ==null)) endDateStr = checkNull(genericUtility.getColumnValue("end_date",dom)); System.out.println("endDateStr::::"+endDateStr); if((endDateStr ==null || endDateStr.trim().length() == 0)) //Modified By Dipesh on[22/08/2019][End] { errCode = "VEDAT2"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("end_date",errCode,userId); errString = itmDbAcess.getErrorString("end_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if((endDate.compareTo(startDate) <= 0)) { errCode = "VTDATE1"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("end_date",errCode,userId); errString = itmDbAcess.getErrorString("end_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } //Modified By Dipesh on[18/07/2019][Start] //else if (childNodeName.equals("start_date") || childNodeName.equals("end_date")) else if (childNodeName.equalsIgnoreCase("start_date") || childNodeName.equalsIgnoreCase("end_date")) //Modified By Dipesh on[18/07/2019][End] if(editFlag.equalsIgnoreCase("E")) { java.sql.Date dbFrDate = new java.sql.Date(System.currentTimeMillis()); java.sql.Date dbToDate = new java.sql.Date(System.currentTimeMillis()); //Modified By Dipesh on[18/07/2019][Start] //sql = "SELECT START_DATE,END_DATE FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' AND LINE_NO = "+lineNo+""; //System.out.println("SQL :: "+sql); //stmt = conn.createStatement(); //rs = stmt.executeQuery(sql); sql = "SELECT START_DATE,END_DATE FROM WORK_TABLE WHERE WORK_TBLNO = ? AND LINE_NO = ?"; System.out.println("SQL :: "+sql); pstmt = conn.prepareStatement(sql); pstmt.setString(1,workTblNo); pstmt.setInt(2,lineNo); rs = pstmt.executeQuery(); if(rs.next()) { dbFrDate = rs.getDate("START_DATE"); dbToDate = rs.getDate("END_DATE"); System.out.println("DomFrDate : "+startDate+" DbFromDate :"+dbFrDate+" DomEndDate :"+endDate+" dbEndDate :"+dbToDate); if(startDate.compareTo(new java.util.Date(dbFrDate.getTime())) == 0 && endDate.compareTo(new java.util.Date(dbToDate.getTime())) == 0){ break; } } //stmt.close(); if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[18/07/2019][End] } int count = 0; java.sql.Date startSqlDate = new java.sql.Date(startDate.getTime()); java.sql.Date endSqlDate = new java.sql.Date(endDate.getTime()); System.out.println("Work Table No ::"+workTblNo); if(workTblNo != null && workTblNo.trim().length() > 0) { //Modified By Dipesh on[19/07/2019][Start] //sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"'"; //System.out.println("SQL ::"+sql); //stmt = conn.createStatement(); //rs = stmt.executeQuery(sql); sql = "SELECT COUNT(*) as cnt FROM WORK_TABLE WHERE WORK_TBLNO = ?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1,workTblNo); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt("cnt"); } if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] if(count > 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND ? BETWEEN START_DATE AND END_DATE AND LINE_NO != "+lineNo+""; System.out.println("SQL ::"+sql); pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); System.out.println("SET 1 "+Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if(count == 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND ? BETWEEN START_DATE AND END_DATE AND LINE_NO != "+lineNo+""; pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); System.out.println("SET 1 "+Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("end_date",errCode,userId); errString = itmDbAcess.getErrorString("end_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if(count == 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND START_DATE BETWEEN ? AND ? AND LINE_NO != "+lineNo+""; System.out.println("SQL ::"+sql); pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); pstmt.setTimestamp(2,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if(count == 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND END_DATE BETWEEN ? AND ? AND LINE_NO != "+lineNo+""; System.out.println("SQL ::"+sql); pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); pstmt.setTimestamp(2,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } } } } } } }//End of Switch //Modified By Dipesh on[19/07/2019][Start] break; //Modified By Dipesh on[19/07/2019][End] } //Modified By Dipesh on[19/07/2019][Start] if (errList != null && errList.size() > 0) { System.out.println("errList==[" + errList + "]"); int errListSize = errList.size(); System.out.println("errListSize:::::::[" + errListSize + "]"); System.out.println("in error::::::::::"); for (int i = 0; i < errListSize; i++) { System.out.println("in error For:::::::::::::::"); String errCode1 = (String) errList.get(i); String errFldName = (String) errFields.get(i); System.out.println("errCode .........." + errCode1); //Modified By Dipesh on[13/08/2019][Start] errString = itmDbAcess.getErrorString(errFldName, errCode1, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] System.out.println("errString is : ::::>>>> " + errString); String msgType = errorType(conn, errCode1); if (errString.length() > 0) { String bifurErrString = errString.substring(errString.indexOf("<Errors>") + 8,errString.indexOf("<trace>")); bifurErrString = bifurErrString + errString.substring(errString.indexOf("</trace>") + 8,errString.indexOf("</Errors>")); errStringXml.append(bifurErrString); System.out.println("errStringXml .........." + errStringXml); errString = ""; } if (msgType.equalsIgnoreCase("E")) { break; } } errList.clear(); errFields.clear(); } errStringXml.append("</Errors></Root>\r\n"); System.out.println("errStringXml.toString()---2= "+errStringXml.toString()); //Modified By Dipesh on[19/07/2019][End] } catch(Exception e) { System.out.println("Exception ::"+e); e.printStackTrace(); //Modified By Dipesh on[19/07/2019][Start] throw new ITMException(e); //Modified By Dipesh on[19/07/2019][End] } finally { try { if(stmt != null){ stmt.close(); stmt = null; } if(pstmt != null){ pstmt.close(); pstmt = null; } if(conn != null) { conn.close(); } } catch(Exception ex) { System.out.println("Exception ::"+ex.getMessage()); ex.printStackTrace(); //Modified By Dipesh on[19/07/2019][Start] throw new ITMException(ex); //Modified By Dipesh on[19/07/2019][End] } } return errString; } private String errorType(Connection conn, String errorCode) throws ITMException { String msgType = ""; PreparedStatement pstmt = null; ResultSet rs = null; try { if (conn == null) { System.out.println("Connection is null"); } else { System.out.println("Connection is not null"); } String sql = " SELECT MSG_TYPE FROM MESSAGES WHERE MSG_NO = ? "; pstmt = conn.prepareStatement(sql); pstmt.setString(1, errorCode); rs = pstmt.executeQuery(); if (rs.next()) { msgType = rs.getString("MSG_TYPE"); } if (rs != null) { rs.close(); rs = null; } if (pstmt != null) { pstmt.close(); pstmt = null; } } catch (Exception ex) { ex.printStackTrace(); throw new ITMException(ex); } finally { try { if (rs != null) { rs.close(); rs = null; } if (pstmt != null) { pstmt.close(); pstmt = null; } } catch (Exception e) { e.printStackTrace(); throw new ITMException(e); } } return msgType; } private String checkNull(String input) { if (input == null) { input = ""; } return input; } }
\ No newline at end of file
package ibase.webitm.ejb.adm; import java.rmi.RemoteException; import java.util.*;import java.util.Date;import java.text.*;import java.sql.*;import org.w3c.dom.*; import javax.ejb.*; import ibase.system.config.ConnDriver;import ibase.utility.E12GenericUtility;import ibase.webitm.utility.ITMException;import ibase.webitm.utility.*;import ibase.webitm.ejb.*;import javax.ejb.Stateless; // added for ejb3 @Stateless // added for ejb3 public class AttendanceWorkBal extends ValidatorEJB implements AttendanceWorkBalLocal,AttendanceWorkBalRemote // SessionBean { //Modified By Dipesh on[18/07/2019][Start] //GenericUtility genericUtility = GenericUtility.getInstance(); E12GenericUtility genericUtility = new E12GenericUtility(); //Modified By Dipesh on[18/07/2019][End] ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); //Modified By Dipesh on[18/07/2019][Start] //ConnDriver connDriver = new ConnDriver(); Connection conn = null; //Modified By Dipesh on[18/07/2019][End] /* public void ejbCreate() throws RemoteException, CreateException { System.out.println("Entering into AttendancesEJB............."); } public void ejbRemove() { } public void ejbActivate() { } public void ejbPassivate() { }*/ public String wfValData() throws RemoteException,ITMException { return ""; } public String itemChanged() throws RemoteException,ITMException { return ""; } public String itemChanged(String xmlString, String xmlString1,String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException { Document dom = null; Document dom1 = null; Document dom2 = null; String valueXmlString = ""; try { dom = parseString(xmlString); //returns the DOM Object for the passed XML Stirng System.out.println("xmlString :" + xmlString); dom1 = parseString(xmlString1); //returns the DOM Object for the passed XML Stirng System.out.println("xmlString1 :" + xmlString1); System.out.println("xmlString2 :" + xmlString2); if (xmlString2.trim().length() > 0 ) { dom2 = parseString(xmlString2); } valueXmlString = itemChanged(dom,dom1,dom2,objContext,currentColumn,editFlag,xtraParams); } catch(Exception e) { System.out.println("Exception : [AttendancesEJB][itemChanged(String,String)] :==>\n"+e.getMessage()); } return valueXmlString; } public String itemChanged(Document dom, Document dom1,Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException { System.out.println(" in itemChanged "); StringBuffer valueXmlString = new StringBuffer(); StringBuffer retString = new StringBuffer(); PreparedStatement pstmt = null; ResultSet rs = null; String errCode = ""; String sql = ""; String sundrySql= ""; String columnValue = ""; String loginSite = ""; String format = ""; String accPrd = ""; String childNodeName = ""; String dateStr=""; String endDateStr=""; String endTime=null; String stsrtTime=null; int childListLength=0; NodeList parentNodeList = null; NodeList childNodeList = null; Node parentNode = null; Node childNode = null; int ctr = 0; int n = 0; int currentFormNo = 0; String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"userId"); System.out.println("userId ::-"+userId); loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginSiteCode"); System.out.println("loginSiteCode ::-"+loginSite); System.out.println("currentColumn ::-"+currentColumn); try { conn=getConnection(); if(objContext != null && objContext.trim().length()>0) { currentFormNo = Integer.parseInt(objContext); } valueXmlString = new StringBuffer("<?xml version=\"1.0\"?><Root><header><editFlag>"); valueXmlString.append(editFlag).append("</editFlag></header>"); switch (currentFormNo) { case 1: parentNodeList = dom.getElementsByTagName("Detail1"); parentNode = parentNodeList.item(0); childNodeList = parentNode.getChildNodes(); valueXmlString.append("<Detail1>"); //Modified By Dipesh on[18/07/2019][Start] //if(currentColumn.trim().equals("itm_default")) if(currentColumn.trim().equalsIgnoreCase("itm_default")) //Modified By Dipesh on[18/07/2019][End] { Calendar cal=Calendar.getInstance(); Date date=cal.getTime(); //Changed by Pawan on 5/2/2011 [AD01SUN007] for date formating.start //SimpleDateFormat dateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat dateFormat = null; if( xtraParams.indexOf("user_lang=") <= 0 ) { dateFormat = new SimpleDateFormat("yyyy-MM-dd"); } else { dateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); } //Changed by Pawan on 5/2/2011 [AD01SUN009] for date formating.end dateStr=dateFormat.format(date); System.out.println("Today's Date "+dateStr); valueXmlString.append("<start_date>").append(dateStr).append("</start_date>\r\n"); } /*else if(currentColumn.trim().equals("end_date") || currentColumn.trim().equals("start_date")) { parentNodeList = dom.getElementsByTagName("Detail1"); parentNode = parentNodeList.item(0); childNodeList = parentNode.getChildNodes(); ctr = 0; childListLength = childNodeList.getLength(); while(ctr<childListLength) { String dateString=childNodeList.item(ctr).getNodeName(); if("end_date".equals(dateString)) endTime=childNodeList.item(ctr).getFirstChild().getNodeValue(); else if("start_date".equals(dateString)) stsrtTime=childNodeList.item(ctr).getFirstChild().getNodeValue(); ctr++; } if(endTime.indexOf(' ')!=-1) { endTime=endTime.substring(0,endTime.indexOf(' ')); } if(stsrtTime.indexOf(' ')!=-1) { stsrtTime=stsrtTime.substring(0,stsrtTime.indexOf(' ')); } if(endTime.indexOf('-')!=-1) { endTime=endTime.replace('-','/'); } if(stsrtTime.indexOf('-')!=-1) { stsrtTime=stsrtTime.replace('-','/'); } System.out.println(">>>>>>.. endTime "+endTime); System.out.println(">>>>>>.. stsrtTime "+stsrtTime); if(stsrtTime !=null && endTime !=null) { SimpleDateFormat simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); Date stDate = simpleDateFormat.parse(stsrtTime); Date edDate = simpleDateFormat.parse(endTime); // Date stDate = new Date(stsrtTime); // Date edDate = new Date(endTime); long stTimeImMilsec=stDate.getTime(); long edTimeImMilsec=edDate.getTime(); long dayTminMilsec=24*60*60*1000; long noOfDays =(edTimeImMilsec - stTimeImMilsec)/dayTminMilsec; if(noOfDays !=0) { noOfDays=noOfDays + 1; } System.out.println(">>>>>>.. stTimeImMilsec "+stTimeImMilsec); System.out.println(">>>>>>.. edTimeImMilsec "+edTimeImMilsec); System.out.println(">>>>>>.. noOfDays "+noOfDays); valueXmlString.append("<paid_prdcode>").append(noOfDays).append("</paid_prdcode>\r\n"); } }*/ valueXmlString.append("</Detail1>\r\n"); break; } valueXmlString.append("</Root>"); } catch(Exception e) { System.out.println("Exception ::"+e.getMessage()); e.printStackTrace(); } finally { try { if (conn != null) { conn.close(); conn = null; } if (rs != null) { rs.close(); rs = null; } if (pstmt != null) { pstmt.close(); pstmt = null; } } catch (Exception e) { System.out.println("Exception ::" + e); e.printStackTrace(); throw new ITMException(e); } } return valueXmlString.toString(); } private long getTimeInMinit(String timeStr) { String hr=timeStr.substring(0,timeStr.indexOf(':')); String min=timeStr.substring(timeStr.indexOf(':')+1); long timinMin=Integer.parseInt(hr)*60+Integer.parseInt(min); return timinMin; } public String wfValData(String xmlString, String xmlString1,String xmlString2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException { Document dom = null; Document dom1 = null; Document dom2 = null; String errString = null; System.out.println("Entering into validations ..................."); System.out.println("xmlString : "+xmlString); System.out.println("xmlString1 : "+xmlString1); System.out.println("xmlString2 : "+xmlString2); try { dom = parseString(xmlString); dom1 = parseString(xmlString1); if (xmlString2.trim().length() > 0 ) { dom2 = parseString(xmlString2); } errString = wfValData(dom,dom1,dom2,objContext,editFlag,xtraParams); } catch(Exception e) { System.out.println("Exception : PayableOpeningsEJB : wfValData(String xmlString) : ==>\n"+e.getMessage()); } return (errString); } public String wfValData(Document dom, Document dom1,Document dom2, String objContext, String editFlag, String xtraParams) throws RemoteException,ITMException { System.out.println(" IN wfValData 2"); Connection conn = null; Statement stmt = null; PreparedStatement pstmt = null; ResultSet rs = null; String errString = ""; String errCode = ""; String sql = ""; String userId = ""; String loginSite = ""; String startDateStr = ""; String endDateStr = ""; String shiftPattern = ""; String periodCode = ""; String itemSer = ""; String currCode = ""; String childNodeName = ""; NodeList parentNodeList = null; NodeList childNodeList = null; Node parentNode = null; Node childNode = null; int ctr,currentFormNo=0; int childNodeListLength; int cnt; Date startDate=null; Date endDate=null; String workTblNo = ""; int lineNo = 0; String lineNoStr = ""; SimpleDateFormat simpleDateFormat = null; userId = getValueFromXTRA_PARAMS(xtraParams,"userId"); //Modified By Dipesh on[13/08/2019][Start] ITMDBAccessEJB itmDbAcess = null; StringBuffer errStringXml = null; errStringXml = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root><Errors>"); ArrayList<String> errList = new ArrayList<String>(); ArrayList<String> errFields = new ArrayList<String>(); //Modified By Dipesh on[13/08/2019][End] try { //Modified By Dipesh on[13/08/2019][Start] itmDbAcess =new ITMDBAccessEJB(); //Modified By Dipesh on[13/08/2019][End] conn = getConnection(); simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat()); if(objContext != null && objContext.trim().length()>0) { currentFormNo = Integer.parseInt(objContext); } parentNodeList = dom.getElementsByTagName("Detail" + currentFormNo); //Modified By Dipesh on[19/07/2019][Start] //startDateStr = genericUtility.getColumnValue("start_date",dom); //endDateStr = genericUtility.getColumnValue("end_date",dom); //workTblNo = genericUtility.getColumnValue("work_tblno",dom); //lineNoStr = genericUtility.getColumnValue("line_no",dom); startDateStr = checkNull(genericUtility.getColumnValue("start_date",dom)); endDateStr = checkNull(genericUtility.getColumnValue("end_date",dom)); workTblNo = checkNull(genericUtility.getColumnValue("work_tblno",dom)); lineNoStr = checkNull(genericUtility.getColumnValue("line_no",dom)); //Modified By Dipesh on[19/07/2019][End] System.out.println("Line No : "+lineNoStr); if(lineNoStr != null && lineNoStr.trim().length() > 0){ lineNo = Integer.parseInt(lineNoStr); } if(startDateStr !=null && endDateStr !=null) { if(startDateStr.indexOf(" ")!= -1) { startDateStr=startDateStr.substring(0,startDateStr.indexOf(" ")); } if(endDateStr.indexOf(" ")!=-1) { endDateStr=endDateStr.substring(0,endDateStr.indexOf(" ")); } if(startDateStr.indexOf('-')!=-1) { startDateStr=startDateStr.replace('-','/'); } if(endDateStr.indexOf('-')!=-1) { endDateStr=endDateStr.replace('-','/'); } if(startDateStr != null && startDateStr.trim().length() > 0) { //startDate = simpleDateFormat.parse(startDateStr); startDate = Timestamp.valueOf(genericUtility.getValidDateString(startDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); } System.out.println("startDate::::::"+startDate); if(endDateStr != null && endDateStr.trim().length() > 0) { //endDate = simpleDateFormat.parse(endDateStr); endDate = Timestamp.valueOf(genericUtility.getValidDateString(endDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); } System.out.println("endDate::::::"+endDate); } parentNode = parentNodeList.item(0); childNodeList = parentNode.getChildNodes(); childNodeListLength = childNodeList.getLength(); for (ctr = 0; ctr < childNodeListLength; ctr++) { childNode = childNodeList.item(ctr); childNodeName = childNode.getNodeName(); switch (currentFormNo) { case 1: //Changed by Pawan on 5/14/2011 [AD01SUN007] to check blank work_tblno and line_no.start //Modified By Dipesh on[18/07/2019][Start] //if (childNodeName.equals("work_tblno")) if ("work_tblno".equalsIgnoreCase(childNodeName)) //Modified By Dipesh on[18/07/2019][End] { if (childNode.getFirstChild() == null) { errCode = "INVWORKTBL"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("work_tblno",errCode,userId); errString = itmDbAcess.getErrorString("work_tblno", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } } //Modified By Dipesh on[18/07/2019][Start] //if (childNodeName.equals("line_no")) else if (childNodeName.equalsIgnoreCase("line_no")) //Modified By Dipesh on[18/07/2019][Start] { if (childNode.getFirstChild() == null) { errCode = "INVDLINENO"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("line_no",errCode,userId); errString = itmDbAcess.getErrorString("line_no", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } } //Changed by Pawan on 5/14/2011 [AD01SUN007] to check blank work_tblno and line_no.end //if (childNodeName.equals("paid_prdcode")) //Modified By Dipesh on[18/07/2019][Start] //if (childNodeName.equals("prd_code__pay")) else if (childNodeName.equalsIgnoreCase("prd_code__pay")) //Modified By Dipesh on[18/07/2019][Start] { if (childNode.getFirstChild() == null) { errCode = "VTCALPRD"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("prd_code__pay",errCode,userId); errString = itmDbAcess.getErrorString("prd_code__pay", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } periodCode=childNode.getFirstChild().getNodeValue(); //Modified By Dipesh on[18/07/2019][Start] //sql = "SELECT COUNT(*) AS COUNT FROM PERIOD WHERE CODE = '"+periodCode+"'"; //stmt = conn.createStatement(); //rs = stmt.executeQuery(sql); sql = "SELECT COUNT(*) AS COUNT FROM PERIOD WHERE CODE = ?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1,periodCode); //Modified By Dipesh on[18/07/2019][End] rs = pstmt.executeQuery(); if (rs.next()) { cnt = rs.getInt("COUNT"); if (cnt == 0) { errCode = "STARTPRD"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("prd_code__pay",errCode,userId); errString = itmDbAcess.getErrorString("prd_code__pay", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } } //Modified By Dipesh on[18/07/2019][Start] //stmt.close(); //rs.close(); if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[18/07/2019][End] } else //Modified By Dipesh on[13/08/2019][Start] //if((startDateStr ==null)) if((startDateStr == null || startDateStr.trim().length() == 0)) //Modified By Dipesh on[13/08/2019][Start] { errCode = "VEDAT2"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else //Modified By Dipesh on[22/08/2019][Start] //if((endDateStr ==null)) if((endDateStr ==null || endDateStr.trim().length() == 0)) //Modified By Dipesh on[22/08/2019][End] { errCode = "VEDAT2"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("end_date",errCode,userId); errString = itmDbAcess.getErrorString("end_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if((endDate.compareTo(startDate) <= 0)) { errCode = "VTDATE1"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("end_date",errCode,userId); errString = itmDbAcess.getErrorString("end_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } //Modified By Dipesh on[18/07/2019][Start] //else if (childNodeName.equals("start_date") || childNodeName.equals("end_date")) else if (childNodeName.equalsIgnoreCase("start_date") || childNodeName.equalsIgnoreCase("end_date")) //Modified By Dipesh on[18/07/2019][End] { if(editFlag.equalsIgnoreCase("E")) { java.sql.Date dbFrDate = new java.sql.Date(System.currentTimeMillis()); java.sql.Date dbToDate = new java.sql.Date(System.currentTimeMillis()); //Modified By Dipesh on[18/07/2019][Start] //sql = "SELECT START_DATE,END_DATE FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' AND LINE_NO = "+lineNo+""; //System.out.println("SQL :: "+sql); //stmt = conn.createStatement(); //rs = stmt.executeQuery(sql); sql = "SELECT START_DATE,END_DATE FROM WORK_TABLE WHERE WORK_TBLNO = ? AND LINE_NO = ?"; System.out.println("SQL :: "+sql); pstmt = conn.prepareStatement(sql); pstmt.setString(1,workTblNo); pstmt.setInt(2,lineNo); rs = pstmt.executeQuery(); if(rs.next()) { dbFrDate = rs.getDate("START_DATE"); dbToDate = rs.getDate("END_DATE"); System.out.println("DomFrDate : "+startDate+" DbFromDate :"+dbFrDate+" DomEndDate :"+endDate+" dbEndDate :"+dbToDate); if(startDate.compareTo(new java.util.Date(dbFrDate.getTime())) == 0 && endDate.compareTo(new java.util.Date(dbToDate.getTime())) == 0){ break; } } //stmt.close(); if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[18/07/2019][End] } int count = 0; java.sql.Date startSqlDate = new java.sql.Date(startDate.getTime()); java.sql.Date endSqlDate = new java.sql.Date(endDate.getTime()); System.out.println("Work Table No ::"+workTblNo); if(workTblNo != null && workTblNo.trim().length() > 0) { //Modified By Dipesh on[19/07/2019][Start] //sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"'"; //System.out.println("SQL ::"+sql); //stmt = conn.createStatement(); //rs = stmt.executeQuery(sql); sql = "SELECT COUNT(*) as cnt FROM WORK_TABLE WHERE WORK_TBLNO = ?"; pstmt = conn.prepareStatement(sql); pstmt.setString(1,workTblNo); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt("cnt"); } if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] if(count > 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND ? BETWEEN START_DATE AND END_DATE AND LINE_NO != "+lineNo+""; System.out.println("SQL ::"+sql); pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); System.out.println("SET 1 "+Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if(count == 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND ? BETWEEN START_DATE AND END_DATE AND LINE_NO != "+lineNo+""; pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); System.out.println("SET 1 "+Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("end_date",errCode,userId); errString = itmDbAcess.getErrorString("end_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if(count == 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND START_DATE BETWEEN ? AND ? AND LINE_NO != "+lineNo+""; System.out.println("SQL ::"+sql); pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); pstmt.setTimestamp(2,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } else if(count == 0) { sql = "SELECT COUNT(*) FROM WORK_TABLE WHERE WORK_TBLNO = '"+workTblNo+"' "+ "AND END_DATE BETWEEN ? AND ? AND LINE_NO != "+lineNo+""; System.out.println("SQL ::"+sql); pstmt = conn.prepareStatement(sql); pstmt.setTimestamp(1,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(startDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); pstmt.setTimestamp(2,Timestamp.valueOf(genericUtility.getValidDateTimeString(simpleDateFormat.format(endDate),genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()))); rs = pstmt.executeQuery(); if(rs.next()) { count = rs.getInt(1); } //Modified By Dipesh on[19/07/2019][Start] if( rs != null ) { rs.close(); rs = null; } if( pstmt != null ) { pstmt.close(); pstmt = null; } //Modified By Dipesh on[19/07/2019][End] System.out.println("Count ::"+count); if(count > 0) { errCode = "VTINVOT"; //Modified By Dipesh on[13/08/2019][Start] //errString = getErrorString("start_date",errCode,userId); errString = itmDbAcess.getErrorString("start_date", errCode, userId, "", conn); //Modified By Dipesh on[13/08/2019][End] break; } } } } } } } } } } catch(Exception e) { System.out.println("Exception ::"+e); e.printStackTrace(); } finally { try { if(stmt != null){ stmt.close(); stmt = null; } if(pstmt != null){ pstmt.close(); pstmt = null; } if(conn != null) { conn.close(); } } catch(Exception ex) { System.out.println("Exception ::"+ex.getMessage()); ex.printStackTrace(); } } return errString; } private String checkNull(String input) { if (input == null) { input = ""; } return input; } }
\ No newline at end of file
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment