Commit 8654b06b authored by prane's avatar prane

Changes in PriceListConf Component as suggested by sm sir

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@200391 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c96b56a0
...@@ -387,8 +387,8 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -387,8 +387,8 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
} }
private String insertPricelist(String tranId,HashMap PList,ArrayList PricelistGen, Connection conn, String xtraParams) throws RemoteException, ITMException private String insertPricelist(String tranId,HashMap PList,ArrayList PricelistGen, Connection conn, String xtraParams) throws RemoteException, ITMException
{ {
PreparedStatement pstmtSql ,pstmtInsert= null; PreparedStatement pstmtSql ,pstmtInsert= null, pstmtInner = null;
ResultSet rs = null; ResultSet rs = null, rsInner = null;
String dbName = ""; String dbName = "";
String sql = ""; String sql = "";
String retString = ""; String retString = "";
...@@ -444,6 +444,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -444,6 +444,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
} }
else if(AutoExpire.equalsIgnoreCase("Y")) else if(AutoExpire.equalsIgnoreCase("Y"))
{ {
/* Pavan R 6may19 commented and added inside loop
System.out.println("------------------------ Insert Auto Expiry ------------------"); System.out.println("------------------------ Insert Auto Expiry ------------------");
//PricelistGen.add(PList); //PricelistGen.add(PList);
System.out.println("List Size------["+PricelistGen.size()+"]"); System.out.println("List Size------["+PricelistGen.size()+"]");
...@@ -483,33 +484,79 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -483,33 +484,79 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
System.out.println("[orderType1]----["+orderType1+"]"); System.out.println("[orderType1]----["+orderType1+"]");
chgref1 = (String)PList.get("CHG_REF_NO"); chgref1 = (String)PList.get("CHG_REF_NO");
System.out.println("[chgref1]----["+chgref1+"]"); System.out.println("[chgref1]----["+chgref1+"]");
Pavan R 6may19 end
*/
sql="select valid_upto,eff_from,slab_no,lot_no__from,lot_no__to,min_qty,max_qty from pricelist where price_list=? and item_code=? "; sql="select valid_upto,eff_from,slab_no,lot_no__from,lot_no__to,min_qty,max_qty from pricelist where price_list=? and item_code=? ";
pstmtSql = conn.prepareStatement(sql); //pstmtSql = conn.prepareStatement(sql); //Pavan R 6may19 to update sql inside PricelistGen loop
pstmtSql.setString(1,plist); pstmtInner = conn.prepareStatement(sql);
pstmtSql.setString(2,itemcode); //pstmtSql.setString(1,plist);
rs = pstmtSql.executeQuery(); //pstmtSql.setString(2,itemcode);
//rs = pstmtSql.executeQuery();
for (Ctr =0; Ctr < PricelistGen.size(); Ctr++) for (Ctr =0; Ctr < PricelistGen.size(); Ctr++)
{ {
System.out.println("Insert For loop....................................."); System.out.println("Insert For loop.....................................");
PList=new HashMap<String, Object>(); //PList=new HashMap<String, Object>();
PList = (HashMap)PricelistGen.get(Ctr); PList = (HashMap)PricelistGen.get(Ctr);
if(rs.next()) //Pavan R 6may19 to added inside PricelistGen loop
System.out.println("------------------------ Insert Auto Expiry ------------------");
//PricelistGen.add(PList);
System.out.println("List Size------["+PricelistGen.size()+"]");
System.out.println("PList---["+PList+"]");
plist = (String)PList.get("PRICE_LIST");
System.out.println("Price list value is"+plist);
itemcode = (String)PList.get("ITEM_CODE");
System.out.println("item code in price list"+itemcode);
unit = (String)PList.get("UNIT");
listtype = (String)PList.get("LIST_TYPE");
System.out.println("List size is"+PricelistGen);
lotnofrom = (String)PList.get("LOT_NO__FROM");
System.out.println("lot no from [ "+ lotnofrom + "]");
lotnoto1 = (String)PList.get("LOT_NO__TO");
System.out.println("lot no to ["+lotnoto1 + "]");
efffrom = (java.sql.Timestamp)PList.get("EFF_FROM");
System.out.println("[efffrom]----["+efffrom+"]");
minqty = (Double)PList.get("MIN_QTY");
System.out.println("min qty in list"+minqty);
maxqty = (Double)PList.get("MAX_QTY");
System.out.println("[maxqty]----["+maxqty+"]");
rate1 = (Double) PList.get("RATE");
System.out.println("[rate1]-----["+rate1+"]");
ratetype = (String)PList.get("RATE_TYPE");
System.out.println("[ratetype]-----["+ratetype+"]");
minrate = (Double)PList.get("MIN_RATE");
System.out.println("[minrate]----["+minrate+"]");
maxrate1 = (Double)PList.get("MAX_RATE");
System.out.println("[maxrate1]---["+maxrate1+"]");
refNo1 = (String)PList.get("REF_NO");
System.out.println("[refNo1]---["+refNo1+"]");
refNoold1 = (String)PList.get("REF_NO_OLD");
System.out.println("refNoold1----["+refNoold1+"]");
PriceListParent1 = (String)PList.get("PRICE_LIST__PARENT");
System.out.println("[PriceListParent1]------["+PriceListParent1+"]");
orderType1 = (String)PList.get("ORDER_TYPE");
System.out.println("[orderType1]----["+orderType1+"]");
chgref1 = (String)PList.get("CHG_REF_NO");
System.out.println("[chgref1]----["+chgref1+"]");
pstmtInner.setString(1,plist);
pstmtInner.setString(2,itemcode);
rsInner = pstmtInner.executeQuery();
//Pavan R 6may19 end
if(rsInner.next())
{ {
ValidUpTo=rs.getTimestamp("valid_upto"); ValidUpTo=rsInner.getTimestamp("valid_upto");
System.out.println("Valid upto in price list"+ValidUpTo); System.out.println("Valid upto in price list"+ValidUpTo);
EffDate=rs.getTimestamp("eff_from"); EffDate=rsInner.getTimestamp("eff_from");
SlabNo=rs.getDouble("slab_no"); SlabNo=rsInner.getDouble("slab_no");
System.out.println("slab No ----["+SlabNo+"]"); System.out.println("slab No ----["+SlabNo+"]");
LotFrBrow=rs.getString("lot_no__from"); LotFrBrow=rsInner.getString("lot_no__from");
System.out.println("Lots Number from brow window"+LotFrBrow); System.out.println("Lots Number from brow window"+LotFrBrow);
LotNoToBrow=rs.getString("lot_no__to"); LotNoToBrow=rsInner.getString("lot_no__to");
System.out.println("Lots Number from brow window"+LotNoToBrow); System.out.println("Lots Number from brow window"+LotNoToBrow);
MinQtyBrow=rs.getDouble("min_qty"); MinQtyBrow=rsInner.getDouble("min_qty");
MaxQtyBrow=rs.getDouble("max_qty"); MaxQtyBrow=rsInner.getDouble("max_qty");
System.out.println("Minimum value is@@@@@@@@@"+MinQtyBrow); System.out.println("Minimum value is@@@@@@@@@"+MinQtyBrow);
System.out.println("---------------------- Check if Conditon -----------------------"); System.out.println("---------------------- Check if Conditon -----------------------");
...@@ -519,47 +566,41 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -519,47 +566,41 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
{ {
System.out.println("In if condition@@@@@"); System.out.println("In if condition@@@@@");
if(LotFrBrow == lotnofrom && LotNoToBrow ==lotnoto1) if (LotFrBrow == lotnofrom && LotNoToBrow == lotnoto1) {
{
System.out.println("In if condition ######"); System.out.println("In if condition ######");
ValidUpTo=utilMethods.RelativeDate((java.sql.Timestamp)PList.get("EFF_FROM"), -1 ); ValidUpTo = utilMethods.RelativeDate((java.sql.Timestamp) PList.get("EFF_FROM"), -1);
if( dbName.equalsIgnoreCase("db2")) if (dbName.equalsIgnoreCase("db2")) {
{ validupto = (ValidUpTo);
validupto=(ValidUpTo); System.out.println("Valid upto date is:" + ValidUpTo);
System.out.println("Valid upto date is:"+ValidUpTo); System.out.println("Converted Valid Upto Date is:" + validupto);
System.out.println("Converted Valid Upto Date is:"+validupto); sql = "update pricelist set valid_upto = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ?";
sql="update pricelist set valid_upto = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ?"; pstmtSql = conn.prepareStatement(sql);
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto); pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, plist); pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode); pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit); pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype); pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo); pstmtSql.setDouble(6, SlabNo);
int upcnt1=pstmtSql.executeUpdate(); int upcnt1 = pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>"+upcnt1); System.out.println("No. of rows updated------>>" + upcnt1);
if(pstmtSql !=null) if (pstmtSql != null) {
{
pstmtSql.close(); pstmtSql.close();
pstmtSql=null; pstmtSql = null;
}
} }
else } else {
{ sql = "update pricelist set valid_upto = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ?";
sql="update pricelist set valid_upto = ? where price_list =? and item_code = ? and unit = ? and list_type = ? and slab_no = ?"; pstmtSql = conn.prepareStatement(sql);
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, ValidUpTo); pstmtSql.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, plist); pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode); pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit); pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype); pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo); pstmtSql.setDouble(6, SlabNo);
int upcnt1=pstmtSql.executeUpdate(); int upcnt1 = pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>"+upcnt1); System.out.println("No. of rows updated------>>" + upcnt1);
if(pstmtSql !=null) if (pstmtSql != null) {
{
pstmtSql.close(); pstmtSql.close();
pstmtSql=null; pstmtSql = null;
} }
} }
...@@ -567,8 +608,12 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -567,8 +608,12 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
} }
} }
rsInner.close(); rsInner =null; // Pavan R 6may19
pstmtInner.clearParameters();
}// for end }// for end
if(pstmtInner!= null ){
pstmtInner.close(); pstmtInner =null;
}
}// end autoexpire if }// end autoexpire if
/////////////// ///////////////
// astr_PL.list_type = 'B' // astr_PL.list_type = 'B'
...@@ -1616,8 +1661,8 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -1616,8 +1661,8 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
public String confirmPlist(String tranId, Connection conn, String xtraParams) throws RemoteException, ITMException public String confirmPlist(String tranId, Connection conn, String xtraParams) throws RemoteException, ITMException
{ {
PreparedStatement pstmtSql = null; PreparedStatement pstmtSql = null, pstmtInner = null;
ResultSet rs = null; ResultSet rs = null, rsInner = null;
String sql = ""; String sql = "";
String dbName = ""; String dbName = "";
String retString = ""; String retString = "";
...@@ -1758,25 +1803,50 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -1758,25 +1803,50 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
PList.put(calc,"calc_basis");*/ PList.put(calc,"calc_basis");*/
PricelistGen.add(PList); PricelistGen.add(PList);
System.out.println("[PricelistGen----------------][" + PricelistGen + "]"); System.out.println("[PricelistGen----------------][" + PricelistGen + "]");
retString = insertPricelist(tranId,PList,PricelistGen, conn,xtraParams);
/*retString = insertPricelist(tranId,PList,PricelistGen, conn,xtraParams);Pavan R
if ( retString != null && retString.trim().length() > 0) if ( retString != null && retString.trim().length() > 0)
{ {
return retString; 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 = conn.prepareStatement(sql);
pstmtSql.setString(1, PriceList); //pstmtSql.setString(1, PriceList);
rs = pstmtSql.executeQuery(); //rs = pstmtSql.executeQuery();
while ( rs.next() ) pstmtInner = conn.prepareStatement(sql);
{ pstmtInner.setString(1, PriceList);
calcmeth=rs.getString(1); rsInner = pstmtInner.executeQuery();
plisttar=rs.getString(2); while ( rsInner.next() )
PriceListParent=rs.getString(3); {
calcmeth=rsInner.getString(1);
plisttar=rsInner.getString(2);
PriceListParent=rsInner.getString(3);
// Pavan R 6may19 to add new map in PricelistGen list
PList = new HashMap<String, Object>();
PList.put("PRICE_LIST",plisttar); PList.put("PRICE_LIST",plisttar);
PList.put("PRICE_LIST__PARENT",PriceListParent); PList.put("PRICE_LIST__PARENT",PriceListParent);
PList.put("ITEM_CODE",itemCode=rs.getString("item_code"));
PList.put("LOT_NO__FROM",lotNoForm=rs.getString("lot_no__from"));
PList.put("LOT_NO__TO",lotNoTo=rs.getString("lot_no__to"));
PList.put("RATE_TYPE",rateType=rs.getString("rate_type"));
PList.put("MIN_RATE",minrate=rs.getDouble("min_rate"));
PList.put("MAX_RATE",maxrate=rs.getDouble("max_rate"));
PList.put("CHG_REF_NO",chgref=rs.getString("chg_ref_no"));
PList.put("EFF_FROM",efffrom=rs.getTimestamp("eff_from"));
PList.put("VALID_UPTO",validup=rs.getTimestamp("valid_upto"));
PList.put("LIST_TYPE",listType=rs.getString("list_type"));
PList.put("ORDER_TYPE",orderType=rs.getString("order_type"));
PList.put("MANAGE_TYPE",manageType =rs.getString("manage_type"));
PList.put("MIN_QTY",minqty=rs.getDouble("min_qty"));
PList.put("MAX_QTY",maxqty=rs.getDouble("max_qty"));
PList.put("UNIT",unit=rs.getString("unit"));
PList.put("LINE_NO",lineno=rs.getInt("line_no"));
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"));
HashMap<String, String> calcRate = null; HashMap<String, String> calcRate = null;
calcRate = distCommon.calcRate(plisttar, PList, calcmeth, retString, conn); calcRate = distCommon.calcRate(plisttar, PList, calcmeth, retString, conn);
...@@ -1796,20 +1866,30 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca ...@@ -1796,20 +1866,30 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
} }
PList.put("RATE",finalRate); PList.put("RATE",finalRate);
PricelistGen.add(PList);
retString= insertPricelist(tranId, PList, PricelistGen, conn, xtraParams); // Pavan R 6may19 end
/*retString= insertPricelist(tranId, PList, PricelistGen, conn, xtraParams);
System.out.println("retString--------------------["+retString+"]"); System.out.println("retString--------------------["+retString+"]");
if ( retString != null && retString.trim().length() > 0) if ( retString != null && retString.trim().length() > 0)
{ {
return retString; return retString;
} }*/
} }
rsInner.close(); rsInner = null;
pstmtInner.close(); pstmtInner = null;
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmtSql.close(); pstmtSql.close();
pstmtSql = null; pstmtSql = null;
retString= insertPricelist(tranId, PList, PricelistGen, conn, xtraParams);
System.out.println("retString--------------------["+retString+"]");
if ( retString != null && retString.trim().length() > 0)
{
return retString;
}
} }
catch(Exception e) catch(Exception e)
{ {
......
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