Commit 42f357be authored by mmhatre's avatar mmhatre

add code for de-allocate free quantity customer stock

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@210879 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 918667ae
......@@ -6,6 +6,7 @@
package ibase.webitm.ejb.dis.adv;
import ibase.utility.EMail;
import ibase.utility.BaseLogger;
import ibase.utility.CommonConstants;
import ibase.webitm.utility.*;
import ibase.webitm.ejb.*;
......@@ -17,7 +18,6 @@ import ibase.webitm.utility.ITMException;
import java.text.*;
import ibase.webitm.ejb.dis.DistCommon;
import ibase.webitm.ejb.fin.*;
import ibase.webitm.ejb.fin.AssetInstall;
import ibase.webitm.utility.TransIDGenerator;
......@@ -1379,11 +1379,23 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
String locCodeGit = "";
String stockOption = "", qcReq = ""; //Added By Priyanka on 16MAY2019
String gitUpdate = "N";// 10-oct-2019 manoharan to update GIT stock based on channel_partner flag in header
//Manish Mhatre 16oct19 start [to de-allocate free qty customer stock]
String custCodeEnd = "", sorderNo = "", tranIdSordAlloc = "";
PreparedStatement pstmtHdr = null, pstmtDet = null;
InvAllocTraceBean invAllocTrace = null;
HashMap strAllocate = null;
//Manish Mhatre 16oct19 end [to de-allocate free qty customer stock]
try
{
//Manish Mhatre 16oct19 start [to de-allocate free qty customer stock]
SimpleDateFormat sdfApp = new SimpleDateFormat(genericUtility.getApplDateFormat());
ArrayList<HashMap<String, String>> sordAllocStkList = new ArrayList<HashMap<String, String>>();
HashMap<String, String> sordAllocStk = null;
//Manish Mhatre 16oct19 end [to de-allocate free qty customer stock]
DistCommon distCommon = new DistCommon();
ITMDBAccessEJB itmDBAccessLocal = new ITMDBAccessEJB();
sql = "Select tran_date, site_code,tran_ser,supp_code,post_type , curr_code , exch_rate, channel_partner From porcp Where tran_id = ? ";
//sql = "Select tran_date, site_code,tran_ser,supp_code,post_type , curr_code , exch_rate, channel_partner From porcp Where tran_id = ? ";
sql = "Select tran_date, site_code,tran_ser,supp_code,post_type , curr_code , exch_rate, channel_partner From porcp Where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
rs = pstmt.executeQuery();
......@@ -1396,7 +1408,7 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
invacctRate = rs.getString("post_type");
currCode = rs.getString("post_type");
exchRate = rs.getDouble("exch_rate");
gitUpdate = rs.getString("channel_partner");
gitUpdate = rs.getString("channel_partner");
}
pstmt.close();
pstmt = null;
......@@ -1409,7 +1421,56 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
{
gitUpdate = "N";
}
System.out.println("confirm porcp....gitUpdate after["+gitUpdate + "]");
//Manish Mhatre 16oct19 start [to de-allocate free qty customer stock]
String userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams,"loginCode");
String chgTerm = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId");
String loginEmp = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode");
sql = "INSERT INTO SORD_ALLOC (TRAN_ID,TRAN_DATE,CUST_CODE,SITE_CODE,CHG_DATE,CHG_TERM,CHG_USER,ADD_DATE,ADD_TERM,ADD_USER,EMP_CODE__APRV,"
+ " CONFIRMED,CONF_DATE,ACTIVE_PICK_ALLOW,SITE_CODE__SHIP,ALLOC_SOURCE,ALLOC_FLAG,EDI_STAT) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtHdr = conn.prepareStatement(sql);
sql = "Insert into SORD_ALLOC_DET (TRAN_ID,LINE_NO,ITEM_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY,DEALLOC_QTY,SITE_CODE,PENDING_QTY)values (?,?,?,?,?,?,?,?,?,?)";
pstmtDet = conn.prepareStatement(sql);
/*
if ("Y".equalsIgnoreCase(gitUpdate) && (custCodeEnd != null && custCodeEnd.trim().length() > 0))
{
//tranIdSordAlloc = generateTranId("w_sord_alloc", siteCode, sdfApp.format(tranDate), conn);
BaseLogger.log("2", null, null, "SordAlloc Tran ID:["+tranIdSordAlloc+"] custCodeEnd["+custCodeEnd+"]sorderNo["+sorderNo+"]");
if(custCodeEnd != null && custCodeEnd.trim().length() > 0)
{
tranIdSordAlloc = generateTranId("w_sord_alloc", siteCode, sdfApp.format(tranDate), conn);
//String chgUser = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
String userId =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginEmpCode"));
String chgTerm =(genericUtility.getValueFromXTRA_PARAMS(xtraParams, "termId"));
sql = "INSERT INTO SORD_ALLOC (TRAN_ID,TRAN_DATE,CUST_CODE,SITE_CODE,CHG_DATE,CHG_TERM,CHG_USER,ADD_DATE,ADD_TERM,ADD_USER,EMP_CODE__APRV,"
+ " CONFIRMED,CONF_DATE,ACTIVE_PICK_ALLOW,SITE_CODE__SHIP,ALLOC_SOURCE,ALLOC_FLAG,EDI_STAT) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtHdr = conn.prepareStatement(sql);
pstmtHdr.setString(1, tranIdSordAlloc);
pstmtHdr.setTimestamp(2, tranDate);
pstmtHdr.setString(3, custCodeEnd);
pstmtHdr.setString(4, siteRcp);
pstmtHdr.setTimestamp(5, tranDate);
pstmtHdr.setString(6, chgTerm);
pstmtHdr.setString(7, userId);
pstmtHdr.setTimestamp(8, tranDate);
pstmtHdr.setString(9, chgTerm);
pstmtHdr.setString(10, userId);
pstmtHdr.setString(11, userId);
pstmtHdr.setString(12, "Y");
pstmtHdr.setTimestamp(13, tranDate);
pstmtHdr.setString(14, "Y");
pstmtHdr.setString(15, siteRcp);
pstmtHdr.setString(16, "M");
pstmtHdr.setString(17, "A");
pstmtHdr.setString(18, "N");
pstmtHdr.executeUpdate();
pstmtHdr.clearParameters();
pstmtHdr.close();
pstmtHdr = null;
}
}//end if
//Manish Mhatre 16oct19 end [to de-allocate free qty customer stock]
*/ System.out.println("confirm porcp....gitUpdate after["+gitUpdate + "]");
sql = "Select (case when eou is null then 'N' else eou end) eou From site Where site_code = ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, siteRcp);
......@@ -1509,12 +1570,16 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
* lockCode = rs.getString("lock_code"); suppLockList.add(lockCode);
* } pstmt.close(); pstmt = null; rs.close(); rs = null; }
*/
//Manish Mhatre 16oct19 start [to de-allocate free qty customer stock]
//int lineNoDet = 0;
HashMap<String, HashMap> custLineItem = new HashMap<String, HashMap>();
//Manish Mhatre 16oct19 end [to de-allocate free qty customer stock]
// ///////////////////////////////////////////////
sql = "SELECT SHIPPER_SIZE, GROSS_WEIGHT, NET_WEIGHT FROM ITEM_LOT_PACKSIZE WHERE ITEM_CODE = ? AND LOT_NO__FROM <= ? AND LOT_NO__TO >= ? ";
pstmtItemLotPack = conn.prepareStatement(sql);
sql = "select line_no, item_code, purc_order, quantity, " + " unit, rate__stduom, discount, tax_amt, net_amt, " + " loc_code, line_no__ord, canc_bo, lot_no, lot_sl, " + " unit__std, quantity__stduom, acct_code__cr, acct_code__dr, cctr_code__cr, cctr_code__dr, " + " mfg_date, pack_code, potency_perc, expiry_date, " + " gross_weight, tare_weight, net_weight, supp_code__mnfr, " + " site_code__mfg, grade, conv__qty_stduom, " + " (case when excess_short_qty is null then 0 else excess_short_qty end) as excess_short_qty, " + " loc_code__excess_short , (case when realised_qty is null then 0 else realised_qty end) as realised_qty, " + " batch_no, no_art, item_code__mfg, std_rate, effect_stock, form_no, retest_date, " + " duty_paid, batch_size, shelf_life__type " + " from porcpdet Where tran_id = ? ";
//sql = "select line_no, item_code, purc_order, quantity, " + " unit, rate__stduom, discount, tax_amt, net_amt, " + " loc_code, line_no__ord, canc_bo, lot_no, lot_sl, " + " unit__std, quantity__stduom, acct_code__cr, acct_code__dr, cctr_code__cr, cctr_code__dr, " + " mfg_date, pack_code, potency_perc, expiry_date, " + " gross_weight, tare_weight, net_weight, supp_code__mnfr, " + " site_code__mfg, grade, conv__qty_stduom, " + " (case when excess_short_qty is null then 0 else excess_short_qty end) as excess_short_qty, " + " loc_code__excess_short , (case when realised_qty is null then 0 else realised_qty end) as realised_qty, " + " batch_no, no_art, item_code__mfg, std_rate, effect_stock, form_no, retest_date, " + " duty_paid, batch_size, shelf_life__type " + " from porcpdet Where tran_id = ? ";
sql = "select line_no, item_code, purc_order, quantity, " + " unit, rate__stduom, discount, tax_amt, net_amt, " + " loc_code, line_no__ord, canc_bo, lot_no, lot_sl, " + " unit__std, quantity__stduom, acct_code__cr, acct_code__dr, cctr_code__cr, cctr_code__dr, " + " mfg_date, pack_code, potency_perc, expiry_date, " + " gross_weight, tare_weight, net_weight, supp_code__mnfr, " + " site_code__mfg, grade, conv__qty_stduom, " + " (case when excess_short_qty is null then 0 else excess_short_qty end) as excess_short_qty, " + " loc_code__excess_short , (case when realised_qty is null then 0 else realised_qty end) as realised_qty, " + " batch_no, no_art, item_code__mfg, std_rate, effect_stock, form_no, retest_date, " + " duty_paid, batch_size, shelf_life__type, cust_code__end " + " from porcpdet Where tran_id = ? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, tranId);
......@@ -1558,6 +1623,7 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
receiptQty = rs.getDouble("realised_qty");
batchNo = rs.getString("batch_no");
noArt = rs.getDouble("no_art");
custCodeEnd = checkNull(rs.getString("cust_code__end"));
if (noArt == 0)
{
pstmtItemLotPack.setString(1, itemCode);
......@@ -2159,8 +2225,154 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
//if (channelPartner.equalsIgnoreCase("Y") && (disLink.equalsIgnoreCase("E") || disLink.equalsIgnoreCase("A")))
// 10-oct-2019 manoharan to update GIT stock based on channel_partner flag in header
//if (channelPartner.equalsIgnoreCase("Y") && (disLink.equalsIgnoreCase("E") || disLink.equalsIgnoreCase("A")))
if ("Y".equalsIgnoreCase(gitUpdate) && (disLink.equalsIgnoreCase("E") || disLink.equalsIgnoreCase("A")))
{
//if ("Y".equalsIgnoreCase(gitUpdate) && (disLink.equalsIgnoreCase("E") || disLink.equalsIgnoreCase("A")))
if ("Y".equalsIgnoreCase(gitUpdate) )
{
//Manish Mhatre 16oct19 start [to de-allocate free qty customer stock]
//if( custCodeEnd != null && custCodeEnd.trim().length()> 0 && rate == 0 )
if( custCodeEnd != null && custCodeEnd.trim().length()> 0 )
{
if ("Y".equalsIgnoreCase(gitUpdate) && (custCodeEnd != null && custCodeEnd.trim().length() > 0))
{
BaseLogger.log("2", null, null, "SordAlloc Tran ID:[" + tranIdSordAlloc+ "] custCodeEnd[" + custCodeEnd + "]sorderNo[" + sorderNo + "]");
int lineNoSord = 1;
if (custCodeEnd != null && custCodeEnd.trim().length() > 0)
{
if (!custLineItem.containsKey(custCodeEnd))
{
tranIdSordAlloc = generateTranId("w_sord_alloc", siteCode,sdfApp.format(tranDate), conn);
HashMap detailItmMap = new HashMap();
detailItmMap.put("tran_id", tranIdSordAlloc);
detailItmMap.put("line_no", lineNoSord);
custLineItem.put(custCodeEnd, detailItmMap);
/*sql = "INSERT INTO SORD_ALLOC (TRAN_ID,TRAN_DATE,CUST_CODE,SITE_CODE,CHG_DATE,CHG_TERM,CHG_USER,ADD_DATE,ADD_TERM,ADD_USER,EMP_CODE__APRV,"
+ " CONFIRMED,CONF_DATE,ACTIVE_PICK_ALLOW,SITE_CODE__SHIP,ALLOC_SOURCE,ALLOC_FLAG,EDI_STAT) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtHdr = conn.prepareStatement(sql);*/
pstmtHdr.setString(1, tranIdSordAlloc);
pstmtHdr.setTimestamp(2, tranDate);
pstmtHdr.setString(3, custCodeEnd);
pstmtHdr.setString(4, siteRcp);
pstmtHdr.setTimestamp(5, tranDate);
pstmtHdr.setString(6, chgTerm);
pstmtHdr.setString(7, userId);
pstmtHdr.setTimestamp(8, tranDate);
pstmtHdr.setString(9, chgTerm);
pstmtHdr.setString(10, userId);
pstmtHdr.setString(11, loginEmp);
pstmtHdr.setString(12, "Y");
pstmtHdr.setTimestamp(13, tranDate);
pstmtHdr.setString(14, "Y");
pstmtHdr.setString(15, siteRcp);
pstmtHdr.setString(16, "M");
pstmtHdr.setString(17, "A");
pstmtHdr.setString(18, "N");
pstmtHdr.executeUpdate();
pstmtHdr.clearParameters();
/*pstmtHdr.close();
pstmtHdr = null;*/
/*sql = "Insert into SORD_ALLOC_DET (TRAN_ID,LINE_NO,ITEM_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY,DEALLOC_QTY,SITE_CODE,PENDING_QTY)values (?,?,?,?,?,?,?,?,?,?)";
pstmtDet = conn.prepareStatement(sql);*/
pstmtDet.setString(1, tranIdSordAlloc);
pstmtDet.setInt(2, lineNoSord);
pstmtDet.setString(3, itemCode);
pstmtDet.setString(4, locCode);
pstmtDet.setString(5, lotNo);
pstmtDet.setString(6, lotSl);
pstmtDet.setDouble(7, stdQuantity);
pstmtDet.setDouble(8, 0.0);
pstmtDet.setString(9, siteRcp);
pstmtDet.setDouble(10, 0.0);
int detCnt = pstmtDet.executeUpdate();
pstmtDet.clearParameters();
/*pstmtDet.close();
pstmtDet = null;*/
if (detCnt > 0) {
strAllocate = new HashMap();
strAllocate.put("tran_date", tranDate);
strAllocate.put("ref_ser", "S-ALC");
strAllocate.put("ref_id", tranIdSordAlloc);
strAllocate.put("ref_line", "" + lineNoSord);
strAllocate.put("site_code", siteRcp);
strAllocate.put("item_code", itemCode);
strAllocate.put("loc_code", locCode);
strAllocate.put("lot_no", lotNo);
strAllocate.put("lot_sl", lotSl);
strAllocate.put("alloc_qty", new Double(stdQuantity));
strAllocate.put("chg_user", new ibase.utility.E12GenericUtility()
.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
strAllocate.put("chg_term", new ibase.utility.E12GenericUtility()
.getValueFromXTRA_PARAMS(xtraParams, "termId"));
strAllocate.put("chg_win", "W_SORDALLOC");
invAllocTrace = new InvAllocTraceBean();
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString for Customer::: " + errString);
if (errString != null && errString.trim().length() > 0) {
break;
}
strAllocate = null;
// end if(detCnt > 0)
}
} else
{
HashMap detailItmMap = custLineItem.get(custCodeEnd);
int line = Integer.parseInt(detailItmMap.get("line_no").toString()) + 1;
tranIdSordAlloc = detailItmMap.get("tran_id").toString();
detailItmMap.put("line_no", line);
custLineItem.put(custCodeEnd, detailItmMap);
BaseLogger.log("2", null, null, "Allocation details:" + line + ">>" + itemCode
+ ">>" + locCode + ">>" + lotNo + ">>" + lotSl + ">>" + convQtyStdUom);
/*sql = "Insert into SORD_ALLOC_DET (TRAN_ID,LINE_NO,ITEM_CODE,LOC_CODE,LOT_NO,LOT_SL,QUANTITY,DEALLOC_QTY,SITE_CODE,PENDING_QTY)values (?,?,?,?,?,?,?,?,?,?)";
pstmtDet = conn.prepareStatement(sql);*/
pstmtDet.setString(1, tranIdSordAlloc);
pstmtDet.setInt(2, line);
pstmtDet.setString(3, itemCode);
pstmtDet.setString(4, locCode);
pstmtDet.setString(5, lotNo);
pstmtDet.setString(6, lotSl);
pstmtDet.setDouble(7, stdQuantity);
pstmtDet.setDouble(8, 0.0);
pstmtDet.setString(9, siteRcp);
pstmtDet.setDouble(10, 0.0);
int detCnt = pstmtDet.executeUpdate();
pstmtDet.clearParameters();
/*pstmtDet.close();
pstmtDet = null;*/
if (detCnt > 0) {
strAllocate = new HashMap();
strAllocate.put("tran_date", tranDate);
strAllocate.put("ref_ser", "S-ALC");
strAllocate.put("ref_id", tranIdSordAlloc);
strAllocate.put("ref_line", "" + line);
strAllocate.put("site_code", siteRcp);
strAllocate.put("item_code", itemCode);
strAllocate.put("loc_code", locCode);
strAllocate.put("lot_no", lotNo);
strAllocate.put("lot_sl", lotSl);
strAllocate.put("alloc_qty", new Double(stdQuantity));
strAllocate.put("chg_user", new ibase.utility.E12GenericUtility()
.getValueFromXTRA_PARAMS(xtraParams, "loginCode"));
strAllocate.put("chg_term", new ibase.utility.E12GenericUtility()
.getValueFromXTRA_PARAMS(xtraParams, "termId"));
strAllocate.put("chg_win", "W_SORDALLOC");
invAllocTrace = new InvAllocTraceBean();
errString = invAllocTrace.updateInvallocTrace(strAllocate, conn);
System.out.println("errString for Customer::: " + errString);
if (errString != null && errString.trim().length() > 0) {
break;
}
strAllocate = null;
// end if(detCnt > 0)
}
}
}
} // end if
}
//Manish Mhatre 16oct19 end [to de-allocate free qty customer stock]
System.out.println("Entered in channel Partner loop");
sql = "select var_value" + " from disparm Where prd_code='999999'" + " And var_name='TRANSIT_LOC'";
......@@ -2242,9 +2454,8 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
pstmtUpd.close();
pstmtUpd = null;
}
}
}
// stkUpdMap = null;
/*
......@@ -2616,6 +2827,21 @@ public class PoRcpConf extends ActionHandlerEJB implements PoRcpConfLocal, PoRcp
pstmtItemLotPack.close();
pstmtItemLotPack = null;
}
//Manish Mhatre 16oct19 start [to de-allocate free qty customer stock]
if(pstmtHdr != null) {
pstmtHdr.close();
pstmtHdr = null;
}
if(pstmtDet != null)
{
pstmtDet.close();
pstmtDet = null;
}
if(!custLineItem.isEmpty())
{
custLineItem.clear();
}
//Manish Mhatre 16oct19 end [to de-allocate free qty customer stock]
//Ended by Varsha V on 31-05-18 for cursor issue
pstmt.close();
pstmt = null;
......
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