Commit 4d478096 authored by rtiwari's avatar rtiwari

change for request DI3ESUN009


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@93735 ce508802-f39f-4f6c-b175-0d175dae99d5
parent c681e205
......@@ -730,7 +730,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
int updCnt = 0;
int parentNodeListLength = 0;
int childNodeListLength = 0;
NodeList parentNodeList = null;
NodeList childNodeList = null;
Node parentNode = null;
......@@ -738,8 +738,9 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
PreparedStatement pstmt = null;
Statement st = null;
int elements = 0;
ArrayList list = new ArrayList();
boolean flag = false;
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
try
{
......@@ -803,25 +804,66 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
{
activeAllow = childNode.getFirstChild().getNodeValue();
}
if(!"Y".equalsIgnoreCase(activeAllow) )
{
if(!"N".equalsIgnoreCase(activeAllow))
{
System.out.println("==activeAllow validate==");
errString = itmDBAccessEJB.getErrorString("","VTACTALW","","",conn);
return errString;
}
}
} //added by ritesh 0n 7/8/13 for request DI3ESUN009 END
}//inner for loop
if(allocQty > 0)
if(!"Y".equalsIgnoreCase(activeAllow) )
{
if(!"N".equalsIgnoreCase(activeAllow))
{
System.out.println("==activeAllow validate==");
errString = itmDBAccessEJB.getErrorString("","VTACTALW","","",conn);
return errString;
}
} //added by ritesh on 07/10/13 for request DI3ESUN009
if("N".equalsIgnoreCase(activeAllow))
{
String sql1 = "";
double shipperSize = 0;
sql1 = "select shipper_size from item_lot_packsize where item_code = ? ";
pstmt = conn.prepareStatement(sql1);
pstmt.setString(1,itemCode);
rs = pstmt.executeQuery();
if(rs.next())
{
shipperSize = rs.getDouble(1);
}
pstmt.close();pstmt = null;
rs.close();rs = null;
try{
if(allocQty % shipperSize != 0)
{
System.out.println("==activeAllow validate 4 N ==");
errString = itmDBAccessEJB.getErrorString("","VTACTALW2","","",conn);
}
}
catch(ArithmeticException ex)
{
System.out.println("==ArithmeticException==");
errString = itmDBAccessEJB.getErrorString("","VTACTALW3","","",conn);
}
if( errString != null && errString.trim().length() > 0 )
{
flag = true;
list.add(saleOrder);
list.add(lineNo);
list.add(itemCode);
list.add(allocQty);
elements ++;
}
} //added by ritesh on 07/10/13 for request DI3ESUN009 END
if(allocQty > 0 && flag == false)
{
System.out.println("if calling........");
errString = sorderAllocate(saleOrder, lineNo, itemCode, allocQty, expLev ,holdFlag,activeAllow);
if (errString != null && errString.trim().length() > 0)
{
System.out.println("errString :"+errString);
System.out.println("@@@errString :"+errString);
return errString;
}
}else if(allocQty == 0) //added by kunal on 27/12/12 as per manoj instruction
......@@ -838,8 +880,32 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
pstmt.close();
pstmt = null;
}
}// out for loop
//added by ritesh on 07/10/13 for request DI3ESUN009 start
if (errString != null && errString.trim().length() > 0)
{
String begPart = errString.substring( 0, errString.indexOf("<trace>") + 7 );
String endPart = errString.substring( errString.indexOf("</trace>"));
String mainStr = begPart + "Following error has occured\n" ;
for(int i = 0; i < elements * 4;i++)
{
if( i > 0)
{
i -= 1;
}
mainStr = mainStr +
"sale order :"+list.get(i++)+ ",line no :"+ list.get(i++) + ",item code :"+list.get(i++)+",quantity :"+list.get(i++)+"\n" ;
}
mainStr = mainStr + endPart;
errString = mainStr;
begPart =null;
endPart =null;
mainStr =null;
return errString;
}
//added by ritesh on 07/10/13 for request DI3ESUN009 end
/*Commented By Manoj Sharma dtd 29/032012 Not required as discussed with Manohar Sir
if(postOrderFg.equals("Y"))
{
......@@ -854,20 +920,20 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
//added by kunal on 27/12/12
if (errString == null || errString.trim().length() == 0)
{
conn.commit();
conn.commit();
errString="VTCOMPL";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
return errString;
}
else
{
errString="VTPRCERR";
errString="VTPRCERR";
errString = itmDBAccessEJB.getErrorString("",errString,"","",conn);
return errString;
}
//added by kunal on 27/12/12
}//try end
catch(Exception e)
{
......@@ -925,6 +991,17 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
return input;
}
/**
* @param saleOrder
* @param lineNo
* @param itemCode
* @param allocQty
* @param expLev
* @param holdFlag
* @param activeAllow
* @return
* @throws ITMException
*/
private String sorderAllocate(String saleOrder, String lineNo, String itemCode, double allocQty, String expLev ,String holdFlag,String activeAllow) throws ITMException
{
System.out.println("updateSOrder calling ..............");
......@@ -1102,195 +1179,242 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
invallocTrace.setLocCode(locCode);
invallocTrace.setLotNo(lotNo);
invallocTrace.setLotSl(lotSl);
if (allocQty >= qtyAvailAlloc)
PreparedStatement pstmt = null;
ResultSet rs1 = null;
String sqls = "";
double shipperSize = 0;
//added by ritesh on 07/10/13 for request DI3ESUN009 start
if(!"N".equalsIgnoreCase(activeAllow))
{
lotQtyToBeAllocated = qtyAvailAlloc;
if (allocQty >= qtyAvailAlloc)
{
lotQtyToBeAllocated = qtyAvailAlloc;
}
else
{
lotQtyToBeAllocated = allocQty;
}
}
else
{
lotQtyToBeAllocated = allocQty;
}
invallocTrace.setAllocQty(lotQtyToBeAllocated);
//
allocQty -= lotQtyToBeAllocated ;
System.out.print("AllocQty = " + lotQtyToBeAllocated);
if (lotQtyToBeAllocated > 0)
{
invallocTrace.setChgUser(chgUser);
invallocTrace.setChgTerm(chgTerm);
invallocTrace.setChgWin("W_SORDALLOC" );
errString = updateInvallocTrace(invallocTrace, conn);
if (errString != null && errString.trim().length() > 0)
sqls = "select shipper_size from item_lot_packsize where item_code = ? and '"+lotNo+"' between lot_no__from and lot_no__to";
pstmt = conn.prepareStatement(sqls);
pstmt.setString(1,itemCode);
rs1 = pstmt.executeQuery();
if(rs1.next())
{
System.out.println("manohar connection rolledback errString :::"+ errString );
conn.rollback();
return errString;
shipperSize = rs1.getDouble(1);
}
if (!saleOrderArr.contains(saleOrder))
{
saleOrderArr.add(saleOrderArr.size() , saleOrder);
pstmt.close();pstmt = null;
rs1.close();rs1 = null;
System.out.print(":: qtyAvailAlloc ::"+qtyAvailAlloc);
System.out.print(":: shipperSize ::"+shipperSize);
if(qtyAvailAlloc >= shipperSize )
{
int div = 0;
if(shipperSize > 0)
{
div = (int) (allocQty / shipperSize);
lotQtyToBeAllocated=div*shipperSize;
if(lotQtyToBeAllocated > qtyAvailAlloc)
{
lotQtyToBeAllocated = 0;
System.out.println("::::::uncommon");
}
}
System.out.println("::lotQtyToBeAllocated::"+lotQtyToBeAllocated);
}
else
{
continue;
}
}
updateSorditem ="UPDATE SORDITEM SET QTY_ALLOC = CASE WHEN QTY_ALLOC IS NULL THEN 0 ELSE QTY_ALLOC END + " + new Double(lotQtyToBeAllocated).toString()
+" WHERE SALE_ORDER = '" + saleOrder + "' "
+" AND LINE_NO = '" + lineNo + "' "
+" AND EXP_LEV = '" + expLev + "' ";
System.out.println("updateSql------->"+updateSorditem);
st = conn.createStatement();
st.executeUpdate(updateSorditem);
System.out.println("UPDATE SUCCESS FOR SORDITEM....>>>>>>>>");
sorditemSql = "SELECT COUNT(1) FROM SORDALLOC "
+ " WHERE SALE_ORDER = '" + saleOrder + "' "
+ " AND LINE_NO = '" + lineNo + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE__ORD = '" + itemCodeOrd + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
rsSItem = st.executeQuery(sorditemSql);
int count = 0 ;
if (rsSItem.next())
{
count = rsSItem.getInt(1);
}
rsSItem.close();
rsSItem=null;
st.close();
st=null;
if (count > 0 )
//added by ritesh on 07/10/13 for request DI3ESUN009 end
invallocTrace.setAllocQty(lotQtyToBeAllocated);
//
allocQty -= lotQtyToBeAllocated ;
System.out.print("AllocQty = " + lotQtyToBeAllocated);
if (lotQtyToBeAllocated > 0)
{
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + " + new Double(lotQtyToBeAllocated).toString()
invallocTrace.setChgUser(chgUser);
invallocTrace.setChgTerm(chgTerm);
invallocTrace.setChgWin("W_SORDALLOC" );
errString = updateInvallocTrace(invallocTrace, conn);
if (errString != null && errString.trim().length() > 0)
{
System.out.println("manohar connection rolledback errString :::"+ errString );
conn.rollback();
return errString;
}
if (!saleOrderArr.contains(saleOrder))
{
saleOrderArr.add(saleOrderArr.size() , saleOrder);
}
updateSorditem ="UPDATE SORDITEM SET QTY_ALLOC = CASE WHEN QTY_ALLOC IS NULL THEN 0 ELSE QTY_ALLOC END + " + new Double(lotQtyToBeAllocated).toString()
+" WHERE SALE_ORDER = '" + saleOrder + "' "
+" AND LINE_NO = '" + lineNo + "' "
+" AND EXP_LEV = '" + expLev + "' ";
System.out.println("updateSql------->"+updateSorditem);
st = conn.createStatement();
st.executeUpdate(updateSorditem);
System.out.println("UPDATE SUCCESS FOR SORDITEM....>>>>>>>>");
sorditemSql = "SELECT COUNT(1) FROM SORDALLOC "
+ " WHERE SALE_ORDER = '" + saleOrder + "' "
+ " AND LINE_NO = '" + lineNo + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE__ORD = '" + itemCodeOrd + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
rsSItem = st.executeQuery(sorditemSql);
int count = 0 ;
if (rsSItem.next())
{
count = rsSItem.getInt(1);
}
rsSItem.close();
rsSItem=null;
st.close();
st=null;
if (count > 0 )
{
updateSql = "UPDATE SORDALLOC SET QTY_ALLOC = QTY_ALLOC + " + new Double(lotQtyToBeAllocated).toString()
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNo + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE__ORD = '" + itemCodeOrd + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
System.out.println("updateSql:::>>>>"+ updateSql);
st = conn.createStatement();
st.executeUpdate(updateSql);
st.close();
st=null;
System.out.println("UPDATE SUCCESS FOR SORDALLOC....");
}
else
{
insertSql ="INSERT INTO SORDALLOC (SALE_ORDER,LINE_NO,EXP_LEV,ITEM_CODE__ORD,SITE_CODE ,"
+"ITEM_CODE,QUANTITY ,LOT_NO, LOT_SL, LOC_CODE, UNIT, QTY_ALLOC,"
+"ITEM_REF, DATE_ALLOC, STATUS,ITEM_GRADE, EXP_DATE, ALLOC_MODE, "
+" CONV__QTY_STDUOM, UNIT__STD, QUANTITY__STDUOM, "
+"MFG_DATE, SITE_CODE__MFG ) "
+"VALUES ( ?, ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ,"
+" ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) " ;
pstmtStockInsertSordAlloc = conn.prepareStatement(insertSql);
System.out.println("Insert Sql :"+ insertSql );
//SALE_ORDER
pstmtStockInsertSordAlloc.setString(1, saleOrder);
System.out.println("saleOrder------->"+saleOrder);
//LINE_NO
pstmtStockInsertSordAlloc.setString(2, lineNo);
System.out.println("lineNo------->"+lineNo);
//EXP_LEV
pstmtStockInsertSordAlloc.setString(3, expLev);
System.out.println("EXP_LEV------->"+expLev);
//ITEM_CODE__ORD
pstmtStockInsertSordAlloc.setString(4, itemCodeOrd);
System.out.println("itemCode------->"+itemCodeOrd);
//SITE_CODE
pstmtStockInsertSordAlloc.setString(5, siteCode);
System.out.println("siteCode------->"+siteCode);
//ITEM_CODE
pstmtStockInsertSordAlloc.setString(6, itemCode);
System.out.println("itemCode------->"+itemCode);
//QUANTITY***** set pending qty
pstmtStockInsertSordAlloc.setDouble(7, pendingQuantity);
System.out.println("pendingQuantity------->"+pendingQuantity);
//LOT_NO
pstmtStockInsertSordAlloc.setString(8, lotNo);
System.out.println("lotNo------->"+lotNo);
//LOT_SL
pstmtStockInsertSordAlloc.setString(9, lotSl);
System.out.println("lotSl------->"+lotSl);
//LOC_CODE
pstmtStockInsertSordAlloc.setString(10, locCode);
System.out.println("locCode------->"+locCode);
//UNIT
pstmtStockInsertSordAlloc.setString(11, unit);
System.out.println("unit------->"+unit);
//QTY_ALLOC
pstmtStockInsertSordAlloc.setDouble(12, lotQtyToBeAllocated);
System.out.println("lotQtyToBeAllocated------->"+lotQtyToBeAllocated);
//ITEM_REF
pstmtStockInsertSordAlloc.setString(13,itemRef);
System.out.println("itemRef------->"+itemRef);
//DATE_ALLOC
pstmtStockInsertSordAlloc.setDate(14,dateAlloc);
System.out.println("dateAlloc------->"+dateAlloc);
//STATUS
pstmtStockInsertSordAlloc.setString(15,"P");
System.out.println("status------->P");
//ITEM_GRADE
pstmtStockInsertSordAlloc.setString(16,grade);
System.out.println("grade------->"+grade);
//EXP_DATE
pstmtStockInsertSordAlloc.setDate(17,expDate);
System.out.println("expDate------->"+expDate);
//ALLOC_MODE
pstmtStockInsertSordAlloc.setString(18,"M");
//CONV__QTY_STDUOM
pstmtStockInsertSordAlloc.setDouble(19,convQtyStduom);
System.out.println("convQtyStduom------->"+convQtyStduom);
//UNIT__STD
pstmtStockInsertSordAlloc.setString(20,unitStd);
System.out.println("unitStd------->"+unitStd);
quantityStduom = convQtyStduom * lotQtyToBeAllocated ;
//QUANTITY__STDUOM
pstmtStockInsertSordAlloc.setDouble(21,quantityStduom);
System.out.println("quantityStduom------->"+quantityStduom);
//MFG_DATE
pstmtStockInsertSordAlloc.setDate(22,mfgDate);
System.out.println("mfgDate------->"+mfgDate);
//SITE_CODE__MFG
pstmtStockInsertSordAlloc.setString(23,siteCodeMfg);
System.out.println("siteCodeMfg------->"+siteCodeMfg);
//QTY_DESP
intCnt = pstmtStockInsertSordAlloc.executeUpdate();
System.out.println("insertion success ...............>>>>>>>>");
pstmtStockInsertSordAlloc.close();
}//end else
//st.close();
//added by akhilesh to update hold_flag
updateSql = "UPDATE SORDDET SET HOLD_FLAG ='"+holdFlag+"'"
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNo + "' "
+ " AND EXP_LEV = '" + expLev + "' "
+ " AND ITEM_CODE__ORD = '" + itemCodeOrd + "' "
+ " AND ITEM_CODE = '" + itemCode + "' "
+ " AND LOT_NO = '" + lotNo + "' "
+ " AND LOT_SL = '" + lotSl + "' "
+ " AND LOC_CODE = '" + locCode + "' " ;
System.out.println("updateSql:::>>>>"+ updateSql);
+ " AND LINE_NO = '" + lineNo + "' ";
System.out.println("updateSql::>>>>"+ updateSql);
st = conn.createStatement();
st.executeUpdate(updateSql);
st.close();
st=null;
System.out.println("UPDATE SUCCESS FOR SORDALLOC....");
}
else
{
insertSql ="INSERT INTO SORDALLOC (SALE_ORDER,LINE_NO,EXP_LEV,ITEM_CODE__ORD,SITE_CODE ,"
+"ITEM_CODE,QUANTITY ,LOT_NO, LOT_SL, LOC_CODE, UNIT, QTY_ALLOC,"
+"ITEM_REF, DATE_ALLOC, STATUS,ITEM_GRADE, EXP_DATE, ALLOC_MODE, "
+" CONV__QTY_STDUOM, UNIT__STD, QUANTITY__STDUOM, "
+"MFG_DATE, SITE_CODE__MFG ) "
+"VALUES ( ?, ? , ? , ? , ? , ? , ? , ? , ? , ? , ? , ? ,"
+" ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ? ) " ;
pstmtStockInsertSordAlloc = conn.prepareStatement(insertSql);
System.out.println("Insert Sql :"+ insertSql );
//SALE_ORDER
pstmtStockInsertSordAlloc.setString(1, saleOrder);
System.out.println("saleOrder------->"+saleOrder);
//LINE_NO
pstmtStockInsertSordAlloc.setString(2, lineNo);
System.out.println("lineNo------->"+lineNo);
//EXP_LEV
pstmtStockInsertSordAlloc.setString(3, expLev);
System.out.println("EXP_LEV------->"+expLev);
//ITEM_CODE__ORD
pstmtStockInsertSordAlloc.setString(4, itemCodeOrd);
System.out.println("itemCode------->"+itemCodeOrd);
//SITE_CODE
pstmtStockInsertSordAlloc.setString(5, siteCode);
System.out.println("siteCode------->"+siteCode);
//ITEM_CODE
pstmtStockInsertSordAlloc.setString(6, itemCode);
System.out.println("itemCode------->"+itemCode);
//QUANTITY***** set pending qty
pstmtStockInsertSordAlloc.setDouble(7, pendingQuantity);
System.out.println("pendingQuantity------->"+pendingQuantity);
//LOT_NO
pstmtStockInsertSordAlloc.setString(8, lotNo);
System.out.println("lotNo------->"+lotNo);
//LOT_SL
pstmtStockInsertSordAlloc.setString(9, lotSl);
System.out.println("lotSl------->"+lotSl);
//LOC_CODE
pstmtStockInsertSordAlloc.setString(10, locCode);
System.out.println("locCode------->"+locCode);
//UNIT
pstmtStockInsertSordAlloc.setString(11, unit);
System.out.println("unit------->"+unit);
//QTY_ALLOC
pstmtStockInsertSordAlloc.setDouble(12, lotQtyToBeAllocated);
System.out.println("lotQtyToBeAllocated------->"+lotQtyToBeAllocated);
//ITEM_REF
pstmtStockInsertSordAlloc.setString(13,itemRef);
System.out.println("itemRef------->"+itemRef);
//DATE_ALLOC
pstmtStockInsertSordAlloc.setDate(14,dateAlloc);
System.out.println("dateAlloc------->"+dateAlloc);
//STATUS
pstmtStockInsertSordAlloc.setString(15,"P");
System.out.println("status------->P");
//ITEM_GRADE
pstmtStockInsertSordAlloc.setString(16,grade);
System.out.println("grade------->"+grade);
//EXP_DATE
pstmtStockInsertSordAlloc.setDate(17,expDate);
System.out.println("expDate------->"+expDate);
//ALLOC_MODE
pstmtStockInsertSordAlloc.setString(18,"M");
//CONV__QTY_STDUOM
pstmtStockInsertSordAlloc.setDouble(19,convQtyStduom);
System.out.println("convQtyStduom------->"+convQtyStduom);
//UNIT__STD
pstmtStockInsertSordAlloc.setString(20,unitStd);
System.out.println("unitStd------->"+unitStd);
quantityStduom = convQtyStduom * lotQtyToBeAllocated ;
//QUANTITY__STDUOM
pstmtStockInsertSordAlloc.setDouble(21,quantityStduom);
System.out.println("quantityStduom------->"+quantityStduom);
//MFG_DATE
pstmtStockInsertSordAlloc.setDate(22,mfgDate);
System.out.println("mfgDate------->"+mfgDate);
//SITE_CODE__MFG
pstmtStockInsertSordAlloc.setString(23,siteCodeMfg);
System.out.println("siteCodeMfg------->"+siteCodeMfg);
//QTY_DESP
intCnt = pstmtStockInsertSordAlloc.executeUpdate();
System.out.println("insertion success ...............>>>>>>>>");
pstmtStockInsertSordAlloc.close();
}//end else
//st.close();
//added by akhilesh to update hold_flag
updateSql = "UPDATE SORDDET SET HOLD_FLAG ='"+holdFlag+"'"
+ " WHERE SALE_ORDER = '" + saleOrder + " ' "
+ " AND LINE_NO = '" + lineNo + "' ";
System.out.println("updateSql::>>>>"+ updateSql);
st = conn.createStatement();
st.executeUpdate(updateSql);
st.close();
st=null;
System.out.println("UPDATE SUCCESS FOR SORDDET....");
//ended by akhilesh
}//end of if(lotQtyToBeAllocated > 0)
System.out.println("UPDATE SUCCESS FOR SORDDET....");
//ended by akhilesh
}//end of while
}//end of if(lotQtyToBeAllocated > 0)
}//end of while
rs.close();
pstmtStock.clearParameters();
pstmtStock.close();
......@@ -1359,6 +1483,7 @@ public class StockAllocationPrc extends ProcessEJB implements StockAllocationPrc
{
errString = e.getMessage();
e.printStackTrace();
System.out.println("::@errString@:::"+errString);
return errString ;
}
......
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