Commit 83ed73fc authored by Ajit Deshmukh's avatar Ajit Deshmukh

Added the updated Java Components

parent 319d558a
This diff is collapsed.
package ibase.webitm.ejb.dis;
import java.math.BigDecimal;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import org.w3c.dom.Document;
import ibase.utility.BaseLogger;
import ibase.utility.E12GenericUtility;
import ibase.webitm.ejb.ValidatorEJB;
import ibase.webitm.utility.ITMException;
public class ReqForQuotationPostSave extends ValidatorEJB {
String objName = "", detailNode = "";
E12GenericUtility genericUtility = new E12GenericUtility();
public String postSave(String xmlString, String tranId, String editFlag, String xtraParams, Connection conn)
throws RemoteException, ITMException {
Document dom = null;
String errString = "";
try {
if (xmlString != null && xmlString.trim().length() > 0) {
dom = parseString(xmlString);
errString = postSave(dom, tranId, xtraParams, conn);
}
} catch (Exception e) {
BaseLogger.log("0", null, null, "Exception : ReqForQuotationPostSave : postSave : ==>\n" + e.getMessage());
throw new ITMException(e);
}
return errString;
}
public String postSave(Document dom, String tranId, String xtraParams, Connection conn) throws ITMException {
BaseLogger.log("3", getUserInfo(), null, "tran_id---->>[" + tranId + "]");
BaseLogger.log("3", getUserInfo(), null, "in ReqForQuotationPostSave postSave tran_id---->>[" + tranId + "]");
BaseLogger.log("3", getUserInfo(), null, "in ReqForQuotationPostSave postSave xtraParams---->>[" + xtraParams.toString() + "]");
tranId = checkNull(genericUtility.getColumnValue("tran_id", dom));
BaseLogger.log("3", getUserInfo(), null, "in ReqForQuotationPostSave postSave tran_id---->>[" + tranId + "]");
BaseLogger.log("3", getUserInfo(), null, "dom ReqForQuotationPostSave*>>>> Elements>>["+genericUtility.serializeDom(dom).toString()+"]");//added for testing
PreparedStatement ps = null;
ResultSet rs = null;
String errorString = "";
try {
if (conn == null) {
conn = getConnection(); // only fallback
}
String sql = "SELECT PTR, RATE_QUOT FROM SALES_QUOT_REQ_DET WHERE TRAN_ID = ?";
ps = conn.prepareStatement(sql);
ps.setString(1, tranId);
rs = ps.executeQuery();
boolean allEqual = true;
while (rs.next()) {
BigDecimal ptrVal = rs.getBigDecimal("PTR") != null ? rs.getBigDecimal("PTR") : BigDecimal.ZERO;
BigDecimal rateVal = rs.getBigDecimal("RATE_QUOT") != null ? rs.getBigDecimal("RATE_QUOT") : BigDecimal.ZERO;
BaseLogger.log("3", null, null, "Comparing PTR: " + ptrVal + " with RATE_QUOT: " + rateVal);
if (rateVal.compareTo(ptrVal) != 0) {
allEqual = false;
break;
}
}
// ✅ Update ONLY AFTER loop
if (allEqual) {
BaseLogger.log("3", null, null, "All values matched → Updating mgmnt_apprv");
String updateSql = "UPDATE SALES_QUOT_REQ SET mgmnt_apprv = 'D' WHERE TRAN_ID = ?";
PreparedStatement updPs = conn.prepareStatement(updateSql);
updPs.setString(1, tranId);
int count = updPs.executeUpdate();
BaseLogger.log("3", null, null, "Rows updated: " + count);
if (updPs != null) updPs.close();
}
} catch (Exception e) {
BaseLogger.log("0", null, null, "Exception : " + e.getMessage());
throw new ITMException(e);
} finally {
try {
if (rs != null) rs.close();
if (ps != null) ps.close();
// ❌ DO NOT CLOSE CONNECTION HERE
// ❌ DO NOT COMMIT / ROLLBACK
} catch (Exception e) {
BaseLogger.log("0", null, null, "Error closing resources: " + e.getMessage());
}
}
return errorString;
}
private String checkNull(String inputVal) {
if (inputVal == null) {
inputVal = "";
}
return inputVal;
}
}
package ibase.webitm.ejb.dis;
import java.math.BigDecimal;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import org.w3c.dom.Document;
import ibase.system.config.ConnDriver;
import ibase.utility.BaseLogger;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.utility.ITMException;
public class ReqForQuotationSubmit extends ActionHandlerEJB {
public String confirm(String tranID, String xtraParams, String forcedFlag) throws RemoteException, ITMException {
String retString = "";
Connection conn = null;
boolean isConn = false;
try {
BaseLogger.log("3", getUserInfo(), null, "tranID:::::" + tranID);
BaseLogger.log("3", getUserInfo(), null, "xtraParams:::::" + xtraParams);
BaseLogger.log("3", getUserInfo(), null, "forcedFlag:::::" + forcedFlag);
retString = this.confirm(tranID, xtraParams, forcedFlag, conn, isConn);
BaseLogger.log("3", getUserInfo(), null, "retString:::::" + retString);
} catch (Exception e) {
BaseLogger.log("3", getUserInfo(), null, "Exception in [ReqForQuotationSubmit] submit " + e.getMessage());
throw new ITMException(e);
}
return retString;
}
public String confirm(String tranId, String xtraParams, String forcedFlag, Connection conn, boolean connStatus)
throws RemoteException, ITMException {
String retString = " ", status = "";
String sql = "";
int count = 0, upd = 0;
String refSer = "";
String confirmed = "";
ResultSet rs = null;
PreparedStatement pstmt = null;
ibase.utility.E12GenericUtility genericUtility = null;
ITMDBAccessEJB itmDBAccess = null;
String ptr = "", rateQuot = "";
try {
UserInfoBean userInfo = getUserInfo();
BaseLogger.log("3", null, null, "ManageSQLSubmit userInfo" + userInfo);
BaseLogger.log("3", getUserInfo(), null, " [ReqForQuotationSubmit] submit tranId:: " + tranId);
BaseLogger.log("3", getUserInfo(), null, " [ReqForQuotationSubmit] submit xtraParams:: " + xtraParams);
genericUtility = new ibase.utility.E12GenericUtility();
itmDBAccess = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
// Changes and Commented By Bhushan on 09-06-2016 :START
// conn = connDriver.getConnectDB("DriverITM");
conn = getConnection();
String ptrAndQuotRateSql = "SELECT PTR, RATE_QUOT FROM SALES_QUOT_REQ_DET WHERE TRAN_ID = ?";
PreparedStatement ptrAndQuotRatePs = conn.prepareStatement(ptrAndQuotRateSql);
ptrAndQuotRatePs.setString(1, tranId);
ResultSet ptrAndQuotRateRs = ptrAndQuotRatePs.executeQuery();
boolean allEqual = true;
while (ptrAndQuotRateRs.next()) {
ptr = checkNull(ptrAndQuotRateRs.getString("PTR"));
rateQuot = checkNull(ptrAndQuotRateRs.getString("RATE_QUOT"));
BigDecimal ratePtrVal = BigDecimal.ZERO;
BigDecimal rateQuotVal = BigDecimal.ZERO;
if (ptr != null && ptr.trim().length() > 0) {
ratePtrVal = new BigDecimal(ptr.trim());
}
if (rateQuot != null && rateQuot.trim().length() > 0) {
rateQuotVal = new BigDecimal(rateQuot.trim());
}
BaseLogger.log("3", null, null, "Comparing PTR: " + ratePtrVal + " with RATE_QUOT: " + rateQuotVal);
// ❗ If ANY record does not match → break
if (rateQuotVal.compareTo(ratePtrVal) != 0) {
allEqual = false;
BaseLogger.log("3", null, null, "Mismatch found. Skipping workflow.");
break;
}
}
String loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
BaseLogger.log("3", null, null, "loginCode>>>>:" + loginCode);
BaseLogger.log("3", null, null, "allEqual>>>>:" + allEqual);
// Added condition if ptr and special rate is same direct create the sales
// quotation
if (allEqual) {
String updateWfStatusSql = "update SALES_QUOT_REQ set WF_STATUS = 'D' where tran_id = ?";
PreparedStatement updateWfStatusPstmt = conn.prepareStatement(updateWfStatusSql);
updateWfStatusPstmt.setString(1, tranId);
int updateWfStatusCount = updateWfStatusPstmt.executeUpdate();
System.out.println("updateWfStatusCount::::: =[" + updateWfStatusCount + "]");
conn.commit();
if (updateWfStatusPstmt != null) {
updateWfStatusPstmt.close();
updateWfStatusPstmt = null;
}
BaseLogger.log("3", null, null, "In PTR and Special rate equal condition");
ReqForQuotationAprv reqForQuotationAprv = new ReqForQuotationAprv();
String domStringForTranId = "<Root><ref_id>" + tranId + "</ref_id><emp_code>" + loginCode
+ "</emp_code></Root>";
String result = reqForQuotationAprv.updateWFStatus(domStringForTranId, conn, xtraParams);
BaseLogger.log("3", null, null, "ReqForQuotationAprv result>>>>> " + result);
Document dom = genericUtility.parseString(result);
String detail = checkNull(genericUtility.getColumnValue("Detail", dom));
if ("Success".equalsIgnoreCase(detail)) {
BaseLogger.log("3", null, null, "ReqForQuotation transaction submitted");
retString = (new ITMDBAccessEJB()).getErrorString("", "VTSUBMTSUC", "", "", userInfo.getTransDB());
} else {
BaseLogger.log("3", null, null, "ReqForQuotation transaction submition failed");
retString = (new ITMDBAccessEJB()).getErrorString("", "VTSUBMTREJ", "", "", userInfo.getTransDB());
}
BaseLogger.log("3", null, null, "ReqForQuotation retString::" + retString);
}
else {
retString = (new ITMDBAccessEJB()).getErrorString("", "VTSUBMTSUC", "", "", userInfo.getTransDB());
}
} catch (Exception e) {
try {
conn.rollback();
retString = e.getMessage();
e.printStackTrace();
} catch (Exception e1) {
BaseLogger.log("3", getUserInfo(), null, "Exception : " + e);
e.printStackTrace();
}
throw new ITMException(e);
} finally {
System.out.println("retString1" + retString);
if (retString != null && retString.indexOf("submitted") > -1) {
try {
conn.commit();
} catch (SQLException e) {
e.printStackTrace();
}
} else if (retString != null && retString.indexOf("VTCONF8") > -1) {
System.out.println("retString2" + retString);
retString = itmDBAccess.getErrorString("", "VTALSUB1", "", "", conn);
} else {
System.out.println("retString3" + retString);
retString = itmDBAccess.getErrorString("", "VTERRSUB", "", "", conn);
}
try {
if (rs != null) {
rs.close();
rs = null;
}
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (conn != null) {
conn.close();
conn = null;
}
} catch (Exception e) {
BaseLogger.log("3", getUserInfo(), null, "Exception : " + e);
e.printStackTrace();
}
}
return retString;
}
private String checkNull(String inputVal) {
if (inputVal == null) {
inputVal = "";
}
return inputVal;
}
}
...@@ -968,6 +968,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -968,6 +968,9 @@ public class ReqForQuotationWiz extends ValidatorEJB{
int lineNo = 0; int lineNo = 0;
String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); String custCode = checkNull(genericUtility.getColumnValue("cust_code", dom1));
String itemSer = checkNull(genericUtility.getColumnValue("item_ser",dom1,"1")); String itemSer = checkNull(genericUtility.getColumnValue("item_ser",dom1,"1"));
String setSrPtrAll = checkNull(genericUtility.getColumnValue("set_sr_ptr_all",dom1,"1"));
BaseLogger.log("3", null, null, "ReqForQuotationWiz in itm default setSrPtrAll:: "+setSrPtrAll);
BaseLogger.log("3", null, null, "ReqForQuotationWiz in itm default "); BaseLogger.log("3", null, null, "ReqForQuotationWiz in itm default ");
//Management rate block[Start] //Management rate block[Start]
String finEntityQuery = "select fin_entity from site where site_code = ?"; String finEntityQuery = "select fin_entity from site where site_code = ?";
...@@ -1162,13 +1165,19 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1162,13 +1165,19 @@ public class ReqForQuotationWiz extends ValidatorEJB{
domId++; domId++;
lineNo++; lineNo++;
String itemDescr = ""; String itemDescr = "";
String unit = "";
String packCode = "";
System.out.println("Item Code::::: " + itemCode); System.out.println("Item Code::::: " + itemCode);
String itemDescrSql = "select descr from item where item_code = ?"; String itemDescrSql = "select descr,unit,pack_code from item where item_code = ?";
PreparedStatement itemDescrPs = conn.prepareStatement(itemDescrSql); PreparedStatement itemDescrPs = conn.prepareStatement(itemDescrSql);
itemDescrPs.setString(1, itemCode); itemDescrPs.setString(1, itemCode);
ResultSet itemDescrRs = itemDescrPs.executeQuery(); ResultSet itemDescrRs = itemDescrPs.executeQuery();
while(itemDescrRs.next()) { while(itemDescrRs.next()) {
itemDescr = itemDescrRs.getString("descr"); itemDescr = checkNull(itemDescrRs.getString("descr"));
unit = checkNull(itemDescrRs.getString("unit"));
packCode = checkNull(itemDescrRs.getString("pack_code"));
} }
BaseLogger.log("3", null, null, "removed the line no from the itmdefault case " ); BaseLogger.log("3", null, null, "removed the line no from the itmdefault case " );
...@@ -1182,14 +1191,20 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1182,14 +1191,20 @@ public class ReqForQuotationWiz extends ValidatorEJB{
valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n"); valueXmlString.append("<ptd>").append("<![CDATA["+ptd+"]]>").append("</ptd>\r\n");
valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n"); valueXmlString.append("<pts>").append("<![CDATA["+pts+"]]>").append("</pts>\r\n");
valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n"); valueXmlString.append("<ptr>").append("<![CDATA["+rate+"]]>").append("</ptr>\r\n");
valueXmlString.append("<rate_quot>").append("<![CDATA[]]>").append("</rate_quot>"); if(setSrPtrAll.trim().equalsIgnoreCase("Y")) {
valueXmlString.append("<rate_quot>").append("<![CDATA["+rate+"]]>").append("</rate_quot>");
}else {
valueXmlString.append("<rate_quot>").append("<![CDATA[]]>").append("</rate_quot>");
}
valueXmlString.append("<qty_quot>").append("<![CDATA[0]]>").append("</qty_quot>"); valueXmlString.append("<qty_quot>").append("<![CDATA[0]]>").append("</qty_quot>");
valueXmlString.append("<competitor_rate>").append("<![CDATA[]]>").append("</competitor_rate>"); valueXmlString.append("<competitor_rate>").append("<![CDATA[]]>").append("</competitor_rate>");
valueXmlString.append("<competitor_name>").append("<![CDATA[]]>").append("</competitor_name>"); valueXmlString.append("<competitor_name>").append("<![CDATA[]]>").append("</competitor_name>");
valueXmlString.append("<competitor_item>").append("<![CDATA[]]>").append("</competitor_item>"); valueXmlString.append("<competitor_item>").append("<![CDATA[]]>").append("</competitor_item>");
valueXmlString.append("<remarks>").append("<![CDATA[]]>").append("</remarks>"); valueXmlString.append("<remarks>").append("<![CDATA[]]>").append("</remarks>");
valueXmlString.append("<pack_code>").append("<![CDATA[]]>").append("</pack_code>"); valueXmlString.append("<pack_code protect='1'>").append("<![CDATA["+packCode+"]]>").append("</pack_code>");
valueXmlString.append("<unit>").append("<![CDATA[]]>").append("</unit>"); valueXmlString.append("<unit protect='1'>").append("<![CDATA["+unit+"]]>").append("</unit>");
valueXmlString.append("<spec_instr>").append("<![CDATA[]]>").append("</spec_instr>"); valueXmlString.append("<spec_instr>").append("<![CDATA[]]>").append("</spec_instr>");
valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>"); valueXmlString.append("<descr>").append("<![CDATA["+itemDescr+"]]>").append("</descr>");
valueXmlString.append("</Detail"+objContext+">"); valueXmlString.append("</Detail"+objContext+">");
...@@ -1239,9 +1254,22 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1239,9 +1254,22 @@ public class ReqForQuotationWiz extends ValidatorEJB{
String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom)); String itemCode = checkNull(genericUtility.getColumnValue("item_code", dom));
String rateApprv = checkNull(genericUtility.getColumnValue("rate_apprv", dom)); String rateApprv = checkNull(genericUtility.getColumnValue("rate_apprv", dom));
String ratePtr = checkNull(genericUtility.getColumnValue("ptr", dom)); String ratePtr = checkNull(genericUtility.getColumnValue("ptr", dom));
String quantity = checkNull(genericUtility.getColumnValue("qty_quot", dom));
int rateQuotInt = 0;
int quantityInt = 0;
int values = 0;
BaseLogger.log("3", null, null, "ReqForQuotationWiz in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr); BaseLogger.log("3", null, null, "ReqForQuotationWiz in rate_quot:: "+rateQuot+" rateApprv::"+rateApprv+ " ratePtr::"+ratePtr+" quantity::"+quantity);
try {
rateQuotInt = (rateQuot != null && rateQuot.trim().length() > 0) ? Integer.parseInt(rateQuot.trim()) : 0;
quantityInt = (quantity != null && quantity.trim().length() > 0) ? Integer.parseInt(quantity.trim()) : 0;
values = rateQuotInt*quantityInt;
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing String to Int values:: "+e.getMessage());
}
BaseLogger.log("3", null, null, "values:: "+values);
if (!rateQuot.isEmpty() && !rateApprv.isEmpty()) { if (!rateQuot.isEmpty() && !rateApprv.isEmpty()) {
BigDecimal rateApprvVal = new BigDecimal(rateApprv); BigDecimal rateApprvVal = new BigDecimal(rateApprv);
...@@ -1332,6 +1360,8 @@ public class ReqForQuotationWiz extends ValidatorEJB{ ...@@ -1332,6 +1360,8 @@ public class ReqForQuotationWiz extends ValidatorEJB{
valueXmlString.append("<revised_ptr>").append("<![CDATA[" + revisedPtr + "]]>").append("</revised_ptr>\r\n"); valueXmlString.append("<revised_ptr>").append("<![CDATA[" + revisedPtr + "]]>").append("</revised_ptr>\r\n");
valueXmlString.append("<revised_pts>").append("<![CDATA[" + revisedPts + "]]>").append("</revised_pts>\r\n"); valueXmlString.append("<revised_pts>").append("<![CDATA[" + revisedPts + "]]>").append("</revised_pts>\r\n");
valueXmlString.append("<revised_ptd>").append("<![CDATA[" + revisedPtd + "]]>").append("</revised_ptd>\r\n"); valueXmlString.append("<revised_ptd>").append("<![CDATA[" + revisedPtd + "]]>").append("</revised_ptd>\r\n");
valueXmlString.append("<value>").append("<![CDATA[" + values + "]]>").append("</value>\r\n");
} }
......
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