Commit e51e0b87 authored by cpatil's avatar cpatil

modify for item code and defect


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@92739 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c9bba916
...@@ -77,7 +77,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -77,7 +77,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
Timestamp effDate = null, newSysdate = null; Timestamp effDate = null, newSysdate = null;
String lineNo="",commTable="",itemSer="",itemCode="",effDateStr="",validUptoStr="",commType="",commPercOn="",commPerc=""; String lineNo="",commTable="",itemSer="",itemCode="",effDateStr="",validUptoStr="",commType="",commPercOn="",commPerc="";
String effDateTemp=null ; String effDateTemp=null ;
String descr = ""; String descr = "",shDescr="";
Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null; Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null;
int ctr1=0,k=0,l=1; int ctr1=0,k=0,l=1;
...@@ -110,7 +110,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -110,7 +110,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
childNode = childNodeList.item(ctr); childNode = childNodeList.item(ctr);
childNodeName = childNode.getNodeName(); childNodeName = childNode.getNodeName();
if(childNodeName.equalsIgnoreCase("comm_table") && ("A".equalsIgnoreCase(editFlag)) ) if(childNodeName.equalsIgnoreCase("comm_table") && ("A".equalsIgnoreCase(editFlag)) )
{ {
System.out.println("validation comm_table executed"); System.out.println("validation comm_table executed");
commTable = genericUtility.getColumnValue("comm_table",dom); commTable = genericUtility.getColumnValue("comm_table",dom);
...@@ -144,7 +144,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -144,7 +144,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
} }
} }
if(childNodeName.equalsIgnoreCase("descr") ) if(childNodeName.equalsIgnoreCase("descr") && ("A".equalsIgnoreCase(editFlag)) )
{ {
descr = genericUtility.getColumnValue("descr",dom); descr = genericUtility.getColumnValue("descr",dom);
...@@ -154,7 +154,62 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -154,7 +154,62 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
errString = itmDBAccessEJB.getErrorString("","VMDESCR",userId); errString = itmDBAccessEJB.getErrorString("","VMDESCR",userId);
break ; break ;
} }
else
{
sql = "SELECT COUNT(1) FROM COMM_HDR WHERE descr = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, descr );
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt > 0 )
{
errString = itmDBAccessEJB.getErrorString("","VMDESCEXIS",userId);
break ;
}
}
} }
if(childNodeName.equalsIgnoreCase("sh_descr") && ("A".equalsIgnoreCase(editFlag)) )
{
shDescr = genericUtility.getColumnValue("sh_descr",dom);
System.out.println("sh_descr === "+shDescr);
if(shDescr != null && shDescr.trim().length() > 0)
{
sql = "SELECT COUNT(1) FROM COMM_HDR WHERE sh_descr = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString( 1, shDescr );
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( cnt > 0 )
{
errString = itmDBAccessEJB.getErrorString("","VMSHDECEXS",userId);
break ;
}
}
}
} // end for } // end for
break; break;
...@@ -288,7 +343,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -288,7 +343,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
System.out.println("effDate date is :=> " + effDate); System.out.println("effDate date is :=> " + effDate);
System.out.println("validUpto date is :=> " + validUpto); System.out.println("validUpto date is :=> " + validUpto);
if( !validUpto.after(effDate) ) if( !validUpto.after(effDate) && !( validUpto.equals(effDate) ) )
{ {
System.out.println("effFrom.after(validUpto"); System.out.println("effFrom.after(validUpto");
errString = getErrorString("","INVEFDATE ",userId); errString = getErrorString("","INVEFDATE ",userId);
...@@ -311,7 +366,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -311,7 +366,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
System.out.println("effDate date is :=> " + effDate); System.out.println("effDate date is :=> " + effDate);
System.out.println("validUpto date is :=> " + validUpto); System.out.println("validUpto date is :=> " + validUpto);
if( !validUpto.after(effDate) ) if( !validUpto.after(effDate) && !( validUpto.equals(effDate) ) )
{ {
//Valid upto cannot be less than effective date //Valid upto cannot be less than effective date
errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId); errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId);
...@@ -362,13 +417,13 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -362,13 +417,13 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
} //END switch } //END switch
/*boolean res = dateCheck (dom,dom2,itemCode,itemSer); //comment by kunal on 22/02/13 boolean res = duplicateCheck (dom,dom2,itemCode,itemSer,effDateStr,validUptoStr,lineNo); //comment by kunal on 22/02/13
System.out.println("@@@@ res::"+res); System.out.println("@@@@ res::"+res);
if( res == true ) if( res == true )
{ {
errString = itmDBAccessEJB.getErrorString("","VMVALDTWR",userId); errString = itmDBAccessEJB.getErrorString("","VMVALDTWR",userId);
return errString; return errString;
}*/ }
}//END TRY }//END TRY
catch(Exception e) catch(Exception e)
{ {
...@@ -541,6 +596,41 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -541,6 +596,41 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
valueXmlString.append( "<eff_date><![CDATA[" ).append(sysDate).append( "]]></eff_date>\r\n" ); valueXmlString.append( "<eff_date><![CDATA[" ).append(sysDate).append( "]]></eff_date>\r\n" );
valueXmlString.append( "<valid_upto><![CDATA[" ).append( fSysDate ).append( "]]></valid_upto>\r\n" ); valueXmlString.append( "<valid_upto><![CDATA[" ).append( fSysDate ).append( "]]></valid_upto>\r\n" );
}
else if( currentColumn.trim().equalsIgnoreCase( "item_code" ) )
{
System.out.println("-------------------item_code-----------------------");
itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
System.out.println("item_code = "+itemCode);
if(itemCode != null && itemCode.trim().length() > 0 )
{
sql = "select descr from item where item_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
itemDescr = rs.getString(1);
valueXmlString.append("<item_descr>").append("<![CDATA[" + itemDescr +"]]>").append("</item_descr>");
}
else
{
valueXmlString.append("<item_descr>").append("<![CDATA[]]>").append("</item_descr>");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
}
else
{
valueXmlString.append("<item_descr>").append("<![CDATA[]]>").append("</item_descr>");
}
} }
valueXmlString.append("</Detail2>"); valueXmlString.append("</Detail2>");
...@@ -584,12 +674,12 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -584,12 +674,12 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
return valueXmlString.toString(); return valueXmlString.toString();
}//End of itemChanged }//End of itemChanged
public boolean dateCheck (Document dom,Document dom2,String pitemCode,String pitemSer) throws Exception public boolean duplicateCheck (Document dom,Document dom2,String pitemCode,String pitemSer,String peffDateStr,String pvalidUptoStr,String plineNo) throws Exception
{ {
String lineNo="",commTable="",itemSer="",itemCode="",effDateStr="",validUptoStr=""; String lineNo="",commTable="",itemSer="",itemCode="",effDateStr="",validUptoStr="";
String effDateTemp=null ; String effDateTemp=null ;
Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null; Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null,peffDate=null,pvalidUpto=null;
String errString = ""; String errString = "",editFlag="";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
//String userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode"); //String userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
int ctr1=0,k=0,l=1,noOfParent=0; int ctr1=0,k=0,l=1,noOfParent=0;
...@@ -605,8 +695,15 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -605,8 +695,15 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
{ {
noOfParent = detail2List.getLength(); noOfParent = detail2List.getLength();
System.out.println("@@@@@@@@ noOfParent [["+noOfParent +"]]"); System.out.println("@@@@@@@@ noOfParent [["+noOfParent +"]]");
System.out.println("@@@@ pitemCode:["+pitemCode+"]::::pitemSer["+pitemSer+"]"); System.out.println("@@@@ pitemCode:["+pitemCode+"]::::pitemSer["+pitemSer+"]::lineNo:["+lineNo+"]");
if( peffDateStr != null && pvalidUptoStr !=null && peffDateStr.trim().length() > 0 && pvalidUptoStr.trim().length() > 0 )
{
peffDate = Timestamp.valueOf(genericUtility.getValidDateString(peffDateStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
pvalidUpto = Timestamp.valueOf(genericUtility.getValidDateString(pvalidUptoStr, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
System.out.println("@@@@@parent date@@@peffDate["+peffDate+"] ::pvalidUpto["+pvalidUpto+"]");
for ( ctr1 = 0; ctr1 < noOfParent; ctr1++ ) //Loop for each node of current detail for ( ctr1 = 0; ctr1 < noOfParent; ctr1++ ) //Loop for each node of current detail
{ {
...@@ -614,11 +711,14 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -614,11 +711,14 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
effDateStr = genericUtility.getColumnValueFromNode( "eff_date", detail2List.item(ctr1) ); effDateStr = genericUtility.getColumnValueFromNode( "eff_date", detail2List.item(ctr1) );
validUptoStr = genericUtility.getColumnValueFromNode( "valid_upto", detail2List.item(ctr1) ); validUptoStr = genericUtility.getColumnValueFromNode( "valid_upto", detail2List.item(ctr1) );
itemSer = genericUtility.getColumnValueFromNode( "item_ser", detail2List.item(ctr1) ); itemSer = genericUtility.getColumnValueFromNode( "item_ser", detail2List.item(ctr1) );
System.out.println("@@@@ itemCode:["+itemCode+"]::::itemSer["+itemSer+"]"); editFlag = genericUtility.getColumnValueFromNode( "edit_flag", detail2List.item(ctr1) );
lineNo = genericUtility.getColumnValueFromNode( "line_no", detail2List.item(ctr1) );
System.out.println("@@@@ itemCode:["+itemCode+"]::::itemSer["+itemSer+"]:::editFlag["+editFlag+"]");
dateStr = validUptoStr+"@"+effDateStr ; dateStr = validUptoStr+"@"+effDateStr ;
System.out.println("dateStr[[[[[[[["+dateStr+"]]]]]]]]]"); System.out.println("dateStr[[[[[[[["+dateStr+"]]]]]]]]]");
if( ( pitemCode.trim().equalsIgnoreCase( itemCode.trim() )) && ( pitemSer.trim().equalsIgnoreCase(itemSer.trim() ) )) if( ( pitemCode.trim().equalsIgnoreCase( itemCode.trim() )) && ( pitemSer.trim().equalsIgnoreCase(itemSer.trim() ) ) && ( !( plineNo.trim().equalsIgnoreCase(lineNo.trim() ) )))
{ {
arrLstDate.add(dateStr); arrLstDate.add(dateStr);
...@@ -629,6 +729,44 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -629,6 +729,44 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
Collections.sort(arrLstDate); Collections.sort(arrLstDate);
System.out.println("@@@@@arrLstDate.size()["+arrLstDate.size()+"]]]:: Sorted::::"+arrLstDate); System.out.println("@@@@@arrLstDate.size()["+arrLstDate.size()+"]]]:: Sorted::::"+arrLstDate);
for( k=0;k< arrLstDate.size();k++)
{
String temp = (String) arrLstDate.get(k);
StringTokenizer st = new StringTokenizer(temp,"@");
while(st.hasMoreTokens())
{
if( l== 1)
{
validUptoTemp = st.nextToken();
l++;
}
else if( l== 2)
{
effDateTemp = st.nextToken();
l=1;
}
}
if( effDateTemp != null && validUptoTemp !=null && effDateTemp.trim().length() > 0 && validUptoTemp.trim().length() > 0 && !("D".equalsIgnoreCase(editFlag)))
{
effDateTemp2 = Timestamp.valueOf(genericUtility.getValidDateString(effDateTemp, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
validUptoTemp2 = Timestamp.valueOf(genericUtility.getValidDateString(validUptoTemp, genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat()) + " 00:00:00.0");
}
System.out.println("@@@@@date@@@effDateTemp2["+effDateTemp2+"] ::validUptoTemp2["+validUptoTemp2+"]");
if( (effDateTemp2 != null ) && (validUptoTemp2 != null ))
{
if( (effDateTemp2.equals( peffDate )) && ( validUptoTemp2.equals(pvalidUpto)) )
{
System.out.println("@@@@@@@ error in date");
return true;
}
}
}
/*
for( k=0;k< arrLstDate.size();k++) for( k=0;k< arrLstDate.size();k++)
{ {
String temp = (String) arrLstDate.get(k); String temp = (String) arrLstDate.get(k);
...@@ -675,12 +813,21 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca ...@@ -675,12 +813,21 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
//} //}
ValidUptoLastTemp = validUptoTemp2; ValidUptoLastTemp = validUptoTemp2;
} }
*/
} }
return false; return false;
} }
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
} }
......
...@@ -38,8 +38,9 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL ...@@ -38,8 +38,9 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
java.sql.Timestamp validUpto = null, validUptoLast=null; java.sql.Timestamp validUpto = null, validUptoLast=null;
SimpleDateFormat sdf1 = null; SimpleDateFormat sdf1 = null;
String effDateStr="",itemSer="",validUptostr="",commTable="",retString="",lineNo="",lineNoLast=""; String effDateStr="",itemSer="",validUptostr="",commTable="",retString="",lineNo="",lineNoLast="";
String customError = "",mainStr = "", begPart = "" ,endPart = ""; String customError = "",mainStr = "", begPart = "" ,endPart = "",userId="";
int cnt=0; int cnt=0;
//ConnDriver connDriver = null; //ConnDriver connDriver = null;
//Connection conn=null; //Connection conn=null;
System.out.println("Connection = "+conn); System.out.println("Connection = "+conn);
...@@ -52,7 +53,7 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL ...@@ -52,7 +53,7 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
dom = genericUtility.parseString(domString); dom = genericUtility.parseString(domString);
NodeList detail3List = dom.getElementsByTagName("Detail2"); NodeList detail3List = dom.getElementsByTagName("Detail2");
NodeList detail1List = dom.getElementsByTagName("Detail1"); NodeList detail1List = dom.getElementsByTagName("Detail1");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("@@@@@ postSave called"); System.out.println("@@@@@ postSave called");
System.out.println("@@@@@@@@ detail3List [[[[[[[["+detail3List.toString()+"]]]]]]]]]]]]]"); System.out.println("@@@@@@@@ detail3List [[[[[[[["+detail3List.toString()+"]]]]]]]]]]]]]");
System.out.println("@@@@@@@@ detail1List [[[[[[[["+detail1List.toString()+"]]]]]]]]]]]]]"); System.out.println("@@@@@@@@ detail1List [[[[[[[["+detail1List.toString()+"]]]]]]]]]]]]]");
...@@ -117,6 +118,11 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL ...@@ -117,6 +118,11 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
validUptoLast = new Timestamp( c.getTimeInMillis()); validUptoLast = new Timestamp( c.getTimeInMillis());
System.out.println("@@@@@@@@@@@@ new date into validUpto new : ["+validUptoLast+"]"); System.out.println("@@@@@@@@@@@@ new date into validUpto new : ["+validUptoLast+"]");
// System.out.println("@@@@@updating:::.["+commTable+"]...["+lineNo+"]....["+validUptoLast+"]....["+ cnt+"]record update successfully."); // System.out.println("@@@@@updating:::.["+commTable+"]...["+lineNo+"]....["+validUptoLast+"]....["+ cnt+"]record update successfully.");
if( effDateLast.after(validUptoLast)) //added cpatil
{
errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId);
return errString;
}
sql1="UPDATE COMM_DET SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? "; sql1="UPDATE COMM_DET SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1); pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1,validUptoLast); pstmt1.setTimestamp(1,validUptoLast);
...@@ -130,7 +136,7 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL ...@@ -130,7 +136,7 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
System.out.println("@@@@@@update sucess:::.["+commTable+"]...["+lineNoLast+"]....["+validUptoLast+"]....["+ cnt+"]record update successfully."); System.out.println("@@@@@@update sucess:::.["+commTable+"]...["+lineNoLast+"]....["+validUptoLast+"]....["+ cnt+"]record update successfully.");
} }
} }
if(effDate.after(validUptoLast)) if(effDate.after(validUptoLast) )
{ {
int diffInDays = (int)( (effDate.getTime() - validUptoLast.getTime()) / (1000 * 60 * 60 * 24) ); int diffInDays = (int)( (effDate.getTime() - validUptoLast.getTime()) / (1000 * 60 * 60 * 24) );
...@@ -142,6 +148,11 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL ...@@ -142,6 +148,11 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
c.add(Calendar.DATE, (diffInDays - 1)); c.add(Calendar.DATE, (diffInDays - 1));
validUptoLast = new Timestamp( c.getTimeInMillis()); validUptoLast = new Timestamp( c.getTimeInMillis());
System.out.println("@@@@@@@@@@@@ new date into validUpto new 2: ["+validUptoLast+"]"); System.out.println("@@@@@@@@@@@@ new date into validUpto new 2: ["+validUptoLast+"]");
if( effDateLast.after(validUptoLast)) //added cpatil
{
errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId);
return errString;
}
sql1="UPDATE COMM_DET SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? "; sql1="UPDATE COMM_DET SET valid_upto= ? WHERE COMM_TABLE= ? and LINE_NO = ? ";
pstmt1 = conn.prepareStatement(sql1); pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1,validUptoLast); pstmt1.setTimestamp(1,validUptoLast);
......
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