You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
253 lines
17 KiB
C#
253 lines
17 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using DSWeb.MvcShipping.Helper;
|
|
using DSWeb.MvcShipping.Comm.Cookie;
|
|
using DSWeb.Areas.CommMng.DAL;
|
|
using DSWeb.Areas.RptMng.Comm;
|
|
using HcUtility.Comm;
|
|
using HcUtility.Core;
|
|
using Microsoft.Practices.EnterpriseLibrary.Data;
|
|
using DSWeb.EntityDA;
|
|
using DSWeb.Areas.CommMng.Models;
|
|
using DSWeb.MvcShipping.DAL.RptCwGLDetailColumnChartDAL;
|
|
|
|
namespace DSWeb.MvcShipping.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 多栏账图表分析
|
|
/// </summary>
|
|
[JsonRequestBehavior]
|
|
public class RptCwGLDetailColumnChartController : Controller
|
|
{
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
//查询
|
|
public ContentResult GetDataList(int start, int limit, string sort, string strACCDATE, string strCURRENCY, string strACCID, string strCustNAME, string strDeptName, string strSALE, string strITEMNAME, string strSubjectAccount, string acctype, string sumfieldtype, string isDETAILED)
|
|
{
|
|
if (Convert.ToString(Session["COMPANYID"]).Trim() == "" || Convert.ToString(Session["USERID"]).Trim() == "" || Convert.ToString(Session["CODENAME"]).Trim() == "" || Convert.ToString(Session["SHOWNAME"]).Trim() == "" || Convert.ToString(Session["DEPTNAME"]).Trim() == "")
|
|
{
|
|
var jsonRespose2 = new JsonResponse { Success = false, Message = "登录超时,请退出系统重新登录!" };
|
|
return new ContentResult() { Content = JsonConvert.Serialize(jsonRespose2) };
|
|
}
|
|
//
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
String strSql = RptCwGLDetailColumnChartDAL.GetDataList(strACCDATE, strCURRENCY, strACCID, strCustNAME, strDeptName, strSALE, strITEMNAME, strSubjectAccount, acctype, sumfieldtype, isDETAILED, Convert.ToString(Session["USERID"]), Convert.ToString(Session["SHOWNAME"]), Convert.ToString(Session["COMPANYID"]), sort);
|
|
DataSet ds = T_ALL_DA.GetAllSQL(strSql.ToString());
|
|
var json = RptHelper.GetRptJsonResult(start, limit, ds, true);
|
|
return new ContentResult() { Content = json };
|
|
}
|
|
|
|
//显示科目明细信息
|
|
public string GetDataListDetail(string strACCDATE, string strCURRENCY, string strACCID, string strInquireField, string sumfieldtype, string acctype) // string strSubjectAccount,
|
|
{
|
|
T_ALL_DA T_ALL_DA = new EntityDA.T_ALL_DA();
|
|
string strCwSTARTGID = BasicDataRefDAL.GetCwSTARTGID(Convert.ToString(Session["USERID"]));
|
|
string strCondition = "";
|
|
string sYear = DateTime.Parse(strACCDATE + "-01").Year.ToString();
|
|
|
|
string accDateBgn = "and ACCDATE='" + strACCDATE + "'";
|
|
string accDateEnd = "and ACCDATE='" + strACCDATE + "'";
|
|
|
|
string sCondition = "";
|
|
string sHSKM = "";
|
|
|
|
string createUser = Convert.ToString(Session["USERID"]);
|
|
string corpID = Convert.ToString(Session["COMPANYID"]);
|
|
|
|
strCondition = "ACCID='" + strACCID + "'";
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
sCondition += "and " + strCondition;
|
|
}
|
|
|
|
sCondition += " and [YEAR]='" + sYear + "'";
|
|
|
|
string strSqlAdjust = "select top 1 * from cw_accitems_gl where [STARTGID]='" + strCwSTARTGID + "'" + sCondition;
|
|
DataSet ds = T_ALL_DA.GetAllSQL(strSqlAdjust);
|
|
if (ds != null)
|
|
{
|
|
if (ds.Tables[0].Rows.Count > 0)
|
|
{
|
|
if (ds.Tables[0].Rows[0]["ISCORPACC"].ToString() == "True")
|
|
{
|
|
sHSKM = "客户";
|
|
}
|
|
if (ds.Tables[0].Rows[0]["ISDEPTACC"].ToString() == "True")
|
|
{
|
|
sHSKM = "部门";
|
|
}
|
|
if (ds.Tables[0].Rows[0]["ISEMPLACC"].ToString() == "True")
|
|
{
|
|
sHSKM = "人员";
|
|
}
|
|
if (ds.Tables[0].Rows[0]["ISITEMACC"].ToString() == "True")
|
|
{
|
|
sHSKM = "项目";
|
|
}
|
|
}
|
|
}
|
|
strCondition = "";
|
|
|
|
#region 基本变量
|
|
|
|
string strParam1 = "";
|
|
string strParam2 = "";
|
|
switch (sHSKM)
|
|
{
|
|
case "客户":
|
|
if (!string.IsNullOrEmpty(strInquireField))
|
|
{
|
|
strParam1 = " and CUSTOMERNAME='" + strInquireField + "'";
|
|
}
|
|
break;
|
|
case "部门":
|
|
if (!string.IsNullOrEmpty(strInquireField))
|
|
{
|
|
strParam1 = " and DEPTNAME='" + strInquireField + "'";
|
|
}
|
|
break;
|
|
case "人员":
|
|
if (!string.IsNullOrEmpty(strInquireField))
|
|
{
|
|
strParam1 = " and SALE='" + strInquireField + "'";
|
|
}
|
|
break;
|
|
case "项目":
|
|
if (!string.IsNullOrEmpty(strInquireField))
|
|
{
|
|
strParam1 = " and ITEMNAME='" + strInquireField + "'";
|
|
}
|
|
break;
|
|
default:
|
|
if (!string.IsNullOrEmpty(strInquireField))
|
|
{
|
|
strParam2 = " and LINKACCID = (select top 1 ACCID from cw_accitems_gl where ACCNAME='" + strInquireField + "' and [STARTGID]='" + strCwSTARTGID + "')";
|
|
}
|
|
break;
|
|
}
|
|
|
|
#endregion
|
|
if (sumfieldtype == "本期合计")
|
|
{
|
|
strCondition = "ACCDATE>='" + strACCDATE + "' and ACCDATE<='" + strACCDATE + "'";
|
|
}
|
|
else if (sumfieldtype == "本年累计")
|
|
{
|
|
strCondition = "ACCDATE>='" + DateTime.Today.Year.ToString() + "-01' and ACCDATE<='" + DateTime.Today.Year.ToString() + "-12'";
|
|
}
|
|
#region 基本查询语句
|
|
StringBuilder strSql = new StringBuilder();
|
|
if (strCURRENCY.Trim() == "综合本位币")
|
|
{
|
|
#region 综合本位币
|
|
strSql.Append("select LINKACCID,GID,ORDNO,VKNO,VOUNO,VOUDATE,EXPLAN,EXPLAN2,DC=(SELECT top 1 DC FROM cw_accitems_gl WHERE GID=a.LINKGID),DR,CR,isnull((CASE WHEN DC='借' THEN (DR-CR) ELSE (CR-DR) END),0) as BLC,'" + createUser + "' as [CREATEUSER],'" + corpID + "' as [CORPID] from (select GID,ORDNO,LINKACCID=(SELECT top 1 ACCID FROM cw_accitems_gl WHERE ACCID=VW_cw_vouchers_vouitems_gl.ACCID and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "'),LINKGID=(SELECT top 1 GID FROM cw_accitems_gl WHERE ACCID=VW_cw_vouchers_vouitems_gl.ACCID and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "'),VKNO,VOUNO,VOUDATE,(ACCYEAR+'-'+ACCMONTH) as ACCDATE,EXPLAN,2 as EXPLAN2,DC=(CASE WHEN DC='D' THEN '借' ELSE '贷' END),(case when isnull(AMTDR,0)=0 THEN isnull(convert(numeric(8,2),round(FCYDR*FCYEXRATE,2)),0) else isnull(AMTDR,0) END) as DR,(case when isnull(AMTCR,0)=0 THEN isnull(convert(numeric(8,2),round(FCYCR*FCYEXRATE,2)),0) else isnull(AMTCR,0) END) as CR from VW_cw_vouchers_vouitems_gl where STARTGID='" + strCwSTARTGID + "' and (ISDELETE=0 or ISDELETE is null) and ISCHECKED=1" + strParam1 + ") as a where (DR<>0 OR CR<>0) and LINKGID in (select GID from cw_accitems_gl where ACCID like '" + strACCID + "%' and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "') " + strParam2);
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
strSql.Append("order by VOUDATE asc ");
|
|
/*strSql.Append(" union ");
|
|
|
|
strSql.Append("(SELECT newid() as GID,'' as ORDNO,'' as VKNO,0 as VOUNO,CONVERT(varchar(100),(DATEADD(mm,1,(ACCDATE+'-01'))-1),23) as VOUDATE,'本期合计' as EXPLAN,3 as EXPLAN2,DC");
|
|
strSql.Append(",isnull(sum(QTYDR),0) as DR,isnull(sum(QTYCR),0) as CR,isnull(sum(QTYBLC),0) as BLC,'" + createUser + "' as [CREATEUSER],'" + corpID + "' as [CORPID]");
|
|
strSql.Append(" from (");
|
|
strSql.Append("select *,DC=(select top 1 DC from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and (QTYLASTBLC<>0 OR QTYDR<>0 OR QTYCR<>0 or QTYLASTDR<>0 or QTYLASTCR<>0) and LINKGID in (select GID from cw_accitems_gl where ACCID like '" + strACCID + "' and [YEAR]='" + sYear + "')" + strCustNAME2 + strDeptName2 + strSALE2 + strITEMNAME2);
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
//strSql.Append(" and CORPID='" + corpID + "'");
|
|
strSql.Append(") as a");
|
|
strSql.Append(" group by LINKGID,ACCDATE,DC)");*/
|
|
#endregion
|
|
}
|
|
else if (strCURRENCY.Trim() == "RMB")
|
|
{
|
|
#region RMB
|
|
strSql.Append("select LINKACCID,GID,ORDNO,VKNO,VOUNO,VOUDATE,EXPLAN,EXPLAN2,DC=(SELECT top 1 DC FROM cw_accitems_gl WHERE GID=a.LINKGID),DR,CR,BLC,'" + createUser + "' as [CREATEUSER],'" + corpID + "' as [CORPID] from (select GID,ORDNO,LINKACCID=(SELECT top 1 ACCID FROM cw_accitems_gl WHERE ACCID=VW_cw_vouchers_vouitems_gl.ACCID and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "'),LINKGID=(SELECT top 1 GID FROM cw_accitems_gl WHERE ACCID=VW_cw_vouchers_vouitems_gl.ACCID and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "'),VKNO,VOUNO,VOUDATE,(ACCYEAR+'-'+ACCMONTH) as ACCDATE,EXPLAN,2 as EXPLAN2,DC=(CASE WHEN DC='D' THEN '借' ELSE '贷' END),AMTDR as DR,AMTCR as CR,isnull((CASE WHEN DC='D' THEN (AMTDR-AMTCR) ELSE (AMTCR-AMTDR) END),0) as BLC from VW_cw_vouchers_vouitems_gl where STARTGID='" + strCwSTARTGID + "' and (ISDELETE=0 or ISDELETE is null) and ISCHECKED=1 and (AMTDR<>0 OR AMTCR<>0)" + strParam1 + " and (case when FCY='USD' then FCY else 'RMB' end)='" + strCURRENCY + "') as a where LINKGID in (select GID from cw_accitems_gl where ACCID like '" + strACCID + "%' and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "') " + strParam2);// and CURRENCY='" + strCURRENCY + "'
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
strSql.Append("order by VOUDATE asc ");
|
|
/*strSql.Append(" union ");
|
|
|
|
strSql.Append("(SELECT newid() as GID,'' as ORDNO,'' as VKNO,0 as VOUNO,CONVERT(varchar(100),(DATEADD(mm,1,(ACCDATE+'-01'))-1),23) as VOUDATE,'本期合计' as EXPLAN,3 as EXPLAN2,DC");
|
|
strSql.Append(",isnull(sum(AMTDR),0) as DR,isnull(sum(AMTCR),0) as CR,isnull(sum(AMTBLC),0) as BLC,'" + userid + "' as [CREATEUSER],'" + corpID + "' as [CORPID]");
|
|
strSql.Append(" from (");
|
|
strSql.Append("select *,DC=(select top 1 DC from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCURRENCY + "' and (QTYLASTBLC<>0 OR QTYDR<>0 OR QTYCR<>0 or QTYLASTDR<>0 or QTYLASTCR<>0) and LINKGID in (select GID from cw_accitems_gl where ACCID like '" + strACCID + "' and [YEAR]='" + sYear + "')" + strCustNAME2 + strDeptName2 + strSALE2 + strITEMNAME2);
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
//strSql.Append(" and CORPID='" + corpID + "'");
|
|
strSql.Append(") as a");
|
|
strSql.Append(" group by LINKGID,ACCDATE,DC)");*/
|
|
#endregion
|
|
}
|
|
else//外币
|
|
{
|
|
#region 外币
|
|
strSql.Append("select LINKACCID,GID,ORDNO,VKNO,VOUNO,VOUDATE,EXPLAN,EXPLAN2,DC=(SELECT top 1 DC FROM cw_accitems_gl WHERE GID=a.LINKGID),DR,CR,BLC,'" + createUser + "' as [CREATEUSER],'" + corpID + "' as [CORPID] from (select GID,ORDNO,LINKACCID=(SELECT top 1 ACCID FROM cw_accitems_gl WHERE ACCID=VW_cw_vouchers_vouitems_gl.ACCID and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "'),LINKGID=(SELECT top 1 GID FROM cw_accitems_gl WHERE ACCID=VW_cw_vouchers_vouitems_gl.ACCID and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "'),VKNO,VOUNO,VOUDATE,(ACCYEAR+'-'+ACCMONTH) as ACCDATE,EXPLAN,2 as EXPLAN2,DC=(CASE WHEN DC='D' THEN '借' ELSE '贷' END),FCYDR as DR,FCYCR as CR,isnull((CASE WHEN DC='D' THEN (FCYDR-FCYCR) ELSE (FCYCR-FCYDR) END),0) as BLC from VW_cw_vouchers_vouitems_gl where STARTGID='" + strCwSTARTGID + "' and (ISDELETE=0 or ISDELETE is null) and ISCHECKED=1 and (FCYDR<>0 OR FCYCR<>0)" + strParam1 + " and (case when FCY='USD' then FCY else 'RMB' end)='" + strCURRENCY + "') as a where LINKGID in (select GID from cw_accitems_gl where ACCID like '" + strACCID + "%' and STARTGID='" + strCwSTARTGID + "' and [YEAR]='" + sYear + "' )" + strParam2);// and CURRENCY='" + strCURRENCY + "'
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
strSql.Append("order by VOUDATE asc ");
|
|
/*strSql.Append(" union ");
|
|
|
|
strSql.Append("(SELECT newid() as GID,'' as ORDNO,'' as VKNO,0 as VOUNO,CONVERT(varchar(100),(DATEADD(mm,1,(ACCDATE+'-01'))-1),23) as VOUDATE,'本期合计' as EXPLAN,3 as EXPLAN2,DC");
|
|
strSql.Append(",isnull(sum(FCYDR),0) as DR,isnull(sum(FCYCR),0) as CR,isnull(sum(FCYBLC),0) as BLC,'" + userid + "' as [CREATEUSER],'" + corpID + "' as [CORPID]");
|
|
strSql.Append(" from (");
|
|
strSql.Append("select *,DC=(select top 1 DC from [cw_accitems_gl] where gid=cw_genleg_accitems.LINKGID) from cw_genleg_accitems where ISDELETE=0 and ISENABLE=1 and CURRENCY='" + strCURRENCY + "' and (QTYLASTBLC<>0 OR QTYDR<>0 OR QTYCR<>0 or QTYLASTDR<>0 or QTYLASTCR<>0) and LINKGID in (select GID from cw_accitems_gl where ACCID like '" + strACCID + "' and [YEAR]='" + sYear + "')" + strCustNAME2 + strDeptName2 + strSALE2 + strITEMNAME2);
|
|
if (!string.IsNullOrEmpty(strCondition))
|
|
{
|
|
strSql.Append(" and " + strCondition);
|
|
}
|
|
//strSql.Append(" and CORPID='" + corpID + "'");
|
|
strSql.Append(") as a");
|
|
strSql.Append(" group by LINKGID,ACCDATE,DC)");*/
|
|
#endregion
|
|
}
|
|
#endregion
|
|
|
|
Database db = DatabaseFactory.CreateDatabase();
|
|
string evList = string.Empty;
|
|
evList = "[";
|
|
|
|
using (IDataReader reader = db.ExecuteReader(CommandType.Text, strSql.ToString()))
|
|
{
|
|
var i = 1;
|
|
while (reader.Read())
|
|
{
|
|
evList += "{";
|
|
//evList += "MONTHNAME:\"" + Convert.ToString(reader["MONTHNAME"]) + "\",MBLNO:\"" + Convert.ToString(reader["MBLNO"]) + "\",CUSTOMERNAME:\"" + Convert.ToString(reader["CUSTOMERNAME"]) + "\",CNTRTOTAL:\"" + Convert.ToString(reader["CNTRTOTAL"]) + "\",PORTDISCHARGE:\"" + Convert.ToString(reader["PORTDISCHARGE"]) + "\",OP:\"" + Convert.ToString(reader["OP"]) + "\",SALE:\"" + Convert.ToString(reader["SALE"]) + "\",BSSOURCE:\"" + Convert.ToString(reader["BSSOURCE"]) + "\",BSTYPE:\"" + Convert.ToString(reader["BSTYPE"]) + "\",LANE:\"" + Convert.ToString(reader["LANE"]) + "\",RMBAMOUNT:\"" + Convert.ToString(reader["RMBAMOUNT"]) + "\",SUMRMBAMOUNT:\"" + Convert.ToString(reader["SUMRMBAMOUNT"]) + "\",USDAMOUNT:\"" + Convert.ToString(reader["USDAMOUNT"]) + "\",SUMUSDAMOUNT:\"" + Convert.ToString(reader["SUMUSDAMOUNT"]) + "\",OTAMOUNT:\"" + Convert.ToString(reader["OTAMOUNT"]) + "\",SUMOTAMOUNT:\"" + Convert.ToString(reader["SUMOTAMOUNT"]) + "\",TTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["TTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",SUMTTLAMOUNT:\"" + Math.Round(decimal.Parse(Convert.ToString(reader["SUMTTLAMOUNT"])), 2, MidpointRounding.AwayFromZero) + "\",INPUTBY:\"" + Convert.ToString(reader["INPUTBY"]) + "\"";
|
|
//OBJNAME, OBJNUM, ACCATTRIBUTE, ACCNAME, DC, ACCDATE, ACCTYPE
|
|
//evList += "OBJNAME:\"" + Convert.ToString(reader["OBJNAME"]) + "\",OBJNUM:\"" + Convert.ToString(reader["OBJNUM"]) + "\",ACCATTRIBUTE:\"" + Convert.ToString(reader["ACCATTRIBUTE"]) + "\",ACCNAME:\"" + Convert.ToString(reader["ACCNAME"]) + "\",DC:\"" + Convert.ToString(reader["DC"]) + "\",ACCDATE:\"" + Convert.ToString(reader["ACCDATE"]) + "\",ACCTYPE:\"" + Convert.ToString(reader["ACCTYPE"]) + "\"";
|
|
evList += "VOUDATE:\"" + Convert.ToString(reader["VOUDATE"]) + "\",VKNO:\"" + Convert.ToString(reader["VKNO"]) + "\",VOUNO:\"" + Convert.ToString(reader["VOUNO"]) + "\",EXPLAN:\"" + Convert.ToString(reader["EXPLAN"]) + "\",DR:\"" + Convert.ToString(reader["DR"]) + "\",CR:\"" + Convert.ToString(reader["CR"]) + "\",DC:\"" + Convert.ToString(reader["DC"]) + "\"";
|
|
evList += "},";
|
|
i = i + 1;
|
|
}
|
|
reader.Close();
|
|
}
|
|
|
|
evList = evList.Substring(0, evList.Length - 1);
|
|
evList += "]";
|
|
|
|
return evList;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|