Commit 3ba17ad5 authored by ngadkari's avatar ngadkari

added new method of split

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@202565 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 61b7b50a
...@@ -15,6 +15,7 @@ import javax.ejb.*; ...@@ -15,6 +15,7 @@ import javax.ejb.*;
import ibase.webitm.utility.ITMException; import ibase.webitm.utility.ITMException;
import ibase.webitm.ejb.*; import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.utility.E12GenericUtility; import ibase.utility.E12GenericUtility;
import ibase.system.config.*; import ibase.system.config.*;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
...@@ -79,6 +80,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -79,6 +80,12 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
{ {
resString = actionFullSr(dom,dom1,dom2,objContext,xtraParams); resString = actionFullSr(dom,dom1,dom2,objContext,xtraParams);
} }
//condition added by nandkumar gadkari on 25/06/19
if (actionType.equalsIgnoreCase("Split"))
{
resString = splitMinRateHistBalAct(dom,dom1,objContext,xtraParams);
}
}catch(Exception e) }catch(Exception e)
{ {
System.out.println("Exception :SalesReturn :actionHandler(String xmlString):" + e.getMessage() + ":"); System.out.println("Exception :SalesReturn :actionHandler(String xmlString):" + e.getMessage() + ":");
...@@ -787,6 +794,216 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo ...@@ -787,6 +794,216 @@ public class SalesReturnAct extends ActionHandlerEJB implements SalesReturnActLo
System.out.println("SalesReturn :actionFullSR:Final Value :valueXmlString.toString():"+valueXmlString.toString()); System.out.println("SalesReturn :actionFullSR:Final Value :valueXmlString.toString():"+valueXmlString.toString());
return valueXmlString.toString(); return valueXmlString.toString();
} }
//method added by nandkumar gadkari on 25/06/19------------------------------------start--------------------------------------
private String splitMinRateHistBalAct(Document dom,Document dom1, String objContext, String xtraParams) throws RemoteException , ITMException
{
Connection conn = null;
Statement stmt = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
String sql = "";
String errCode = "";
String errString = "";
String flag = "";
String invoiceId = "";
String siteCode = "";
String itemCode = "";
String locCode = "";
String lotNoInv = "";
String lotSlInv = "";
String sreturnAdjOpt = "";
String orderByStr = "";
String custCode = "";
String reason = "";
String docKey = "";
String siteCodeMfgFn = "";
String packCodeFn = "";
String chkDate = "";
String quantity = "";
String stkMfgDate = "";
String stkExpDate = "";
String lotNo ="";
String lotSl ="";
String siteCodeMfg ="";
String packCode ="";
String unit = "";
java.sql.Date expDate = null;
java.sql.Date mfgDate = null;
int minShelfLife = 0;
int detCnt =0,cnt=0;
double totStk =0.0;
double inputQty = 0.0;
double qty =0;
double qtyStk = 0,invoiceQty=0,adjQty=0,rate=0;
DistCommon distCommon = null;
distCommon = new DistCommon();
StringBuffer valueXmlString = new StringBuffer("<?xml version=\"1.0\"?>\r\n<Root>\r\n");
if (dom == null)
{
valueXmlString.append("</Root>\r\n");
return valueXmlString.toString();
}
ibase.utility.E12GenericUtility genericUtility= new ibase.utility.E12GenericUtility();
ITMDBAccessEJB itmDBAccess = new ITMDBAccessEJB();
ConnDriver connDriver = new ConnDriver();
try
{
conn = getConnection();
System.out.println("\n******************** S T A R T *******splitMinRateHistBalAct*********************");
siteCode = genericUtility.getColumnValue("site_code",dom1);
itemCode = genericUtility.getColumnValue("item_code",dom);
quantity = genericUtility.getColumnValue("quantity",dom);
lotNo = genericUtility.getColumnValue("lot_no",dom);
custCode = genericUtility.getColumnValue("cust_code",dom1);
System.out.println("Values From DOM :siteCode:"+siteCode+":invoiceId:"+invoiceId+":quantity:"+quantity+":");
if(quantity != null && quantity.trim().length() > 0)
{
qty = Double.parseDouble(quantity);
sreturnAdjOpt = distCommon.getDisparams("999999", "SRETURN_ADJ_OPT", conn);
System.out.println("sreturnAdjOpt:::["+sreturnAdjOpt+"]");
if (sreturnAdjOpt == null || sreturnAdjOpt.trim().length()== 0 || "NULLFOUND".equalsIgnoreCase(sreturnAdjOpt))
{
sreturnAdjOpt="M";
}
if ("M".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " ORDER BY MRH.EFF_COST ";
}
else if("E".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " ORDER BY MRH.INVOICE_DATE ASC,MRH.INVOICE_ID ASC ";
}
else if("L".equalsIgnoreCase(sreturnAdjOpt))
{
orderByStr = " ORDER BY MRH.INVOICE_DATE DESC,MRH.INVOICE_ID DESC ";
}
if(lotNo != null && lotNo.trim().length() > 0 && qty > 0 && itemCode != null && itemCode.trim().length() > 0)
{
sql = " SELECT MRH.DOC_KEY,MRH.INVOICE_ID,MRH.QUANTITY, MRH.CUST_CODE, MRH.ITEM_CODE, MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE,"
+ " SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) AS QTY_ADJ, MRH.EFF_COST"
+ " FROM MIN_RATE_HISTORY MRH, SRETURNDET SRDET"
+ " WHERE MRH.DOC_KEY =SRDET.DOC_KEY(+) AND MRH.CUST_CODE = ?"
+ " AND MRH.ITEM_CODE = ? AND MRH.LOT_NO = ?"
+ " AND MRH.SITE_CODE = ? AND MRH.QUANTITY - CASE WHEN MRH.QUANTITY_ADJ IS NULL THEN 0 ELSE MRH.QUANTITY_ADJ END > 0"
+ " AND MRH.QUANTITY IS NOT NULL"
+ " GROUP BY MRH.DOC_KEY,MRH.INVOICE_ID, MRH.QUANTITY, MRH.EFF_COST,MRH.CUST_CODE,MRH.ITEM_CODE,MRH.LOT_NO, MRH.SITE_CODE, MRH.INVOICE_DATE"
+ " HAVING MRH.QUANTITY-SUM( CASE WHEN SRDET.QUANTITY IS NULL THEN 0 ELSE SRDET.QUANTITY END) > 0 "
+ orderByStr;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, custCode);
pstmt.setString(2, itemCode);
pstmt.setString(3, lotNo);
pstmt.setString(4, siteCode);
rs = pstmt.executeQuery();
while(rs.next())
{
if(qty >0)
{
invoiceId = checkNull(rs.getString("INVOICE_ID"));
invoiceQty =rs.getDouble("QUANTITY");
adjQty = rs.getDouble("QTY_ADJ");
docKey = checkNull(rs.getString("DOC_KEY"));
rate = rs.getDouble("EFF_COST");
cnt=0;
if (docKey.trim().length() > 0) {
String[] docKeyStr = docKey.split(",");
for(int j=0; j<docKeyStr.length; j++)
{
System.out.println( "docKeyStr :: " + docKeyStr[j]);
System.out.println( "docKeyStrlength :: " + docKeyStr.length);
cnt++;
}
}
System.out.println( "cnt :: " + cnt );
if(cnt==5)
{
inputQty=invoiceQty-adjQty;
System.out.println( "inputQty :: " + inputQty);System.out.println( "qty :: " + qty);
if(inputQty > 0)
{
valueXmlString.append("<Detail>\r\n");
valueXmlString.append("<item_code>").append("<![CDATA[").append(itemCode).append("]]>").append("</item_code>\r\n");
if(qty > inputQty)
{
valueXmlString.append("<quantity>").append("<![CDATA[").append(inputQty).append("]]>").append("</quantity>\r\n");
}
else {
valueXmlString.append("<quantity>").append("<![CDATA[").append(qty).append("]]>").append("</quantity>\r\n");
}
valueXmlString.append("<lot_no>").append("<![CDATA[").append(lotNo).append("]]>").append("</lot_no>\r\n");
valueXmlString.append("<invoice_ref>").append("<![CDATA[").append(invoiceId).append("]]>").append("</invoice_ref>\r\n");
valueXmlString.append("</Detail>\r\n");
qty=qty-inputQty;
}
}
if(qty <= 0)
{
break;
}
}
}//loop end
if (pstmt != null) {
pstmt.close();
pstmt = null;
}
if (rs != null) {
rs.close();
rs = null;
}
}
}
valueXmlString.append("</Root>\r\n");
if (errCode != null && errCode.trim().length() > 0)
{
System.out.println("SReturnMinRateHistBalAct:errCode:"+errCode);
errString = itmDBAccess.getErrorString("",errCode,"","",conn);
conn.close();
conn = null;
return errString;
}
}
catch(Exception e)
{
System.out.println("Exception :SalesReturn :" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
System.out.println("Closing Connection.....");
conn.close();
conn = null;
}catch(Exception e){}
}
System.out.println("SReturnMinRateHistBalAct :valueXmlString.toString():"+valueXmlString.toString());
return valueXmlString.toString();
}
private String checkNull(String input)
{
if (input == null)
{
input="";
}
return input;
}
//method added by nandkumar gadkari on 25/06/19------------------------------------end--------------------------------------
public String getRelativeDate(int no) throws RemoteException , ITMException public String getRelativeDate(int no) throws RemoteException , ITMException
{ {
String relativeDate = ""; String relativeDate = "";
......
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