Commit db1226bb authored by manohar's avatar manohar

Potency calculation changes


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101745 ce508802-f39f-4f6c-b175-0d175dae99d5
parent f42ce7ef
......@@ -1150,6 +1150,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
SiteItemSummaryBean siteItemSumBeanObj = null;
WorderStkBean worderStkBeanObj = null;
int count1 = 0;
int stkindex = -1;
double finalAllocatedQty = 0;
try
{
......@@ -1373,11 +1374,18 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
packCode = rs.getString("PACK_CODE");
System.out.println("stkPotencyPerc------>>["+stkPotencyPerc+"]");
System.out.println("minPotencyPerc------>>["+minPotencyPerc+"]");
stkindex = -1;
if(stkPotencyPerc >= minPotencyPerc)
{
int stkindex = indexOfWorkorderStkList(detailMap.get("WORK_ORDER"),detailMap.get("EXP_LEV"),detailMap.get("ITEM_CODE"),
if(!isReallocation)
{
stkindex = indexOfWorkorderStkList(detailMap.get("WORK_ORDER"),detailMap.get("EXP_LEV"),detailMap.get("ITEM_CODE"),
locCode,detailMap.get("SITE_CODE"),lotNo,lotSl);
}
else
{
stkindex = -1;
}
if(stkindex != -1)
{
System.out.println("Adding itemCode in existing worderStkBeanList"+detailMap.get("ITEM_CODE"));
......@@ -1386,7 +1394,6 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
else
{
worderStkBeanObj = new WorderStkBean();
}
worderStkBeanObj.setItemCode(detailMap.get("ITEM_CODE"));
itemDescr = getColumnDescr(conn, "descr", "item", "item_code", detailMap.get("ITEM_CODE"));
worderStkBeanObj.setItemDescr(itemDescr);
......@@ -1410,6 +1417,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
worderStkBeanObj.setOtherSiteYN(otherSite);
worderStkBeanObj.setIsStockDetail("Y");
worderStkBeanObj.setMinQtyReq(minQtyReq);
}
double qtyPerArt = 0,finalAllocQty = 0;
qtyPerArt = getQtyPerArt(stkKey,conn);
......@@ -1587,7 +1595,24 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
finalAllocatedQty = stkQuantity;
}
System.out.println("Adding stk..........."+worderStkBeanObj.getStockSufficient());
System.out.println("isReallocation Flag in check site["+isReallocation+"]");
System.out.println("isReallocation Flag in check site["+isReallocation+"] [" + stkindex + "]");
if (!isReallocation)
{
if(stkindex != -1)
{
worderStkBeanObj.setAllocQty(worderStkBeanObj.getAllocQty() + finalAllocatedQty);
System.out.println("manohar before .setQuantity 1["+worderStkBeanObj.getQuantity()+"] isReallocation[" + isReallocation + "]");
worderStkBeanObj.setQuantity(worderStkBeanObj.getQuantity() + finalAllocatedQty);
System.out.println("manohar after .setQuantity 1["+worderStkBeanObj.getQuantity()+"]");
}
else
{
worderStkBeanObj.setAllocQty(finalAllocatedQty);
System.out.println("manohar before .setQuantity 2["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setQuantity(finalAllocatedQty);
System.out.println("manohar after .setQuantity 2["+worderStkBeanObj.getQuantity()+"]");
}
}
if(isReallocation)
{
tempWorderExpStkBeanList.add(worderStkBeanObj);
......@@ -1604,8 +1629,6 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
else
{
System.out.println("Adding itemCode in worderStkBeanList"+detailMap.get("ITEM_CODE"));
worderStkBeanObj.setAllocQty(finalAllocatedQty);
worderStkBeanObj.setQuantity(finalAllocatedQty);
//worderStkBeanObj.setStkQuantity(stkQuantity - finalAllocatedQty);
worderStkBeanList.add(worderStkBeanObj);
}
......@@ -1750,10 +1773,10 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{
System.out.println("@@in checkStockPotency..........");
String workOrder = "",expLevel = "",matchPotency = "",adjPotency = "",itemCode = "",unitPotency = "";
String errorCodeRet = "",adjPotencyChk = "",expLevelNew = "",allocRetStr = "" ;
String errorCodeRet = "",adjPotencyChkY = "",expLevelNew = "",allocRetStr = "" , adjPotencyChkN = "";
//String splitKey [];
//int index = -1; // 09-mar-16 manoharan
double proQty=0, qtyPotencyUnit = 0,ItemStdPotency = 0,potencyAdjNew = 0, proportionateTotQty = 0,PropoQtySum = 0;
double proQty=0, qtyPotencyUnit = 0,ItemStdPotency = 0,potencyAdjNew = 0, potencyAdjExpLev = 0,quantityReqExpLev = 0;
double requiredStock = 0,availableStock = 0,potencyAdj = 0,stkPotencyPerc = 0,balanceQty = 0,
tempStock = 0,matchQty = 0,totalPro = 0,stockAllocAddN = 0,updQty = 0,preExpShortQty = 0,balance = 0,currentLotQty = 0,currntEqualQty = 0;
Map<String,Double>potencyAdjMapY = null;
......@@ -1773,6 +1796,9 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
//int count = -1,indexAdjust = -1;
int foundIndex = -1;
boolean isSufficient = false;
double deallocQty = 0,allocatedQty = 0, extraQty = 0, potencyAdjLot = 0, quantityReqLot = 0;
boolean removeElement = false;
try
{
......@@ -1845,7 +1871,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
if(workOrder.equalsIgnoreCase(worderStkBeanObj.getWorkOrder().trim()) && expLevel.equalsIgnoreCase(worderStkBeanObj.getExpLevel().trim()))
{
System.out.println("Same wo/expLev worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"]Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"]Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
System.out.println("Same wo/expLev worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
availableStock = worderStkBeanObj.getStkQuantity();//available
stkPotencyPerc = worderStkBeanObj.getStkPotencyPerc();
itemCode = worderStkBeanObj.getItemCode();
......@@ -1868,17 +1894,20 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
potencyAdj = Double.parseDouble(df.format(potencyAdj));//0.200
System.out.println("After calculating potencyAdj NOT SUFFICIENT----->>["+potencyAdj+"]");
currntEqualQty = currentLotQty - potencyAdj; //4-0.2 = 3.8
currntEqualQty = Double.parseDouble(df.format(currentLotQty - potencyAdj)) ; //4-0.2 = 3.8
balance = balance - currntEqualQty; //6-3.8 = 2.2
balance = Double.parseDouble(df.format(balance - currntEqualQty)); //6-3.8 = 2.2
worderStkBeanObj.setPotencyAdj(potencyAdj);
worderStkBeanObj.setQuantity(currntEqualQty);
worderStkBeanObj.setQtyAdj(potencyAdj);
worderStkBeanObj.setPotencyAdj(Double.parseDouble(df.format(potencyAdj)));
///////////////////////////////worderStkBeanObj.setQuantity(currntEqualQty);
worderStkBeanObj.setQtyAdj(Double.parseDouble(df.format(potencyAdj)));
balance = Double.parseDouble(df.format(balance));
//worderStkBeanObj.setAllocQty(Double.parseDouble(df.format(balance)));//Changed by wasim on 18-04-2014
//updQty = worderStkBeanObj.getAllocQty() + potencyAdj;
//worderStkBeanObj.setAllocQty(updQty);
System.out.println("manohar before .setQuantity 3["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setQuantity(currntEqualQty);
System.out.println("manohar after .setQuantity 3["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setAllocQty(currentLotQty); // 09-mar-16 manoharan added if stock not sufficient full stock of the lot is allocated
worderStkBeanObj.setUpdQty(currentLotQty);
......@@ -1895,9 +1924,11 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
System.out.println("Final Balance="+balance);
if(balance > 0)
{
System.out.print("Balance > 0 [" + balance + "] worderStkBeanList.size() [" + worderStkBeanList.size() + "] innerCtr [" + innerCtr +"]" );
if (worderStkBeanList.size() > innerCtr +1)
{
WorderStkBean worderStkBeanObjNext = (WorderStkBean) worderStkBeanList.get(innerCtr+1);
if(
(worderStkBeanObj.getWorkOrder().equals(worderStkBeanObjNext.getWorkOrder())) &&
(worderStkBeanObj.getExpLevel().equals(worderStkBeanObjNext.getExpLevel()))
......@@ -1908,6 +1939,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
}
}
}
else // if stock sufficient
{
System.out.println("@@Sufficient--> balance["+balance+"] stkPotencyPerc ["+stkPotencyPerc+"] ItemStdPotency ["+ItemStdPotency+"]");
......@@ -1918,10 +1950,13 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
worderStkBeanObj.setQtyAdj(Double.parseDouble(df.format(potencyAdj)));
updQty = worderStkBeanObj.getAllocQty() + potencyAdj; //2 + 0.244 = 2.244
updQty = Double.parseDouble(df.format(updQty));
//updQty = balance + potencyAdj; //2.2+0.244 = 2.444
System.out.println("manohar before .setQuantity 4["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setQuantity(worderStkBeanObj.getAllocQty() ); // 2.2 - 0.2444 = /// 23-may-16 manoharan
System.out.println("manohar after .setQuantity 3["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setAllocQty(updQty); // 2 + 0.244 = 2.244
//worderStkBeanObj.setQuantity(balance - potencyAdj); // 2.2 - 0.2444 =
worderStkBeanObj.setQuantity(updQty); // 2.2 - 0.2444 =
//////////////////////////////*********worderStkBeanObj.setQuantity(updQty); // 2.2 - 0.2444 =
worderStkBeanObj.setUpdQty(updQty);
worderStkBeanObj.setStockSufficient("Y");
worderStkBeanObj.setQtyAdj(potencyAdj);//wasim on 13-04-2016
......@@ -1930,7 +1965,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
if(potencyAdjMapY.containsKey(adjPotency) )
{
potencyAdjMapY.put(adjPotency, (potencyAdjMapY.get(adjPotency) + potencyAdj ));
potencyAdjMapY.put(adjPotency, Double.parseDouble(df.format((potencyAdjMapY.get(adjPotency) + potencyAdj ))) );
}
else
{
......@@ -1974,8 +2010,16 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
detailMap.put("MIN_QTY_REQ", String.valueOf(worderDetailBeanObj.getMinReqQty()));
detailMap.put("BALANCE_QTY",potencyAdj+"");
// 26-may-16 the following part added
isReallocation = true;
Map<String,String>detailStkMap = checkCurrentSiteStock(detailMap, conn);
for(WorderStkBean tempStkObj : tempWorderExpStkBeanList)
{
worderStkBeanListTemp.add(tempStkObj);
}
tempWorderExpStkBeanList.clear();
isReallocation = false;
// end 26-may-16 the following part added
System.out.println("detailStkMap C.Potency-------->>["+detailStkMap+"]");
balance = 0;
......@@ -2045,7 +2089,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
else
{
System.out.println(" N adjPotency----->>["+adjPotency+"] ["+availableStock+"]");
System.out.println("Same wo/expLev(N) worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"]Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"]Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
System.out.println("Same wo/expLev(N) worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
if(adjPotency != null && adjPotency.trim().length() > 0)
{
System.out.println("Potency to be adjusted [" + adjPotency + "]");
......@@ -2066,6 +2110,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{
qtyPotencyUnit = requiredStock;
}
qtyPotencyUnit = Double.parseDouble(df.format(qtyPotencyUnit));
System.out.println("manohar qtyPotencyUnit before[" + qtyPotencyUnit + "] worderStkBeanObj.getAllocQty() [" + worderStkBeanObj.getAllocQty() + "]");
System.out.println("Stk qty After--->>["+worderStkBeanObj.getStkQuantity()+"]");
System.out.println("Work Order Bean Quantity="+worderDetailBeanObj.getQuantity());
......@@ -2078,7 +2123,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
AdjPotencyExplevQtyMap.put(adjPotency+":"+expLevel, qtyPotencyUnit );
if(potencyAdjMapN.containsKey(adjPotency))
{
potencyAdjMapN.put(adjPotency, (potencyAdjMapN.get(adjPotency) + qtyPotencyUnit ));
potencyAdjMapN.put(adjPotency, Double.parseDouble(df.format((potencyAdjMapN.get(adjPotency) + qtyPotencyUnit ))));
}
else
{
......@@ -2130,18 +2176,23 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
for(WorderStkBean tempStkObj : worderStkBeanListTemp)
{
// 09-mar-16 manoharan check whether same key exists of so add to existing
System.out.println("manohar before adding templist getAllocQty [" + tempStkObj.getAllocQty()+ "] potencyadj [" + tempStkObj.getPotencyAdj() + "]" );
foundIndex = -1;
foundIndex = indexOfWorkorderStkList(tempStkObj.getWorkOrder(), tempStkObj.getExpLevel(),tempStkObj.getItemCode(),tempStkObj.getLocCode(),tempStkObj.getSiteCode(),tempStkObj.getLotNo(),tempStkObj.getLotSl());
if (foundIndex > -1) // already exists add alloc_qty and petencyadj to existing
{
System.out.println("manohar before templist merge " );
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(foundIndex);
System.out.println("manohar before templist merge getAllocQty [" + worderStkBeanObj.getAllocQty()+ "] potencyadj [" + worderStkBeanObj.getPotencyAdj() + "]" );
worderStkBeanObj.setAllocQty(worderStkBeanObj.getAllocQty() + tempStkObj.getAllocQty());
worderStkBeanObj.setPotencyAdj(worderStkBeanObj.getPotencyAdj() + tempStkObj.getPotencyAdj());
worderStkBeanList.set(foundIndex,worderStkBeanObj);
System.out.println("manohar after templist merge getAllocQty [" + worderStkBeanObj.getAllocQty()+ "] potencyadj [" + worderStkBeanObj.getPotencyAdj() + "]" );
}
else
{
worderStkBeanList.add(tempStkObj);// not exists add
}
}
......@@ -2149,71 +2200,80 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
System.out.println("potencyAdjMapY---------->>["+potencyAdjMapY+"]");
System.out.println("AdjPotencyExplevQtyMap---------->>["+AdjPotencyExplevQtyMap+"]");
System.out.println("AdjPotencyExplevQtyMap-->>["+AdjPotencyExplevQtyMap+"]");
System.out.println("potencyAdjMapN---------->>["+potencyAdjMapN+"]");
System.out.println("worderStkBeanList---------->>["+worderStkBeanList.size()+"]");
System.out.println("worderStkBeanList------->>["+worderStkBeanList.size()+"]");
//int indexN = -1;// 09-mar-16 manoharan commented for index based
//shortageQty = 0;
for(Map.Entry<String,Double> entry : potencyAdjMapY.entrySet())
{
adjPotencyChk = entry.getKey();
adjPotencyChkY = entry.getKey();
potencyAdjNew = -1 * (entry.getValue());
System.out.println("adjPotencyChk ["+adjPotencyChk+"] potencyAdjNew ["+potencyAdjNew + "]");
System.out.println("adjPotencyChkY ["+adjPotencyChkY+"] potencyAdjNew ["+potencyAdjNew + "]");
if(potencyAdjMapN.containsKey(adjPotencyChk))
if(potencyAdjMapN.containsKey(adjPotencyChkY))
{
//AdjPotencyExplevQtyMap
adjPotencyChkN = "";
for(Map.Entry<String,Double> adjPotencyExpLevel : AdjPotencyExplevQtyMap.entrySet())
{
String splitKey [] = adjPotencyExpLevel.getKey().split(":");
// 19-may-16 manoharan there cn be many different adjPotency in AdjPotencyExplevQtyMap
// if the current adjPotency not matching with adjPotencyChkY
adjPotencyChkN = splitKey [0];
if (!adjPotencyChkN.trim().equals(adjPotencyChkY.trim()))
{
continue;
}
expLevelNew = splitKey [1];
System.out.println("expLevelNew---------->>["+expLevelNew+"]");
//indexN = -1; // 09-mar-16 manoharan commented for index based
//for(WorderStkBean worderStkBeanObj : worderStkBeanList)
//{
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
for(int potencyCtr=0 ; potencyCtr < worderStkBeanList.size(); potencyCtr++)
System.out.println("potencyAdjNew--------->>["+potencyAdjNew+"]");//-93.733
System.out.println("adjPotencyExpLevel.getValue()--------->>["+adjPotencyExpLevel.getValue()+"]");//
System.out.println("potencyAdjMapN--------->>["+potencyAdjMapN.get(adjPotencyChkY)+"]");//
potencyAdjExpLev = potencyAdjNew * adjPotencyExpLevel.getValue() / potencyAdjMapN.get(adjPotencyChkY) ;
potencyAdjExpLev = Double.parseDouble(df.format(potencyAdjExpLev));
System.out.println("potencyAdjExpLev---------->>["+potencyAdjExpLev+"]");//-93.733
quantityReqExpLev = adjPotencyExpLevel.getValue() + potencyAdjExpLev;//56.366
quantityReqExpLev = Double.parseDouble(df.format(quantityReqExpLev));//38.477
System.out.println("quantityReqExpLev---------->>["+quantityReqExpLev+"]");
if (potencyAdjExpLev < 0)
{
// Extra allocation done to be deallocated
// 1. deallocate the extra quantity then proportionally recalculate potencyAdj and update
extraQty = adjPotencyExpLevel.getValue() - quantityReqExpLev;
extraQty = Double.parseDouble(df.format(extraQty));
int stockListSize = worderStkBeanList.size() -1;
System.out.println("Deallocate stockListSize [" + stockListSize + "] ExpLev [" + expLevelNew+"] quantity["+ adjPotencyExpLevel.getValue() + "] quantityReqExpLev ["+quantityReqExpLev+"] extraQty [" + extraQty + "]");
for(int potencyCtr = stockListSize; potencyCtr > 0 ; potencyCtr--)
{
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(potencyCtr);
System.out.println("20-May-16 In deallocate stockListSize ["+stockListSize + "] potencyCtr [" + potencyCtr + "]");
//indexN++; // 09-mar-16 manoharan commented for index based
System.out.println("workOrderPotency["+workOrderPotency+"] and getWork Order["+worderStkBeanObj.getWorkOrder()+"]");
System.out.println("expLevelNew["+expLevelNew+"] and getWork Order["+worderStkBeanObj.getExpLevel()+"]");
if(workOrderPotency.equalsIgnoreCase(worderStkBeanObj.getWorkOrder()) && expLevelNew.equalsIgnoreCase(worderStkBeanObj.getExpLevel()))
if(workOrderPotency.trim().equalsIgnoreCase(worderStkBeanObj.getWorkOrder().trim()) && expLevelNew.trim().equalsIgnoreCase(worderStkBeanObj.getExpLevel().trim()))
{
availableStock = worderStkBeanObj.getStkQuantity();
/*if(shortageQty <= availableStock )
{*/
//-3.425 * 40 / 90 = -1.5221088435
//System.out.println("shortageQty---------->>["+shortageQty+"]");
System.out.println("potencyAdjNew--------->>["+potencyAdjNew+"]");//-93.733
System.out.println("adjPotencyExpLevel.getValue()--------->>["+adjPotencyExpLevel.getValue()+"]");//
System.out.println("potencyAdjMapN--------->>["+potencyAdjMapN.get(adjPotencyChk)+"]");//
proportionateTotQty = potencyAdjNew * adjPotencyExpLevel.getValue() / potencyAdjMapN.get(adjPotencyChk) ;
proportionateTotQty = Double.parseDouble(df.format(proportionateTotQty));
System.out.println("proportionateTotQty---------->>["+proportionateTotQty+"]");//-93.733
PropoQtySum = adjPotencyExpLevel.getValue() + proportionateTotQty;//56.366
System.out.println("PropoQtySum---------->>["+PropoQtySum+"]");
PropoQtySum = Double.parseDouble(df.format(PropoQtySum));//38.477
worderStkBeanObj.setQtyAdj(proportionateTotQty);
worderStkBeanObj.setUpdQty(PropoQtySum);
worderStkBeanObj.setAllocQty(PropoQtySum);
System.out.println("item code"+worderStkBeanObj.getItemCode()+"and alloc quantity setting as"+worderStkBeanObj.getAllocQty());
//worderStkBeanList.set(indexN, worderStkBeanObj); // 09-mar-16 manoharan commented for index based
worderStkBeanList.set(potencyCtr, worderStkBeanObj);// 09-mar-16 manoharan added for index based
//Changed by wasim on 07-04-2015 to call allocation for stock if it plus or minus [START]
if(proportionateTotQty < 0)
if (extraQty <= 0)
{
break;
}
removeElement = false;
allocatedQty = worderStkBeanObj.getAllocQty();
System.out.println("Same wo/expLev(N) deallocate worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
// check allocated quantity >= extra quantity and deallocate accordingly
if (allocatedQty <= extraQty )
{
deallocQty = allocatedQty;
extraQty -= allocatedQty;
removeElement = true;
}
else
{
deallocQty = extraQty;
extraQty = 0;
}
Map<String,String> stockAllocMap = new HashMap<String,String>();
stockAllocMap.put("ALLOC_QTY",""+proportionateTotQty);
stockAllocMap.put("ALLOC_QTY",""+ (deallocQty * -1));
stockAllocMap.put("LOC_CODE", worderStkBeanObj.getLocCode());
stockAllocMap.put("ITEM_CODE",worderStkBeanObj.getItemCode());
stockAllocMap.put("SITE_CODE",worderStkBeanObj.getSiteCode());
......@@ -2221,12 +2281,49 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
stockAllocMap.put("LOT_SL",worderStkBeanObj.getLotSl());
// 09-mar-16 manoharan - what will the string returned??????????
allocRetStr = updateStockAllocQty(stockAllocMap,conn);
System.out.println("After update stock="+allocRetStr);
System.out.println("After update stock ["+allocRetStr + "]") ;
if (removeElement)
{
worderStkBeanList.remove(potencyCtr);
}
else
{
worderStkBeanObj.setUpdQty(worderStkBeanObj.getAllocQty() - deallocQty);
worderStkBeanObj.setAllocQty(worderStkBeanObj.getAllocQty() - deallocQty);
worderStkBeanList.set(potencyCtr, worderStkBeanObj);
System.out.println("Same wo/expLev(N) after deallocate worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
}
}
}
// 2. proportionally recalculate potencyAdj and update
for(int potencyCtr = 0; potencyCtr < worderStkBeanList.size(); potencyCtr++)
{
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(potencyCtr);
if(workOrderPotency.trim().equalsIgnoreCase(worderStkBeanObj.getWorkOrder().trim()) && expLevelNew.trim().equalsIgnoreCase(worderStkBeanObj.getExpLevel().trim()))
{
allocatedQty = worderStkBeanObj.getQuantity();
// -13.015 34.988 34.988
potencyAdjLot = potencyAdjExpLev / adjPotencyExpLevel.getValue() * allocatedQty;
potencyAdjLot = Double.parseDouble(df.format(potencyAdjLot));
quantityReqLot = allocatedQty + potencyAdjLot;
quantityReqLot = Double.parseDouble(df.format(quantityReqLot));
System.out.println("Same wo/expLev(N) before recalculate worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
worderStkBeanObj.setQtyAdj(potencyAdjLot);
worderStkBeanObj.setPotencyAdj(potencyAdjLot);
//worderStkBeanObj.setQuantity(quantityReqLot);
worderStkBeanObj.setUpdQty(quantityReqLot);
worderStkBeanObj.setAllocQty(quantityReqLot);
System.out.println("Same wo/expLev(N) after recalculate worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
worderStkBeanList.set(potencyCtr, worderStkBeanObj);// 09-mar-16 manoharan added for index based
}
}
}
else
{
System.out.println("Now going for last allocation");
// additional stock to be allocated
// 1. Allocate additional stock to the extend of potencyAdj
foundIndex = indexOfWorkorderBeanList(worderStkBeanObj.getWorkOrder(),worderStkBeanObj.getExpLevel());
worderDetailBeanObj = workOrderBeanList.get(foundIndex);
......@@ -2242,7 +2339,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
detailMap.put("ITEM_REF", worderDetailBeanObj.getItemRef());
detailMap.put("BOM_CODE", worderDetailBeanObj.getBomCode());
detailMap.put("ITEM_CODE", worderDetailBeanObj.getItemCode());
detailMap.put("QUANTITY", String.valueOf(proportionateTotQty));
detailMap.put("QUANTITY", String.valueOf(potencyAdjExpLev));
detailMap.put("SITE_CODE", worderStkBeanObj.getSiteCode());//wasim
detailMap.put("UNIT", worderDetailBeanObj.getUnit());
detailMap.put("MATCH_POTENCY", worderDetailBeanObj.getMatchPotency());
......@@ -2267,7 +2364,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
detailMap.put("STOCK_DETAIL", "Y");
detailMap.put("MIN_QTY_REQ", String.valueOf(worderDetailBeanObj.getMinReqQty()));
detailMap.put("BALANCE_QTY",proportionateTotQty+"");
//detailMap.put("BALANCE_QTY",potencyAdjExpLev+"");
isReallocation = true; // 09-mar-16 manoharan reallocation templist to be populated
//checkCurrentSiteStock(detailMap,conn); // 09-mar-16 manoharan commented return value to be captured and checked
Map<String,String>detailStkMap = checkCurrentSiteStock(detailMap,conn); // 09-mar-16 manoharan return value to be captured and checked
......@@ -2283,12 +2380,34 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
tempWorderExpStkBeanList.clear();
isReallocation = false; // 09-mar-16 manoharan to reset the flag
// 2. adjust potencyAdj proportionately
for(int potencyCtr=0 ; potencyCtr < worderStkBeanList.size(); potencyCtr++)
{
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(potencyCtr);
if(workOrderPotency.trim().equalsIgnoreCase(worderStkBeanObj.getWorkOrder().trim()) && expLevelNew.trim().equalsIgnoreCase(worderStkBeanObj.getExpLevel().trim()))
{
allocatedQty = worderStkBeanObj.getQuantity();
potencyAdjLot = potencyAdjExpLev / adjPotencyExpLevel.getValue() * allocatedQty;
potencyAdjLot = Double.parseDouble(df.format(potencyAdjLot));
quantityReqLot = allocatedQty - potencyAdjLot;
quantityReqLot = Double.parseDouble(df.format(quantityReqLot));
System.out.println("Same wo/expLev(N) before recalculate worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
worderStkBeanObj.setQtyAdj(potencyAdjLot);
worderStkBeanObj.setPotencyAdj(potencyAdjLot);
System.out.println("manohar before .setQuantity 5["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setQuantity(quantityReqLot);
System.out.println("manohar after .setQuantity 5["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setUpdQty(allocatedQty);
worderStkBeanObj.setAllocQty(allocatedQty);
System.out.println("Same wo/expLev(N) after recalculate worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
worderStkBeanList.set(potencyCtr, worderStkBeanObj);
}
//Changed by wasim on 07-04-2015 to call allocation for stock if it plus or minus [END]
}
} //end stock bean
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
}
} //end AdjPotencyExplevQtyMap
} //end potencyAdjMapN contains
......@@ -2318,6 +2437,11 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
// end 09-mar-16 manoharan to update main list with the temporary list
} //end work order list
for(int potencyCtr = 0; potencyCtr < worderStkBeanList.size(); potencyCtr++)
{
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(potencyCtr);
System.out.println("After potency calculation worderStkBeanObj->workOrder["+worderStkBeanObj.getWorkOrder()+"] expLevel ["+worderStkBeanObj.getExpLevel()+"]ItemCode["+worderStkBeanObj.getItemCode()+"]LotNo["+worderStkBeanObj.getLotNo()+"]LotSl["+worderStkBeanObj.getLotSl()+"]LocCode["+worderStkBeanObj.getLocCode()+"]SiteCode["+worderStkBeanObj.getSiteCode()+"]AllocQty["+worderStkBeanObj.getAllocQty()+"]Stock Quantity["+worderStkBeanObj.getStkQuantity()+"]getQuantity["+worderStkBeanObj.getQuantity()+"]PotencyAdj["+worderStkBeanObj.getPotencyAdj()+"] Qty Adj["+worderStkBeanObj.getQtyAdj()+"]UpdQty["+worderStkBeanObj.getUpdQty()+"] Stock Sufficient["+worderStkBeanObj.getStockSufficient()+"]getCritItem["+worderStkBeanObj.getCritItem()+"]MinReqQty["+worderStkBeanObj.getMinQtyReq()+"]StockPotencyPerc["+worderStkBeanObj.getStkPotencyPerc()+"]OtherSiteYN["+worderStkBeanObj.getOtherSiteYN()+"]getAlternate["+worderStkBeanObj.getAlternate()+"] MfgDate["+worderStkBeanObj.getMfgDate()+"]ExpDate["+worderStkBeanObj.getExpDate()+"SiteCodeMfg["+worderStkBeanObj.getSiteCodeMfg()+"]ReserveLineNo["+worderStkBeanObj.getReserveLineNo()+"]ReserveStkTranId["+worderStkBeanObj.getReserveStkTranId()+"]Unit["+worderStkBeanObj.getUnit()+"]");
}
}
catch( Exception e)
......@@ -2362,11 +2486,12 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
locUsageType = "",considerLotNoIss ="",trackShelfLife = "",worder = "",locGrp = "",packLotNo = "",dimension = "",
expLevel = "",itemRef = "",critItem = "",unit = "",errorCode = "",bomCode= "",itemDescr = "";
String itemSitekey = "",stkKey = "",expLev = "",mfgItemCode = "",alternate = "",considerPartialAlt = "";
double stkQuantity = 0,requiredQty = 0,allocQty = 0,balanceQty = 0,remainQty = 0,softAllocQty = 0,
double reserveStkQty = 0,requiredQty = 0,allocQty = 0,balanceQty = 0,remainQty = 0,softAllocQty = 0, stkAvailQuantity = 0,
stkPotencyPerc = 0,minPotencyPerc = 0 ;
double minQtyReq = 0; //Changed by wasim on 29-02-2016
ArrayList<String> altItemCodeList = new ArrayList<String>();
ArrayList<String> invAllocateTranIDList = new ArrayList<String>();
WorderStkBean worderStkBeanObj = null;
try
{
Calendar currentDate = Calendar.getInstance();
......@@ -2379,15 +2504,16 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
System.out.println("mfgItemCode------------>>"+mfgItemCode);
siteCode = worderDetailMap.get("SITE_CODE");
minPotencyPerc = Double.parseDouble(worderDetailMap.get("MIN_POTENCY_PERC"));
sql = "select tran_id from inv_allocate where site_code = ? and item_code = ? "
sql = "select tran_id from inv_allocate where site_code = ? "
+ "and CASE WHEN status IS NULL THEN 'O' ELSE status END <> 'C' and confirmed = ? " //nvl(status,'O') <> 'C'
+ "and work_order = ? "
+ "and (work_order = ? or (length(trim(nvl(?,' '))) = 0 and item_code = ? )) and nvl(tran_type,'MAN') <> 'AUT' "
+ "Order By conf_date";
pstmt = conn.prepareStatement(sql) ;
pstmt.setString(1, siteCode);
pstmt.setString(2, mfgItemCode);
pstmt.setString(3, "Y");
pstmt.setString(2, "Y");
pstmt.setString(3, worder);
pstmt.setString(4, worder);
pstmt.setString(5, mfgItemCode);
rs = pstmt.executeQuery();
while( rs.next() )
......@@ -2485,7 +2611,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
reserveStkSql.append("select inv_alloc_det.line_no,inv_alloc_det.loc_code,inv_alloc_det.lot_no,inv_alloc_det.lot_sl," );
//reserveStkSql.append(" (CASE WHEN inv_alloc_det.quantity IS NULL THEN 0 ELSE inv_alloc_det.quantity END - CASE WHEN inv_alloc_det.dealloc_qty IS NULL THEN 0 ELSE inv_alloc_det.dealloc_qty END )as inv_qty from inv_alloc_det,stock,location,invstat " );
reserveStkSql.append(" (CASE WHEN inv_alloc_det.quantity IS NULL THEN 0 ELSE inv_alloc_det.quantity END - CASE WHEN inv_alloc_det.dealloc_qty IS NULL THEN 0 ELSE inv_alloc_det.dealloc_qty END )as inv_qty, " );
reserveStkSql.append(" stock.potency_perc, inv_alloc_det.exp_lev from inv_alloc_det,stock,location,invstat " );
reserveStkSql.append(" stock.potency_perc, inv_alloc_det.exp_lev,stock.quantity - case when stock.alloc_qty is null then 0 else stock.alloc_qty end as stk_qty from inv_alloc_det,stock,location,invstat " );
reserveStkSql.append( "where inv_alloc_det.tran_id ='" + tranID + "' and inv_alloc_det.item_code ='"+ itemCode + "'" );
reserveStkSql.append(" and (length(rtrim(ltrim(inv_alloc_det.exp_lev))) = 0 or inv_alloc_det.exp_lev is null) " );
......@@ -2506,9 +2632,11 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
reserveStkSql.append(" and ddf_compare_dimension(stock.dimension, '" + dimension + "') = 'Y', " );
}
if(locUsageType.length() > 0)
//if(locUsageType.length() > 0)
if(!"N".equals(locUsageType.trim()))
{
reserveStkSql.append(" and rtrim(location.loc_group) = decode('" + locUsageType + "','A',rtrim('" + locUsageType + "'),rtrim(location.loc_group))" );
//reserveStkSql.append(" and rtrim(location.loc_group) = decode('" + locUsageType + "','A',rtrim('" + locUsageType + "'),rtrim(location.loc_group))" );
reserveStkSql.append("and rtrim(nvl(location.loc_group,'NA')) = decode('" + locUsageType+ "','A',rtrim('" + locGrp + "'), rtrim(nvl(location.loc_group,'NA'))) ");
}
qcReqd = mfgCommon.chkQcReqd(siteCode, itemCode, conn);
System.out.println("mfgCommon.chkQcReqd qcReqd------>>"+qcReqd);
......@@ -2565,11 +2693,12 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
invLocCode = checkNull(rs.getString("loc_code"));
invLotNo = rs.getString("lot_no");
invLotSl = rs.getString("lot_sl");
stkQuantity = rs.getDouble("inv_qty");
reserveStkQty = rs.getDouble("inv_qty");
stkPotencyPerc = rs.getDouble("potency_perc");
stkAvailQuantity = rs.getDouble("stk_qty");
//Changed by wasim on 29-01-2016 to continue if min_req_qty greater than stock qty [START]
if(stkQuantity < minQtyReq)
if(reserveStkQty < minQtyReq)
{
System.out.println("Stock quantity is less than min quantity required so continue loop");
//continue;
......@@ -2582,7 +2711,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
// Now Check the reserved stock potency with Min. Potency required
if(stkPotencyPerc >= minPotencyPerc)
{
WorderStkBean worderStkBeanObj = new WorderStkBean();
worderStkBeanObj = new WorderStkBean();
worderStkBeanObj.setReserveLineNo(reserveLineNo);
worderStkBeanObj.setLocCode(invLocCode);
worderStkBeanObj.setLotNo(invLotNo);
......@@ -2590,7 +2719,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
worderStkBeanObj.setSiteCode(siteCode);
worderStkBeanObj.setItemCode(itemCode);
worderStkBeanObj.setStkQuantity(stkQuantity);
worderStkBeanObj.setStkQuantity(stkAvailQuantity);
worderStkBeanObj.setReserveStkQty(reserveStkQty);
worderStkBeanObj.setItemDescr(itemDescr);
worderStkBeanObj.setStkPotencyPerc(stkPotencyPerc);
......@@ -2606,17 +2736,22 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
worderStkBeanObj.setPotencyAdj(0); //update at the time of calculation of check potency.
worderStkBeanObj.setIsStockDetail("N");
worderStkBeanObj.setAllocQty(0); //update at the time of calculation of check potency.
//20-may-16 manoharan allocation quantity to be set whenever there is a change
// it cannot be set in some other place
//worderStkBeanObj.setAllocQty(0); //update at the time of calculation of check potency.
worderStkBeanObj.setAllocQty(reserveStkQty);
System.out.println("manohar before .setQuantity 6["+worderStkBeanObj.getQuantity()+"]");
worderStkBeanObj.setQuantity(reserveStkQty);
System.out.println("manohar after .setQuantity 6["+worderStkBeanObj.getQuantity()+"]");
stkKey = invLocCode+":"+invLotNo+":"+invLotSl+":"+siteCode+":"+itemCode;
System.out.println("requiredQty------>>["+requiredQty+"]");
System.out.println("stkQuantity------>>["+stkQuantity+"]");
System.out.println("isSufficient------>>["+isSufficient+"]");
//System.out.println("requiredQty------>>["+requiredQty+"]");
//System.out.println("stkQuantity------>>["+stkQuantity+"]");
//System.out.println("isSufficient------>>["+isSufficient+"]");
if(! isSufficient)
{
if(requiredQty <= (stkQuantity + softAllocQty) )
if(requiredQty <= (reserveStkQty + softAllocQty) )
{
balanceQty = 0;
isSufficient = true;
......@@ -2625,7 +2760,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{
System.out.println("else...........");
isSufficient = false;
balanceQty = requiredQty - (stkQuantity + softAllocQty);
balanceQty = requiredQty - (reserveStkQty + softAllocQty);
//softAllocQty = stkQuantity + softAllocQty;
balanceQty = Double.parseDouble(df.format(balanceQty));
System.out.println("balanceQty@@ : ["+balanceQty+"] ");
......@@ -2691,6 +2826,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
}
else
{
......@@ -2701,6 +2838,30 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
returnMapDetails.put("ERROR_CODE", "");
returnMapDetails.put("IS_SUFFICIENT", "false");
}
// 20-may-16 manoharan update dealloc_qty in inv_alloc_det
if (worderStkBeanList.size() > 0)
{
sql = "update inv_alloc_det set dealloc_qty = (case when dealloc_qty is null then 0 else dealloc_qty end) + ?, deallocated = case when quantity = ? then 'Y' else 'N' end where tran_id = ? and line_no = ?";
pstmt = conn.prepareStatement(sql);
for(int potencyCtr = 0; potencyCtr < worderStkBeanList.size(); potencyCtr++)
{
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(potencyCtr);
pstmt.setDouble(1, worderStkBeanObj.getAllocQty());
pstmt.setDouble(2, worderStkBeanObj.getAllocQty());
pstmt.setString(3,worderStkBeanObj.getReserveStkTranId());
pstmt.setInt(4,worderStkBeanObj.getReserveLineNo());
pstmt.addBatch();
pstmt.clearParameters();
}
pstmt.executeBatch();
if(pstmt !=null)
{
pstmt.close();pstmt = null;
}
}
}
......@@ -3787,6 +3948,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
if("Y".equalsIgnoreCase(WorderStkBeanObj.getReserveStk()))
{
//line no set in checkReser..Stk method for unique update.
/* 20-may-16 manoharan commented this has to be done at the time of taking reserve stock
sql = "update inv_alloc_det set dealloc_qty = (case when dealloc_qty is null then 0 else dealloc_qty end) + ? where tran_id = ? and "
//+ "lot_no = ? and lot_sl = ? and site_code = ? and loc_code = ? and item_code = ?";
+ "line_no = ?";
......@@ -3798,17 +3960,12 @@ public String populateWorkOrderBill(Connection conn) throws Exception
pstmt.setString(2,WorderStkBeanObj.getReserveStkTranId());
pstmt.setInt(3,WorderStkBeanObj.getReserveLineNo());
/*pstmt.setString(4,WorderStkBeanObj.getLotSl());
pstmt.setString(5,WorderStkBeanObj.getSiteCode());
pstmt.setString(6,WorderStkBeanObj.getLocCode());
pstmt.setString(7,WorderStkBeanObj.getItemCode());*/
int i = pstmt.executeUpdate();
System.out.println("inv_alloc_det rows updated....................."+i);
if(pstmt !=null)
{
pstmt.close();pstmt = null;
}
} */
}
else
{
......@@ -3968,13 +4125,11 @@ public String populateWorkOrderBill(Connection conn) throws Exception
pstmt.setString(4,WorderStkBeanObj.getItemCode());//discuss with sir (Pending)
pstmt.setString(5,WorderStkBeanObj.getLotNo());
pstmt.setString(6,WorderStkBeanObj.getLotSl());
//pstmt.setDouble(7, WorderStkBeanObj.getAllocQty());//check actual quantity (Pending)
pstmt.setDouble(7, WorderStkBeanObj.getQuantity());
pstmt.setString(8,"Auto Reserve");//remarks
pstmt.setString(9, WorderStkBeanObj.getLocCode());//loc_code
pstmt.setString(10, WorderStkBeanObj.getExpLevel());//EXP_LEV
pstmt.setDouble(11, WorderStkBeanObj.getQtyAdj());
//pstmt.setDouble(12, WorderStkBeanObj.getAllocQty());//ISSUE_QTY check actual quantity (Pending)
pstmt.setDouble(12, WorderStkBeanObj.getAllocQty());//ALLOC_QTY check actual quantity (Pending)
System.out.println("Before Update of inv allocate det");
......@@ -5842,7 +5997,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
reserveStockXMl.append("<lot_no><![CDATA[" ).append( tempObj.getLotNo() ).append( "]]></lot_no>\r\n" );
reserveStockXMl.append("<lot_sl><![CDATA[" ).append( tempObj.getLotSl() ).append( "]]></lot_sl>\r\n" );
reserveStockXMl.append("<stock_potency><![CDATA[" ).append( tempObj.getStkPotencyPerc() ).append( "]]></stock_potency>\r\n" );
reserveStockXMl.append("<quantity><![CDATA[" ).append(Double.parseDouble(df.format( tempObj.getStkQuantity())) ).append( "]]></quantity>\r\n" );
reserveStockXMl.append("<quantity><![CDATA[" ).append(Double.parseDouble(df.format( tempObj.getReserveStkQty())) ).append( "]]></quantity>\r\n" );
reserveStockXMl.append("<remarks><![CDATA[" ).append( "Firm plan process" ).append( "]]></remarks>\r\n" );
reserveStockXMl.append("<reas_code><![CDATA[" ).append( "" ).append( "]]></reas_code>\r\n" );
reserveStockXMl.append("<loc_code><![CDATA[" ).append( tempObj.getLocCode() ).append( "]]></loc_code>\r\n" );
......
......@@ -4,13 +4,14 @@ import java.util.ArrayList;
public class WorderStkBean
{
private double potencyAdj = 0,stkQuantityNew = 0,updQty = 0,qtyAdj = 0;
private double potencyAdj = 0,stkQuantityNew = 0,updQty = 0,qtyAdj = 0,reserveStkQty = 0;
private double allocQty = 0,stkQuantity = 0,stkPotencyPerc = 0,actualAllocQty = 0;
java.sql.Timestamp expDate = null,mfgDate = null;
private String locCode = "",lotNo = "",lotSl = "",siteCode = "",itemCode = "",itemRef = "",alternate = "",itemDescr = "",
workOrder = "",expLevel = "",critItem = "",unit = "",dimension = "",reserveStk = "",reserveStkTranId = "",
siteCodeMfg ="",otherSiteYN = "",stockSufficient = "",isStockDetail = "",alternateItem = "";
private double minQtyReq = 0,quantity = 0;
int reserveLineNo = 0;
......@@ -51,7 +52,13 @@ public class WorderStkBean
public void setOtherSiteYN(String otherSiteYN) {
this.otherSiteYN = otherSiteYN;
}
int reserveLineNo = 0;
public double getReserveStkQty() {
return reserveStkQty;
}
public void setReserveStkQty(double reserveStkQty) {
this.reserveStkQty = reserveStkQty;
}
......
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