/*************************************************
Copyright: Baosight Software LTD.co Copyright (c) 2010
Author: sky_yang
Version: 1.0
Date: 2017-8-08
Description: 生产单元产量完成情况查询(按生产厂)
**************************************************/
/***** C++ 的标准头文件部分 *****/
include "stdafx.h"
/***** C++ 的业务头文件部分 *****/
/<remark>=========================================================
///<summary>
///<para> </para>
///<para></para>
///</summary>
///<returns></returns>
===========================================================</remark>/
// service入口
BM2F_ENTERACE(oimmhp05f2_inq)
int f_oimmhp05f2_inq(EIClass * bcls_rec, EIClass * bcls_ret, CDbConnection * conn)
{
CTracer log(__FUNCTION__); //系统日志类定义
/* 程序内部变量 */
int doFlag = 0;
/* 数据库SQL操作字符串 */
CString sqlstr;
CDbCommand cmd_inq(conn);
try
{
//获取传入参数
switch (conn->DatabaseKind)
{
case DB_KIND_DB2: // DB2 数据库(未开Oracle兼容)
case DB_KIND_DB2_ORACLE: // DB2 数据库(开Oracle兼容)
case DB_KIND_MSSQL: // MS SQL Server数据库
case DB_KIND_ORACLE: // Oracle 数据库
default:
sqlstr = "SELECT CFGP01_VDESC AS CFGP01_VD,SUM(STOCK_END_WT) AS STOCK_END_WT FROM TOIMM02 WHERE CFGP01_NAME = 'PROD_CODE' GROUP BY CFGP01_VDESC";
}
Log::Trace(" ", __FUNCTION__, "sqlstr =[{0}]", sqlstr);
cmd_inq.SetCommandText(sqlstr);
cmd_inq.ExecuteQuery(bcls_ret->Tables[0]);
cmd_inq.Close();
bcls_ret->Tables.Add();
bcls_ret->Tables[1].Rows.Add();
switch (conn->DatabaseKind)
{
case DB_KIND_DB2: // DB2 数据库(未开Oracle兼容)
case DB_KIND_DB2_ORACLE: // DB2 数据库(开Oracle兼容)
case DB_KIND_MSSQL: // MS SQL Server数据库
case DB_KIND_ORACLE: // Oracle 数据库
default:
sqlstr = "select CFGP01_VDESC AS CFGP01_VE,SUM(STOCK_END_WT) AS STOCK_E_WT from TOIMM02 WHERE CFGP01_NAME = 'STOCK_AGE' GROUP BY CFGP01_VDESC ";
}
Log::Trace(" ", __FUNCTION__, "sqlstr =[{0}]", sqlstr);
cmd_inq.SetCommandText(sqlstr);
cmd_inq.ExecuteQuery(bcls_ret->Tables[1]);
cmd_inq.Close();
bcls_ret->Tables.Add();
bcls_ret->Tables[2].Rows.Add();
switch (conn->DatabaseKind)
{
case DB_KIND_DB2: // DB2 数据库(未开Oracle兼容)
case DB_KIND_DB2_ORACLE: // DB2 数据库(开Oracle兼容)
case DB_KIND_MSSQL: // MS SQL Server数据库
case DB_KIND_ORACLE: // Oracle 数据库
default:
sqlstr = "select CFGP01_VDESC AS CFGP01_VS,SUM(STOCK_END_WT) AS STOCK_N_WT from TOIMM02 WHERE CFGP01_NAME = 'STOCK_STURCT' AND CFGP02_VALUE = 'SM' group by CFGP01_VDESC";
}
Log::Trace(" ", __FUNCTION__, "sqlstr =[{0}]", sqlstr);
cmd_inq.SetCommandText(sqlstr);
cmd_inq.ExecuteQuery(bcls_ret->Tables[2]);
cmd_inq.Close();
bcls_ret->Tables.Add();
bcls_ret->Tables[3].Rows.Add();
switch (conn->DatabaseKind)
{
case DB_KIND_DB2: // DB2 数据库(未开Oracle兼容)
case DB_KIND_DB2_ORACLE: // DB2 数据库(开Oracle兼容)
case DB_KIND_MSSQL: // MS SQL Server数据库
case DB_KIND_ORACLE: // Oracle 数据库
default:
sqlstr = " SELECT CFGP01_VDESC AS CFGP01_VC,SUM(STOCK_END_WT) AS STOCK_D_WT FROM TOIMM02 WHERE CFGP01_NAME = 'STOCK_STURCT' AND CFGP02_VALUE = 'PR' GROUP BY CFGP01_VDESC ";
}
Log::Trace(" ", __FUNCTION__, "sqlstr =[{0}]", sqlstr);
cmd_inq.SetCommandText(sqlstr);
cmd_inq.ExecuteQuery(bcls_ret->Tables[3]);
cmd_inq.Close();
}
catch (CDbException& ex) //捕获数据库操作异常
{
CFormattable arguments[] = { ex.GetCode() };
CMessageFormat::Format(s.msg, _RES("GCRSS0000006")/*数据库处理出错,sqlcode=[{0}]。请联系系统维护人员。*/, arguments, 1);
CString str = sqlstr + "\r\n" + ex.GetMsg();
strncpy(s.sysmsg, (const char*)str, sizeof(s.sysmsg) - 1);
s.flag = -1;
doFlag = -1; //数据库异常时返回-1,事务将被回滚
}
catch (CApplicationException& ex) //捕获应用错误
{
s.flag = ex.GetCode();
doFlag = -1;
}
catch (CException& ex)
{
strncpy(s.msg, (const char*)ex.GetMsg(), sizeof(s.msg) - 1);
s.flag = ex.GetCode();
doFlag = -1;
}
return doFlag;
}