Commit 607b4b7e authored by ssalve's avatar ssalve

Sarita: Done changes to resolve duplicate Free Items Issues on 02FEB2018

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@179537 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5bfa5441
...@@ -216,9 +216,9 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -216,9 +216,9 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
{ {
System.out.println("getFreeSchemeAction is calling............."); System.out.println("getFreeSchemeAction is calling.............");
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n"); StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
String sql = ""; String sql = "",newDomXml = "";
String detCnt = "0"; String detCnt = "0";
int noOfDetails = 0; int noOfDetails = 0,domID1=0;
Timestamp TranDateDet = null; Timestamp TranDateDet = null;
Connection conn = null; Connection conn = null;
PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null; PreparedStatement pstmt = null,pstmt1 = null,pstmt2 = null;
...@@ -235,6 +235,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -235,6 +235,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
List<String> itemList = new ArrayList<String>(); List<String> itemList = new ArrayList<String>();
List<String> getSchemeList = new ArrayList<String>(); List<String> getSchemeList = new ArrayList<String>();
HashMap<String,Double> itemQuantityMap = new HashMap<String,Double>(); HashMap<String,Double> itemQuantityMap = new HashMap<String,Double>();
HashMap<String,Double> itemRateMap = new HashMap<String,Double>();
HashMap<String,List<String>> getSchemeItemList = new HashMap<String,List<String>>(); HashMap<String,List<String>> getSchemeItemList = new HashMap<String,List<String>>();
//HashMap<String,List<String>> freeItemInfoMap = new HashMap<String,List<String>>();//Added by sarita on 15JAN2018 //HashMap<String,List<String>> freeItemInfoMap = new HashMap<String,List<String>>();//Added by sarita on 15JAN2018
List<String> itemCodeListScheme = new ArrayList<String>(); List<String> itemCodeListScheme = new ArrayList<String>();
...@@ -246,6 +247,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -246,6 +247,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
HashMap<String,List<String>> freeItemInfoMap = new HashMap<String,List<String>>(); HashMap<String,List<String>> freeItemInfoMap = new HashMap<String,List<String>>();
HashMap<String,String> detai1ValueMap = new HashMap<String,String>(); HashMap<String,String> detai1ValueMap = new HashMap<String,String>();
List<String> schemeInfo = null; List<String> schemeInfo = null;
Set<String> finalApplicableSchemeSet = new HashSet<String>();
String itemValues = "",itemCodeSchm = "",rate = "",SaleOrder = "",schemeCode1 = "",siteCode1=""; String itemValues = "",itemCodeSchm = "",rate = "",SaleOrder = "",schemeCode1 = "",siteCode1="";
double finRate =0.0; double finRate =0.0;
...@@ -305,12 +307,26 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -305,12 +307,26 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
qty = qty + Double.valueOf(itemQuantityMap.get(itemCode)); qty = qty + Double.valueOf(itemQuantityMap.get(itemCode));
} }
itemQuantityMap.put(itemCode.trim(), qty); itemQuantityMap.put(itemCode.trim(), qty);
itemQuantityMap.put(itemCode.trim(), purRate); //itemQuantityMap.put(itemCode.trim(), purRate);
} }
else else
{ {
itemQuantityMap.put(itemCode.trim(), qty); itemQuantityMap.put(itemCode.trim(), qty);
} }
//Added by sarita on 02FEB2018
if(itemRateMap.containsKey(itemCode))
{
if(rate != null)
{
purRate = purRate + Double.valueOf(itemRateMap.get(itemCode));
}
itemRateMap.put(itemCode.trim(), purRate);
//itemQuantityMap.put(itemCode.trim(), purRate);
}
else
{
itemRateMap.put(itemCode.trim(), purRate);
}
} }
itr = itemList.iterator(); itr = itemList.iterator();
...@@ -327,8 +343,8 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -327,8 +343,8 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
{ {
s = "''"; s = "''";
} }
System.out.println("s :::::::::"+s); System.out.println("Purchase Item Code are :::"+s);
//Getting Distinct Scheme Code for Purchased Item -------------------------------
sql = "select distinct(scheme_code),item_code from sch_pur_items where item_code in ("+s+")"; sql = "select distinct(scheme_code),item_code from sch_pur_items where item_code in ("+s+")";
System.out.println("sql ==="+sql); System.out.println("sql ==="+sql);
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
...@@ -338,43 +354,29 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -338,43 +354,29 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
schemeCode1 = rs.getString("scheme_code"); schemeCode1 = rs.getString("scheme_code");
//getSchemeList.add(schemeCode); //getSchemeList.add(schemeCode);
itmCode = rs.getString("item_code"); itmCode = rs.getString("item_code");
System.out.println("Item Code is itmCode["+itmCode+"]"); System.out.println("Applicable Scheme for Purchase Item ["+itmCode+"]" + " is === Scheme Code ["+schemeCode1+"]");
sql = "select distinct(a.scheme_code) from scheme_applicability a,scheme_applicability_det b" sql = "select distinct(a.scheme_code) from scheme_applicability a,scheme_applicability_det b"
+ " where a.scheme_code = b.scheme_code" + " where a.scheme_code = b.scheme_code"
+ " and a.prod_sch = 'Y'" + " and a.prod_sch = 'Y'"
+ " and a.app_from<= ?" + " and a.valid_upto>= ?" + " and b.site_code=?" + " and a.app_from<= ?" + " and a.valid_upto>= ?"
+ " and b.site_code=?"
+ " or b.state_code = ?" + " or b.count_code= ?"; + " or b.state_code = ?" + " or b.count_code= ?";
pstmt2 = conn.prepareStatement(sql); pstmt2 = conn.prepareStatement(sql);
//pstmt2.setString(1, itmCode); //pstmt2.setString(1, itmCode);
pstmt2.setTimestamp(1, TranDateDet); pstmt2.setTimestamp(1, TranDateDet);
pstmt2.setTimestamp(2, TranDateDet); pstmt2.setTimestamp(2, TranDateDet);
//pstmt2.setString(3, schemeCode1);
pstmt2.setString(3, siteCode); pstmt2.setString(3, siteCode);
pstmt2.setString(4, ""); pstmt2.setString(4, "");
pstmt2.setString(5, ""); pstmt2.setString(5, "");
rs2 = pstmt2.executeQuery(); rs2 = pstmt2.executeQuery();
while(rs2.next()) while(rs2.next())
{ {
schemeCode = rs.getString("scheme_code"); schemeCode = rs2.getString("scheme_code");
getSchemeList.add(schemeCode); getSchemeList.add(schemeCode);
System.out.println("getSchemeList ::::::::::"+getSchemeList); //System.out.println("All Applicable Schemes in scheme_applicability Table ["+getSchemeList+"]");
System.out.println("schemeCode["+schemeCode+"]" + "itmCode["+itmCode+"]" + "\t"); //System.out.println("schemeCode["+schemeCode+"]" + "itmCode["+itmCode+"]" + "\t");
if(getSchemeItemList.containsKey(schemeCode))
{
//System.out.println("Inside 1");
schemeInfo = getSchemeItemList.get(schemeCode);
schemeInfo.add(itmCode.trim());
getSchemeItemList.put(schemeCode,schemeInfo);
}
else
{
//System.out.println("Inside 2");
schemeInfo = new ArrayList<String>();
schemeInfo.add(itmCode.trim());
System.out.println("schemeInfo1"+schemeInfo);
getSchemeItemList.put(schemeCode,schemeInfo);
}
} }
if(pstmt2 != null) if(pstmt2 != null)
{ {
...@@ -386,7 +388,33 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -386,7 +388,33 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
rs2.close(); rs2.close();
rs2 = null; rs2 = null;
} }
System.out.println("getSchemeItemList:::"+getSchemeItemList);
//checking Applicability of schemes
if(getSchemeList.contains(schemeCode1))
{
if(getSchemeItemList.containsKey(schemeCode1))
{
//System.out.println("Inside 1");
schemeInfo = getSchemeItemList.get(schemeCode1);
schemeInfo.add(itmCode.trim());
finalApplicableSchemeSet.add(schemeCode1);
getSchemeItemList.put(schemeCode1,schemeInfo);
}
else
{
//System.out.println("Inside 2");
schemeInfo = new ArrayList<String>();
schemeInfo.add(itmCode.trim());
finalApplicableSchemeSet.add(schemeCode1);
//System.out.println("schemeInfo1"+schemeInfo);
getSchemeItemList.put(schemeCode1,schemeInfo);
}
}
System.out.println("Applicable Scheme code and Item code are :::"+getSchemeItemList);
System.out.println("Scheme Applicable for Purchased Item in ArrayList ::["+finalApplicableSchemeSet+"]");
} }
if(pstmt != null) if(pstmt != null)
{ {
...@@ -399,19 +427,25 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -399,19 +427,25 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
rs = null; rs = null;
} }
itr = getSchemeList.iterator(); //itr = getSchemeList.iterator();
if(getSchemeItemList.size() > 0)
while(itr.hasNext())
{
s1 = s1 + "'"+(String) itr.next() + "'"+",";
}
//System.out.println("s1 is "+s1);
if(s1 != null && s1.length() != 0)
{ {
s1 = s1.substring(0,s1.length()-1); //List<String> finalApplicableSchemeList = getSchemeItemList.get("schemeInfo");
// System.out.println("s1 is "+s1); System.out.println("finalApplicableSchemeSet :: ["+finalApplicableSchemeSet+"]");
//itr = getSchemeItemList.get("schemeInfo");
itr = finalApplicableSchemeSet.iterator();
while(itr.hasNext())
{
s1 = s1 + "'"+(String) itr.next() + "'"+",";
}
//System.out.println("s1 is "+s1);
if(s1 != null && s1.length() != 0)
{
s1 = s1.substring(0,s1.length()-1);
// System.out.println("s1 is "+s1);
}
} }
//Working on Scheme Applicability... //Working on Scheme Applicability...
System.out.println("Scheme Applicability...."+getSchemeItemList.size()); System.out.println("Scheme Applicability...."+getSchemeItemList.size());
...@@ -432,18 +466,14 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -432,18 +466,14 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
purcBase = Double.valueOf(rs.getString("purc_base")); purcBase = Double.valueOf(rs.getString("purc_base"));
schAllowence1= Double.valueOf(checkDouble(rs.getString("sch_allowence"))); schAllowence1= Double.valueOf(checkDouble(rs.getString("sch_allowence")));
discount = Double.valueOf(checkDouble(rs.getString("discount"))); discount = Double.valueOf(checkDouble(rs.getString("discount")));
System.out.println("schemeType ["+schemeType+"]" + "schemeCode ["+schemeCode+"]" + "purcBase ["+purcBase+"]" +"schAllowence1 ["+schAllowence1+"]" +"Scheme Description ["+schemeDescr+"]" + "Discount is :::["+discount+"]"); System.out.println("Applicable schemeType ["+schemeType+"]" + "for schemeCode ["+schemeCode+"]" + "purcBase ["+purcBase+"]" +"schAllowence1 ["+schAllowence1+"]" +"Scheme Description ["+schemeDescr+"]" + "Discount is :::["+discount+"]");
//valueXmlString.append("<scheme_type>").append("<![CDATA[").append(schemeType).append("]]>").append("</scheme_type>\r\n");
//valueXmlString.append("<applicable_scheme>").append("<![CDATA[").append(schemeCode).append("]]>").append("</applicable_scheme>\r\n");
//valueXmlString.append("<scheme_description visible = \"1\">").append("<![CDATA[").append(schemeDescr).append("]]>").append("</scheme_description>\r\n");
if("0".equalsIgnoreCase(schemeType)) if("0".equalsIgnoreCase(schemeType))
{ {
System.out.println("Scheme Type ::::::::::::"+schemeType); System.out.println("Applied Scheme Type is ::"+schemeType);
itemCodeListScheme = getSchemeItemList.get(schemeCode); itemCodeListScheme = getSchemeItemList.get(schemeCode);
System.out.println("itemCodeListScheme **"+itemCodeListScheme); System.out.println("Purchased Item Code for Scheme Type 0 is "+itemCodeListScheme);
System.out.println("itemCodes are in ListScheme **"+itemCodeListScheme.size()); System.out.println("Total Purchased Item for Scheme Type 0 is "+itemCodeListScheme.size());
if(itemCodeListScheme.size() > 0) if(itemCodeListScheme.size() > 0)
{ {
for(int cntr=0; cntr<itemCodeListScheme.size();cntr++) for(int cntr=0; cntr<itemCodeListScheme.size();cntr++)
...@@ -453,8 +483,8 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -453,8 +483,8 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
if(itemQuantityMap.containsKey(itemCodeSchm)) if(itemQuantityMap.containsKey(itemCodeSchm))
{ {
double xmlQty = itemQuantityMap.get(itemCodeSchm); double xmlQty = itemQuantityMap.get(itemCodeSchm);
finRate = itemQuantityMap.get(itemCodeSchm); //finRate = itemQuantityMap.get(itemCodeSchm);
System.out.println("Applicable Rate is ==["+finRate+"]"+"Quantity in XML is ::["+xmlQty+"]" + "\t" + "Quantity Applicable for Scheme is ::["+purcBase+"]"); System.out.println("Quantity in XML is ::["+xmlQty+"]" + "\t" + "Quantity Applicable for Scheme is ::["+purcBase+"]");
if(xmlQty >= purcBase) if(xmlQty >= purcBase)
{ {
...@@ -470,9 +500,10 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -470,9 +500,10 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
//pstmt.setString(1,itemCodeSchm); //pstmt.setString(1,itemCodeSchm);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
freeItemListApplcbleType0.clear();
freeItemList.clear(); freeItemList.clear();
freeItemInfoMap.clear(); freeItemInfoMap.clear();
System.out.println("Values in list after clear for Scheme 1:::"+freeItemList + "\t" +"freeItemInfoMap ["+freeItemInfoMap+"] "); //System.out.println("Values in list after clear for Scheme 1:::"+freeItemList + "\t" +"freeItemInfoMap ["+freeItemInfoMap+"] ");
while(rs1.next()) while(rs1.next())
{ {
String freeItem = rs1.getString("item_code"); String freeItem = rs1.getString("item_code");
...@@ -494,7 +525,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -494,7 +525,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
System.out.println("Final List of Free Items for ::::Scheme Type 0 is "+finalFreeItems); System.out.println("Final List of Free Items for ::::Scheme Type 0 is "+finalFreeItems);
//s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr); //s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap); s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap);
System.out.println("***********"+s12); //System.out.println("***********"+s12);
valueXmlString.append(s12); valueXmlString.append(s12);
} }
else else
...@@ -504,13 +535,13 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -504,13 +535,13 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
} }
} }
} }
}//end of if block for type0 }//end of if block for type0
if("1".equalsIgnoreCase(schemeType)) if("1".equalsIgnoreCase(schemeType))
{ {
System.out.println("Scheme Type ::::::::::::"+schemeType); System.out.println("Applied Scheme Type is ::"+schemeType);
itemCodeListScheme = getSchemeItemList.get(schemeCode); itemCodeListScheme = getSchemeItemList.get(schemeCode);
System.out.println("itemCodeListScheme **"+itemCodeListScheme); System.out.println("Purchased Item Code for Scheme Type 1 is "+itemCodeListScheme);
System.out.println("itemCodes are in ListScheme **"+itemCodeListScheme.size()); System.out.println("Total Purchased Item for Scheme Type 1 is "+itemCodeListScheme.size());
if(itemCodeListScheme.size() > 0) if(itemCodeListScheme.size() > 0)
{ {
for(int cntr=0; cntr<itemCodeListScheme.size();cntr++) for(int cntr=0; cntr<itemCodeListScheme.size();cntr++)
...@@ -521,25 +552,33 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -521,25 +552,33 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
if(itemQuantityMap.containsKey(itemCodeSchm)) if(itemQuantityMap.containsKey(itemCodeSchm))
{ {
double xmlQty = itemQuantityMap.get(itemCodeSchm); double xmlQty = itemQuantityMap.get(itemCodeSchm);
finRate = itemQuantityMap.get(itemCodeSchm); //finRate = itemQuantityMap.get(itemCodeSchm);
System.out.println("Applicable Rate is ==["+finRate+"]"+"Quantity in XML is ::["+xmlQty+"]" + "\t" +"Purchased Items ["+itemCodeSchm+"]"+ "Quantity Applicable for Scheme is ::["+purcBase+"]"); //ContractNo=salesOrderIC.getContract(detai1ValueMap.get("site_code"), detai1ValueMap.get("cust_code"), getTimeStamp(detai1ValueMap.get("order_date")), itemCodeSchm, "", "", conn);
//SalesPriceList = distCommon.getSalesPriceList(detai1ValueMap.get("cust_code"),detai1ValueMap.get("cust_code__dlv"),detai1ValueMap.get("site_code"),ContractNo,itemCodeSchm,detai1ValueMap.get("order_date"),conn);
finRate = itemRateMap.get(itemCodeSchm);
System.out.println("Applicable Rate for Scheme Type 1 is ==["+finRate+"]"+"Quantity in XML is ::["+xmlQty+"]" + "\t" +"Purchased Items ["+itemCodeSchm+"]"+ "Quantity Applicable for Scheme is ::["+purcBase+"]" + " Scheme Allowence for Scheme is ::["+schAllowence1+"]");
if(xmlQty >= purcBase) if(xmlQty >= purcBase)
{ {
double freeQty = (int)(xmlQty / purcBase); System.out.println("freeQty is ::["+freeQty+"]"); //double freeQty = (int)(xmlQty / purcBase); System.out.println("freeQty is ::["+freeQty+"]");
freeQty = freeQty * schAllowence1; //freeQty = freeQty * schAllowence1;
//Added by sarita on 02FEB2018
double chargedQty = (finRate * xmlQty);
double freeQty = (chargedQty * schAllowence1)/purcBase;
System.out.println("chargedQty ["+chargedQty+"]" + "freeQty ["+freeQty+"]");
System.out.println("Items Applicable for Free Schemes :::"+itemCodeSchm + "free quantity"+(int)freeQty); System.out.println("Items Applicable for Free Schemes :::"+itemCodeSchm + "free quantity"+(int)freeQty);
freeItemListApplcbleType1.add(itemCodeSchm); freeItemListApplcbleType1.add(itemCodeSchm);
itemValues = getItemCode(freeItemListApplcbleType1); itemValues = getItemCode(freeItemListApplcbleType1);
System.out.println("Item Values for Scheme Type 1 is :::["+itemValues+"]"); System.out.println("Item Values for Scheme Type 1 is :::["+itemValues+"]");
sql = "SELECT S.item_code FROM SCH_PUR_ITEMS P ,SCH_OFFER_ITEMS S WHERE P.SCHEME_CODE=S.SCHEME_CODE AND P.ITEM_CODE in ("+itemValues+")"; sql = "SELECT S.item_code FROM SCH_PUR_ITEMS P ,SCH_OFFER_ITEMS S WHERE P.SCHEME_CODE=S.SCHEME_CODE AND P.ITEM_CODE in ("+itemValues+")";
System.out.println("sql :::::"+sql); //System.out.println("sql :::::"+sql);
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
//pstmt.setString(1,itemCodeSchm); //pstmt.setString(1,itemCodeSchm);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
freeItemListApplcbleType1.clear();
freeItemList.clear(); freeItemList.clear();
freeItemInfoMap.clear(); freeItemInfoMap.clear();
System.out.println("Values in list after clear for Scheme 1:::"+freeItemList); //System.out.println("Values in list after clear for Scheme 1:::"+freeItemList);
while(rs1.next()) while(rs1.next())
{ {
String freeItem = rs1.getString("item_code"); String freeItem = rs1.getString("item_code");
...@@ -559,7 +598,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -559,7 +598,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
finalFreeItems = freeItemInfoMap.get(itemCodeSchm); finalFreeItems = freeItemInfoMap.get(itemCodeSchm);
System.out.println("Final List of Free Items for ::::Scheme Type 1 is "+finalFreeItems); System.out.println("Final List of Free Items for ::::Scheme Type 1 is "+finalFreeItems);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap); s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap);
System.out.println("***********"+s12); //System.out.println("***********"+s12);
valueXmlString.append(s12); valueXmlString.append(s12);
} }
else else
...@@ -570,42 +609,47 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -570,42 +609,47 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
} }
} }
}//end of if block for type1//Added by sarita on 15JAN2018 }//end of if block for type1//Added by sarita on 15JAN2018
else if("2".equalsIgnoreCase(schemeType)) if("2".equalsIgnoreCase(schemeType))
{ {
System.out.println("Scheme Type ::::::::::::"+schemeType); System.out.println("Applied Scheme Type is ::"+schemeType);
itemCodeListScheme = getSchemeItemList.get(schemeCode); itemCodeListScheme = getSchemeItemList.get(schemeCode);
System.out.println("itemCodeListScheme **"+itemCodeListScheme); System.out.println("Purchased Item Code for Scheme Type 2 is "+itemCodeListScheme);
System.out.println("itemCodes are in ListScheme **"+itemCodeListScheme.size()); System.out.println("Total Purchased Item for Scheme Type 2 is "+itemCodeListScheme.size());
if(itemCodeListScheme.size() > 0) if(itemCodeListScheme.size() > 0)
{ {
for(int cntr=0; cntr<itemCodeListScheme.size();cntr++) for(int cntr=0; cntr<itemCodeListScheme.size();cntr++)
{ {
itemCodeSchm = itemCodeListScheme.get(cntr); itemCodeSchm = itemCodeListScheme.get(cntr);
System.out.println("itemCodeSchm ::::"+itemCodeSchm); //System.out.println("itemCodeSchm ::::"+itemCodeSchm);
if(itemQuantityMap.containsKey(itemCodeSchm)) if(itemQuantityMap.containsKey(itemCodeSchm))
{ {
double xmlQty = itemQuantityMap.get(itemCodeSchm); double xmlQty = itemQuantityMap.get(itemCodeSchm);
finRate = itemQuantityMap.get(itemCodeSchm); finRate = itemRateMap.get(itemCodeSchm);
System.out.println("Applicable Rate is ==["+finRate+"]"+"Quantity in XML is ::["+xmlQty+"]" + "\t" +"Purchased Items ["+itemCodeSchm+"]"+ "Quantity Applicable for Scheme is ::["+purcBase+"]"); System.out.println("Applicable Rate for Scheme Type 2 is ==["+finRate+"]"+"Quantity in XML is ::["+xmlQty+"]" + "\t" +"Purchased Items ["+itemCodeSchm+"]"+ "Quantity Applicable for Scheme is ::["+purcBase+"]");
if(xmlQty >= purcBase) if(xmlQty >= purcBase)
{ {
double freeQty = (int)(xmlQty / purcBase); System.out.println("freeQty is ::["+freeQty+"]"); //double freeQty = (int)(xmlQty / purcBase); System.out.println("freeQty is ::["+freeQty+"]");
freeQty = freeQty * schAllowence1; //freeQty = freeQty * schAllowence1;
//Added by sarita on 2FEB2018
double chargedQty = (finRate * xmlQty);
double freeQty = (chargedQty * schAllowence1)/purcBase;
System.out.println("chargedQty ["+chargedQty+"]" + "freeQty ["+freeQty+"]");
System.out.println("Items Applicable for Free Schemes :::"+itemCodeSchm + "free quantity"+(int)freeQty); System.out.println("Items Applicable for Free Schemes :::"+itemCodeSchm + "free quantity"+(int)freeQty);
freeItemListApplcbleType2.add(itemCodeSchm); freeItemListApplcbleType2.add(itemCodeSchm);
itemValues = getItemCode(freeItemListApplcbleType2); itemValues = getItemCode(freeItemListApplcbleType2);
System.out.println("Item Values for Scheme Type 2 is :::["+itemValues+"]"); System.out.println("Item Values for Scheme Type 2 is :::["+itemValues+"]");
sql = "SELECT S.item_code FROM SCH_PUR_ITEMS P ,SCH_OFFER_ITEMS S WHERE P.SCHEME_CODE=S.SCHEME_CODE AND P.ITEM_CODE in ("+itemValues+")"; sql = "SELECT S.item_code FROM SCH_PUR_ITEMS P ,SCH_OFFER_ITEMS S WHERE P.SCHEME_CODE=S.SCHEME_CODE AND P.ITEM_CODE in ("+itemValues+")";
System.out.println("sql :::::"+sql); //System.out.println("sql :::::"+sql);
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
//pstmt.setString(1,itemCodeSchm); //pstmt.setString(1,itemCodeSchm);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
freeItemListApplcbleType2.clear();
freeItemList.clear(); freeItemList.clear();
freeItemInfoMap.clear(); freeItemInfoMap.clear();
System.out.println("Values in list after clear for Scheme 2:::"+freeItemList); //System.out.println("Values in list after clear for Scheme 2:::"+freeItemList);
while(rs1.next()) while(rs1.next())
{ {
String freeItem = rs1.getString("item_code"); String freeItem = rs1.getString("item_code");
...@@ -625,7 +669,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -625,7 +669,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
finalFreeItems = freeItemInfoMap.get(itemCodeSchm); finalFreeItems = freeItemInfoMap.get(itemCodeSchm);
System.out.println("Final List of Free Items for ::::Scheme Type 2 is "+finalFreeItems); System.out.println("Final List of Free Items for ::::Scheme Type 2 is "+finalFreeItems);
s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap); s12 = returnFinalFreeItemDataUsingList(finalFreeItems, conn,schemeType,schemeCode,schemeDescr,discount,freeQty,itemCodeSchm,detai1ValueMap);
System.out.println("***********"+s12); //System.out.println("***********"+s12);
valueXmlString.append(s12); valueXmlString.append(s12);
} }
else else
...@@ -651,6 +695,31 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -651,6 +695,31 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
//valueXmlString.append(s12); //valueXmlString.append(s12);
}//end of if block for list }//end of if block for list
valueXmlString.append("</Root>\r\n"); valueXmlString.append("</Root>\r\n");
/* Added by kaustubh on 30 jan 2018 start */
/* to resolved issue of improper domID */
System.out.println("@@xmlString For Scheme :: "+valueXmlString.toString());
Document finalxml = genericUtility.parseString(valueXmlString.toString());
NodeList detail1NodeList = finalxml.getElementsByTagName("Detail");
System.out.println("@SchemeXml length:"+detail1NodeList.getLength());
for(int nodeCnt = 0;nodeCnt<detail1NodeList.getLength();nodeCnt++)
{
domID1++;
System.out.println("New DomID"+domID1);
//if(detail1NodeList.item(nodeCnt).getAttributes().getNamedItem("dbID") != null)
//{
detail1NodeList.item(nodeCnt).getAttributes().getNamedItem("domId").setNodeValue(String.valueOf(domID1));
//}
}
System.out.println("");
newDomXml = genericUtility.serializeDom(finalxml);
System.out.println("XML For Scheme with new domID ["+newDomXml+"]");
/* Added by kaustubh on 30 jan 2018 end */
} }
catch(Exception e) catch(Exception e)
{ {
...@@ -683,8 +752,8 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -683,8 +752,8 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
ex.printStackTrace(); ex.printStackTrace();
} }
} }
return valueXmlString.toString(); //return valueXmlString.toString();
return newDomXml;
} }
public String getItemDescr(String itemCode , Connection conn) public String getItemDescr(String itemCode , Connection conn)
...@@ -831,22 +900,23 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -831,22 +900,23 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
valueXmlString.append("<scheme_type>").append("<![CDATA[").append(schemeType).append("]]>").append("</scheme_type>\r\n"); valueXmlString.append("<scheme_type>").append("<![CDATA[").append(schemeType).append("]]>").append("</scheme_type>\r\n");
valueXmlString.append("<applicable_scheme>").append("<![CDATA[").append(schemeCode).append("]]>").append("</applicable_scheme>\r\n"); valueXmlString.append("<applicable_scheme>").append("<![CDATA[").append(schemeCode).append("]]>").append("</applicable_scheme>\r\n");
//valueXmlString.append("<scheme_description visible = \"1\">").append("<![CDATA[").append(schemeDescr).append("]]>").append("</scheme_description>\r\n");//changes by sarita on 18JAN2018 //valueXmlString.append("<scheme_description visible = \"1\">").append("<![CDATA[").append(schemeDescr).append("]]>").append("</scheme_description>\r\n");//changes by sarita on 18JAN2018
valueXmlString.append("<scheme_description>").append("<![CDATA[").append(schemeDescr).append("]]>").append("</scheme_description>\r\n"); //valueXmlString.append("<scheme_description>").append("<![CDATA[").append(schemeDescr).append("]]>").append("</scheme_description>\r\n");
valueXmlString.append("<purchase_item_code>").append("<![CDATA[").append(itemValues).append("]]>").append("</purchase_item_code>\r\n"); valueXmlString.append("<purchase_item_code>").append("<![CDATA[").append(itemValues).append("]]>").append("</purchase_item_code>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code>\r\n"); valueXmlString.append("<item_code>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code>\r\n");
//valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code__ord>\r\n"); //valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code__ord>\r\n");
//valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code__ord>\r\n"); //valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code__ord>\r\n");
valueXmlString.append("<item_descr>").append("<![CDATA[").append(itemDescription).append("]]>").append("</item_descr>\r\n"); //valueXmlString.append("<item_descr>").append("<![CDATA[").append(itemDescription).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<quantity>").append("<![CDATA[").append(freeQty).append("]]>").append("</quantity>\r\n"); valueXmlString.append("<item_descr>").append("<![CDATA[").append(schemeDescr).append("]]>").append("</item_descr>\r\n");
valueXmlString.append("<free_quantity>").append("<![CDATA[").append(freeQty).append("]]>").append("</free_quantity>\r\n");
valueXmlString.append("<discount>").append("<![CDATA[").append(discount).append("]]>").append("</discount>\r\n"); valueXmlString.append("<discount>").append("<![CDATA[").append(discount).append("]]>").append("</discount>\r\n");
valueXmlString.append("<nature>").append("<![CDATA[").append(nature).append("]]>").append("</nature>\r\n"); valueXmlString.append("<nature>").append("<![CDATA[").append(nature).append("]]>").append("</nature>\r\n");
valueXmlString.append("<sch_attr>").append("<![CDATA[").append(sch_attr).append("]]>").append("</sch_attr>\r\n"); //valueXmlString.append("<sch_attr>").append("<![CDATA[").append(sch_attr).append("]]>").append("</sch_attr>\r\n");
valueXmlString.append("<rate>").append("<![CDATA[").append(newRate).append("]]>").append("</rate>\r\n"); valueXmlString.append("<rate>").append("<![CDATA[").append(newRate).append("]]>").append("</rate>\r\n");
valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code__ord>\r\n"); valueXmlString.append("<item_code__ord>").append("<![CDATA[").append(item_Code).append("]]>").append("</item_code__ord>\r\n");
valueXmlString.append("<tax_chap>").append("<![CDATA[").append(taxChap).append("]]>").append("</tax_chap>\r\n"); valueXmlString.append("<tax_chap>").append("<![CDATA[").append(taxChap).append("]]>").append("</tax_chap>\r\n");
valueXmlString.append("<tax_class>").append("<![CDATA[").append(taxClass).append("]]>").append("</tax_class>\r\n"); valueXmlString.append("<tax_class>").append("<![CDATA[").append(taxClass).append("]]>").append("</tax_class>\r\n");
valueXmlString.append("<tax_env>").append("<![CDATA[").append(taxEnv).append("]]>").append("</tax_env>\r\n"); valueXmlString.append("<tax_env>").append("<![CDATA[").append(taxEnv).append("]]>").append("</tax_env>\r\n");
valueXmlString.append("<contract_no>").append("<![CDATA[").append(ContractNo).append("]]>").append("</contract_no>\r\n"); //valueXmlString.append("<contract_no>").append("<![CDATA[").append(ContractNo).append("]]>").append("</contract_no>\r\n");
valueXmlString.append("</Detail>\r\n"); valueXmlString.append("</Detail>\r\n");
} }
} }
...@@ -854,6 +924,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -854,6 +924,7 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
} }
catch(Exception e) catch(Exception e)
{ {
System.out.println("Exception in returnFinalFreeItemDataUsingList is:::"+e); System.out.println("Exception in returnFinalFreeItemDataUsingList is:::"+e);
e.printStackTrace(); e.printStackTrace();
} }
...@@ -974,12 +1045,12 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde ...@@ -974,12 +1045,12 @@ public class SorderAct extends ActionHandlerEJB implements SorderActLocal, Sorde
{ {
if(dateStr.indexOf(":") != -1) if(dateStr.indexOf(":") != -1)
{ {
System.out.println("inside logic"+dateStr); System.out.println("inside getTimeStamp METHOD logic"+dateStr);
return java.sql.Timestamp.valueOf(dateStr); return java.sql.Timestamp.valueOf(dateStr);
} }
else else
{ {
System.out.println("inside "); System.out.println("inside getTimeStamp METHOD ");
dbDateStr = genericUtility.getValidDateTimeString(dateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateTimeFormat()); dbDateStr = genericUtility.getValidDateTimeString(dateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateTimeFormat());
return java.sql.Timestamp.valueOf(dbDateStr); return java.sql.Timestamp.valueOf(dbDateStr);
} }
......
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