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
Timestamp effDate = null, newSysdate = null;
String lineNo="",commTable="",itemSer="",itemCode="",effDateStr="",validUptoStr="",commType="",commPercOn="",commPerc="";
String effDateTemp=null ;
String descr = "";
String descr = "",shDescr="";
Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null;
int ctr1=0,k=0,l=1;
......@@ -110,7 +110,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
childNode = childNodeList.item(ctr);
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");
commTable = genericUtility.getColumnValue("comm_table",dom);
......@@ -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);
......@@ -154,7 +154,62 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
errString = itmDBAccessEJB.getErrorString("","VMDESCR",userId);
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
break;
......@@ -288,7 +343,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
System.out.println("effDate date is :=> " + effDate);
System.out.println("validUpto date is :=> " + validUpto);
if( !validUpto.after(effDate) )
if( !validUpto.after(effDate) && !( validUpto.equals(effDate) ) )
{
System.out.println("effFrom.after(validUpto");
errString = getErrorString("","INVEFDATE ",userId);
......@@ -311,7 +366,7 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
System.out.println("effDate date is :=> " + effDate);
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
errString = itmDBAccessEJB.getErrorString("","INVEFDATE",userId);
......@@ -362,13 +417,13 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
} //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);
if( res == true )
{
errString = itmDBAccessEJB.getErrorString("","VMVALDTWR",userId);
return errString;
}*/
}
}//END TRY
catch(Exception e)
{
......@@ -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( "<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>");
......@@ -584,12 +674,12 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
return valueXmlString.toString();
}//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 effDateTemp=null ;
Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null;
String errString = "";
Timestamp effDateTemp2=null ,ValidUptoLastTemp=null, ValidUptoLastTemp2=null,peffDate=null,pvalidUpto=null;
String errString = "",editFlag="";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
//String userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
int ctr1=0,k=0,l=1,noOfParent=0;
......@@ -605,8 +695,15 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
{
noOfParent = detail2List.getLength();
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
{
......@@ -614,11 +711,14 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
effDateStr = genericUtility.getColumnValueFromNode( "eff_date", detail2List.item(ctr1) );
validUptoStr = genericUtility.getColumnValueFromNode( "valid_upto", 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 ;
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);
......@@ -629,6 +729,44 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
Collections.sort(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++)
{
String temp = (String) arrLstDate.get(k);
......@@ -675,12 +813,21 @@ public class CommissiondetIC extends ValidatorEJB implements CommissiondetICLoca
//}
ValidUptoLastTemp = validUptoTemp2;
}
}
*/
}
return false;
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
......
......@@ -38,8 +38,9 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
java.sql.Timestamp validUpto = null, validUptoLast=null;
SimpleDateFormat sdf1 = null;
String effDateStr="",itemSer="",validUptostr="",commTable="",retString="",lineNo="",lineNoLast="";
String customError = "",mainStr = "", begPart = "" ,endPart = "";
String customError = "",mainStr = "", begPart = "" ,endPart = "",userId="";
int cnt=0;
//ConnDriver connDriver = null;
//Connection conn=null;
System.out.println("Connection = "+conn);
......@@ -52,7 +53,7 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
dom = genericUtility.parseString(domString);
NodeList detail3List = dom.getElementsByTagName("Detail2");
NodeList detail1List = dom.getElementsByTagName("Detail1");
userId = getValueFromXTRA_PARAMS(xtraParams,"loginCode");
System.out.println("@@@@@ postSave called");
System.out.println("@@@@@@@@ detail3List [[[[[[[["+detail3List.toString()+"]]]]]]]]]]]]]");
System.out.println("@@@@@@@@ detail1List [[[[[[[["+detail1List.toString()+"]]]]]]]]]]]]]");
......@@ -117,6 +118,11 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
validUptoLast = new Timestamp( c.getTimeInMillis());
System.out.println("@@@@@@@@@@@@ new date into validUpto new : ["+validUptoLast+"]");
// 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 = ? ";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setTimestamp(1,validUptoLast);
......@@ -130,7 +136,7 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
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) );
......@@ -142,6 +148,11 @@ public class CommissiondetPos extends ValidatorEJB implements CommissiondetPosL
c.add(Calendar.DATE, (diffInDays - 1));
validUptoLast = new Timestamp( c.getTimeInMillis());
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 = ? ";
pstmt1 = conn.prepareStatement(sql1);
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