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
}
private String insertPricelist(String tranId,HashMap PList,ArrayList PricelistGen, Connection conn, String xtraParams) throws RemoteException, ITMException
{
PreparedStatement pstmtSql ,pstmtInsert= null;
ResultSet rs = null;
PreparedStatement pstmtSql ,pstmtInsert= null, pstmtInner = null;
ResultSet rs = null, rsInner = null;
String dbName = "";
String sql = "";
String retString = "";
......@@ -444,6 +444,7 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
}
else if(AutoExpire.equalsIgnoreCase("Y"))
{
/* Pavan R 6may19 commented and added inside loop
System.out.println("------------------------ Insert Auto Expiry ------------------");
//PricelistGen.add(PList);
System.out.println("List Size------["+PricelistGen.size()+"]");
......@@ -483,92 +484,136 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
System.out.println("[orderType1]----["+orderType1+"]");
chgref1 = (String)PList.get("CHG_REF_NO");
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=? ";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setString(1,plist);
pstmtSql.setString(2,itemcode);
rs = pstmtSql.executeQuery();
//pstmtSql = conn.prepareStatement(sql); //Pavan R 6may19 to update sql inside PricelistGen loop
pstmtInner = conn.prepareStatement(sql);
//pstmtSql.setString(1,plist);
//pstmtSql.setString(2,itemcode);
//rs = pstmtSql.executeQuery();
for (Ctr =0; Ctr < PricelistGen.size(); Ctr++)
{
System.out.println("Insert For loop.....................................");
PList=new HashMap<String, Object>();
{
System.out.println("Insert For loop.....................................");
//PList=new HashMap<String, Object>();
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");
System.out.println("Valid upto in price list"+ValidUpTo);
EffDate=rs.getTimestamp("eff_from");
SlabNo=rs.getDouble("slab_no");
System.out.println("slab No ----["+SlabNo+"]");
LotFrBrow=rs.getString("lot_no__from");
System.out.println("Lots Number from brow window"+LotFrBrow);
LotNoToBrow=rs.getString("lot_no__to");
System.out.println("Lots Number from brow window"+LotNoToBrow);
MinQtyBrow=rs.getDouble("min_qty");
MaxQtyBrow=rs.getDouble("max_qty");
System.out.println("Minimum value is@@@@@@@@@"+MinQtyBrow);
ValidUpTo=rsInner.getTimestamp("valid_upto");
System.out.println("Valid upto in price list"+ValidUpTo);
EffDate=rsInner.getTimestamp("eff_from");
SlabNo=rsInner.getDouble("slab_no");
System.out.println("slab No ----["+SlabNo+"]");
LotFrBrow=rsInner.getString("lot_no__from");
System.out.println("Lots Number from brow window"+LotFrBrow);
LotNoToBrow=rsInner.getString("lot_no__to");
System.out.println("Lots Number from brow window"+LotNoToBrow);
MinQtyBrow=rsInner.getDouble("min_qty");
MaxQtyBrow=rsInner.getDouble("max_qty");
System.out.println("Minimum value is@@@@@@@@@"+MinQtyBrow);
System.out.println("---------------------- Check if Conditon -----------------------");
DayDiff=(int)utilMethods.DaysAfter(ValidUpTo,EffDate);
DayDiff=(int)utilMethods.DaysAfter(ValidUpTo,EffDate);
System.out.println("DayDiff-----------["+DayDiff+"]");
if(DayDiff<=0 )
{
System.out.println("In if condition@@@@@");
if(LotFrBrow == lotnofrom && LotNoToBrow ==lotnoto1)
if(DayDiff<=0 )
{
System.out.println("In if condition ######");
ValidUpTo=utilMethods.RelativeDate((java.sql.Timestamp)PList.get("EFF_FROM"), -1 );
if( dbName.equalsIgnoreCase("db2"))
{
validupto=(ValidUpTo);
System.out.println("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 = ?";
pstmtSql=conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
}
else
{
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.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo);
int upcnt1=pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>"+upcnt1);
if(pstmtSql !=null)
{
pstmtSql.close();
pstmtSql=null;
}
System.out.println("In if condition@@@@@");
if (LotFrBrow == lotnofrom && LotNoToBrow == lotnoto1) {
System.out.println("In if condition ######");
ValidUpTo = utilMethods.RelativeDate((java.sql.Timestamp) PList.get("EFF_FROM"), -1);
if (dbName.equalsIgnoreCase("db2")) {
validupto = (ValidUpTo);
System.out.println("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 = ?";
pstmtSql = conn.prepareStatement(sql);
pstmtSql.setTimestamp(1, validupto);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo);
int upcnt1 = pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>" + upcnt1);
if (pstmtSql != null) {
pstmtSql.close();
pstmtSql = null;
}
} else {
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.setTimestamp(1, ValidUpTo);
pstmtSql.setString(2, plist);
pstmtSql.setString(3, itemcode);
pstmtSql.setString(4, unit);
pstmtSql.setString(5, listtype);
pstmtSql.setDouble(6, SlabNo);
int upcnt1 = pstmtSql.executeUpdate();
System.out.println("No. of rows updated------>>" + upcnt1);
if (pstmtSql != null) {
pstmtSql.close();
pstmtSql = null;
}
}
}
}
}
}
}
}// for end
rsInner.close(); rsInner =null; // Pavan R 6may19
pstmtInner.clearParameters();
}// for end
if(pstmtInner!= null ){
pstmtInner.close(); pstmtInner =null;
}
}// end autoexpire if
///////////////
// astr_PL.list_type = 'B'
......@@ -1616,8 +1661,8 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
public String confirmPlist(String tranId, Connection conn, String xtraParams) throws RemoteException, ITMException
{
PreparedStatement pstmtSql = null;
ResultSet rs = null;
PreparedStatement pstmtSql = null, pstmtInner = null;
ResultSet rs = null, rsInner = null;
String sql = "";
String dbName = "";
String retString = "";
......@@ -1736,47 +1781,72 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
PList.put("CALC_BASIS",calc=rs.getString("calc_basis"));
/*PList = new HashMap();
PList.put(PriceList,"PriceList");
PList.put(itemCode, "item_code");
PList.put(unit,"unit");
PList.put(listType,"list_type");
PList.put(validup,"valid_upto");
PList.put(lotNoForm,"lot_no__from");
PList.put(lotNoTo,"lot_no__to");
PList.put(minqty,"min_qty");
PList.put(maxqty,"max_qty");
PList.put(rate,"rate");
PList.put(rateType,"rate_type");
PList.put(minrate,"min_rate");
PList.put(maxrate,"max_rate");
PList.put(orderType,"order_type");
PList.put(PriceListParent,"price_list__parent");
PList.put(chgref,"chg_ref_no");
PList.put(refNO,"ref_no");
PList.put(refNoold,"ref_no_old");
PList.put(calc,"calc_basis");*/
PricelistGen.add(PList);
/*PList = new HashMap();
PList.put(PriceList,"PriceList");
PList.put(itemCode, "item_code");
PList.put(unit,"unit");
PList.put(listType,"list_type");
PList.put(validup,"valid_upto");
PList.put(lotNoForm,"lot_no__from");
PList.put(lotNoTo,"lot_no__to");
PList.put(minqty,"min_qty");
PList.put(maxqty,"max_qty");
PList.put(rate,"rate");
PList.put(rateType,"rate_type");
PList.put(minrate,"min_rate");
PList.put(maxrate,"max_rate");
PList.put(orderType,"order_type");
PList.put(PriceListParent,"price_list__parent");
PList.put(chgref,"chg_ref_no");
PList.put(refNO,"ref_no");
PList.put(refNoold,"ref_no_old");
PList.put(calc,"calc_basis");*/
PricelistGen.add(PList);
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)
{
return retString;
}
}*/
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() )
{
calcmeth=rs.getString(1);
plisttar=rs.getString(2);
PriceListParent=rs.getString(3);
//pstmtSql = conn.prepareStatement(sql);
//pstmtSql.setString(1, PriceList);
//rs = pstmtSql.executeQuery();
pstmtInner = conn.prepareStatement(sql);
pstmtInner.setString(1, PriceList);
rsInner = pstmtInner.executeQuery();
while ( rsInner.next() )
{
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__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;
calcRate = distCommon.calcRate(plisttar, PList, calcmeth, retString, conn);
......@@ -1795,21 +1865,31 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
}
}
PList.put("RATE",finalRate);
retString= insertPricelist(tranId, PList, PricelistGen, conn, xtraParams);
PricelistGen.add(PList);
// Pavan R 6may19 end
/*retString= insertPricelist(tranId, PList, PricelistGen, conn, xtraParams);
System.out.println("retString--------------------["+retString+"]");
if ( retString != null && retString.trim().length() > 0)
{
return retString;
}
if ( retString != null && retString.trim().length() > 0)
{
return retString;
}*/
}
}
rsInner.close(); rsInner = null;
pstmtInner.close(); pstmtInner = null;
}
rs.close();
rs = null;
pstmtSql.close();
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)
{
......@@ -1855,4 +1935,4 @@ public class PriceListConf extends ActionHandlerEJB implements PriceListConfLoca
return true;
}
}
}
\ No newline at end of file
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