Commit c6c876ce authored by kshinde's avatar kshinde

Code changed for batch split if the entered batch no is already existing in the master pricelist


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@105195 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 33d53ea6
......@@ -374,8 +374,10 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
String plist="",itemcode="",unit="",listtype="";
String plist1="",refNoold="";
int cnt1=0,UpdCnt=0;
String LotNoFroma[] = null, LotNoToa[]=null;
//String LotNoFroma[] = null, LotNoToa[]=null;
ArrayList<String> LotNoFroma=new ArrayList<String>(); ArrayList<String> LotNoToa=new ArrayList<String>();
char left1=0,left2=0,left3 = 0,left4=0;
char left=0;
int updCnt = 0;
String mid1="",mid2="",mid3="",mid4="";
java.text.SimpleDateFormat sdf = null;
......@@ -461,7 +463,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
System.out.println("Minimum value is@@@@@@@@@"+MinQtyBrow);
}
System.out.println("check if conditionn");
DayDiff=(int)utilMethods.DaysAfter(ValidUpTo,efffrom);
DayDiff=(int)utilMethods.DaysAfter(ValidUpTo,EffDate);
System.out.println("check"+DayDiff);
if(DayDiff<=0 )
{
......@@ -555,7 +557,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
if(Count > 0)
{
System.out.println("insert in count");
/*System.out.println("insert in count");
Len=LotNoFrom.trim().length();
Ctr=1;
String s2=LotNoFrom.trim();
......@@ -635,7 +637,101 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
pstmtSql.close();
pstmtSql=null;
}
}//end if
}*///end if
String s2=LotNoFrom.trim();
System.out.println("Lotnumber "+s2.length());
left=0;
char right= s2.charAt(s2.length()-1);
int diff3=0;
String original="", result = "",result2="";
int length = LotNoFrom.trim().length();
/*System.out.println("insert in count");
Len=LotNoFrom.trim().length();
Ctr=1;
String s2=LotNoFrom.trim();
//String chekStr=LotNoFrom.trim();
*/
System.out.println("s22222222222222"+s2);
//char right= s2.charAt(s2.length()-1);
System.out.println("right s22222222222222"+right);
for ( int i = length - 1 ; i >= 0 ; i-- )
{
Character character = LotNoFrom.trim().charAt(i);
System.out.println("Char"+character);
boolean flag = isNumber(character);
if(!flag)
{
result = result + LotNoFrom.trim().charAt(i);
break;
}
System.out.println("result"+result);
cnt1++;
System.out.println("Count is"+cnt1);
}
System.out.println("Result of entered string is: "+result);
System.out.println("Count is:::"+cnt1);
int testOrginal=0;
int sub=0;
testOrginal=length-cnt1;
System.out.println("testOrginal["+testOrginal+"]");
String testSub1=LotNoFrom.trim().substring(0,testOrginal);
System.out.println("testSub1::-["+testSub1+"]");
int testSub=testSub1.length();
System.out.println("testSub"+testSub);
String testSub2=LotNoFrom.trim().substring(s2.length()-cnt1);
System.out.println("testSub2::-"+testSub2);
sub=Integer.parseInt(testSub2);
int u2=testSub2.length();
int OrgSub=sub-1;
String v1=String.valueOf(OrgSub);
int v2=v1.length();
System.out.println("V2:"+v2);
int z=u2-v2;
System.out.println("z:"+z);
if(z!=0)
{
for(int s3=0;s3<z;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
int q=NewStr.length();
String a2=Integer.toString(OrgSub);
System.out.println("NewStr"+NewStr);
LotNoFrom = testSub1.trim()+NewStr.trim()+a2 ;
System.out.println("LotNoFrom1@@@@LotNoFrom@@@@:"+LotNoFrom);
sql="update pricelist set lot_no__to = ? where price_list = ? and item_code = ? and unit = ? and list_type = ? and lot_no__from <= ? and lot_no__to >= ? and min_qty <= ? and max_qty >= ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setString(1,LotNoFrom);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5,listtype);
pstmtSql.setString(6, lotnofrom);
pstmtSql.setString(7, lotnofrom);
pstmtSql.setDouble(8, minqty);
pstmtSql.setDouble(9, maxqty);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated@@@@@@@@------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
}
//to expire the pricelist in case of revise circular of old circular.
......@@ -749,7 +845,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
ValidUpTo=utilMethods.RelativeDate((efffromdt), -1 );
Len=LotNoFrom.trim().length();
/*Len=LotNoFrom.trim().length();
String s=LotNoFrom.trim();
System.out.println("String s"+s);
Ctr=1;
......@@ -809,7 +905,79 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
{
String a1=Integer.toString(New);
LotNoFrom = Set + NewStr.trim() +a1.trim();
}
}*/
String s2=LotNoFrom.trim();
System.out.println("Lotnumber "+s2.length());
left=0;
char right= s2.charAt(s2.length()-1);
int diff3=0,cntt=0;
String original="", result = "",result2="";
int length = LotNoFrom.trim().length();
/*System.out.println("insert in count");
Len=LotNoFrom.trim().length();
Ctr=1;
String s2=LotNoFrom.trim();
//String chekStr=LotNoFrom.trim();
*/
System.out.println("s22222222222222"+s2);
//char right= s2.charAt(s2.length()-1);
System.out.println("right s22222222222222"+right);
for ( int i = length - 1 ; i >= 0 ; i-- )
{
Character character = LotNoFrom.trim().charAt(i);
System.out.println("Char"+character);
boolean flag = isNumber(character);
if(!flag)
{
result = result + LotNoFrom.trim().charAt(i);
break;
}
System.out.println("result"+result);
cnt1++;
System.out.println("Count is"+cnt1);
}
System.out.println("Result of entered string is: "+result);
System.out.println("Count is:::"+cnt1);
int testOrginal=0;
int sub=0;
testOrginal=length-cnt1;
System.out.println("testOrginal["+testOrginal+"]");
String testSub1=LotNoFrom.trim().substring(0,testOrginal);
System.out.println("testSub1::-["+testSub1+"]");
int testSub=testSub1.length();
System.out.println("testSub"+testSub);
String testSub2=LotNoFrom.trim().substring(s2.length()-cnt1);
System.out.println("testSub2::-"+testSub2);
sub=Integer.parseInt(testSub2);
int u2=testSub2.length();
int OrgSub=sub-1;
String v1=String.valueOf(OrgSub);
int v2=v1.length();
System.out.println("V2:"+v2);
int z=u2-v2;
System.out.println("z:"+z);
if(z!=0)
{
for(int s3=0;s3<z;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
int q=NewStr.length();
String a2=Integer.toString(OrgSub);
System.out.println("NewStr"+NewStr);
LotNoFrom = testSub1.trim()+NewStr.trim()+a2 ;
System.out.println("LotNoFrom1@@@@LotNoFrom@@@@:"+LotNoFrom);
if( dbName.equalsIgnoreCase("db2"))
{
validupto=(ValidUpTo);
......@@ -905,8 +1073,6 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
}
}
}
}
}
//split the batch if the entered batch no is already existing in the master pricelist
......@@ -929,6 +1095,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
if(rs.next())
{
cnt=rs.getInt(1);
System.out.println("Batch sql count"+cnt);
}
System.out.println("llCount22222222222-------->>["+cnt+"]");
if(rs != null)
......@@ -962,7 +1129,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
{
currentlotnofr=rs.getString(1);
currentlotnoto=rs.getString(2);
}
//}
recordfound = true;
System.out.println("Recode Found@@@@@@@@@@@@@"+recordfound);
currentlotnofrtemp = currentlotnofr;
......@@ -974,14 +1141,18 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
Set ="";
NewStr ="";
New = 0;
int diff3=0,cntt=0;
String original="", result = "",result2="";
String x=LotNoFrom.trim();
System.out.println("@@@@@x"+x);
String y=currentlotnofr.trim();
System.out.println("@@@@@x"+y);
String s2=y;
if(x.length()<y.length())
{
char right3= y.charAt(y.length()-1);
/*char right3= y.charAt(y.length()-1);
if(Character.isDigit(right3) )
{
do
......@@ -1028,8 +1199,67 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
//ls_lot_no__fr = ls_next_lot_no_fr
String a2=Integer.toString(New);
lotnoto = Set + NewStr.trim() +a2.trim();
lotnofr = nextlotnofr;
}
lotnofr = nextlotnofr;*/
int length = currentlotnofr.trim().length();
System.out.println("s22222222222222"+s2);
//char right= s2.charAt(s2.length()-1);
//System.out.println("right s22222222222222"+right);
for ( int i = length - 1 ; i >= 0 ; i-- )
{
Character character = currentlotnofr.trim().charAt(i);
System.out.println("Char"+character);
boolean flag = isNumber(character);
if(!flag)
{
result = result + currentlotnofr.trim().charAt(i);
break;
}
System.out.println("result"+result);
cnt1++;
System.out.println("Count is"+cnt1);
}
System.out.println("Result of entered string is: "+result);
System.out.println("Count is:::"+cnt1);
int testOrginal=0;
int sub=0;
testOrginal=length-cnt1;
System.out.println("testOrginal["+testOrginal+"]");
String testSub1=currentlotnofr.trim().substring(0,testOrginal);
System.out.println("testSub1::-["+testSub1+"]");
int testSub=testSub1.length();
System.out.println("testSub"+testSub);
String testSub2=currentlotnofr.trim().substring(s2.length()-cnt1);
System.out.println("testSub2::-"+testSub2);
sub=Integer.parseInt(testSub2);
int u2=testSub2.length();
int OrgSub=sub-1;
String v1=String.valueOf(OrgSub);
int v2=v1.length();
System.out.println("V2:"+v2);
int z=u2-v2;
System.out.println("z:"+z);
if(z!=0)
{
for(int s3=0;s3<z;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
int q=NewStr.length();
String a2=Integer.toString(OrgSub);
System.out.println("NewStr"+NewStr);
lotnoto = testSub1.trim()+NewStr.trim()+a2 ;
lotnofr = nextlotnofr;
System.out.println("LotNoFrom1@@@@LotNoFrom@@@@:"+lotnoto);
}
......@@ -1039,11 +1269,15 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
Set ="";
NewStr ="";
New = 0;
String p=LotNoFrom.trim();
String q=currentlotnofr.trim();
String p=currentlotnoto.trim();
String q=LotNoTo.trim();
s2=currentlotnoto.trim();
int length = currentlotnoto.trim().length();
System.out.println("s22222222222222"+s2);
if(p.length()<q.length())
{
char right4= y.charAt(y.length()-1);
/*char right4= y.charAt(y.length()-1);
if(Character.isDigit(right4) )
{
do
......@@ -1089,29 +1323,84 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
//ls_lot_no__fr = ls_next_lot_no_fr
String a2=Integer.toString(New);
lotnofr = Set + NewStr.trim() +a2.trim();
lotnofr = nextlotnofr;
}
lotnofr = nextlotnofr;*/
for ( int i = length - 1 ; i >= 0 ; i-- )
{
Character character = currentlotnoto.trim().charAt(i);
System.out.println("Char"+character);
boolean flag = isNumber(character);
if(!flag)
{
result = result + currentlotnoto.trim().charAt(i);
break;
}
System.out.println("result"+result);
cnt1++;
System.out.println("Count is"+cnt1);
}
System.out.println("Result of entered string is: "+result);
System.out.println("Count is:::"+cnt1);
int testOrginal=0;
int sub=0;
testOrginal=length-cnt1;
System.out.println("testOrginal["+testOrginal+"]");
String testSub1=currentlotnofr.trim().substring(0,testOrginal);
System.out.println("testSub1::-["+testSub1+"]");
int testSub=testSub1.length();
System.out.println("testSub"+testSub);
String testSub2=currentlotnoto.trim().substring(s2.length()-cnt1);
System.out.println("testSub2::-"+testSub2);
sub=Integer.parseInt(testSub2);
int u2=testSub2.length();
int OrgSub=sub+1;
String v1=String.valueOf(OrgSub);
int v2=v1.length();
System.out.println("V2:"+v2);
int z=u2-v2;
System.out.println("z:"+z);
if(z!=0)
{
for(int s3=0;s3<z;s3++)
{
System.out.println("For loop if ");
NewStr=NewStr.concat("0");
System.out.println("@@@@@@@@@New String:::::::::::"+NewStr.length());
}
}
//int q=NewStr.length();
String a2=Integer.toString(OrgSub);
System.out.println("NewStr"+NewStr);
nextlotnofr= testSub1.trim()+NewStr.trim()+a2 ;
lotnofr = nextlotnofr;
System.out.println("LotNoFrom1@@@@LotNoFrom@@@@:"+lotnofr);
}
int temp=0;
if(currentlotnofrtemp != LotNoFrom)
{
temp =Integer.parseInt(LotNoFrom);
int temp1=Integer.parseInt(LotNoTo);
nextlotnofr=LotNoFroma[temp]+1;
lotnoto=LotNoToa[temp1]+1;
//temp =Integer.parseInt(LotNoFrom);
//int temp1=Integer.parseInt(LotNoTo);
LotNoFroma.add(nextlotnofr);
LotNoToa.add(lotnoto);
}
//int tempnew=0;
/* if(currentlotnototemp <= LotNoTo)
/* if(currentlotnototemp <= LotNoTo)
{
tempnew =Integer.parseInt(LotNoFrom);
int temp2=Integer.parseInt(LotNoTo);
nextlotnofr=LotNoFroma[temp]+1;
lotnoto=LotNoToa[temp2]+1;
}*/
}
for(int i=0;i<LotNoFroma.size();i++)
{
tempnew =Integer.parseInt(LotNoFrom);
int temp2=Integer.parseInt(LotNoTo);
nextlotnofr=LotNoFroma[temp]+1;
lotnoto=LotNoToa[temp2]+1;
}*/
for(int i=1;i<temp;i++)
{
lotnofr = LotNoFroma[i];
lotnoto = LotNoToa[i];
lotnofr = LotNoFroma.get(i);
lotnoto = LotNoToa.get(i);
sql="select max(slab_no) from pricelist where price_list = ? AND item_code = ? ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, plist);
......@@ -1197,7 +1486,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
pstmtInsert.setString(2, itemcode);
pstmtInsert.setString(3, unit);
pstmtInsert.setString(4, listtype);
pstmtInsert.setDouble(5, slabno);
pstmtInsert.setDouble(5, LineNo);
pstmtInsert.setTimestamp(6, EffDate);
pstmtInsert.setTimestamp(7, ValidUpTo);
pstmtInsert.setString(8,lotnofrom);//lotnofr)
......@@ -1344,9 +1633,11 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
sql="select d.item_code,d.lot_no__from,d.lot_no__to,d.rate,d.rate_type,d.min_rate,d.max_rate,d.chg_ref_no,d.eff_from,d.valid_upto,m.price_list,m.list_type ,m.price_list__parent,m.order_type,m.manage_type,d.min_qty ,d.max_qty,d.unit,d.line_no,h.ref_no,ref_no_old,h.calc_basis from pricelist_hdr h, pricelist_det d, pricelist_mst m where h.tran_id = d.tran_id and h.price_list = m.price_list and h.tran_id = ?";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, tranId);
System.out.println("Tran_id"+tranId);
rs = pstmtSql.executeQuery();
while ( rs.next() )
while (rs.next())
{
System.out.print("Inside loop");
PList = new HashMap();
PList.put("item_code",itemCode=rs.getString("item_code"));
PList.put("lot_no__from",lotNoForm=rs.getString("lot_no__from"));
......@@ -1370,10 +1661,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
PList.put("ref_no",refNO=rs.getString("ref_no"));
PList.put("ref_no_old",refNoold=rs.getString("ref_no_old"));
PList.put("calc_basis",calc=rs.getString("calc_basis"));
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
/*PList = new HashMap();
PList.put(PriceList,"PriceList");
......@@ -1402,23 +1690,25 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
{
return retString;
}
sql="select calc_method, price_list__tar , price_list__parent from pricelist_mst_det where price_list = ? order by line_no ";
/*sql="select calc_method, price_list__tar , price_list__parent from pricelist_mst_det where price_list = ? order by line_no ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1, PriceList);
rs = pstmtSql.executeQuery();
while ( rs.next() )
/*while ( rs.next() )
{
calcmeth=rs.getString(1);
plisttar=rs.getString(2);
PriceListParent=rs.getString(3);
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
PList.put(plisttar,"price_list__tar");
PList.put(PriceListParent,"price_list__parentfrom");
PList.put("price_list__tar",plisttar);
PList.put("price_list__parentfrom",PriceListParent);
// PList.put(PriceListParent,"rate");
......@@ -1428,8 +1718,12 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
return retString;
}
}
}
}*/
}
rs.close();
rs = null;
pstmtSql.close();
pstmtSql = null;
}
catch(Exception e)
{
......@@ -1442,6 +1736,22 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
}
private static boolean isNumber(Character character)
{
boolean flag= false;
try
{
double num = Double.parseDouble(""+character);
flag = true;
return flag;
}
catch( Exception e)
{
return flag;
}
}
}
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