Commit 3fd16e42 authored by kshinde's avatar kshinde

Changed demand gen to club quantity on basis of site code itemcode and due date

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@181150 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5feecec4
...@@ -21,176 +21,193 @@ import java.text.ParseException; ...@@ -21,176 +21,193 @@ import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import javax.naming.InitialContext; import javax.naming.InitialContext;
import javax.ejb.Stateless; import javax.ejb.Stateless;
@Stateless @Stateless
public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,DemandGenPrcRemote public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal, DemandGenPrcRemote {
{ public String process() throws RemoteException, ITMException {
public String process() throws RemoteException,ITMException
{
return ""; return "";
} }
DistCommon distCommon = new DistCommon(); DistCommon distCommon = new DistCommon();
public String process(String xmlString, String xmlString2, String windowName, String xtraParams) throws RemoteException,ITMException public String process(String xmlString, String xmlString2, String windowName, String xtraParams)
{ throws RemoteException, ITMException {
String retStr = ""; String retStr = "";
Document dom = null; Document dom = null;
Document dom2 = null; Document dom2 = null;
//GenericUtility genericUtility = GenericUtility.getInstance(); // GenericUtility genericUtility = GenericUtility.getInstance();
E12GenericUtility genericUtility = new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
try try {
{ if (xmlString != null && xmlString.trim().length() != 0) {
if(xmlString != null && xmlString.trim().length()!=0)
{
dom = genericUtility.parseString(xmlString); dom = genericUtility.parseString(xmlString);
} }
if(xmlString2 != null && xmlString2.trim().length()!=0) if (xmlString2 != null && xmlString2.trim().length() != 0) {
{
dom2 = genericUtility.parseString(xmlString2); dom2 = genericUtility.parseString(xmlString2);
} }
retStr = process(dom,dom2, windowName, xtraParams); retStr = process(dom, dom2, windowName, xtraParams);
} } catch (Exception e) {
catch (Exception e) System.out.println(
{ "Exception : process(String xmlString, String xmlString2, String windowName, String xtraParams)"
System.out.println("Exception : process(String xmlString, String xmlString2, String windowName, String xtraParams)" + e.getMessage() + ":"); + e.getMessage() + ":");
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} }
return retStr; return retStr;
} }
public String process(Document Dom, Document Dom2, String windowName, String xtraParams) throws RemoteException,ITMException public String process(Document Dom, Document Dom2, String windowName, String xtraParams)
{ throws RemoteException, ITMException {
System.out.println("Inside Process method:::::::"); System.out.println("Inside Process method:::::::");
String errString=null,retString=null,xmlString=null; String errString = null, retString = null, xmlString = null;
String siteCode="",stateCode=null,countCode=null,itemCode="",strQuantity="",bomCode="",custCode="",loginSite="",tranID="",sysDate="",fromDT=null,toDT=null,unit=null,convQtyStduom1=null,unitStd=null,prdCodeRef=null; String siteCode = "", stateCode = null, countCode = null, itemCode = "", strQuantity = "", bomCode = "",
Timestamp dueDate=null,fromDate=null,toDate=null,tranDate=null; custCode = "", loginSite = "", tranID = null, sysDate = "", fromDT = null, toDT = null, unit = null,
Double quantity=0.0d,frQty=0.0d,convQtyStduom=0.0d,qtyStdUom=0.0d,indQty=0.0d; convQtyStduom1 = null, unitStd = null, prdCodeRef = null;
Timestamp dueDate = null, fromDate = null, toDate = null, tranDate = null;
Double quantity = 0.0d, frQty = 0.0d, convQtyStduom = 0.0d, qtyStdUom = 0.0d, indQty = 0.0d;
Connection conn = null; Connection conn = null;
int cnt=0,cnt1=0,cntr=0,updcnt=0; int cnt = 0, cnt1 = 0, cntr = 0, updcnt = 0;
String sql=null; String sql = null;
PreparedStatement pstmt=null,pstmt1=null,pstmt2=null; PreparedStatement pstmt = null, pstmt1 = null, pstmt2 = null;
boolean count=false; boolean count = false;
ResultSet rs=null,rs1=null,rs2=null; ResultSet rs = null, rs1 = null, rs2 = null;
E12GenericUtility genericUtility=new E12GenericUtility(); E12GenericUtility genericUtility = new E12GenericUtility();
ArrayList qtyStdUom1=new ArrayList(); ArrayList qtyStdUom1 = new ArrayList();
ArrayList<HashMap> indDemand=new ArrayList<HashMap>();
ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB(); ITMDBAccessEJB itmDBAccessEJB = new ITMDBAccessEJB();
DistCommon distCommon=new DistCommon(); DistCommon distCommon = new DistCommon();
HashMap<String, Double> indDemandrow = new HashMap<String, Double>();
StringBuffer xmlBuff; StringBuffer xmlBuff;
String userId = "";//Added By Pavan R 27/DEC/17 String userId = "";// Added By Pavan R 27/DEC/17
try try {
{ conn = getConnection();
conn=getConnection();
conn.setAutoCommit(false); conn.setAutoCommit(false);
fromDT=genericUtility.getColumnValue("from_date", Dom); fromDT = genericUtility.getColumnValue("from_date", Dom);
toDT=genericUtility.getColumnValue("to_date", Dom); toDT = genericUtility.getColumnValue("to_date", Dom);
// custCode=genericUtility.getColumnValue("cust_code",Dom);
//custCode=genericUtility.getColumnValue("cust_code",Dom);
SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat()); SimpleDateFormat sdf1 = new SimpleDateFormat(genericUtility.getDBDateFormat());
loginSite=genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode"); loginSite = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginSiteCode");
//added by Pavan R on 27/DEC/17 userId passwed to savData() and processRequest() // added by Pavan R on 27/DEC/17 userId passwed to savData() and
// processRequest()
userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode"); userId = genericUtility.getValueFromXTRA_PARAMS(xtraParams, "loginCode");
System.out.println("userId::["+userId+"]"); System.out.println("userId::[" + userId + "]");
tranDate = java.sql.Timestamp.valueOf(sdf1.format(new java.util.Date()).toString() + " 00:00:00.0"); tranDate = java.sql.Timestamp.valueOf(sdf1.format(new java.util.Date()).toString() + " 00:00:00.0");
System.out.println("FromDate["+fromDate+"]: ToDate["+toDate+"]"); System.out.println("FromDate[" + fromDate + "]: ToDate[" + toDate + "]");
Calendar currentDate = Calendar.getInstance(); Calendar currentDate = Calendar.getInstance();
System.out.println("currDate>>>>>>"+tranDate); System.out.println("currDate>>>>>>" + tranDate);
SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat()); SimpleDateFormat sdf = new SimpleDateFormat(genericUtility.getApplDateFormat());
sysDate = sdf.format(currentDate.getTime()); sysDate = sdf.format(currentDate.getTime());
System.out.println("Now the date is :=> " + sysDate); System.out.println("Now the date is :=> " + sysDate);
if (fromDT == null || fromDT.trim().length() == 0) {
if(fromDT==null || fromDT.trim().length()==0) errString = itmDBAccessEJB.getErrorString("", "VPEDATE1", "", "", conn);
{
errString = itmDBAccessEJB.getErrorString("","VPEDATE1","","",conn);
return errString; return errString;
} }
if(toDT==null || toDT.trim().length()==0) if (toDT == null || toDT.trim().length() == 0) {
{ errString = itmDBAccessEJB.getErrorString("", "VPEDATE1", "", "", conn);
errString = itmDBAccessEJB.getErrorString("","VPEDATE1","","",conn);
return errString; return errString;
} }
if(compareDates(fromDT,toDT)) if (compareDates(fromDT, toDT)) {
{
errString = itmDBAccessEJB.getErrorString("","VFRTODATE","","",conn); errString = itmDBAccessEJB.getErrorString("", "VFRTODATE", "", "", conn);
return errString; return errString;
} }
fromDate=Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("from_date", Dom), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); fromDate = Timestamp
toDate=Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("to_date", Dom), genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0"); .valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("from_date", Dom),
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
toDate = Timestamp.valueOf(genericUtility.getValidDateString(genericUtility.getColumnValue("to_date", Dom),
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()) + " 00:00:00.0");
sql="Select site_code,item_code,due_date,quantity,cust_code from PPPL_IND_DEMAND where due_date <= ? and due_date >= ?"; sql = "Select site_code,item_code,due_date,sum(quantity),cust_code as quantity from PPPL_IND_DEMAND "
pstmt=conn.prepareStatement(sql); + "where due_date <= ? and due_date >= ? group by site_code,item_code,due_date,cust_code";
pstmt.setTimestamp(1,toDate); pstmt = conn.prepareStatement(sql);
pstmt.setTimestamp(2,fromDate); pstmt.setTimestamp(1, toDate);
rs=pstmt.executeQuery(); pstmt.setTimestamp(2, fromDate);
while(rs.next()) rs = pstmt.executeQuery();
{ while (rs.next()) {
cnt++; cnt++;
siteCode=rs.getString(1); siteCode = rs.getString(1);
itemCode=rs.getString(2); itemCode = rs.getString(2);
dueDate=rs.getTimestamp(3); dueDate = rs.getTimestamp(3);
quantity=rs.getDouble(4); quantity = rs.getDouble(4);
custCode=rs.getString(5); custCode = rs.getString(5);
System.out.println("Row ["+cnt+"] siteCode["+siteCode+"]: itemCode["+itemCode+"]: dueDate["+dueDate+"]: quantity["+quantity+"]"); System.out.println("Row [" + cnt + "] siteCode[" + siteCode + "]: itemCode[" + itemCode + "]: dueDate["
+ dueDate + "]: quantity[" + quantity + "]");
String sql3="select state_code,count_code from customer where cust_code= ? ";
pstmt2=conn.prepareStatement(sql3); // HashMap <String,Double> indDemandrow =new
pstmt2.setString(1,custCode); // HashMap<String,Double>();
rs2=pstmt2.executeQuery();
if(rs2.next()) // Generating key
{ String Key = siteCode.trim() + "," + itemCode.trim() + "," + sdf.format(dueDate);
stateCode=rs2.getString(1);
countCode=rs2.getString(2); String sql3 = "Select state_code,count_code from customer where cust_code= ? ";
pstmt2 = conn.prepareStatement(sql3);
pstmt2.setString(1, custCode);
rs2 = pstmt2.executeQuery();
if (rs2.next()) {
stateCode = rs2.getString(1);
countCode = rs2.getString(2);
} }
pstmt2.close(); pstmt2.close();
pstmt2=null; pstmt2 = null;
rs2.close(); rs2.close();
rs2=null; rs2 = null;
// get Scheme code
bomCode = getBomCode(itemCode, custCode, quantity, tranDate, siteCode, stateCode, countCode, conn);
bomCode=getBomCode(itemCode,custCode,quantity,tranDate,siteCode,stateCode,countCode,conn); // calculate free quantity
frQty=getFreeQty(bomCode,quantity,conn); frQty = getFreeQty(bomCode, quantity, conn);
System.out.println("CustCode ["+custCode+"]BomCode ["+bomCode+"] FreeQty ["+frQty+"]");
quantity=quantity+frQty;
System.out.println("CustCode [" + custCode + "]BomCode [" + bomCode + "] FreeQty [" + frQty + "]");
quantity = quantity + frQty;
// if Already present sum quantity
if (indDemandrow.containsKey(Key)) {
double SumQuantity = (indDemandrow.get(Key)) + quantity;
indDemandrow.replace(Key, SumQuantity);
} else {
System.out.println("Key is " + Key);
indDemandrow.put(Key, quantity);
}
String sql1="select tran_id,quantity,unit,conv__qty_stduom,quantity__std_uom,unit__std,prd_code__ref from independent_demand where site_code=? and item_code= ? and due_date = ?"; }
pstmt1=conn.prepareStatement(sql1); Set<String> eachKey = indDemandrow.keySet();
pstmt1.setString(1,siteCode); System.out.println("custCodekeys[" + eachKey + "]");
pstmt1.setString(2,itemCode); for (String eachIndDemand : eachKey) {
pstmt1.setTimestamp(3,dueDate); // splitting key to get sitecode itemcode and due date
rs1=pstmt1.executeQuery(); String[] keyData = eachIndDemand.split(",");
if(rs1.next())
{
tranID=rs1.getString("tran_id");
unit=rs1.getString("unit");
indQty=rs1.getDouble("quantity");
convQtyStduom=rs1.getDouble("conv__qty_stduom");
//qtyStdUom=rs1.getString("quantity__std_uom");
unitStd=rs1.getString("unit__std");
prdCodeRef=rs1.getString("prd_code__ref");
String sql1 = "Select tran_id,quantity,unit,conv__qty_stduom,quantity__std_uom,unit__std,prd_code__ref from independent_demand where site_code=? and item_code= ? and due_date = ?";
pstmt1 = conn.prepareStatement(sql1);
pstmt1.setString(1, keyData[0]);
pstmt1.setString(2, keyData[1]);
Timestamp dueDateTimestmp = java.sql.Timestamp.valueOf(genericUtility.getValidDateTimeString(keyData[2],
genericUtility.getApplDateFormat(), genericUtility.getDBDateFormat()));
pstmt1.setTimestamp(3, dueDateTimestmp);
rs1 = pstmt1.executeQuery();
if (rs1.next()) {
tranID = rs1.getString("tran_id");
unit = rs1.getString("unit");
indQty = rs1.getDouble("quantity");
convQtyStduom = rs1.getDouble("conv__qty_stduom");
// qtyStdUom=rs1.getString("quantity__std_uom");
unitStd = rs1.getString("unit__std");
prdCodeRef = rs1.getString("prd_code__ref");
} }
pstmt1.close(); pstmt1.close();
pstmt1=null; pstmt1 = null;
rs1.close(); rs1.close();
rs1=null; rs1 = null;
if(tranID==null || tranID.trim().length()==0) if (tranID == null || tranID.trim().length() == 0) {
{ // cntr++;
//cntr++;
xmlBuff = new StringBuffer(); xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n"); xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>"); xmlBuff.append("<DocumentRoot>");
...@@ -206,202 +223,130 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -206,202 +223,130 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>"); xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>"); xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>"); xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
//xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>"); // xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>"); xmlBuff.append("<description>").append("Header0 members").append("</description>");
//<Detail1 dbID="0000000007" domID="1" objContext="1" objName="independent_demand"> // <Detail1 dbID="0000000007" domID="1" objContext="1"
// objName="independent_demand">
xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"independent_demand\" objContext=\"1\">"); xmlBuff.append("<Detail1 dbID=\"\" domID=\"1\" objName=\"independent_demand\" objContext=\"1\">");
xmlBuff.append("<attribute selected=\"N\" updateFlag=\"E\" status=\"N\" pkNames=\"\"/>"); xmlBuff.append("<attribute selected=\"N\" updateFlag=\"E\" status=\"N\" pkNames=\"\"/>");
//<attribute pkNames="tran_id:" selected="N" status="O" updateFlag="N"/> // <attribute pkNames="tran_id:" selected="N" status="O"
//xmlBuff.append("<tran_id><![CDATA[0000000007]]></tran_id>"); // updateFlag="N"/>
xmlBuff.append("<tran_date><![CDATA["+sysDate +"]]></tran_date>"); // xmlBuff.append("<tran_id><![CDATA[0000000007]]></tran_id>");
xmlBuff.append("<due_date><![CDATA["+sdf.format(dueDate) +"]]></due_date>"); xmlBuff.append("<tran_date><![CDATA[" + sysDate + "]]></tran_date>");
xmlBuff.append("<site_code><![CDATA["+siteCode +"]]></site_code>"); xmlBuff.append("<due_date><![CDATA[" + keyData[2] + "]]></due_date>");
xmlBuff.append("<item_code><![CDATA["+itemCode +"]]></item_code>"); xmlBuff.append("<site_code><![CDATA[" + keyData[0] + "]]></site_code>");
xmlBuff.append("<quantity><![CDATA["+quantity +"]]></quantity>"); xmlBuff.append("<item_code><![CDATA[" + keyData[1] + "]]></item_code>");
xmlBuff.append("</Detail1>"); xmlBuff.append("<quantity><![CDATA[" + indDemandrow.get(eachKey) + "]]></quantity>");
xmlBuff.append("</Header0>");
xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>");
xmlString=xmlBuff.toString();
System.out.println("xmlString::"+xmlString);
retString = saveData(loginSite,xmlString,userId,conn);
}
else
{
/*xmlBuff = new StringBuffer();
xmlBuff.append("<?xml version='1.0' encoding='ISO-8859-1'?>\n");
xmlBuff.append("<DocumentRoot>");
xmlBuff.append("<description>").append("Datawindow Root").append("</description>");
xmlBuff.append("<group0>");
xmlBuff.append("<description>").append("Group0 description").append("</description>");
xmlBuff.append("<Header0>");
xmlBuff.append("<objName><![CDATA[").append("independent_demand").append("]]></objName>");
xmlBuff.append("<pageContext><![CDATA[").append("1").append("]]></pageContext>");
xmlBuff.append("<objContext><![CDATA[").append("1").append("]]></objContext>");
xmlBuff.append("<editFlag><![CDATA[").append("E").append("]]></editFlag>");
xmlBuff.append("<focusedColumn><![CDATA[").append("").append("]]></focusedColumn>");
xmlBuff.append("<action><![CDATA[").append("SAVE").append("]]></action>");
xmlBuff.append("<saveLevel><![CDATA[").append("1").append("]]></saveLevel>");
xmlBuff.append("<forcedSave><![CDATA[").append(true).append("]]></forcedSave>");
//xmlBuff.append("<taxInFocus><![CDATA[").append(false).append("]]></taxInFocus>");
xmlBuff.append("<description>").append("Header0 members").append("</description>");
//<Detail1 dbID="0000000007" domID="1" objContext="1" objName="independent_demand">
xmlBuff.append("<Detail1 dbID='"+tranID+"' domID=\"1\" objName=\"independent_demand\" objContext=\"1\">");
xmlBuff.append("<attribute pkNames=\"tran_id:\" selected=\"N\" updateFlag=\"A\" status=\"N\" />");
xmlBuff.append("<tran_id><![CDATA["+tranID+"]]></tran_id>");
//xmlBuff.append("<attribute pkNames="tran_id:" selected="N" status="O" updateFlag="E"/>");
//<attribute pkNames="tran_id:" selected="N" status="O" updateFlag="N"/>
xmlBuff.append("<tran_date><![CDATA["+sysDate +"]]></tran_date>");
xmlBuff.append("<due_date><![CDATA["+sdf.format(dueDate) +"]]></due_date>");
xmlBuff.append("<site_code><![CDATA["+siteCode +"]]></site_code>");
xmlBuff.append("<item_code><![CDATA["+itemCode +"]]></item_code>");
xmlBuff.append("<unit><![CDATA["+unit +"]]></unit>");
xmlBuff.append("<conv__qty_stduom><![CDATA["+convQtyStduom +"]]></conv__qty_stduom>");
xmlBuff.append("<quantity__std_uom><![CDATA["+qtyStdUom +"]]></quantity__std_uom>");
xmlBuff.append("<unit__std><![CDATA["+unitStd +"]]></unit__std>");
xmlBuff.append("<prd_code__ref><![CDATA["+prdCodeRef +"]]></prd_code__ref>");
xmlBuff.append("<quantity><![CDATA["+quantity +"]]></quantity>");
xmlBuff.append("</Detail1>"); xmlBuff.append("</Detail1>");
xmlBuff.append("</Header0>"); xmlBuff.append("</Header0>");
xmlBuff.append("</group0>"); xmlBuff.append("</group0>");
xmlBuff.append("</DocumentRoot>"); xmlBuff.append("</DocumentRoot>");
xmlString=xmlBuff.toString(); xmlString = xmlBuff.toString();
System.out.println("xmlString::"+xmlString);
System.out.println("xmlString::" + xmlString);
retString = saveData(loginSite,xmlString,conn);*/ retString = saveData(loginSite, xmlString, userId, conn);
} else {
qtyStdUom1 = distCommon.getConvQuantityFact(unit, unitStd, itemCode, quantity, convQtyStduom, conn); qtyStdUom1 = distCommon.getConvQuantityFact(unit, unitStd, itemCode, quantity, convQtyStduom, conn);
qtyStdUom=Double.parseDouble((String)qtyStdUom1.get(1)); qtyStdUom = Double.parseDouble((String) qtyStdUom1.get(1));
String sql2="Update independent_demand set quantity = ? , quantity__std_uom= ? where tran_id= ? ";
pstmt1=conn.prepareStatement(sql2);
pstmt1.setDouble(1,quantity);
pstmt1.setDouble(2,qtyStdUom);
pstmt1.setString(3,tranID);
updcnt=pstmt1.executeUpdate();
System.out.println("updcnt"+updcnt);
String sql2 = "Update independent_demand set quantity = ? , quantity__std_uom= ? where tran_id= ? ";
pstmt1 = conn.prepareStatement(sql2);
pstmt1.setDouble(1, quantity);
pstmt1.setDouble(2, qtyStdUom);
pstmt1.setString(3, tranID);
updcnt = pstmt1.executeUpdate();
System.out.println("updcnt" + updcnt);
} }
if ( updcnt>0 || retString.indexOf("Success") > -1 ) if (updcnt > 0 || retString.indexOf("Success") > -1) {
{ // conn.commit();
//conn.commit();
cntr++; cntr++;
System.out.println("Connection Commited"); System.out.println("Connection Commited");
} } else {
else
{
conn.rollback(); conn.rollback();
return retString; return retString;
} }
updcnt=0; updcnt = 0;
tranID=null; tranID = null;
} }
if(cntr>0)
{ if (cntr > 0) {
conn.commit(); conn.commit();
errString = itmDBAccessEJB.getErrorString("","VMSUCC",""); errString = itmDBAccessEJB.getErrorString("", "NODATAERR", "", "", conn);
} else if (cnt <= 0) {
errString = itmDBAccessEJB.getErrorString("", "NODATAERR", "", "", conn);
} }
else if(cnt<=0)
{
errString = itmDBAccessEJB.getErrorString("","NODATAERR","","",conn);
}
} } catch (Exception e) {
catch(Exception e) try {
{
try
{
System.out.println("@@@@@@@@@ Exception.........conn.rollback()........."); System.out.println("@@@@@@@@@ Exception.........conn.rollback().........");
conn.rollback(); conn.rollback();
} } catch (SQLException e1) {
catch (SQLException e1)
{
e1.printStackTrace(); e1.printStackTrace();
System.out.println("Exception ::"+ e1.getMessage()); System.out.println("Exception ::" + e1.getMessage());
throw new ITMException(e1); throw new ITMException(e1);
}; }
;
System.out.println(e.getMessage()); System.out.println(e.getMessage());
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
} } finally {
finally try {
{ // conn.rollback();
try if (rs != null) {
{
//conn.rollback();
if(rs != null)
{
rs.close(); rs.close();
rs = null; rs = null;
} }
if(pstmt != null) if (pstmt != null) {
{
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if(conn !=null) if (conn != null) {
{
conn.close(); conn.close();
conn=null; conn = null;
}
} }
catch(Exception e) } catch (Exception e) {
{
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception ::"+e.getMessage()); System.out.println("Exception ::" + e.getMessage());
throw new ITMException(e); throw new ITMException(e);
} }
} }
return errString; return errString;
} }
private String saveData(String siteCode,String xmlString,String userId,Connection conn) throws ITMException
{ private String saveData(String siteCode, String xmlString, String userId, Connection conn) throws ITMException {
System.out.println("saving data..........."); System.out.println("saving data...........");
InitialContext ctx = null; InitialContext ctx = null;
String retString = null; String retString = null;
//Connection conn=null; // Connection conn=null;
ConnDriver connDriver = new ConnDriver(); ConnDriver connDriver = new ConnDriver();
MasterStatefulLocal masterStateful = null; // for ejb3 MasterStatefulLocal masterStateful = null; // for ejb3
try try {
{
//conn = getConnection(); // conn = getConnection();
//conn=connDriver.getConnectDB("DriverITM"); // conn=connDriver.getConnectDB("DriverITM");
//conn.setAutoCommit(false); // conn.setAutoCommit(false);
AppConnectParm appConnect = new AppConnectParm(); AppConnectParm appConnect = new AppConnectParm();
ctx = new InitialContext(appConnect.getProperty()); ctx = new InitialContext(appConnect.getProperty());
masterStateful = (MasterStatefulLocal)ctx.lookup("ibase/MasterStatefulEJB/local"); masterStateful = (MasterStatefulLocal) ctx.lookup("ibase/MasterStatefulEJB/local");
System.out.println("-----------masterStateful------- " + masterStateful); System.out.println("-----------masterStateful------- " + masterStateful);
String [] authencate = new String[2]; String[] authencate = new String[2];
authencate[0] = userId; authencate[0] = userId;
authencate[1] = ""; authencate[1] = "";
System.out.println("xmlString to masterstateful [" + xmlString + "]"); System.out.println("xmlString to masterstateful [" + xmlString + "]");
retString = masterStateful.processRequest(authencate, siteCode, true, xmlString,true,conn); retString = masterStateful.processRequest(authencate, siteCode, true, xmlString, true, conn);
System.out.println("--retString - -"+retString); System.out.println("--retString - -" + retString);
} } catch (ITMException itme) {
catch(ITMException itme)
{
System.out.println("ITMException : Create Independent Demand :saveData :==>"); System.out.println("ITMException : Create Independent Demand :saveData :==>");
throw itme; throw itme;
} } catch (Exception e) {
catch(Exception e)
{
e.printStackTrace(); e.printStackTrace();
System.out.println("Exception :Create Independent Demand :saveData :==>"); System.out.println("Exception :Create Independent Demand :saveData :==>");
throw new ITMException(e); throw new ITMException(e);
...@@ -409,37 +354,40 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -409,37 +354,40 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
return retString; return retString;
} }
public String getBomCode(String lsItemCodeOrd,String custCode,Double quantity,Timestamp tranDate,String siteCode,String stateCode,String countCode,Connection conn) throws RemoteException,ITMException public String getBomCode(String lsItemCodeOrd, String custCode, Double quantity, Timestamp tranDate,
{ String siteCode, String stateCode, String countCode, Connection conn) throws RemoteException, ITMException {
String retString=null; String retString = null;
//String lsSchemeCode=null,lstype=null;
E12GenericUtility genericUtility=new E12GenericUtility();
double mQty = 0.00, ldConvQtyStduom = 0.00, mRate = 0.00, mNum = 0.00, ldRate = 0.00, idRateWtDiscount = 0.00, acShipperQty = 0.00, acIntegralQty = 0.00, lcRate = 0.00; // String lsSchemeCode=null,lstype=null;
double lcOrdValue = 0.00, lcShipperQty = 0.00, lcIntQty = 0.00, lcBalQty = 0.00, lcLooseQty = 0.00, lcIntegralQty = 0.00, lcQty1 = 0.00, lcQtyFc = 0.00; E12GenericUtility genericUtility = new E12GenericUtility();
String sql = "", mVal = "", mVal1 = "", lsNature = "", lsPriceListParent = "", lsUnitSal = "", lsPriceList = "", lsContractNo = "", lsListType = "";
String lsPlistDisc = "",lsPlistDiscount="", lsCustCode = "", mSiteCode = "", lsPackCode = "", mStateCd = "", lsOrderType = "", lsCountCodeDlv = "", itemStru = "", lstype = "";
String lsCurscheme = "", lsItemCodeParent = "", lsApplyCustList = "", lsNoapplyCustList = "", lsApplicableOrdTypes = "", lsSchemeCode = "", lsPrevscheme = "";
String lsCustSchemeCode = "", lsItemStru = "", lsDisPobOrdTypeList = "", lsSchemeEdit = "", lsUnit = "", lsRefNo = "", lsSiteCodeShip = "", mSlabOn = "", lsDescr = "";
String lsSalesOrd = "", lsQuotNo = "",reStr="",ldtDateStr="";
int llNoOfArt = 0, cnt = 0, llPlcount = 0, llNoOfArt1 = 0, llNoOfArt2 = 0,pos=0,schecnt= 0;
double mQty = 0.00, ldConvQtyStduom = 0.00, mRate = 0.00, mNum = 0.00, ldRate = 0.00, idRateWtDiscount = 0.00,
acShipperQty = 0.00, acIntegralQty = 0.00, lcRate = 0.00;
double lcOrdValue = 0.00, lcShipperQty = 0.00, lcIntQty = 0.00, lcBalQty = 0.00, lcLooseQty = 0.00,
lcIntegralQty = 0.00, lcQty1 = 0.00, lcQtyFc = 0.00;
String sql = "", mVal = "", mVal1 = "", lsNature = "", lsPriceListParent = "", lsUnitSal = "", lsPriceList = "",
lsContractNo = "", lsListType = "";
String lsPlistDisc = "", lsPlistDiscount = "", lsCustCode = "", mSiteCode = "", lsPackCode = "", mStateCd = "",
lsOrderType = "", lsCountCodeDlv = "", itemStru = "", lstype = "";
String lsCurscheme = "", lsItemCodeParent = "", lsApplyCustList = "", lsNoapplyCustList = "",
lsApplicableOrdTypes = "", lsSchemeCode = "", lsPrevscheme = "";
String lsCustSchemeCode = "", lsItemStru = "", lsDisPobOrdTypeList = "", lsSchemeEdit = "", lsUnit = "",
lsRefNo = "", lsSiteCodeShip = "", mSlabOn = "", lsDescr = "";
String lsSalesOrd = "", lsQuotNo = "", reStr = "", ldtDateStr = "";
int llNoOfArt = 0, cnt = 0, llPlcount = 0, llNoOfArt1 = 0, llNoOfArt2 = 0, pos = 0, schecnt = 0;
boolean lsDiscFalg = false, lbProceed = false, lbOrdFlag = false; boolean lsDiscFalg = false, lbProceed = false, lbOrdFlag = false;
PreparedStatement pstmt=null,pstmt1=null; PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs=null,rs1=null; ResultSet rs = null, rs1 = null;
//String sql=null; // String sql=null;
try try {
{
sql = "select bom_code,item_stru from item where item_code = ?"; sql = "select bom_code,item_stru from item where item_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsItemCodeOrd); pstmt.setString(1, lsItemCodeOrd);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
lsSchemeCode = checkNull(rs.getString("bom_code")); lsSchemeCode = checkNull(rs.getString("bom_code"));
lstype = checkNull(rs.getString("item_stru")); lstype = checkNull(rs.getString("item_stru"));
} }
...@@ -448,12 +396,11 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -448,12 +396,11 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (!"C".equalsIgnoreCase(lstype)) if (!"C".equalsIgnoreCase(lstype)) {
{
sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b" sql = "select a.scheme_code from scheme_applicability a,scheme_applicability_det b"
+ " where a.scheme_code= b.scheme_code and a.item_code= ? and a.app_from<= ? and a.valid_upto>= ?" + " where a.scheme_code= b.scheme_code and a.item_code= ? and a.app_from<= ? and a.valid_upto>= ?"
+ " and (b.site_code= ? or b.state_code= ? or b.count_code =? )"; + " and (b.site_code= ? or b.state_code ? or b.count_code)";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, lsItemCodeOrd); pstmt1.setString(1, lsItemCodeOrd);
pstmt1.setTimestamp(2, tranDate); pstmt1.setTimestamp(2, tranDate);
...@@ -462,18 +409,15 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -462,18 +409,15 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
pstmt1.setString(5, stateCode); pstmt1.setString(5, stateCode);
pstmt1.setString(6, countCode); pstmt1.setString(6, countCode);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
while (rs1.next()) while (rs1.next()) {
{
lsCurscheme = rs1.getString("scheme_code"); lsCurscheme = rs1.getString("scheme_code");
if (lsCurscheme != null || lsCurscheme.trim().length() == 0) if (lsCurscheme != null || lsCurscheme.trim().length() == 0) {
{
sql = "select item_code__parent from item where item_code =?"; sql = "select item_code__parent from item where item_code =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsItemCodeOrd); pstmt.setString(1, lsItemCodeOrd);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
lsItemCodeParent = rs.getString("item_code__parent"); lsItemCodeParent = rs.getString("item_code__parent");
} }
rs.close(); rs.close();
...@@ -481,14 +425,12 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -481,14 +425,12 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if (lsItemCodeParent == null || lsItemCodeParent.trim().length() == 0) if (lsItemCodeParent == null || lsItemCodeParent.trim().length() == 0) {
{
sql = "select count(1) as cnt from item where item_code__parent =?"; sql = "select count(1) as cnt from item where item_code__parent =?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsItemCodeOrd); pstmt.setString(1, lsItemCodeOrd);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
...@@ -496,38 +438,37 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -496,38 +438,37 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
} }
if (cnt > 0) if (cnt > 0) {
{
break; break;
} }
} }
sql = "Select count(1) as cnt From scheme_applicability A, bom b Where A.scheme_code = b.bom_code And B.bom_code= ?" + " And(? between case when b.min_qty is null then 0 else b.min_qty end" + " And case when b.max_qty is null then 0 else b.max_qty end) and B.promo_term is null"; sql = "Select count(1) as cnt From scheme_applicability A, bom b Where A.scheme_code = b.bom_code And B.bom_code= ?"
+ " And(? between case when b.min_qty is null then 0 else b.min_qty end"
+ " And case when b.max_qty is null then 0 else b.max_qty end) and B.promo_term is null";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsCurscheme); pstmt.setString(1, lsCurscheme);
pstmt.setDouble(2, quantity); pstmt.setDouble(2, quantity);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
cnt = rs.getInt("cnt"); cnt = rs.getInt("cnt");
} }
rs.close(); rs.close();
rs = null; rs = null;
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
if(cnt == 0)continue; if (cnt == 0)
continue;
/* if (cnt == 0) /*
{ * if (cnt == 0) { // Goto Nextrec }
// Goto Nextrec */
}*/
sql = "select (case when apply_cust_list is null then ' ' else apply_cust_list end) as ls_apply_cust_list," sql = "select (case when apply_cust_list is null then ' ' else apply_cust_list end) as ls_apply_cust_list,"
+ " (case when noapply_cust_list is null then ' ' else noapply_cust_list end) as ls_noapply_cust_list, order_type" + " (case when noapply_cust_list is null then ' ' else noapply_cust_list end) as ls_noapply_cust_list, order_type"
+ " from scheme_applicability where scheme_code =?"; + " from scheme_applicability where scheme_code = ?";
pstmt = conn.prepareStatement(sql); pstmt = conn.prepareStatement(sql);
pstmt.setString(1, lsCurscheme); pstmt.setString(1, lsCurscheme);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if (rs.next()) if (rs.next()) {
{
lsApplyCustList = rs.getString("ls_apply_cust_list"); lsApplyCustList = rs.getString("ls_apply_cust_list");
lsNoapplyCustList = rs.getString("ls_noapply_cust_list"); lsNoapplyCustList = rs.getString("ls_noapply_cust_list");
lsApplicableOrdTypes = rs.getString("order_type"); lsApplicableOrdTypes = rs.getString("order_type");
...@@ -537,70 +478,64 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -537,70 +478,64 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
pstmt.close(); pstmt.close();
pstmt = null; pstmt = null;
/*if ("NE".equalsIgnoreCase(lsOrderType) && (lsApplicableOrdTypes == null || lsApplicableOrdTypes.trim().length() == 0)) /*
{ * if ("NE".equalsIgnoreCase(lsOrderType) &&
// goto Nextrec * (lsApplicableOrdTypes == null ||
} else if (lsApplicableOrdTypes != null && lsApplicableOrdTypes.trim().length() > 0) * lsApplicableOrdTypes.trim().length() == 0)) { // goto
{ * Nextrec } else if (lsApplicableOrdTypes != null &&
System.out.println("lsApplicableOrdTypes1"+lsApplicableOrdTypes+":::"); * lsApplicableOrdTypes.trim().length() > 0) {
lbProceed = false; * System.out.println("lsApplicableOrdTypes1"+
String lsApplicableOrdTypesArr[] = lsApplicableOrdTypes.split(","); * lsApplicableOrdTypes+":::"); lbProceed = false; String
ArrayList<String> applicableOrdTypes= new ArrayList<String>(Arrays.asList(lsApplicableOrdTypesArr)); * lsApplicableOrdTypesArr[] =
if(applicableOrdTypes.contains(lsOrderType)) * lsApplicableOrdTypes.split(","); ArrayList<String>
{ * applicableOrdTypes= new
System.out.println("lbProceed"+lbProceed); * ArrayList<String>(Arrays.asList(lsApplicableOrdTypesArr))
lbProceed = true; * ; if(applicableOrdTypes.contains(lsOrderType)) {
// break; * System.out.println("lbProceed"+lbProceed); lbProceed =
} * true; // break; } if (!lbProceed) {
if (!lbProceed) * System.out.println("Inside lbproceed"); continue; // goto
{ * Nextrec } }
System.out.println("Inside lbproceed"); */
continue;
// goto Nextrec
}
}*/
lsPrevscheme = lsSchemeCode; lsPrevscheme = lsSchemeCode;
lsSchemeCode = lsCurscheme; lsSchemeCode = lsCurscheme;
if (lsApplyCustList.trim().length() > 0) if (lsApplyCustList.trim().length() > 0) {
{ lsSchemeCode = null;
lsSchemeCode=null; System.out.println("lsSchemeCode:::::::1" + lsSchemeCode);
System.out.println("lsSchemeCode:::::::1"+lsSchemeCode); // lsCustCode =
//lsCustCode = checkNull(genericUtility.getColumnValue("cust_code", dom1)); // checkNull(genericUtility.getColumnValue("cust_code",
lsCustCode=custCode; // dom1));
System.out.println("lsCustCode"+lsCustCode); lsCustCode = custCode;
System.out.println("lsCustCode" + lsCustCode);
String lsApplyCustListArr[] = lsApplyCustList.split(","); String lsApplyCustListArr[] = lsApplyCustList.split(",");
ArrayList<String> applyCustList= new ArrayList<String>(Arrays.asList(lsApplyCustListArr)); ArrayList<String> applyCustList = new ArrayList<String>(Arrays.asList(lsApplyCustListArr));
if(applyCustList.contains(lsCustCode.trim())) if (applyCustList.contains(lsCustCode.trim())) {
{
System.out.println("Inside applycustList"); System.out.println("Inside applycustList");
lsSchemeCode = lsCurscheme; lsSchemeCode = lsCurscheme;
lsCustSchemeCode = lsCurscheme; lsCustSchemeCode = lsCurscheme;
System.out.println("lsSchemeCode::"+lsSchemeCode+" lsCustSchemeCode::"+lsCurscheme); System.out.println("lsSchemeCode::" + lsSchemeCode + " lsCustSchemeCode::" + lsCurscheme);
// break; // break;
} }
} }
if (lsNoapplyCustList.trim().length() > 0 && lsSchemeCode != null) if (lsNoapplyCustList.trim().length() > 0 && lsSchemeCode != null) {
{ // lsCustCode =
//lsCustCode = checkNull(genericUtility.getColumnValue("cust_code", dom)); // checkNull(genericUtility.getColumnValue("cust_code",
lsCustCode=custCode; // dom));
lsCustCode = custCode;
String lsNoapplyCustListArr[] = lsNoapplyCustList.split(","); String lsNoapplyCustListArr[] = lsNoapplyCustList.split(",");
ArrayList<String> noapplyCustList= new ArrayList<String>(Arrays.asList(lsNoapplyCustListArr)); ArrayList<String> noapplyCustList = new ArrayList<String>(Arrays.asList(lsNoapplyCustListArr));
if(noapplyCustList.contains(lsCustCode)) if (noapplyCustList.contains(lsCustCode)) {
{
lsSchemeCode = ""; lsSchemeCode = "";
break; break;
} }
} }
cnt = 0; cnt = 0;
if (lsSchemeCode != null) if (lsSchemeCode != null) {
{
schecnt++; schecnt++;
} else if (schecnt == 1) } else if (schecnt == 1) {
{
lsSchemeCode = lsPrevscheme; lsSchemeCode = lsPrevscheme;
System.out.println("lsSchemeCode:::::::2"+lsSchemeCode); System.out.println("lsSchemeCode:::::::2" + lsSchemeCode);
} }
// Nextrec: // Nextrec:
// fetch next curscheme into :ls_curscheme; // fetch next curscheme into :ls_curscheme;
...@@ -610,21 +545,16 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -610,21 +545,16 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
pstmt1.close(); pstmt1.close();
pstmt1 = null; pstmt1 = null;
if (schecnt > 1) if (schecnt > 1) {
{
lsSchemeCode = ""; lsSchemeCode = "";
} else if (lsCustSchemeCode.trim().length() > 0) } else if (lsCustSchemeCode.trim().length() > 0) {
{ System.out.println("lsSchemeCode:::::::3" + lsSchemeCode);
System.out.println("lsSchemeCode:::::::3"+lsSchemeCode);
lsSchemeCode = lsCustSchemeCode; lsSchemeCode = lsCustSchemeCode;
} }
} }
} } catch (Exception e) {
catch(Exception e)
{
System.out.println(e.getMessage()); System.out.println(e.getMessage());
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
...@@ -632,63 +562,53 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -632,63 +562,53 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
return lsSchemeCode; return lsSchemeCode;
} }
public double getFreeQty(String schemeCode,Double chrgQty,Connection conn) throws RemoteException,ITMException
{ public double getFreeQty(String schemeCode, Double chrgQty, Connection conn) throws RemoteException, ITMException {
Double freeQty=0.0d,batchQty=0.0d,qtyPer=0.0d,minQty=0.0d,appMinQty=0.0d,appMaxQty=0.0d; Double freeQty = 0.0d, batchQty = 0.0d, qtyPer = 0.0d, minQty = 0.0d, appMinQty = 0.0d, appMaxQty = 0.0d;
int cnt=0; int cnt = 0;
String sql=null,sql1=null; String sql = null, sql1 = null;
PreparedStatement pstmt=null,pstmt1=null; PreparedStatement pstmt = null, pstmt1 = null;
ResultSet rs=null,rs1=null; ResultSet rs = null, rs1 = null;
try try {
{ sql1 = "Select count(1) from bom Where bom_code = ?"
sql1="Select count(1) from bom Where bom_code = ?"
+ "And ? between case when min_qty is null then 0 else min_qty end And" + "And ? between case when min_qty is null then 0 else min_qty end And"
+ " case when max_qty is null then 0 else max_qty end"; + " case when max_qty is null then 0 else max_qty end";
pstmt = conn.prepareStatement(sql1); pstmt = conn.prepareStatement(sql1);
pstmt.setString(1, schemeCode); pstmt.setString(1, schemeCode);
pstmt.setDouble(2, chrgQty); pstmt.setDouble(2, chrgQty);
rs = pstmt.executeQuery(); rs = pstmt.executeQuery();
if(rs.next()) if (rs.next()) {
{ cnt = rs.getInt(1);
cnt=rs.getInt(1);
} }
if(cnt!=0) if (cnt != 0) {
{
sql="select bom.batch_qty,bomdet.qty_per,bomdet.min_qty ,bomdet.app_min_qty,bomdet.app_max_qty " sql = "select bom.batch_qty,bomdet.qty_per,bomdet.min_qty ,bomdet.app_min_qty,bomdet.app_max_qty "
+ "from bom, bomdet where bom.bom_code = bomdet.bom_code and bomdet.bom_code = ? and bomdet.nature = 'F' "; + "from bom, bomdet where bom.bom_code = bomdet.bom_code and bomdet.bom_code = ? and bomdet.nature = 'F' ";
pstmt1 = conn.prepareStatement(sql); pstmt1 = conn.prepareStatement(sql);
pstmt1.setString(1, schemeCode); pstmt1.setString(1, schemeCode);
rs1 = pstmt1.executeQuery(); rs1 = pstmt1.executeQuery();
if(rs1.next()) if (rs1.next()) {
{ batchQty = rs1.getDouble("batch_qty");
batchQty=rs1.getDouble("batch_qty"); qtyPer = rs1.getDouble("qty_per");
qtyPer=rs1.getDouble("qty_per"); minQty = rs1.getDouble("min_qty");
minQty=rs1.getDouble("min_qty"); appMinQty = rs1.getDouble("app_min_qty");
appMinQty=rs1.getDouble("app_min_qty"); appMaxQty = rs1.getDouble("app_max_qty");
appMaxQty=rs1.getDouble("app_max_qty"); }
} /*
/*if(chrgQty >= appMinQty && chrgQty <= appMaxQty) * if(chrgQty >= appMinQty && chrgQty <= appMaxQty) {
{*/ */
DecimalFormat df=new DecimalFormat("################"); DecimalFormat df = new DecimalFormat("################");
freeQty=Double.parseDouble(df.format(chrgQty/batchQty))*qtyPer; freeQty = Double.parseDouble(df.format(chrgQty / batchQty)) * qtyPer;
/*} /*
else * } else { freeQty=0.0; }
{ */
freeQty=0.0; } else {
} freeQty = 0.0;
*/ }
}
else } catch (Exception e) {
{
freeQty=0.0;
}
}
catch(Exception e)
{
System.out.println(e.getMessage()); System.out.println(e.getMessage());
e.printStackTrace(); e.printStackTrace();
throw new ITMException(e); throw new ITMException(e);
...@@ -696,32 +616,30 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand ...@@ -696,32 +616,30 @@ public class DemandGenPrc extends ProcessEJB implements DemandGenPrcLocal,Demand
return freeQty; return freeQty;
} }
private String checkNull(String inp)
{ private String checkNull(String inp) {
if(inp == null) if (inp == null)
inp = " "; inp = " ";
return inp.trim(); return inp.trim();
} }
public boolean compareDates(String d1,String d2)
{ public boolean compareDates(String d1, String d2) {
boolean err=false; boolean err = false;
try{ try {
SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy"); SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yy");
java.util.Date date1 = sdf.parse(d1); java.util.Date date1 = sdf.parse(d1);
java.util.Date date2 = sdf.parse(d2); java.util.Date date2 = sdf.parse(d2);
System.out.println("Date1"+sdf.format(date1)); System.out.println("Date1" + sdf.format(date1));
System.out.println("Date2"+sdf.format(date2));System.out.println(); System.out.println("Date2" + sdf.format(date2));
System.out.println();
if(date1.after(date2)) if (date1.after(date2)) {
{ err = true;
err=true;
} }
} } catch (ParseException ex) {
catch(ParseException ex){
ex.printStackTrace(); ex.printStackTrace();
} }
return err; return err;
} }
} }
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