Commit da1f008c authored by pborate's avatar pborate

Updated changes for target qauntity and target value column

git-svn-id: http://15.206.35.175/svn/proteus/business-java/trunk@203460 ce508802-f39f-4f6c-b175-0d175dae99d5
parent 5687a4c4
......@@ -475,6 +475,9 @@ public class UpdateDWHSalesSum implements Schedule
rs = pstmt.executeQuery();
pstmt.close();
rs.close();
updateTragetQtyValue(userDbConn,refId,refSer,refDate);
pstmt = null;
rs = null;
......@@ -562,6 +565,124 @@ public class UpdateDWHSalesSum implements Schedule
private String updateTragetQtyValue(Connection conn, String refId, String refSer, String refDate) throws Exception {
//System.out.println("INSIDE deleteData "+transDataArray);
PreparedStatement pstmt = null;
ResultSet rs = null;
PreparedStatement pstmt1 = null;
ResultSet rs1 = null;
StringBuffer selectSql = new StringBuffer();
StringBuffer updateSql = new StringBuffer();
try
{
E12GenericUtility genericUtility = new E12GenericUtility();
String sourceDateFormat=genericUtility.getDBDateFormat();
String targetDateFormat=genericUtility.getApplDateFormat();
//refDate=genericUtility.getValidDateString(refDate, sourceDateFormat, targetDateFormat);
System.out.println("UpdateDWHSalesSum ==== updateTragetQtyValue query for transaction of records in DWH_SALES_SUM [" +refId+"] refSer ["+refSer+"] refDate ["+refDate+"]");
selectSql.append("SELECT SITE_CODE, CUST_CODE, POS_CODE, ITEM_CODE, ITEM_SER FROM DWH_SALES_SUM WHERE TRAN_ID = '"+refId+"' AND DOC_DATE = TO_DATE('"+refDate+"','"+sourceDateFormat+"') AND REF_SER ='"+refSer+"'");
pstmt = conn.prepareStatement(selectSql.toString());
rs = pstmt.executeQuery();
if(rs.next()) {
String siteCode=checkNull(rs.getString("SITE_CODE"));
String custCode=checkNull(rs.getString("CUST_CODE"));
String posCode=checkNull(rs.getString("POS_CODE"));
String itmCode=checkNull(rs.getString("ITEM_CODE"));
String itmSer=checkNull(rs.getString("ITEM_SER"));
System.out.println("updateTragetQtyValue ::: siteCode "+siteCode+" custCode "+custCode+" posCode "+posCode+" itmCode "+itmCode+" itmSer "+itmSer);
updateSql.append("UPDATE DWH_SALES_SUM t1 ")
.append(" SET (t1.TARGET_QTY, t1.TARGET_VALUE) = ( SELECT t2.TARGET_QTY, t2.TARGET_VALUE ")
.append(" FROM ( ")
.append(" select SITE_CODE, CUST_CODE, POS_CODE, ITEM_CODE, ITEM_SER, SUM(H_NET_AMT) as TARGET_VALUE, SUM(QUANTITY) as TARGET_QTY ")
.append(" from ( ")
.append(" select SBC.TRAN_ID, SBCD.LINE_NO, SBC.SITE_CODE, SBC.CUST_CODE, SBC.POS_CODE, SBCD.ITEM_CODE, SBC.ITEM_SER, SBC.NET_AMT as H_NET_AMT, ")
.append(" SBCD.RATE, SBCD.QUANTITY, SBCD.NET_AMT as D_NET_AMT ")
.append(" from SALES_BUDGET_CUST SBC ")
.append(" LEFT JOIN SALES_BUDGET_CUST_DET SBCD ")
.append(" ON SBC.TRAN_ID = SBCD.TRAN_ID ")
.append(" ) ")
.append(" where SITE_CODE ='"+siteCode+"' ")
.append(" And CUST_CODE ='"+custCode+"' ")
.append(" And POS_CODE ='"+posCode+"' ")
.append(" And ITEM_CODE ='"+itmCode+"' ")
.append(" And ITEM_SER ='"+itmSer+"' ")
.append(" group by SITE_CODE, CUST_CODE, POS_CODE, ITEM_CODE, ITEM_SER ")
.append(" ) t2 ")
.append(" WHERE t1.SITE_CODE = t2.SITE_CODE ")
.append(" and t1.CUST_CODE = t2.CUST_CODE ")
.append(" and t1.POS_CODE = t2.POS_CODE ")
.append(" and t1.ITEM_CODE = t2.ITEM_CODE ")
.append(" and t1.ITEM_SER = t2.ITEM_SER)")
.append(" where SITE_CODE ='"+siteCode+"' ")
.append(" And CUST_CODE ='"+custCode+"' ")
.append(" And POS_CODE ='"+posCode+"' ")
.append(" And ITEM_CODE ='"+itmCode+"' ")
.append(" And ITEM_SER ='"+itmSer+"' ")
.append(" And TRAN_ID = '"+refId+"' AND DOC_DATE = TO_DATE('"+refDate+"','"+sourceDateFormat+"') AND REF_SER ='"+refSer+"'");
System.out.println("update sql "+updateSql);
pstmt1 = conn.prepareStatement(updateSql.toString());
rs1 = pstmt1.executeQuery();
pstmt1.close();
rs1.close();
pstmt1 = null;
rs1 = null;
}
pstmt.close();
rs.close();
pstmt = null;
rs = null;
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
finally
{
try
{
if( pstmt != null )
{
pstmt.close();
pstmt = null;
}
if ( rs != null )
{
rs.close();
rs = null;
}
if( pstmt1 != null )
{
pstmt1.close();
pstmt1 = null;
}
if ( rs1 != null )
{
rs1.close();
rs1 = null;
}
}
catch(Exception e)
{
e.printStackTrace();
}
}
return "";
}
private JSONArray getTransData(Connection conn) throws Exception
{
......@@ -833,6 +954,18 @@ public class UpdateDWHSalesSum implements Schedule
//System.out.println(xmlObj.getNodeName() + ">>childNodeName>" + jsonObj);
return jsonObj;
}
private String checkNull(String str)
{
if(str == null)
{
return "NA";
}
else
{
return str ;
}
}
......
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