Commit bdf9ce8b authored by Ajit Deshmukh's avatar Ajit Deshmukh

Added the changes

parent dae219f7
......@@ -3,10 +3,16 @@ package ibase.webitm.ejb.dis;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import javax.naming.InitialContext;
import ibase.system.config.AppConnectParm;
import ibase.utility.BaseLogger;
import ibase.utility.UserInfoBean;
import ibase.webitm.ejb.ActionHandlerEJB;
import ibase.webitm.ejb.ITMDBAccessEJB;
import ibase.webitm.ejb.MasterStatefulLocal;
import ibase.webitm.utility.ITMException;
public class SalesQuotationAcknowledge extends ActionHandlerEJB{
......@@ -15,8 +21,17 @@ public class SalesQuotationAcknowledge extends ActionHandlerEJB{
Connection conn = null;
String errString = "";
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String quotType="",custCode="";
StringBuffer processDynXmlString = new StringBuffer();
int domId=0;
int lineNo = 0;
String processRequestResult="";
UserInfoBean userInfo = null;
try
{
userInfo = getUserInfo();
AppConnectParm appConnect = new AppConnectParm();
InitialContext initialContext = new InitialContext(appConnect.getProperty());
BaseLogger.log("3", getUserInfo(), null, "SalesQuotationAcknowledge --> tranID MArch 9 2026["+tranID+"]");
conn = getConnection();
......@@ -26,11 +41,56 @@ public class SalesQuotationAcknowledge extends ActionHandlerEJB{
updateStatusPs.setString(1, tranID);
int updateStatusCnt = updateStatusPs.executeUpdate();
BaseLogger.log("3", getUserInfo(), null, "SalesQuotationAcknowledge --> updateStatusCnt ["+updateStatusCnt+"]");
String fetchSQuotDetSql = "select quot_type, cust_code from sales_quot where quot_no = ?";
PreparedStatement fetchSQuotDetPs = conn.prepareStatement(fetchSQuotDetSql);
fetchSQuotDetPs.setString(1, tranID);
ResultSet fetchSQuotDetRs = fetchSQuotDetPs.executeQuery();
while(fetchSQuotDetRs.next()) {
quotType = checkNull(fetchSQuotDetRs.getString("quot_type"));
custCode = checkNull(fetchSQuotDetRs.getString("cust_code"));
}
processDynXmlString.append("<DocumentRoot><description>Datawindow Root</description><group0>");
processDynXmlString.append(
"<description>Group0 description</description><Header0><description>Header0 members</description>");
if(quotType.trim().equalsIgnoreCase("G")) {
String fetchHospitalMappingSql = "select CUST_CODE__STK, CUST_CODE__DIST from CUSTOMER_PREF_DIST where CUST_CODE = ?";
PreparedStatement fetchHospitalMappingPs = conn.prepareStatement(fetchHospitalMappingSql);
fetchHospitalMappingPs.setString(1, custCode);
ResultSet fetchHospitalMappingRs = fetchHospitalMappingPs.executeQuery();
while(fetchHospitalMappingRs.next()) {
domId++;
lineNo++;
processDynXmlString.append("<Detail3 dbID=':' domID='"+domId+"' objName=\"salesquot\" objContext=\"3\">");
processDynXmlString.append("<attribute pkNames=\"quot_no:line_no:\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
processDynXmlString.append("<line_no><![CDATA[").append(lineNo).append("]]></line_no>");
processDynXmlString.append("<cust_code><![CDATA[").append(custCode).append("]]></cust_code>");
processDynXmlString.append("<cust_code__stk><![CDATA[").append(checkNull(fetchHospitalMappingRs.getString("CUST_CODE__STK"))).append("]]></cust_code__stk>");
processDynXmlString.append("<cust_code__dist><![CDATA[").append(checkNull(fetchHospitalMappingRs.getString("CUST_CODE__DIST"))).append("]]></cust_code__dist>");
processDynXmlString.append("</Detail3>");
}
}
processDynXmlString.append("</Header0></group0></DocumentRoot>");
String salesQuotDet3Xml = processDynXmlString.toString();
BaseLogger.log("3", null, null, "userInfo::" + userInfo.toString() + "]");
BaseLogger.log("3", null, null, "salesQuotDet3Xml::" + salesQuotDet3Xml.toString() + "]");
MasterStatefulLocal masterStateful = (MasterStatefulLocal) initialContext
.lookup("ibase/MasterStatefulEJB/local");
processRequestResult = masterStateful.processRequest(userInfo, salesQuotDet3Xml, false, conn);
BaseLogger.log("3", null, null, "processRequest processRequestResultD" + processRequestResult + "]");
if(updateStatusCnt>0) {
conn.commit();
return errString = itmDBAccessEJB.getErrorString("","SALESACK","","",conn);
}
}catch(Exception e) {
BaseLogger.log("3", getUserInfo(), null, "Exception from SalesQuotationAcknowledge updateStatus --["+e.getMessage()+"]");
e.printStackTrace();
......@@ -38,4 +98,13 @@ public class SalesQuotationAcknowledge extends ActionHandlerEJB{
}
return " ";
}
private String checkNull(String input)
{
if(input == null)
{
input = "";
}
return input;
}
}
package ibase.webitm.ejb.dis;
import java.io.StringReader;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.rmi.RemoteException;
......@@ -15,8 +16,12 @@ import java.time.format.DateTimeFormatter;
import java.util.Date;
import javax.naming.InitialContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.InputSource;
import ibase.ejb.CommonDBAccessEJB;
import ibase.system.config.AppConnectParm;
......@@ -76,7 +81,6 @@ public class ReqForQuotationAprv extends ValidatorEJB{
LocalDate tranDate = LocalDate.now();// for tranDate
LocalTime tranTime = LocalTime.now();
String tranDateStr = formatDateTime(tranDate, tranTime);
String tranId = "";
String reqId = "";
String custCode = "";
String quotType = "";
......@@ -201,7 +205,7 @@ public class ReqForQuotationAprv extends ValidatorEJB{
checkAppr2StatusRs = checkAppr2StatusPs.executeQuery();
while (checkAppr2StatusRs.next()) {
String wfStatus = checkAppr2StatusRs.getString("WF_STATUS");
String wfStatus = checkNull(checkAppr2StatusRs.getString("WF_STATUS"));
if (wfStatus.equalsIgnoreCase("A")) {
tranFlag = false;
......@@ -299,10 +303,30 @@ public class ReqForQuotationAprv extends ValidatorEJB{
resvisedRatePstmt.setString(1, itemCode);
ResultSet resvisedRateRs = resvisedRatePstmt.executeQuery();
while(resvisedRateRs.next()) {
int distMargin = resvisedRateRs.getInt("PHY_ATTRIB_13");
int stockMargin = resvisedRateRs.getInt("PHY_ATTRIB_14");
int retailMargin = resvisedRateRs.getInt("PHY_ATTRIB_15");
String distMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_13"));
String stockMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_14"));
String retailMarginStr = checkNull(resvisedRateRs.getString("PHY_ATTRIB_15"));
int distMargin = 0;
int stockMargin = 0;
int retailMargin = 0;
try {
distMargin = (distMarginStr != null && distMarginStr.trim().length() > 0)
? Integer.parseInt(distMarginStr.trim())
: 0;
stockMargin = (stockMarginStr != null && stockMarginStr.trim().length() > 0)
? Integer.parseInt(stockMarginStr.trim())
: 0;
retailMargin = (retailMarginStr != null && retailMarginStr.trim().length() > 0)
? Integer.parseInt(retailMarginStr.trim())
: 0;
} catch (Exception e) {
BaseLogger.log("3", null, null, "Error parsing margin values");
}
BigDecimal rateBD = new BigDecimal(rate);
BigDecimal hundred = new BigDecimal(100);
......@@ -361,6 +385,35 @@ public class ReqForQuotationAprv extends ValidatorEJB{
rfqDetPstmt = null;
}
//Detail3 XML Building start - 19 March
/*
* BaseLogger.log("3", null, null, "quotType::" + quotType.toString() + "]");
* BaseLogger.log("3", null, null, "custCode::" + custCode.toString() + "]");
*
* if(quotType.trim().equalsIgnoreCase("G")) { String fetchHospitalMappingSql =
* "select CUST_CODE__STK, CUST_CODE__DIST from CUSTOMER_PREF_DIST where CUST_CODE = ?"
* ; PreparedStatement fetchHospitalMappingPs =
* conn.prepareStatement(fetchHospitalMappingSql);
* fetchHospitalMappingPs.setString(1, custCode); ResultSet
* fetchHospitalMappingRs = fetchHospitalMappingPs.executeQuery();
* while(fetchHospitalMappingRs.next()) {
* processDynXmlString.append("<Detail3 dbID=':' domID='"
* +domId+"' objName=\"salesquot\" objContext=\"3\">"); processDynXmlString.
* append("<attribute pkNames=\"quot_no:line_no:\" selected=\"N\" updateFlag=\"A\" status=\"N\" />"
* ); processDynXmlString.append("<line_no><![CDATA[").append(lineNo).append(
* "]]></line_no>");
* processDynXmlString.append("<cust_code><![CDATA[").append(custCode).append(
* "]]></cust_code>");
* processDynXmlString.append("<cust_code__stk><![CDATA[").append(checkNull(
* fetchHospitalMappingRs.getString("CUST_CODE__STK"))).append(
* "]]></cust_code__stk>");
* processDynXmlString.append("<cust_code__dist><![CDATA[").append(checkNull(
* fetchHospitalMappingRs.getString("CUST_CODE__DIST"))).append(
* "]]></cust_code__dist>"); processDynXmlString.append("</Detail3>"); } }
*/
//Detail3 XML Building end - 19 March
processDynXmlString.append("</Header0></group0></DocumentRoot>");
......@@ -398,7 +451,63 @@ public class ReqForQuotationAprv extends ValidatorEJB{
processRequestResult = masterStateful.processRequest(userInfo, salesQuotXml, false, conn);
BaseLogger.log("3", null, null, "processRequest processRequestResultD" + processRequestResult + "]");
if(processRequestResult != null && processRequestResult.trim().length() > 0)
{
try
{
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
DocumentBuilder builder = factory.newDocumentBuilder();
InputSource is = new InputSource(new StringReader(processRequestResult));
Document doc = builder.parse(is);
// 🔹 Check SUCCESS
NodeList detailNodeList = doc.getElementsByTagName("Detail");
if(detailNodeList != null && detailNodeList.getLength() > 0)
{
String detailValue = detailNodeList.item(0).getTextContent();
if("Success".equalsIgnoreCase(detailValue))
{
BaseLogger.log("3", null, null, "Transaction SUCCESS");
// ✅ Success logic
String tranIdOfSalesQuotaion = doc.getElementsByTagName("TranID").item(0).getTextContent();
BaseLogger.log("3", null, null, "Generated Sales Quotaion TranID: " + tranIdOfSalesQuotaion);
BaseLogger.log("3", null, null, "RFQ TranID: " + tranID);
String UpdateRfqIdInSQuotSql = "update sales_quot set TRAN_ID__RFQ = ? where QUOT_NO = ?";
PreparedStatement UpdateRfqIdInSQuotPs = conn.prepareStatement(UpdateRfqIdInSQuotSql);
UpdateRfqIdInSQuotPs.setString(1, tranID);
UpdateRfqIdInSQuotPs.setString(2, tranIdOfSalesQuotaion);
int UpdateRfqIdInSQuotCount = UpdateRfqIdInSQuotPs.executeUpdate();
conn.commit();
BaseLogger.log("3", null, null, "Sales Quotation TRAN_ID__RFQ upadate count: "+UpdateRfqIdInSQuotCount);
String updateConfirm = "update sales_quot_req set confirmed = 'Y' where tran_id = ?";
PreparedStatement updateConfirmPs = conn.prepareStatement(updateConfirm);
updateConfirmPs.setString(1, tranID);
int updateConfirmCount = updateConfirmPs.executeUpdate();
conn.commit();
BaseLogger.log("3", null, null, "RFQ Confirmed Column update count: "+updateConfirmCount);
if (updateConfirmPs != null) {
updateConfirmPs.close();
updateConfirmPs = null;
}
}
}
else
{
BaseLogger.log("3", null, null, "Sales Quotation Generation Failed: ");
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
retString = processRequestResult;
}
......
......@@ -52,6 +52,8 @@ public class ReqForQuotationSubmit extends ActionHandlerEJB
ibase.utility.E12GenericUtility genericUtility= null;
ITMDBAccessEJB itmDBAccess = null;
String ptr="",rateQuot="";
BigDecimal ratePtrVal = null;
BigDecimal rateQuotVal = null;
try
{
......@@ -81,8 +83,16 @@ public class ReqForQuotationSubmit extends ActionHandlerEJB
}
BigDecimal ratePtrVal = new BigDecimal(ptr);
BigDecimal rateQuotVal = new BigDecimal(rateQuot);
if(ptr != null && ptr.trim().length() > 0)
{
ratePtrVal = new BigDecimal(ptr);
}
if(rateQuot != null && rateQuot.trim().length() > 0)
{
rateQuotVal = new BigDecimal(rateQuot);
}
String loginCode = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
BaseLogger.log("3", null, null,"loginCode>>>>:"+loginCode);
......
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