Commit acb70c75 authored by manohar's avatar manohar

Changes related to other site, rounding and min required stock


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@101962 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 0991f4a4
......@@ -21,6 +21,7 @@ import java.sql.SQLException;
import org.w3c.dom.Document;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;
import ibase.webitm.ejb.mfg.MfgCommon;
import javax.ejb.Stateless;
......@@ -262,7 +263,7 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
// method for item change
public String itemChanged(Document dom, Document dom1, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException, ITMException
{
String childNodeName = null;
String childNodeName = null,leastExpdtActivRm = "N";
StringBuffer valueXmlString = new StringBuffer();
int ctr = 0;
NodeList parentNodeList = null;
......@@ -284,6 +285,7 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDate);
MfgCommon mfgCommon = new MfgCommon();
//Changed by Poonam Gole for changing connection object :Start
//conn = connDriver.getConnectDB("DriverITM");
......@@ -329,9 +331,16 @@ public class WoFirmplanIC extends ValidatorEJB implements WoFirmplanICLocal, WoF
{
campgnNo = checkNull(genericUtility.getColumnValue("campgn_no", dom));
workOrder = checkNull(genericUtility.getColumnValue("work_order", dom));
leastExpdtActivRm = mfgCommon.getEnvMfg("999999", "LEAST_EXPDT_ACTIVE_R", conn);
if ("NULLFOUND".equals(leastExpdtActivRm))
{
leastExpdtActivRm = "N";
}
System.out.println(" Itemchanged called for [" + currentColumn + "] ==> [" + columnValue + "] campgnNo [" + campgnNo + "] workOrder [" + workOrder + "]");
valueXmlString.append("<campgn_no protect = \"0\">").append("<![CDATA[" + campgnNo + "]]>").append("</campgn_no>");
valueXmlString.append("<work_order protect = \"0\">").append("<![CDATA[" + workOrder + "]]>").append("</work_order>");
valueXmlString.append("<least_expdt_active_rm protect = \"1\">").append("<![CDATA[" + leastExpdtActivRm + "]]>").append("</least_expdt_active_rm>");
/*if ( campgnNo != null && !"null".equals(campgnNo) && campgnNo.trim().length() > 0 )
{
valueXmlString.append("<work_order protect = \"1\">").append("<![CDATA[ ]]>").append("</work_order>");
......
......@@ -150,7 +150,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
Map<String,Double>potencyAdjMapY = null;
Map<String,Double>potencyAdjMapN = null;
Map<String,Double> AdjPotencyExplevQtyMap = null;
String leastExpdtActivRm = "";
public String process() throws RemoteException,ITMException
{
return "";
......@@ -232,7 +232,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
//GenericUtility genericUtility =GenericUtility.getInstance();
E12GenericUtility genericUtility= new E12GenericUtility();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
String sql ="", workOrder = "",campgnNo = "",leastExpdtActivRm = "",errString = "", potencyRetStr="",
String sql ="", workOrder = "",campgnNo = "",errString = "", potencyRetStr="",
errorCodeRet = "";
double balanceQty = 0;
boolean isSufficient = false;
......@@ -262,9 +262,16 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
connDriver = null;
workOrder = checkNull(genericUtility.getColumnValue("work_order",headerDom));
campgnNo = checkNull(genericUtility.getColumnValue("campgn_no",headerDom));
//leastExpdtActivRm = checkNull(genericUtility.getColumnValue("least_expdt_active_rm",headerDom));
MfgCommon mfgCommon = new MfgCommon();
this.leastExpdtActivRm = mfgCommon.getEnvMfg("999999", "LEAST_EXPDT_ACTIVE_R", conn);
if ("NULLFOUND".equals(leastExpdtActivRm))
{
leastExpdtActivRm = "N";
}
//this.leastExpdtActivRm = checkNull(genericUtility.getColumnValue("least_expdt_active_rm",headerDom));
System.out.println("workOrder----->>["+workOrder+"] campgnNo---->>["+campgnNo+"]");
//System.out.println("leastExpdtActivRm----->>["+leastExpdtActivRm+"]");
System.out.println("leastExpdtActivRm----->>["+this.leastExpdtActivRm+"]");
if(workOrder.length() > 0 || campgnNo.length() > 0)
{
......@@ -524,20 +531,20 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
count++;
System.out.println("["+tempWorderObj.getItemCode()+"] item main workorder xml -------------->>"+count + " Exp lev..."+tempWorderObj.getExpLev());
sql = "select iss_criteria,controlled_yn from item where item_code = ? ";
sql = "select iss_criteria from item where item_code = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tempWorderObj.getItemCode());
rs = pstmt.executeQuery();
if(rs.next())
{
issCriteria = checkNull(rs.getString("iss_criteria"));
controlledYn = checkNull(rs.getString("controlled_yn"));
}
rs.close();
rs = null;
pstmt.close();
sql = "select loc_group, lot_no__issue from workorder where work_order = ?";
sql = "select w.loc_group, w.lot_no__issue, i.controlled_yn from workorder w, item i where w.item_code = i.item_code and w.work_order = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tempWorderObj.getWorkOrder());
rs = pstmt.executeQuery();
......@@ -545,6 +552,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{
locGroup = checkNull(rs.getString(1));
lotNoIssue = checkNull(rs.getString(2));
controlledYn = checkNull(rs.getString("controlled_yn"));
}
rs.close();
rs = null;
......@@ -614,14 +622,14 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
System.out.println("CONSIDER_PARTIAL_ALT in checkReserveStock.................");
balanceQty = Double.parseDouble(stockReturnMap.get("BALANCE_QTY"));
errorCodeRet = stockReturnMap.get("ERROR_CODE");
if ("Y".equalsIgnoreCase(tempWorderObj.getCritItem()))
{
//if ("Y".equalsIgnoreCase(tempWorderObj.getCritItem()))
//{
isSufficient = Boolean.parseBoolean(stockReturnMap.get("IS_SUFFICIENT"));
}
else
{
isSufficient = true;
}
//}
//else
//{
// isSufficient = true;
//}
System.out.println("6@@@IS_SUFFICIENT"+isSufficient);
if(balanceQty > 0)
{
......@@ -757,7 +765,9 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
if(!"O".equalsIgnoreCase(detailMap.get("ALLOCATE_TYPE")) && !isSufficient)
{
System.out.println("----------------start alternate item-----------------------------for"+detailMap.get("ITEM_CODE"));
System.out.println("@@checkForAlternateItem before Current site @@ : "+stockReturnMap);
detailMap.put("BALANCE_QTY", String.valueOf(balanceQty) );
System.out.println("@@checkForAlternateItem after Current site @@ : "+detailMap);
System.out.println("worderExpLevSufficient before checkForAlternateItem ["+worderExpLevSufficient+"]");
stockReturnMap = checkForAlternateItem(detailMap, conn);
......@@ -845,7 +855,9 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
System.out.println("Checking for item_code="+detailMap.get("ITEM_CODE")+"in site="+suppSiteCode+"for quantity"+detailMap.get("QUANTITY"));
System.out.println("worderExpLevSufficient before checkCurrentSiteStock ["+worderExpLevSufficient+"]");
System.out.println("@@checkForother before Current site detailMap@@ : "+detailMap);
stockReturnMap = checkCurrentSiteStock(detailMap, conn);//Check for Other site
System.out.println("@@checkForother after Current site stockReturnMap@@ : "+stockReturnMap);
System.out.println("worderExpLevSufficient after checkCurrentSiteStock ["+worderExpLevSufficient+"]");
System.out.println("Current Stock return map : "+stockReturnMap);
......@@ -864,11 +876,11 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{
return stockReturnMap;
}
//if(isSufficient)
//{
// tempWorderObj.setSufficient("Y");//Changed by wasim on 07-03-2016
// break;
//}
if(isSufficient)
{
tempWorderObj.setSufficient("Y");//Changed by wasim on 07-03-2016
break;
}
//Changed by wasim on 07-03-2016 to check alternate item in other site if main item not found [START]
//else
//{
......@@ -883,14 +895,14 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
balanceQty = Double.parseDouble(stockReturnMap.get("BALANCE_QTY"));
errorCodeRet = stockReturnMap.get("ERROR_CODE");
if ("Y".equalsIgnoreCase(tempWorderObj.getCritItem()))
{
//if ("Y".equalsIgnoreCase(tempWorderObj.getCritItem()))
//{
isSufficient = Boolean.parseBoolean(stockReturnMap.get("IS_SUFFICIENT"));
}
else
{
isSufficient = true;
}
//}
//else
//{
// isSufficient = true;
//}
if(errorCodeRet.length() > 0)
{
return stockReturnMap;
......@@ -918,9 +930,16 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
System.out.println("worderExpLevSufficient@@--------------"+isSufficient);
if ( (!"Y".equalsIgnoreCase(tempWorderObj.getCritItem())) || (!"R".equalsIgnoreCase(tempWorderObj.getUsageType()) ))
{
isSufficient = true;
}
worderExpLevSufficient.put(tempWorderObj.getWorkOrder()+":"+tempWorderObj.getExpLev(), isSufficient);
System.out.println("123worderExpLevSufficient@@--------------"+worderExpLevSufficient);
//set is Sufficient
} //end for loop
}
......@@ -1288,9 +1307,14 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
Map<String,String> stockAllocMap = new HashMap<String,String>();
SiteItemSummaryBean siteItemSumBeanObj = null;
WorderStkBean worderStkBeanObj = null;
int count1 = 0;
int stkindex = -1;
double finalAllocatedQty = 0, ItemStdPotency = 100, qtyPerArt = 0,finalAllocQty = 0;;
int count1 = 0, cnt = 0, stkindex = -1;
double finalAllocatedQty = 0, ItemStdPotency = 100, qtyPerArt = 0,finalAllocQty = 0,updQtyOriginal = 0;
Timestamp expDateWorkOrder = null;
String trackShelfLifeFG = "",controlledYnFG = "",queryString = "";
String sqlUpd = "";
PreparedStatement pstmtUpd = null;
ResultSet rsExpDate = null;
try
{
Calendar currentDate = Calendar.getInstance();
......@@ -1316,6 +1340,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
minPotencyPerc = Double.parseDouble(detailMap.get("MIN_POTENCY_PERC"));
matchPotency = detailMap.get("MATCH_POTENCY");
adjPotency = detailMap.get("ADJ_POTENCY");
locGroup = detailMap.get("LOC_GROUP"); // 15-jun-16 manoharan
alternateItem = detailMap.get("IS_ALTERNATE");
System.out.println("IS_ALTERNATE : "+alternateItem);
......@@ -1348,8 +1373,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
if("P".equalsIgnoreCase(detailMap.get("LOC_USAGE_TYPE")) || "A".equalsIgnoreCase(detailMap.get("LOC_USAGE_TYPE")))
{
detailMap.put("LOC_GROUP", locGroup);
locGroup = detailMap.get("LOC_GROUP");
//detailMap.put("LOC_GROUP", locGroup); // 15-jun-16 manoharan commented
//locGroup = detailMap.get("LOC_GROUP"); // 15-jun-16 manoharan commented
if(locGroup.length() == 0)
{
errorCode = "WOGRPLOC";
......@@ -1430,7 +1455,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
if(stkQuantity < minQtyReq)
{
System.out.println("in checkCurrentSiteStock Stock quantity is less than min quantity required so continue loop");
//continue;
continue;
}
//Changed by wasim on 29-01-2016 to continue if min_req_qty greater than stock qty [END]
......@@ -1442,75 +1467,60 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
//Changed by wasim to check expDate of FG and RM for controlled item functionality [START]
/*Date expDateWorkOrder = new Date();
Date stkDate = new Date();
String trackShelfLifeFG = "",controlledYnFG = "";
//////////////////////////////////////////////////////////////////////////////////////////////
expDateWorkOrder = null;
trackShelfLifeFG = "";
controlledYnFG = "";
String queryString = "SELECT TRACK_SHELF_LIFE,CONTROLLED_YN FROM ITEM WHERE ITEM_CODE IN (SELECT ITEM_CODE FROM "
+ "WORKORDER WHERE WORK_ORDER = ?)";
queryString = "SELECT i.TRACK_SHELF_LIFE,i.CONTROLLED_YN,w.EXP_DATE "
+ " FROM ITEM i, WORKORDER w WHERE i.item_code = w.item_code and w.WORK_ORDER = ?";
PreparedStatement pstmtExpDate = conn.prepareStatement(queryString);
pstmtExpDate.setString(1,workOrder);
ResultSet rsExpDate = pstmtExpDate.executeQuery();
rsExpDate = pstmtExpDate.executeQuery();
if(rsExpDate.next())
{
trackShelfLifeFG = checkNull(rsExpDate.getString("TRACK_SHELF_LIFE"));
controlledYnFG = checkNull(rsExpDate.getString("CONTROLLED_YN"));
expDateWorkOrder = rsExpDate.getTimestamp("EXP_DATE");
}
if(pstmtExpDate != null)
{
pstmtExpDate.close();pstmtExpDate = null;
}
if(rsExpDate != null)
{
rsExpDate.close();rsExpDate = null;
}
pstmtExpDate.close();
pstmtExpDate = null;
rsExpDate.close();
rsExpDate = null;
System.out.println("Controlled YN for FG item ["+detailMap.get("ITEM_CODE")+"] is["+controlledYnFG+"] AND itemCategory ["+itemCategory+"]");
System.out.println("Track Shelf Life FG["+trackShelfLife+"] Track Shelf Life RM ["+trackShelfLifeFG+"]");
queryString = "SELECT EXP_DATE FROM WORKORDER WHERE WORK_ORDER = ?";
pstmtExpDate = conn.prepareStatement(queryString);
pstmtExpDate.setString(1,workOrder);
rsExpDate = pstmtExpDate.executeQuery();
if(rsExpDate.next())
System.out.println("Track Shelf Life FG["+trackShelfLife+"] Track Shelf Life RM ["+trackShelfLifeFG+"] RM expiry data [" + expDateT + "] workorder expiry date [" + expDateWorkOrder + "]");
if("Y".equalsIgnoreCase(controlledYnFG) && "A".equalsIgnoreCase(itemCategory) && "Y".equalsIgnoreCase(trackShelfLife) && "Y".equalsIgnoreCase(trackShelfLifeFG) )
{
expDateWorkOrder = rsExpDate.getDate("EXP_DATE");
stkDate=new java.util.Date(expDateT.getTime());
System.out.println("ExpDate Stock="+stkDate);
System.out.println("ExpDate Work Order="+expDateWorkOrder);
if(stkDate.before(expDateWorkOrder) && "Y".equalsIgnoreCase(controlledYnFG) && "A".equalsIgnoreCase(itemCategory) &&
"Y".equalsIgnoreCase(trackShelfLife) && "Y".equalsIgnoreCase(trackShelfLifeFG) )
//&& "Y".equalsIgnoreCase(leastExpdtActivRm))
if(expDateWorkOrder.before(expDateT))
{
System.out.println("Work order exp date is greater than Raw material Date");
String sqlUpd = "UPDATE WORKORDER SET EXP_DATE = ? WHERE WORK_ORDER = ?";
PreparedStatement pstmtUpd = conn.prepareStatement(sqlUpd);
pstmtUpd.setDate(1,(java.sql.Date) stkDate);
pstmtUpd.setString(2,workOrder);
int cnt = pstmtUpd.executeUpdate();
System.out.println("Exp date is updated="+cnt);
if(pstmtExpDate != null){pstmtExpDate.close();pstmtExpDate = null;}
if(rsExpDate != null){rsExpDate.close();rsExpDate = null;}
continue;
System.out.println("Controlled Work order exp date is less than Raw material DateRM expiry data [" + expDateT + "] workorder expiry date [" + expDateWorkOrder + "]");
//continue;
}
else
{
System.out.println("Work order exp date is less than Raw material Date");
System.out.println("Controlled Raw material is less than Work order exp DateRM expiry data [" + expDateT + "] workorder expiry date [" + expDateWorkOrder + "]");
if ( "Y".equalsIgnoreCase(this.leastExpdtActivRm))
{
sqlUpd = "UPDATE WORKORDER SET EXP_DATE = ? WHERE WORK_ORDER = ?";
pstmtUpd = conn.prepareStatement(sqlUpd);
pstmtUpd.setTimestamp(1,expDateT);
pstmtUpd.setString(2,workOrder);
cnt = pstmtUpd.executeUpdate();
System.out.println("Controlled Raw material is less than Work order exp Date [" + cnt + "]");
pstmtUpd.close();
pstmtUpd = null;
}
else
{
System.out.println("Controlled Skiping the RM stock as expiry date is less than workorder expiry date");
continue;
}
}
}
if(pstmtExpDate != null)
{
pstmtExpDate.close();pstmtExpDate = null;
}
if(rsExpDate != null)
{
rsExpDate.close();rsExpDate = null;
}*/
//////////////////////////////////////////////////////////////////////////////////////////////
//Changed by wasim to check expDate of FG and RM for controlled item functionality [END]
unit = checkNull(rs.getString("UNIT"));
......@@ -1758,9 +1768,44 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
updateWoBeanSufficient(worderStkBeanObj.getWorkOrder(), worderStkBeanObj.getExpLevel(), "Y");
}
if(stkindex != -1)
// 06-jun-16 manoharan do round off as per iss_criteria of item
if (!"Y".equals(matchPotency) || (adjPotency == null || adjPotency.trim().length() == 0 ))
{
updQtyOriginal = updQty; // 15-jun-16 manoharan store the original before rounding so that same can beset into the array list
if("F".equalsIgnoreCase(issCriteria))
{
qtyPerArt = getQtyPerArt(stkKey,conn);
if(qtyPerArt > updQty)
{
updQty = qtyPerArt;
}
else
{
System.out.println("allocated quantity will be 2 shippersize");
double noArtQuot = 0,noArtRem = 0,noArt = 0;
noArtQuot= updQty / qtyPerArt ;
noArtRem = updQty % qtyPerArt ;
if(noArtRem > 0)
{
noArtRem = 1;
}
noArtQuot = (int) noArtQuot;
noArt = noArtQuot + noArtRem;
System.out.println("NO Art in current site="+noArt);
updQty = qtyPerArt * noArt;
}
}
else if("W".equalsIgnoreCase(issCriteria))
{
updQty = stkQuantity;
}
}
if(stkindex != -1)
{
System.out.println("manohar before .setQuantity 112["+worderStkBeanObj.getQuantity()+"] .getPotencyAdj[" + worderStkBeanObj.getPotencyAdj() + "] .getAllocQty[" + worderStkBeanObj.getAllocQty() + "] .getUpdQty[" + worderStkBeanObj.getUpdQty() +"]");
worderStkBeanObj.setAllocQty(worderStkBeanObj.getAllocQty() + updQty);
worderStkBeanObj.setQuantity(worderStkBeanObj.getQuantity() + updQty);
......@@ -1777,41 +1822,6 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
}
// 06-jun-16 manoharan do round off as per iss_criteria of item
if (!"Y".equals(matchPotency) && (adjPotency == null || adjPotency.trim().length() == 0 ))
{
if("F".equalsIgnoreCase(issCriteria))
{
qtyPerArt = getQtyPerArt(stkKey,conn);
if(qtyPerArt > updQty)
{
updQty = qtyPerArt;
}
else
{
System.out.println("allocated quantity will be 2 shippersize");
double noArtQuot = 0,noArtRem = 0,noArt = 0;
noArtQuot= updQty / qtyPerArt ;
noArtRem = updQty % qtyPerArt ;
if(noArtRem > 0)
{
noArtRem = 1;
}
noArtQuot = (int) noArtQuot;
noArt = noArtQuot + noArtRem;
System.out.println("NO Art in current site="+noArt);
updQty = qtyPerArt * noArt;
}
}
else if("W".equalsIgnoreCase(issCriteria))
{
updQty = stkQuantity;
}
}
/* 31-may-16 manoharan not the right place
......@@ -2010,24 +2020,26 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
pstmt.close();
pstmt = null;
System.out.println("manohar in checkCurrentSiteStock after allocation balanceQty ["+balanceQty+"] isSufficient[" + isSufficient + "]");
returnMapDetails.put("ERROR_CODE","");
returnMapDetails.put("BALANCE_QTY",String.valueOf(balanceQty));
returnMapDetails.put("BALANCE_QTY",String.valueOf(balanceQty));
if(isSufficient)
{
returnMapDetails.put("ERROR_CODE","");
returnMapDetails.put("BALANCE_QTY",String.valueOf(balanceQty));
returnMapDetails.put("IS_SUFFICIENT","true");
}
else if(!isSufficient && count == 0)
{
returnMapDetails.put("ERROR_CODE","");
returnMapDetails.put("BALANCE_QTY",String.valueOf(requiredQty));
//returnMapDetails.put("ERROR_CODE","");
//returnMapDetails.put("BALANCE_QTY",String.valueOf(requiredQty));
returnMapDetails.put("IS_SUFFICIENT","false");
}
else
{
//stock not sufficient check for alternate item.
//checkForAlternateItem(detailMap, conn);
returnMapDetails.put("ERROR_CODE","");
returnMapDetails.put("BALANCE_QTY",String.valueOf(balanceQty));
//returnMapDetails.put("ERROR_CODE","");
//returnMapDetails.put("BALANCE_QTY",String.valueOf(balanceQty));
returnMapDetails.put("IS_SUFFICIENT","false");
}
System.out.println("manohar in checkCurrentSiteStock after allocation balanceQty ["+balanceQty+"] isSufficient[" + isSufficient + "] returnMapDetails [" + returnMapDetails + "]");
......@@ -2132,8 +2144,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
private String checkStockPotencyNew(Connection conn) throws Exception
{
System.out.println("@@in checkStockPotency..........");
String workOrder = "",expLevel = "",matchPotency = "",adjPotency = "",itemCode = "",unitPotency = "";
String errorCodeRet = "",adjPotencyChkY = "",expLevelNew = "",allocRetStr = "" , adjPotencyChkN = "";
String workOrder = "",expLevel = "",matchPotency = "",adjPotency = "",itemCode = "",unitPotency = "",lotNoIssue = "";
String errorCodeRet = "",adjPotencyChkY = "",expLevelNew = "",allocRetStr = "" , adjPotencyChkN = "",locGroup = "";
//String splitKey [];
//int index = -1; // 09-mar-16 manoharan
double proQty=0, qtyPotencyUnit = 0,ItemStdPotency = 0,potencyAdjNew = 0, potencyAdjExpLev = 0,quantityReqExpLev = 0;
......@@ -2159,11 +2171,29 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
double deallocQty = 0,allocatedQty = 0, extraQty = 0, potencyAdjLot = 0, quantityReqLot = 0;
Map<String,String> stockAllocMap = new HashMap<String,String>();
boolean removeElement = false;
ResultSet rs = null;
PreparedStatement pstmt = null;
String sql ="";
try
{
for(String workOrderPotency : workOrderList)
{
sql = "select loc_group, lot_no__issue from workorder where work_order = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, workOrderPotency);
rs = pstmt.executeQuery();
if(rs.next())
{
locGroup = checkNull(rs.getString(1));
lotNoIssue = checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
potencyAdjMapY = null;
potencyAdjMapN = null;
......@@ -2431,6 +2461,9 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
detailMap.put("BALANCE_QTY",balance+"");
System.out.println("manohar after potency calculation balance 444["+balance+"] fresh allocation to be done" );
detailMap.put("PACK_LOT_NO", lotNoIssue);
detailMap.put("LOC_GROUP", locGroup);
Map<String,String>detailStkMap = checkCurrentSiteStock(detailMap, conn);
System.out.println("detailStkMap C.Potency-------->>["+detailStkMap+"]");
......@@ -2748,6 +2781,9 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
//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
detailMap.put("PACK_LOT_NO", lotNoIssue);
detailMap.put("LOC_GROUP", locGroup);
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"));
......@@ -3291,7 +3327,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
ResultSet rs= null,rs1= null;
PreparedStatement pstmt = null,pstmt1 = null;
String sql = "",altItemCode = "",considerPartialAlt = "",bomCode = "",itemCode = "",itemRef = "",siteCode = "",
workOrder = "",operation = "",errorCodeRet = "";
workOrder = "",operation = "",errorCodeRet = "", locGroup = "",lotNoIssue = "" ;
boolean isSufficient = false;
int count = 0;
double altQuantity = 0,altMinPotencyPerc = 0,balanceQty = 0,propotinateMQty = 0,qtyPerBom = 0,altBalanceQty = 0,
......@@ -3310,6 +3346,18 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
requiredQty = Double.parseDouble(altItemDetailMap.get("QUANTITY"));
balanceQty = Double.parseDouble(altItemDetailMap.get("BALANCE_QTY"));
operation = altItemDetailMap.get("OPERATION");
sql = "select loc_group, lot_no__issue from workorder where work_order = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, workOrder);
rs = pstmt.executeQuery();
if(rs.next())
{
locGroup = checkNull(rs.getString(1));
lotNoIssue = checkNull(rs.getString(2));
}
rs.close();
rs = null;
pstmt.close();
sql = "Select item_code__alt,quantity,case when min_potency_perc in null then 0 else min_potency_perc end as min_potency_perc ,consider_partial_alt "
+ "from bom_alt where bom_code = ? and item_code = ? and item_ref = ? "
......@@ -3363,18 +3411,21 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
altItemDetailMap.put("ITEM_CODE", altItemCode);
altItemDetailMap.put("QUANTITY", String.valueOf(propotinateAltQty));
altItemDetailMap.put("IS_ALTERNATE", "Y");
altItemDetailMap.put("PACK_LOT_NO", lotNoIssue);
altItemDetailMap.put("LOC_GROUP", locGroup);
checkStkReturnMap = checkCurrentSiteStock(altItemDetailMap, conn);
//balanceQty = balanceQty -
System.out.println("checkStkReturnMap A2M : "+checkStkReturnMap);
altBalanceQty = Double.parseDouble(checkStkReturnMap.get("BALANCE_QTY"));
errorCodeRet = checkStkReturnMap.get("ERROR_CODE");
isSufficient = Boolean.parseBoolean(checkStkReturnMap.get("IS_SUFFICIENT"));
// 13-jun-16 manoharan following uncommented as balance to convered back to main unit
propotinateMQty = (balanceQty * qtyPerBom)/altQuantity; //(4 * 10)/15 = 2.667 //Commented by wasim
balanceQty = balanceQty - propotinateMQty; // 4 - 2.667 = 1.333 //Commented by wasim
System.out.println("balanceQty A2M : "+balanceQty); //Commented by wasim
//propotinateMQty = (balanceQty * qtyPerBom)/altQuantity; //(4 * 10)/15 = 2.667 //Commented by wasim
//balanceQty = balanceQty - propotinateMQty; // 4 - 2.667 = 1.333 //Commented by wasim
//System.out.println("balanceQty A2M : "+balanceQty); //Commented by wasim
balanceQty = altBalanceQty;
//balanceQty = altBalanceQty;
System.out.println("balanceQty A2M : "+balanceQty);
......@@ -3416,6 +3467,8 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
checkStkReturnMap.put("ERROR_CODE", "");
checkStkReturnMap.put("IS_SUFFICIENT", ""+isSufficient);
}
System.out.println("after alternate checkStkReturnMap ["+checkStkReturnMap + "]");
}
catch(Exception e)
......@@ -3858,7 +3911,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
String sql = "",detailSum = "",matchPotency = "",suppCodeMfg = "",siteCode = "",itemCode = "",locUsageType = "",locGroup = "",
qcReqd = "",trackShelfLife = "",considerLotIssue = "",packLotNo = "",dimension = "",effDate = "",autoQcReqd ="",
useInvStatus = "",qtyPerStr = "",minQtyPerLotStr = "",trimWidthStr = "",compareDimensionStr = "",locType = "",
tranDate = "",orderType = "";
tranDate = "",orderType = "", otherSite = "N";
boolean isCompareDimension = false;
StringBuffer stockSqlBuf = new StringBuffer();
......@@ -3870,7 +3923,13 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
tranDate = simpleDateFormatObj.format(currentDate.getTime());
System.out.println("In getBuildedWoIssueSql : "+stockDetailMap);
// 13-jun-16 manoharan in case of other site quantity available should be atleast 1 article i.e. availabe should be >= qty_per_art
otherSite = checkNull(stockDetailMap.get("OTHER_SITE"));
if (otherSite == null || otherSite.trim().length() == 0)
{
otherSite = "N";
}
// end 13-jun-16 manoharan in case of other site quantity available should be atleast 1 article i.e. availabe should be >= qty_per_art
siteCode = checkNull(stockDetailMap.get("SITE_CODE"));
itemCode = checkNull(stockDetailMap.get("ITEM_CODE"));
qcReqd = checkNull(stockDetailMap.get("QC_REQD"));
......@@ -3984,8 +4043,12 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
{
stockSqlBuf.append("and nvl(stock.quantity,0) - nvl(stock.alloc_qty,0) >= "+minQtyPerLot);
}
// 13-jun-16 manoharan in case of other site quantity available should be atleast 1 article i.e. availabe should be >= qty_per_art
if("Y".equalsIgnoreCase(otherSite))
{
stockSqlBuf.append("and nvl(stock.quantity,0) - nvl(stock.alloc_qty,0) >= stock.qty_per_art ");
}
// end 13-jun-16 manoharan in case of other site quantity available should be atleast 1 article i.e. availabe should be >= qty_per_art
if(suppCodeMfg.length() > 0 && ! "null".equalsIgnoreCase(suppCodeMfg))
{
stockSqlBuf.append(" and stock.supp_code__mfg in ("+getSqlInString(suppCodeMfg)+") ");
......@@ -4051,7 +4114,7 @@ public class WoFirmplanPrc extends ProcessEJB implements WoFirmplanPrcLocal,WoFi
}
}
System.out.println("Final return build SQL----->>["+stockSqlBuf.toString()+"]");
System.out.println("Final return build SQL["+stockSqlBuf.toString()+"]");
return stockSqlBuf.toString();
}
private String checkNull(String str)
......@@ -4364,7 +4427,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
public String insertInInvAllocate(Connection conn) throws Exception, ITMException
{
ResultSet rs = null;
PreparedStatement pstmt = null,pstmtSel = null;
PreparedStatement pstmt = null,pstmtSel = null, pstmtInsert = null ;
String sql = "",tranIDInvAlloc = "",errorString = "";
int lineNo = 0;
double deAllocQty = 0;
......@@ -4563,29 +4626,31 @@ public String populateWorkOrderBill(Connection conn) throws Exception
{
pstmt.close();pstmt = null;
}
sql = "Insert into inv_alloc_det (TRAN_ID,LINE_NO,SITE_CODE,ITEM_CODE,LOT_NO,LOT_SL,QUANTITY,REMARKS,"
+ "LOC_CODE,EXP_LEV,POTENCY_ADJ,ALLOC_QTY) "
+ "values (?,?,?,?,?, ?,?,?,?,?, ?,? )";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIDWorderMap.get(WorderStkBeanObj.getWorkOrder()));
pstmt.setInt(2, ++lineNo);
pstmt.setString(3,WorderStkBeanObj.getSiteCode());
pstmt.setString(4,WorderStkBeanObj.getItemCode());//discuss with sir (Pending)
pstmt.setString(5,WorderStkBeanObj.getLotNo());
pstmt.setString(6,WorderStkBeanObj.getLotSl());
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());//ALLOC_QTY check actual quantity (Pending)
System.out.println("Before Update of inv allocate det");
pstmt.executeUpdate();
if(pstmt !=null)
if (!"Y".equals(WorderStkBeanObj.getOtherSiteYN()))
{
pstmt.close();pstmt = null;
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranIDWorderMap.get(WorderStkBeanObj.getWorkOrder()));
pstmt.setInt(2, ++lineNo);
pstmt.setString(3,WorderStkBeanObj.getSiteCode());
pstmt.setString(4,WorderStkBeanObj.getItemCode());//discuss with sir (Pending)
pstmt.setString(5,WorderStkBeanObj.getLotNo());
pstmt.setString(6,WorderStkBeanObj.getLotSl());
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());//ALLOC_QTY check actual quantity (Pending)
System.out.println("Before Update of inv allocate det");
pstmt.executeUpdate();
if(pstmt !=null)
{
pstmt.close();pstmt = null;
}
}
// invAlloc trace start
......@@ -4715,7 +4780,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
pstmt.setString(8, WorderStkBeanObj.getLotNo());
pstmt.setString(9, WorderStkBeanObj.getLotSl());
pstmt.setDouble(10,allocQty );
pstmt.setDouble(11,allocQty );
pstmt.setDouble(11,WorderStkBeanObj.getAllocQty() );
pstmt.setDouble(12,WorderStkBeanObj.getQtyAdj() );
pstmt.executeUpdate();
pstmt.close();pstmt = null;
......@@ -4787,6 +4852,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
taxDate = (String)sorderDetailMap.get("TAX_DATE");
plDate = (String)sorderDetailMap.get("PL_DATE");
priceList = (String)sorderDetailMap.get("PRICE_LIST");
priceList = priceList==null?"":priceList.trim();
crTerm = (String)sorderDetailMap.get("CR_TERM");
siteCode = (String)sorderDetailMap.get("SITE_CODE");
confirmed = (String)sorderDetailMap.get("CONFIRMED");
......@@ -5046,7 +5112,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
HashMap DOXml = new HashMap();
String preSiteCode = "";
HashMap siteXMLLineNo = new HashMap();
String tabValue = "", priceListType = "", priceListClg = "",dlvTerm = "",gpSer = "";
try
{
......@@ -5056,16 +5122,27 @@ public String populateWorkOrderBill(Connection conn) throws Exception
HeaderXmlString = new StringBuffer();
orderType = disCommon.getDisparams("999999", "AWMS_DO_ORDER_TYPE", conn);
sql = "select loc_code__git,loc_code__gitbf,avaliable_yn ,auto_receipt from distorder_type where tran_type = ? ";
sql = "select loc_code__git,loc_code__gitbf,avaliable_yn ,auto_receipt, "
+ " LOC_CODE__CONS, LOC_GROUP__CONS, TAX_CLASS, TAX_ENV, PRICE_LIST, PRICE_LIST__CLG, DLV_TERM, GP_SER "
+ " from distorder_type where tran_type = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, orderType);
rs = pstmt.executeQuery();
if(rs.next())
{
locCodeGit = rs.getString("loc_code__git")==null?"":rs.getString("loc_code__git").trim();
locCodeGitbf = rs.getString("loc_code__gitbf")==null?"":rs.getString("loc_code__gitbf").trim();
avaliableYN = rs.getString("AVALIABLE_YN")==null?"N":rs.getString("AVALIABLE_YN").trim();
autoReceipt = rs.getString("AUTO_RECEIPT")==null?"N":rs.getString("AUTO_RECEIPT").trim();
priceList = rs.getString("PRICE_LIST")==null?"":rs.getString("PRICE_LIST").trim();
taxClass = rs.getString("TAX_CLASS")==null?"":rs.getString("TAX_CLASS").trim();
taxEnv = rs.getString("TAX_ENV")==null?"":rs.getString("TAX_ENV").trim();
priceListClg = rs.getString("PRICE_LIST__CLG")==null?"":rs.getString("PRICE_LIST__CLG").trim();
dlvTerm = rs.getString("DLV_TERM")==null?"":rs.getString("DLV_TERM").trim();
gpSer = rs.getString("GP_SER")==null?"":rs.getString("GP_SER").trim();
}
rs.close();
rs = null;
......@@ -5144,8 +5221,22 @@ public String populateWorkOrderBill(Connection conn) throws Exception
HeaderXmlString.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
HeaderXmlString.append("<description>").append("Header0 members").append("</description>");
//price_list from distorder_type where tran_type
priceList = getColumnDescr(conn, "price_list", "distorder_type", "tran_type", orderType);
rate = disCommon.pickRate(priceList, getCurrdateAppFormat(), tempObj.getItemCode(), "", "I",conn); //lotSL not set
//priceList = getColumnDescr(conn, "price_list", "distorder_type", "tran_type", orderType);
priceListType = disCommon.getPriceListType(priceList,conn);
//System.out.println("count :" + count);
if (!"I".equalsIgnoreCase(priceListType))
{
rate = disCommon.pickRate(priceList, getCurrdateAppFormat(), tempObj.getItemCode(), "", priceListType,conn); //lotSL not set
}
else
{
//tabValue = tempObj.getSiteCodeShip() + "~t" + tempObj.getLocCode() + "~t" + tempObj.getLotNo() + "~t" + tempObj.getLotSl() ;
//System.out.println("tabValue :" + tabValue);
// rate can be picked in issue only as stock details are not available during order
rate = 0;//disCommon.pickRate(priceList, getCurrdateAppFormat(), tempObj.getItemCode(), tabValue, "I",conn);
//System.out.println("rate2 :" + rate2);
}
HeaderXmlString.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"dist_order\" objContext=\"1\">");
HeaderXmlString.append("<attribute selected=\"N\" updateFlag=\"A\" status=\"N\" pkNames=\"\"/>");
HeaderXmlString.append("<dist_order/>");
......@@ -5220,7 +5311,8 @@ public String populateWorkOrderBill(Connection conn) throws Exception
HeaderXmlString.append("<tax_amt><![CDATA[0]]></tax_amt>");
HeaderXmlString.append("<net_amt><![CDATA[0]]></net_amt>");
HeaderXmlString.append("<tran_ser><![CDATA[]]></tran_ser>");
HeaderXmlString.append("<price_list__clg><![CDATA[]]></price_list__clg>");
HeaderXmlString.append("<price_list__clg><![CDATA["+ priceListClg + "]]></price_list__clg>");
HeaderXmlString.append("<dlv_term><![CDATA["+ dlvTerm + "]]></dlv_term>");
HeaderXmlString.append("<loc><![CDATA[ ]]></loc>");
HeaderXmlString.append("<sundry_name><![CDATA[]]></sundry_name>");
HeaderXmlString.append("<proj_code><![CDATA[]]></proj_code>");
......@@ -5249,23 +5341,22 @@ public String populateWorkOrderBill(Connection conn) throws Exception
valueXmlString.append("<qty_received><![CDATA["+0+"]]></qty_received>");
valueXmlString.append("<qty_shipped><![CDATA["+0+"]]></qty_shipped>");
valueXmlString.append("<due_date><![CDATA["+getCurrdateAppFormat()+"]]></due_date>");
// valueXmlString.append("<tax_class><![CDATA[").append((distDetailMap.containsKey("tax_class")?tagChkMapForDetail1.get("tax_class"):taxClass)).append("]]></tax_class>");
valueXmlString.append("<tax_class><![CDATA[" + taxClass + "]]></tax_class>");
//valueXmlString.append("<tax_chap><![CDATA[").append((distDetailMap.containsKey("tax_chap")?tagChkMapForDetail1.get("tax_chap"):taxChap)).append("]]></tax_chap>");
//valueXmlString.append("<tax_env><![CDATA[").append((distDetailMap.containsKey("tax_env")?tagChkMapForDetail1.get("tax_env"):taxEnv)).append("]]></tax_env>");
valueXmlString.append("<tax_env><![CDATA[" +taxEnv +"]]></tax_env>");
valueXmlString.append("<unit><![CDATA["+unit+"]]></unit>");
valueXmlString.append("<item_descr><![CDATA["+itemDescr+"]]></item_descr>");
//valueXmlString.append("<sale_order><![CDATA[").append((distDetailMap.containsKey("sale_order")?tagChkMapForDetail1.get("sale_order"):saleOrder)).append("]]></sale_order>");
valueXmlString.append("<line_no__sord/>");
valueXmlString.append("<rate><![CDATA["+rate+"]]></rate>");
valueXmlString.append("<qty_return><![CDATA[0]]></qty_return>");
valueXmlString.append("<rate__clg><![CDATA[0]]></rate__clg>");
valueXmlString.append("<discount><![CDATA[0]]></discount>");
valueXmlString.append("<remarks><![CDATA[]]></remarks>");
valueXmlString.append("<tot_amt><![CDATA[0]]></tot_amt>");
valueXmlString.append("<tax_amt><![CDATA[0]]></tax_amt>");
valueXmlString.append("<net_amt><![CDATA[0]]></net_amt>");
valueXmlString.append("<rate__clg><![CDATA[0]]></rate__clg>");
rate = disCommon.pickRate(priceListClg, getCurrdateAppFormat(), tempObj.getItemCode(), "", "B",conn);
valueXmlString.append("<rate__clg><![CDATA[" + rate + "]]></rate__clg>");
valueXmlString.append("<qty_alloc><![CDATA[0]]></qty_alloc>");
valueXmlString.append("<over_ship_perc><![CDATA[0]]></over_ship_perc>");
//valueXmlString.append("<qty_details><![CDATA[]]></qty_details>");
......@@ -5613,7 +5704,8 @@ public String populateWorkOrderBill(Connection conn) throws Exception
int endIndex = arrayForTranId[1].indexOf("</TranID>");
orderNo = arrayForTranId[1].substring(0,endIndex);
System.out.println("distOrderNo/Sale Order No------>>>["+orderNo+"]");
// 13-jun-16 manoharan sord/dist order reference required
//InsertCrossDockAlloc(siteCodeSave[0],siteCodeSave[1],siteCodeSave[2],conn, orderNo);
//Changed by wasim on 29-02-2016 to commit the transaction as NVO call for confirmation [START]
System.out.println("Connection need to be committed for NVO call for DO/SO");
conn.commit();
......@@ -6438,6 +6530,7 @@ public String populateWorkOrderBill(Connection conn) throws Exception
for(WorderStkBean tempObj : worderStkBeanList)
{
isReserve = false;isStkDetail = false; // 07-jun-16 manoharan initialise for each stock item
stockAllocated = false;
if(workOrder.equalsIgnoreCase(tempObj.getWorkOrder()) && expLev.equalsIgnoreCase(tempObj.getExpLevel()) )
{
stockAllocated = true;
......
......@@ -8,7 +8,7 @@ import java.text.SimpleDateFormat;
public class WorderStkBean
{
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,requiredQty = 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 = "",
......@@ -204,8 +204,14 @@ public class WorderStkBean
public void setStkQuantity(double stkQuantity) {
this.stkQuantity = stkQuantity;
}
/*
public double getRequiredQuantity() {
return requiredQty;
}
public void setRequiredQuantity(double requiredQty) {
this.requiredQty = requiredQty;
}
*/
public String getCritItem() {
return critItem;
}
......
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