Commit d4424ccd authored by prane's avatar prane

System is not calculating the no of article, Gross weight, Net Weight & Tare...

System is not calculating the no of article, Gross weight, Net Weight & Tare weight automatically based on the mapping done for that item in Item Lot Pack size

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@203223 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 9b59e7f2
......@@ -20,6 +20,7 @@ import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.text.DateFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Arrays;
......@@ -6212,6 +6213,8 @@ public class PoReceiptIc extends ValidatorEJB implements PoReceiptIcLocal,PoRec
lcstdrate = 0 ,mCancperc = 0 , lcconvtemp= 0 ,lctemp = 0 ,lcconv = 0 ,mDlvQty = 0 ,lcrealisedqty = 0 , lcgrosswt = 0 ,lctarewt = 0 ,
lcnetwt= 0 ;// = 0 , = 0 , = 0;
String projectCode = ""; // Added by sarita on 29 MARCH 2019
String grossWeight="",netWeight="",netWtItem="", netWt="", integrlQty="",lcMode="";
double mGrossWeight=0d, mNetWeight=0d, mGrosswt=0d,mNetWt=0d, mTareWt=0d,mNoart=0d, mNetWtItem=0d, mIntegrlQty=0d;
try {
......@@ -9484,8 +9487,216 @@ public class PoReceiptIc extends ValidatorEJB implements PoReceiptIcLocal,PoRec
System.out.println("rate__stduom inputQty=["+inputQty+"]");
valueXmlString.append("<conv__rtuom_stduom >").append("<![CDATA[" + lcrtconv1 + "]]>").append("</conv__rtuom_stduom>");
valueXmlString.append("<rate__stduom >").append("<![CDATA[" + ratestduom + "]]>").append("</rate__stduom>");
//Pavan R 10jul19 start [no of art to consider from item_lot_packsize, item and if not found then packing master]
double noOfArt = 0d, shipperSize = 0d;
double mCapacity=0d;
System.out.println("Pavan Rane DOM[ "+genericUtility.serializeDom(dom)+"]\n\n\n");
System.out.println("Quantity["+lcqty+"]ItemCode["+mitem+"]mlotno["+mlotno+"]lspack["+lspack+"]");
sql = "select (case when shipper_size is null then 0 else shipper_size end) as shipper_size, "
+ "(case when gross_weight is null then 0 else gross_weight end) as lc_gross_weigth, "
+ "(case when net_weight is null then 0 else net_weight end) as lc_net_weight "
+ "from item_lot_packsize where item_code = ? "
+ "and ? >= lot_no__from and ? <= lot_no__to";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, mitem);
pstmt.setString(2, mlotno);
pstmt.setString(3, mlotno);
rs = pstmt.executeQuery();
if(rs.next())
{
shipperSize = rs.getDouble("shipper_size");
mGrossWeight= rs.getDouble("LC_GROSS_WEIGTH");
mNetWeight= rs.getDouble("LC_NET_WEIGHT");
System.out.println("Pavan R shipperSize["+shipperSize+"] grossWeight [ "+mGrossWeight+" ] netWeight[ "+mNetWeight+" ]");
if (shipperSize > 0)
{
double mod = lcqty/shipperSize;
noOfArt = getRndamt(mod , "X", 1);
System.out.println("noOfArt["+noOfArt+"]");
valueXmlString.append("<no_art><![CDATA[").append(noOfArt).append("]]></no_art>\r\n");
if(noOfArt > 0)
{
mGrosswt = ((mGrossWeight/shipperSize) * lcqty);
mNetWt = ((mNetWeight/shipperSize) * lcqty);
System.out.println("mGrosswt [ "+mGrosswt+" ]");
if(mGrossWeight > 0)
{
valueXmlString.append("<gross_weight ><![CDATA[").append(getRequiredDecimal(mGrosswt,3)).append("]]></gross_weight>\r\n");
valueXmlString.append("<net_weight ><![CDATA[").append(getRequiredDecimal(mNetWt,3)).append("]]></net_weight>\r\n");
mTareWt=mGrosswt - mNetWt;
System.out.println("mGrossWeight > 0 mTareWt [ "+mTareWt+" ]");
valueXmlString.append("<tare_weight ><![CDATA[").append(getRequiredDecimal(mTareWt, 3)).append("]]></tare_weight>\r\n");
}
} //if(noOfArt > 0)
}//if(shipperSize > 0)
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if(shipperSize == 0)
{
System.out.println("Pavan Rane After ShipperSize ==0 PackingCode ["+lspack+"]");
if(lspack != null && lspack.trim().length()>0)
{
double mlcMode = 0d;
sql="select capacity from packing where pack_code = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,lspack);
rs = pstmt.executeQuery();
if( rs.next())
{
mCapacity= rs.getDouble("capacity");
System.out.println("Capacity::["+mCapacity+"]");
}
rs.close();
rs = null;
pstmt.close();
pstmt=null;
}
if((lspack!=null && lspack.trim().length()>0) && (mCapacity > 0))
{
double mod = lcqty/mCapacity;
mNoart = getRndamt(mod, "X", 1);
System.out.println("Pavan R mNoart["+mNoart+"]");
valueXmlString.append("<no_art ><![CDATA[").append(mNoart).append("]]></no_art>\r\n");
if(( mNoart > 0))
{
sql="SELECT (CASE WHEN GROSS_WEIGHT IS NULL THEN 0 ELSE GROSS_WEIGHT END) AS LC_GROSS_WEIGTH, (CASE WHEN NET_WEIGHT IS NULL THEN 0 ELSE NET_WEIGHT END) AS LC_NET_WEIGHT FROM ITEM_LOT_PACKSIZE WHERE ITEM_CODE = ? AND ? BETWEEN LOT_NO__FROM AND LOT_NO__TO ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,mitem);
pstmt.setString(2,mlotno);
rs = pstmt.executeQuery();
if( rs.next())
{
grossWeight= checkNull(rs.getString("LC_GROSS_WEIGTH"));
netWeight= checkNull(rs.getString("LC_NET_WEIGHT"));
System.out.println("Pavan Rane grossWeight ["+grossWeight+"]netWeight["+netWeight+"]");
}
rs.close();
rs = null;
pstmt.close();
pstmt=null;
if(grossWeight.trim().length() > 0)
{
mGrossWeight=Double.parseDouble(grossWeight);
}
if(netWeight.trim().length() > 0)
{
mNetWeight=Double.parseDouble(netWeight);
}
mGrosswt = ((mGrossWeight/mCapacity) * lcqty);
mNetWt = ((mNetWeight/mCapacity) * lcqty);
//mGrosswt= mNoart * mGrossWeight;
System.out.println("Pavan Rane total mGrosswt["+mGrosswt+"] mGrossWeight["+mGrossWeight+"]");
if(mGrossWeight > 0)
{
valueXmlString.append("<gross_weight ><![CDATA[").append(getRequiredDecimal(mGrosswt, 3)).append("]]></gross_weight>\r\n");
valueXmlString.append("<net_weight ><![CDATA[").append(getRequiredDecimal(mNetWt, 3)).append("]]></net_weight>\r\n");
mTareWt=mGrosswt - mNetWt;
valueXmlString.append("<tare_weight ><![CDATA[").append(getRequiredDecimal(mTareWt, 3)).append("]]></tare_weight>\r\n");
}
}
}
else
{
sql="SELECT (CASE WHEN NET_WEIGHT IS NULL THEN 0 ELSE NET_WEIGHT END) AS NET_WT_ITEM, INTEGRAL_QTY FROM ITEM WHERE ITEM_CODE = ? ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,mitem);
rs = pstmt.executeQuery();
if( rs.next())
{
netWtItem= checkNull(rs.getString("NET_WT_ITEM"));
integrlQty= checkNull(rs.getString("INTEGRAL_QTY"));
System.out.println("Pavan Rane else netWtItem["+netWtItem+"] integrlQty["+integrlQty+"]");
}
rs.close();
rs = null;
pstmt.close();
pstmt=null;
sql="SELECT (CASE WHEN NET_WEIGHT IS NULL THEN 0 ELSE NET_WEIGHT END) AS NET_WT FROM ITEM_LOT_PACKSIZE WHERE ITEM_CODE = ? AND ? BETWEEN LOT_NO__FROM AND LOT_NO__TO ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,mitem);
pstmt.setString(2,mlotno);
rs = pstmt.executeQuery();
if( rs.next())
{
netWt= checkNull(rs.getString("NET_WT"));
System.out.println("Pavan Rane netWt["+netWt+"]");
}
rs.close();
rs = null;
pstmt.close();
pstmt=null;
if(netWtItem.trim().length() > 0)
{
mNetWtItem=Double.parseDouble(netWtItem);
}
if(netWt.trim().length() > 0)
{
mNetWt=Double.parseDouble(netWt);
}
if(integrlQty.trim().length()>0)
{
mIntegrlQty=Double.parseDouble(integrlQty);
}
if(mNetWt==0)
{
mNetWt=mNetWtItem;
}
if(mNetWt==0)
{
}
else
{
mNetWt=mNetWt * lcqty;
if(mIntegrlQty>0)
{
sql="SELECT FN_MOD( ? ,? ) AS LC_MODE FROM DUAL ";
pstmt=conn.prepareStatement(sql);
pstmt.setString(1,lcqty1);
pstmt.setString(2,integrlQty);
rs = pstmt.executeQuery();
if( rs.next())
{
lcMode= checkNull(rs.getString("LC_MODE"));
System.out.println("intered in rs item descr hhho.."+lcMode);
}
rs.close();
rs = null;
pstmt.close();
pstmt=null;
if(lcMode.length()>0)
{
mNoart=(lcqty / mIntegrlQty) + 1; //in pb int is used before open brackets
}
else
{
mNoart=(lcqty / mIntegrlQty) ; //in pb int is used before open brackets
}
}
else
{
mNoart=lcqty;
}
}
valueXmlString.append("<gross_weight ><![CDATA[").append(getRequiredDecimal(mNetWt, 3)).append("]]></gross_weight>\r\n");
valueXmlString.append("<net_weight ><![CDATA[").append(getRequiredDecimal(mNetWt, 3)).append("]]></net_weight>\r\n");
valueXmlString.append("<tare_weight ><![CDATA[").append("0").append("]]></tare_weight>\r\n");
valueXmlString.append("<no_art ><![CDATA[").append(mNoart).append("]]></no_art>\r\n");
}
}
//Pavan R 10jul19 end
}
else if(currentColumn.trim().equalsIgnoreCase("lot_sl"))
{
......@@ -11074,5 +11285,74 @@ public class PoReceiptIc extends ValidatorEJB implements PoReceiptIcLocal,PoRec
return cpFlag;
}
//Pavan Rane 11jun19 end
//Pavan R 10jul19 start [below method added for no of art to consider from item_lot_packsize, item and if not found then packing master]
public double getRndamt(double newQty, String round, double roundTo) {
System.out.println(newQty+"~~~"+round+"~~~"+roundTo);
double lcMultiply = 1;
try {
round = round.toUpperCase();
if (newQty < 0) {
lcMultiply = -1;
newQty = Math.abs(newQty);
} else if (newQty == 0) {
return newQty;
} else if (round.trim().equals("N")) {
return newQty;
} else if (roundTo == 0) {
return newQty;
}
if (round.trim().equals("X")) {
if(newQty == (newQty - (newQty % roundTo)))
{
return newQty;
}
else
{
newQty = ((newQty - (newQty % roundTo)) + roundTo);
}
}
if (round.trim().equals("P")) {
newQty = (newQty - (newQty % roundTo));
}
if (round.trim().equals("R")) {
if ((newQty % roundTo) < (roundTo / 2)) {
newQty = (newQty - (newQty % roundTo));
} else {
newQty = (newQty - (newQty % roundTo) + roundTo);
}
}
System.out.println("newQty[" + newQty + "]");
System.out.println("lcMultiply[" + lcMultiply + "]");
newQty = newQty * lcMultiply;
System.out.println("newQty * lcMultiply[" + newQty + "]");
return newQty;
} catch (Exception e) {
System.out.println("Exception :Conversion Qty ::" + e.getMessage()
+ ":");
}
if (roundTo == 1) {
newQty = getRequiredDecimal(newQty, 0);
} else if (roundTo == .1) {
newQty = getRequiredDecimal(newQty, 1);
} else if (roundTo == .01) {
newQty = getRequiredDecimal(newQty, 2);
} else if (roundTo == .001) {
newQty = getRequiredDecimal(newQty, 3);
} else if (roundTo == .0001) {
newQty = getRequiredDecimal(newQty, 4);
}
return newQty;
}
public double getRequiredDecimal(double actVal, int prec) {
NumberFormat numberFormat = NumberFormat.getIntegerInstance();
Double DoubleValue = new Double(actVal);
numberFormat.setMaximumFractionDigits(3);
String strValue = numberFormat.format(DoubleValue);
strValue = strValue.replaceAll(",", "");
double reqVal = Double.parseDouble(strValue);
return reqVal;
}
//Pavan R 10jul19 end
}
\ No newline at end of file
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