Commit 20ecb411 authored by cpatil's avatar cpatil

modify for allocation while click on finish


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@95281 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 6af25e94
......@@ -15,6 +15,7 @@ import ibase.utility.CommonConstants;
import ibase.webitm.ejb.*;
import ibase.webitm.ejb.dis.InvAllocTrace;
import ibase.webitm.ejb.dis.InvAllocTraceBean;
import ibase.webitm.ejb.dis.StockAllocationPrc;
import ibase.webitm.ejb.dis.StockAllocationPrc.*;
import ibase.webitm.ejb.dis.StockUpdate;
......@@ -56,14 +57,13 @@ public class MrpWizPrsSaveBean
private String executepreSaveForm(Document dom , String chgUser , String chgTerm )throws ITMException
{
PreparedStatement pstmt = null;
String sql = "", itemCode = "", effDate = "", itemSer = "";
PreparedStatement pstmt = null, pstmt1 = null;
String sql = "", itemCode = "", effDate = "", itemSer = "", sql1="";
int updCnt = 0;
//java.util.Date effDate1 = null, preDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
NodeList hdrDom = null;
//Node currDetail = null;
ResultSet rs1 = null;
String saleOrder=" ",lineNo=" ", siteCode=" ", lotNo=" ", locCode="", lotSl=" ", tranSer="", runningSupplyStr="", qtyReqdStr="",allocQtyStr="";
double runningSupply=0,qtyReqd=0;
String tranId="",refId="",refLineNo="",unit="",errString="";
......@@ -71,12 +71,23 @@ public class MrpWizPrsSaveBean
int cnt=0;
Connection conn = null;
ConnDriver connDriver = new ConnDriver();
String supplyStr="",availableSupplyStr="";
String supplyStr="",availableSupplyStr="" ,suppSour="",remarks=" ";
InvAllocTrace invallocTrace = new InvAllocTrace();
StockAllocationPrc stockAllocationPrc = new StockAllocationPrc() ;
InvAllocTraceBean invAllocTrace = null;
ArrayList retValue = new ArrayList();
HashMap invAllocateMap = new HashMap ();
HashMap invAllocDetMap = new HashMap ();
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="";
//String chgUser =" " , chgTerm = " ";
StockAllocationPrc stockAllocationPrc = new StockAllocationPrc() ;
ArrayList itemValueList = new ArrayList();
try
{
......@@ -97,10 +108,10 @@ public class MrpWizPrsSaveBean
for (int cntr = 0; cntr < detail4List.getLength(); cntr++)
{
Node detail4Node = detail4List.item(cntr);
NodeList detail4NodeList = detail4Node.getChildNodes();
System.out.println("@@@@@@@@@refrenceNode ["+detail4NodeList.getLength()+"]node name[" + detail4Node.getNodeName()+"]");
//NodeList detail4NodeList = detail4Node.getChildNodes();
System.out.println("@@@@@@@@@node name[" + detail4Node.getNodeName()+"]");
if( detail4Node != null && detail4Node.getNodeValue() != null )
// if( detail4Node != null && detail4Node.getNodeValue() != null )
{
if("sale_order".equalsIgnoreCase( detail4Node.getNodeName()))
{
......@@ -154,12 +165,37 @@ public class MrpWizPrsSaveBean
{
availableSupplyStr = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("supp_sour".equalsIgnoreCase( detail4Node.getNodeName()))
{
suppSour = detail4List.item(cntr).getFirstChild().getNodeValue();
}
if("parent_item".equalsIgnoreCase( detail4Node.getNodeName()))
{
parentItem = detail4List.item(cntr).getFirstChild().getNodeValue();
}
}
}
System.out.println("@@@@ctr["+dtlCtr+"]saleOrder["+saleOrder+"]-lineNo["+lineNo+"]-qtyReqd["+qtyReqdStr+"]@@@");
System.out.println("@@@@ctr["+dtlCtr+"]siteCode["+siteCode+"]-itemCode["+itemCode+"]-lotNo["+lotNo+"]-lotSl["+lotSl+"]-locCode["+locCode+"]-tranSer["+tranSer+"]allocQtyStr["+allocQtyStr+"]@@@");
String itemCodeHdr="";
remarks = "From mrp process";
sql1=" select item_code from sorddet where sale_order = ? and line_no = ? ";
pstmt1=conn.prepareStatement(sql1);
pstmt1.setString(1,saleOrder);
pstmt1.setString(2,lineNo);
rs1 = pstmt1.executeQuery();
if(rs1.next())
{
itemCodeHdr =rs1.getString("item_code");
}
rs1.close();
rs1=null;
pstmt1.close();
pstmt1=null;
if( runningSupplyStr.trim().length() > 0)
{
runningSupply = runningSupplyStr==null?0:Double.parseDouble(runningSupplyStr);
......@@ -174,13 +210,11 @@ public class MrpWizPrsSaveBean
allocQty = allocQtyStr==null?0:Double.parseDouble(allocQtyStr);
}
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());
if(itemCodeHdr.equalsIgnoreCase(itemCode))
{
invallocTrace.setRefSer("MRPWIZ");
InvAllocTrace invallocTrace = new InvAllocTrace();
invallocTrace.setRefSer("S-ORD");
invallocTrace.setRefId(saleOrder);
invallocTrace.setRefLine(lineNo);
invallocTrace.setSiteCode(siteCode);
......@@ -192,7 +226,6 @@ public class MrpWizPrsSaveBean
invallocTrace.setChgUser(chgUser);
invallocTrace.setChgTerm(chgTerm);
invallocTrace.setChgDate( date );
//invallocTrace.setChgWin("W_SORDALLOC" );
errString = stockAllocationPrc.updateInvallocTrace(invallocTrace, conn);
......@@ -203,8 +236,298 @@ public class MrpWizPrsSaveBean
return errString;
}
}
else
{
String tranType = "AUT";
tranId = generateTranId( "w_inv_allocate",siteCode, conn );
sql = " insert into inv_allocate ( TRAN_ID,TRAN_DATE,TRAN_TYPE,WORK_ORDER,SITE_CODE,ITEM_CODE," +
" CHG_DATE,CHG_USER,CHG_TERM,REMARKS,CONFIRMED,CONF_DATE,STATUS,STATUS_DATE )" +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
System.out.println("header sql :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setDate(2,date); // TRAN_DATE
pstmt.setString(3, tranType); // TRAN_TYPE VARCHAR2(3)
pstmt.setString(4, " "); // WORK_ORDER CHAR(10)
pstmt.setString(5, siteCode); // SITE_CODE CHAR(5)
pstmt.setString(6, itemCodeHdr); // ITEM_CODE CHAR(10)
pstmt.setDate(7, date); //CHG_DATE DATE
pstmt.setString(8, chgUser); //CHG_USER CHAR(10)
pstmt.setString(9, chgTerm ); // CHG_TERM CHAR(15)
pstmt.setString(10, remarks); //REMARKS VARCHAR2(40)
pstmt.setString(11, "Y"); //CONFIRMED CHAR(1)
pstmt.setDate(12, date); //CONF_DATE DATE
pstmt.setString(13, "O"); //STATUS CHAR(1)
pstmt.setDate(14, date); //STATUS_DATE
int hdrCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
// for inserting detail
sql = " insert into inv_alloc_det ( TRAN_ID,LINE_NO,SITE_CODE,ITEM_CODE,LOT_NO,LOT_SL,QUANTITY,REMARKS,REAS_CODE," +
" LOC_CODE,EXP_LEV,POTENCY_ADJ,ISSUE_QTY,DEALLOC_QTY,ALLOC_QTY,DEALLOCATED )" +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
System.out.println("detail sql :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setString(2,lineNo); ////LINE_NO NOT NULL NUMBER(3)
pstmt.setString(3, siteCode ); //SITE_CODE CHAR(5)
pstmt.setString(4, itemCode ); //ITEM_CODE CHAR(10)
pstmt.setString(5, lotNo ); //LOT_NO CHAR(15)
pstmt.setString(6, lotSl ); //LOT_SL CHAR(15)
pstmt.setDouble(7, allocQty ); //QUANTITY NUMBER(14,3)
pstmt.setString(8, remarks ); //REMARKS VARCHAR2(60)
pstmt.setString(9, "" ); //REAS_CODE CHAR(5)
pstmt.setString(10, locCode ); //LOC_CODE CHAR(8)
pstmt.setString(11, "" ); //EXP_LEV VARCHAR2(20)
pstmt.setDouble(12, 0 ); //POTENCY_ADJ NUMBER(14,3)
pstmt.setDouble(13, 0 ); //ISSUE_QTY NUMBER(14,3)
pstmt.setDouble(14, 0 ); //DEALLOC_QTY NUMBER(14,3)
pstmt.setDouble(15, allocQty ); //ALLOC_QTY NUMBER(14,3)
pstmt.setString(16, "" ); //DEALLOCATED CHAR(1)
int detCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
System.out.println("Inserted row :::hdrCnt ["+hdrCnt+"]::detCnt["+detCnt+"]");
String refSer = "W-RIN" ;
// for new 17/06/14
HashMap hashMap = null;
hashMap = new HashMap();
hashMap.put("tran_date",date);
hashMap.put("ref_ser",refSer);
hashMap.put("ref_id",tranId);
hashMap.put("ref_line",lineNo);
hashMap.put("site_code",siteCode);
hashMap.put("item_code",itemCode);
hashMap.put("loc_code",locCode);
hashMap.put("lot_no",lotNo);
hashMap.put("lot_sl",lotSl);
hashMap.put("alloc_qty",allocQty);
hashMap.put("chg_user",chgUser);
hashMap.put("chg_term",chgTerm);
hashMap.put("chg_date", date );
System.out.println("CALLING updateInvallocTrace() --");
invAllocTrace = new InvAllocTraceBean();
errString = invAllocTrace.updateInvallocTrace(hashMap, conn);
System.out.println("updateInvallocTrace 1....."+errString);
if ( errString != null && errString.trim().length() > 0 )
{
System.out.println("@@@@@@rolledback errString :::"+ errString );
conn.rollback();
return errString;
/*
retValue.add("Error");
retValue.add(new Double(allocQty));
return retValue;
*/
}
}
}
/*
if("M".equalsIgnoreCase( suppSour ) && (!itemCodeHdr.equalsIgnoreCase(itemCode)))
{
ArrayList valueList = new ArrayList();
String tranType = "AUT";
//valueList.add( tranId ); // TRAN_ID NOT NULL CHAR(10)
valueList.add(date); // TRAN_DATE DATE
valueList.add(tranType); // TRAN_TYPE VARCHAR2(3)
valueList.add(" "); // WORK_ORDER CHAR(10)
valueList.add( siteCode ) ; // SITE_CODE CHAR(5)
valueList.add(itemCode ); // ITEM_CODE CHAR(10)
valueList.add(date); //CHG_DATE DATE
valueList.add(chgUser); //CHG_USER CHAR(10)
valueList.add(chgTerm); // CHG_TERM CHAR(15)
valueList.add(remarks); //REMARKS VARCHAR2(40)
valueList.add("Y"); //CONFIRMED CHAR(1)
valueList.add(date); //CONF_DATE DATE
valueList.add("O"); //STATUS CHAR(1)
valueList.add(date); //STATUS_DATE DATE
invAllocateMap.put(itemCode, valueList);
}
else
{
ArrayList valueList = new ArrayList();
String tranType = "AUT";
//valueList.add( tranId ); // TRAN_ID NOT NULL CHAR(10)
//valueList.add(lineNo); ////LINE_NO NOT NULL NUMBER(3)
valueList.add(siteCode);//SITE_CODE CHAR(5)
valueList.add(itemCode);//ITEM_CODE CHAR(10)
valueList.add(lotNo);//LOT_NO CHAR(15)
valueList.add(lotSl);//LOT_SL CHAR(15)
valueList.add(allocQty);//QUANTITY NUMBER(14,3)
valueList.add(remarks);//REMARKS VARCHAR2(60)
valueList.add(""); //REAS_CODE CHAR(5)
valueList.add(locCode); //LOC_CODE CHAR(8)
valueList.add("");//EXP_LEV VARCHAR2(20)
valueList.add("");//POTENCY_ADJ NUMBER(14,3)
valueList.add("");//ISSUE_QTY NUMBER(14,3)
valueList.add("");//DEALLOC_QTY NUMBER(14,3)
valueList.add("");//ALLOC_QTY NUMBER(14,3)
valueList.add("");//DEALLOCATED CHAR(1)
itemValueList = (ArrayList) invAllocDetMap.get(parentItem)
itemValueList.add(valueList);
invAllocDetMap.put(parentItem, itemValueList);
}
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);
}
String refSer = "S-ORD" ;
// for new 17/06/14
HashMap hashMap = null;
hashMap = new HashMap();
hashMap.put("tran_date",date);
hashMap.put("ref_ser",refSer);
hashMap.put("ref_id",saleOrder);
hashMap.put("ref_line",lineNo);
hashMap.put("site_code",siteCode);
hashMap.put("item_code",itemCode);
hashMap.put("loc_code",locCode);
hashMap.put("lot_no",lotNo);
hashMap.put("lot_sl",lotSl);
hashMap.put("alloc_qty",allocQty);
hashMap.put("chg_user",chgUser);
hashMap.put("chg_term",chgTerm);
hashMap.put("chg_date", date );
System.out.println("CALLING updateInvallocTrace() --");
invAllocTrace = new InvAllocTraceBean();
errString = invAllocTrace.updateInvallocTrace(hashMap, conn);
System.out.println("updateInvallocTrace 1....."+errString);
if ( errString != null && errString.trim().length() > 0 )
{
System.out.println("@@@@@@rolledback errString :::"+ errString );
conn.rollback();
return errString;
}
// end 1706/14
}//end if
// for insertion logic
Set s1=invAllocateMap.entrySet();
Iterator itr=s1.iterator();
System.out.println("@@@@@final---keyMap["+invAllocateMap+"]]");
while(itr.hasNext())
{
for ( int i=0; i < invAllocateMap.size() ; i++ )
{
Map.Entry map=(Map.Entry)itr.next();
{
String mapKey = map.getKey().toString();
// for inserting header
ArrayList hdrValueList = new ArrayList();
hdrValueList = (ArrayList) invAllocateMap.get(mapKey);
int k=0;
sql = " insert into inv_allocate ( TRAN_ID,TRAN_DATE,TRAN_TYPE,WORK_ORDER,SITE_CODE,ITEM_CODE," +
" CHG_DATE,CHG_USER,CHG_TERM,REMARKS,CONFIRMED,CONF_DATE,STATUS,STATUS_DATE )" +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
System.out.println("header sql :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setDate(2,date); // TRAN_DATE
pstmt.setString(3,hdrValueList.get(k++).toString()); // TRAN_TYPE VARCHAR2(3)
pstmt.setString(4,hdrValueList.get(k++).toString()); // WORK_ORDER CHAR(10)
pstmt.setString(5,hdrValueList.get(k++).toString()); // SITE_CODE CHAR(5)
pstmt.setString(6,hdrValueList.get(k++).toString()); // ITEM_CODE CHAR(10)
pstmt.setString(7,hdrValueList.get(k++).toString()); //CHG_DATE DATE
pstmt.setString(8,hdrValueList.get(k++).toString()); //CHG_USER CHAR(10)
pstmt.setString(9,hdrValueList.get(k++).toString()); // CHG_TERM CHAR(15)
pstmt.setString(10,hdrValueList.get(k++).toString()); //REMARKS VARCHAR2(40)
pstmt.setString(11,hdrValueList.get(k++).toString()); //CONFIRMED CHAR(1)
pstmt.setString(12,hdrValueList.get(k++).toString()); //CONF_DATE DATE
pstmt.setString(13,hdrValueList.get(k++).toString()); //STATUS CHAR(1)
pstmt.setString(14,hdrValueList.get(k++).toString()); //STATUS_DATE
int hdrCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
// for inserting detail
int detCnt = 0;
ArrayList detValList = new ArrayList();
lineNo="0";
detValList = (ArrayList) invAllocDetMap.get(mapKey);
for( int m=0; m < detValList.size(); m++)
{
lineNo = "" + Integer.parseInt(lineNo==null?"0":lineNo)+1;
ArrayList detValueList = new ArrayList();
detValueList = (ArrayList) detValueList.get(m);
k=0;
sql = " insert into inv_alloc_det ( TRAN_ID,LINE_NO,ITEM_CODE,LOT_NO,LOT_SL,QUANTITY,REMARKS,REAS_CODE," +
" LOC_CODE,EXP_LEV,POTENCY_ADJ,ISSUE_QTY,DEALLOC_QTY,ALLOC_QTY,DEALLOCATED )" +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?) ";
System.out.println("detail sql :"+sql);
pstmt = conn.prepareStatement(sql);
pstmt.setString(1,tranId);
pstmt.setString(2,lineNo); ////LINE_NO NOT NULL NUMBER(3)
pstmt.setString(3,detValueList.get(k++).toString()); //SITE_CODE CHAR(5)
pstmt.setString(4,detValueList.get(k++).toString()); //ITEM_CODE CHAR(10)
pstmt.setString(5,detValueList.get(k++).toString()); //LOT_NO CHAR(15)
pstmt.setString(6,detValueList.get(k++).toString()); //LOT_SL CHAR(15)
pstmt.setString(7,detValueList.get(k++).toString()); //QUANTITY NUMBER(14,3)
pstmt.setString(8,detValueList.get(k++).toString()); //REMARKS VARCHAR2(60)
pstmt.setString(9,detValueList.get(k++).toString()); //REAS_CODE CHAR(5)
pstmt.setString(10,detValueList.get(k++).toString()); //LOC_CODE CHAR(8)
pstmt.setString(11,detValueList.get(k++).toString()); //EXP_LEV VARCHAR2(20)
pstmt.setString(12,detValueList.get(k++).toString()); //POTENCY_ADJ NUMBER(14,3)
pstmt.setString(13,detValueList.get(k++).toString()); //ISSUE_QTY NUMBER(14,3)
pstmt.setString(14,detValueList.get(k++).toString()); //DEALLOC_QTY NUMBER(14,3)
pstmt.setString(15,detValueList.get(k++).toString()); //ALLOC_QTY NUMBER(14,3)
pstmt.setString(16,detValueList.get(k++).toString()); //DEALLOCATED CHAR(1)
detCnt = pstmt.executeUpdate();
pstmt.close();
pstmt = null;
}
System.out.println("Inserted row :::hdrCnt ["+hdrCnt+"]::detCnt["+detCnt+"]");
}
}
}
*/
}
// end insertion logic
}//try end
catch (SQLException sqx)
{
......@@ -250,6 +573,87 @@ public class MrpWizPrsSaveBean
return "";
}
private String generateTranId( String windowName, String siteCode, Connection conn )throws ITMException
{
PreparedStatement pstmt = null;
ResultSet rs = null;
String selSql = "";
String tranId = "";
String tranSer = "";
String keyString = "";
String keyCol = "";
String xmlValues = "";
java.sql.Timestamp currDate = null;
GenericUtility genericUtility = GenericUtility.getInstance();
try
{
SimpleDateFormat sdfAppl = new SimpleDateFormat(genericUtility.getApplDateFormat());
currDate = new java.sql.Timestamp(System.currentTimeMillis());
String currDateStr = sdfAppl.format(currDate);
selSql = "SELECT KEY_STRING, TRAN_ID_COL, REF_SER FROM TRANSETUP WHERE TRAN_WINDOW = ? ";
pstmt = conn.prepareStatement(selSql);
pstmt.setString( 1, windowName );
rs = pstmt.executeQuery();
if (rs.next())
{
keyString = rs.getString("KEY_STRING");
keyCol = rs.getString("TRAN_ID_COL");
tranSer = rs.getString("REF_SER");
}
rs.close();rs = null;
pstmt.close();pstmt = null;
System.out.println("keyString :"+keyString);
System.out.println("keyCol :"+keyCol);
System.out.println("tranSer :"+tranSer);
xmlValues ="<?xml version=\"1.0\" encoding=\"utf-8\"?><Root>";
xmlValues = xmlValues + "<Header></Header>";
xmlValues = xmlValues + "<Detail1>";
xmlValues = xmlValues + "<tran_id></tran_id>";
xmlValues = xmlValues + "<site_code>" + siteCode + "</site_code>";
xmlValues = xmlValues + "<tran_date>" + currDateStr + "</tran_date>";
xmlValues = xmlValues + "</Detail1></Root>";
System.out.println("xmlValues :["+xmlValues+"]");
TransIDGenerator tg = new TransIDGenerator(xmlValues, "BASE", CommonConstants.DB_NAME);
tranId = tg.generateTranSeqID(tranSer, keyCol, keyString, conn);
System.out.println("tranId :"+tranId);
}
catch (SQLException ex)
{
System.out.println("Exception ::" +selSql+ ex.getMessage() + ":");
ex.printStackTrace();
throw new ITMException(ex);
}
catch (Exception e)
{
System.out.println("Exception ::" + e.getMessage() + ":");
e.printStackTrace();
throw new ITMException(e);
}
finally
{
try
{
if (rs != null)
{
rs.close();
rs = null;
}
if (pstmt != null)
{
pstmt.close();
pstmt = null;
}
}
catch(Exception e){}
}
return tranId;
}//generateTranTd()
/*
private String generateTranId( String windowName, String siteCode, Connection conn )throws ITMException
{
......
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