Commit ed11e308 authored by cpatil's avatar cpatil

modify and created for available to promise


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97288 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 94f13599
......@@ -6,10 +6,11 @@ import java.util.Map;
import java.util.Set;
//import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.ITMException;
//import java.sql.Timestamp;
import java.text.SimpleDateFormat;
class ADPElement
class ADPElement implements Cloneable
{
private String itemCode;
private String siteCode;
......@@ -57,6 +58,7 @@ class ADPElement
private double batchQty = 0;
private double purcRate = 0;
private double qtStk = 0;//Added by chandrashekar 0n 11-08-14
private double ordDemand = 0;
......@@ -98,8 +100,27 @@ class ADPElement
private String bomCodeParent="";
private HashMap bomSet = null;
private ArrayList<String> orderList=new ArrayList<String>();
private double soDemand=0;
private double grossWeight = 0;
private String altitemPerc;
public void setAltitemPerc(String altitemPerc)
{
this.altitemPerc=altitemPerc;
}
public String getAltitemPerc()
{
return this.altitemPerc;
}
public ArrayList<String> getOrderList()
{
return this.orderList;
}
public void setOrderList(ArrayList<String> orderList)
{
this.orderList=orderList;
}
public void setbomSet(HashMap bomCode) //aded by cpatil on 09/06/14
{
......@@ -247,19 +268,65 @@ class ADPElement
public double getQtStk() {
return qtStk;
}
public void setSoDemand(double soDemand) {
this.soDemand = soDemand;
}
public double getSoDemand() {
return soDemand;
}
public void setQtStk(double qtStk) {
this.qtStk = qtStk;
}
//changed method arguments by sabyasachi 29-03-2011
public void setDemand(java.sql.Timestamp dueDate, double demand, String saleOrder, String lineNo)
public void setDemand(java.sql.Timestamp dueDate, double demand, String saleOrder, String itemCode) throws ITMException, Exception
//public void setDemand(java.sql.Timestamp dueDate, double demand)
{
System.out.println("Calling setDemand() for saleOrder["+saleOrder+"]lineNo["+lineNo+"]this.refId["+this.refId+"]");
System.out.println("Calling setDemand() for saleOrder["+saleOrder+"]itemCode["+itemCode+"]this.refId["+this.refId+"]");
this.demand += demand;
//this.saleOrder = saleOrder;//Uncommented by manoj dtd 25/12/2014
//this.lineNo = lineNo;//Uncommented by manoj dtd 25/12/2014
System.out.println("this.refId---"+this.refId);
System.out.println("saleOrder---"+saleOrder);
System.out.println("demand---["+demand+"]");
//Commented by manoj dtd 25/12/2014
String dueDateStr="";
genericUtility = GenericUtility.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
if( dueDate != null)
{
dueDateStr = sdf.format(dueDate);
System.out.println("@@@@@ dueDateStr["+dueDateStr+"]");
}
if(saleOrder!=null && saleOrder.trim().length()>0)
{
if(this.refId==null ||this.refId.trim().length()==0)
this.refId=saleOrder+"@"+itemCode+"@"+demand+"@"+dueDateStr;
else
this.refId+="~"+saleOrder+"@"+itemCode+"@"+demand+"@"+dueDateStr;
}
//updateTimeMrp(dueDate, demand, 0, 0, 0,saleOrder,lineNo);
updateTimeMrp(dueDate, demand, 0, 0, 0);
}
public void setDemand(java.sql.Timestamp dueDate, double demand, String saleOrder, String lineNo,boolean isDetailReq)
//public void setDemand(java.sql.Timestamp dueDate, double demand)
{
System.out.println("Calling setDemand() for saleOrder["+saleOrder+"]lineNo["+lineNo+"]this.refId["+this.refId+"]");
if(isDetailReq)
{
this.demand+= demand;
this.ordDemand=demand;
}
//this.saleOrder = saleOrder;
//this.lineNo = lineNo;
System.out.println("this.refId---"+this.refId);
System.out.println("saleOrder---"+saleOrder);
System.out.println("demand---["+demand+"]");
if(saleOrder!=null && saleOrder.trim().length()>0)
{
if(this.refId==null ||this.refId.trim().length()==0)
......@@ -273,6 +340,8 @@ class ADPElement
//updateTimeMrp(dueDate, demand, 0, 0, 0,saleOrder,lineNo);
updateTimeMrp(dueDate, demand, 0, 0, 0);
}
//changed method arguments by sabyasachi 29-03-2011 end
public double getDemand()
{
......@@ -679,6 +748,16 @@ class ADPElement
}
//added by cpatil on 03/05/14 end
public void setGrossWeight(double grossWeight)
{
this.grossWeight = grossWeight;
}
public double getGrossWeight()
{
return this.grossWeight;
}
//private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply, double stockQty, double othSupply, String saleOrder, String lineNo)
private void updateTimeMrp(java.sql.Timestamp dueDate, double demand, double supply, double stockQty, double othSupply)
{
......@@ -698,6 +777,7 @@ class ADPElement
{
timeMRP = (TimeMRP)timeMRPArr.get(ctr);
//if (timeMRP.getDueDate() != null && timeMRP.getSaleOrder().equals(saleOrder) && timeMRP.getLineNo().equals(lineNo))
System.out.println("772--timeMRP.getDueDate()["+timeMRP.getDueDate()+"]");
if (timeMRP.getDueDate() != null)
{
if (timeMRP.getDueDate().equals(dueDate))
......@@ -715,6 +795,7 @@ class ADPElement
timeMRP.setDueDate(dueDate);
//added by sabyasachi 29.03.2011
//timeMRP.setDemand(demand,saleOrder,lineNo);
System.out.println("@@@@@@@@@@@ timeMRP -1 setdemand["+demand+"]");
timeMRP.setDemand(demand);
//end added by sabyasachi 29.03.2011
timeMRP.setSupply(supply);
......@@ -804,6 +885,10 @@ class ADPElement
errString = e.getMessage();
}
}
@Override
protected Object clone() throws CloneNotSupportedException {
return super.clone();
}
private void updateIndependentDemand(java.sql.Timestamp dueDate, double demand)
{
String errString = "";
......
package ibase.webitm.ejb.mfg;
import java.util.*;
import java.io.File;
import java.sql.*;
import java.sql.Date;
import org.w3c.dom.*;
import java.text.SimpleDateFormat;
import javax.naming.InitialContext;
import javax.servlet.http.HttpSession;
import ibase.system.config.AppConnectParm;
import ibase.system.config.ConnDriver;
import ibase.utility.CommonConstants;
import ibase.webitm.ejb.*;
import ibase.webitm.utility.ITMException;
import ibase.webitm.utility.GenericUtility;
import ibase.webitm.utility.TransIDGenerator;
public class MRPWizardAllocateQtyBean
{
// startt
private ibase.utility.UserInfoBean userInfo = null;
private HttpSession sessionCtx = null;
ITMWizardStatefulRemote itmWizardRemote = null;
private String objName = "";
private String user_lang ="en";
private String user_country = "US";
public String getItemCodeList( String itemCode,String search , String dbID, String siteCode ) throws ITMException
{
String itemCodeData = "";
RequirementICRemote requirementICRemote = null;
try
{
InitialContext ctx = new InitialContext( new AppConnectParm().getProperty() );
requirementICRemote = (ibase.webitm.ejb.mfg.RequirementICRemote)ctx.lookup("ibase/RequirementIC/remote");
itemCodeData = requirementICRemote.getItemCodeList( itemCode ,search,dbID,siteCode);
requirementICRemote = null;
System.out.println("itemCodeData=="+itemCodeData);
String xslFileName = getXSLFileName( "requirement_item_code_set_wiz_" + this.user_lang + "_" + this.user_country + ".xsl" );
//String xslFileName = getXSLFileName( "requirement_item_code_wiz_en_US.xsl" );
itemCodeData = ( new ibase.webitm.utility.GenericUtility() ).transformToString( xslFileName, itemCodeData, CommonConstants.APPLICATION_CONTEXT + File.separator + "temp", "Output", ".html" );
System.out.println("itemCodeData===>"+itemCodeData);
}
catch ( Exception e )
{
throw new ITMException(e);
}
finally
{
if ( requirementICRemote != null )
{
requirementICRemote = null;
}
}
return itemCodeData;
}
private String getXSLFileName( String xslFileName )throws ITMException
{
String retFileName = null;
try
{
String defaultPath = null;
if( CommonConstants.APPLICATION_CONTEXT != null )
{
defaultPath = CommonConstants.APPLICATION_CONTEXT + CommonConstants.ITM_CONTEXT + File.separator;
}
else
{
defaultPath = ".." + File.separator + "webapps" + File.separator + "ibase" + File.separator + CommonConstants.ITM_CONTEXT + File.separator;
}
File xslPath = new File( defaultPath + File.separator + "xsl" + File.separator + CommonConstants.THEME + File.separator + "WIZARD");
if ( !xslPath.exists() )
{
xslPath.mkdir();
}
System.out.println( " xslPath [" + xslPath +"] xslFileName ["+xslFileName +"]");
File xslFile = new File(xslPath , xslFileName);
if( xslFile.exists() )
{
retFileName = xslFile.getAbsolutePath();
}
else
{
throw new ITMException( new Exception( retFileName + " Wizard XSL file Not Found") );
}
}
catch (Exception e)
{
throw new ITMException(e);
}
return retFileName;
}
// end
public String mrpwizardAllocateQty(String xmlString1 , String locGroup , String QuantityReq, String dueDate , String currentSorder, String currentItemCode )throws ITMException
{
Document dom = null;
System.out.println("@@@@@@@@@---------mrpwizardAllocateQty EJB called...");
String returnXml="";
try
{
System.out.println("@@@@@@@xmlString1["+xmlString1+"]@@@@@@@");
System.out.println("@@@@@@ in bean locGroup["+locGroup+"]QuantityReq["+QuantityReq+"]dueDate["+dueDate+"]currentSorder["+currentSorder+"]currentItemCode["+currentItemCode+"]");
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
returnXml = mrpwizardAllocateQty(dom, locGroup, QuantityReq, dueDate , currentSorder, currentItemCode);
}
}
catch(Exception e)
{
System.out.println("Exception :mrpwizardAllocateQty ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
System.out.println("@@@@@@@@@ returnXml["+returnXml+"]");
return returnXml;
}
private String mrpwizardAllocateQty(Document dom , String locGroup , String QuantityReq , String dueDate , String currentSorder, String currentItemCode)throws ITMException
{
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
String sql = "", itemCode = "", effDate = "", itemSer = "", sql1="", sql2="";
int updCnt = 0;
GenericUtility genericUtility = GenericUtility.getInstance();
NodeList hdrDom = null;
//Node currDetail = null;
ResultSet rs1 = null, rs2 = null;
String saleOrder="",lineNo="", siteCode="", lotNo="", locCode="", lotSl="", tranSer="", runningSupplyStr="", qtyReqdStr="",allocQtyStr="";
double runningSupply=0,qtyReqd=0;
String tranId="",refId="",refLineNo="",unit="",errString="";
double quantity=0,qtyAllocated=0,totAllocQty=0,allocQty=0,supply=0,availableSupply=0;
int cnt=0;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String supplyStr="",availableSupplyStr="" ,suppSour="",remarks=" ";
ArrayList retValue = new ArrayList();
java.util.Date currentDate = new java.util.Date();
// SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getDBDateFormat());
// Timestamp newsysDate = java.sql.Timestamp.valueOf( sdf.format(currentDate)+" 00:00:00.0");
// System.out.println("Now the date is :=> ["+newsysDate+"]");
java.sql.Date date = new java.sql.Date(currentDate.getTime());
String parentItem="",prevItemWorder="",previousItem="";
ArrayList itemValueList = new ArrayList();
String selectedItemHtml="";
ArrayList<String> locCodeGrpList= new ArrayList<String>();
TreeMap<String, ArrayList<String>> allocationMap = new TreeMap<String, ArrayList<String>>();
String allocPref="",key="";
try
{
conn = connDriver.getConnectDB("DriverITM");
NodeList hdrDommList = dom.getElementsByTagName("Detail4");
System.out.println("len===["+hdrDommList.getLength()+"]locGroup["+locGroup+"]QuantityReq["+QuantityReq+"]dueDate["+dueDate+"]");
double QuantityRequired = Double.parseDouble(QuantityReq==null?"0":QuantityReq);
sql1=" select distinct loc_code from location where loc_group = ? ";
pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1,locGroup);
rs1 = pstmt1.executeQuery();
while(rs1.next())
{
locCodeGrpList.add(rs1.getString("loc_code"));
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
System.out.println("locCodeGrpList["+locCodeGrpList+"]");
for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++)
{
Node detailListNode = hdrDommList.item(dtlCtr);
NodeList detail4List= detailListNode.getChildNodes();
System.out.println("@@@@@@@@@node name[" + detailListNode.getNodeName()+"]");
if("Detail4".equalsIgnoreCase(detailListNode.getNodeName()))
{
System.out.println("@@@@inside detail4----------------");
for (int cntr = 0; cntr < detail4List.getLength(); cntr++)
{
Node detail4Node = detail4List.item(cntr);
//NodeList detail4NodeList = detail4Node.getChildNodes();
System.out.println("@@@@@@@@@node name[" + detail4Node.getNodeName()+"]");
// if( detail4Node != null && detail4Node.getNodeValue() != null )
{
if("sale_order".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
saleOrder = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
saleOrder= "";
}
}
if("line_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lineNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lineNo= "";
}
}
if("site_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
siteCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
siteCode= "";
}
}
if("item_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
itemCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
itemCode= "";
}
}
if("lot_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lotNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lotNo= "";
}
}
if("lot_sl".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lotSl = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lotSl= "";
}
}
if("loc_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
locCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
locCode= "";
}
}
if("tran_ser".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
tranSer = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
tranSer= "";
}
}
if("running_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
runningSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
runningSupplyStr= "0";
}
}
if("qty_reqd".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
qtyReqdStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
qtyReqdStr= "0";
}
}
if("alloc_qty".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
allocQtyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
allocQtyStr= "0";
}
}
if("supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
supplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
supplyStr= "";
}
}
if("available_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
availableSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
availableSupplyStr= "";
}
}
if("supp_sour".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
suppSour = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
suppSour= "";
}
}
if("parent_item".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
parentItem = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
parentItem= "";
}
}
if("prev_item_worder".equalsIgnoreCase( detail4Node.getNodeName()))
{
if(detail4List.item(cntr).getFirstChild()!=null)
{
prevItemWorder = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
prevItemWorder="";
}
}
if("previous_item".equalsIgnoreCase( detail4Node.getNodeName()))
{
if(detail4List.item(cntr).getFirstChild()!=null)
{
previousItem = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
previousItem = "";
}
}
if("alloc_pref".equalsIgnoreCase( detail4Node.getNodeName()))
{
if(detail4List.item(cntr).getFirstChild()!=null)
{
allocPref = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
allocPref = "";
}
}
}
}
System.out.println("@@@@@@@@itemCode["+itemCode+"]currentItemCode["+currentItemCode+"] ");
if( itemCode.trim().equalsIgnoreCase(currentItemCode.trim()) )
{
saleOrder = saleOrder==null?"":saleOrder.trim();
lineNo = lineNo==null?"":lineNo.trim();
System.out.println("cpatil@@@@ctr["+dtlCtr+"]saleOrder["+saleOrder+"]-lineNo["+lineNo+"]-" +
"qtyReqd["+qtyReqdStr+"]prevItemWorder["+prevItemWorder+"]previousItem["+previousItem+"]@@@");
System.out.println("@@@@ctr["+dtlCtr+"]siteCode["+siteCode+"]-itemCode["+itemCode+"]" +
"-lotNo["+lotNo+"]-lotSl["+lotSl+"]-locCode["+locCode+"]-tranSer["+tranSer+"]" +
"allocQtyStr["+allocQtyStr+"]allocPref["+allocPref+"]" +
"availableSupplyStr["+availableSupplyStr+"]supplyStr["+supplyStr+"]@@@");
String stockInfo="";
if( locCodeGrpList.contains(locCode))
{
key = "A1";
}
else
{
key = "B"+allocPref;
}
//System.out.println("key["+key+"]");
stockInfo = siteCode+"@"+itemCode+"@"+lotNo+"@"+lotSl+"@"+locCode+"@" +
""+tranSer+"@"+runningSupplyStr+"@"+qtyReqdStr+"@"+allocQtyStr+"@"+supplyStr+"@" +
""+suppSour+"@"+parentItem+"@" +prevItemWorder+"@"+previousItem+"@"+dtlCtr;
System.out.println("key["+key+"]stockInfo["+stockInfo+"]");
ArrayList<String> tempAllocationList = new ArrayList<String>();
if(allocationMap.containsKey(key))
{
tempAllocationList = allocationMap.get(key);
tempAllocationList.add(stockInfo);
}
else
{
tempAllocationList.add(stockInfo);
}
allocationMap.put(key, tempAllocationList);
}
}
}
// prepare xml from treemap
ArrayList<String> tempList = new ArrayList<String>();
String dtlCtr="";
double QuantityReqAllocate=0;
System.out.println("@@@@@final---allocationMap["+allocationMap+"]QuantityReqAllocate["+QuantityReqAllocate+"]");
Set s1=allocationMap.entrySet();
Iterator itr=s1.iterator();
while(itr.hasNext())
{
//System.out.println("@@@@@final---keyMap["+keyMap+"]@@@@@@@");
Map.Entry m=(Map.Entry)itr.next();
{
//System.out.println("@@@@@@@@@@@m["+m+"]@@@@@@@@@");
tempList = new ArrayList();
String keyListStr = m.getKey().toString();
System.out.println("@@@@@keyListStr["+keyListStr+"]");
tempList = (ArrayList) allocationMap.get(keyListStr);
for( int i=0; i < tempList.size(); i++)
{
String[] keyStr = tempList.get(i).split("@");
System.out.println("@@@@@ i["+i+"] keyStr["+keyStr+"]");
siteCode = keyStr[0];
itemCode = keyStr[1];
lotNo = keyStr[2];
lotSl = keyStr[3];
locCode = keyStr[4];
tranSer = keyStr[5];
runningSupplyStr = keyStr[6];
qtyReqdStr = keyStr[7];
allocQtyStr = keyStr[8];
availableSupplyStr = keyStr[9];
suppSour = keyStr[10];
parentItem = keyStr[11];
prevItemWorder = keyStr[12];
previousItem = keyStr[13];
dtlCtr = keyStr[14];
if( runningSupplyStr.trim().length() > 0)
{
runningSupply = runningSupplyStr==null?0:Double.parseDouble(runningSupplyStr);
}
if( qtyReqdStr.trim().length() > 0)
{
qtyReqd = qtyReqdStr==null?0:Double.parseDouble(qtyReqdStr);
}
if( allocQtyStr.trim().length() > 0)
{
allocQty = allocQtyStr==null?0:Double.parseDouble(allocQtyStr);
}
if( supplyStr.trim().length() > 0)
{
supply = supplyStr==null?0:Double.parseDouble(supplyStr);
}
if( availableSupplyStr.trim().length() > 0)
{
availableSupply = availableSupplyStr==null?0:Double.parseDouble(availableSupplyStr);
}
System.out.println("@@@@@513::supply["+supply+"]:availableSupply["+availableSupply+"]QuantityRequired["+QuantityRequired+"]");
if( availableSupply > 0 && QuantityRequired > 0 )
{
if( availableSupply >= QuantityRequired )
{
QuantityReqAllocate = QuantityRequired;
QuantityRequired=0;
}
else
{
QuantityReqAllocate = availableSupply;
QuantityRequired= QuantityRequired-QuantityReqAllocate;
}
}
else
{
QuantityReqAllocate = 0;
}
if( saleOrder == null || saleOrder.trim().length() == 0 )
{
saleOrder = currentSorder ;
}
System.out.println("@@@@@531:::QuantityReqAllocate["+QuantityReqAllocate+"]dueDate["+dueDate+"]dtlCtr["+dtlCtr+"]");
//dtlCtr++;
selectedItemHtml = selectedItemHtml + //Detail4.PORF0006..3.11/03/13.item_code
//"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".sale_order' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".sale_order' value='" + saleOrder + "'></INPUT>"+
//"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".line_no' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".line_no' value='" + lineNo + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".item_code' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".item_code' value='" + itemCode + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".qty_reqd' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".qty_reqd' value='" + qtyReqd + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".site_code' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".site_code' value='" + siteCode + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".lot_no' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".lot_no' value='" + lotNo + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".lot_sl' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".lot_sl' value='" + lotSl + "'></INPUT>" +
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".loc_code' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".loc_code' value='" + locCode + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".tran_ser' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".tran_ser' value='" + tranSer + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".tran_id' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".tran_id' value='" + tranId + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".ref_line_no' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".ref_line_no' value='" + refLineNo + "'></INPUT>"+
//"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".supply' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".supply' value='" + ( availableSupply - QuantityReqAllocate ) + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".supply' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".supply' value='" + availableSupply + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".available_supply' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".available_supply' value='" + availableSupply + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".parent_item' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".parent_item' value='" + parentItem + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".prev_item_worder' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".prev_item_worder' value='" + prevItemWorder + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".previous_item' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".previous_item' value='" + previousItem + "'></INPUT>"+
"<INPUT TYPE='hidden' name='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".alloc_qty' id='Detail4." +saleOrder+"."+lineNo+"."+dtlCtr+"."+dueDate+".alloc_qty' value='" + QuantityReqAllocate + "'></INPUT>";
System.out.println("@@@@@@@@ QuantityReqAllocate["+QuantityReqAllocate+"] for itemCode["+itemCode+"]locCode["+locCode+"]lotNo["+lotNo+"]lotSl["+lotSl+"]saleOrder["+saleOrder+"]lineNo["+lineNo+"]");
}
}
}
System.out.println("@@@@@@@@@@@@@@ in jsp selectedItemHtml["+selectedItemHtml+"]");
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in MrpWizPrsSaveBean :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The SQLException occurs in MrpWizPrsSaveBean :"+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (errString == null || errString.trim().length() == 0)
{
System.out.println("@@@@@@commit errString :::"+ errString );
conn.commit();
//return errString;
}
if (pstmt!= null)
{
pstmt = null;
}
if( conn != null )
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println("The SQLException occurs in MrpWizPrsSaveBean :"+e);
e.printStackTrace();
throw new ITMException(e);
}
}
return selectedItemHtml;
}
}
\ No newline at end of file
......@@ -50,6 +50,7 @@ public class MRPWizardXmlDataBean
return xmldata;
}
private String getXmlData(Document dom )throws ITMException
{
PreparedStatement pstmt = null;
......@@ -102,6 +103,1410 @@ public class MRPWizardXmlDataBean
//System.out.println("@@@ initiaalize detail4ListMap...");
String locGroup="",mfgType="",other="",grossWeight="",netReq="",orderType="",currentSorder="",itemDetailsInfo="";
String sodemand="";
int nextDomId = 0;
String altItemPerc="";
try
{
conn = connDriver.getConnectDB("DriverITM");
NodeList hdrDommList = dom.getElementsByTagName("Detail2");
System.out.println("len===["+hdrDommList.getLength()+"]");
nextDomId = hdrDommList.getLength();
System.out.println("@@@@ nextDomId["+nextDomId+"]");
//// for test
for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++)
{
Node detailListNode = hdrDommList.item(dtlCtr);
/*
if("Detail2".equalsIgnoreCase(detailListNode.getNodeName()))
{
detail2Flag = true;
detail2keyList = new ArrayList();
for (int cntr = 0; cntr < refrenceList.getLength(); cntr++)
{
Node refrenceNode = refrenceList.item(cntr);
orderList = refrenceNode.getChildNodes();
//System.out.println("@@@@@@@@@refrenceNode node name[" + refrenceNode.getNodeName()+"]");
if("sale_order".equalsIgnoreCase(refrenceNode.getNodeName()))
{
saleOrder = refrenceList.item(cntr).getFirstChild().getNodeValue();
System.out.println("saleOrder["+saleOrder+"]");
}
*/
if("Detail2".equalsIgnoreCase(detailListNode.getNodeName()))
{
ArrayList detail4OuterList = new ArrayList();
NodeList refrenceList= detailListNode.getChildNodes();
for (int cntr1 = 0; cntr1 < refrenceList.getLength(); cntr1++)
{
Node refrenceNode = refrenceList.item(cntr1);
orderList = refrenceNode.getChildNodes();
System.out.println("@@@@@@@@ detail2 node ::: refrenceNode.getNodeName()["+ refrenceNode.getNodeName()+"]");
if("sale_order".equalsIgnoreCase( refrenceNode.getNodeName()))
{
saleOrder = refrenceNode.getTextContent();
}
if("line_no".equalsIgnoreCase( refrenceNode.getNodeName()))
{
lineNo = refrenceNode.getTextContent();
}
if("item_code".equalsIgnoreCase( refrenceNode.getNodeName()))
{
itemCode = refrenceNode.getTextContent();
}
if("bom_code_org".equalsIgnoreCase( refrenceNode.getNodeName()))
{
bomCodeOrg = refrenceNode.getTextContent();
}
if("bom_code_ref".equalsIgnoreCase( refrenceNode.getNodeName()))
{
bomCodeRef = refrenceNode.getTextContent();
}
String LineNo = "",QtyReqd = "",ItemCodeDescr = "",AvailableSupply = "",OriginalOrAltitem = "";
String QuantityFlag = "",PrevItemWorder = "",PreviousItem = "",NewPlannedSupply = "",DueDate = "",AllocPref = "";
altItemPerc="";
if("Detail4".equalsIgnoreCase(refrenceNode.getNodeName()))
{
System.out.println("@@@@@@ inside Detail4 :::itemCode["+itemCode+"]");
//orderList1 = refrenceNode.getChildNodes();
for (int nodCtr1 = 0; nodCtr1 < orderList.getLength(); nodCtr1++)
{
Node detail4Node2=orderList.item(nodCtr1);
//System.out.println("node in detail4 ["+detail4Node2.getNodeName()+"]");
{
if( detail4Node2.getFirstChild() != null)
{
if("site_code".equalsIgnoreCase(detail4Node2.getNodeName()))
{
siteCodeSupp = detail4Node2.getFirstChild().getNodeValue();
}
if("item_code".equalsIgnoreCase(detail4Node2.getNodeName()))
{
itemCodeSupp = detail4Node2.getFirstChild().getNodeValue();
}
if("item_code_descr".equalsIgnoreCase(detail4Node2.getNodeName()))
{
itemCodeDescr = detail4Node2.getFirstChild().getNodeValue();
}
if("lot_no".equalsIgnoreCase(detail4Node2.getNodeName()))
{
lotNo = detail4Node2.getFirstChild().getNodeValue();
}
if("lot_sl".equalsIgnoreCase(detail4Node2.getNodeName()))
{
lotSl = detail4Node2.getFirstChild().getNodeValue();
}
if("loc_code".equalsIgnoreCase(detail4Node2.getNodeName()))
{
locCode = detail4Node2.getFirstChild().getNodeValue();
}
if("tran_ser".equalsIgnoreCase(detail4Node2.getNodeName()))
{
tranSer = detail4Node2.getFirstChild().getNodeValue();
}
if("tran_id".equalsIgnoreCase(detail4Node2.getNodeName()))
{
tranId = detail4Node2.getFirstChild().getNodeValue();
}
if("supply".equalsIgnoreCase(detail4Node2.getNodeName()))
{
supply = detail4Node2.getFirstChild().getNodeValue();
}
if("alloc_qty".equalsIgnoreCase(detail4Node2.getNodeName()))
{
allocQty = detail4Node2.getFirstChild().getNodeValue();
}
if("unit".equalsIgnoreCase(detail4Node2.getNodeName()))
{
unit = detail4Node2.getFirstChild().getNodeValue();
}
if("ref_line_no".equalsIgnoreCase(detail4Node2.getNodeName()))
{
refLineNo = detail4Node2.getFirstChild().getNodeValue();
}
if("planned_quantity".equalsIgnoreCase(detail4Node2.getNodeName()))
{
plannedQuantity = detail4Node2.getFirstChild().getNodeValue();
}
if("parent_item".equalsIgnoreCase(detail4Node2.getNodeName()))
{
parentItem = detail4Node2.getFirstChild().getNodeValue();
}
if("source_supply".equalsIgnoreCase(detail4Node2.getNodeName()))
{
sourceSupply = detail4Node2.getFirstChild().getNodeValue();
}
if("item_code_parent".equalsIgnoreCase(detail4Node2.getNodeName()))
{
itemCodeParent = detail4Node2.getFirstChild().getNodeValue();
}
if("sale_order".equalsIgnoreCase(detail4Node2.getNodeName()))
{
saleOrder = detail4Node2.getFirstChild().getNodeValue();
}
if("line_no".equalsIgnoreCase(detail4Node2.getNodeName()))
{
LineNo = detail4Node2.getFirstChild().getNodeValue();
}
if("qty_reqd".equalsIgnoreCase(detail4Node2.getNodeName()))
{
QtyReqd = detail4Node2.getFirstChild().getNodeValue();
}
if("item_code_descr".equalsIgnoreCase(detail4Node2.getNodeName()))
{
ItemCodeDescr = detail4Node2.getFirstChild().getNodeValue();
}
if("available_supply".equalsIgnoreCase(detail4Node2.getNodeName()))
{
AvailableSupply = detail4Node2.getFirstChild().getNodeValue();
}
if("originalOrAltitem".equalsIgnoreCase(detail4Node2.getNodeName()))
{
OriginalOrAltitem = detail4Node2.getFirstChild().getNodeValue();
}
if("quantityFlag".equalsIgnoreCase(detail4Node2.getNodeName()))
{
QuantityFlag = detail4Node2.getFirstChild().getNodeValue();
}
if("prev_item_worder".equalsIgnoreCase(detail4Node2.getNodeName()))
{
PrevItemWorder = detail4Node2.getFirstChild().getNodeValue();
}
if("previous_item".equalsIgnoreCase(detail4Node2.getNodeName()))
{
PreviousItem = detail4Node2.getFirstChild().getNodeValue();
}
if("new_planned_supply".equalsIgnoreCase(detail4Node2.getNodeName()))
{
NewPlannedSupply = detail4Node2.getFirstChild().getNodeValue();
}
if("due_date".equalsIgnoreCase(detail4Node2.getNodeName()))
{
DueDate = detail4Node2.getFirstChild().getNodeValue();
}
if("alloc_pref".equalsIgnoreCase(detail4Node2.getNodeName()))
{
AllocPref = detail4Node2.getFirstChild().getNodeValue();
}
if("alt_item_perc".equalsIgnoreCase(detail4Node2.getNodeName()))
{
altItemPerc = detail4Node2.getFirstChild().getNodeValue();
}
}
}
}
System.out.println("@@@@ for list ctr["+dtlCtr+"]itemCodeSupp["+itemCodeSupp+"]sourceSupply["+sourceSupply+"]siteCodeSupp["+siteCodeSupp+"]-itemCodeSupp["+itemCodeSupp+"]-lotNo["+lotNo+"]-lotSl["+lotSl+"]-locCode["+locCode+"]-tranSer["+tranSer+"]originalOrAltitem["+originalOrAltitem+"]@@@");
//detail4List.clear();
ArrayList detail4List = new ArrayList();
detail4List.add(siteCodeSupp);
detail4List.add(itemCodeSupp );
detail4List.add(itemCodeDescr );
detail4List.add(lotNo );
detail4List.add(lotSl );
detail4List.add(locCode );
detail4List.add(tranSer );
detail4List.add(tranId );
detail4List.add(supply );
detail4List.add(allocQty );
detail4List.add(unit );
detail4List.add(refLineNo);
detail4List.add(plannedQuantity);
detail4List.add(parentItem );
detail4List.add(sourceSupply );
detail4List.add(itemCodeParent );
detail4List.add(saleOrder);
detail4List.add(LineNo);
detail4List.add(QtyReqd );
detail4List.add(ItemCodeDescr );
detail4List.add(AvailableSupply );
detail4List.add(OriginalOrAltitem );
detail4List.add(QuantityFlag );
detail4List.add(PrevItemWorder );
detail4List.add(PreviousItem );
detail4List.add(NewPlannedSupply );
detail4List.add(DueDate );
detail4List.add(AllocPref);
detail4List.add(altItemPerc);
System.out.println("detail4List["+detail4List+"]");
detail4OuterList.add(detail4List);
//System.out.println("detail4List added");
}
}
System.out.println("for delete compare ::: bomCodeOrg["+bomCodeOrg+"]bomCodeRef["+bomCodeRef+"]");
if( bomCodeOrg != null && bomCodeRef != null && bomCodeOrg.trim().length() > 0 && bomCodeRef.trim().length() > 0 )
{
if( !(bomCodeOrg.equalsIgnoreCase(bomCodeRef)))
{
System.out.println("@@@@@@@@ bomCodeOrg ["+bomCodeOrg+"] added in deleteBomList ");
if(! (deleteBomList.contains(bomCodeOrg) ))
{
deleteBomList.add(bomCodeOrg);
}
if( !(deleteSaleOrderList.contains(saleOrder+"@"+lineNo)))
{
deleteSaleOrderList.add(saleOrder+"@"+lineNo);
}
// String returnBom = runMRPObj.bomExplode(siteCode, bomCodeRef);
}
}
System.out.println("detail4OuterList["+detail4OuterList+"]");
if( detail4OuterList != null && detail4OuterList.size() > 0 )
{
//System.out.println("before addedd.."+saleOrder+lineNo+itemCode+".detail4ListMap["+detail4ListMap+"]");
detail4ListMap.put(saleOrder+lineNo+itemCode, detail4OuterList);
System.out.println("after addedd.."+saleOrder+lineNo+itemCode+".detail4ListMap["+detail4ListMap+"]");
// detail4OuterList.clear();
}
}
}
// end
System.out.println("@@@@@@@@ deleteBomList["+deleteBomList+"]deleteSaleOrderList["+deleteSaleOrderList+"]detail4ListMap["+detail4ListMap+"]");
//// start new test
StringBuffer valueXmlString = new StringBuffer();
valueXmlString = new StringBuffer("<?xml version = \"1.0\"?><Root>\r\n");
for (int dtlCtr = 0; dtlCtr < hdrDommList.getLength(); dtlCtr++)
{
Node detailListNode = hdrDommList.item(dtlCtr);
NodeList refrenceList= detailListNode.getChildNodes();
if("Detail2".equalsIgnoreCase(detailListNode.getNodeName()))
{
for (int cntr1 = 0; cntr1 < refrenceList.getLength(); cntr1++)
{
Node refrenceNode = refrenceList.item(cntr1);
orderList = refrenceNode.getChildNodes();
System.out.println("344@@@@@@@@ refrenceNode.getNodeName()[ "+ refrenceNode.getNodeName()+"]");
if("supp_sour".equalsIgnoreCase( refrenceNode.getNodeName()))
{
suppSour = refrenceNode.getTextContent();
}
if("sale_order".equalsIgnoreCase( refrenceNode.getNodeName()))
{
saleOrder = refrenceNode.getTextContent();
System.out.println("352@@@@@@@@ saleOrder["+saleOrder+"]");
}
if("line_no".equalsIgnoreCase( refrenceNode.getNodeName()))
{
lineNo = refrenceNode.getTextContent();
}
if("site_code".equalsIgnoreCase( refrenceNode.getNodeName()))
{
siteCode = refrenceNode.getTextContent();
}
if("bom_code_parent".equalsIgnoreCase( refrenceNode.getNodeName()))
{
bomCodeParent = refrenceNode.getTextContent();
}
if("bom_code_org".equalsIgnoreCase( refrenceNode.getNodeName()))
{
bomCodeOrg = refrenceNode.getTextContent();
}
if("bom_code_ref".equalsIgnoreCase( refrenceNode.getNodeName()))
{
bomCodeRef = refrenceNode.getTextContent();
}
if("item_code".equalsIgnoreCase( refrenceNode.getNodeName()))
{
itemCode = refrenceNode.getTextContent();
}
if("item_code_descr".equalsIgnoreCase( refrenceNode.getNodeName()))
{
itemCodeDescr = refrenceNode.getTextContent();
}
if("qty_reqd".equalsIgnoreCase( refrenceNode.getNodeName()))
{
qtyReqdStr = refrenceNode.getTextContent();
}
if("unit".equalsIgnoreCase( refrenceNode.getNodeName()))
{
unit = refrenceNode.getTextContent();
}
if("source_supply".equalsIgnoreCase( refrenceNode.getNodeName()))
{
sourceSupply = refrenceNode.getTextContent();
}
if("source_supply_ref".equalsIgnoreCase( refrenceNode.getNodeName()))
{
sourceSupplyRef = refrenceNode.getTextContent();
}
if("itemCodeDetailMap".equalsIgnoreCase( refrenceNode.getNodeName()))
{
itemCodeDetailMapStr = refrenceNode.getTextContent();
System.out.println("@@@@@@ itemCodeDetailMapStr["+itemCodeDetailMapStr+"]");
}
// 230115
//new tag
if("mfg_type".equalsIgnoreCase( refrenceNode.getNodeName()))
{
mfgType = refrenceNode.getTextContent();
}
if("demand".equalsIgnoreCase( refrenceNode.getNodeName()))
{
demand = refrenceNode.getTextContent();
}
if("other".equalsIgnoreCase( refrenceNode.getNodeName()))
{
other = refrenceNode.getTextContent();
}
if("gross_weight".equalsIgnoreCase( refrenceNode.getNodeName()))
{
grossWeight = refrenceNode.getTextContent();
}
if("supply".equalsIgnoreCase( refrenceNode.getNodeName()))
{
supply = refrenceNode.getTextContent();
}
if("net_req".equalsIgnoreCase( refrenceNode.getNodeName()))
{
netReq = refrenceNode.getTextContent();
}
if("order_type".equalsIgnoreCase( refrenceNode.getNodeName()))
{
orderType = refrenceNode.getTextContent();
}
if("current_sorder".equalsIgnoreCase( refrenceNode.getNodeName()))
{
currentSorder = refrenceNode.getTextContent();
}
if("item_code_descr".equalsIgnoreCase( refrenceNode.getNodeName()))
{
itemCodeDescr = refrenceNode.getTextContent();
}
if("due_date".equalsIgnoreCase( refrenceNode.getNodeName()))
{
dueDate = refrenceNode.getTextContent();
}
if("loc_group".equalsIgnoreCase( refrenceNode.getNodeName()))
{
locGroup = refrenceNode.getTextContent();
}
if("itemDetailsInfo".equalsIgnoreCase( refrenceNode.getNodeName()))
{
itemDetailsInfo = refrenceNode.getTextContent();
}
// end new tag
//230115
}
// }
System.out.println("@@@@ saleOrder["+saleOrder+"]-lineNo["+lineNo+"]-qtyReqd["+qtyReqdStr+"]sourceSupply["+sourceSupply+"]@@@");
System.out.println("@@@@ siteCode["+siteCode+"]-itemCode["+itemCode+"]-bomCodeOrg["+bomCodeOrg+"]-bomCodeRef["+bomCodeRef+"]bomCodeParent["+bomCodeParent+"]");
System.out.println("@@@@@ itemCodeDetailMap in bean itemCodeDetailMapStr["+itemCodeDetailMapStr+"]bomCodeRef["+bomCodeRef+"]");
System.out.println("@@@@@ itemCodeDetailMap in bean deleteBomList["+deleteBomList+"]deleteSaleOrderList["+deleteSaleOrderList+"]");
if( itemCodeDetailMapStr != null && ( ! bomCodeOrg.equalsIgnoreCase(bomCodeRef)) )
{
itemCodeDetailMapStr = bomCodeParent;
}
System.out.println("@@@@@ itemCodeDetailMap in bean itemCode["+itemCode+"]bomCodeParent["+bomCodeParent+"]deleteBomList["+deleteBomList+"]deleteSaleOrderList["+deleteSaleOrderList+"]saleOrder@lineNo["+saleOrder+"@"+lineNo+"]bomCodeRef["+bomCodeRef+"]bomCodeOrg["+bomCodeOrg+"]");
if( !( ( deleteBomList.contains(bomCodeParent.trim()) ) && deleteSaleOrderList.contains(saleOrder+"@"+lineNo)) )
{ // ||
System.out.println("@@@@@ itemCodeDetailMapitemCode["+itemCode+"]deleteBomList["+deleteBomList+"]bomCodeOrg["+bomCodeOrg+"]");
//if( !(deleteBomList.contains(bomCodeOrg)) )
//{
System.out.println("14/06/14 supreme 1 inside itemCode ["+itemCode+"]bomCodeRef["+bomCodeRef+"] suppSour [" + suppSour+"]itemCodeDetailMapStr["+itemCodeDetailMapStr+"]bomCodeParent["+bomCodeParent+"]bomCodeOrg["+bomCodeOrg+"]");
ArrayList tempdetail4OuterList = new ArrayList();
ArrayList tempdetail4List = new ArrayList();
//System.out.println("@@@@ inside first if....");
if( ( (bomCodeRef != null && bomCodeRef.trim().length() > 0 ) )
&& ( (itemCodeDetailMapStr.contains(bomCodeParent))
&& ( !bomCodeOrg.equalsIgnoreCase(bomCodeRef)) ) )
{
System.out.println("@@@@@@@@ before recalcilate valueXmlString ["+valueXmlString.toString()+"]");
System.out.println("14/06/14 supreme 2 inside itemCode ["+itemCode+"]bomCodeRef["+bomCodeRef+"] suppSour [" + suppSour+"]bomCodeOrg["+bomCodeOrg+"]");
System.out.println("14/06/14 Before recalculate itemCode {" + itemCode +"] bomCodeRef [" + bomCodeRef + "] bomCodeParent [" + bomCodeParent+ "]dueDate["+dueDate+"]" );
Document argDom = null;
NodeList parentNodeList = null;
Node parentNode = null;
String winName="",editFlag="",xtraParams="",mrpGetData="" ;
Document dom2 = null;
ResultSet rs = null;
//Timestamp dateFr = java.sql.Timestamp.valueOf(genericUtility.getValidDateString(dueDate, genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00");
System.out.println("456 @@@@@@@@@ exsting order deleted next...duedate["+dueDate+"]..finish..errString["+errString+"]");
SimpleDateFormat simpleDateFormat = null;
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
StringBuffer argData = new StringBuffer();
argData = new StringBuffer("<?xml version=\"1.0\"?><Root><Header><editFlag>");
argData.append(editFlag).append("</editFlag></Header>");
argData.append("<Detail\r\n>");
argData.append("<site_code>").append(siteCode).append("</site_code>\r\n");
argData.append("<process_cycle>").append("3").append("</process_cycle>\r\n");
//argData.append("<run_date>").append(simpleDateFormat.format(new Date())).append("</run_date>\r\n"); // 01-10-2007
//argData.append("<run_date>").append(simpleDateFormat.format(new Date())).append("</run_date>\r\n"); // 01-10-2007
argData.append("<run_date>").append(dueDate).append("</run_date>\r\n"); // 01-10-2007
argData.append("<dis_plan>").append("Y").append("</dis_plan>\r\n"); //N
argData.append("<mfg_plan>").append("Y").append("</mfg_plan>\r\n");
argData.append("<mat_plan>").append("Y").append("</mat_plan>\r\n"); // change from N
argData.append("<made_to_stock>").append("1").append("</made_to_stock>\r\n"); //0
argData.append("<made_to_order>").append("0").append("</made_to_order>\r\n");
argData.append("<balance_intersite>").append("N").append("</balance_intersite>\r\n");
argData.append("<gen_ind>").append("Y").append("</gen_ind>\r\n"); //N
argData.append("<wizard>").append("2").append("</wizard>\r\n"); //3
argData.append("<verifier>").append("N").append("</verifier>\r\n");
argData.append("<isBomReplace>").append("Y").append("</isBomReplace>\r\n"); // added by cpatil on 17/05/14 for BomReplace
argData.append("<bom_code>").append(bomCodeRef).append("</bom_code>\r\n"); // added by cpatil on 17/05/14 for BomReplace
argData.append("<bomReplaceDemand>").append(qtyReqdStr).append("</bomReplaceDemand>\r\n"); // added by cpatil on 17/05/14 for BomReplace
//argData.append("<date_from>").append(simpleDateFormat.format(new Date())).append("</date_from>\r\n"); // 01-10-2007
//argData.append("<date_to>").append(simpleDateFormat.format(new Date())).append("</date_to>\r\n"); // 01-10-2007
argData.append("<date_from>").append(dueDate).append("</date_from>\r\n"); // 01-10-2007
argData.append("<date_to>").append(dueDate).append("</date_to>\r\n"); // 01-10-2007
argData.append("<saleOrderReplaceBom>").append(saleOrder).append("</saleOrderReplaceBom>\r\n"); // added by cpatil on 17/05/14 for BomReplace
argData.append("<lineNoReplaceBom>").append(lineNo).append("</lineNoReplaceBom>\r\n"); // added by cpatil on 17/05/14 for BomReplace
argData.append("<bom_code_parent>").append(bomCodeParent).append("</bom_code_parent>\r\n"); // added by cpatil on 17/05/14 for BomReplace
argData.append("<site_code__from>").append(siteCode).append("</site_code__from>\r\n");
argData.append("<site_code__to>").append(siteCode).append("</site_code__to>\r\n");
argData.append("<item_code__from>").append(itemCode).append("</item_code__from>\r\n");
argData.append("<item_code__to>").append(itemCode).append("</item_code__to>\r\n");
argData.append("<item_ser__from>").append("0").append("</item_ser__from>\r\n");
argData.append("<item_ser__to>").append("ZZ").append("</item_ser__to>\r\n");
argData.append("<item_code_list>").append("").append("</item_code_list>\r\n");
argData.append("</Detail>");
argData.append("</Root>");
System.out.println("argData=="+argData);
argDom = genericUtility.parseString(argData.toString());
// 13/06/14 manoharan delete line for which bom_code changed
errString = runMRPObj.validateFilterParams( argDom );
if (errString != null && errString.trim().length() > 0)
{
System.out.println("Error validating filter parameters:..." + errString);
return errString;
}
errString = runMRPObj.deleteOldPlan (siteCode,itemCode);
if (errString != null && errString.trim().length() > 0)
{
System.out.println("Error validating filter parameters:..." + errString);
return errString;
}
// end 13/06/14 manoharan
sql = "select bomdet.item_code from bomdet bomdet, bom bom " +
" where bom.bom_code = bomdet.bom_code " +
" and bom.bom_code = ? " +
" and bom.site_code = ? ";
pstmt = conn.prepareStatement(sql);
//pstmt.setString(1, bomCodeRef); // 13/06/14 manoharan
pstmt.setString(1, bomCodeOrg);
pstmt.setString(2, siteCode);
rs = pstmt.executeQuery();
while (rs.next())
{
replaceBomItemList.add(rs.getString(1));
errString = runMRPObj.deleteOldPlan (siteCode,rs.getString(1));
if (errString != null && errString.trim().length() > 0)
{
System.out.println("Error validating filter parameters:..." + errString);
return errString;
}
//errString = runMRPObj.deleteOldPlan (siteCode,rs.getString(1));
}
rs.close(); rs=null;
pstmt.close(); pstmt=null;
System.out.println("@@@@@ replaceBomItemList["+replaceBomItemList+"]");
winName = "w_mrp_run_wiz";
mrpGetData = runMRPObj.getData(argDom, argDom, winName, xtraParams);
// mrpGetData = runMRPObj.getData(argDom, dom2, winName, xtraParams);
System.out.println("@@@@mrpGetData return string in bean:: after recalculate::["+mrpGetData+"]");
mrpGetDataDom = genericUtility.parseString(mrpGetData.toString());
NodeList hdrDommList2 = mrpGetDataDom.getElementsByTagName("Detail2");
System.out.println("len1===["+hdrDommList2.getLength()+"]");
for (int dtlCtr2 = 0; dtlCtr2 < hdrDommList2.getLength(); dtlCtr2++)
{
Node detailListNode2 = hdrDommList2.item(dtlCtr2);
if( detailListNode2.hasChildNodes() == true )
{
System.out.println("@@@@@@@@for_test detailListNode2.hasChildNodes()["+detailListNode2.hasChildNodes()+"]dtlCtr2["+dtlCtr2+"]");
qtyReqdStr = "0";
sourceSupply = "";
siteCodeSupp = "";
itemCodeSupp = "";
itemCodeDescr = "";
lotNo = "";
lotSl = "";
locCode = "";
unit = "";
parentItem = "";
tranSer = "";
demand = "";
supply = "";
planSupply = "0";
runningDemand = "0";
runningSupplyStr = "0";
runningPlanSupply = "0";
independentDemand = "0";
stockQty = "0";
othSupply = "0";
pendingPo = "0";
pendingDo = "0";
pendingIndent = "0";
pendingDr = "0";
itemCodeParent = "";
originalOrAltitem = "";
nextDomId++;
valueXmlString.append("<Detail2 domID='" + nextDomId + "' >\r\n");
//domCnt++;
//300115 valueXmlString.append("<Detail2 domID='" + domCnt + "' >\r\n");
System.out.println("@@@@@ node name1 ["+detailListNode2.getNodeName()+"]");
NodeList refrenceList2= detailListNode2.getChildNodes();
if( refrenceList2 != null )
{
System.out.println("refrenceList2.getLength()["+refrenceList2.getLength()+"]");
for (int cntr2 = 0; cntr2 < refrenceList2.getLength(); cntr2++)
{
System.out.println("@@@@@@@@ inside detail2["+cntr2+"]");
Node refrenceNode2 = refrenceList2.item(cntr2);
orderList1 = refrenceNode2.getChildNodes();
System.out.println("@@@@@ node name2 ["+refrenceNode2.getNodeName()+"]");
// for detail4 start
if("Detail4".equalsIgnoreCase(refrenceNode2.getNodeName()))
{
//detail4Flag = true;
NodeList orderList2 = refrenceNode2.getChildNodes();
sourceSupply = "";
siteCodeSupp = "";
itemCodeSupp = "";
itemCodeDescr = "";
lotNo = "";
lotSl = "";
locCode = "";
unit = "";
parentItem = "";
tranSer = "";
//demand = "";
supply = "";
planSupply = "0";
runningDemand = "0";
runningSupplyStr = "0";
runningPlanSupply = "0";
independentDemand = "0";
stockQty = "0";
othSupply = "0";
pendingPo = "0";
pendingDo = "0";
pendingIndent = "0";
pendingDr = "0";
itemCodeParent = "";
originalOrAltitem = "";
altItemPerc = "";
for (int nodCtr1 = 0; nodCtr1 < orderList2.getLength(); nodCtr1++)
{
Node detail4Node=orderList2.item(nodCtr1);
//NodeList suppDetailList=detail4Node.getChildNodes();
//System.out.println("@@@@@@@@@orderNode node name[" + detail4Node.getNodeName()+"]");
//if("supp_detail".equalsIgnoreCase(detail4Node.getNodeName()))
// for (int cn = 0; cn < suppDetailList .getLength(); cn++)
{
//String nodeName=suppDetailList.item(cn).getNodeName();
if("source_supply".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
sourceSupply = detail4Node.getFirstChild().getNodeValue();
}
else
{
sourceSupply="";
}
//sourceSupply = detail4Node.getFirstChild().getNodeValue();
}
if("site_code".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
siteCodeSupp = detail4Node.getFirstChild().getNodeValue();
}
else
{
siteCodeSupp="";
}
//siteCodeSupp = detail4Node.getFirstChild().getNodeValue();
}
if("item_code".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
itemCodeSupp = detail4Node.getFirstChild().getNodeValue();
}
else
{
itemCodeSupp="";
}
//itemCodeSupp = detail4Node.getFirstChild().getNodeValue();
}
if("item_code_descr".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
itemCodeDescr = detail4Node.getFirstChild().getNodeValue();
}
else
{
itemCodeDescr="";
}
//itemCodeDescr = detail4Node.getFirstChild().getNodeValue();
}
if("lot_no".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
lotNo = detail4Node.getFirstChild().getNodeValue();
}
else
{
lotNo="";
}
//lotNo = detail4Node.getFirstChild().getNodeValue();
}
if("lot_sl".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
lotSl = detail4Node.getFirstChild().getNodeValue();
}
else
{
lotSl="";
}
//lotSl = detail4Node.getFirstChild().getNodeValue();
}
if("loc_code".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
locCode = detail4Node.getFirstChild().getNodeValue();
}
else
{
locCode="";
}
}
if("unit".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
unit = detail4Node.getFirstChild().getNodeValue();
}
else
{
unit="";
}
//unit = detail4Node.getFirstChild().getNodeValue();
}
if("parent_item".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
parentItem = detail4Node.getFirstChild().getNodeValue();
}
else
{
parentItem="";
}
//parentItem = detail4Node.getFirstChild().getNodeValue();
}
if("tran_ser".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
tranSer = detail4Node.getFirstChild().getNodeValue();
}
else
{
tranSer="";
}
//tranSer = detail4Node.getFirstChild().getNodeValue();
}
/*if("demand".equalsIgnoreCase(detail4Node.getNodeName()))
{
demand = detail4Node.getFirstChild().getNodeValue();
}*/
if("supply".equalsIgnoreCase(detail4Node.getNodeName()))
{
supply = detail4Node.getFirstChild().getNodeValue();
}
if("plan_supply".equalsIgnoreCase(detail4Node.getNodeName()))
{
planSupply = detail4Node.getFirstChild().getNodeValue();
}
if("running_demand".equalsIgnoreCase(detail4Node.getNodeName()))
{
runningDemand = detail4Node.getFirstChild().getNodeValue();
}
if("running_supply".equalsIgnoreCase(detail4Node.getNodeName()))
{
runningSupplyStr = detail4Node.getFirstChild().getNodeValue();
}
if("running_plan_supply".equalsIgnoreCase(detail4Node.getNodeName()))
{
runningPlanSupply = detail4Node.getFirstChild().getNodeValue();
}
if("independent_demand".equalsIgnoreCase(detail4Node.getNodeName()))
{
independentDemand = detail4Node.getFirstChild().getNodeValue();
}
if("stock_qty".equalsIgnoreCase(detail4Node.getNodeName()))
{
stockQty = detail4Node.getFirstChild().getNodeValue();
}
if("oth_supply".equalsIgnoreCase(detail4Node.getNodeName()))
{
othSupply = detail4Node.getFirstChild().getNodeValue();
}
if("pending_po".equalsIgnoreCase(detail4Node.getNodeName()))
{
pendingPo = detail4Node.getFirstChild().getNodeValue();
}
if("pending_do".equalsIgnoreCase(detail4Node.getNodeName()))
{
pendingDo = detail4Node.getFirstChild().getNodeValue();
}
if("pending_indent".equalsIgnoreCase(detail4Node.getNodeName()))
{
pendingIndent = detail4Node.getFirstChild().getNodeValue();
}
if("pending_dr".equalsIgnoreCase(detail4Node.getNodeName()))
{
pendingDr = detail4Node.getFirstChild().getNodeValue();
}
if("item_code_parent".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
itemCodeParent = detail4Node.getFirstChild().getNodeValue();
}
else
{
itemCodeParent="";
}
//itemCodeParent = detail4Node.getFirstChild().getNodeValue();
}
if("originalOrAltitem".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
originalOrAltitem = detail4Node.getFirstChild().getNodeValue();
}
else
{
originalOrAltitem="";
}
//originalOrAltitem = detail4Node.getFirstChild().getNodeValue();
}
if("alt_item_perc".equalsIgnoreCase(detail4Node.getNodeName()))
{
if( detail4Node.getFirstChild() != null)
{
altItemPerc = detail4Node.getFirstChild().getNodeValue();
}
else
{
altItemPerc="";
}
}
}
}
System.out.println("@@@@ for test ctr["+dtlCtr+"]itemCodeSupp["+itemCodeSupp+"]sourceSupply["+sourceSupply+"]siteCodeSupp["+siteCodeSupp+"]-itemCodeSupp["+itemCodeSupp+"]-lotNo["+lotNo+"]-lotSl["+lotSl+"]-locCode["+locCode+"]-tranSer["+tranSer+"]@@@");
if( "Stock".equalsIgnoreCase(tranSer))
{
sourceSupply = sourceSupply+"S";
}
domCnt2++;
valueXmlString.append("<Detail4 domID='" + domCnt2 + "' >\r\n");
/*
selectedSampleItem = selectedSampleItem + "<CommonDetail >" +
"<sale_order>" + saleOrderDet2 + "</sale_order><line_no>" + lineNoDet2 + "</line_no>" +
"<site_code>"+siteCodeDet2 + "</site_code><item_code>"+ itemCodeDet2 + "</item_code>" +
"<item_code_descr>" + itemCodeDescr1 + "</item_code_descr>" +
"<qty_reqd>" + qtyReqd2 + "</qty_reqd>" +
"<order_type>" + orderType + "</order_type>" +
"<detail2dbID>"+detail2dbID+"</detail2dbID>" +
"</CommonDetail>";
*/
valueXmlString.append("<source_supply protect = '1'>").append("<![CDATA[" + sourceSupply + "]]>").append("</source_supply>\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCodeSupp + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + itemCodeDescr + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<lot_no protect = '1'>").append("<![CDATA[" + lotNo + "]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl protect = '1'>").append("<![CDATA[" + lotSl + "]]>").append("</lot_sl>\r\n");
valueXmlString.append("<loc_code protect = '1'>").append("<![CDATA[" + locCode + "]]>").append("</loc_code>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unit + "]]>").append("</unit>\r\n");
valueXmlString.append("<parent_item protect = '1'>").append("<![CDATA[" + parentItem + "]]>").append("</parent_item>\r\n");
valueXmlString.append("<tran_ser protect = '1'>").append("<![CDATA[" + tranSer + "]]>").append("</tran_ser>\r\n");
//valueXmlString.append("<demand protect = '1'>").append("<![CDATA[" + demand + "]]>").append("</demand>\r\n");
valueXmlString.append("<supply protect = '1'>").append("<![CDATA[" + supply + "]]>").append("</supply>\r\n");
valueXmlString.append("<plan_supply protect = '1'>").append("<![CDATA[" + planSupply + "]]>").append("</plan_supply>\r\n");
valueXmlString.append("<running_demand protect = '1'>").append("<![CDATA[" + runningDemand + "]]>").append("</running_demand>\r\n");
valueXmlString.append("<running_supply protect = '1'>").append("<![CDATA[" + runningSupply + "]]>").append("</running_supply>\r\n");
valueXmlString.append("<running_plan_supply protect = '1'>").append("<![CDATA[" + runningPlanSupply + "]]>").append("</running_plan_supply>\r\n");
valueXmlString.append("<independent_demand protect = '1'>").append("<![CDATA[" + independentDemand + "]]>").append("</independent_demand>\r\n");
valueXmlString.append("<stock_qty protect = '1'>").append("<![CDATA[" + stockQty + "]]>").append("</stock_qty>\r\n");
valueXmlString.append("<oth_supply protect = '1'>").append("<![CDATA[" + othSupply + "]]>").append("</oth_supply>\r\n");
valueXmlString.append("<pending_po protect = '1'>").append("<![CDATA[" + pendingPo + "]]>").append("</pending_po>\r\n");
valueXmlString.append("<pending_do protect = '1'>").append("<![CDATA[" + pendingDo + "]]>").append("</pending_do>\r\n");
valueXmlString.append("<pending_indent protect = '1'>").append("<![CDATA[" + pendingIndent + "]]>").append("</pending_indent>\r\n");
valueXmlString.append("<pending_dr protect = '1'>").append("<![CDATA[" + pendingDr + "]]>").append("</pending_dr>\r\n");
valueXmlString.append("<item_code_parent protect = '1'>").append("<![CDATA[" + itemCodeParent + "]]>").append("</item_code_parent>\r\n");
valueXmlString.append("<originalOrAltitem protect = '1'>").append("<![CDATA[" + originalOrAltitem + "]]>").append("</originalOrAltitem>\r\n");
valueXmlString.append("<alt_item_perc protect = '1'>").append("<![CDATA[" + altItemPerc + "]]>").append("</alt_item_perc>\r\n");
valueXmlString.append("</Detail4>\r\n");
}
//////////////////////////////////////////////////////////
//if("reference".equalsIgnoreCase(refrenceNode2.getNodeName()))
//{
//orderList = refrenceNode2.getChildNodes();
//for (int nodCtr1 = 0; nodCtr1 < orderList .getLength(); nodCtr1++)
//{
//orderNode=orderList.item(nodCtr1);
//orderDtlList=orderNode.getChildNodes();
//if("order".equalsIgnoreCase(orderNode.getNodeName()))
//{
/* saleOrder = "";
lineNo = "";
bomCodeParent= "";
bomCodeOrg = "";
bomCodeRef = "";
itemCode= "";
itemCodeDescr = "";
qtyReqdStr = "0";
unit = "";
sourceSupply = "";
sourceSupplyRef = "";
suppSour = "";
*/
//for (int cntr = 0; cntr < refrenceList2.getLength(); cntr++) //orderDtlList
//{
//Node detail2Node = refrenceList2.item(cntr); //orderDtlList
if("sale_order".equalsIgnoreCase( refrenceNode2.getNodeName())) // detail2Node replace below detail2Node
{
saleOrder = refrenceNode2.getTextContent();
}
if("line_no".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
lineNo = refrenceNode2.getTextContent();
}
if("site_code".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
siteCode = refrenceNode2.getTextContent();
}
if("bom_code_parent".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
bomCodeParent = refrenceNode2.getTextContent();
}
if("bom_code_org".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
bomCodeOrg = refrenceNode2.getTextContent();
}
if("bom_code_ref".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
bomCodeRef = refrenceNode2.getTextContent();
}
if("item_code".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
itemCode = refrenceNode2.getTextContent();
}
if("item_code_descr".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
itemCodeDescr = refrenceNode2.getTextContent();
}
if("qty_reqd".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
qtyReqdStr = refrenceNode2.getTextContent();
System.out.println("@@@@@@ in detail2 qtyReqdStr["+qtyReqdStr+"]");
}
if("unit".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
unit = refrenceNode2.getTextContent();
}
if("source_supply".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
sourceSupply = refrenceNode2.getTextContent();
}
if("source_supply_ref".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
sourceSupplyRef = refrenceNode2.getTextContent();
}
if("supp_sour".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
suppSour = refrenceNode2.getTextContent();
}
if("itemCodeDetailMap".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
itemCodeDetailMapStr = refrenceNode2.getTextContent();
System.out.println("@@@@@@ itemCodeDetailMapStr["+itemCodeDetailMapStr+"]");
}
//new tag
if("mfg_type".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
mfgType = refrenceNode2.getTextContent();
}
if("demand".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
demand = refrenceNode2.getTextContent();
}
if("other".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
other = refrenceNode2.getTextContent();
}
if("gross_weight".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
grossWeight = refrenceNode2.getTextContent();
}
if("supply".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
supply = refrenceNode2.getTextContent();
}
if("net_req".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
netReq = refrenceNode2.getTextContent();
}
if("order_type".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
orderType = refrenceNode2.getTextContent();
}
if("current_sorder".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
currentSorder = refrenceNode2.getTextContent();
}
if("item_code_descr".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
itemCodeDescr = refrenceNode2.getTextContent();
}
if("due_date".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
dueDate = refrenceNode2.getTextContent();
}
if("loc_group".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
locGroup = refrenceNode2.getTextContent();
}
if("itemDetailsInfo".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
itemDetailsInfo = refrenceNode2.getTextContent();
}
if("sodemand".equalsIgnoreCase( refrenceNode2.getNodeName()))
{
sodemand = refrenceNode2.getTextContent();
}
// end new tag
//}
//}
//}
//test
//test
//}
///////////////////////////////////////////////////////////
}
}
System.out.println("14/06/14 After recalculate itemCode {" + itemCode +"] bomCodeRef [" + bomCodeRef + "] bomCodeParent [" + bomCodeParent+ "]itemCodeDetailMapStr["+itemCodeDetailMapStr+"]" );
////////////////////////////////////////////////////////
System.out.println("13/06/14 reference qtyReqdStr before["+qtyReqdStr+"]demand["+demand+"]sodemand["+sodemand+"]");
if (sodemand == null || "null".equals(sodemand) || sodemand.trim().length() == 0 )
{
sodemand = "0";
}
//qtyReqd = Double.parseDouble(qtyReqdStr);
System.out.println("13/06/14 outside qtyReqd before["+qtyReqd+"]sodemand["+sodemand+"]itemCode["+itemCode+"]");
if( Double.parseDouble( sodemand ) > 0)
{
System.out.println("13/06/14 inside qtyReqd before["+qtyReqd+"]itemCode["+itemCode+"]");
//valueXmlString.append("<reference protect = '1'>\r\n");
//valueXmlString.append("<order protect = '1' domID='" + domCnt + "'>\r\n");
valueXmlString.append("<sale_order protect = '1'>").append("<![CDATA[" + saleOrder + "]]>").append("</sale_order>\r\n");
valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<qty_reqd protect = '1'>").append("<![CDATA[" + sodemand + "]]>").append("</qty_reqd>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + itemCodeDescr + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<supp_sour protect = '1'>").append("<![CDATA[" + suppSour + "]]>").append("</supp_sour>\r\n");
valueXmlString.append("<running_supply protect = '1'>").append("<![CDATA[" + runningSupplyStr + "]]>").append("</running_supply>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unit + "]]>").append("</unit>\r\n");
valueXmlString.append("<originalOrAltitem protect = '1'>").append("<![CDATA[" + originalOrAltitem + "]]>").append("</originalOrAltitem>\r\n");
valueXmlString.append("<bom_code_parent protect = '1'>").append("<![CDATA[" + bomCodeParent + "]]>").append("</bom_code_parent>\r\n"); //bomCodeParent
valueXmlString.append("<bom_code_org protect = '1'>").append("<![CDATA[" + bomCodeRef + "]]>").append("</bom_code_org>\r\n");
if( "P".equalsIgnoreCase(suppSour))
{
valueXmlString.append("<bom_code_ref protect = '1'>").append(" ").append("</bom_code_ref>\r\n");
}
else
{
valueXmlString.append("<bom_code_ref protect = '1'>").append("<![CDATA[" + bomCodeRef + "]]>").append("</bom_code_ref>\r\n");
}
valueXmlString.append("<source_supply protect = '1'>").append("<![CDATA[" + sourceSupply + "]]>").append("</source_supply>\r\n");
valueXmlString.append("<source_supply_ref protect = '1'>").append("<![CDATA[" + sourceSupplyRef + "]]>").append("</source_supply_ref>\r\n");
//new tag
valueXmlString.append("<itemDetailsInfo protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</itemDetailsInfo>\r\n");
valueXmlString.append("<mfg_type protect = '1'>").append("<![CDATA[" + mfgType + "]]>").append("</mfg_type>\r\n");
valueXmlString.append("<demand protect = '1'>").append("<![CDATA[" + demand + "]]>").append("</demand>\r\n");
valueXmlString.append("<sodemand protect = '1'>").append("<![CDATA[" + sodemand + "]]>").append("</sodemand>\r\n");
valueXmlString.append("<other protect = '1'>").append("<![CDATA[" + other + "]]>").append("</other>\r\n");
valueXmlString.append("<gross_weight protect = '1'>").append("<![CDATA[" + grossWeight + "]]>").append("</gross_weight>\r\n");
valueXmlString.append("<supply protect = '1'>").append("<![CDATA[" + supply + "]]>").append("</supply>\r\n");
valueXmlString.append("<net_req protect = '1'>").append("<![CDATA[" + netReq + "]]>").append("</net_req>\r\n");
valueXmlString.append("<order_type protect = '1'>").append("<![CDATA[" + orderType + "]]>").append("</order_type>\r\n");
valueXmlString.append("<current_sorder protect = '1'>").append("<![CDATA[" + currentSorder + "]]>").append("</current_sorder>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("<![CDATA[" + dueDate + "]]>").append("</due_date>\r\n");
valueXmlString.append("<loc_group protect = '1'>").append("<![CDATA[" + locGroup + "]]>").append("</loc_group>\r\n");
//valueXmlString.append("<itemDetailsInfo protect = '1'>").append("<![CDATA[" + itemDetailsInfo + "]]>").append("</itemDetailsInfo>\r\n");
//valueXmlString.append("<refDetails protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</refDetails>\r\n");
//valueXmlString.append("<bom_code protect = '1'>").append("<![CDATA[" + "" + "]]>").append("</bom_code>\r\n");
//valueXmlString.append("<stock_qty protect = '1'>").append("<![CDATA[" + itemDetailsInfo + "]]>").append("</stock_qty>\r\n");
//valueXmlString.append("<itemType protect = '1'>").append("<![CDATA[" + getItemType(suppSour) + "]]>").append("</itemType>\r\n");
//valueXmlString.append("<itemCodeDetailMap protect = '1'>").append("<![CDATA[" + itemDetailsInfo + "]]>").append("</itemCodeDetailMap>\r\n");
// end new tag
//valueXmlString.append("</order>\r\n");
//valueXmlString.append("</reference>\r\n");
}
////////////////////////////////////////////////////////
/*
valueXmlString.append("<CommonDetail protect = '1'>\r\n>");
valueXmlString.append("<sale_order protect = '1'>").append("<![CDATA[" + saleOrder + "]]>").append("</sale_order>\r\n");
valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + itemCodeDescr + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<qty_reqd protect = '1'>").append("<![CDATA[" + sodemand + "]]>").append("</qty_reqd>\r\n");
valueXmlString.append("<order_type protect = '1'>").append("<![CDATA[" + orderType + "]]>").append("</order_type>\r\n");
valueXmlString.append("</CommonDetail>\r\n");
*/
valueXmlString.append("</Detail2>\r\n");
}
}
System.out.println("@@@@@@@@ before recalcilate valueXmlString after added ["+valueXmlString.toString()+"]");
}
else
{
System.out.println("@@@@@@@@ for old xml itemDetailsInfo["+itemDetailsInfo+"]itemCode["+itemCode+"]mfgType["+mfgType+"]demand["+demand+"]qtyReqdStr["+qtyReqdStr+"]supply["+supply+"]currentSorder["+currentSorder+"]suppSour["+suppSour+"]");
domCnt++;
valueXmlString.append("<Detail2 domID='" + domCnt + "' >\r\n");
//valueXmlString.append("<reference protect = '1'>");
//valueXmlString.append("<order protect = '1' domID='" + domCnt + "'>\r\n");
valueXmlString.append("<sale_order protect = '1'>").append("<![CDATA[" + saleOrder + "]]>").append("</sale_order>\r\n");
valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
valueXmlString.append("<qty_reqd protect = '1'>").append("<![CDATA[" + qtyReqdStr + "]]>").append("</qty_reqd>\r\n");
valueXmlString.append("<item_code protect = '1'>").append("<![CDATA[" + itemCode + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>").append("<![CDATA[" + itemCodeDescr + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<supp_sour protect = '1'>").append("<![CDATA[" + suppSour + "]]>").append("</supp_sour>\r\n");
valueXmlString.append("<running_supply protect = '1'>").append("<![CDATA[" + runningSupplyStr + "]]>").append("</running_supply>\r\n");
valueXmlString.append("<unit protect = '1'>").append("<![CDATA[" + unit + "]]>").append("</unit>\r\n");
valueXmlString.append("<originalOrAltitem protect = '1'>").append("<![CDATA[" + originalOrAltitem + "]]>").append("</originalOrAltitem>\r\n");
valueXmlString.append("<bom_code_parent protect = '1'>").append("<![CDATA[" + bomCodeParent + "]]>").append("</bom_code_parent>\r\n");
valueXmlString.append("<bom_code_org protect = '1'>").append("<![CDATA[" + bomCodeOrg + "]]>").append("</bom_code_org>\r\n");
valueXmlString.append("<bom_code_ref protect = '1'>").append("<![CDATA[" + bomCodeRef + "]]>").append("</bom_code_ref>\r\n");
valueXmlString.append("<source_supply protect = '1'>").append("<![CDATA[" + sourceSupply + "]]>").append("</source_supply>\r\n");
valueXmlString.append("<source_supply_ref protect = '1'>").append("<![CDATA[" + sourceSupplyRef + "]]>").append("</source_supply_ref>\r\n");
//valueXmlString.append("</order>\r\n");
//valueXmlString.append("</reference>\r\n");
//new tag
valueXmlString.append("<mfg_type protect = '1'>").append("<![CDATA[" + mfgType + "]]>").append("</mfg_type>\r\n");
valueXmlString.append("<demand protect = '1'>").append("<![CDATA[" + demand + "]]>").append("</demand>\r\n");
valueXmlString.append("<sodemand protect = '1'>").append("<![CDATA[" + demand + "]]>").append("</sodemand>\r\n");
valueXmlString.append("<other protect = '1'>").append("<![CDATA[" + other + "]]>").append("</other>\r\n");
valueXmlString.append("<gross_weight protect = '1'>").append("<![CDATA[" + grossWeight + "]]>").append("</gross_weight>\r\n");
valueXmlString.append("<supply protect = '1'>").append("<![CDATA[" + supply + "]]>").append("</supply>\r\n");
valueXmlString.append("<net_req protect = '1'>").append("<![CDATA[" + netReq + "]]>").append("</net_req>\r\n");
valueXmlString.append("<order_type protect = '1'>").append("<![CDATA[" + orderType + "]]>").append("</order_type>\r\n");
valueXmlString.append("<current_sorder protect = '1'>").append("<![CDATA[" + currentSorder + "]]>").append("</current_sorder>\r\n");
valueXmlString.append("<due_date protect = '1'>").append("<![CDATA[" + dueDate + "]]>").append("</due_date>\r\n");
valueXmlString.append("<loc_group protect = '1'>").append("<![CDATA[" + locGroup + "]]>").append("</loc_group>\r\n");
valueXmlString.append("<itemDetailsInfo protect = '1'>").append("<![CDATA[" + itemDetailsInfo + "]]>").append("</itemDetailsInfo>\r\n");
// end new tag
//tempdetail4OuterList.clear();
tempdetail4OuterList = (ArrayList) detail4ListMap.get(saleOrder+lineNo+itemCode);
System.out.println("@@@@@@1073["+detail4ListMap.size()+"]:["+saleOrder+lineNo+itemCode+"]detail4ListMap["+detail4ListMap+"]");
if( tempdetail4OuterList != null && tempdetail4OuterList.size() > 0 )
{
System.out.println("@@@@@@1074[:tempdetail4OuterList.size["+tempdetail4OuterList.size()+"]");
for( int listCtr=0; listCtr < tempdetail4OuterList.size() ; listCtr++)
{
//tempdetail4List.clear();
tempdetail4List = ( ArrayList ) tempdetail4OuterList.get(listCtr);
System.out.println("@@@@@@ tempdetail4List listCtr["+listCtr+"]["+tempdetail4List+"]");
domCnt2++;
int k=0;
valueXmlString.append("<Detail4 domID='" + domCnt2 + "' >\r\n");
valueXmlString.append("<site_code protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</site_code>\r\n");
valueXmlString.append("<item_code protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</item_code>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<lot_no protect = '1' >" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</lot_no>\r\n");
valueXmlString.append("<lot_sl protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</lot_sl>\r\n");
valueXmlString.append("<loc_code protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</loc_code>\r\n");
valueXmlString.append("<tran_ser protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</tran_ser>\r\n");
valueXmlString.append("<tran_id protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</tran_id>\r\n");
valueXmlString.append("<supply protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</supply>\r\n");
valueXmlString.append("<alloc_qty protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</alloc_qty>\r\n");
valueXmlString.append("<unit protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</unit>\r\n");
valueXmlString.append("<ref_line_no protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</ref_line_no>\r\n");
valueXmlString.append("<planned_quantity protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</planned_quantity>\r\n");
valueXmlString.append("<parent_item protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</parent_item>\r\n");
valueXmlString.append("<source_supply protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</source_supply>\r\n");
valueXmlString.append("<item_code_parent protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</item_code_parent>\r\n");
valueXmlString.append("<sale_order protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</sale_order>\r\n");
valueXmlString.append("<line_no protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</line_no>\r\n");
valueXmlString.append("<qty_reqd protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</qty_reqd>\r\n");
valueXmlString.append("<item_code_descr protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</item_code_descr>\r\n");
valueXmlString.append("<available_supply protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</available_supply>\r\n");
valueXmlString.append("<originalOrAltitem protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</originalOrAltitem>\r\n");
valueXmlString.append("<quantityFlag protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</quantityFlag>\r\n");
valueXmlString.append("<prev_item_worder protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</prev_item_worder>\r\n");
valueXmlString.append("<previous_item protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</previous_item>\r\n");
valueXmlString.append("<new_planned_supply protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</new_planned_supply>\r\n");
valueXmlString.append("<due_date protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</due_date>\r\n");
valueXmlString.append("<alloc_pref protect = '1'>" ).append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</alloc_pref>\r\n");
valueXmlString.append("<alt_item_perc protect = '1'>").append("<![CDATA[" + tempdetail4List.get(k++) + "]]>").append("</alt_item_perc>\r\n");
valueXmlString.append("</Detail4>\r\n");
}
}
valueXmlString.append("</Detail2>\r\n");
}
//System.out.println("@@@@@@@@@ 328 xmldata============[["+xmldata+"]]");
//}
}
//}
//}
//}
//}
}
}
// end
valueXmlString.append("</Root>");
xmldata = valueXmlString.toString();
System.out.println("@@@@@@@@@final bean xmldata============[["+xmldata+"]]");
}//try end
catch (SQLException sqx)
{
System.out.println("The SQLException occurs in MrpWizPrsSaveBean :"+sqx);
sqx.printStackTrace();
throw new ITMException(sqx);
}
catch(Exception e)
{
System.out.println("The Exception occurs in MrpWizPrsSaveBean : "+e);
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (errString == null || errString.trim().length() == 0)
{
System.out.println("@@@@@@ errString :::"+ errString );
//conn.commit();
//return errString;
}
if (pstmt!= null)
{
pstmt = null;
}
if( conn != null )
{
conn.close();
conn=null;
}
}
catch(Exception e)
{
System.out.println("The Exception occurs in MrpWizPrsSaveBean :"+e);
e.printStackTrace();
throw new ITMException(e);
}
}
return xmldata;
}
private String getXmlDataBackup(Document dom )throws ITMException
{
PreparedStatement pstmt = null;
String sql = "", itemCode = "", effDate = "", itemSer = "";
int updCnt = 0;
//java.util.Date effDate1 = null, preDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
NodeList hdrDom = null;
//Node currDetail = null;
String saleOrder="",lineNo="", siteCode="", lotNo="", locCode="", lotSl="", tranSer="", runningSupplyStr="", qtyReqdStr="",allocQtyStr="";
double runningSupply=0,qtyReqd=0;
String tranId="",refId="",refLineNo="",unit="",errString="",bomCodeParent="",sourceSupplyRef="";
int cnt=0;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String xmldata="",bomCodeOrg="",itemCodeDescr="",bomCodeRef="";
ArrayList replaceBomItemList = new ArrayList();
ArrayList deleteBomList = new ArrayList();
ArrayList deleteSaleOrderList = new ArrayList();
NodeList orderList=null;
NodeList orderList1=null;
//Node mrpGetDataNode =null, referenceChildNode=null, Detail4ChildNode=null,mrpGetDataNode2=null;
RunMRPPrc runMRPObj = new RunMRPPrc();
int i=0,domCnt=0;
String suppSour="",originalOrAltitem="",sourceSupply="";
String itemCodeDetailMapStr="";
HashMap itemCodeDetailMap = new HashMap();
String siteCodeSupp="",itemCodeSupp="",parentItem="",demand="",supply="",planSupply="",runningDemand="",runningPlanSupply="";
String independentDemand="",stockQty="",othSupply="",pendingPo="",pendingDo="",pendingIndent="",pendingDr="",itemCodeParent="";
String bomCode="",dueDate="",orderOpt="",minOrderQty="",batchQtyType="",integralQty="",purLeadTime="";
String reorderQty="",minPlanPerc="",maxQty="",minQty="",batchQty="",yieldPerc="",mfgLeadTime="",description="",qcLeadTime="";
int domCnt2=0;
Document mrpGetDataDom = null;
String Deatail4SiteCode="",Deatail4LotNo="",Deatail4LocCode="",Deatail4LotSl="",Deatail4AllocQty="",Deatail4TranId="";
String Deatail4ItemCode="",Deatail4Unit="",Deatail4TranSer="",Deatail4RefLineNo="",Deatail4Supply="",Deatail4ParentItem="";
String Deatail4SourceSupply="",Deatail4PlannedQuantity="",Deatail4ItemCodeDescr="",Deatail4ItemCodeParent="";
String allocQty="",plannedQuantity="";
HashMap detail4ListMap = new HashMap();
//System.out.println("@@@ initiaalize detail4ListMap...");
......@@ -489,7 +1894,7 @@ public class MRPWizardXmlDataBean
Document dom2 = null;
ResultSet rs = null;
System.out.println("@@@@@@@@@ exsting order deleted next.....finish..errString["+errString+"]");
System.out.println("1500 @@@@@@@@@ exsting order deleted next.....finish..errString["+errString+"]");
SimpleDateFormat simpleDateFormat = null;
simpleDateFormat = new SimpleDateFormat(genericUtility.getApplDateFormat());
......@@ -528,6 +1933,9 @@ public class MRPWizardXmlDataBean
argData.append("<item_ser__from>").append("0").append("</item_ser__from>\r\n");
argData.append("<item_ser__to>").append("ZZ").append("</item_ser__to>\r\n");
argData.append("<item_code_list>").append("").append("</item_code_list>\r\n");
argData.append("</Detail>");
argData.append("</Root>");
......@@ -920,11 +2328,12 @@ public class MRPWizardXmlDataBean
qtyReqdStr = "0";
}
qtyReqd = Double.parseDouble(qtyReqdStr);
System.out.println("13/06/14 reference qtyReqd before["+qtyReqd+"]");
System.out.println("13/06/14 qtyReqd before["+qtyReqd+"]itemCode["+itemCode+"]");
if(qtyReqd > 0)
{
valueXmlString.append("<reference protect = '1'>\r\n");
valueXmlString.append("<order protect = '1' domID='" + domCnt + "'>\r\n");
System.out.println("13/06/14 inside qtyReqd before["+qtyReqd+"]");
//valueXmlString.append("<reference protect = '1'>\r\n");
//valueXmlString.append("<order protect = '1' domID='" + domCnt + "'>\r\n");
valueXmlString.append("<sale_order protect = '1'>").append("<![CDATA[" + saleOrder + "]]>").append("</sale_order>\r\n");
valueXmlString.append("<line_no protect = '1'>").append("<![CDATA[" + lineNo + "]]>").append("</line_no>\r\n");
valueXmlString.append("<site_code protect = '1'>").append("<![CDATA[" + siteCode + "]]>").append("</site_code>\r\n");
......@@ -947,8 +2356,8 @@ public class MRPWizardXmlDataBean
}
valueXmlString.append("<source_supply protect = '1'>").append("<![CDATA[" + sourceSupply + "]]>").append("</source_supply>\r\n");
valueXmlString.append("<source_supply_ref protect = '1'>").append("<![CDATA[" + sourceSupplyRef + "]]>").append("</source_supply_ref>\r\n");
valueXmlString.append("</order>\r\n");
valueXmlString.append("</reference>\r\n");
//valueXmlString.append("</order>\r\n");
//valueXmlString.append("</reference>\r\n");
}
////////////////////////////////////////////////////////
}
......@@ -1116,7 +2525,7 @@ public class MRPWizardXmlDataBean
return descr;
}
*/
*/
private String getWinName(Node node) throws Exception
{
......@@ -1127,7 +2536,44 @@ public class MRPWizardXmlDataBean
return "w_" + objName;
}
private String checkNull(String value)
{
if (value == null)
{
value = "";
}
return value;
}
private String getItemType(String suppSour) throws SQLException
{
String value="";
suppSour = checkNull(suppSour);
//System.out.println("@@@@@@@@@ inside getItemType suppSour["+suppSour+"]");
// if( flag == true )
// {
// value="0";
// }
// else
if("M".equalsIgnoreCase(suppSour.trim()) ) // M
{
value="1";
//System.out.println("@@@@@@@@@ inside M suppSour["+suppSour+"]value["+value+"]");
}
else if("P".equalsIgnoreCase(suppSour) )
{
value="2";
//System.out.println("@@@@@@@@@ inside P suppSour["+suppSour+"]value["+value+"]");
}
else
{
value="0";
//System.out.println("@@@@@@@@@ inside else suppSour["+suppSour+"]value["+value+"]");
}
//System.out.println("return --- > suppSour["+suppSour+"]value["+value+"]");
return value;
}
......
......@@ -28,7 +28,7 @@ public class MrpWizPrsSaveBean
{
public String preSaveForm(String xmlString1 , String chgUser , String chgTerm )throws ITMException
public String preSaveForm(String xmlString1 , String chgUser , String chgTerm , String sorderList )throws ITMException
{
Document dom = null;
System.out.println("@@@@@@@@@---------MrpWizPrsSaveBean EJB called...");
......@@ -38,12 +38,12 @@ public class MrpWizPrsSaveBean
{
System.out.println("@@@@@@@xmlString1["+xmlString1+"]@@@@@@@");
System.out.println("@@@@@@ in bean chgUser["+chgUser+"]::chgTerm["+chgTerm+"]");
System.out.println("@@@@@@ in bean chgUser["+chgUser+"]::chgTerm["+chgTerm+"]sorderList["+sorderList+"]");
if (xmlString1 != null && xmlString1.trim().length() > 0)
{
dom = GenericUtility.getInstance().parseString(xmlString1);
executepreSaveForm(dom,chgUser,chgTerm);
executepreSaveForm(dom,chgUser,chgTerm, sorderList);
}
}
catch(Exception e)
......@@ -55,7 +55,7 @@ public class MrpWizPrsSaveBean
return "";
}
private String executepreSaveForm(Document dom , String chgUser , String chgTerm )throws ITMException
private String executepreSaveForm(Document dom , String chgUser , String chgTerm , String sorderList)throws ITMException
{
PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
String sql = "", itemCode = "", effDate = "", itemSer = "", sql1="", sql2="";
......@@ -114,65 +114,170 @@ public class MrpWizPrsSaveBean
// if( detail4Node != null && detail4Node.getNodeValue() != null )
{
if("sale_order".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
saleOrder = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
saleOrder= "";
}
}
if("line_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lineNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lineNo= "";
}
}
if("site_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
siteCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
siteCode= "";
}
}
if("item_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
itemCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
itemCode= "";
}
}
if("lot_no".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lotNo = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lotNo= "";
}
}
if("lot_sl".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
lotSl = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
lotSl= "";
}
}
if("loc_code".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
locCode = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
locCode= "";
}
}
if("tran_ser".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
tranSer = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
tranSer= "";
}
}
if("running_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
runningSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
runningSupplyStr= "0";
}
}
if("qty_reqd".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
qtyReqdStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
qtyReqdStr= "0";
}
}
if("alloc_qty".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
allocQtyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
allocQtyStr= "0";
}
}
if("supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
supplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
supplyStr= "";
}
}
if("available_supply".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
availableSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
availableSupplyStr= "";
}
}
if("supp_sour".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
suppSour = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
suppSour= "";
}
}
if("parent_item".equalsIgnoreCase( detail4Node.getNodeName()))
{
if( detail4List.item(cntr).getFirstChild() != null)
{
parentItem = detail4List.item(cntr).getFirstChild().getNodeValue();
}
else
{
parentItem= "";
}
}
if("prev_item_worder".equalsIgnoreCase( detail4Node.getNodeName()))
{
......@@ -206,6 +311,7 @@ public class MrpWizPrsSaveBean
String itemCodeHdr="";
remarks = "From mrp process";
sql1=" select item_code from sorddet where sale_order = ? and trim(line_no) = ? "; //added trim() for line no on 07/08/14 by cpatil
pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1,saleOrder);
......@@ -224,7 +330,6 @@ public class MrpWizPrsSaveBean
{
runningSupply = runningSupplyStr==null?0:Double.parseDouble(runningSupplyStr);
}
if( qtyReqdStr.trim().length() > 0)
{
qtyReqd = qtyReqdStr==null?0:Double.parseDouble(qtyReqdStr);
......@@ -234,9 +339,9 @@ public class MrpWizPrsSaveBean
allocQty = allocQtyStr==null?0:Double.parseDouble(allocQtyStr);
}
System.out.println("itemCodeHdr["+itemCodeHdr+"]==itemCode["+itemCode+"]");
System.out.println("itemCodeHdr["+itemCodeHdr+"]==itemCode["+itemCode+"]parentItem["+parentItem+"]saleOrder["+saleOrder+"]");
if(itemCodeHdr.equalsIgnoreCase(itemCode))
if( ( itemCodeHdr.equalsIgnoreCase(itemCode) || itemCodeHdr.equalsIgnoreCase(parentItem) ) && saleOrder != null && saleOrder.trim().length() > 0 )
{
InvAllocTrace invallocTrace = new InvAllocTrace();
......@@ -267,6 +372,10 @@ public class MrpWizPrsSaveBean
{
String tranType = "AUT";
if( lineNo == null || lineNo.trim().length() == 0 )
{
lineNo = "1";
}
tranId = generateTranId( "w_inv_allocate",siteCode, conn );
sql = " insert into inv_allocate ( TRAN_ID,TRAN_DATE,TRAN_TYPE,WORK_ORDER,SITE_CODE,ITEM_CODE," +
......@@ -358,6 +467,7 @@ public class MrpWizPrsSaveBean
}
}
/*
if ( errString == null || errString.trim().length() == 0 )
{
......@@ -371,6 +481,7 @@ public class MrpWizPrsSaveBean
System.out.println("@@@@@ cnt ["+cnt2+"]::: sorder ["+saleOrder+"] alloc_flag [ Y ] updated sucessfully");
}
*/
}
......@@ -569,6 +680,37 @@ public class MrpWizPrsSaveBean
*/
}
// for sorder updation
if ( ( errString == null || errString.trim().length() == 0 ) && sorderList != null )
{
System.out.println("@@@@@@@@@@@ sorderList["+sorderList+"]");
String sorderArray[]=sorderList.split("@");
System.out.println("@@@@@ sorderArray.length["+sorderArray.length+"]");
for(int i=0;i<sorderArray.length;i++)
{
String tempSO=sorderArray[i];
System.out.println("@@@@@::: sorder ["+tempSO+"] updated next i["+i+"]....");
sql2 = " update sorder set alloc_flag = 'Y' where sale_order = ? ";
System.out.println("sql2 :"+sql2 );
pstmt2 = conn.prepareStatement(sql2);
pstmt2.setString(1,tempSO);
int cnt2 = pstmt2.executeUpdate();
pstmt2.close();
pstmt2 = null;
System.out.println("@@@@@ cnt ["+cnt2+"]::: sorder ["+tempSO+"] alloc_flag [ Y ] updated sucessfully");
}
}
//end
// end insertion logic
}//try end
catch (SQLException sqx)
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -285,11 +285,13 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
Boolean detail2Flag = false, detail4Flag=false;
String custCode="",custName="",quantity="",unit="",loginSiteCode="";
String orderType="";
String orderType="",mfgType="";
java.sql.Date orderDueDate=null, orderDate = null ;
String itemCodeOnlyList=""; // added 20/11/14 by cpatil
String locGroup="", locGroupList=""; // added on 12/01/12 by cpatil
try
{
conn = connDriver.getConnectDB("DriverITM");
......@@ -415,13 +417,17 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
+" and (sorder.cust_code = customer.cust_code ) "
+" and case when sorder.alloc_flag is null then 'N' else sorder.alloc_flag end <> 'Y' ";
*/
sql=" select a.sale_order,a.line_no,a.site_code,a.item_code,a.due_date,a.cust_code,a.cust_name,a.quantity,a.unit,a.type,a.order_due_date , a.order_date from ( " +
sql=" select a.sale_order,a.line_no,a.site_code,a.item_code,a.due_date,a.cust_code,a.cust_name," +
"a.quantity,a.unit,a.type,a.order_due_date , a.order_date ,a.mfg_type " +
" from ( " +
" SELECT sorditem.sale_order as sale_order,sorditem.line_no as line_no," +
" sorditem.site_code as site_code," +
" item.item_code__plan as item_code,sorditem.due_date as due_date," +
" sorder.cust_code as cust_code, customer.cust_name as cust_name ," +
" sorditem.quantity quantity,sorditem.unit unit,'SORD' as type " +
" ,sorder.due_date as order_due_date , sorder.order_date " +
//" sorditem.quantity quantity," +
" ((case when sorditem.quantity is null then 0 else sorditem.quantity end - case when sorditem.qty_alloc is null then 0 else sorditem.qty_alloc end - case when sorditem.qty_desp is null then 0 else sorditem.qty_desp end ) * case when sorditem.conv__qty_stdqty is null then 1 else sorditem.conv__qty_stdqty end ) as quantity , " +
" sorditem.unit unit,'SORD' as type " +
" ,sorder.due_date as order_due_date , sorder.order_date ,item.mfg_type " +
" FROM sorder,sorditem, item ,customer" +
" WHERE ( sorditem.item_code = item.item_code ) and" +
" (sorder.sale_order = sorditem.sale_order )" +
......@@ -434,6 +440,7 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
" and ( case when sorder.status is null then 'P' else sorder.status end = 'P')" +
" and (sorder.cust_code = customer.cust_code )" +
" and case when sorder.alloc_flag is null then 'N' else sorder.alloc_flag end <> 'Y' " ;
if("order_date".equalsIgnoreCase(viewByDate))
{
sql = sql + " and ( sorder.order_date >= ? ) and ( sorder.order_date <= ? ) ";
......@@ -452,7 +459,7 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
" item.item_code__plan as item_code,mps_order.due_date due_date,'' as " +
" cust_code,'' as cust_name, " +
" mps_order.quantity as quantity,item.unit,'MPS' as type " +
" ,mps_order.due_date as order_due_date , mps_order.ord_date as order_date " +
" ,mps_order.due_date as order_due_date , mps_order.ord_date as order_date ,item.mfg_type " +
" from mps_order,item where mps_order.item_code=item.item_code " +
" and ( case when mps_order.status is null then 'P' else " +
" mps_order.status end in ('P','T','M','N')) " + // added N in condition on 26/06/14
......@@ -528,7 +535,7 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
orderType = checkNull(rs.getString("type"));
orderDueDate = rs.getDate("order_due_date"); // added on 02-07-14
orderDate = rs.getDate("order_date");
mfgType = checkNull(rs.getString("mfg_type"));
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
String sysDate = sdf.format(orderDueDate);
System.out.println("Now the due date is ["+sysDate+"]");
......@@ -551,6 +558,9 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
valueXmlString.append( "<order_type><![CDATA[" ).append(orderType).append("]]></order_type>\r\n" );
valueXmlString.append( "<due_date><![CDATA[" ).append(sysDate).append("]]></due_date>\r\n" );
valueXmlString.append( "<order_date><![CDATA[" ).append(orderDate1).append("]]></order_date>\r\n" );
valueXmlString.append( "<loc_group><![CDATA[" ).append("").append("]]></loc_group>\r\n" );
valueXmlString.append( "<mfg_type><![CDATA[" ).append(mfgType).append("]]></mfg_type>\r\n" );
//valueXmlString.append( "<mfg_type><![CDATA[" ).append(getMfgType(mfgType)).append("]]></mfg_type>\r\n" );
valueXmlString.append( "</Detail2>\r\n" );
}
......@@ -576,7 +586,6 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
if(currentColumn.trim().equalsIgnoreCase("itm_default"))
{
siteCodeTo = genericUtility.getColumnValue("site_code__to",dom1);
siteCodeFr = genericUtility.getColumnValue("site_code__from",dom1);
System.out.println("siteCodeTo="+siteCodeTo+ " siteCodeFr ="+siteCodeFr);
......@@ -587,20 +596,35 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
{
saleOrder = checkNull(genericUtility.getColumnValueFromNode( "sale_order", detail2List.item(ctr1) ));
itemCode = checkNull(genericUtility.getColumnValueFromNode( "item_code", detail2List.item(ctr1) ));
System.out.println("sale_order=="+saleOrder+"itemCode=="+itemCode);
locGroup = checkNull(genericUtility.getColumnValueFromNode( "loc_group", detail2List.item(ctr1) ));
String dueDate = checkNull(genericUtility.getColumnValueFromNode( "due_date", detail2List.item(ctr1) ));
System.out.println("sale_order["+saleOrder+"]itemCode["+itemCode+"]locGroup["+locGroup+"]dueDate["+dueDate+"]");
System.out.println("ctr1=="+ctr1);
if(ctr1 > 0)
{
itemCodeList = itemCodeList + ",'"+saleOrder+itemCode+"'" ;
itemCodeOnlyList = itemCodeOnlyList + ",'"+itemCode+"'" ;
//locGroupList = locGroupList + ",'"+saleOrder+itemCode+"@"+locGroup+"'" ;
locGroupList = locGroupList + ","+checkNull(saleOrder).trim()+"@"+checkNull(locGroup).trim()+"" ;
}
else
{
itemCodeList = "'"+saleOrder+itemCode+"'" ;
itemCodeOnlyList = "'"+itemCode+"'" ;
//locGroupList = "'"+saleOrder+itemCode+"@"+locGroup+"'" ;
locGroupList = ""+checkNull(saleOrder).trim()+"@"+checkNull(locGroup).trim()+"" ;
}
System.out.println("itemCodeList=="+itemCodeList);
System.out.println("itemCodeOnlyList=="+itemCodeOnlyList);
System.out.println("locGroupList=="+locGroupList);
orderType= checkNull(genericUtility.getColumnValueFromNode( "order_type", detail2List.item(ctr1) ));
System.out.println("inside for orderType["+orderType+"]");
......@@ -660,6 +684,8 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
argData.append("<order_type>").append(orderType).append("</order_type>\r\n"); // added by cpatil on 17/05/14 for BomReplace
System.out.println("@@@@@@@@:: order_type["+orderType+"]");
argData.append("<locGroupList>").append(locGroupList).append("</locGroupList>\r\n");
argData.append("</Detail>");
argData.append("</Root>");
......@@ -679,7 +705,7 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
if( mrpGetData != null )
{
System.out.println("@@@@@@@@@ returning mrpGetData------------");
System.out.println("@@@@@@@@@ returning mrpGetData------------ ");
return mrpGetData;
}
......@@ -1032,7 +1058,20 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
return valueXmlString.toString();
}
/*
private String getMfgType(String mfgType)
{
String descr="";
if("O".equalsIgnoreCase(mfgType))
{
descr ="Made To Order";
}
return descr;
}
*/
private String setDescription(String field, String table,
String field2, String value,Connection conn) throws SQLException
{
......@@ -1167,6 +1206,81 @@ public class RunMRPWiz extends ValidatorEJB implements RunMRPWizLocal, RunMRPWiz
}
catch (Exception e)
{
e.printStackTrace();
System.out.println("Exception :BOM :getBOMCodeList(String,String):" + e.getMessage() + ":");
valueXmlString = valueXmlString.append(genericUtility.createErrorString(e));
}
finally
{
try
{
if (conn != null && !conn.isClosed())
{
conn.close();
conn = null;
}
}
catch (Exception e)
{
System.out.println("Exception :BOM :getBomCodeList(String,String) :==>\n"+ e.getMessage());
throw new ITMException(e);
}
}
valueXmlString.append("</Root>\r\n");
System.out.println("\n****ValueXmlString ::" + valueXmlString.toString() + ":********");
return valueXmlString.toString();
}
public String getOthersDetails( String othersDetails , String currentSOrder ) throws ITMException
{
System.out.println("getOthersDetails called---currentSOrder["+currentSOrder+"]othersDetails["+othersDetails+"]");
String sql = "";
String selectSql = "";
int detCnt=0;
double quantity=0,batchQty=0,batchReq=0;
StringBuffer valueXmlString = new StringBuffer("<Root>\r\n");
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
ConnDriver connDriver = new ConnDriver();
conn = connDriver.getConnectDB("DriverITM");
//int num = 1;
//if(itemCode == null || itemCode.trim().length() == 0)
//{
String[] othersDetailsInfo = othersDetails.split("~");
int domId = 0;
int len = othersDetailsInfo.length;
System.out.println("@@@cr len["+len+"]");
for( int i=0; i< len; i++)
{
String tempLine = othersDetailsInfo[i];
System.out.println("@@@@@@@@@ tempLine["+tempLine+"]");
String[] tempValue = tempLine.split("@");
if( tempValue[0] != null && !( checkNull(tempValue[0]).trim().equalsIgnoreCase(checkNull(currentSOrder).trim()) ) )
{
domId++;
///+saleOrder+"@"+lineNo+"@"+demand+"@"+dueDate;
valueXmlString.append("<OTHERSDETAILS domID='" + domId + "' selected = 'N'>\r\n");
valueXmlString.append("<SALE_ORDER protect = '1'>").append("<![CDATA[" + tempValue[0] + "]]>").append("</SALE_ORDER>\r\n");
valueXmlString.append("<LINE_NO protect = '1'>").append("<![CDATA[" + tempValue[1] + "]]>").append("</LINE_NO>\r\n");
valueXmlString.append("<DEMAND protect = '1'>").append("<![CDATA[" + tempValue[2] + "]]>").append("</DEMAND>\r\n");
valueXmlString.append("<DUE_DATE protect = '1'>").append("<![CDATA[" + tempValue[3] + "]]>").append("</DUE_DATE>\r\n");
valueXmlString.append("</OTHERSDETAILS>\r\n");
}
}
}
catch (Exception e)
{
......
......@@ -20,4 +20,5 @@ public interface RunMRPWizLocal extends ValidatorLocal
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String getBomCodeList( String itemCode , String siteCode, String dbID) throws RemoteException,ITMException;
public String getOthersDetails( String othersDetails , String currentSOrder ) throws RemoteException,ITMException;
}
......@@ -20,4 +20,5 @@ public interface RunMRPWizRemote extends ValidatorRemote
public String itemChanged(String xmlString, String xmlString1, String xmlString2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String itemChanged(Document dom, Document dom1, Document dom2, String objContext, String currentColumn, String editFlag, String xtraParams) throws RemoteException,ITMException;
public String getBomCodeList( String itemCode ,String siteCode, String dbID) throws RemoteException,ITMException;
public String getOthersDetails( String othersDetails , String currentSOrder ) throws RemoteException,ITMException;
}
package ibase.webitm.ejb.mfg;
import ibase.utility.*;
import ibase.system.config.*;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.mfg.RequirementICRemote;
import ibase.webitm.utility.*;
import javax.servlet.http.*;
import java.io.*;
import javax.naming.InitialContext;
public class RunMrpOthersDetails
{
private ibase.utility.UserInfoBean userInfo = null;
private HttpSession sessionCtx = null;
ITMWizardStatefulRemote itmWizardRemote = null;
private String objName = "";
private String user_lang ="en";
private String user_country = "US";
public RunMrpOthersDetails ( String objName, HttpSession sessionCtx ) throws ITMException
{
try
{
this.objName = objName;
this.sessionCtx = sessionCtx;
this.userInfo = ( ibase.utility.UserInfoBean ) this.sessionCtx.getAttribute("USER_INFO");
this.user_lang = this.userInfo.getUserLanguage();
this.user_country = this.userInfo.getUserCountry();
if( this.itmWizardRemote == null )
{
InitialContext ctx = new InitialContext( new AppConnectParm().getProperty() );
this.itmWizardRemote = (ibase.webitm.ejb.ITMWizardStatefulRemote)ctx.lookup("ibase/ITMWizardStatefulEJB/remote");
this.itmWizardRemote.setUserInfo( this.userInfo );
this.itmWizardRemote.loadFormsMetaData( this.objName, "1", this.objName+"21", this.userInfo.getEmpCode(), this.userInfo.getProfileId() );
}
}
catch (ITMException itme)
{
itmWizardRemote.remove();
itmWizardRemote = null;
throw itme;
}
catch (Exception e)
{
itmWizardRemote.remove();
itmWizardRemote = null;
throw new ITMException(e);
}
}
public RunMrpOthersDetails () throws ITMException
{
}
//get item code pop help
public String getOthersDetails( String othersDetails , String currentSorder) throws ITMException
{
String OthersDetailsData = "";
RunMRPWizRemote runMRPWizRemote = null;
try
{
InitialContext ctx = new InitialContext( new AppConnectParm().getProperty() );
runMRPWizRemote = (ibase.webitm.ejb.mfg.RunMRPWizRemote)ctx.lookup("ibase/RunMRPWiz/remote");
OthersDetailsData = runMRPWizRemote.getOthersDetails(othersDetails , currentSorder);
runMRPWizRemote = null;
System.out.println("OthersDetailsData=="+OthersDetailsData);
String xslFileName = getXSLFileName( "mrp_others_details_wiz_" + this.user_lang + "_" + this.user_country + ".xsl" );
//String xslFileName = getXSLFileName( "requirement_item_code_wiz_en_US.xsl" );
OthersDetailsData = ( new ibase.webitm.utility.GenericUtility() ).transformToString( xslFileName, OthersDetailsData, CommonConstants.APPLICATION_CONTEXT + File.separator + "temp", "Output", ".html" );
System.out.println("OthersDetailsData==="+OthersDetailsData);
}
catch ( Exception e )
{
throw new ITMException(e);
}
finally
{
if ( runMRPWizRemote != null )
{
runMRPWizRemote = null;
}
}
return OthersDetailsData;
}
private String getXSLFileName( String xslFileName )throws ITMException
{
String retFileName = null;
try
{
String defaultPath = null;
if( CommonConstants.APPLICATION_CONTEXT != null )
{
defaultPath = CommonConstants.APPLICATION_CONTEXT + CommonConstants.ITM_CONTEXT + File.separator;
}
else
{
defaultPath = ".." + File.separator + "webapps" + File.separator + "ibase" + File.separator + CommonConstants.ITM_CONTEXT + File.separator;
}
File xslPath = new File( defaultPath + File.separator + "xsl" + File.separator + CommonConstants.THEME + File.separator + "WIZARD");
if ( !xslPath.exists() )
{
xslPath.mkdir();
}
System.out.println( " xslPath [" + xslPath +"] xslFileName ["+xslFileName +"]");
File xslFile = new File(xslPath , xslFileName);
if( xslFile.exists() )
{
retFileName = xslFile.getAbsolutePath();
}
else
{
throw new ITMException( new Exception( retFileName + " Wizard XSL file Not Found") );
}
}
catch (Exception e)
{
throw new ITMException(e);
}
return retFileName;
}
}
......@@ -33,6 +33,8 @@ public class TimeMRP
//end added by sabyasachi 17.03.2011
boolean createDemand = false;
String saleOrder="";
double orderDemand=0;
public TimeMRP()
{
......@@ -54,12 +56,21 @@ public class TimeMRP
//changed method arguments by sabyasachi 29-03-2011
//public void setDemand(double demand,String saleOrder, String lineNo)
public void setDemand(double demand)
{
this.demand += demand;
//this.saleOrder = saleOrder;
//this.lineNo = lineNo;
}
public void setOrderDemand(double orderDemand)
{
this.orderDemand=orderDemand;
}
public double setOrderDemand()
{
return this.orderDemand;
}
//changed method definition by sabyasachi 29-03-2011 end
public double getDemand()
......
select item_code, due_date, round(sum(demand),0) demand, sum(supply) supply , sum(stock_qty) stock_qty, sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr,tran_id,tran_ser ,site_code from
(
SELECT a.site_code||'@'||d.item_code||'@'||a.lot_no||'@'||a.lot_sl||'@'||a.loc_code||'@'||(case when c.alloc_pref is null then 'X' else c.alloc_pref end) as tran_id,
'Stock' as tran_ser, d.item_code__plan as item_code,
FN_MRP_DUEDATE(timestamp('@fromdate@-00.00.00')) as due_date,
0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , a.site_code
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> @ordtypes@
and ( a.site_code || d.item_code__plan ) IN ( '@itemcode@' )
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
) alias
group by item_code,due_date ,tran_id,tran_ser,site_code
having sum(supply) <> 0
select item_code, due_date, 0 demand, sum(supply) supply , sum(stock_qty) stock_qty, sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr,tran_id,tran_ser ,site_code from
(
SELECT a.site_code||'@'||d.item_code||'@'||a.lot_no||'@'||a.lot_sl||'@'||a.loc_code||'@'||(case when c.alloc_pref is null then 'X' else c.alloc_pref end) as tran_id,
'Stock' as tran_ser, d.item_code__plan as item_code,
FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , a.site_code
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> @ordtypes@
and ( a.site_code || d.item_code__plan ) IN ( '@itemcode@' )
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
) alias
group by item_code,due_date ,tran_id,tran_ser,site_code
having sum(supply) <> 0
select item_code, due_date, round(sum(demand),0) demand, sum(supply) supply , sum(stock_qty) stock_qty, sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr,tran_id,tran_ser ,site_code from
(
SELECT independent_demand.tran_id,'I-REQ' as tran_ser,item.item_code__plan as item_code,independent_demand.due_date as due_date, sum(case when independent_demand.quantity__std_uom is null then 0 else independent_demand.quantity__std_uom end)
as demand, 0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , independent_demand.site_code
FROM independent_demand, item
WHERE ( independent_demand.item_code = item.item_code ) and
( independent_demand.site_code || item.item_code__plan ) IN ( '@itemcode@' ) AND
( independent_demand.due_date >= timestamp('@fromdate@-00.00.00')) AND
( independent_demand.due_date <= timestamp('@todate@-00.00.00')) and
( case when independent_demand.status is null then 'C' else independent_demand.status end <> 'P')
Group By independent_demand.tran_id,'I-REQ',item.item_code__plan,independent_demand.due_date , independent_demand.site_code
UNION ALL
SELECT sales_demand.tran_id,'S-FCT' as tran_ser,item.item_code__plan as item_code, sales_demand.due_date as due_date,
sum(case when sales_demand.quantity__std_uom is null then 0 else sales_demand.quantity__std_uom end - case
when sales_demand.consumed_qty is null then 0 else sales_demand.consumed_qty end ) as demand, 0 as supply ,
0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , sales_demand.site_code
FROM sales_demand, item
WHERE ( sales_demand.item_code = item.item_code ) and
( sales_demand.site_code || sales_demand.item_code ) IN ( '@itemcode@' ) AND
( sales_demand.due_date >= timestamp('@fromdate@-00.00.00')) AND
( sales_demand.due_date <= timestamp('@todate@-00.00.00')) AND ( 0 = @madetostock@)
Group By sales_demand.tran_id,'S-FCT',item.item_code__plan,sales_demand.due_date , sales_demand.site_code
UNION ALL
SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id,'Dist Order' as tran_ser,
item.item_code__plan as item_code,
distorder_det.due_date as due_date,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as pending_do,
0 as pending_indent, 0 as pending_dr , distorder.site_code__ship as site_code
FROM distorder,distorder_det, item
WHERE ( distorder_det.item_code = item.item_code ) and
( distorder.dist_order = distorder_det.dist_order ) and
( distorder.confirmed = 'Y' ) and
( distorder.site_code__ship || distorder_det.item_code ) IN ( '@itemcode@' ) AND
( distorder_det.due_date <= timestamp('@todate@-00.00.00')) and
( distorder.order_type not in (@ordtypes@) ) and
( case when distorder.status is null then 'P' else distorder.status end = 'P') AND
( case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) > 0
Group By distorder.dist_order||'@'||distorder_det.line_no,'Dist Order',item.item_code__plan,distorder_det.due_date , distorder.site_code__ship
UNION ALL
SELECT sorder.sale_order||'@'||sorditem.line_no tran_id,'S-ITEM' as tran_ser,
item.item_code__plan as item_code, sorditem.due_date as due_date,
sum((case when sorditem.quantity is null then 0 else sorditem.quantity end - case when sorditem.qty_alloc is null then 0 else sorditem.qty_alloc end - case when sorditem.qty_desp is null then 0 else sorditem.qty_desp end ) * case when sorditem.conv__qty_stdqty is null then 1 else sorditem.conv__qty_stdqty end ) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do,
0 as pending_indent, 0 as pending_dr , sorditem.site_code
FROM sorder,sorditem, item
WHERE
( sorditem.item_code = item.item_code ) and
( sorder.sale_order = sorditem.sale_order ) and
( case when sorder.confirmed is null then 'N' else sorder.confirmed end = 'Y' ) and
( case when sorditem.consume_fc is null then 'Y' else sorditem.consume_fc end = 'N' ) and
( sorditem.site_code || sorditem.item_code ) IN ( '@itemcode@' ) AND
( sorditem.due_date <= timestamp('@todate@-00.00.00')) and
( case when sorder.status is null then 'P' else sorder.status end = 'P') and
( sorder.order_type not in (@ordtypes@) ) and ( 0 = @madetostock@)
Group By sorder.sale_order||'@'||sorditem.line_no ,'S-ITEM',
item.item_code__plan,sorditem.due_date , sorditem.site_code
UNION ALL
SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id,'Dist Order' as tran_ser,item.item_code__plan as item_code, distorder_det.due_date as due_date,
0 as demand,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) as supply,
0 as stock_qty, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) as oth_supply,
0 as pending_po, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as pending_do,
0 as pending_indent, 0 as pending_dr , distorder.site_code__dlv as site_code
FROM distorder,distorder_det, item
WHERE ( distorder_det.item_code = item.item_code )
and ( distorder.dist_order = distorder_det.dist_order )
and ( distorder.confirmed = 'Y' )
and ( distorder.site_code__dlv || distorder_det.item_code ) IN ( '@itemcode@' )
AND ( distorder_det.due_date <= timestamp('@todate@-00.00.00'))
and ( distorder.order_type not in (@ordtypes@) )
and ( case when distorder.status is null then 'P' else distorder.status end = 'P')
AND (case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) > 0
Group By distorder.dist_order||'@'||distorder_det.line_no,'Dist Order',item.item_code__plan,distorder_det.due_date , distorder.site_code__dlv
UNION ALL
SELECT porder.purc_order||'@'||porddet.line_no as tran_id,'Purchase Order' as tran_ser,item.item_code__plan as item_code, porddet.dlv_date as due_date,
0 as demand ,
sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0
else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0
else porddet.dlv_qty end end ) as supply ,
0 as stock_qty, sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end end ) as oth_supply, sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end end ) as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr, porddet.site_code
FROM porddet,porder, item
WHERE ( porddet.item_code = item.item_code )
and (porddet.purc_order = porder.purc_order )
and (porder.confirmed = 'Y')
and (porder.status not in('C','X'))
and (porddet.status not in('C','X'))
and ( porddet.site_code || porddet.item_code ) IN ( '@itemcode@' )
and ( porder.pord_type not in (@ordtypes@) )
and ( porddet.dlv_date <= timestamp('@todate@-00.00.00'))
Group By porder.purc_order||'@'||porddet.line_no,'Purchase Order',item.item_code__plan,porddet.dlv_date , porddet.site_code
UNION ALL
SELECT a.site_code||'@'||d.item_code||'@'||a.lot_no||'@'||a.lot_sl||'@'||a.loc_code||'@'||(case when c.alloc_pref is null then 'X' else c.alloc_pref end) as tran_id,
'Stock' as tran_ser, d.item_code__plan as item_code,
FN_MRP_DUEDATE(timestamp('@fromdate@-00.00.00')) as due_date,
0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , a.site_code
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> @ordtypes@
and ( a.site_code || d.item_code__plan ) IN ( '@itemcode@' )
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
UNION ALL
SELECT workorder.work_order||'@'||'1' as tran_id,'Work Order' as tran_ser,item.item_code__plan as item_code,
timestamp('@fromdate@-00.00.00') as due_date,
0 as demand,sum((case when workorder.current_batch_qty is null then 0 else workorder.current_batch_qty end * case when workorder.yield_perc is null then 100 else workorder.yield_perc end / 100 ) - case when workorder.quantity__rcvd is null then 0 else workorder.quantity__rcvd end ) as supply,
0 as stock_qty, sum((case when workorder.current_batch_qty is null then 0 else workorder.current_batch_qty end * case when workorder.yield_perc is null then 100 else workorder.yield_perc end / 100 ) - case when workorder.quantity__rcvd is null then 0 else workorder.quantity__rcvd end ) as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , workorder.site_code
FROM workorder, item
WHERE ( workorder.item_code = item.item_code )
and ( workorder.site_code || workorder.item_code ) IN ( '@itemcode@' )
AND ( workorder.due_date <= timestamp('@todate@-00.00.00'))
AND workorder.SALE_ORDER IS NULL
AND (case when workorder.status is null then 'P' else workorder.status end in ('R','F'))
and (case when workorder.consider_wip is null then 'O' else workorder.consider_wip end = 'O')
Group By workorder.work_order||'@'||'1','Work Order',item.item_code__plan, timestamp('@fromdate@-00.00.00') , workorder.site_code
UNION ALL
SELECT workorder_bill.work_order||'@'||'1' as tran_id,case when rtrim(siteitem.supp_sour) = 'M' then 'Work Order' when rtrim(siteitem.supp_sour) = 'P' then 'Indent' else '???' end as tran_ser, workorder_bill.item_code as item_code, timestamp('@fromdate@-00.00.00') as due_date,
sum( case when workorder_bill.QUANTITY is null then 0 else workorder_bill.QUANTITY end - case when (case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end - case when workorder_bill.ISS_QTY is null then 0
else workorder_bill.ISS_QTY end) < 0 then case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end else case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end end ) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , workorder.site_code
from workorder_bill, workorder, item, siteitem
where workorder_bill.work_order = workorder.work_order
and workorder_bill.item_code = item.item_code
and workorder_bill.line_type <> 'B'
and workorder_bill.item_code = siteitem.item_code
and workorder.site_code = siteitem.site_code
and case when workorder_bill.QUANTITY is null then 0
else workorder_bill.QUANTITY end - case when (case when workorder_bill.ALLOC_QTY is null then 0
else workorder_bill.ALLOC_QTY end - case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end)<0
then ( case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end)
else (case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end) end > 0
and workorder.work_order in ( SELECT workorder.work_order FROM workorder WHERE
( workorder.site_code || workorder.item_code ) IN ( '@itemcode@' )
AND (workorder.due_date <= timestamp('@todate@-00.00.00'))
AND workorder.SALE_ORDER IS NULL
AND (case when workorder.status is null then 'P' else workorder.status end in ('R','F'))
and (case when workorder.consider_wip is null then 'O' else workorder.consider_wip end = 'O') )
Group By workorder_bill.work_order,case when rtrim(siteitem.supp_sour) = 'M' then 'Work Order' when rtrim(siteitem.supp_sour) = 'P' then 'Indent' else '???' end,workorder_bill.item_code, timestamp('@fromdate@-00.00.00') , workorder.site_code
) alias
group by item_code,due_date ,tran_id,tran_ser,site_code
having sum(demand) <> 0 or sum(supply) <> 0
select item_code, due_date, 0 demand, sum(supply) supply , sum(stock_qty) stock_qty, sum(oth_supply) oth_supply, sum(pending_po) pending_po ,sum(pending_do) pending_do, sum(pending_indent) pending_indent, sum(pending_dr) pending_dr,tran_id,tran_ser ,site_code from
(
SELECT independent_demand.tran_id,'I-REQ' as tran_ser,item.item_code__plan as item_code,independent_demand.due_date as due_date, sum(case when independent_demand.quantity__std_uom is null then 0 else independent_demand.quantity__std_uom end)
as demand, 0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , independent_demand.site_code
FROM independent_demand, item
WHERE ( independent_demand.item_code = item.item_code ) and
( independent_demand.site_code || item.item_code__plan ) IN ( '@itemcode@' ) AND
( independent_demand.due_date >= to_date('@fromdate@')) AND
( independent_demand.due_date <= to_date('@todate@')) and
( case when independent_demand.status is null then 'C' else independent_demand.status end <> 'P')
Group By independent_demand.tran_id,'I-REQ',item.item_code__plan,independent_demand.due_date , independent_demand.site_code
UNION ALL
SELECT sales_demand.tran_id,'S-FCT' as tran_ser,item.item_code__plan as item_code, sales_demand.due_date as due_date,
sum(case when sales_demand.quantity__std_uom is null then 0 else sales_demand.quantity__std_uom end - case
when sales_demand.consumed_qty is null then 0 else sales_demand.consumed_qty end ) as demand, 0 as supply ,
0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , sales_demand.site_code
FROM sales_demand, item
WHERE ( sales_demand.item_code = item.item_code ) and
( sales_demand.site_code || sales_demand.item_code ) IN ( '@itemcode@' ) AND
( sales_demand.due_date >= to_date('@fromdate@')) AND
( sales_demand.due_date <= to_date('@todate@')) AND ( 0 = @madetostock@)
Group By sales_demand.tran_id,'S-FCT',item.item_code__plan,sales_demand.due_date , sales_demand.site_code
UNION ALL
SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id,'Dist Order' as tran_ser,
item.item_code__plan as item_code,
distorder_det.due_date as due_date,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as pending_do,
0 as pending_indent, 0 as pending_dr , distorder.site_code__ship as site_code
FROM distorder,distorder_det, item
WHERE ( distorder_det.item_code = item.item_code ) and
( distorder.dist_order = distorder_det.dist_order ) and
( distorder.confirmed = 'Y' ) and
( distorder.site_code__ship || distorder_det.item_code ) IN ( '@itemcode@' ) AND
( distorder_det.due_date <= to_date('@todate@')) and
( distorder.order_type not in (@ordtypes@) ) and
( case when distorder.status is null then 'P' else distorder.status end = 'P') AND
( case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) > 0
Group By distorder.dist_order||'@'||distorder_det.line_no,'Dist Order',item.item_code__plan,distorder_det.due_date , distorder.site_code__ship
UNION ALL
SELECT sorder.sale_order||'@'||sorditem.line_no tran_id,'S-ITEM' as tran_ser,
item.item_code__plan as item_code, sorditem.due_date as due_date,
sum((case when sorditem.quantity is null then 0 else sorditem.quantity end - case when sorditem.qty_alloc is null then 0 else sorditem.qty_alloc end - case when sorditem.qty_desp is null then 0 else sorditem.qty_desp end ) * case when sorditem.conv__qty_stdqty is null then 1 else sorditem.conv__qty_stdqty end ) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do,
0 as pending_indent, 0 as pending_dr , sorditem.site_code
FROM sorder,sorditem, item
WHERE
( sorditem.item_code = item.item_code ) and
( sorder.sale_order = sorditem.sale_order ) and
( case when sorder.confirmed is null then 'N' else sorder.confirmed end = 'Y' ) and
( case when sorditem.consume_fc is null then 'Y' else sorditem.consume_fc end = 'N' ) and
( sorditem.site_code || sorditem.item_code ) IN ( '@itemcode@' ) AND
( sorditem.due_date <= to_date('@todate@')) and
( case when sorder.status is null then 'P' else sorder.status end = 'P') and
( sorder.order_type not in (@ordtypes@) ) and ( 0 = @madetostock@)
Group By sorder.sale_order||'@'||sorditem.line_no ,'S-ITEM',
item.item_code__plan,sorditem.due_date , sorditem.site_code
UNION ALL
SELECT distorder.dist_order||'@'||distorder_det.line_no tran_id,'Dist Order' as tran_ser,item.item_code__plan as item_code, distorder_det.due_date as due_date,
0 as demand,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) as supply,
0 as stock_qty, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) as oth_supply,
0 as pending_po, sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as pending_do,
0 as pending_indent, 0 as pending_dr , distorder.site_code__dlv as site_code
FROM distorder,distorder_det, item
WHERE ( distorder_det.item_code = item.item_code )
and ( distorder.dist_order = distorder_det.dist_order )
and ( distorder.confirmed = 'Y' )
and ( distorder.site_code__dlv || distorder_det.item_code ) IN ( '@itemcode@' )
AND ( distorder_det.due_date <= to_date('@todate@'))
and ( distorder.order_type not in (@ordtypes@) )
and ( case when distorder.status is null then 'P' else distorder.status end = 'P')
AND (case when qty_confirm is null then 0 else qty_confirm end - case when qty_received is null then 0 else qty_received end ) > 0
Group By distorder.dist_order||'@'||distorder_det.line_no,'Dist Order',item.item_code__plan,distorder_det.due_date , distorder.site_code__dlv
UNION ALL
SELECT porder.purc_order||'@'||porddet.line_no as tran_id,'Purchase Order' as tran_ser,item.item_code__plan as item_code, porddet.dlv_date as due_date,
0 as demand ,
sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0
else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0
else porddet.dlv_qty end end ) as supply ,
0 as stock_qty, sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end end ) as oth_supply, sum(case when (case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end) < 0 then 0 else case when porddet.quantity__stduom is null then 0 else porddet.quantity__stduom end - case when porddet.dlv_qty is null then 0 else porddet.dlv_qty end end ) as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr, porddet.site_code
FROM porddet,porder, item
WHERE ( porddet.item_code = item.item_code )
and (porddet.purc_order = porder.purc_order )
and (porder.confirmed = 'Y')
and (porder.status not in('C','X'))
and (porddet.status not in('C','X'))
and ( porddet.site_code || porddet.item_code ) IN ( '@itemcode@' )
and ( porder.pord_type not in (@ordtypes@) )
and ( porddet.dlv_date <= to_date('@todate@'))
Group By porder.purc_order||'@'||porddet.line_no,'Purchase Order',item.item_code__plan,porddet.dlv_date , porddet.site_code
UNION ALL
SELECT a.site_code||'@'||d.item_code||'@'||a.lot_no||'@'||a.lot_sl||'@'||a.loc_code||'@'||(case when c.alloc_pref is null then 'X' else c.alloc_pref end) as tran_id,
'Stock' as tran_ser, d.item_code__plan as item_code,
FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , a.site_code
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> @ordtypes@
and ( a.site_code || d.item_code__plan ) IN ( '@itemcode@' )
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
UNION ALL
SELECT workorder.work_order||'@'||'1' as tran_id,'Work Order' as tran_ser,item.item_code__plan as item_code,
to_date('@fromdate@') as due_date,
0 as demand,sum((case when workorder.current_batch_qty is null then 0 else workorder.current_batch_qty end * case when workorder.yield_perc is null then 100 else workorder.yield_perc end / 100 ) - case when workorder.quantity__rcvd is null then 0 else workorder.quantity__rcvd end ) as supply,
0 as stock_qty, sum((case when workorder.current_batch_qty is null then 0 else workorder.current_batch_qty end * case when workorder.yield_perc is null then 100 else workorder.yield_perc end / 100 ) - case when workorder.quantity__rcvd is null then 0 else workorder.quantity__rcvd end ) as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , workorder.site_code
FROM workorder, item
WHERE ( workorder.item_code = item.item_code )
and ( workorder.site_code || workorder.item_code ) IN ( '@itemcode@' )
AND ( workorder.due_date <= to_date('@todate@'))
AND workorder.SALE_ORDER IS NULL
AND (case when workorder.status is null then 'P' else workorder.status end in ('R','F'))
and (case when workorder.consider_wip is null then 'O' else workorder.consider_wip end = 'O')
Group By workorder.work_order||'@'||'1','Work Order',item.item_code__plan, to_date('@fromdate@') , workorder.site_code
UNION ALL
SELECT workorder_bill.work_order||'@'||'1' as tran_id,case when rtrim(siteitem.supp_sour) = 'M' then 'Work Order' when rtrim(siteitem.supp_sour) = 'P' then 'Indend' else '???' end as tran_ser, workorder_bill.item_code as item_code, to_date('@fromdate@') as due_date,
sum( case when workorder_bill.QUANTITY is null then 0 else workorder_bill.QUANTITY end - case when (case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end - case when workorder_bill.ISS_QTY is null then 0
else workorder_bill.ISS_QTY end) < 0 then case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end else case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end end ) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr , workorder.site_code
from workorder_bill, workorder, item, siteitem
where workorder_bill.work_order = workorder.work_order
and workorder_bill.item_code = item.item_code
and workorder_bill.line_type <> 'B'
and workorder_bill.item_code = siteitem.item_code
and workorder.site_code = siteitem.site_code
and case when workorder_bill.QUANTITY is null then 0
else workorder_bill.QUANTITY end - case when (case when workorder_bill.ALLOC_QTY is null then 0
else workorder_bill.ALLOC_QTY end - case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end)<0
then ( case when workorder_bill.ISS_QTY is null then 0 else workorder_bill.ISS_QTY end)
else (case when workorder_bill.ALLOC_QTY is null then 0 else workorder_bill.ALLOC_QTY end) end > 0
and workorder.work_order in ( SELECT workorder.work_order FROM workorder WHERE
( workorder.site_code || workorder.item_code ) IN ( '@itemcode@' )
AND (workorder.due_date <= to_date('@todate@'))
AND workorder.SALE_ORDER IS NULL
AND (case when workorder.status is null then 'P' else workorder.status end in ('R','F'))
and (case when workorder.consider_wip is null then 'O' else workorder.consider_wip end = 'O') )
Group By workorder_bill.work_order,case when rtrim(siteitem.supp_sour) = 'M' then 'Work Order' when rtrim(siteitem.supp_sour) = 'P' then 'Indend' else '???' end,workorder_bill.item_code, to_date('@fromdate@') , workorder.site_code
) alias
group by item_code,due_date ,tran_id,tran_ser,site_code
having sum(demand) <> 0 or sum(supply) <> 0
......@@ -37,6 +37,21 @@
( sales_demand.due_date <= to_date('@todate@')) AND
( 0 = @madetostock@ )
Group By item.item_code__plan,sales_demand.due_date
UNION ALL
SELECT item.item_code__plan as item_code,invtrace.tran_date as due_date,
sum(invtrace.eff_qty) as demand,
0 as supply , 0 as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM invtrace, item, location, invstat
WHERE ( invtrace.item_code = item.item_code ) and
( location.loc_code = invtrace.loc_code) and
( invstat.inv_stat = location.inv_stat) and
( invstat.stat_type <> 'S' ) and
( invtrace.site_code in ('@sitecode@') ) AND
( item.item_code__plan = '@itemcode@') AND
( invtrace.tran_date >= to_date('@fromdate@')) and
( invtrace.tran_date <= to_date('@rundate@')) and
( invtrace.ref_ser in ('D-ISS','S-DSP') )
Group By item.item_code__plan,invtrace.tran_date
UNION ALL
SELECT item.item_code__plan as item_code,distorder_det.due_date as due_date,
sum(case when qty_confirm is null then 0 else qty_confirm end - case when qty_shipped is null then 0 else qty_shipped end) as demand,
......@@ -113,14 +128,37 @@ FROM indent,item
( porder.pord_type not in (@ordtypes@) ) and
( porddet.dlv_date <= to_date('@todate@'))
Group By item.item_code__plan,porddet.dlv_date
UNION ALL
SELECT item.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,
0 as demand ,
DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) as supply,
DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) as stock_qty, 0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM item
WHERE item.item_code__plan= '@itemcode@'
and DDF_INV_CLSTK_MRP('@sitecode@',item.item_code,to_date(fn_sysdate())) > 0
UNION ALL
select item_code,due_date,sum(demand) demand,sum(supply) supply,sum(stock_qty) stock_qty,
sum(oth_supply) oth_supply,sum(pending_po) pending_po,sum(pending_do) pending_do,sum(pending_indent) pending_indent,
sum(pending_dr) pending_dr from
( SELECT d.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,0 as demand,
(a.quantity-a.alloc_qty) as supply,(a.quantity-a.alloc_qty) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM STOCK a, INVSTAT b , LOCATION c,item d
WHERE a.loc_code = c.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(b.stat_type, ' ') <> 'S'
AND a.site_code = '@sitecode@'
AND a.item_code = '@itemcode@'
AND NVL(b.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
UNION ALL
SELECT d.item_code__plan as item_code,FN_MRP_DUEDATE(to_date('@fromdate@')) as due_date,0 as demand,
NVL((eff_qty * -1),0) as supply,NVL((eff_qty * -1),0) as stock_qty,
0 as oth_supply, 0 as pending_po, 0 as pending_do, 0 as pending_indent, 0 as pending_dr
FROM INVTRACE a, LOCATION b, INVSTAT c,item d
WHERE a.loc_code = b.loc_code
AND b.inv_stat = c.inv_stat
AND NVL(c.stat_type, ' ') <> 'S'
AND a.item_code = '@itemcode@'
AND a.site_code = '@sitecode@'
AND NVL(c.plan_prod,'N') = 'Y'
AND a.item_code=d.item_code
AND a.EFF_date > to_date(fn_sysdate())) group by item_code,due_date
UNION ALL
SELECT item.item_code__plan as item_code,to_date('@fromdate@') as due_date,
0 as demand,
......
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