Commit d6a5fc65 authored by agaikwad's avatar agaikwad

Added order type column condition in validation and item change of column total qty and item code.


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@99383 ce508802-f39f-4f6c-b175-0d175dae99d5
parent aa21cf84
......@@ -184,6 +184,26 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
distCommon = new DistCommon();
String SalesPers1 = null;
String totqtyStr=null;
String stateCd = null, browItemCode = null, itemCodeParentCur = null;
String itemCodeParent = null, colname = null;
double qtyper = 0.0, batqty = 0.0, appMinQty = 0.0, appMaxQty = 0.0, minqty = 0.0, freeQty = 0.0, totChargeQty = 0.0;
double totFreeQty = 0.0;
double chargrQty = 0.0, prvChargeQty = 0.0, unconfirmChargeQty = 0.0;
double mqty = 0.0, unconfirmFreeQty = 0.0, prvFreeQty = 0.0;
double qtyVal = 0.0;
int curLineno;
Timestamp appfromDate = null, validuptoDate = null, tranDateTs = null;
String curscheme = null, sqlStr = null;
String applyCustList = null;
String noapplyCustList = null, applicableordtypes = null, tranDateStr = null;
String[] token;
String prevscheme = null, applyCust = null;
String custSchemeCode = null, noapplyCust = null;
int llRow = 0, llSchcnt = 0, llCnt = 0;
String countCode = null;
boolean proceed;
try
{
//System.out.println(".....call validate method ....");
......@@ -713,7 +733,6 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
childNodeName = childNode.getNodeName();
if (childNodeName.equalsIgnoreCase("item_code"))
{
String countCode = null;
//itemNodeList = dom2.getElementsByTagName("item_code");
//lineNoList = dom2.getElementsByTagName("line_no");
detail2List = dom2.getElementsByTagName("Detail2");
......@@ -1114,8 +1133,6 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
}//end else if( ( disLink.equalsIgnoreCase("A")
String natureVal = genericUtility.getColumnValue( "nature", dom );
String sqlStr = null;
String itemCodeParent = null;
if( "F".equalsIgnoreCase( natureVal ) )
{
sqlStr = "select item_code__parent from item where item_code = ? ";
......@@ -1223,8 +1240,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
else if (childNodeName.startsWith("qty"))
{
//System.out.println( "Detail 2 Validation called for qty " );
String countCode = null;
itemCode = genericUtility.getColumnValue("item_code",dom);
siteCode = genericUtility.getColumnValue("site_code",dom1);
orderDate = genericUtility.getColumnValue("order_date",dom1);
......@@ -1303,7 +1319,6 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
+ " from scheme_applicability a, scheme_applicability_det b,bom c "
+ " where a.scheme_code = b.scheme_code and a.scheme_code = c.bom_code"
+ " and a.item_code = ?"
+ " and a.order_type = ? "
+ " and a.app_from <= ?"
+ " and a.valid_upto >= ?"
+ " and (b.site_code = ? or b.state_code = ? or b.count_code = ? ) and" +
......@@ -1311,18 +1326,106 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
System.out.println("select ITEM_SER var_value.." + sql);
pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1,itemCode);
pstmt1.setString(2,orderType);
pstmt1.setTimestamp(2,OrderDate);
pstmt1.setTimestamp(3,OrderDate);
pstmt1.setTimestamp(4,OrderDate);
pstmt1.setString(5,siteCode);
pstmt1.setString(6,stateCode);
pstmt1.setString(7,countCode);
pstmt1.setString(8,totqtyStr);
pstmt1.setString(4,siteCode);
pstmt1.setString(5,stateCode);
pstmt1.setString(6,countCode);
pstmt1.setString(7,totqtyStr);
rs2 = pstmt1.executeQuery();
while(rs2.next()) // Request_id-SUN15OCT15-added while condition For multiple scheme code by abhijit Gaikwad on 16-OCT-2015
{
schemeCode = rs2.getString("scheme_code") ;
System.out.println("schemeCode 1@@@@@@ [" + schemeCode + "]");
curscheme = rs2.getString("scheme_code") ;
System.out.println("schemeCode 1@@@@@@ [" + curscheme + "]");
sql = " select (case when apply_cust_list is null then ' ' else apply_cust_list end) apply_cust_list , "
+" (case when noapply_cust_list is null then ' ' else noapply_cust_list end) noapply_cust_list, "
+" order_type "
+" from scheme_applicability "
+" where scheme_code = ? ";
pstmt = conn.prepareStatement( sql );
pstmt.setString( 1, curscheme );
rs = pstmt.executeQuery();
if( rs.next() )
{
applyCustList = rs.getString( "apply_cust_list" );
noapplyCustList = rs.getString( "noapply_cust_list" );
applicableordtypes = rs.getString( "order_type" );
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if( "NE".equalsIgnoreCase( orderType.trim() ) && ( applicableordtypes == null || applicableordtypes.trim().length() == 0 ) )
{
continue;
}
else if( applicableordtypes != null && applicableordtypes.trim().length() > 0 )
{
proceed = false;
token = applicableordtypes.split( "," ); // f_get_token(ls_applicableordtypes,',')
for( int tokenCtr = 0; tokenCtr < token.length; tokenCtr++ )
{
if( orderType.trim().equalsIgnoreCase( token[ tokenCtr ] ) )
{
proceed = true;
break;
}
}
if( !proceed )
{
break;
}
}
//applicable customer
prevscheme = schemeCode;
schemeCode = curscheme;
if( applyCustList != null && applyCustList.trim().length() > 0 )
{
schemeCode = null;
token = applyCustList.split( "," );
for( int tokenCtr = 0; tokenCtr < token.length; tokenCtr++ )
{
if( custCode.trim().equalsIgnoreCase( token[ tokenCtr ] ) )
{
schemeCode = curscheme;
custSchemeCode = curscheme;
break;
}
}
}
//non-applicable customer
token = noapplyCustList.split( "," );
for( int tokenCtr = 0; tokenCtr < token.length; tokenCtr++ )
{
if( custCode.trim().equalsIgnoreCase( token[ tokenCtr ] ) )
{
schemeCode = null;
break;
}
}
if( schemeCode != null && schemeCode.trim().length() > 0 )
{
llSchcnt++;
}
else if( llSchcnt == 1 )
{
schemeCode = prevscheme;
}
System.out.println("Scheme code is:"+ schemeCode);
System.out.println("Scheme code is11111111:"+ curscheme);
if( schemeCode == null || schemeCode.trim().length() == 0 )
{
System.out.println("Enter if condition");
......@@ -1527,7 +1630,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
String natureVal = genericUtility.getColumnValue( "nature", dom );
if( "F".equalsIgnoreCase( natureVal ) )
{
String stateCd = null, browItemCode = null, itemCodeParentCur = null;
/*String stateCd = null, browItemCode = null, itemCodeParentCur = null;
String itemCodeParent = null, colname = null;
double qtyper = 0.0, batqty = 0.0, appMinQty = 0.0, appMaxQty = 0.0, minqty = 0.0, freeQty = 0.0, totChargeQty = 0.0;
double totFreeQty = 0.0;
......@@ -1544,7 +1647,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
String prevscheme = null, applyCust = null;
String custSchemeCode = null, noapplyCust = null;
int llRow = 0, llSchcnt = 0, llCnt = 0, i = 0;
boolean proceed;
boolean proceed;*/
//ResultSet rs1;
itemCode = genericUtility.getColumnValue( "item_code", dom );
......@@ -2349,6 +2452,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
String totQtyStr = "0";
String disparmVal = null;
String salesPers = "";
String Descr= null;
try
{
......@@ -4085,10 +4189,11 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
// if(applicableordtypes.trim() == "NE" && applicableordtypes.trim().length()==0)
//System.out.println("Cust list applicable.....["+applyCustList + "]");
//System.out.println("Cust list non applicable.....["+noapplyCustList + "]");
//System.out.println("order type applicable.....["+applicableordtypes + "]");
System.out.println("order type applicable.....["+applicableordtypes + "]");
//System.out.println("current order type ["+orderType + "]");
if(applicableordtypes.trim().equalsIgnoreCase("NE") && applicableordtypes.trim().length()==0)
{
System.out.println("In NE Oreder type Condtion");
continue;
}
else if ( applicableordtypes !=null && applicableordtypes.trim().length()>0)
......@@ -4097,14 +4202,17 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
while (applicableordtypes.length()>0)
{
pos = applicableordtypes.indexOf(",");
System.out.println("POSL:" + pos);
if (pos > -1)
{
lsToken = distCommon.getToken(applicableordtypes,",");
System.out
.println("Token is:"+lsToken);
//System.out.println("getToken().call and returnValue is....."+lsToken);
if (orderType.trim().equals(lsToken.trim()))
{
//System.out.println("order type matched.....["+orderType + "]");
System.out.println("order type matched.....["+orderType + "]");
lbProceed = true ;
break;
}
......@@ -4115,7 +4223,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
if (orderType.trim().equals(applicableordtypes.trim()))
{
//System.out.println("order type matched.....["+orderType + "]");
System.out.println("Else order type matched.....["+orderType + "]");
lbProceed = true ;
}
break;
......@@ -4125,6 +4233,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
}
System.out.println("Prev Scheme code"+lsPrevscheme);
lsPrevscheme = schemeCode;
System.out.println("SCheme code is" +lsPrevscheme);
schemeCode = lsCurscheme ;
System.out.println("Scheme COde"+schemeCode);
if (applyCustList.trim().length() > 0)
......@@ -4365,11 +4474,12 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
itemCode1 = genericUtility.getColumnValue("item_code",dom);
totqtyStr = genericUtility.getColumnValue("totqty",dom);
siteCode1 = genericUtility.getColumnValue("site_code",dom1);
siteCode = siteCode ==null ? "" : siteCode;
siteCode1 = siteCode1 ==null ? "" : siteCode1;
tranDateStr = genericUtility.getColumnValue("order_date",dom1);
tranDateStr = genericUtility.getValidDateString(tranDateStr,genericUtility.getApplDateFormat(),genericUtility.getDBDateFormat());
tranDate = java.sql.Timestamp.valueOf(tranDateStr + " 00:00:00.00");
custCd = genericUtility.getColumnValue("cust_code",dom1);
custCd = genericUtility.getColumnValue("cust_code",dom1);
sql="select state_code, count_code from customer where cust_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,custCd);
......@@ -4383,6 +4493,29 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
pstmt.close();
pstmt = null;
rs = null;
lsItemCode = itemCode1 ;
System.out.println("Item code in total qty"+lsItemCode);
sql = "select bom_code , item_stru from item where item_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,itemCode1);
rs = pstmt.executeQuery();
if(rs.next())
{
schemeCode =rs.getString("bom_code") == null ?"" : rs.getString("bom_code");
lsType =rs.getString("item_stru") == null ? "" : rs.getString("item_stru").trim();
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
orderType = genericUtility.getColumnValue("order_type",dom1);
orderType = orderType ==null ? "" : orderType;
if(lsType != "C")
{
lsOrderType = lsOrderType == null ? "" : lsOrderType ;
siteCode = siteCode == null ? "" : siteCode ;
stateCd = stateCd == null ? "" : stateCd ;
}
//System.out.println("totqtyStr...value....."+totqtyStr);
sql = " select a.scheme_code "
+" from scheme_applicability a, "
......@@ -4403,7 +4536,237 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
rs = pstmt.executeQuery();
while(rs.next())
{
Curscheme = rs.getString("scheme_code") == null ? "" : rs.getString("scheme_code");
lsCurscheme = rs.getString("scheme_code") == null ? "" : rs.getString("scheme_code");
System.out.println("Scheme COde of table scheme applicability total "+lsCurscheme);
mcount = 0 ;
sql ="select (case when apply_cust_list is null then '' else apply_cust_list end) apply_cust_list, "
+" (case when noapply_cust_list is null then '' else noapply_cust_list end) noapply_cust_list, "
+" order_type from scheme_applicability where scheme_code = ? " ;
pstmt1= conn.prepareStatement(sql);
pstmt1.setString(1,lsCurscheme);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
applyCustList =rs1.getString("apply_cust_list") == null ?"" : rs1.getString("apply_cust_list");
noapplyCustList=rs1.getString("noapply_cust_list") == null ? "" : rs1.getString("noapply_cust_list");
applicableordtypes=rs1.getString("order_type") == null ? "" : rs1.getString("order_type");
}
rs1.close();
rs1 = null;
pstmt1.close();
if(applicableordtypes.trim().equalsIgnoreCase("NE") && applicableordtypes.trim().length()==0)
{
System.out.println("In NE Oreder type Condtion");
continue;
}
else if ( applicableordtypes !=null && applicableordtypes.trim().length()>0)
{
lbProceed = false ;
while (applicableordtypes.length()>0)
{
pos = applicableordtypes.indexOf(",");
System.out.println("POS total Qty:" + pos);
if (pos > -1)
{
lsToken = distCommon.getToken(applicableordtypes,",");
System.out
.println("Token is:"+lsToken);
if (orderType.trim().equals(lsToken.trim()))
{
System.out.println("order type matched.....["+orderType + "]");
lbProceed = true ;
break;
}
applicableordtypes = applicableordtypes.substring(pos+1);
}
else
{
if (orderType.trim().equals(applicableordtypes.trim()))
{
System.out.println("Else order type matched total qty.....["+orderType + "]");
lbProceed = true ;
}
break;
}
}
if(!lbProceed) continue;
}
System.out.println("Prev Scheme code"+lsPrevscheme);
lsPrevscheme = schemeCode;
System.out.println("SCheme code is" +lsPrevscheme);
schemeCode = lsCurscheme ;
System.out.println("Scheme COde"+schemeCode);
if (applyCustList.trim().length() > 0)
{
schemeCode = null;
mcustCd = genericUtility.getColumnValue("cust_code",dom1);
mcustCd = mcustCd == null ?"" : mcustCd;
while(applyCustList.trim().length() > 0)
{
pos = applyCustList.indexOf(",");
if (pos > -1)
{
applyCust = distCommon.getToken(applyCustList,",");
if (applyCust.trim().equals( mcustCd.trim()))
{
schemeCode = lsCurscheme;
break;
}
applyCustList = applyCustList.substring(pos+1);
}
else
{
// 03/06/10 manoharan
//if (applyCust.trim().equals( applyCustList.trim()))
if (mcustCd.trim().equals( applyCustList.trim()))
{
schemeCode = lsCurscheme;
}
break;
}
}
}
if(schemeCode != null && noapplyCustList != null && noapplyCustList.trim().length()>0 )
{
mcustCd = genericUtility.getColumnValue("cust_code",dom1);
mcustCd = mcustCd == null ? "" : mcustCd;
while (noapplyCustList.trim().length()>0)
{
pos = noapplyCustList.indexOf(",");
if (pos > -1)
{
noapplyCust = distCommon.getToken(noapplyCustList,",");
if (noapplyCust.trim().equals( mcustCd.trim()))
{
schemeCode = null ;
break;
}
noapplyCustList = noapplyCustList.substring(pos+1);
}
else
{
// 03/06/10 manoharan
//if (noapplyCust.trim().equals( noapplyCustList.trim()))
if (mcustCd.trim().equals( noapplyCustList.trim()))
{
schemeCode = null ;
}
break;
}
}
}
if (schemeCode !=null)
llSchcnt ++ ;
else if( llSchcnt > 1 )
schemeCode = lsPrevscheme;
} // end of while
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if (llSchcnt > 1 )
schemeCode = lsPrevscheme ;
System.out.println("schemeCode = lsPrevscheme "+schemeCode);
System.out.println("schemeCode = lsPrevscheme@@@ "+lsPrevscheme);
//System.out.println("Scheme count.....["+llSchcnt + "] Scheme Code [" + schemeCode + "]");
sql="select (case when item_stru is null then 'S' else item_stru end)"
+"from item "
+"where item_code = ?" ;
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,itemCode1);
rs = pstmt.executeQuery();
if(rs.next())
{
lsItemStru = rs.getString(1) == null ?"" : rs.getString(1).trim();
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
//System.out.println("lsItemStru.....["+lsItemStru + "]");
if( lsItemStru != null && "F".equalsIgnoreCase(lsItemStru) && schemeCode.trim().length()>0)
{
sql="select count(*) from scheme_applicability where item_code = ?";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,itemCode1);
rs = pstmt.executeQuery();
if(rs.next())
{
cnt= rs.getInt(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if(cnt >1)
{
schemeCode = null;
}
else
{
schemeCode = schemeCode;
}
}
// System.out.println("schemeCode.....after item_stru check.....["+schemeCode + "]");
if(schemeCode !=null && schemeCode.trim().length()>0)
{
sql=" select slab_on from scheme_applicability where scheme_code = ? ";
pstmt= conn.prepareStatement(sql);
pstmt.setString(1,schemeCode);
rs = pstmt.executeQuery();
if(rs.next())
{
mslabOn = rs.getString("slab_on") == null ? "" : rs.getString("slab_on");
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
System.out.println("slab on....["+mslabOn + "]");
if(mslabOn != null && mslabOn.trim().length() > 0 && mslabOn.equalsIgnoreCase("N"))
{
sql="select descr from bom "
+"where bom_code = ? and (? between case when min_qty is null then 0 else min_qty end And case when max_qty is null then 0 else max_qty end) ";
pstmt= conn.prepareStatement(sql);
//pstmt.setString(1,lsSchemeCode);
pstmt.setString(1,schemeCode);
pstmt.setString(2,totqtyStr);
rs = pstmt.executeQuery();
if(rs.next())
{
Descr = rs.getString("descr");
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
System.out.println("Scheme Descr"+Descr);
Descr = Descr ==null ? "" : Descr;
valueXmlString.append("<st_scheme>").append("<![CDATA[Scheme Descr :"+Descr+"]]>").append("</st_scheme>");
}
else
{
integralQty = distCommon.getIntegralQty(custCd,itemCode1,siteCode1,conn);
valueXmlString.append("<st_scheme>").append("<![CDATA[Integral Quantity :"+integralQty+"]]>").append("</st_scheme>");
}
}
else
{ //System.out.println("....call()..getIntegralQty........");
System.out.println("Site code :"+ siteCode1);
integralQty = distCommon.getIntegralQty(custCd,itemCode1,siteCode1,conn);
//System.out.println("getIntegralQty()....return value...... "+integralQty);
//dw_detedit[ii_currformno].setitem(1,"st_scheme","Integral Quantity : " + string(lc_integral_qty,'#,##0.00') );
valueXmlString.append("<st_scheme>").append("<![CDATA[Integral Quantity :"+integralQty+"]]>").append("</st_scheme>");
}
/* Curscheme = rs.getString("scheme_code") == null ? "" : rs.getString("scheme_code");
System.out.println("Scheme COde of table scheme applicability total quantity "+lsCurscheme);
sql="select descr From scheme_applicability a,bom b Where a.scheme_code = b.bom_code And b.bom_code = ? And (? between case when b.min_qty is null then 0 else b.min_qty end And case when b.max_qty is null then 0 else b.max_qty end)";
......@@ -4434,7 +4797,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
{
valueXmlString.append("<st_scheme>").append("<![CDATA[]]>").append("</st_scheme>");
} //Abhijit Gaikwad 16/10/15 End
*/
if(totqtyStr != null && totqtyStr.trim().length() > 0)
{
......@@ -4516,7 +4879,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
listType = getPriceListType(priceList,conn);
if(listType.equalsIgnoreCase("L"))
{
String sql1 = " select count(1) from pricelist"
String sql1 = " select count(1) from pricelist "
+ " where price_list = ? "
+ " and item_code = ? "
+ " and unit = ? "
......@@ -4851,7 +5214,7 @@ public class SOrderForm extends ValidatorEJB implements SOrderFormLocal, SOrderF
valueXmlString.append("<st_shipper>").append("<![CDATA["+lsStr+"]]>").append("</st_shipper>");
//System.out.println("valueXmlString :["+valueXmlString.toString()+"]");
} //end totqty
} //end totqt
else if(currentColumn.trim().equalsIgnoreCase("cust_item__ref"))
{
custItemRef = genericUtility.getColumnValue("cust_item__ref",dom);
......
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