Commit 8da0e397 authored by kshinde's avatar kshinde

Changed logic for displaying MRP in side panel.

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@194356 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 2d42c744
package ibase.webitm.ejb.dis;
import ibase.system.config.AppConnectParm;
import ibase.utility.E12GenericUtility;
import ibase.utility.GenericUtility;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.DBAccessLocal;
import ibase.webitm.ejb.E12GenerateEDIEJB;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import org.apache.xerces.xs.LSInputList;
public class ItemDetails extends ValidatorEJB
{
//Added and replace by sarita on 2nd JAN 2018 for setting userinfo [start]
......@@ -32,9 +37,9 @@ public class ItemDetails extends ValidatorEJB
/*public ArrayList getItemListDetails(String itemCode)
{*/
////Changed By PriyankaC on 18March2018.[END]
public ArrayList getItemListDetails(String itemCode ,String siteCode,String sorder,String qty) throws ITMException
public ArrayList getItemListDetails(String itemCode ,String siteCode,String lotNo,String qty) throws ITMException
{
System.out.println("itemCode : " +itemCode +"siteCode " +siteCode+"quantity"+qty);//Added By PriyankaC on 18March2018.
System.out.println("itemCode : " +itemCode +"siteCode " +siteCode+"quantity"+qty+"LotNo"+lotNo);//Added By PriyankaC on 18March2018.
System.out.println("usersiteCode In ListDetails : " +usersiteCode);
if(siteCode == null || siteCode.trim().length()==0)
......@@ -215,7 +220,7 @@ sql =" select m.ITEM_CODE, m.descr as PARENT_DESCR, m.unit, x.QUANTITY, x.ALLOC_
pstmt.close();
pstmt = null;
double mRate=0;
if (llPlcount >= 1 && (!"L".equalsIgnoreCase(lsListType))) {
if (!"L".equalsIgnoreCase(lsListType.trim())) {
sql = "select max(ref_no) as ref_no from pricelist where price_list = ? and item_code= ? and unit=? and list_type= ?"
+ " and eff_from<=? and valid_upto>=? and min_qty<=? and max_qty>=? and (ref_no is not null)";
pstmt = conn.prepareStatement(sql);
......@@ -236,13 +241,13 @@ sql =" select m.ITEM_CODE, m.descr as PARENT_DESCR, m.unit, x.QUANTITY, x.ALLOC_
pstmt.close();
pstmt = null;
mRate = distCommon.pickRateRefnoWise(lsPriceList, sdf.format(orderDate), itemCode, lsRefNo, lsListType, qtyDb,conn);
mRate = pickRateRefnoWise(lsPriceList, sdf.format(orderDate), itemCode, lsRefNo, lsListType, qtyDb,lotNo,conn);
System.out.println("mRate::::"+mRate);
}
else
{
mRate = distCommon.pickRateRefnoWise(lsPriceList, sdf.format(orderDate), itemCode, lsRefNo, "L", qtyDb,conn);
mRate = pickRateRefnoWise(lsPriceList, sdf.format(orderDate), itemCode, lsRefNo, "L", qtyDb,"",conn);
System.out.println("mRate::::"+mRate);
}
itemList.add(String.valueOf(mRate));
......@@ -366,6 +371,1047 @@ sql =" select m.ITEM_CODE, m.descr as PARENT_DESCR, m.unit, x.QUANTITY, x.ALLOC_
}
return input.trim();
}
public double pickRateRefnoWise(String priceList, String trDate,String itemCode, String aRefNo, String listType, double quantity,String lotNoA,
Connection conn) throws ITMException {
PreparedStatement pstmt = null;
Statement stmt = null;
ResultSet rs = null;
ResultSet rs2 = null;
ResultSet rs3 = null;
ResultSet rs4 = null;
java.sql.Timestamp tranDate = null;
String sql = "";
String priceListParent = "";
String unit = "";
String siteCode = "";
String locCode = "";
String lotNo = "";
String lotSl = "";
String type = "";
double rate = 0.0;
double conv = 0;
int cnt = 0;
String tempDate = trDate;
String lsRefNo = "";
String lsLotNoFrom = "";
String lsCalcMethc = "", lsMethAppl = "", lsCalcPlist = "", lsCalcMeth = "", lsCalcMethp = "";
E12GenericUtility genericUtility = new E12GenericUtility();
type = listType;
try {
trDate = genericUtility.getValidDateString(trDate,
genericUtility.getApplDateFormat(),
genericUtility.getDBDateFormat());
tranDate = java.sql.Timestamp.valueOf(trDate + " 00:00:00");
/*if (aRefNo.indexOf("~t") > 0) {
String MulStr[] = aRefNo.split("~t");
siteCode = MulStr[0];
locCode = MulStr[1];
lotNo = MulStr[2];
lotSl = MulStr[3];
} else {*/
lsRefNo = aRefNo;
} catch (Exception e) {
System.out
.println("Exception...[pickRate] " + sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("type----" + type);
if (type.trim().equals("L")) {
rate = 0;
try {
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'L' " + "AND MIN_QTY <= " + quantity
+ " " + "AND MAX_QTY >= " + quantity + " "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
if (rs.next()) {
System.out.println("Pricelist found in pricelist master");
rate = rs.getDouble(1);
lsLotNoFrom = rs.getString(2);
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
else {
try {// try 2
rs.close();
pstmt.close();
pstmt = null;
rs = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "'" + " AND LIST_TYPE = 'L'";
System.out.println("priceList_mst----" + priceList);
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
priceListParent = rs.getString(1);
System.out.println("priceListParent----"
+ priceListParent);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if ((priceListParent == null)
|| (priceListParent.trim().length() == 0)) {
priceListParent = "";
// System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if (priceListParent.trim().length() > 0) {
try {// try 3
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ ""
+ " AND MAX_QTY >= "
+ quantity
+ " "
+ "AND LIST_TYPE = 'L' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs2 = pstmt.executeQuery();
// System.out.println("The priceListParent sql .. "+sql);
if (rs2.next()) {
rate = rs2.getDouble(1);
lsLotNoFrom = rs2.getString(2);
rs2.close();
pstmt.close();
pstmt = null;
rs2 = null;
System.out
.println("get rate for priceListParent----"
+ rate);
} else {
rs2.close();
pstmt.close();
pstmt = null;
rs2 = null;
// rate =
// pickRate(priceListParent,tempDate,itemCode,aLotNo,listType,
// quantity,conn);
return rate;
// return -1; //change done by kunal on
// 29/11/12 as per Manoj Sharma instruction
}
}// try 3
catch (Exception e) {
System.out.println("Exception...[pickRate] "
+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if
}// try 2
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
// else if
// rs.close();
// pstmt.clearParameters();
// pstmt.close();
// pstmt = null;
}// try 1
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if(type.trim().equals("L"))
if (type.trim().equals("F")) // FIXED PRICE ON DATE
{
rate = 0;
try {// try 1
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'F' " + "AND MIN_QTY <= " + quantity
+ " " + "AND MAX_QTY >= " + quantity + " "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
// System.out.println("Rate sql ..."+sql);
if (rs.next()) {
rate = rs.getDouble(1);
lsLotNoFrom = rs.getString(2);
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
else {
try {// try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "'" + " AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
priceListParent = rs.getString(1);
}
rs.close();
pstmt.close();
pstmt = null;
rs = null;
if ((priceListParent == null)
|| (priceListParent.trim().length() == 0)) {
priceListParent = "";
// System.out.println("The priceListParent if null .... "+priceListParent);
return -1;
}
if (priceListParent.trim().length() > 0) {
try {// try 3
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
+ "AND LIST_TYPE = 'F' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs2 = pstmt.executeQuery();
System.out
.println("The priceListParent sql .. "
+ sql);
if (rs2.next()) {
rate = rs2.getDouble(1);
lsLotNoFrom = rs2.getString(2);
rs2.close();
pstmt.close();
pstmt = null;
rs2 = null;
} else {
rs2.close();
pstmt.close();
pstmt = null;
rs2 = null;
return -1;
}
}// try 3
catch (Exception e) {
System.out.println("Exception...[pickRate] "
+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if
}// try 2
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// else if
// rs.close();
// pstmt.clearParameters();
// pstmt.close();
// pstmt = null;
}// try 1
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if(type.trim().equals("F"))
if (type.trim().equals("D")) // DESPATCH
{
rate = 0;
try {// try 1
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'L' " + "AND MIN_QTY <= " + quantity
+ " " + "AND MAX_QTY >= " + quantity + " "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
// System.out.println("Rate sql ..."+sql);
if (rs.next()) {
rate = rs.getDouble(1);
lsLotNoFrom = rs.getString(2);
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
else {
try {// try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "'" + " AND LIST_TYPE = 'L'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
priceListParent = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((priceListParent == null)
|| (priceListParent.trim().length() == 0)) {
priceListParent = "";
return -1;
}
if (priceListParent.trim().length() > 0) {
try {// try 3
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
+ "AND LIST_TYPE = 'L' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs2 = pstmt.executeQuery();
System.out
.println("The priceListParent sql .. "
+ sql);
if (rs2.next()) {
rate = rs2.getDouble(1);
lsLotNoFrom = rs2.getString(2);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
} else {
rate = 0;
try {// try 4
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceList
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = 'B'"
+ " and ref_no = '"
+ lsRefNo
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
+ "AND LOT_NO__FROM <= '"
+ lotNo
+ "' "
+ "AND LOT_NO__TO >= '"
+ lotNo
+ "' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs2 = pstmt.executeQuery();
if (rs2.next()) {
rate = rs2.getDouble(1);
lsLotNoFrom = rs2.getString(2);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
} else {
try {// try 5
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList
+ "'"
+ " AND LIST_TYPE = 'B'";
pstmt = conn
.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if (rs2.next()) {
priceListParent = rs2
.getString(1);
// System.out.println("The priceListParent is .... "+priceListParent);
}
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
if ((priceListParent == null)
|| (priceListParent
.trim()
.length() == 0)) {
priceListParent = "";
System.out
.println("The priceListParent if null .... "
+ priceListParent);
return -1;
}
if (priceListParent.trim()
.length() > 0) {
try {// try 6
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = 'B'"
+ " and ref_no = '"
+ lsRefNo
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
+ "AND LOT_NO__FROM <= '"
+ lotNo
+ "' "
+ "AND LOT_NO__TO >= '"
+ lotNo
+ "' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn
.prepareStatement(sql);
pstmt.setTimestamp(1,
tranDate);
pstmt.setTimestamp(2,
tranDate);
rs3 = pstmt
.executeQuery();
System.out
.println("The priceListParent sql .. "
+ sql);
if (rs3.next()) {
rate = rs3
.getDouble(1);
lsLotNoFrom = rs3
.getString(2);
rs3.close();
rs3 = null;
pstmt.close();
pstmt = null;
} else {
rs3.close();
rs3 = null;
pstmt.close();
pstmt = null;
return -1;
}
}// try 6
catch (Exception e) {
System.out
.println("Exception...[pickRate] "
+ sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(
e);
}
}// if
}// try 5
catch (Exception e) {
System.out
.println("Exception...[pickRate] "
+ sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// else if
}// try 4
catch (Exception e) {
System.out
.println("Exception...[pickRate] "
+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// else if
// rs2.close();
}// try 3
catch (Exception e) {
System.out.println("Exception...[pickRate] "
+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if
}// try 2
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// else if
// rs.close();
// pstmt.clearParameters();
// pstmt.close();
// pstmt = null;
}// try 1
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if(type.trim().equals("D"))
if (type.trim().equals("B")) // BATCH PRICE
{
rate = 0;
try {// try 1
if(lotNoA!=null && lotNoA.trim().length()>0)
{
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'B' " + "AND MIN_QTY <= " + quantity
+ " " + "AND MAX_QTY >= " + quantity + " "
+ " AND LOT_NO__FROM <= '" + lotNoA + "' "
+ "AND LOT_NO__TO >= '" + lotNoA + "'"
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
if (rs.next()) {
System.out.println("Pricelist found in pricelist master");
rate = rs.getDouble(1);
lsLotNoFrom = rs.getString(2);
rs.close();
pstmt.close();
pstmt = null;
rs = null;
}
}
if(rate<=0)
{
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = 'B'" + " and ref_no ='" + lsRefNo
+ "' " + "AND MIN_QTY <= " + quantity + " "
+ "AND MAX_QTY >= " + quantity + " "
// + "AND LOT_NO__FROM <= '"+lotNo+"' "
// + "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
if (rs.next()) {
rate = rs.getDouble(1);
lsLotNoFrom = rs.getString(2);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} else {
try {// try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList + "'" + " AND LIST_TYPE = 'B'";
pstmt = conn.prepareStatement(sql);
rs2 = pstmt.executeQuery();
if (rs2.next()) {
priceListParent = rs2.getString(1);
}
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
if ((priceListParent == null)
|| (priceListParent.trim().length() == 0)) {
priceListParent = "";
System.out
.println("The priceListParent if null .... "
+ priceListParent);
return -1;
}
if (priceListParent.trim().length() > 0) {
try {// try 3
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = 'B'"
+ " and ref_no ='"
+ lsRefNo
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
// + "AND LOT_NO__FROM <= '"+lotNo+"' "
// + "AND LOT_NO__TO >= '"+lotNo+"' "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs2 = pstmt.executeQuery();
// System.out.println("The priceListParent sql .. "+sql);
if (rs2.next()) {
rate = rs2.getDouble(1);
lsLotNoFrom = rs2.getString(2);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
} else {
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
return -1;
}
}// try 3
catch (Exception e) {
System.out.println("Exception...[pickRate] "
+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if
}// try 2
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}
}// else if
// rs.close();
// pstmt.clearParameters();
// pstmt.close();
// pstmt = null;
}// try1
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if(type.trim().equals("B"))
type = listType;
if ((type.trim().equals("M")) || (type.trim().equals("N"))) // Discount
// PRICE
{
rate = 0;
System.out.println("Inside type ::-<M><N>-::");
try {// try 1
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '" + priceList + "' "
+ "AND ITEM_CODE = '" + itemCode + "' "
+ "AND LIST_TYPE = '" + type + "' " + "AND MIN_QTY <= "
+ quantity + " " + "AND MAX_QTY >= " + quantity + " "
+ "AND EFF_FROM <= ? " + "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs = pstmt.executeQuery();
// System.out.println("Rate sql ..."+sql);
if (rs.next()) {
rate = rs.getDouble(1);
lsLotNoFrom = rs.getString(2);
rs.close();
rs = null;
pstmt.close();
pstmt = null;
} else {
type = listType;
try {// try 2
rs.close();
rs = null;
pstmt.close();
pstmt = null;
sql = "SELECT (CASE WHEN PRICE_LIST__PARENT IS NULL THEN '' ELSE PRICE_LIST__PARENT END) "
+ "FROM pricelist_mst WHERE PRICE_LIST = '"
+ priceList
+ "'"
+ " AND LIST_TYPE = '"
+ type
+ "'";
pstmt = conn.prepareStatement(sql);
rs = pstmt.executeQuery();
if (rs.next()) {
priceListParent = rs.getString(1);
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if ((priceListParent == null)
|| (priceListParent.trim().length() == 0)) {
priceListParent = "";
System.out
.println("The priceListParent if null .... "
+ priceListParent);
return -1;
}
if (priceListParent.trim().length() > 0) {
type = listType;
try {// try 3
sql = "SELECT RATE,lot_no__from FROM PRICELIST "
+ "WHERE PRICE_LIST = '"
+ priceListParent
+ "' "
+ "AND ITEM_CODE = '"
+ itemCode
+ "' "
+ "AND LIST_TYPE = '"
+ type
+ "' "
+ "AND MIN_QTY <= "
+ quantity
+ " "
+ "AND MAX_QTY >= "
+ quantity
+ " "
+ "AND EFF_FROM <= ? "
+ "AND VALID_UPTO >= ?";
pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(1, tranDate);
pstmt.setTimestamp(2, tranDate);
rs2 = pstmt.executeQuery();
System.out
.println("The priceListParent sql .. "
+ sql);
if (rs2.next()) {
rate = rs2.getDouble(1);
lsLotNoFrom = rs2.getString(2);
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
} else {
rs2.close();
rs2 = null;
pstmt.close();
pstmt = null;
return -1;
}
}// try 3
catch (Exception e) {
System.out.println("Exception...[pickRate] "
+ sql + e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if
}// try 2
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// else
// rs.close();
// pstmt.clearParameters();
// pstmt.close();
// pstmt = null;
}// try 1
catch (Exception e) {
System.out.println("Exception...[pickRate] " + sql
+ e.getMessage());
e.printStackTrace();
throw new ITMException(e);
}
}// if((type.trim().equals("M")) || (type.trim().equals("N")))
// if(rate>0)
// {
// if(priceList!=null && priceList.trim().length()>0)
// {
// try
// {
// sql = "select calc_method from pricelist_mst where price_list =?";
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, priceList);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// lsCalcMethc = rs.getString("calc_method");
// //System.out.println("Rate is .*...."+rate);
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
//
//
// sql =
// "select method_applicable from pricelist_mst where price_list = ?";
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, priceListParent);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// lsMethAppl = rs.getString("method_applicable");
// //System.out.println("Rate is .*...."+rate);
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
//
// } catch (SQLException e)
// {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// else
// {
// try
// {
// sql =
// "select calc_method, method_applicable from pricelist_mst where price_list =?";
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, priceList);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// lsCalcMethc = rs.getString("calc_method");
// lsMethAppl = rs.getString("method_applicable");
// //System.out.println("Rate is .*...."+rate);
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
// } catch (SQLException e)
// {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
//
// if(!lsMethAppl.equalsIgnoreCase("N"))
// {
// if(lsMethAppl.equalsIgnoreCase("C"))
// {
// lsCalcPlist=priceList;
// lsCalcMeth=lsCalcMethc;
// }
// else if(lsMethAppl.equalsIgnoreCase("P"))
// {
// if(priceList!=null && priceList.trim().length()>0)
// {
// try
// {
// sql = "select calc_method from pricelist_mst where price_list =?";
// pstmt = conn.prepareStatement(sql);
// pstmt.setString(1, priceList);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// lsCalcMethp = rs.getString("calc_method");
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
// }
// else
// {
// if(lsCalcMethp==null || lsCalcMethp.trim().length()==0)
// {
// lsCalcPlist=priceList;
// lsCalcMeth=lsCalcMethc;
// }
// else
// {
// lsCalcPlist=priceListParent;
// lsCalcMeth=lsCalcMethp;
// }
// }
// } catch (SQLException e)
// {
// // TODO Auto-generated catch block
// e.printStackTrace();
// }
// }
// else
// {
// lsCalcPlist=priceList;
// lsCalcMeth=lsCalcMethc;
// }
// }
//
// if(lsCalcMeth!=null && lsCalcMeth.trim().length()>0)
// {
// //
// }
// }
// }
// if(type.trim().equals("I")) //Inventory
// {
// rate = 0;
// if ((lotSl == null) || (lotSl.trim().length() == 0))
// {
// System.out.println("Inside type ::-<I>-::");
// try
// {//try 1
// sql = "SELECT RATE FROM STOCK "
// + "WHERE ITEM_CODE = '"+itemCode+"' "
// + "AND SITE_CODE = '"+siteCode+"' "
// + "AND LOC_CODE = '"+locCode+"' "
// + "AND LOT_NO = '"+lotNo+"'";
// pstmt = conn.prepareStatement(sql);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// rate = rs.getDouble(1);
// //System.out.println("Rate is .*...."+rate);
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
// }//try
// catch(Exception e)
// {
// System.out.println("Exception...[pickRate] "+sql+e.getMessage());
// e.printStackTrace();
// throw new ITMException(e);
// }
// }//if
// else
// {
// try
// {//try 1
// sql = "SELECT RATE FROM STOCK "
// + "WHERE ITEM_CODE = '"+itemCode+"' "
// + "AND SITE_CODE = '"+siteCode+"' "
// + "AND LOC_CODE = '"+locCode+"' "
// + "AND LOT_NO = '"+lotNo+"' "
// + "AND LOT_SL = '"+lotSl+"'";
// pstmt = conn.prepareStatement(sql);
// rs = pstmt.executeQuery();
// if (rs.next())
// {
// rate = rs.getDouble(1);
// //System.out.println("Rate is .*...."+rate);
// }
// rs.close();
// rs = null;
// pstmt.close();
// pstmt = null;
// }//try
// catch(Exception e)
// {
// System.out.println("Exception...[pickRate] "+sql+e.getMessage());
// e.printStackTrace();
// throw new ITMException(e);
// }
// }//else
// }//if(type.trim().equals("I")) //Inventory
// System.out.println("Rate From DisCommon***:::::["+rate+"]");
return (rate);
}
}
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