Commit e472347b authored by caluka's avatar caluka

stock transfer time qc_order_lots insert for to location


git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@97094 ce508802-f39f-4f6c-b175-0d175dae99d5
parent cad53229
......@@ -25,6 +25,7 @@ import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
......@@ -678,7 +679,6 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer
retString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
System.out.println("Update stock complter1111");
if ( retString != null && retString.trim().length() > 0 )
{
......@@ -686,7 +686,7 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer
break;
}
updateRowMap = updateQcOrderLotInfo( updateRowMap , conn);//added by chandrashekar 05-01-2015
// added by cpatil on 20/11/13 start
sql1 = " select inv_stat from location where loc_code = ? ";
......@@ -755,9 +755,10 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer
updateRowMap.put("ref_id__for",refIdFor);
updateRowMap.put("pack_ref",packRef); ///added by chandrashekar on20-12-2014
// added by cpatil on 20/11/13 end
updateRowMap.put("loc_code_from",locCodeFr); //added by chandrashekar 05-01-2015
updateRowMap = updateQcOrderLotInfo( updateRowMap , conn);//added by chandrashekar 05-01-2015
retString = stkUpdate.updateStock( updateRowMap, xtraParams, conn );
if ( retString != null && retString.trim().length() > 0 )
{
isError = true;
......@@ -3068,4 +3069,262 @@ public class StockTransferConf extends ActionHandlerEJB implements StockTransfer
return retValue;
}//end allocTransfer
private HashMap updateQcOrderLotInfo(HashMap updateRowMap ,Connection conn) throws ITMException, Exception
{
String sql="",errCode="",sqlQC="";
ResultSet rs=null, rs2=null,rsQC=null;
PreparedStatement pstmt=null, pstmtUpd=null,pstmtInsert = null,pstmtQC=null;
String lotNo="",itemCode="",siteCode="",locationCode="",lotSl="",qorderNo="",locationCodeFrom="";
String unit="",aprv="",rej="",qcLotLocCode="";
int cnt=0,cnt1=0,updCnt=0,updCnt1=0;
double quantity=0,qtySample=0,qcOrdQty=0;
double noArt=0 , netWeight=0 , rate=0 , batchSize=0;
int lineNo=0,qcCount=0,qcLotCount=0;
System.out.println("@@@@@ updateQcOrderLotInfo() method called..............");
try
{
if(updateRowMap.get("item_code")!= null)
{
itemCode = updateRowMap.get("item_code").toString();
}
if(updateRowMap.get("site_code")!= null)
{
siteCode = updateRowMap.get("site_code").toString();
}
if(updateRowMap.get("loc_code")!= null)
{
locationCode = updateRowMap.get("loc_code").toString();
}
if(updateRowMap.get("loc_code_from")!= null)
{
locationCodeFrom = updateRowMap.get("loc_code_from").toString();
}
if(updateRowMap.get("lot_no")!= null)
{
lotNo = updateRowMap.get("lot_no").toString();
}
if(updateRowMap.get("lot_sl")!= null)
{
lotSl = updateRowMap.get("lot_sl").toString();
}
if(updateRowMap.get("quantity")!= null)
{
quantity = Double.parseDouble(updateRowMap.get("quantity").toString());
}
if(updateRowMap.get("line_no")!=null)
{
lineNo = Integer.parseInt(updateRowMap.get("line_no").toString());
}
if(updateRowMap.get("no_art")!=null)
{
noArt = Double.parseDouble(updateRowMap.get("no_art").toString());
}
if(updateRowMap.get("net_weight")!=null)
{
netWeight = Double.parseDouble(updateRowMap.get("net_weight").toString());
}
if (quantity > 0)
{
sqlQC = "select count(1) from qc_order "
+ " where site_code = ? "
+ " and item_code = ? "
+ " and lot_no = ? "
+ " and status <> 'C' ";
pstmtQC = conn.prepareStatement(sqlQC);
pstmtQC.setString(1, siteCode);
pstmtQC.setString(2, itemCode);
pstmtQC.setString(3, lotNo);
rsQC = pstmtQC.executeQuery();
if (rsQC.next())
{
qcCount = rsQC.getInt(1);
}
rsQC.close();
rsQC = null;
pstmtQC.close();
pstmtQC = null;
if (qcCount > 0)
{
sql = " select count (*) as cnt,quantity from qc_order_lots " +
"where item_code = ? and lot_no = ? and loc_code__issue = ? and lot_sl=? group by quantity";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, lotNo);
pstmt.setString(3, locationCode);
pstmt.setString(4, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
cnt = rs.getInt("cnt");
qcOrdQty = rs.getDouble("quantity");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
if (cnt > 0)
{
if( locationCodeFrom != null && locationCodeFrom.trim().length()>0 )
{
sql = "update qc_order_lots set quantity = ?+? where item_code = ?" +
" and lot_no = ? and loc_code__issue = ? and lot_sl=? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, qcOrdQty);
pstmtUpd.setDouble(2, quantity);
pstmtUpd.setString(3, itemCode);
pstmtUpd.setString(4, lotNo);
pstmtUpd.setString(5, locationCode);
pstmtUpd.setString(6, lotSl);
updCnt = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
}
else
{
sql = "update qc_order_lots set quantity = ?-? where item_code = ? " +
"and lot_no = ? and loc_code__issue = ? and lot_sl=? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, qcOrdQty);
pstmtUpd.setDouble(2, quantity);
pstmtUpd.setString(3, itemCode);
pstmtUpd.setString(4, lotNo);
pstmtUpd.setString(5, locationCode);
pstmtUpd.setString(6, lotSl);
updCnt = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
}
} else
{
sql = " select quantity from qc_order_lots "
+ "where item_code = ? and lot_no = ? and loc_code__issue=? and lot_sl=? ";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, lotNo);
pstmt.setString(3, locationCodeFrom);
pstmt.setString(4, lotSl);
rs = pstmt.executeQuery();
if (rs.next())
{
qcOrdQty = rs.getDouble("quantity");
}
rs.close();
rs = null;
pstmt.close();
pstmt = null;
System.out.println("@@@@ qcOrdQty To:" + qcOrdQty+"quantity To:"+quantity);
if(qcOrdQty==0)
{
sql = "update qc_order_lots set quantity = ? ,loc_code__issue= ? ,no_art = ? " +
" where item_code = ? and lot_no = ? and loc_code__issue = ? and lot_sl=? ";
pstmtUpd = conn.prepareStatement(sql);
pstmtUpd.setDouble(1, quantity);
pstmtUpd.setString(2, locationCode);
pstmtUpd.setDouble(3, noArt);
pstmtUpd.setString(4, itemCode);
pstmtUpd.setString(5, lotNo);
pstmtUpd.setString(6, locationCodeFrom);
pstmtUpd.setString(7, lotSl);
updCnt = pstmtUpd.executeUpdate();
pstmtUpd.close();
pstmtUpd = null;
}
else
{
sqlQC = "select qorder_no,unit,qty_sample from qc_order " + " where site_code = ? "
+ " and item_code = ? " + " and lot_no = ? "
+ " and status <> 'C' ";
pstmtQC = conn.prepareStatement(sqlQC);
pstmtQC.setString(1, siteCode);
pstmtQC.setString(2, itemCode);
pstmtQC.setString(3, lotNo);
rsQC = pstmtQC.executeQuery();
if (rsQC.next())
{
qorderNo = rsQC.getString("qorder_no");
unit = rsQC.getString("unit");
qtySample = rsQC.getDouble("qty_sample");
}
rsQC.close();
rsQC = null;
pstmtQC.close();
pstmtQC = null;
sql = "select max(line_no) as line_no,loc_code from qc_order_lots " +
" where item_code = ? and lot_no = ? and qorder_no= ? group by loc_code";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, itemCode);
pstmt.setString(2, lotNo);
pstmt.setString(3, qorderNo);
rs2 = pstmt.executeQuery();
if (rs2.next())
{
lineNo = Integer.parseInt(rs2.getString("line_no") == null ? "0" : rs2.getString("line_no"));
qcLotLocCode = rs2.getString("loc_code");
}
pstmt.close();
pstmt = null;
rs2.close();
rs2 = null;
lineNo++;
sql = " Insert into qc_order_lots (QC_ORDER,LINE_NO,ITEM_CODE,LOT_NO,LOT_SL,LOC_CODE,QUANTITY," +
"UNIT,SAMPLE_QTY,LOCTYPE,LOC_CODE__ISSUE,QORDER_NO,NO_ART,NET_WEIGHT) " +
" values (?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
pstmtInsert = conn.prepareStatement(sql);
pstmtInsert.setString(1, qorderNo);
pstmtInsert.setInt(2, lineNo);
pstmtInsert.setString(3, itemCode);
pstmtInsert.setString(4, lotNo);
pstmtInsert.setString(5, lotSl);
// pstmtInsert.setString(6, locationCode);
pstmtInsert.setString(6, qcLotLocCode);
quantity = getUnroundDecimal(quantity, 3);
pstmtInsert.setDouble(7, quantity);
pstmtInsert.setString(8, unit);
pstmtInsert.setDouble(9, qtySample);
pstmtInsert.setString(10, "A");
pstmtInsert.setString(11, locationCode);
pstmtInsert.setString(12, qorderNo);
pstmtInsert.setDouble(13, noArt);
pstmtInsert.setDouble(14, netWeight);
updCnt1 = pstmtInsert.executeUpdate();
pstmtInsert.close();
pstmtInsert = null;
}
}
}
}
} catch (Exception e)
{
System.out.println("Exception " + e);
e.printStackTrace();
throw new ITMException(e);
}
return updateRowMap;
}
public double getUnroundDecimal(double actVal, int prec)
{
String fmtStr = "############0";
String strValue = null;
double retVal = 0;
if (prec > 0)
{
fmtStr = fmtStr + "." + "000000000".substring(0, prec + 1);
}
System.out.println("fmtStr value [" + fmtStr + "]");
DecimalFormat decFormat = new DecimalFormat(fmtStr);
strValue = decFormat.format(actVal);
System.out.println(" actVal [" + actVal + "] integer [" + strValue.substring(0,strValue.indexOf(".") +1) + "]");
System.out.println("decimal [" + strValue.substring(strValue.indexOf(".") + 1, strValue.indexOf(".") + prec + 1) + "]");
retVal = Double.parseDouble( strValue.substring(0,strValue.indexOf(".") +1) + strValue.substring(strValue.indexOf(".") + 1, strValue.indexOf(".") + prec + 1));
System.out.println("rounded value [" + retVal + "]");
return retVal;
}
}
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