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 ...@@ -1150,6 +1150,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
SiteItemSummaryBean siteItemSumBeanObj = null; SiteItemSummaryBean siteItemSumBeanObj = null;
WorderStkBean worderStkBeanObj = null; WorderStkBean worderStkBeanObj = null;
int count1 = 0; int count1 = 0;
int stkindex = -1;
double finalAllocatedQty = 0; double finalAllocatedQty = 0;
try try
{ {
...@@ -1373,11 +1374,18 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1373,11 +1374,18 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
packCode = rs.getString("PACK_CODE"); packCode = rs.getString("PACK_CODE");
System.out.println("stkPotencyPerc------>>["+stkPotencyPerc+"]"); System.out.println("stkPotencyPerc------>>["+stkPotencyPerc+"]");
System.out.println("minPotencyPerc------>>["+minPotencyPerc+"]"); System.out.println("minPotencyPerc------>>["+minPotencyPerc+"]");
stkindex = -1;
if(stkPotencyPerc >= minPotencyPerc) 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); locCode,detailMap.get("SITE_CODE"),lotNo,lotSl);
}
else
{
stkindex = -1;
}
if(stkindex != -1) if(stkindex != -1)
{ {
System.out.println("Adding itemCode in existing worderStkBeanList"+detailMap.get("ITEM_CODE")); System.out.println("Adding itemCode in existing worderStkBeanList"+detailMap.get("ITEM_CODE"));
...@@ -1386,30 +1394,30 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1386,30 +1394,30 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
else else
{ {
worderStkBeanObj = new WorderStkBean(); worderStkBeanObj = new WorderStkBean();
worderStkBeanObj.setItemCode(detailMap.get("ITEM_CODE"));
itemDescr = getColumnDescr(conn, "descr", "item", "item_code", detailMap.get("ITEM_CODE"));
worderStkBeanObj.setItemDescr(itemDescr);
worderStkBeanObj.setLocCode(locCode);
worderStkBeanObj.setLotNo(lotNo);
worderStkBeanObj.setLotSl(lotSl);
worderStkBeanObj.setStkQuantity(stkQuantity);
worderStkBeanObj.setUnit(unit);
worderStkBeanObj.setStkPotencyPerc(stkPotencyPerc);
worderStkBeanObj.setSiteCode(detailMap.get("SITE_CODE"));
worderStkBeanObj.setMfgDate(mfgDateT);
worderStkBeanObj.setExpDate(expDateT);
worderStkBeanObj.setSiteCodeMfg(siteCodeMfg);
worderStkBeanObj.setWorkOrder(detailMap.get("WORK_ORDER"));
worderStkBeanObj.setExpLevel(detailMap.get("EXP_LEV"));
worderStkBeanObj.setItemRef(detailMap.get("ITEM_REF"));
worderStkBeanObj.setCritItem(detailMap.get("CRIT_ITEM"));
worderStkBeanObj.setDimension(dimension);
worderStkBeanObj.setAlternate(alternateItem);
worderStkBeanObj.setReserveStk("N");
worderStkBeanObj.setOtherSiteYN(otherSite);
worderStkBeanObj.setIsStockDetail("Y");
worderStkBeanObj.setMinQtyReq(minQtyReq);
} }
worderStkBeanObj.setItemCode(detailMap.get("ITEM_CODE"));
itemDescr = getColumnDescr(conn, "descr", "item", "item_code", detailMap.get("ITEM_CODE"));
worderStkBeanObj.setItemDescr(itemDescr);
worderStkBeanObj.setLocCode(locCode);
worderStkBeanObj.setLotNo(lotNo);
worderStkBeanObj.setLotSl(lotSl);
worderStkBeanObj.setStkQuantity(stkQuantity);
worderStkBeanObj.setUnit(unit);
worderStkBeanObj.setStkPotencyPerc(stkPotencyPerc);
worderStkBeanObj.setSiteCode(detailMap.get("SITE_CODE"));
worderStkBeanObj.setMfgDate(mfgDateT);
worderStkBeanObj.setExpDate(expDateT);
worderStkBeanObj.setSiteCodeMfg(siteCodeMfg);
worderStkBeanObj.setWorkOrder(detailMap.get("WORK_ORDER"));
worderStkBeanObj.setExpLevel(detailMap.get("EXP_LEV"));
worderStkBeanObj.setItemRef(detailMap.get("ITEM_REF"));
worderStkBeanObj.setCritItem(detailMap.get("CRIT_ITEM"));
worderStkBeanObj.setDimension(dimension);
worderStkBeanObj.setAlternate(alternateItem);
worderStkBeanObj.setReserveStk("N");
worderStkBeanObj.setOtherSiteYN(otherSite);
worderStkBeanObj.setIsStockDetail("Y");
worderStkBeanObj.setMinQtyReq(minQtyReq);
double qtyPerArt = 0,finalAllocQty = 0; double qtyPerArt = 0,finalAllocQty = 0;
qtyPerArt = getQtyPerArt(stkKey,conn); qtyPerArt = getQtyPerArt(stkKey,conn);
...@@ -1587,7 +1595,24 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1587,7 +1595,24 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
finalAllocatedQty = stkQuantity; finalAllocatedQty = stkQuantity;
} }
System.out.println("Adding stk..........."+worderStkBeanObj.getStockSufficient()); 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) if(isReallocation)
{ {
tempWorderExpStkBeanList.add(worderStkBeanObj); tempWorderExpStkBeanList.add(worderStkBeanObj);
...@@ -1604,8 +1629,6 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1604,8 +1629,6 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
else else
{ {
System.out.println("Adding itemCode in worderStkBeanList"+detailMap.get("ITEM_CODE")); System.out.println("Adding itemCode in worderStkBeanList"+detailMap.get("ITEM_CODE"));
worderStkBeanObj.setAllocQty(finalAllocatedQty);
worderStkBeanObj.setQuantity(finalAllocatedQty);
//worderStkBeanObj.setStkQuantity(stkQuantity - finalAllocatedQty); //worderStkBeanObj.setStkQuantity(stkQuantity - finalAllocatedQty);
worderStkBeanList.add(worderStkBeanObj); worderStkBeanList.add(worderStkBeanObj);
} }
...@@ -1750,10 +1773,10 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1750,10 +1773,10 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{ {
System.out.println("@@in checkStockPotency.........."); System.out.println("@@in checkStockPotency..........");
String workOrder = "",expLevel = "",matchPotency = "",adjPotency = "",itemCode = "",unitPotency = ""; String workOrder = "",expLevel = "",matchPotency = "",adjPotency = "",itemCode = "",unitPotency = "";
String errorCodeRet = "",adjPotencyChk = "",expLevelNew = "",allocRetStr = "" ; String errorCodeRet = "",adjPotencyChkY = "",expLevelNew = "",allocRetStr = "" , adjPotencyChkN = "";
//String splitKey []; //String splitKey [];
//int index = -1; // 09-mar-16 manoharan //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, 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; tempStock = 0,matchQty = 0,totalPro = 0,stockAllocAddN = 0,updQty = 0,preExpShortQty = 0,balance = 0,currentLotQty = 0,currntEqualQty = 0;
Map<String,Double>potencyAdjMapY = null; Map<String,Double>potencyAdjMapY = null;
...@@ -1773,6 +1796,9 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1773,6 +1796,9 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
//int count = -1,indexAdjust = -1; //int count = -1,indexAdjust = -1;
int foundIndex = -1; int foundIndex = -1;
boolean isSufficient = false; boolean isSufficient = false;
double deallocQty = 0,allocatedQty = 0, extraQty = 0, potencyAdjLot = 0, quantityReqLot = 0;
boolean removeElement = false;
try try
{ {
...@@ -1845,7 +1871,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1845,7 +1871,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
if(workOrder.equalsIgnoreCase(worderStkBeanObj.getWorkOrder().trim()) && expLevel.equalsIgnoreCase(worderStkBeanObj.getExpLevel().trim())) 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 availableStock = worderStkBeanObj.getStkQuantity();//available
stkPotencyPerc = worderStkBeanObj.getStkPotencyPerc(); stkPotencyPerc = worderStkBeanObj.getStkPotencyPerc();
itemCode = worderStkBeanObj.getItemCode(); itemCode = worderStkBeanObj.getItemCode();
...@@ -1868,17 +1894,20 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1868,17 +1894,20 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
potencyAdj = Double.parseDouble(df.format(potencyAdj));//0.200 potencyAdj = Double.parseDouble(df.format(potencyAdj));//0.200
System.out.println("After calculating potencyAdj NOT SUFFICIENT----->>["+potencyAdj+"]"); 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.setPotencyAdj(Double.parseDouble(df.format(potencyAdj)));
worderStkBeanObj.setQuantity(currntEqualQty); ///////////////////////////////worderStkBeanObj.setQuantity(currntEqualQty);
worderStkBeanObj.setQtyAdj(potencyAdj); worderStkBeanObj.setQtyAdj(Double.parseDouble(df.format(potencyAdj)));
balance = Double.parseDouble(df.format(balance)); balance = Double.parseDouble(df.format(balance));
//worderStkBeanObj.setAllocQty(Double.parseDouble(df.format(balance)));//Changed by wasim on 18-04-2014 //worderStkBeanObj.setAllocQty(Double.parseDouble(df.format(balance)));//Changed by wasim on 18-04-2014
//updQty = worderStkBeanObj.getAllocQty() + potencyAdj; //updQty = worderStkBeanObj.getAllocQty() + potencyAdj;
//worderStkBeanObj.setAllocQty(updQty); //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.setAllocQty(currentLotQty); // 09-mar-16 manoharan added if stock not sufficient full stock of the lot is allocated
worderStkBeanObj.setUpdQty(currentLotQty); worderStkBeanObj.setUpdQty(currentLotQty);
...@@ -1896,16 +1925,19 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1896,16 +1925,19 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
System.out.println("Final Balance="+balance); System.out.println("Final Balance="+balance);
if(balance > 0) if(balance > 0)
{ {
WorderStkBean worderStkBeanObjNext = (WorderStkBean) worderStkBeanList.get(innerCtr+1); System.out.print("Balance > 0 [" + balance + "] worderStkBeanList.size() [" + worderStkBeanList.size() + "] innerCtr [" + innerCtr +"]" );
if (worderStkBeanList.size() > innerCtr +1)
if( {
(worderStkBeanObj.getWorkOrder().equals(worderStkBeanObjNext.getWorkOrder())) && WorderStkBean worderStkBeanObjNext = (WorderStkBean) worderStkBeanList.get(innerCtr+1);
(worderStkBeanObj.getExpLevel().equals(worderStkBeanObjNext.getExpLevel())) if(
) (worderStkBeanObj.getWorkOrder().equals(worderStkBeanObjNext.getWorkOrder())) &&
{ (worderStkBeanObj.getExpLevel().equals(worderStkBeanObjNext.getExpLevel()))
System.out.print("Workorder and explev more stock bean exist in list continue with next for further calculation"); )
continue; {
} System.out.print("Workorder and explev more stock bean exist in list continue with next for further calculation");
continue;
}
}
} }
} }
else // if stock sufficient else // if stock sufficient
...@@ -1918,10 +1950,13 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1918,10 +1950,13 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
worderStkBeanObj.setQtyAdj(Double.parseDouble(df.format(potencyAdj))); worderStkBeanObj.setQtyAdj(Double.parseDouble(df.format(potencyAdj)));
updQty = worderStkBeanObj.getAllocQty() + potencyAdj; //2 + 0.244 = 2.244 updQty = worderStkBeanObj.getAllocQty() + potencyAdj; //2 + 0.244 = 2.244
updQty = Double.parseDouble(df.format(updQty));
//updQty = balance + potencyAdj; //2.2+0.244 = 2.444 //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.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.setUpdQty(updQty);
worderStkBeanObj.setStockSufficient("Y"); worderStkBeanObj.setStockSufficient("Y");
worderStkBeanObj.setQtyAdj(potencyAdj);//wasim on 13-04-2016 worderStkBeanObj.setQtyAdj(potencyAdj);//wasim on 13-04-2016
...@@ -1930,7 +1965,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1930,7 +1965,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
if(potencyAdjMapY.containsKey(adjPotency) ) if(potencyAdjMapY.containsKey(adjPotency) )
{ {
potencyAdjMapY.put(adjPotency, (potencyAdjMapY.get(adjPotency) + potencyAdj ));
potencyAdjMapY.put(adjPotency, Double.parseDouble(df.format((potencyAdjMapY.get(adjPotency) + potencyAdj ))) );
} }
else else
{ {
...@@ -1973,9 +2009,17 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -1973,9 +2009,17 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
detailMap.put("STOCK_DETAIL", "Y"); detailMap.put("STOCK_DETAIL", "Y");
detailMap.put("MIN_QTY_REQ", String.valueOf(worderDetailBeanObj.getMinReqQty())); detailMap.put("MIN_QTY_REQ", String.valueOf(worderDetailBeanObj.getMinReqQty()));
detailMap.put("BALANCE_QTY",potencyAdj+""); detailMap.put("BALANCE_QTY",potencyAdj+"");
// 26-may-16 the following part added
Map<String,String>detailStkMap = checkCurrentSiteStock(detailMap, conn); 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+"]"); System.out.println("detailStkMap C.Potency-------->>["+detailStkMap+"]");
balance = 0; balance = 0;
...@@ -2045,7 +2089,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2045,7 +2089,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
else else
{ {
System.out.println(" N adjPotency----->>["+adjPotency+"] ["+availableStock+"]"); 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) if(adjPotency != null && adjPotency.trim().length() > 0)
{ {
System.out.println("Potency to be adjusted [" + adjPotency + "]"); System.out.println("Potency to be adjusted [" + adjPotency + "]");
...@@ -2066,6 +2110,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2066,6 +2110,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{ {
qtyPotencyUnit = requiredStock; qtyPotencyUnit = requiredStock;
} }
qtyPotencyUnit = Double.parseDouble(df.format(qtyPotencyUnit));
System.out.println("manohar qtyPotencyUnit before[" + qtyPotencyUnit + "] worderStkBeanObj.getAllocQty() [" + worderStkBeanObj.getAllocQty() + "]"); System.out.println("manohar qtyPotencyUnit before[" + qtyPotencyUnit + "] worderStkBeanObj.getAllocQty() [" + worderStkBeanObj.getAllocQty() + "]");
System.out.println("Stk qty After--->>["+worderStkBeanObj.getStkQuantity()+"]"); System.out.println("Stk qty After--->>["+worderStkBeanObj.getStkQuantity()+"]");
System.out.println("Work Order Bean Quantity="+worderDetailBeanObj.getQuantity()); System.out.println("Work Order Bean Quantity="+worderDetailBeanObj.getQuantity());
...@@ -2078,7 +2123,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2078,7 +2123,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
AdjPotencyExplevQtyMap.put(adjPotency+":"+expLevel, qtyPotencyUnit ); AdjPotencyExplevQtyMap.put(adjPotency+":"+expLevel, qtyPotencyUnit );
if(potencyAdjMapN.containsKey(adjPotency)) if(potencyAdjMapN.containsKey(adjPotency))
{ {
potencyAdjMapN.put(adjPotency, (potencyAdjMapN.get(adjPotency) + qtyPotencyUnit ));
potencyAdjMapN.put(adjPotency, Double.parseDouble(df.format((potencyAdjMapN.get(adjPotency) + qtyPotencyUnit ))));
} }
else else
{ {
...@@ -2130,18 +2176,23 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2130,18 +2176,23 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
for(WorderStkBean tempStkObj : worderStkBeanListTemp) for(WorderStkBean tempStkObj : worderStkBeanListTemp)
{ {
// 09-mar-16 manoharan check whether same key exists of so add to existing // 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 = -1;
foundIndex = indexOfWorkorderStkList(tempStkObj.getWorkOrder(), tempStkObj.getExpLevel(),tempStkObj.getItemCode(),tempStkObj.getLocCode(),tempStkObj.getSiteCode(),tempStkObj.getLotNo(),tempStkObj.getLotSl()); 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 if (foundIndex > -1) // already exists add alloc_qty and petencyadj to existing
{ {
System.out.println("manohar before templist merge " );
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(foundIndex); 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.setAllocQty(worderStkBeanObj.getAllocQty() + tempStkObj.getAllocQty());
worderStkBeanObj.setPotencyAdj(worderStkBeanObj.getPotencyAdj() + tempStkObj.getPotencyAdj()); worderStkBeanObj.setPotencyAdj(worderStkBeanObj.getPotencyAdj() + tempStkObj.getPotencyAdj());
worderStkBeanList.set(foundIndex,worderStkBeanObj); worderStkBeanList.set(foundIndex,worderStkBeanObj);
System.out.println("manohar after templist merge getAllocQty [" + worderStkBeanObj.getAllocQty()+ "] potencyadj [" + worderStkBeanObj.getPotencyAdj() + "]" );
} }
else else
{ {
worderStkBeanList.add(tempStkObj);// not exists add worderStkBeanList.add(tempStkObj);// not exists add
} }
} }
...@@ -2149,146 +2200,214 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2149,146 +2200,214 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
} }
System.out.println("potencyAdjMapY---------->>["+potencyAdjMapY+"]"); System.out.println("potencyAdjMapY---------->>["+potencyAdjMapY+"]");
System.out.println("AdjPotencyExplevQtyMap---------->>["+AdjPotencyExplevQtyMap+"]"); System.out.println("AdjPotencyExplevQtyMap-->>["+AdjPotencyExplevQtyMap+"]");
System.out.println("potencyAdjMapN---------->>["+potencyAdjMapN+"]"); 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 //int indexN = -1;// 09-mar-16 manoharan commented for index based
//shortageQty = 0; //shortageQty = 0;
for(Map.Entry<String,Double> entry : potencyAdjMapY.entrySet()) for(Map.Entry<String,Double> entry : potencyAdjMapY.entrySet())
{ {
adjPotencyChk = entry.getKey(); adjPotencyChkY = entry.getKey();
potencyAdjNew = -1 * (entry.getValue()); 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 //AdjPotencyExplevQtyMap
adjPotencyChkN = "";
for(Map.Entry<String,Double> adjPotencyExpLevel : AdjPotencyExplevQtyMap.entrySet()) for(Map.Entry<String,Double> adjPotencyExpLevel : AdjPotencyExplevQtyMap.entrySet())
{ {
String splitKey [] = adjPotencyExpLevel.getKey().split(":"); 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]; expLevelNew = splitKey [1];
System.out.println("expLevelNew---------->>["+expLevelNew+"]"); System.out.println("expLevelNew---------->>["+expLevelNew+"]");
//indexN = -1; // 09-mar-16 manoharan commented for index based
//for(WorderStkBean worderStkBeanObj : worderStkBeanList)
//{
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// System.out.println("potencyAdjNew--------->>["+potencyAdjNew+"]");//-93.733
for(int potencyCtr=0 ; potencyCtr < worderStkBeanList.size(); potencyCtr++) 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)
{ {
worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(potencyCtr); // Extra allocation done to be deallocated
// 1. deallocate the extra quantity then proportionally recalculate potencyAdj and update
//indexN++; // 09-mar-16 manoharan commented for index based extraQty = adjPotencyExpLevel.getValue() - quantityReqExpLev;
System.out.println("workOrderPotency["+workOrderPotency+"] and getWork Order["+worderStkBeanObj.getWorkOrder()+"]"); extraQty = Double.parseDouble(df.format(extraQty));
System.out.println("expLevelNew["+expLevelNew+"] and getWork Order["+worderStkBeanObj.getExpLevel()+"]"); int stockListSize = worderStkBeanList.size() -1;
System.out.println("Deallocate stockListSize [" + stockListSize + "] ExpLev [" + expLevelNew+"] quantity["+ adjPotencyExpLevel.getValue() + "] quantityReqExpLev ["+quantityReqExpLev+"] extraQty [" + extraQty + "]");
if(workOrderPotency.equalsIgnoreCase(worderStkBeanObj.getWorkOrder()) && expLevelNew.equalsIgnoreCase(worderStkBeanObj.getExpLevel())) for(int potencyCtr = stockListSize; potencyCtr > 0 ; potencyCtr--)
{ {
availableStock = worderStkBeanObj.getStkQuantity(); worderStkBeanObj = (WorderStkBean) worderStkBeanList.get(potencyCtr);
/*if(shortageQty <= availableStock ) System.out.println("20-May-16 In deallocate stockListSize ["+stockListSize + "] potencyCtr [" + potencyCtr + "]");
{*/
//-3.425 * 40 / 90 = -1.5221088435 if(workOrderPotency.trim().equalsIgnoreCase(worderStkBeanObj.getWorkOrder().trim()) && expLevelNew.trim().equalsIgnoreCase(worderStkBeanObj.getExpLevel().trim()))
//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)
{ {
Map<String,String> stockAllocMap = new HashMap<String,String>(); if (extraQty <= 0)
stockAllocMap.put("ALLOC_QTY",""+proportionateTotQty); {
stockAllocMap.put("LOC_CODE", worderStkBeanObj.getLocCode()); break;
stockAllocMap.put("ITEM_CODE",worderStkBeanObj.getItemCode()); }
stockAllocMap.put("SITE_CODE",worderStkBeanObj.getSiteCode()); removeElement = false;
stockAllocMap.put("LOT_NO",worderStkBeanObj.getLotNo()); allocatedQty = worderStkBeanObj.getAllocQty();
stockAllocMap.put("LOT_SL",worderStkBeanObj.getLotSl()); 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",""+ (deallocQty * -1));
stockAllocMap.put("LOC_CODE", worderStkBeanObj.getLocCode());
stockAllocMap.put("ITEM_CODE",worderStkBeanObj.getItemCode());
stockAllocMap.put("SITE_CODE",worderStkBeanObj.getSiteCode());
stockAllocMap.put("LOT_NO",worderStkBeanObj.getLotNo());
stockAllocMap.put("LOT_SL",worderStkBeanObj.getLotSl());
// 09-mar-16 manoharan - what will the string returned?????????? // 09-mar-16 manoharan - what will the string returned??????????
allocRetStr = updateStockAllocQty(stockAllocMap,conn); 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()+"]");
}
} }
else }
// 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()))
{ {
System.out.println("Now going for last allocation"); allocatedQty = worderStkBeanObj.getQuantity();
foundIndex = indexOfWorkorderBeanList(worderStkBeanObj.getWorkOrder(),worderStkBeanObj.getExpLevel()); // -13.015 34.988 34.988
worderDetailBeanObj = workOrderBeanList.get(foundIndex); potencyAdjLot = potencyAdjExpLev / adjPotencyExpLevel.getValue() * allocatedQty;
potencyAdjLot = Double.parseDouble(df.format(potencyAdjLot));
HashMap<String,String> detailMap = new HashMap<String,String>(); quantityReqLot = allocatedQty + potencyAdjLot;
detailMap.put("USE_INV_STATUS", worderDetailBeanObj.getUseInvStatus()); quantityReqLot = Double.parseDouble(df.format(quantityReqLot));
detailMap.put("SUPP_CODE_MFG", worderDetailBeanObj.getSuppCodeMfg()); 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()+"]");
detailMap.put("DIMENSION", worderDetailBeanObj.getDimension()); worderStkBeanObj.setQtyAdj(potencyAdjLot);
detailMap.put("MIN_POTENCY_PERC", String.valueOf(worderDetailBeanObj.getMinPotencyPerc()) ); worderStkBeanObj.setPotencyAdj(potencyAdjLot);
//worderStkBeanObj.setQuantity(quantityReqLot);
detailMap.put("EXP_LEV", worderDetailBeanObj.getExpLev()); worderStkBeanObj.setUpdQty(quantityReqLot);
detailMap.put("OPERATION", ""+worderDetailBeanObj.getOperation()); worderStkBeanObj.setAllocQty(quantityReqLot);
detailMap.put("CRIT_ITEM", worderDetailBeanObj.getCritItem()); 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()+"]");
detailMap.put("ITEM_REF", worderDetailBeanObj.getItemRef()); worderStkBeanList.set(potencyCtr, worderStkBeanObj);// 09-mar-16 manoharan added for index based
detailMap.put("BOM_CODE", worderDetailBeanObj.getBomCode()); }
detailMap.put("ITEM_CODE", worderDetailBeanObj.getItemCode()); }
detailMap.put("QUANTITY", String.valueOf(proportionateTotQty)); }
detailMap.put("SITE_CODE", worderStkBeanObj.getSiteCode());//wasim else
detailMap.put("UNIT", worderDetailBeanObj.getUnit()); {
detailMap.put("MATCH_POTENCY", worderDetailBeanObj.getMatchPotency()); // additional stock to be allocated
detailMap.put("ADJ_POTENCY", worderDetailBeanObj.getAdjPotency()); // 1. Allocate additional stock to the extend of potencyAdj
detailMap.put("USAGE_TYPE", worderDetailBeanObj.getUsageType()); foundIndex = indexOfWorkorderBeanList(worderStkBeanObj.getWorkOrder(),worderStkBeanObj.getExpLevel());
detailMap.put("MIN_QTY_REQ", String.valueOf(worderDetailBeanObj.getMinReqQty())); worderDetailBeanObj = workOrderBeanList.get(foundIndex);
detailMap.put("CONSIDER_LOTNO_ISSUE", worderDetailBeanObj.getConsiderLotNoIssue());
detailMap.put("LOC_USAGE_TYPE", worderDetailBeanObj.getLocUsageType()); HashMap<String,String> detailMap = new HashMap<String,String>();
detailMap.put("WORK_ORDER", worderDetailBeanObj.getWorkOrder()); detailMap.put("USE_INV_STATUS", worderDetailBeanObj.getUseInvStatus());
detailMap.put("ITEM_ACTIVE", worderDetailBeanObj.getItemActive()); detailMap.put("SUPP_CODE_MFG", worderDetailBeanObj.getSuppCodeMfg());
detailMap.put("ALLOCATE_TYPE", worderDetailBeanObj.getAllocateType()); detailMap.put("DIMENSION", worderDetailBeanObj.getDimension());
detailMap.put("ITEM_CATEGORY", worderDetailBeanObj.getItemCategory()); detailMap.put("MIN_POTENCY_PERC", String.valueOf(worderDetailBeanObj.getMinPotencyPerc()) );
detailMap.put("IS_ALTERNATE", "N");
if("Y".equalsIgnoreCase(worderStkBeanObj.getOtherSiteYN())) detailMap.put("EXP_LEV", worderDetailBeanObj.getExpLev());
{ detailMap.put("OPERATION", ""+worderDetailBeanObj.getOperation());
detailMap.put("OTHER_SITE", "Y"); detailMap.put("CRIT_ITEM", worderDetailBeanObj.getCritItem());
} detailMap.put("ITEM_REF", worderDetailBeanObj.getItemRef());
else detailMap.put("BOM_CODE", worderDetailBeanObj.getBomCode());
{ detailMap.put("ITEM_CODE", worderDetailBeanObj.getItemCode());
detailMap.put("OTHER_SITE", "N"); detailMap.put("QUANTITY", String.valueOf(potencyAdjExpLev));
} detailMap.put("SITE_CODE", worderStkBeanObj.getSiteCode());//wasim
detailMap.put("STOCK_DETAIL", "Y"); detailMap.put("UNIT", worderDetailBeanObj.getUnit());
detailMap.put("MIN_QTY_REQ", String.valueOf(worderDetailBeanObj.getMinReqQty())); detailMap.put("MATCH_POTENCY", worderDetailBeanObj.getMatchPotency());
detailMap.put("ADJ_POTENCY", worderDetailBeanObj.getAdjPotency());
detailMap.put("USAGE_TYPE", worderDetailBeanObj.getUsageType());
detailMap.put("MIN_QTY_REQ", String.valueOf(worderDetailBeanObj.getMinReqQty()));
detailMap.put("CONSIDER_LOTNO_ISSUE", worderDetailBeanObj.getConsiderLotNoIssue());
detailMap.put("LOC_USAGE_TYPE", worderDetailBeanObj.getLocUsageType());
detailMap.put("WORK_ORDER", worderDetailBeanObj.getWorkOrder());
detailMap.put("ITEM_ACTIVE", worderDetailBeanObj.getItemActive());
detailMap.put("ALLOCATE_TYPE", worderDetailBeanObj.getAllocateType());
detailMap.put("ITEM_CATEGORY", worderDetailBeanObj.getItemCategory());
detailMap.put("IS_ALTERNATE", "N");
if("Y".equalsIgnoreCase(worderStkBeanObj.getOtherSiteYN()))
{
detailMap.put("OTHER_SITE", "Y");
}
else
{
detailMap.put("OTHER_SITE", "N");
}
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 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 //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 Map<String,String>detailStkMap = checkCurrentSiteStock(detailMap,conn); // 09-mar-16 manoharan return value to be captured and checked
balanceQty = Double.parseDouble(detailStkMap.get("BALANCE_QTY")); balanceQty = Double.parseDouble(detailStkMap.get("BALANCE_QTY"));
errorCodeRet = detailStkMap.get("ERROR_CODE"); errorCodeRet = detailStkMap.get("ERROR_CODE");
isSufficient = Boolean.parseBoolean(detailStkMap.get("IS_SUFFICIENT")); isSufficient = Boolean.parseBoolean(detailStkMap.get("IS_SUFFICIENT"));
for(WorderStkBean tempStkObj : tempWorderExpStkBeanList) for(WorderStkBean tempStkObj : tempWorderExpStkBeanList)
{ {
worderStkBeanListTemp.add(tempStkObj); worderStkBeanListTemp.add(tempStkObj);
} }
tempWorderExpStkBeanList.clear(); tempWorderExpStkBeanList.clear();
isReallocation = false; // 09-mar-16 manoharan to reset the flag 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 AdjPotencyExplevQtyMap
} //end potencyAdjMapN contains } //end potencyAdjMapN contains
...@@ -2318,6 +2437,11 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -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 09-mar-16 manoharan to update main list with the temporary list
} //end work order 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) catch( Exception e)
...@@ -2362,11 +2486,12 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2362,11 +2486,12 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
locUsageType = "",considerLotNoIss ="",trackShelfLife = "",worder = "",locGrp = "",packLotNo = "",dimension = "", locUsageType = "",considerLotNoIss ="",trackShelfLife = "",worder = "",locGrp = "",packLotNo = "",dimension = "",
expLevel = "",itemRef = "",critItem = "",unit = "",errorCode = "",bomCode= "",itemDescr = ""; expLevel = "",itemRef = "",critItem = "",unit = "",errorCode = "",bomCode= "",itemDescr = "";
String itemSitekey = "",stkKey = "",expLev = "",mfgItemCode = "",alternate = "",considerPartialAlt = ""; 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 ; stkPotencyPerc = 0,minPotencyPerc = 0 ;
double minQtyReq = 0; //Changed by wasim on 29-02-2016 double minQtyReq = 0; //Changed by wasim on 29-02-2016
ArrayList<String> altItemCodeList = new ArrayList<String>(); ArrayList<String> altItemCodeList = new ArrayList<String>();
ArrayList<String> invAllocateTranIDList = new ArrayList<String>(); ArrayList<String> invAllocateTranIDList = new ArrayList<String>();
WorderStkBean worderStkBeanObj = null;
try try
{ {
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();
...@@ -2379,15 +2504,16 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2379,15 +2504,16 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
System.out.println("mfgItemCode------------>>"+mfgItemCode); System.out.println("mfgItemCode------------>>"+mfgItemCode);
siteCode = worderDetailMap.get("SITE_CODE"); siteCode = worderDetailMap.get("SITE_CODE");
minPotencyPerc = Double.parseDouble(worderDetailMap.get("MIN_POTENCY_PERC")); 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 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"; + "Order By conf_date";
pstmt = conn.prepareStatement(sql) ; pstmt = conn.prepareStatement(sql) ;
pstmt.setString(1, siteCode); pstmt.setString(1, siteCode);
pstmt.setString(2, mfgItemCode); pstmt.setString(2, "Y");
pstmt.setString(3, "Y"); pstmt.setString(3, worder);
pstmt.setString(4, worder); pstmt.setString(4, worder);
pstmt.setString(5, mfgItemCode);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
while( rs.next() ) while( rs.next() )
...@@ -2485,7 +2611,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -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("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 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(" (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( "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) " ); 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 ...@@ -2506,9 +2632,11 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
reserveStkSql.append(" and ddf_compare_dimension(stock.dimension, '" + dimension + "') = 'Y', " ); 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); qcReqd = mfgCommon.chkQcReqd(siteCode, itemCode, conn);
System.out.println("mfgCommon.chkQcReqd qcReqd------>>"+qcReqd); System.out.println("mfgCommon.chkQcReqd qcReqd------>>"+qcReqd);
...@@ -2565,11 +2693,12 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2565,11 +2693,12 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
invLocCode = checkNull(rs.getString("loc_code")); invLocCode = checkNull(rs.getString("loc_code"));
invLotNo = rs.getString("lot_no"); invLotNo = rs.getString("lot_no");
invLotSl = rs.getString("lot_sl"); invLotSl = rs.getString("lot_sl");
stkQuantity = rs.getDouble("inv_qty"); reserveStkQty = rs.getDouble("inv_qty");
stkPotencyPerc = rs.getDouble("potency_perc"); 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] //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"); System.out.println("Stock quantity is less than min quantity required so continue loop");
//continue; //continue;
...@@ -2582,7 +2711,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2582,7 +2711,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
// Now Check the reserved stock potency with Min. Potency required // Now Check the reserved stock potency with Min. Potency required
if(stkPotencyPerc >= minPotencyPerc) if(stkPotencyPerc >= minPotencyPerc)
{ {
WorderStkBean worderStkBeanObj = new WorderStkBean(); worderStkBeanObj = new WorderStkBean();
worderStkBeanObj.setReserveLineNo(reserveLineNo); worderStkBeanObj.setReserveLineNo(reserveLineNo);
worderStkBeanObj.setLocCode(invLocCode); worderStkBeanObj.setLocCode(invLocCode);
worderStkBeanObj.setLotNo(invLotNo); worderStkBeanObj.setLotNo(invLotNo);
...@@ -2590,7 +2719,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2590,7 +2719,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
worderStkBeanObj.setSiteCode(siteCode); worderStkBeanObj.setSiteCode(siteCode);
worderStkBeanObj.setItemCode(itemCode); worderStkBeanObj.setItemCode(itemCode);
worderStkBeanObj.setStkQuantity(stkQuantity); worderStkBeanObj.setStkQuantity(stkAvailQuantity);
worderStkBeanObj.setReserveStkQty(reserveStkQty);
worderStkBeanObj.setItemDescr(itemDescr); worderStkBeanObj.setItemDescr(itemDescr);
worderStkBeanObj.setStkPotencyPerc(stkPotencyPerc); worderStkBeanObj.setStkPotencyPerc(stkPotencyPerc);
...@@ -2606,17 +2736,22 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -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.setPotencyAdj(0); //update at the time of calculation of check potency.
worderStkBeanObj.setIsStockDetail("N"); worderStkBeanObj.setIsStockDetail("N");
//20-may-16 manoharan allocation quantity to be set whenever there is a change
worderStkBeanObj.setAllocQty(0); //update at the time of calculation of check potency. // 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; stkKey = invLocCode+":"+invLotNo+":"+invLotSl+":"+siteCode+":"+itemCode;
System.out.println("requiredQty------>>["+requiredQty+"]"); //System.out.println("requiredQty------>>["+requiredQty+"]");
System.out.println("stkQuantity------>>["+stkQuantity+"]"); //System.out.println("stkQuantity------>>["+stkQuantity+"]");
System.out.println("isSufficient------>>["+isSufficient+"]"); //System.out.println("isSufficient------>>["+isSufficient+"]");
if(! isSufficient) if(! isSufficient)
{ {
if(requiredQty <= (stkQuantity + softAllocQty) ) if(requiredQty <= (reserveStkQty + softAllocQty) )
{ {
balanceQty = 0; balanceQty = 0;
isSufficient = true; isSufficient = true;
...@@ -2625,7 +2760,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2625,7 +2760,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{ {
System.out.println("else..........."); System.out.println("else...........");
isSufficient = false; isSufficient = false;
balanceQty = requiredQty - (stkQuantity + softAllocQty); balanceQty = requiredQty - (reserveStkQty + softAllocQty);
//softAllocQty = stkQuantity + softAllocQty; //softAllocQty = stkQuantity + softAllocQty;
balanceQty = Double.parseDouble(df.format(balanceQty)); balanceQty = Double.parseDouble(df.format(balanceQty));
System.out.println("balanceQty@@ : ["+balanceQty+"] "); System.out.println("balanceQty@@ : ["+balanceQty+"] ");
...@@ -2691,6 +2826,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2691,6 +2826,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
} }
} }
else else
{ {
...@@ -2701,6 +2838,30 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi ...@@ -2701,6 +2838,30 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
returnMapDetails.put("ERROR_CODE", ""); returnMapDetails.put("ERROR_CODE", "");
returnMapDetails.put("IS_SUFFICIENT", "false"); 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 ...@@ -3787,6 +3948,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
if("Y".equalsIgnoreCase(WorderStkBeanObj.getReserveStk())) if("Y".equalsIgnoreCase(WorderStkBeanObj.getReserveStk()))
{ {
//line no set in checkReser..Stk method for unique update. //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 " 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 = ?"; //+ "lot_no = ? and lot_sl = ? and site_code = ? and loc_code = ? and item_code = ?";
+ "line_no = ?"; + "line_no = ?";
...@@ -3798,17 +3960,12 @@ public String populateWorkOrderBill(Connection conn) throws Exception ...@@ -3798,17 +3960,12 @@ public String populateWorkOrderBill(Connection conn) throws Exception
pstmt.setString(2,WorderStkBeanObj.getReserveStkTranId()); pstmt.setString(2,WorderStkBeanObj.getReserveStkTranId());
pstmt.setInt(3,WorderStkBeanObj.getReserveLineNo()); 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(); int i = pstmt.executeUpdate();
System.out.println("inv_alloc_det rows updated....................."+i); System.out.println("inv_alloc_det rows updated....................."+i);
if(pstmt !=null) if(pstmt !=null)
{ {
pstmt.close();pstmt = null; pstmt.close();pstmt = null;
} } */
} }
else else
{ {
...@@ -3968,13 +4125,11 @@ public String populateWorkOrderBill(Connection conn) throws Exception ...@@ -3968,13 +4125,11 @@ public String populateWorkOrderBill(Connection conn) throws Exception
pstmt.setString(4,WorderStkBeanObj.getItemCode());//discuss with sir (Pending) pstmt.setString(4,WorderStkBeanObj.getItemCode());//discuss with sir (Pending)
pstmt.setString(5,WorderStkBeanObj.getLotNo()); pstmt.setString(5,WorderStkBeanObj.getLotNo());
pstmt.setString(6,WorderStkBeanObj.getLotSl()); pstmt.setString(6,WorderStkBeanObj.getLotSl());
//pstmt.setDouble(7, WorderStkBeanObj.getAllocQty());//check actual quantity (Pending)
pstmt.setDouble(7, WorderStkBeanObj.getQuantity()); pstmt.setDouble(7, WorderStkBeanObj.getQuantity());
pstmt.setString(8,"Auto Reserve");//remarks pstmt.setString(8,"Auto Reserve");//remarks
pstmt.setString(9, WorderStkBeanObj.getLocCode());//loc_code pstmt.setString(9, WorderStkBeanObj.getLocCode());//loc_code
pstmt.setString(10, WorderStkBeanObj.getExpLevel());//EXP_LEV pstmt.setString(10, WorderStkBeanObj.getExpLevel());//EXP_LEV
pstmt.setDouble(11, WorderStkBeanObj.getQtyAdj()); 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) pstmt.setDouble(12, WorderStkBeanObj.getAllocQty());//ALLOC_QTY check actual quantity (Pending)
System.out.println("Before Update of inv allocate det"); System.out.println("Before Update of inv allocate det");
...@@ -5842,7 +5997,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception ...@@ -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_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("<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("<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("<remarks><![CDATA[" ).append( "Firm plan process" ).append( "]]></remarks>\r\n" );
reserveStockXMl.append("<reas_code><![CDATA[" ).append( "" ).append( "]]></reas_code>\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" ); reserveStockXMl.append("<loc_code><![CDATA[" ).append( tempObj.getLocCode() ).append( "]]></loc_code>\r\n" );
......
...@@ -4,13 +4,14 @@ import java.util.ArrayList; ...@@ -4,13 +4,14 @@ import java.util.ArrayList;
public class WorderStkBean 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; private double allocQty = 0,stkQuantity = 0,stkPotencyPerc = 0,actualAllocQty = 0;
java.sql.Timestamp expDate = null,mfgDate = null; java.sql.Timestamp expDate = null,mfgDate = null;
private String locCode = "",lotNo = "",lotSl = "",siteCode = "",itemCode = "",itemRef = "",alternate = "",itemDescr = "", private String locCode = "",lotNo = "",lotSl = "",siteCode = "",itemCode = "",itemRef = "",alternate = "",itemDescr = "",
workOrder = "",expLevel = "",critItem = "",unit = "",dimension = "",reserveStk = "",reserveStkTranId = "", workOrder = "",expLevel = "",critItem = "",unit = "",dimension = "",reserveStk = "",reserveStkTranId = "",
siteCodeMfg ="",otherSiteYN = "",stockSufficient = "",isStockDetail = "",alternateItem = ""; siteCodeMfg ="",otherSiteYN = "",stockSufficient = "",isStockDetail = "",alternateItem = "";
private double minQtyReq = 0,quantity = 0; private double minQtyReq = 0,quantity = 0;
int reserveLineNo = 0;
...@@ -51,7 +52,13 @@ public class WorderStkBean ...@@ -51,7 +52,13 @@ public class WorderStkBean
public void setOtherSiteYN(String otherSiteYN) { public void setOtherSiteYN(String otherSiteYN) {
this.otherSiteYN = 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