Commit bf358cfe authored by ngadkari's avatar ngadkari

changes for new column added ref_no

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@206168 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6ae90cf8
......@@ -7,10 +7,15 @@ package ibase.webitm.ejb.dis.adv;
import java.rmi.RemoteException;
import java.sql.Connection;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Iterator;
import javax.ejb.Stateless;
......@@ -72,12 +77,18 @@ public class SchemeDefWizPostSave extends ValidatorEJB implements SchemeDefWizPo
String returnString = "", todayDate = "", loginSiteCode = "", userId = "", chgTerm = "", loginEmpCode = "", sql = "";
ResultSet rs = null, rs3 = null;
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null, pstmt3 = null, pstmt4 = null, pstmt5 = null, pstmt6 = null;
String tranId = "", customerCode = "", siteCodeVal = "", effFromStr = "", validUptoStr = "", statusFlag = "", itemCode = "";
String unit = "", tranIdScheme = "", descr = "", stateCode = "", stanCode = "", countryCode = "";
Timestamp effFromDate = null, validUptoDate = null;
double baseQty = 0.0, freeQty = 0.0, chargeDetQty = 0.0, freeDetQty = 0.0;
int[] updCount = null;
int noOfRows = 0, domId = 0, lineNo = 0, lineNoApplDet = 0;
String refNo="",schemeCode="",validUptoDateStr="";//ref_no added by nandkumar gadkari on 22/08/19
ArrayList<String> schemeCodeList = new ArrayList<String>();// added by nandkumar gadkari on 22/08/19
PreparedStatement pstmt7 = null, pstmt8 = null, pstmt9 = null, pstmt10 = null;
Iterator<String> itr = null;
int cnt=0,insertCnt=0,updateCnt=0;
try
{
if(conn == null || conn.isClosed())
......@@ -154,10 +165,38 @@ public class SchemeDefWizPostSave extends ValidatorEJB implements SchemeDefWizPo
freeQty = Double.parseDouble(checkDouble(childNode.getFirstChild().getNodeValue()));
System.out.println("freeQty is===="+freeQty);
}
else if(childNode != null && "ref_no".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)//ref_no added by nandkumar gadkari on 22/08/19
{
refNo = checkNullAndTrim(childNode.getFirstChild().getNodeValue());
System.out.println("refNo is===="+refNo);
}
}
}
noOfRows = 0;
// added by nandkumar gadkari on 22/08/19----------------------------start----------------------
sql = "SELECT SCHEME_CODE FROM SCHEME_APPLICABILITY WHERE REF_NO= ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,refNo);
rs = pstmt.executeQuery();
while(rs.next())
{
schemeCode = rs.getString(1);
if(schemeCode != null && schemeCode.trim().length() > 0)
{
schemeCodeList.add(schemeCode.trim());
}
}
if(rs != null)
{
rs.close();
rs = null;
}
if(pstmt != null)
{
pstmt.close();
pstmt = null;
}
// added by nandkumar gadkari on 22/08/19----------------------------end------------------------
sql = "select s.state_code,s.stan_code, st.count_code from site s, state st where "
+ "s.state_code = st.state_code and site_code = ?";
pstmt = conn.prepareStatement(sql);
......@@ -182,7 +221,7 @@ public class SchemeDefWizPostSave extends ValidatorEJB implements SchemeDefWizPo
sql = "insert into bom(bom_code,descr,type,chg_date,chg_user,chg_term,batch_qty,"
+ "scheme_flag,unit,min_qty,apply_price,price_var,usage_type,max_qty,"
+ "batch_value,min_batch_value,max_batch_value) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "batch_value,min_batch_value,max_batch_value,ref_no) values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; //ref_no added by nandkumar gadkari on 22/08/19
pstmt1 = conn.prepareStatement(sql);
sql = "insert into bomdet(bom_code,line_no,item_code,item_ref,eff_from,valid_upto,req_type,"
......@@ -195,16 +234,27 @@ public class SchemeDefWizPostSave extends ValidatorEJB implements SchemeDefWizPo
pstmt3 = conn.prepareStatement(sql);
sql = "insert into scheme_applicability(scheme_code,item_code,chg_date,chg_user,chg_term,slab_on,"
+ "app_from,valid_upto,apply_cust_list,min_value,max_value,grace_days,prod_sch) "
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?)";
+ "app_from,valid_upto,apply_cust_list,min_value,max_value,grace_days,prod_sch,ref_no) " //ref_no added by nandkumar gadkari on 22/08/19
+ "values(?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmt4 = conn.prepareStatement(sql);
sql = "insert into scheme_applicability_det(scheme_code,line_no,site_code,state_code,count_code,"
+ "stan_code) values(?,?,?,?,?,?)";
pstmt5 = conn.prepareStatement(sql);
sql = "update scheme_def_det set scheme_code = ? where tran_id = ? and item_code = ?";
sql = "update scheme_def_det set scheme_code = ? ,ref_no = ? where tran_id = ? and item_code = ?";//ref_no added by nandkumar gadkari on 22/08/19
pstmt6 = conn.prepareStatement(sql);
//update added by nandkumar gadkari on 22/08/19---------------------------------start----------------------
sql = "update bom set descr = ? ,batch_qty = ? ,min_qty= ? where bom_code = ? ";
pstmt7 = conn.prepareStatement(sql);
sql = "update bomdet set qty_per = ? where bom_code = ? and nature = ?";
pstmt8 = conn.prepareStatement(sql);
sql = "update bomdet set qty_per = ? ,min_qty = ? where bom_code = ? and nature = ?";
pstmt9 = conn.prepareStatement(sql);
//update added by nandkumar gadkari on 22/08/19----------------------------------end-----------------------
for(int ctrH = 0; ctrH < detail2NodeListlen ; ctrH++)
{
......@@ -216,6 +266,12 @@ public class SchemeDefWizPostSave extends ValidatorEJB implements SchemeDefWizPo
domId++;
NodeList childNodeList = detail2NodeList.item(ctrH).getChildNodes();
int childNodeListlen = childNodeList.getLength();
//scheme_code added by nandkumar gadkari on 22/08/19--START--
schemeCode="";
freeDetQty=0;
chargeDetQty=0;
itemCode="";
//scheme_code added by nandkumar gadkari on 22/08/19--EBD---
for(int ctrD = 0; ctrD < childNodeListlen ; ctrD++)
{
Node childNode = childNodeList.item(ctrD);
......@@ -251,171 +307,285 @@ public class SchemeDefWizPostSave extends ValidatorEJB implements SchemeDefWizPo
else if(childNode != null && "chargeable_qty".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
chargeDetQty = Double.parseDouble(checkDouble(childNode.getFirstChild().getNodeValue()));
System.out.println("chargeable_qty is===="+baseQty);
System.out.println("chargeable_qty is===="+chargeDetQty);
}
else if(childNode != null && "free_qty".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)
{
freeDetQty = Double.parseDouble(checkDouble(childNode.getFirstChild().getNodeValue()));
System.out.println("free_qty is===="+freeQty);
System.out.println("free_qty is===="+freeDetQty);
}
else if(childNode != null && "scheme_code".equalsIgnoreCase(childNode.getNodeName()) && childNode.getFirstChild() != null)//scheme_code added by nandkumar gadkari on 22/08/19
{
schemeCode = (checkNullAndTrim(childNode.getFirstChild().getNodeValue()));
System.out.println("scheme_code is===="+schemeCode);
}
}
tranIdScheme = generateTranID(xtraParams, "w_bom", conn);
System.out.println("Tran ID for Scheme Definition :::["+tranId+"]");
System.out.println("Tran ID for Scheme BOM :::["+tranIdScheme+"]");
if(tranIdScheme == null || tranIdScheme.trim().length() == 0)
System.out.println("schemeCode ::::["+schemeCode+"]" );
System.out.println("freeQty ::::["+freeDetQty+"]" );
System.out.println("baseQty ::::["+chargeDetQty+"]" );
System.out.println("itemCode ::::["+itemCode+"]" );
if(schemeCode.trim().length() == 0)//scheme_code condition added by nandkumar gadkari on 22/08/19
{
returnString = itmDBAccessLocal.getErrorString("","VTTRANID","","",conn);
tranIdScheme = generateTranID(xtraParams, "w_bom", conn);
System.out.println("Tran ID for Scheme Definition :::["+tranId+"]");
System.out.println("Tran ID for Scheme BOM :::["+tranIdScheme+"]");
if(tranIdScheme == null || tranIdScheme.trim().length() == 0)
{
returnString = itmDBAccessLocal.getErrorString("","VTTRANID","","",conn);
}
pstmt1.setString(1, tranIdScheme);
pstmt1.setString(2, chargeDetQty+"+"+freeDetQty);
pstmt1.setString(3, "S");
pstmt1.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
pstmt1.setString(5, userId);
pstmt1.setString(6, chgTerm);
pstmt1.setDouble(7, chargeDetQty);
pstmt1.setString(8, "Q");
pstmt1.setString(9, unit);
pstmt1.setDouble(10, chargeDetQty);
pstmt1.setString(11, "P");
pstmt1.setString(12, "A");
pstmt1.setString(13, "A");
pstmt1.setLong(14, 99999999999L);
pstmt1.setInt(15, 0);
pstmt1.setInt(16, 0);
pstmt1.setInt(17, 9999999);
pstmt1.setString(18, refNo); //ref_no added by nandkumar gadkari on 22/08/19
pstmt1.addBatch();
pstmt1.clearParameters();
pstmt2.setString(1, tranIdScheme);
pstmt2.setInt(2, lineNo);
pstmt2.setString(3, itemCode);
pstmt2.setString(4, itemCode+"C");
pstmt2.setTimestamp(5, effFromDate);
pstmt2.setTimestamp(6, validUptoDate);
pstmt2.setString(7, "P");
//Commented and added below line by Varsha V to set app_min_qty in bomdet as 0
//pstmt2.setDouble(8, chargeDetQty);
pstmt2.setInt(8, 1);
pstmt2.setInt(9, 99999999);
pstmt2.setString(10, "C");
pstmt2.setDouble(11, chargeDetQty);
pstmt2.setDouble(12, 0);
pstmt2.setString(13, "N");
pstmt2.setString(14, "N");
pstmt2.setDouble(15, 0);
pstmt2.setDouble(16, 0);
pstmt2.setDouble(17, 0);
pstmt2.setDouble(18, 0);
pstmt2.setDouble(19, 0);
pstmt2.setString(20, "R");
pstmt2.setDouble(21, 0.001);
pstmt2.addBatch();
pstmt2.clearParameters();
lineNo++;
pstmt2.setString(1, tranIdScheme);
pstmt2.setInt(2, lineNo);
pstmt2.setString(3, itemCode);
pstmt2.setString(4, itemCode+"F");
pstmt2.setTimestamp(5, effFromDate);
pstmt2.setTimestamp(6, validUptoDate);
pstmt2.setString(7, "P");
//pstmt2.setDouble(8, freeDetQty); commented and quantity 0 set by nandkumar gadkari on 25/07/19
pstmt2.setDouble(8, 1);
pstmt2.setInt(9, 99999999);
pstmt2.setString(10, "F");
pstmt2.setDouble(11, freeDetQty);
pstmt2.setDouble(12, freeDetQty);
pstmt2.setString(13, "N");
pstmt2.setString(14, "N");
pstmt2.setDouble(15, 0);
pstmt2.setDouble(16, 0);
pstmt2.setDouble(17, 0);
pstmt2.setDouble(18, 0);
pstmt2.setDouble(19, 0);
pstmt2.setString(20, "R");
pstmt2.setDouble(21, 0.001);
pstmt2.addBatch();
pstmt2.clearParameters();
pstmt4.setString(1, tranIdScheme);//0.00 0.00 0 N
pstmt4.setString(2, itemCode);
pstmt4.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
pstmt4.setString(4, userId);
pstmt4.setString(5, chgTerm);
pstmt4.setString(6, "N");
pstmt4.setTimestamp(7, effFromDate);
pstmt4.setTimestamp(8, validUptoDate);
pstmt4.setString(9, customerCode);
pstmt4.setDouble(10, 0.00);
pstmt4.setDouble(11, 0.00);
pstmt4.setInt(12, 0);
pstmt4.setString(13, "N");
pstmt4.setString(14, refNo);//ref_no added by nandkumar gadkari on 22/08/19
pstmt4.addBatch();
pstmt4.clearParameters();
pstmt5.setString(1, tranIdScheme);
pstmt5.setInt(2, lineNoApplDet);
pstmt5.setString(3, siteCodeVal);
pstmt5.setString(4, stateCode);
pstmt5.setString(5, countryCode);
pstmt5.setString(6, stanCode);
pstmt5.addBatch();
pstmt5.clearParameters();
pstmt6.setString(1, tranIdScheme);
pstmt6.setString(2, refNo);//ref_no added by nandkumar gadkari on 22/08/19
pstmt6.setString(3, tranId);
pstmt6.setString(4, itemCode);
pstmt6.addBatch();
pstmt6.clearParameters();
insertCnt++;
}
pstmt1.setString(1, tranIdScheme);
pstmt1.setString(2, chargeDetQty+"+"+freeDetQty);
pstmt1.setString(3, "S");
pstmt1.setTimestamp(4, new Timestamp(System.currentTimeMillis()));
pstmt1.setString(5, userId);
pstmt1.setString(6, chgTerm);
pstmt1.setDouble(7, chargeDetQty);
pstmt1.setString(8, "Q");
pstmt1.setString(9, unit);
pstmt1.setDouble(10, chargeDetQty);
pstmt1.setString(11, "P");
pstmt1.setString(12, "A");
pstmt1.setString(13, "A");
pstmt1.setLong(14, 99999999999L);
pstmt1.setInt(15, 0);
pstmt1.setInt(16, 0);
pstmt1.setInt(17, 9999999);
pstmt1.addBatch();
pstmt1.clearParameters();
pstmt2.setString(1, tranIdScheme);
pstmt2.setInt(2, lineNo);
pstmt2.setString(3, itemCode);
pstmt2.setString(4, itemCode+"C");
pstmt2.setTimestamp(5, effFromDate);
pstmt2.setTimestamp(6, validUptoDate);
pstmt2.setString(7, "P");
//Commented and added below line by Varsha V to set app_min_qty in bomdet as 0
//pstmt2.setDouble(8, chargeDetQty);
pstmt2.setInt(8, 1);
pstmt2.setInt(9, 99999999);
pstmt2.setString(10, "C");
pstmt2.setDouble(11, chargeDetQty);
pstmt2.setDouble(12, 0);
pstmt2.setString(13, "N");
pstmt2.setString(14, "N");
pstmt2.setDouble(15, 0);
pstmt2.setDouble(16, 0);
pstmt2.setDouble(17, 0);
pstmt2.setDouble(18, 0);
pstmt2.setDouble(19, 0);
pstmt2.setString(20, "R");
pstmt2.setDouble(21, 0.001);
pstmt2.addBatch();
pstmt2.clearParameters();
lineNo++;
pstmt2.setString(1, tranIdScheme);
pstmt2.setInt(2, lineNo);
pstmt2.setString(3, itemCode);
pstmt2.setString(4, itemCode+"F");
pstmt2.setTimestamp(5, effFromDate);
pstmt2.setTimestamp(6, validUptoDate);
pstmt2.setString(7, "P");
//pstmt2.setDouble(8, freeDetQty); commented and quantity 0 set by nandkumar gadkari on 25/07/19
pstmt2.setDouble(8, 1);
pstmt2.setInt(9, 99999999);
pstmt2.setString(10, "F");
pstmt2.setDouble(11, freeDetQty);
pstmt2.setDouble(12, freeDetQty);
pstmt2.setString(13, "N");
pstmt2.setString(14, "N");
pstmt2.setDouble(15, 0);
pstmt2.setDouble(16, 0);
pstmt2.setDouble(17, 0);
pstmt2.setDouble(18, 0);
pstmt2.setDouble(19, 0);
pstmt2.setString(20, "R");
pstmt2.setDouble(21, 0.001);
pstmt2.addBatch();
pstmt2.clearParameters();
pstmt4.setString(1, tranIdScheme);//0.00 0.00 0 N
pstmt4.setString(2, itemCode);
pstmt4.setTimestamp(3, new Timestamp(System.currentTimeMillis()));
pstmt4.setString(4, userId);
pstmt4.setString(5, chgTerm);
pstmt4.setString(6, "N");
pstmt4.setTimestamp(7, effFromDate);
pstmt4.setTimestamp(8, validUptoDate);
pstmt4.setString(9, customerCode);
pstmt4.setDouble(10, 0.00);
pstmt4.setDouble(11, 0.00);
pstmt4.setInt(12, 0);
pstmt4.setString(13, "N");
pstmt4.addBatch();
pstmt4.clearParameters();
pstmt5.setString(1, tranIdScheme);
pstmt5.setInt(2, lineNoApplDet);
pstmt5.setString(3, siteCodeVal);
pstmt5.setString(4, stateCode);
pstmt5.setString(5, countryCode);
pstmt5.setString(6, stanCode);
pstmt5.addBatch();
pstmt5.clearParameters();
else//added by nandkumar gadkari on 22/08/19
{
schemeCodeList.remove(schemeCode);
pstmt7.setString(1, chargeDetQty+"+"+freeDetQty);
pstmt7.setDouble(2, chargeDetQty);
pstmt7.setDouble(3, chargeDetQty);
pstmt7.setString(4, schemeCode);
pstmt7.addBatch();
pstmt7.clearParameters();
pstmt8.setDouble(1, chargeDetQty);
pstmt8.setString(2, schemeCode);
pstmt8.setString(3, "C");
pstmt8.addBatch();
pstmt8.clearParameters();
pstmt6.setString(1, tranIdScheme);
pstmt6.setString(2, tranId);
pstmt6.setString(3, itemCode);
pstmt6.addBatch();
pstmt6.clearParameters();
}
if(pstmt1 != null)
{
updCount = null;
updCount = pstmt1.executeBatch();
System.out.println("Update count on BOM insert::"+updCount);
pstmt1.close();
pstmt1 = null;
}
if(pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
if(pstmt2 != null && lineNo > 0)
{
updCount = null;
updCount = pstmt2.executeBatch();
System.out.println("Update count on BOMDET insert::"+updCount);
pstmt2.close();
pstmt2 = null;
pstmt9.setDouble(1, freeDetQty);
pstmt9.setDouble(2, freeDetQty);
pstmt9.setString(3, schemeCode);
pstmt9.setString(4, "F");
pstmt9.addBatch();
pstmt9.clearParameters();
updateCnt++;
}
}
if(pstmt4 != null)
if(insertCnt > 0)
{
updCount = null;
updCount = pstmt4.executeBatch();
System.out.println("Update count on SCHEME_APPLICABILITY insert::"+updCount);
pstmt4.close();
pstmt4 = null;
if(pstmt1 != null)
{
updCount = null;
updCount = pstmt1.executeBatch();
System.out.println("Update count on BOM insert::"+updCount);
pstmt1.close();
pstmt1 = null;
}
if(pstmt3 != null)
{
pstmt3.close();
pstmt3 = null;
}
if(pstmt2 != null && lineNo > 0)
{
updCount = null;
updCount = pstmt2.executeBatch();
System.out.println("Update count on BOMDET insert::"+updCount);
pstmt2.close();
pstmt2 = null;
}
if(pstmt4 != null)
{
updCount = null;
updCount = pstmt4.executeBatch();
System.out.println("Update count on SCHEME_APPLICABILITY insert::"+updCount);
pstmt4.close();
pstmt4 = null;
}
if(pstmt5 != null && lineNoApplDet > 0)
{
updCount = null;
updCount = pstmt5.executeBatch();
System.out.println("Update count on SCHEME_APPLICABILITY_DET insert::"+updCount);
pstmt5.close();
pstmt5 = null;
}
if(pstmt6 != null)
{
updCount = null;
updCount = pstmt6.executeBatch();
System.out.println("Update count on SCHEME_DEF_DET update::"+updCount);
pstmt6.close();
pstmt6 = null;
}
}
if(pstmt5 != null && lineNoApplDet > 0)
//added by nandkumar gadkari on 22/08/19-------------------START------------------------
if(updateCnt > 0)
{
updCount = null;
updCount = pstmt5.executeBatch();
System.out.println("Update count on SCHEME_APPLICABILITY_DET insert::"+updCount);
pstmt5.close();
pstmt5 = null;
if(pstmt7 != null)
{
updCount = null;
updCount = pstmt7.executeBatch();
System.out.println("Update count on BOM update::"+updCount);
pstmt7.close();
pstmt7 = null;
}
if(pstmt8 != null)
{
updCount = null;
updCount = pstmt8.executeBatch();
System.out.println("Update count on BOMDET CHARGABLE update::"+updCount);
pstmt8.close();
pstmt8 = null;
}
if(pstmt9 != null)
{
updCount = null;
updCount = pstmt9.executeBatch();
System.out.println("Update count on BOMDET FREE update::"+updCount);
pstmt9.close();
pstmt9 = null;
}
}
if(pstmt6 != null)
cnt =schemeCodeList.size();
System.out.println("^^^^^^^schemeCodeList schemeCodeList["+schemeCodeList);
if(cnt> 0)
{
updCount = null;
updCount = pstmt6.executeBatch();
System.out.println("Update count on SCHEME_DEF_DET update::"+updCount);
pstmt6.close();
pstmt6 = null;
SimpleDateFormat simpleDateFormatObj = new SimpleDateFormat(genericUtility.getApplDateFormat());
validUptoDateStr=simpleDateFormatObj.format(yesterday());
validUptoDate=Timestamp.valueOf(genericUtility.getValidDateString(validUptoDateStr, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()+" 00:00:00"));
sql = "update scheme_applicability set VALID_UPTO = ? ,REF_NO ='' where SCHEME_CODE = ? ";
pstmt9 = conn.prepareStatement(sql);
itr = schemeCodeList.iterator();
while(itr.hasNext())
{
schemeCode =(String) itr.next();
pstmt9.setTimestamp(1, validUptoDate);
pstmt9.setString(2, schemeCode);
pstmt9.addBatch();
pstmt9.clearParameters();
}
if(pstmt9 != null)
{
updCount = null;
updCount = pstmt9.executeBatch();
System.out.println("Update count on scheme_applicability update::"+updCount);
pstmt9.close();
pstmt9 = null;
}
}
//added by nandkumar gadkari on 22/08/19-------------------END-------------------
}
catch(Exception e)
......@@ -607,4 +777,9 @@ public class SchemeDefWizPostSave extends ValidatorEJB implements SchemeDefWizPo
}
return sprsTravelTranID;
}
public java.util.Date yesterday() {
final Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);
return cal.getTime();
}
}
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